From ad25f4c43a08da7382433cc80423b2a1b1caf4d4 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Fri, 6 Jul 2012 21:10:55 +0200 Subject: [PATCH] Cleanup toward test-merge --- pcbnew/class_footprint_wizard.cpp | 19 +++++++----- pcbnew/class_footprint_wizard.h | 4 ++- pcbnew/footprint_wizard_frame.h | 49 ++++++++++++++++++++++--------- scripting/dlist.i | 9 +++--- scripting/fixswigimports.py | 7 +++-- scripting/kicad.i | 23 +++++++-------- scripting/kicadplugins.i | 48 ++++++++++++++++++++---------- scripting/wx.i | 10 +++++-- 8 files changed, 111 insertions(+), 58 deletions(-) diff --git a/pcbnew/class_footprint_wizard.cpp b/pcbnew/class_footprint_wizard.cpp index fd76899b54..3bc232b882 100644 --- a/pcbnew/class_footprint_wizard.cpp +++ b/pcbnew/class_footprint_wizard.cpp @@ -8,26 +8,31 @@ void FOOTPRINT_WIZARD::register_wizard() { - FOOTPRINT_WIZARDS::register_wizard(this); + FOOTPRINT_WIZARDS::register_wizard( this ); } +/** + * FOOTPRINT_WIZARD system wide static list + */ std::vector FOOTPRINT_WIZARDS::m_FootprintWizards; -FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard(int aIndex) +FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( int aIndex ) { return m_FootprintWizards[aIndex]; } -FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard(wxString aName) +FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName ) { int max = GetSize(); - for(int i=0; iGetName(); - if (name.Cmp(aName)) + + if ( name.Cmp(aName) ) return wizard; } @@ -45,7 +50,7 @@ void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard) wxString name = aWizard->GetName(); m_FootprintWizards.push_back(aWizard); - printf("Registered footprint wizard '%s'\n",(const char*)name.mb_str() ); + //printf("Registered footprint wizard '%s'\n",(const char*)name.mb_str() ); } diff --git a/pcbnew/class_footprint_wizard.h b/pcbnew/class_footprint_wizard.h index 08a9d049bf..7e0e3bf347 100644 --- a/pcbnew/class_footprint_wizard.h +++ b/pcbnew/class_footprint_wizard.h @@ -8,7 +8,9 @@ #include #include -/* This is the parent class from where any footprint wiizard class must +/** + * Class FOOTPRINT_WIZARD + * This is the parent class from where any footprint wizard class must * derive */ class FOOTPRINT_WIZARD { diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index 584445cf89..34f19c7290 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -46,19 +46,19 @@ class wxGridEvent; class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_FRAME { private: - // List of libraries (for selection ) - wxSashLayoutWindow* m_PageListWindow; - wxListBox* m_PageList; // The list of pages - wxSize m_PageListSize; // size of the window + + wxSashLayoutWindow* m_PageListWindow; //< List of libraries (for selection ) + wxListBox* m_PageList; //< The list of pages + wxSize m_PageListSize; //< size of the window - // List of components in the selected library - wxSashLayoutWindow* m_ParameterGridWindow; - wxGrid* m_ParameterGrid; // The list of parameters - wxSize m_ParameterGridSize; // size of the window + + wxSashLayoutWindow* m_ParameterGridWindow; //< List of components in the selected library + wxGrid* m_ParameterGrid; //< The list of parameters + wxSize m_ParameterGridSize; //< size of the window // Flags - wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog - wxString m_configPath; // subpath for configuration + wxSemaphore* m_Semaphore; //< != NULL if the frame must emulate a modal dialog + wxString m_configPath; //< subpath for configuration FOOTPRINT_WIZARD* m_FootprintWizard; @@ -86,19 +86,40 @@ private: void OnSashDrag( wxSashEvent& event ); /** - * Function ReCreateLibraryList - * - * Creates or recreates the list of current loaded libraries. - * This list is sorted, with the library cache always at end of the list + * Function ReCreatePageList + * Creates or recreates the list of parameter pages for the current wizard. + * This list is sorted */ void ReCreatePageList(); + + /** + * Function ReCreateParameterList + * Creates the list of parameters for the current page + */ void ReCreateParameterList(); + + /** + * Function SelectFootprintWizard + * Shows the list of footprint wizards available into the system + */ void SelectFootprintWizard(); + + /** + * Function ReloadFootprint + * Reloads the current footprint + */ void ReloadFootprint(); void Process_Special_Functions( wxCommandEvent& event ); + + /** + * Function DisplayWizardInfos + * Shows all the details about the current wizard + */ void DisplayWizardInfos(); + + void RedrawActiveWindow( wxDC* DC, bool EraseBg ); void OnCloseWindow( wxCloseEvent& Event ); void ReCreateHToolbar(); diff --git a/scripting/dlist.i b/scripting/dlist.i index c05c6a237f..aa3f5e25ad 100644 --- a/scripting/dlist.i +++ b/scripting/dlist.i @@ -6,9 +6,9 @@ { class DLISTIter: def __init__(self,aList): - self.last = aList + self.last = aList # last item is the start of list - def next(self): + def next(self): # get the next item item = self.last try: @@ -16,7 +16,7 @@ except: pass - if item is None: + if item is None: # if the item is None, then finish the iteration raise StopIteration else: ret = None @@ -25,11 +25,12 @@ try: ret = self.last.Get() except: - ret = self.last #next items just not.. + ret = self.last # next items do not.. self.last = self.last.Next() # when the iterated object can be casted down in inheritance, just do it.. + if 'Cast' in dir(ret): ret = ret.Cast() diff --git a/scripting/fixswigimports.py b/scripting/fixswigimports.py index add960fa81..ece19a2e54 100755 --- a/scripting/fixswigimports.py +++ b/scripting/fixswigimports.py @@ -27,7 +27,6 @@ f = open(filename,"rb") lines = f.readlines() f.close() -f = open(filename,"wb") doneOk = False @@ -35,14 +34,18 @@ if (len(lines)<4000): print "still building" exit(0) +txt = "" + for l in lines: if l.startswith("if version_info >= (2,6,0):"): l = l.replace("version_info >= (2,6,0)","False") doneOk = True elif l.startswith("if False:"): # it was already patched? doneOk = True - f.write(l) + txt = txt + l +f = open(filename,"wb") +f.write(txt) f.close() if doneOk: diff --git a/scripting/kicad.i b/scripting/kicad.i index 7029044e1d..71b00bc7fe 100644 --- a/scripting/kicad.i +++ b/scripting/kicad.i @@ -27,14 +27,8 @@ * @brief General wrappers for kicad / wx structures and classes */ - -/* 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 -*/ - - - %include - %include +%include +%include /* ignore some constructors of EDA_ITEM that will make the build fail */ @@ -44,11 +38,12 @@ %ignore EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ); /* swig tries to wrap SetBack/SetNext on derived classes, but this method is - private for most childs, so if we don't ignore it it won't compile */ + private for most childs, so if we don't ignore it won't compile */ %ignore EDA_ITEM::SetBack; %ignore EDA_ITEM::SetNext; +/* ignore other functions that cause trouble */ %ignore InitKiCadAbout; %ignore GetCommandOptions; @@ -57,9 +52,10 @@ %ignore operator <<; %ignore operator=; +/* headers/imports that must be included in the _wrapper.cpp at top */ %{ - #include + #include #include #include #include @@ -72,7 +68,7 @@ #include #include #include - #include + #include %} @@ -95,6 +91,7 @@ } */ +/* header files that must be wrapped */ %include %include @@ -104,10 +101,12 @@ %include %include - +/* special iteration wrapper for DLIST objects */ %include "dlist.i" /* std template mappings */ %template(intVector) std::vector; +/* KiCad plugin handling */ %include "kicadplugins.i" + diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i index 1bdae479e0..b3b14d5743 100644 --- a/scripting/kicadplugins.i +++ b/scripting/kicadplugins.i @@ -22,9 +22,41 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + /** + * This file builds the base classes for all kind of python plugins that + * can be included into kicad. + * they provide generic code to all the classes: + * + * KiCadPlugin + * /|\ + * | + * |\-FilePlugin + * |\-FootprintWizardPlugin + * |\-ActionPlugin + * + * It defines the LoadPlugins() function that loads all the plugins + * available in the system + * + */ %pythoncode { +def LoadPlugins(): + import os + import sys + + plugins_dir = os.environ['HOME']+'/.kicad_plugins/' + + sys.path.append(plugins_dir) + + for module in os.listdir(plugins_dir): + if os.path.isdir(plugins_dir+module): + __import__(module, locals(), globals()) + + if module == '__init__.py' or module[-3:] != '.py': + continue + __import__(module[:-3], locals(), globals()) + # KiCadPlugin base class will register any plugin into the right place class KiCadPlugin: @@ -159,21 +191,5 @@ class ActionPlugin(KiCadPlugin): KiCadPlugin.__init__(self) -def LoadPlugins(): - import os - import sys - - plugins_dir = os.environ['HOME']+'/.kicad_plugins/' - - sys.path.append(plugins_dir) - - for module in os.listdir(plugins_dir): - if os.path.isdir(plugins_dir+module): - __import__(module, locals(), globals()) - - if module == '__init__.py' or module[-3:] != '.py': - continue - __import__(module[:-3], locals(), globals()) - } diff --git a/scripting/wx.i b/scripting/wx.i index 20ac1ec398..d3421bd94f 100644 --- a/scripting/wx.i +++ b/scripting/wx.i @@ -25,6 +25,9 @@ /** * @file wx.i * @brief wx wrappers for basic things, wxString, wxPoint, wxRect, etc.. + * 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. */ %{ @@ -67,7 +70,8 @@ public: int x, y, width, height; %extend - { + { + /* extend the wxRect object so it can be converted into a tuple */ PyObject* Get() { PyObject* res = PyTuple_New(4); @@ -191,7 +195,9 @@ public: }; -// wxChar wrappers /////////////////////////////////////////////////////////// +// wxChar typemaps /////////////////////////////////////////////////////////// + +/* they handle the conversion from/to strings */ %typemap(in) wxChar { wxString str = Py2wxString($input); $1 = str[0]; } %typemap(out) wxChar { wxString str($1); $result = wx2PyString(str); }