From 374808ac5b9283d94dfac1af2959ad4058809928 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 22 Sep 2016 19:12:36 -0500 Subject: [PATCH] Cleanup SWIG's board.i, remove scrap *.{ref,orig} files, and add .pyc to .gitignore --- .gitignore | 1 + common/swig/kicad.i.orig | 160 ---------------------------- pcbnew/swig/board.i | 71 +++++------- pcbnew/swig/board.i.orig | 0 pcbnew/swig/board.i.rej | 147 ------------------------- pcbnew/swig/board_connected_item.i | 7 ++ pcbnew/swig/board_design_settings.i | 4 + pcbnew/swig/module.i | 2 +- pcbnew/swig/pcbnew.i.orig | 0 pcbnew/swig/pcbnew.i.rej | 29 ----- pcbnew/swig/zone_settings.i | 4 + 11 files changed, 44 insertions(+), 381 deletions(-) delete mode 100644 common/swig/kicad.i.orig delete mode 100644 pcbnew/swig/board.i.orig delete mode 100644 pcbnew/swig/board.i.rej create mode 100644 pcbnew/swig/board_connected_item.i create mode 100644 pcbnew/swig/board_design_settings.i delete mode 100644 pcbnew/swig/pcbnew.i.orig delete mode 100644 pcbnew/swig/pcbnew.i.rej create mode 100644 pcbnew/swig/zone_settings.i diff --git a/.gitignore b/.gitignore index acff0235e7..0d7329ede8 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ install_manifest.txt Documentation/doxygen Documentation/development/doxygen *.bak +*.pyc .*.swp *~ build-* diff --git a/common/swig/kicad.i.orig b/common/swig/kicad.i.orig deleted file mode 100644 index 19fa123bf5..0000000000 --- a/common/swig/kicad.i.orig +++ /dev/null @@ -1,160 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo - * 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 kicad.i - * @brief General wrappers for kicad / wx structures and classes - */ - -%include -%include -%include -%include -%include -%include - -/* -http://www.swig.org/Doc3.0/CPlusPlus11.html -7.3.3 Hash tables - -The new hash tables in the STL are unordered_set, unordered_multiset, -unordered_map, unordered_multimap. These are not available in SWIG, but in -principle should be easily implemented by adapting the current STL containers. - -%include -*/ - -// ignore some constructors of EDA_ITEM that will make the build fail - -%nodefaultctor EDA_ITEM; -%ignore EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ); -%ignore EDA_ITEM::EDA_ITEM( KICAD_T idType ); -%ignore EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ); - - -%warnfilter(401) EDA_ITEM; -%warnfilter(509) UTF8; - -/* swig tries to wrap SetBack/SetNext on derived classes, but this method is - 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; - -%rename(getWxRect) operator wxRect; -%ignore operator <<; -%ignore operator=; - - -// headers/imports that must be included in the _wrapper.cpp at top - -%{ - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #include - #include - #include - #include - #include -%} - -// all the wx wrappers for wxString, wxPoint, wxRect, wxChar .. -%include - -// header files that must be wrapped - -%include -%include -%include -%include -%include -%include -%include -%include -%include -%include - -// special iteration wrapper for DLIST objects -%include "dlist.i" - -// std template mappings -%template(intVector) std::vector; -%template(str_utf8_Map) std::map< std::string,UTF8 >; - -// wrapper of BASE_SEQ (see typedef std::vector BASE_SEQ;) -%template(base_seqVect) std::vector; - -// TODO: wrapper of BASE_SET (see std::bitset BASE_SET;) - - -// KiCad plugin handling -%include "kicadplugins.i" - -// map CPolyLine and classes used in CPolyLine: -#include <../polygon/PolyLine.h> -%include <../polygon/PolyLine.h> - -// ignore warning relative to operator = and operator ++: -#pragma SWIG nowarn=362,383 - -// Rename operators defined in utf8.h -%rename(utf8_to_charptr) operator char* () const; -%rename(utf8_to_wxstring) operator wxString () const; - -#include -%include - -%extend UTF8 -{ - const char* Cast_to_CChar() { return (self->c_str()); } - - %pythoncode - %{ - - # Get the char buffer of the UTF8 string - def GetChars(self): - return self.Cast_to_CChar() - - # Convert the UTF8 string to a python string - # Same as GetChars(), but more easy to use in print command - def __str__(self): - return self.GetChars() - - %} -} - diff --git a/pcbnew/swig/board.i b/pcbnew/swig/board.i index a566c686d5..244f7f862d 100644 --- a/pcbnew/swig/board.i +++ b/pcbnew/swig/board.i @@ -33,37 +33,34 @@ By default we do not translate exceptions for EVERY C++ function since not every C++ function throws, and that would be unused and very bulky mapping code. -Therefore please help gather the subset of C++ functions for this class that do -throw and add them here, each before its respective class declaration. +Therefore please help gather the subset of C++ functions for each class that do +throw and add each in a separate HANDLE_EXCEPTIONS() invocation before its +respective class declaration. i.e. put them inside of their respective *.i +file near the top; only class BOARD functions go in board.i. */ HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints) -%include -%{ -#include -#include -%} - - -%import dlist.h - - -// Organize the two forms of include side by side so that it is easier to -// migrate each grouping into a separate *.i file later. - +//%import dlist.h // comes in from kicad.i which wraps & includes board.i %include board_item.i - %include board_item_container.i - -%include class_board_connected_item.h - - +%include board_connected_item.i +%include board_design_settings.i %include pad.i %include track.i %include zone.i +%include zone_settings.i +%include pcb_text.i +%include dimension.i +%include drawsegment.i +%include marker_pcb.i +%include mire.i +%include text_mod.i +%include edge_mod.i +%include netinfo.i +%include netclass.i %include layers_id_colors_and_visibility.h @@ -96,33 +93,19 @@ HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints) %} -%include pcb_text.i -%include dimension.i -%include drawsegment.i -%include marker_pcb.i -%include mire.i -%include text_mod.i -%include edge_mod.i - - -%include class_zone_settings.h -%{ -#include -%} - -%include netinfo.i -%include netclass.i - - // std::vector templates - %template(VIA_DIMENSION_Vector) std::vector; %template(RATSNEST_Vector) std::vector; - - %include class_board.h +%{ +#include +%} + %extend BOARD { + // BOARD_ITEM_CONTAINER's interface functions will be implemented by SWIG + // automatically and inherited by the python wrapper class. + %pythoncode %{ @@ -173,9 +156,9 @@ HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints) """ netclassmap = self.GetNetClasses().NetClasses() - # Add the Default one too, but this is probably modifying the dict (aka NETCLASS_MAP) - # in the BOARD. So change code here to create a dict copy first. - # netclassmap = dict(netclassmap) + # Add the Default one too, but this is probably modifying the NETCLASS_MAP + # in the BOARD. If that causes trouble, could make a deepcopy() here first. + # netclassmap = deepcopy(netclassmap) netclassmap['Default'] = self.GetNetClasses().GetDefault() return netclassmap %} diff --git a/pcbnew/swig/board.i.orig b/pcbnew/swig/board.i.orig deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/pcbnew/swig/board.i.rej b/pcbnew/swig/board.i.rej deleted file mode 100644 index f994ba5ef9..0000000000 --- a/pcbnew/swig/board.i.rej +++ /dev/null @@ -1,147 +0,0 @@ ---- pcbnew/scripting/board.i -+++ pcbnew/swig/board.i -@@ -28,38 +28,123 @@ - */ - - --%extend BOARD --{ -- %pythoncode -- %{ -- def GetModules(self): return self.m_Modules -- def GetDrawings(self): return self.m_Drawings -- def GetTracks(self): return self.m_Track -- def GetFullRatsnest(self): return self.m_FullRatsnest -+/* - -- def Save(self,filename): -- return SaveBoard(filename,self,IO_MGR.KICAD) -+By default we do not translate exceptions for EVERY C++ function since not every -+C++ function throws, and that would be unused and very bulky mapping code. -+Therefore please help gather the subset of C++ functions for this class that do -+throw and add them here, before the class declarations. - -- # -- # add function, clears the thisown to avoid python from deleting -- # the object in the garbage collector -- # -+*/ -+HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints) - -- def Add(self,item): -- item.thisown=0 -- self.AddNative(item) -- %} - --} -+%{ -+#include - --// this is to help python with the * accessor of DLIST templates -+#include -+#include -+ -+%} -+ -+ -+%import dlist.h -+ -+// Organize the two forms of include side by side so that it is easier to -+// migrate each grouping into a separate *.i file later. -+ -+ -+%include class_board_item.h -+%{ -+#include -+%} -+ -+%include class_board_connected_item.h -+%{ -+#include -+%} -+ -+%include pad_shapes.h -+ -+%include class_pad.h -+%{ -+#include -+%} -+ -+%include class_module.h -+%{ -+#include -+%} -+ -+%include class_track.h -+%{ -+#include -+%} -+ -+%include class_zone.h -+%include zones.h -+%{ -+#include -+#include -+%} -+ -+ -+%include layers_id_colors_and_visibility.h -+ -+%include class_pcb_text.h -+%{ -+#include -+%} -+ -+%include class_dimension.h -+%{ -+#include -+%} - -+ -+%include class_drawsegment.h -+%{ -+#include -+%} -+ -+%include class_marker_pcb.h -+%{ -+#include -+%} -+ -+ -+%include class_mire.h -+%{ -+#include -+%} -+ -+ -+%include class_text_mod.h -+%{ -+#include -+%} -+ -+%include class_edge_mod.h -+%{ -+#include -+%} -+ -+%include class_zone_settings.h -+ -+%include class_netinfo.h -+%include class_netclass.h -+%{ -+#include -+#include -+%} -+ -+ -+// this is to help python with the * accessor of DLIST templates - %rename(Get) operator BOARD_ITEM*; - %rename(Get) operator TRACK*; - %rename(Get) operator D_PAD*; - %rename(Get) operator MODULE*; - -- - // we must translate C++ templates to scripting languages - - %template(BOARD_ITEM_List) DLIST; diff --git a/pcbnew/swig/board_connected_item.i b/pcbnew/swig/board_connected_item.i new file mode 100644 index 0000000000..9f3e49b8d3 --- /dev/null +++ b/pcbnew/swig/board_connected_item.i @@ -0,0 +1,7 @@ + +%include class_board_connected_item.h + +%{ +#include +%} + diff --git a/pcbnew/swig/board_design_settings.i b/pcbnew/swig/board_design_settings.i new file mode 100644 index 0000000000..906f0ee7b8 --- /dev/null +++ b/pcbnew/swig/board_design_settings.i @@ -0,0 +1,4 @@ +%include +%{ +#include +%} diff --git a/pcbnew/swig/module.i b/pcbnew/swig/module.i index 9d9009e747..b273766541 100644 --- a/pcbnew/swig/module.i +++ b/pcbnew/swig/module.i @@ -39,7 +39,7 @@ // BOARD_ITEM_CONTAINER's interface functions will be implemented by SWIG -// automatically. +// automatically and inherited by the python wrapper class. /* diff --git a/pcbnew/swig/pcbnew.i.orig b/pcbnew/swig/pcbnew.i.orig deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/pcbnew/swig/pcbnew.i.rej b/pcbnew/swig/pcbnew.i.rej deleted file mode 100644 index 95e6fae83e..0000000000 --- a/pcbnew/swig/pcbnew.i.rej +++ /dev/null @@ -1,29 +0,0 @@ ---- pcbnew/scripting/pcbnew.i -+++ pcbnew/swig/pcbnew.i -@@ -87,26 +46,6 @@ class BASE_SET {}; - #include - %} - --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include --%include - - %include - %include diff --git a/pcbnew/swig/zone_settings.i b/pcbnew/swig/zone_settings.i new file mode 100644 index 0000000000..6565013c78 --- /dev/null +++ b/pcbnew/swig/zone_settings.i @@ -0,0 +1,4 @@ +%include class_zone_settings.h +%{ +#include +%}