diff --git a/CMakeLists.txt b/CMakeLists.txt
index 065995b410..5ff860bcd2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -574,6 +574,11 @@ set( INC_AFTER
# Find Python and other scripting resources
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
+
+ # SWIG 3.0 or later require for C++11 support.
+ find_package( SWIG 3.0 REQUIRED )
+ include( ${SWIG_USE_FILE} )
+
# force a python version < 3.0
set( PythonInterp_FIND_VERSION 2.6 )
set( PythonLibs_FIND_VERSION 2.6 )
diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake
index 01359cc003..700ec2a7a8 100644
--- a/CMakeModules/config.h.cmake
+++ b/CMakeModules/config.h.cmake
@@ -74,8 +74,8 @@
/// A file extension with a leading '.' is a suffix, and this one is used on
/// top level program modules which implement the KIFACE.
-#define KIFACE_SUFFIX wxT( "@KIFACE_SUFFIX@" )
-#define KIFACE_PREFIX wxT( "@KIFACE_PREFIX@" )
+#define KIFACE_SUFFIX "@KIFACE_SUFFIX@"
+#define KIFACE_PREFIX "@KIFACE_PREFIX@"
/// Name of repo from which this build came.
#define KICAD_REPO_NAME "@KICAD_REPO_NAME@"
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 6b6e1feb7c..4d304ae8b8 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -225,6 +225,7 @@ set( COMMON_SRCS
eda_dde.cpp
eda_doc.cpp
eda_pattern_match.cpp
+ exceptions.cpp
filter_reader.cpp
# findkicadhelppath.cpp.notused deprecated, use searchhelpfilefullpath.cpp
gbr_metadata.cpp
@@ -507,3 +508,64 @@ target_link_libraries( dsntest common ${wxWidgets_LIBRARIES} rt )
add_dependencies( dsntest lib-dependencies )
target_link_libraries( pcbcommon 3d-viewer )
+
+
+# kiway.so
+if( future AND 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 )
+ set( SWIG_FLAGS ${SWIG_FLAGS} -DDEBUG )
+ endif()
+
+ # call SWIG in C++ mode: https://cmake.org/cmake/help/v3.2/module/UseSWIG.html
+ set_source_files_properties( swig/kiway.i PROPERTIES CPLUSPLUS ON )
+
+ # collect CFLAGS , and pass them to swig later
+ get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS )
+ foreach( d ${DirDefs} )
+ set( SWIG_FLAGS ${SWIG_FLAGS} -D${d} )
+ endforeach()
+
+ 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
+ ${INC_AFTER}
+ )
+
+ set( SWIG_MODULE_kiway_EXTRA_DEPS
+ ../common/swig/ki_exception.i
+ ../common/swig/kicad.i
+ )
+
+ swig_add_module( kiway python
+ swig/kiway.i
+ #../common/kiway.cpp
+ #../common/project.cpp
+ #../common/pgm_base.cpp
+ #../common/
+ )
+
+ swig_link_libraries( kiway
+ common
+ bitmaps
+ ${wxWidgets_LIBRARIES}
+ ${PYTHON_LIBRARIES}
+ )
+
+ if( MAKE_LINK_MAPS )
+ set_target_properties( _kiway PROPERTIES
+ LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_kiway.so.map"
+ )
+ endif()
+
+endif()
diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp
index dab09cf9e8..ff4fdee9f6 100644
--- a/common/footprint_info.cpp
+++ b/common/footprint_info.cpp
@@ -306,7 +306,7 @@ void FOOTPRINT_LIST::DisplayErrors( wxTopLevelWindow* aWindow )
for( unsigned i = 0; i" ) + m_errors[i].errorText + wxT( "
" );
+ msg += wxT( "" ) + m_errors[i].Problem() + wxT( "
" );
}
dlg.AddHTML_Text( msg );
diff --git a/common/kiway.cpp b/common/kiway.cpp
index fef1689389..65f8cc53c1 100644
--- a/common/kiway.cpp
+++ b/common/kiway.cpp
@@ -93,19 +93,19 @@ void KIWAY::SetTop( wxFrame* aTop )
}
-const wxString KIWAY::dso_full_path( FACE_T aFaceId )
+const wxString KIWAY::dso_search_path( FACE_T aFaceId )
{
- const wxChar* name;
+ const char* name;
switch( aFaceId )
{
- case FACE_SCH: name = KIFACE_PREFIX wxT( "eeschema" ); break;
- case FACE_PCB: name = KIFACE_PREFIX wxT( "pcbnew" ); break;
- case FACE_CVPCB: name = KIFACE_PREFIX wxT( "cvpcb" ); break;
- case FACE_GERBVIEW: name = KIFACE_PREFIX wxT( "gerbview" ); break;
- case FACE_PL_EDITOR: name = KIFACE_PREFIX wxT( "pl_editor" ); break;
- case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX wxT( "pcb_calculator" ); break;
- case FACE_BMP2CMP: name = KIFACE_PREFIX wxT( "bitmap2component" ); break;
+ case FACE_SCH: name = KIFACE_PREFIX "eeschema"; break;
+ case FACE_PCB: name = KIFACE_PREFIX "pcbnew"; break;
+ case FACE_CVPCB: name = KIFACE_PREFIX "cvpcb"; break;
+ case FACE_GERBVIEW: name = KIFACE_PREFIX "gerbview"; break;
+ case FACE_PL_EDITOR: name = KIFACE_PREFIX "pl_editor"; break;
+ case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX "pcb_calculator"; break;
+ case FACE_BMP2CMP: name = KIFACE_PREFIX "bitmap2component"; break;
default:
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
@@ -113,7 +113,17 @@ const wxString KIWAY::dso_full_path( FACE_T aFaceId )
}
#ifndef __WXMAC__
- wxFileName fn = wxStandardPaths::Get().GetExecutablePath();
+ wxString path;
+
+ if( m_ctl & (KFCTL_STANDALONE | KFCTL_CPP_PROJECT_SUITE) )
+ {
+ // The 2 *.cpp program launchers: single_top.cpp and kicad.cpp expect
+ // the *.kiface's to reside in same diretory as their binaries do.
+ // Not so for python launcher, identified by KFCTL_PY_PROJECT_SUITE
+ path = wxStandardPaths::Get().GetExecutablePath();
+ }
+
+ wxFileName fn = path;
#else
// we have the dso's in main OSX bundle kicad.app/Contents/PlugIns
wxFileName fn = Pgm().GetExecutablePath();
@@ -159,7 +169,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
// DSO with KIFACE has not been loaded yet, does caller want to load it?
if( doLoad )
{
- wxString dname = dso_full_path( aFaceId );
+ wxString dname = dso_search_path( aFaceId );
wxDynamicLibrary dso;
diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp
index 936853463f..ce26c2b7f8 100644
--- a/common/pgm_base.cpp
+++ b/common/pgm_base.cpp
@@ -285,7 +285,6 @@ PGM_BASE::PGM_BASE()
m_locale = NULL;
m_common_settings = NULL;
- m_wx_app = NULL;
m_show_env_var_dialog = true;
setLanguageId( wxLANGUAGE_DEFAULT );
@@ -296,11 +295,11 @@ PGM_BASE::PGM_BASE()
PGM_BASE::~PGM_BASE()
{
- destroy();
+ Destroy();
}
-void PGM_BASE::destroy()
+void PGM_BASE::Destroy()
{
// unlike a normal destructor, this is designed to be called more than once safely:
@@ -315,6 +314,13 @@ void PGM_BASE::destroy()
}
+wxApp& PGM_BASE::App()
+{
+ wxASSERT( wxTheApp );
+ return *wxTheApp;
+}
+
+
void PGM_BASE::SetEditorName( const wxString& aFileName )
{
m_editor_name = aFileName;
@@ -383,7 +389,7 @@ const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEdit
}
-bool PGM_BASE::initPgm()
+bool PGM_BASE::InitPgm()
{
wxFileName pgm_name( App().argv[0] );
@@ -609,10 +615,10 @@ void PGM_BASE::loadCommonSettings()
}
-void PGM_BASE::saveCommonSettings()
+void PGM_BASE::SaveCommonSettings()
{
// m_common_settings is not initialized until fairly late in the
- // process startup: initPgm(), so test before using:
+ // process startup: InitPgm(), so test before using:
if( m_common_settings )
{
wxString cur_dir = wxGetCwd();
@@ -846,7 +852,7 @@ void PGM_BASE::SetLocalEnvVariables( const ENV_VAR_MAP& aEnvVarMap )
if( m_common_settings )
m_common_settings->DeleteGroup( pathEnvVariables );
- saveCommonSettings();
+ SaveCommonSettings();
// Overwrites externally defined environment variable until the next time the application
// is run.
diff --git a/scripting/dlist.i b/common/swig/dlist.i
similarity index 98%
rename from scripting/dlist.i
rename to common/swig/dlist.i
index 9ea7712a3b..72d6f360a3 100644
--- a/scripting/dlist.i
+++ b/common/swig/dlist.i
@@ -24,6 +24,13 @@
/* DLIST python iteration code, to allow standard iteration over DLIST */
+%include
+
+%{
+#include
+%}
+
+
%extend DLIST
{
%pythoncode
diff --git a/common/swig/ki_exception.i b/common/swig/ki_exception.i
new file mode 100644
index 0000000000..0a42cc8404
--- /dev/null
+++ b/common/swig/ki_exception.i
@@ -0,0 +1,65 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2016 SoftPLC Corporation, Dick Hollenbeck
+ * Copyright (C) 2016 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
+ */
+
+%warnfilter(511) IO_ERROR;
+
+%include ki_exception.h
+
+%{
+#include
+%}
+
+%include exception.i
+
+// Target a specific function with "C++ to python exception handling and
+// translation code". Invoke this macro separately for each C++ function
+// that throws. This is a less bulkier scheme than assuming that ALL C++
+// functions throw, because they do not all throw.
+%define HANDLE_EXCEPTIONS(function)
+%exception function {
+ try
+ {
+ $action
+ }
+ catch( const IO_ERROR& e )
+ {
+ UTF8 str = e.Problem();
+
+ SWIG_exception( SWIG_IOError, str.c_str() );
+ return NULL;
+ }
+ catch( const std::exception& e )
+ {
+ std::string str = e.what();
+
+ SWIG_exception( SWIG_IOError, str.c_str() );
+ return NULL;
+ }
+ catch( ... )
+ {
+ SWIG_fail;
+ }
+}
+%enddef
+
diff --git a/common/swig/kicad.i b/common/swig/kicad.i
new file mode 100644
index 0000000000..6382369e01
--- /dev/null
+++ b/common/swig/kicad.i
@@ -0,0 +1,158 @@
+/*
+ * 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
+
+%include "ki_exception.i" // affects all that follow it
+
+/*
+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=;
+
+%include dlist.i
+
+// 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
+%}
+
+// all the wx wrappers for wxString, wxPoint, wxRect, wxChar ..
+%include wx.i
+
+// header files that must be wrapped
+
+%include macros.h
+%include core/typeinfo.h
+%include base_struct.h
+%include class_eda_rect.h
+%include common.h
+%include class_title_block.h
+%include class_colors_design_settings.h
+%include class_marker_base.h
+%include eda_text.h
+
+
+// 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/scripting/kicad.i b/common/swig/kicad.i.orig
similarity index 99%
rename from scripting/kicad.i
rename to common/swig/kicad.i.orig
index 58194a2550..19fa123bf5 100644
--- a/scripting/kicad.i
+++ b/common/swig/kicad.i.orig
@@ -32,6 +32,7 @@
%include
%include
%include
+%include
/*
http://www.swig.org/Doc3.0/CPlusPlus11.html
diff --git a/common/swig/kiway.i b/common/swig/kiway.i
new file mode 100644
index 0000000000..3c97a018ca
--- /dev/null
+++ b/common/swig/kiway.i
@@ -0,0 +1,234 @@
+
+//%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
+*/
+
+%include ki_exception.i // affects all that follow it
+
+%include pgm_base.h
+%include frame_type.h
+%include mail_type.h
+%include project.h
+%include kiway.h
+%include kiway_express.h
+
+%include kiway_player.i
+
+
+HANDLE_EXCEPTIONS(KIWAY::Player)
+
+%constant KIWAY Kiway;
+
+%pythoncode
+%{
+#import wx
+%}
+
+
+%{
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+
+// Only a single KIWAY is supported in this single_top top level component,
+// which is dedicated to loading only a single DSO.
+KIWAY Kiway( &Pgm(), KFCTL_PY_PROJECT_SUITE );
+
+
+
+
+
+/**
+ * Struct PGM_PYTHON
+ * implements PGM_BASE with its own OnPgmInit() and OnPgmExit().
+ */
+static struct PGM_PYTHON : public PGM_BASE
+{
+#if 0
+ bool OnPgmInit( wxApp* aWxApp )
+ {
+ // first thing: set m_wx_app
+ SetApp( aWxApp );
+
+ if( !initPgm() )
+ return false;
+
+ // Use KIWAY to create a top window, which registers its existence also.
+ // "TOP_FRAME" is a macro that is passed on compiler command line from CMake,
+ // and is one of the types in FRAME_T.
+ KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB, true );
+
+ Kiway.SetTop( frame );
+
+ App().SetTopWindow( frame ); // wxApp gets a face.
+
+ // Open project or file specified on the command line:
+ int argc = App().argc;
+
+ if( argc > 1 )
+ {
+ /*
+ gerbview handles multiple project data files, i.e. gerber files on
+ cmd line. Others currently do not, they handle only one. For common
+ code simplicity we simply pass all the arguments in however, each
+ program module can do with them what they want, ignore, complain
+ whatever. We don't establish policy here, as this is a multi-purpose
+ launcher.
+ */
+
+ std::vector argSet;
+
+ for( int i=1; iOpenProjectFiles( argSet ) )
+ {
+ // OpenProjectFiles() API asks that it report failure to the UI.
+ // Nothing further to say here.
+
+ // We've already initialized things at this point, but wx won't call OnExit if
+ // we fail out. Call our own cleanup routine here to ensure the relevant resources
+ // are freed at the right time (if they aren't, segfaults will occur).
+ OnPgmExit();
+
+ // Fail the process startup if the file could not be opened,
+ // although this is an optional choice, one that can be reversed
+ // also in the KIFACE specific OpenProjectFiles() return value.
+ return false;
+ }
+ }
+
+ frame->Show();
+
+ return true;
+ }
+
+ void OnPgmExit()
+ {
+ Kiway.OnKiwayEnd();
+
+ saveCommonSettings();
+
+ // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
+ // earlier than wxApp and earlier than static destruction would.
+ PGM_BASE::destroy();
+ }
+#endif
+
+
+#if 0 // multi-project
+ void PGM_KICAD::MacOpenFile( const wxString& aFileName )
+ {
+ #if defined(__WXMAC__)
+
+ KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) App().GetTopWindow();
+
+ frame->SetProjectFileName( aFileName );
+
+ wxCommandEvent loadEvent( 0, wxID_ANY );
+
+ frame->OnLoadProject( loadEvent );
+ #endif
+ }
+
+#else
+ void MacOpenFile( const wxString& aFileName ) override
+ {
+ wxFileName filename( aFileName );
+
+ if( filename.FileExists() )
+ {
+#if 0
+ // this pulls in EDA_DRAW_FRAME type info, which we don't want in
+ // the link image.
+ KIWAY_PLAYER* frame = dynamic_cast( App().GetTopWindow() );
+#else
+ KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
+#endif
+ if( frame )
+ frame->OpenProjectFiles( std::vector( 1, aFileName ) );
+ }
+ }
+#endif
+
+} program;
+
+
+PGM_BASE& Pgm()
+{
+ return program;
+}
+
+%}
+
+/*
+import ctypes, os, sys
+libcef_so = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'libcef.so')
+if os.path.exists(libcef_so):
+*/
+
+%extend PGM_BASE {
+
+ %pythoncode
+ %{
+
+ def OnPgmInit(self):
+ print "hereA"
+
+ if not self.InitPgm():
+ return False;
+
+ print "hereB"
+
+ try:
+ # A KIWAY_PLAYER is a wx.Window
+ frame = Kiway.Player( FRAME_SCH, True )
+
+ print "here0"
+
+ except IOError as e:
+ print 'Player()', e
+ return None
+
+ print "here1"
+
+ Kiway.SetTop(frame)
+
+ print "here2"
+
+ return frame
+ %}
+};
+
diff --git a/common/swig/kiway_player.i b/common/swig/kiway_player.i
new file mode 100644
index 0000000000..13da05e347
--- /dev/null
+++ b/common/swig/kiway_player.i
@@ -0,0 +1,20 @@
+
+// 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
+%}
+
diff --git a/scripting/wx.i b/common/swig/wx.i
similarity index 100%
rename from scripting/wx.i
rename to common/swig/wx.i
diff --git a/scripting/wx_python_helpers.cpp b/common/swig/wx_python_helpers.cpp
similarity index 100%
rename from scripting/wx_python_helpers.cpp
rename to common/swig/wx_python_helpers.cpp
diff --git a/scripting/wx_python_helpers.h b/common/swig/wx_python_helpers.h
similarity index 85%
rename from scripting/wx_python_helpers.h
rename to common/swig/wx_python_helpers.h
index 2da11d654a..8c6753cc75 100644
--- a/scripting/wx_python_helpers.h
+++ b/common/swig/wx_python_helpers.h
@@ -1,5 +1,5 @@
-#ifndef __wx_helpers_h
-#define __wx_helpers_h
+#ifndef WX_HELPERS_H_
+#define WX_HELPERS_H_
#include
#include
@@ -15,4 +15,4 @@ PyObject* wx2PyString( const wxString& src );
void wxSetDefaultPyEncoding( const char* encoding );
const char* wxGetDefaultPyEncoding();
-#endif
+#endif // WX_HELPERS_H_
diff --git a/include/kiway.h b/include/kiway.h
index 43eafab1b2..300d6db123 100644
--- a/include/kiway.h
+++ b/include/kiway.h
@@ -103,6 +103,7 @@ as such! As such, it is OK to use UTF8 characters:
#include
#include
#include
+#include
#define VTBL_ENTRY virtual
@@ -114,6 +115,7 @@ as such! As such, it is OK to use UTF8 characters:
// be mangled.
#define KIFACE_INSTANCE_NAME_AND_VERSION "KIFACE_1"
+#ifndef SWIG
#if defined(__linux__) || defined(__FreeBSD__)
#define LIB_ENV_VAR wxT( "LD_LIBRARY_PATH" )
#elif defined(__WXMAC__)
@@ -123,7 +125,7 @@ as such! As such, it is OK to use UTF8 characters:
#else
#error Platform support missing
#endif
-
+#endif // SWIG
class wxConfigBase;
class wxWindow;
@@ -151,6 +153,8 @@ struct KIFACE
// order of functions in this listing unless you recompile all clients of
// this interface.
+ virtual ~KIFACE() throw() {}
+
#define KFCTL_STANDALONE (1<<0) ///< Am running as a standalone Top.
#define KFCTL_CPP_PROJECT_SUITE (1<<1) ///< Am running under C++ project mgr, possibly with others
#define KFCTL_PY_PROJECT_SUITE (1<<2) ///< Am running under python project mgr, possibly with others
@@ -269,6 +273,8 @@ public:
KIWAY_FACE_COUNT
};
+ ~KIWAY() throw () {}
+
/**
* Function KifaceType
* is a simple mapping function which returns the FACE_T which is known to
@@ -278,7 +284,6 @@ public:
*/
static FACE_T KifaceType( FRAME_T aFrameType );
-
// If you change the vtable, recompile all of KiCad.
/**
@@ -303,6 +308,8 @@ public:
*
* @return KIWAY_PLAYER* - a valid opened KIWAY_PLAYER or NULL if there
* is something wrong or doCreate was false and the player has yet to be created.
+ *
+ * @throw IO_ERROR if the *.kiface file could not be found, filled with text saying what.
*/
VTBL_ENTRY KIWAY_PLAYER* Player( FRAME_T aFrameType, bool doCreate = true, KIWAY_PLAYER* aParent = NULL );
@@ -368,8 +375,8 @@ public:
private:
- /// Get the full path & name of the DSO holding the requested FACE_T.
- static const wxString dso_full_path( FACE_T aFaceId );
+ /// Get the [path &] name of the DSO holding the requested FACE_T.
+ const wxString dso_search_path( FACE_T aFaceId );
#if 0
/// hooked into m_top in SetTop(), marks child frame as closed.
@@ -400,7 +407,6 @@ private:
wxFrame* m_top; // Usually m_top is the Project manager
-
// a string array ( size KIWAY_PLAYER_COUNT ) to Store the frame name
// of PLAYER frames which were run.
// A non empty name means only a PLAYER was run at least one time.
@@ -413,20 +419,11 @@ private:
};
-/*
-/// Given aProject, return its KIWAY*
-inline KIWAY* PrjToKiway( PROJECT* aProject )
-{
- // It's ugly, but isolated. The compiler should simply do what's
- // it's told to do here and shut up.
- KIWAY* p = 0;
- ptrdiff_t offset = (char*) &p->m_project - (char*) p;
-
- return (KIWAY*) ((char*)aProject - offset);
-}
-*/
-
-extern KIWAY Kiway; // provided by single_top.cpp and kicad.cpp
+#ifndef SWIG
+// provided by single_top.cpp and kicad.cpp;
+extern KIWAY Kiway;
+// whereas python launchers: single_top.py and project manager instantiate as a python object
+#endif
/**
@@ -444,16 +441,18 @@ extern KIWAY Kiway; // provided by single_top.cpp and kicad.cpp
*/
typedef KIFACE* KIFACE_GETTER_FUNC( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
+
+#ifndef SWIG
+
/// No name mangling. Each KIFACE (DSO/DLL) will implement this once.
extern "C" {
-
#if defined(BUILD_KIWAY_DLL)
-MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
+ MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
#else
-KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
+ KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
#endif
-
}
+#endif // SWIG
#endif // KIWAY_H_
diff --git a/include/kiway_player.h b/include/kiway_player.h
index eeff8a5b65..9738fd5d5d 100644
--- a/include/kiway_player.h
+++ b/include/kiway_player.h
@@ -105,7 +105,11 @@ class WX_EVENT_LOOP;
* EDA_BASE_FRAME would not have sufficed because BM2CMP_FRAME_BASE is not
* derived from it.
*/
+#ifdef SWIG
+class KIWAY_PLAYER : public wxFrame, public KIWAY_HOLDER
+#else
class KIWAY_PLAYER : public EDA_BASE_FRAME, public KIWAY_HOLDER
+#endif
{
public:
KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
@@ -118,7 +122,7 @@ public:
const wxPoint& aPos, const wxSize& aSize, long aStyle,
const wxString& aWdoName = wxFrameNameStr );
- ~KIWAY_PLAYER();
+ ~KIWAY_PLAYER() throw();
//---------------------------------------------------------
@@ -238,7 +242,9 @@ protected:
wxString m_modal_string;
bool m_modal_ret_val; // true if a selection was made
+#ifndef SWIG
DECLARE_EVENT_TABLE()
+#endif
};
diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h
index 24d819eef2..42b83c5946 100644
--- a/include/layers_id_colors_and_visibility.h
+++ b/include/layers_id_colors_and_visibility.h
@@ -235,7 +235,7 @@ public:
/**
* Constructor LSET( const LAYER_ID* aArray, unsigned aCount )
- * works well with an arry or LSEQ.
+ * works well with an array or LSEQ.
*/
LSET( const LAYER_ID* aArray, unsigned aCount );
diff --git a/include/macros.h b/include/macros.h
index 52580428fc..bf81070340 100644
--- a/include/macros.h
+++ b/include/macros.h
@@ -33,6 +33,7 @@
#include
#include
#include