From d957670034649a67fd31b3d2e4dd250f96a78ecc Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 19 Sep 2016 14:31:26 -0500 Subject: [PATCH] Add more HANDLE_EXCEPTIONS(), board.i refactoring. --- common/CMakeLists.txt | 16 ++++++------- common/swig/kiway.i | 29 +++++++++++++++++------ common/swig/kiway_player.i | 12 +--------- pcbnew/swig/board.i | 13 ++++++++--- pcbnew/swig/pcbnew.i | 47 +++++++++++++++++++++++++------------- 5 files changed, 71 insertions(+), 46 deletions(-) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index bbb0744b17..f6a759d73b 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -510,14 +510,12 @@ add_dependencies( dsntest lib-dependencies ) target_link_libraries( pcbcommon 3d-viewer ) -# kiway.so +# _kiway.so if( false ) # future #if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) - #file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripting ) set( SWIG_FLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/../include - -I${CMAKE_CURRENT_SOURCE_DIR}/swig/wx ) if( DEBUG ) @@ -535,8 +533,6 @@ if( false ) # future set( CMAKE_SWIG_FLAGS ${SWIG_FLAGS} ) - #set( SWIG_OPTS -python -c++ -outdir ${CMAKE_CURRENT_BINARY_DIR} ${SWIG_FLAGS} ) - include_directories( BEFORE ${INC_BEFORE} ) include_directories( ../common @@ -550,10 +546,6 @@ if( false ) # future swig_add_module( kiway python swig/kiway.i - #../common/kiway.cpp - #../common/project.cpp - #../common/pgm_base.cpp - #../common/ ) swig_link_libraries( kiway @@ -563,6 +555,12 @@ if( false ) # future ${PYTHON_LIBRARIES} ) + set_source_files_properties( ${swig_generated_file_fullname} PROPERTIES + # See section 16.3 "The SWIG runtime code" + # http://www.swig.org/Doc3.0/SWIGDocumentation.html#Modules_nn2 + COMPILE_FLAGS "-DSWIG_TYPE_TABLE=WXPYTHON_TYPE_TABLE -Wno-delete-non-virtual-dtor" + ) + if( MAKE_LINK_MAPS ) set_target_properties( _kiway PROPERTIES LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_kiway.so.map" diff --git a/common/swig/kiway.i b/common/swig/kiway.i index 3c97a018ca..df8873385f 100644 --- a/common/swig/kiway.i +++ b/common/swig/kiway.i @@ -2,15 +2,21 @@ //%module(directors="1") kiway %module kiway -/* -%import _defs.i -%import _window.i -%import _toplvl.i -%threadWrapperOff // _defs.i turns on thread protection, turn it off -*/ + +%import(module="wx") wx_kiway_player_hierarchy.h %include ki_exception.i // affects all that follow it +/* + +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. + +*/ +HANDLE_EXCEPTIONS(KIWAY::Player) + %include pgm_base.h %include frame_type.h %include mail_type.h @@ -21,7 +27,6 @@ %include kiway_player.i -HANDLE_EXCEPTIONS(KIWAY::Player) %constant KIWAY Kiway; @@ -46,7 +51,17 @@ HANDLE_EXCEPTIONS(KIWAY::Player) KIWAY Kiway( &Pgm(), KFCTL_PY_PROJECT_SUITE ); +// a dummy to quiet linking with EDA_BASE_FRAME::config(); +#include +KIFACE_I& Kiface() +{ + // This function should never be called. It is only referenced from + // EDA_BASE_FRAME::config() and this is only provided to satisfy the linker, + // not to be actually called. + wxLogFatalError( wxT( "Unexpected call to Kiface() in kicad/kicad.cpp" ) ); + return (KIFACE_I&) *(KIFACE_I*) 0; +} /** diff --git a/common/swig/kiway_player.i b/common/swig/kiway_player.i index 13da05e347..ac646a9e44 100644 --- a/common/swig/kiway_player.i +++ b/common/swig/kiway_player.i @@ -1,18 +1,8 @@ // Swig interface to classes KIWAY_PLAYER and KIWAY_HOLDER -class wxFrame -{ -}; -class KIWAY_PLAYER : public wxFrame -{ -}; - -%ignore wxFrame; -%ignore KIWAY_PLAYER; - -//%include kiway_player.h +%include kiway_player.h %{ #include diff --git a/pcbnew/swig/board.i b/pcbnew/swig/board.i index 7d6955ca8b..0d16e46163 100644 --- a/pcbnew/swig/board.i +++ b/pcbnew/swig/board.i @@ -39,12 +39,16 @@ throw and add them here, before the class declarations. HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints) +%include +%{ +#include +%} + + + %{ #include - -#include #include - %} @@ -130,6 +134,9 @@ HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints) %} %include class_zone_settings.h +%{ +#include +%} %include class_netinfo.h %include class_netclass.h diff --git a/pcbnew/swig/pcbnew.i b/pcbnew/swig/pcbnew.i index e77a93dec1..ec490e50e0 100644 --- a/pcbnew/swig/pcbnew.i +++ b/pcbnew/swig/pcbnew.i @@ -67,28 +67,47 @@ class BASE_SET {}; // this is what it must be included in the wrapper .cxx code to compile %{ - #include - #include +#include +#include - //#include - #include - #include +#include - #include - #include - #include +#include +#include +#include - BOARD *GetBoard(); /* get current editor board */ +BOARD *GetBoard(); /* get current editor board */ %} +// ignore RELEASER as nested classes are still unsupported by swig +%ignore IO_MGR::RELEASER; +%include %{ - #include - #include +#include +%} + + +/* + +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. + +*/ +HANDLE_EXCEPTIONS(PLUGIN::Load) +HANDLE_EXCEPTIONS(PLUGIN::Save) +HANDLE_EXCEPTIONS(PLUGIN::FootprintEnumerate) +HANDLE_EXCEPTIONS(PLUGIN::FootprintLoad) +HANDLE_EXCEPTIONS(PLUGIN::FootprintSave) +HANDLE_EXCEPTIONS(PLUGIN::FootprintDelete) +%include +%{ +#include %} -%include %include %include %include @@ -98,10 +117,6 @@ class BASE_SET {}; %include -// ignore RELEASER as nested classes are still unsupported by swig -%ignore IO_MGR::RELEASER; -%include -%include %include board.i %include module.i