Commit 9398eb97 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo
Browse files

std::vector and std::string items

DLIST iterator code, now we can do:

    for module in pcb.m_Modules:
    	print module.GetReference()

instead of:

    module = pcb.m_Modules

    while module:
	print module.GetReference()
	module = module.Next()

or even:
    module_list = list(pcb.m_Modules)
parent 7a256041
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -180,9 +180,10 @@ BOARD *GetBoard();
%template(TRACK_List)      DLIST<TRACK>;
%template(TRACK_List)      DLIST<TRACK>;
%template(PAD_List)        DLIST<D_PAD>;
%template(PAD_List)        DLIST<D_PAD>;


/* TODO: -the std::* compilatio is broken with some swig + gcc combinations 
 
 *        see kicad.i for more information.

 * %template(MARKER_Vector) std::vector<MARKER_PCB*>;
%template(MARKER_Vector) std::vector<MARKER_PCB*>;
 * %template(ZONE_CONTAINER_Vector) std::vector<ZONE_CONTAINER*>;
%template(ZONE_CONTAINER_Vector) std::vector<ZONE_CONTAINER*>;
 */
%template(VIA_DIMENSION_Vector) std::vector<VIA_DIMENSION>;

+33 −6
Original line number Original line Diff line number Diff line
@@ -30,10 +30,12 @@


/* OFF NOW, it triggers an error with GCC 4.6 and swig-2.0.4 or trunk.. 
/* OFF NOW, it triggers an error with GCC 4.6 and swig-2.0.4 or trunk.. 
   http://sourceforge.net/tracker/index.php?func=detail&aid=3391906&group_id=1645&atid=101645
   http://sourceforge.net/tracker/index.php?func=detail&aid=3391906&group_id=1645&atid=101645
*/



   %include <std_vector.i>
   %include <std_vector.i>
   %include <std_string.i>
   %include <std_string.i>
*/

%nodefaultctor EDA_ITEM;
%nodefaultctor EDA_ITEM;




@@ -48,6 +50,7 @@
%ignore GetCommandOptions;
%ignore GetCommandOptions;


%{
%{
  #include <cstddef>
	#include <dlist.h>
	#include <dlist.h>
	#include <base_struct.h>
	#include <base_struct.h>
	#include <common.h>
	#include <common.h>
@@ -63,7 +66,6 @@
/* all the wx wrappers for wxString, wxPoint, wxRect, wxChar .. */
/* all the wx wrappers for wxString, wxPoint, wxRect, wxChar .. */
%include <wx.i>
%include <wx.i>



%include <dlist.h>
%include <dlist.h>
%include <base_struct.h>
%include <base_struct.h>
%include <common.h>
%include <common.h>
@@ -71,9 +73,34 @@
%include <class_colors_design_settings.h>
%include <class_colors_design_settings.h>




/*
%extend DLIST
namespace std 
{
{
	%template(intVector) vector<int>;
	%pythoncode
	{
		class DLISTIter:
			def __init__(self,aList):
				self.last = aList
		
			def next(self):
				if self.last is None: 
					raise StopIteration
				else:
					ret = None
					
					# first item in list has "Get" as a DLIST
					try:
						ret = self.last.Get()
					except: 
						ret = self.last #next items just not..
					
					self.last = self.last.Next()
					return ret
	
		def __iter__(self):
			return self.DLISTIter(self)
			
	}
	}
*/
}
%template(intVector) std::vector<int>;