2012-03-17 17:30:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Miguel Angel Ajo <miguelangel@nbee.es>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file wx.i
|
|
|
|
* @brief wx wrappers for basic things, wxString, wxPoint, wxRect, etc..
|
2012-07-06 19:10:55 +00:00
|
|
|
* all the wx objects are very complex, and we don't want to pull
|
|
|
|
* and swig all depending objects, so we just define the methods
|
|
|
|
* we want to wrap.
|
2012-03-17 17:30:03 +00:00
|
|
|
*/
|
2012-03-05 22:49:49 +00:00
|
|
|
|
2012-03-10 21:40:41 +00:00
|
|
|
%{
|
2012-03-11 19:07:10 +00:00
|
|
|
#include <wx_python_helpers.h>
|
2012-03-10 21:40:41 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
// encoding setup, ascii by default ///////////////////////////////////////////
|
|
|
|
|
|
|
|
void wxSetDefaultPyEncoding(const char* encoding);
|
|
|
|
const char* wxGetDefaultPyEncoding();
|
|
|
|
|
2017-03-17 14:41:00 +00:00
|
|
|
// wxCoord /////////////////////////////////////////////////////////
|
|
|
|
// need to let swig know that wxCoord is an int. Ref: wx/defs.h
|
|
|
|
typedef int wxCoord;
|
|
|
|
|
2012-04-05 21:41:45 +00:00
|
|
|
|
|
|
|
// wxRect class wrapper ///////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class wxRect
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxRect() : x(0), y(0), width(0), height(0) { }
|
|
|
|
wxRect(int xx, int yy, int ww, int hh): x(xx), y(yy), width(ww), height(hh) { }
|
|
|
|
wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
|
|
|
|
wxRect(const wxPoint& pt, const wxSize& size)
|
|
|
|
: x(pt.x), y(pt.y), width(size.x), height(size.y) { }
|
|
|
|
wxRect(const wxSize& size): x(0), y(0), width(size.x), height(size.y) { }
|
|
|
|
|
|
|
|
int GetX() const { return x; }
|
|
|
|
void SetX(int xx) { x = xx; }
|
|
|
|
|
|
|
|
int GetY() const { return y; }
|
|
|
|
void SetY(int yy) { y = yy; }
|
|
|
|
|
|
|
|
int GetWidth() const { return width; }
|
|
|
|
void SetWidth(int w) { width = w; }
|
2014-10-28 19:43:12 +00:00
|
|
|
|
2012-04-05 21:41:45 +00:00
|
|
|
int GetHeight() const { return height; }
|
|
|
|
void SetHeight(int h) { height = h; }
|
|
|
|
|
|
|
|
wxPoint GetPosition() const { return wxPoint(x, y); }
|
|
|
|
void SetPosition( const wxPoint &p ) { x = p.x; y = p.y; }
|
2014-10-28 19:43:12 +00:00
|
|
|
|
2012-04-05 21:41:45 +00:00
|
|
|
int x, y, width, height;
|
2014-10-28 19:43:12 +00:00
|
|
|
|
|
|
|
%extend
|
|
|
|
{
|
2012-07-06 19:10:55 +00:00
|
|
|
/* extend the wxRect object so it can be converted into a tuple */
|
2014-10-28 19:43:12 +00:00
|
|
|
PyObject* Get()
|
2012-04-05 21:41:45 +00:00
|
|
|
{
|
|
|
|
PyObject* res = PyTuple_New(4);
|
|
|
|
PyTuple_SET_ITEM(res, 0, PyInt_FromLong(self->x));
|
|
|
|
PyTuple_SET_ITEM(res, 1, PyInt_FromLong(self->y));
|
|
|
|
PyTuple_SET_ITEM(res, 2, PyInt_FromLong(self->width));
|
|
|
|
PyTuple_SET_ITEM(res, 3, PyInt_FromLong(self->height));
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2014-10-28 19:43:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
%pythoncode
|
2012-04-05 21:41:45 +00:00
|
|
|
{
|
2014-10-28 19:43:12 +00:00
|
|
|
|
|
|
|
def __eq__(self,other):
|
|
|
|
return self.x==other.x and self.y==other.y and self.width==other.width and self.height==other.height
|
2012-04-05 21:41:45 +00:00
|
|
|
def __str__(self): return str(self.Get())
|
|
|
|
def __repr__(self): return 'wxRect'+str(self.Get())
|
|
|
|
def __len__(self): return len(self.Get())
|
|
|
|
def __getitem__(self, index): return self.Get()[index]
|
|
|
|
def __setitem__(self, index, val):
|
2014-10-28 19:43:12 +00:00
|
|
|
if index == 0: self.SetX(val)
|
|
|
|
elif index == 1: self.SetY(val)
|
|
|
|
elif index == 2: self.SetWidth(val)
|
|
|
|
elif index == 3: self.SetHeight(val)
|
|
|
|
else: raise IndexError
|
2012-04-05 21:41:45 +00:00
|
|
|
def __nonzero__(self): return self.Get() != (0,0,0,0)
|
|
|
|
__safe_for_unpickling__ = True
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// wxSize class wrapper ///////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class wxSize
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int x,y;
|
|
|
|
wxSize(int xx, int yy) : x(xx), y(yy) { }
|
2012-04-08 14:25:49 +00:00
|
|
|
wxSize(double xx, double yy) : x(xx), y(yy) {}
|
2014-10-28 19:43:12 +00:00
|
|
|
%extend
|
|
|
|
{
|
|
|
|
PyObject* Get()
|
2012-04-05 21:41:45 +00:00
|
|
|
{
|
|
|
|
PyObject* res = PyTuple_New(2);
|
|
|
|
PyTuple_SET_ITEM(res, 0, PyInt_FromLong(self->x));
|
|
|
|
PyTuple_SET_ITEM(res, 1, PyInt_FromLong(self->y));
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2014-10-28 19:43:12 +00:00
|
|
|
|
2012-04-05 21:41:45 +00:00
|
|
|
~wxSize();
|
2014-10-28 19:43:12 +00:00
|
|
|
|
2012-04-05 21:41:45 +00:00
|
|
|
void SetWidth(int w);
|
|
|
|
void SetHeight(int h);
|
|
|
|
int GetWidth() const;
|
|
|
|
int GetHeight() const;
|
2014-10-28 19:43:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
%pythoncode
|
2012-04-05 21:41:45 +00:00
|
|
|
{
|
2014-10-28 19:43:12 +00:00
|
|
|
def Scale(self,xscale,yscale):
|
|
|
|
return wxSize(self.x*xscale,self.y*yscale)
|
|
|
|
def __eq__(self,other):
|
|
|
|
return self.GetWidth()==other.GetWidth() and self.GetHeight()==other.GetHeight()
|
|
|
|
def __str__(self): return str(self.Get())
|
|
|
|
def __repr__(self): return 'wxSize'+str(self.Get())
|
|
|
|
def __len__(self): return len(self.Get())
|
|
|
|
def __getitem__(self, index): return self.Get()[index]
|
|
|
|
def __setitem__(self, index, val):
|
|
|
|
if index == 0: self.SetWidth(val)
|
|
|
|
elif index == 1: self.SetHeight(val)
|
|
|
|
else: raise IndexError
|
|
|
|
def __nonzero__(self): return self.Get() != (0,0)
|
|
|
|
__safe_for_unpickling__ = True
|
|
|
|
|
2012-04-05 21:41:45 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-03-10 21:40:41 +00:00
|
|
|
// wxPoint class wrapper to (xx,yy) tuple /////////////////////////////////////
|
2012-03-05 22:49:49 +00:00
|
|
|
|
|
|
|
class wxPoint
|
2014-10-28 19:43:12 +00:00
|
|
|
{
|
2012-03-05 22:49:49 +00:00
|
|
|
public:
|
|
|
|
int x, y;
|
|
|
|
wxPoint(int xx, int yy);
|
2012-04-08 14:25:49 +00:00
|
|
|
wxPoint(double xx, double yy) : x(xx), y(yy) {}
|
2012-03-05 22:49:49 +00:00
|
|
|
~wxPoint();
|
|
|
|
%extend {
|
2012-03-10 21:40:41 +00:00
|
|
|
wxPoint __add__(const wxPoint& pt) { return *self + pt; }
|
|
|
|
wxPoint __sub__(const wxPoint& pt) { return *self - pt; }
|
2012-03-05 22:49:49 +00:00
|
|
|
|
2012-03-10 21:40:41 +00:00
|
|
|
void Set(long x, long y) { self->x = x; self->y = y; }
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
PyObject* Get()
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
{
|
2012-03-05 22:49:49 +00:00
|
|
|
PyObject* tup = PyTuple_New(2);
|
|
|
|
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
|
|
|
|
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
|
|
|
|
return tup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
%pythoncode {
|
2012-03-10 21:40:41 +00:00
|
|
|
def __eq__(self,other): return (self.x==other.x and self.y==other.y)
|
|
|
|
def __ne__(self,other): return not (self==other)
|
|
|
|
def __str__(self): return str(self.Get())
|
|
|
|
def __repr__(self): return 'wxPoint'+str(self.Get())
|
|
|
|
def __len__(self): return len(self.Get())
|
|
|
|
def __getitem__(self, index): return self.Get()[index]
|
2012-03-05 22:49:49 +00:00
|
|
|
def __setitem__(self, index, val):
|
2014-10-28 19:43:12 +00:00
|
|
|
if index == 0:
|
2012-03-10 21:40:41 +00:00
|
|
|
self.x = val
|
2014-10-28 19:43:12 +00:00
|
|
|
elif index == 1:
|
2012-03-10 21:40:41 +00:00
|
|
|
self.y = val
|
2014-10-28 19:43:12 +00:00
|
|
|
else:
|
2012-03-10 21:40:41 +00:00
|
|
|
raise IndexError
|
2012-03-05 22:49:49 +00:00
|
|
|
def __nonzero__(self): return self.Get() != (0,0)
|
2012-03-10 21:40:41 +00:00
|
|
|
|
2012-03-05 22:49:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-03-10 21:40:41 +00:00
|
|
|
|
2012-07-06 19:10:55 +00:00
|
|
|
// wxChar typemaps ///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/* they handle the conversion from/to strings */
|
2012-03-10 21:40:41 +00:00
|
|
|
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
%typemap(in) wxChar { wxString str = Py2wxString($input); $1 = str[0]; }
|
2012-03-10 21:40:41 +00:00
|
|
|
%typemap(out) wxChar { wxString str($1); $result = wx2PyString(str); }
|
|
|
|
|
|
|
|
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
// wxString /////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/*
|
|
|
|
The wxString typemaps below are sufficient to handle two cases but not
|
|
|
|
a third.
|
|
|
|
|
|
|
|
1) Arguments into wrapped C++ functions taking wxString as parameters can be
|
|
|
|
passed as python strings, not wxString. In fact you cannot create a wxString
|
|
|
|
from python, only in C++.
|
|
|
|
|
|
|
|
2) Wrapped C++ functions returning wxString will have that wxString
|
|
|
|
converted to a python unicode or string automatically.
|
|
|
|
|
|
|
|
Both of these features are a result of the wxString typemaps below. Note
|
|
|
|
that this philosophy is very agreeable, and is consistent with the
|
|
|
|
philosophy adopted by wxPython. In fact one might wish that KiCad did not
|
|
|
|
use wxString in any of its data structures, and merely used UTF8s, which
|
|
|
|
will convert automatically to and from wxString when needed.
|
|
|
|
|
|
|
|
There is another case that typemaps to not address, and no, this is not the
|
|
|
|
construction of wxString from python, but rather the examination of wxString
|
|
|
|
in situ, i.e. in a data structure within the BOARD. It does not match either
|
|
|
|
case above. So the class wxString {} spec block below is in here to allow
|
|
|
|
examination of a wxString's value when operating python interactively or
|
|
|
|
when printing a value in situ that was not returned from a wrapped function.
|
|
|
|
Remember wxString return values of functions are converted by the typemaps.
|
|
|
|
|
2021-04-05 13:24:57 +00:00
|
|
|
No wxString constructor is given to SWIG, since wxString construction is
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
always done in C++, but python needs to know that it can delete a wxString
|
|
|
|
when necessary. And most importantly we need to see a string's contents so
|
|
|
|
the __str__() function must show content.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
class wxString
|
2012-03-10 21:40:41 +00:00
|
|
|
{
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
public:
|
|
|
|
// this is not C++ source, it is SWIG interface spec
|
|
|
|
virtual ~wxString();
|
|
|
|
|
|
|
|
%extend
|
|
|
|
{
|
|
|
|
PyObject* __str__()
|
|
|
|
{
|
|
|
|
%#if wxUSE_UNICODE
|
|
|
|
return PyUnicode_FromWideChar( $self->c_str(), $self->Len() );
|
|
|
|
%#else
|
|
|
|
return PyString_FromStringAndSize( $self->c_str(), $self->Len() );
|
|
|
|
%#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
%pythoncode
|
|
|
|
{
|
|
|
|
def __repr__(self): return 'wxString(\'' + self.__str__() + '\')'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// wxString typemaps
|
|
|
|
|
|
|
|
%typemap(in) wxString {
|
|
|
|
wxString* sptr = newWxStringFromPy($input);
|
|
|
|
if (sptr == NULL) SWIG_fail;
|
|
|
|
$1 = *sptr;
|
|
|
|
delete sptr;
|
2012-03-10 21:40:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
%typemap(out) wxString
|
2012-04-23 06:59:37 +00:00
|
|
|
{
|
2012-03-10 21:40:41 +00:00
|
|
|
%#if wxUSE_UNICODE
|
|
|
|
$result = PyUnicode_FromWideChar($1.c_str(), $1.Len());
|
|
|
|
%#else
|
|
|
|
$result = PyString_FromStringAndSize($1.c_str(), $1.Len());
|
|
|
|
%#endif
|
|
|
|
}
|
|
|
|
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
%typemap(varout) wxString
|
2012-04-23 06:59:37 +00:00
|
|
|
{
|
2012-03-10 21:40:41 +00:00
|
|
|
%#if wxUSE_UNICODE
|
|
|
|
$result = PyUnicode_FromWideChar($1.c_str(), $1.Len());
|
|
|
|
%#else
|
|
|
|
$result = PyString_FromStringAndSize($1.c_str(), $1.Len());
|
|
|
|
%#endif
|
|
|
|
}
|
|
|
|
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
%typemap(in) wxString& (bool temp=false)
|
2012-03-10 21:40:41 +00:00
|
|
|
{
|
|
|
|
$1 = newWxStringFromPy($input);
|
|
|
|
if ($1 == NULL) SWIG_fail;
|
|
|
|
temp = true;
|
|
|
|
}
|
|
|
|
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
|
|
|
|
%typemap(out) wxString&
|
|
|
|
{
|
|
|
|
%#if wxUSE_UNICODE
|
|
|
|
$result = PyUnicode_FromWideChar($1->c_str(), $1->Len());
|
|
|
|
%#else
|
|
|
|
$result = PyString_FromStringAndSize($1->c_str(), $1->Len());
|
|
|
|
%#endif
|
|
|
|
}
|
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
%typemap(freearg) wxString&
|
2012-03-10 21:40:41 +00:00
|
|
|
{
|
|
|
|
if (temp$argnum)
|
|
|
|
delete $1;
|
|
|
|
}
|
|
|
|
|
|
|
|
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxString& {
|
|
|
|
$1 = PyString_Check($input) || PyUnicode_Check($input);
|
|
|
|
}
|
|
|
|
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
%apply wxString& { wxString* }
|
|
|
|
|
2012-03-10 21:40:41 +00:00
|
|
|
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
// wxArrayString //////////////////////////////////////////////////////
|
2012-04-23 06:59:37 +00:00
|
|
|
%typemap(in) wxArrayString& (bool temp=false) {
|
2014-10-28 19:43:12 +00:00
|
|
|
if (!PySequence_Check($input))
|
2012-04-23 06:59:37 +00:00
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Not a sequence of strings");
|
|
|
|
SWIG_fail;
|
|
|
|
}
|
2014-10-28 19:43:12 +00:00
|
|
|
|
2012-04-23 06:59:37 +00:00
|
|
|
$1 = new wxArrayString;
|
|
|
|
temp = true;
|
|
|
|
int last=PySequence_Length($input);
|
2014-10-28 19:43:12 +00:00
|
|
|
for (int i=0; i<last; i++)
|
2012-04-23 06:59:37 +00:00
|
|
|
{
|
|
|
|
PyObject* pyStr = PySequence_GetItem($input, i);
|
|
|
|
wxString* wxS = newWxStringFromPy(pyStr);
|
2014-10-28 19:43:12 +00:00
|
|
|
if (PyErr_Occurred())
|
2012-04-23 06:59:37 +00:00
|
|
|
SWIG_fail;
|
|
|
|
$1->Add(*wxS);
|
|
|
|
delete wxS;
|
|
|
|
Py_DECREF(pyStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
%typemap(freearg) wxArrayString&
|
2012-04-23 06:59:37 +00:00
|
|
|
{
|
2014-10-28 19:43:12 +00:00
|
|
|
if (temp$argnum)
|
2012-04-23 06:59:37 +00:00
|
|
|
delete $1;
|
|
|
|
}
|
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
%typemap(out) wxArrayString&
|
2012-04-23 06:59:37 +00:00
|
|
|
{
|
|
|
|
$result = wxArrayString2PyList(*$1);
|
|
|
|
}
|
|
|
|
|
2014-10-28 19:43:12 +00:00
|
|
|
%typemap(out) wxArrayString
|
2012-04-23 06:59:37 +00:00
|
|
|
{
|
|
|
|
$result = wxArrayString2PyList($1);
|
|
|
|
}
|
2012-03-10 21:40:41 +00:00
|
|
|
|
2015-04-16 15:26:51 +00:00
|
|
|
%template(wxPoint_Vector) std::vector<wxPoint>;
|