Expose new netclass storage to SWIG

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13337
This commit is contained in:
Jon Evans 2023-02-11 09:50:24 -05:00
parent 93020cf78f
commit 6948a0bebd
3 changed files with 9 additions and 62 deletions

View File

@ -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<NETCLASS>
{
public:
std::shared_ptr<NETCLASS>( std::string name ) { return new std::shared_ptr<NETCLASS>( 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 <netclass.h>
%}

View File

@ -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()

View File

@ -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<wxString, std::shared_ptr<NETCLASS>>;
%{
#include <board_design_settings.h>
#include <project/net_settings.h>
%}
%include <board_design_settings.h>
%include <project/net_settings.h>
%extend BOARD_DESIGN_SETTINGS
{