From 6948a0bebd025fc0f601de855ae16efd6350d3c8 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 11 Feb 2023 09:50:24 -0500 Subject: [PATCH] Expose new netclass storage to SWIG Fixes https://gitlab.com/kicad/code/kicad/-/issues/13337 --- common/swig/netclass.i | 62 +--------------------- pcbnew/python/swig/board.i | 2 +- pcbnew/python/swig/board_design_settings.i | 7 +++ 3 files changed, 9 insertions(+), 62 deletions(-) diff --git a/common/swig/netclass.i b/common/swig/netclass.i index 9bb23ab3df..7291112cef 100644 --- a/common/swig/netclass.i +++ b/common/swig/netclass.i @@ -22,69 +22,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/* - -NETCLASS is not exposed/generated via SWIG but rather class NETCLASSPTR is. This -is because we can never have a simple pointer to a NETCLASS, only can we have a -NETCLASSPTR. So we cannot build a python wrapper without using NETCLASSPTR to do -the pointing. - -*/ - -%ignore NETCLASS; // no code generation for it +%shared_ptr(NETCLASS) %include netclass.h - -/* - -Propagate important member functions from NETCLASS into SWIG's NETCLASSPTR. Do -this by dereferencing the pointer to the NETCLASSPTR proxy, then dereference the -std::share_ptr to get to the actual NETCLASS::member. Complete the member -function set if you see something missing from class NETCLASS that you need. - -*/ - -//%extend NETCLASSPTR // would have thought the typedef in header above was golden here. -%extend std::shared_ptr -{ -public: - std::shared_ptr( std::string name ) { return new std::shared_ptr( new NETCLASS(name) ); } - - STRINGSET& NetNames() { return (*self)->NetNames(); } - - const wxString& GetName() { return (*self)->GetName(); } - - unsigned GetCount() const { return (*self)->GetCount(); } - - const wxString& GetDescription() const { return (*self)->GetDescription(); } - void SetDescription( const wxString& aDesc ) { (*self)->SetDescription( aDesc ); } - - int GetClearance() const { return (*self)->GetClearance(); } - void SetClearance( int aClearance ) { (*self)->SetClearance( aClearance ); } - - int GetTrackWidth() const { return (*self)->GetTrackWidth(); } - void SetTrackWidth( int aWidth ) { (*self)->SetTrackWidth( aWidth ); } - - int GetViaDiameter() const { return (*self)->GetViaDiameter(); } - void SetViaDiameter( int aDia ) { (*self)->SetViaDiameter( aDia ); } - - int GetViaDrill() const { return (*self)->GetViaDrill(); } - void SetViaDrill( int aSize ) { (*self)->SetViaDrill( aSize ); } - - int GetuViaDiameter() const { return (*self)->GetuViaDiameter(); } - void SetuViaDiameter( int aSize ) { (*self)->SetuViaDiameter( aSize ); } - - int GetuViaDrill() const { return (*self)->GetuViaDrill(); } - void SetuViaDrill( int aSize ) { (*self)->SetuViaDrill( aSize ); } - - int GetDiffPairWidth() const { return (*self)->GetDiffPairWidth(); } - void SetDiffPairWidth( int aSize ) { (*self)->SetDiffPairWidth( aSize ); } - - int GetDiffPairGap() const { return (*self)->GetDiffPairGap(); } - void SetDiffPairGap( int aSize ) { (*self)->SetDiffPairGap( aSize ); } -}; - - %{ #include %} diff --git a/pcbnew/python/swig/board.i b/pcbnew/python/swig/board.i index 8ce3701b7f..efc888db6f 100644 --- a/pcbnew/python/swig/board.i +++ b/pcbnew/python/swig/board.i @@ -154,7 +154,7 @@ HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints) return SaveBoard(filename,self) def GetNetClasses(self): - return self.GetDesignSettings().GetNetClasses() + return self.GetDesignSettings().m_NetSettings.m_NetClasses def GetCurrentNetClassName(self): return self.GetDesignSettings().GetCurrentNetClassName() diff --git a/pcbnew/python/swig/board_design_settings.i b/pcbnew/python/swig/board_design_settings.i index 1f12cc3160..8e1ea0edb7 100644 --- a/pcbnew/python/swig/board_design_settings.i +++ b/pcbnew/python/swig/board_design_settings.i @@ -1,11 +1,18 @@ %ignore BOARD_DESIGN_SETTINGS::m_Pad_Master; %ignore BOARD_DESIGN_SETTINGS::m_DRCEngine; +%ignore NET_SETTINGS::m_NetClassPatternAssignments; +%ignore NET_SETTINGS::m_NetClassLabelAssignments; + +%shared_ptr(NET_SETTINGS) +%template(netclasses_map) std::map>; %{ #include +#include %} %include +%include %extend BOARD_DESIGN_SETTINGS {