2009-05-21 17:42:42 +00:00
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
#include <id.h>
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
#include <wx/dir.h>
|
|
|
|
|
|
|
|
#include <pyhandler.h>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace boost::python;
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Common Python Binding */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
static int GetLastID() { return ID_END_LIST; }
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
static object ChooseFile( str objTitle, str objMask, object objOpen )
|
|
|
|
{
|
|
|
|
wxString mask = PyHandler::MakeStr( objMask );
|
|
|
|
int open = extract<int>( objOpen );
|
|
|
|
|
|
|
|
wxString script = EDA_FileSelector( PyHandler::MakeStr( objTitle ),
|
2009-11-23 15:16:50 +00:00
|
|
|
wxEmptyString,
|
|
|
|
wxEmptyString,
|
|
|
|
mask,
|
|
|
|
mask,
|
|
|
|
NULL,
|
|
|
|
open ? wxFD_OPEN : wxFD_SAVE,
|
|
|
|
TRUE );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
return PyHandler::Convert( script );
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
static void Print( str message )
|
|
|
|
{
|
|
|
|
std::cout << extract<char *>(message) << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
static void Clear() {}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
static void RegisterCb( str objKey, object callback )
|
2009-11-23 15:16:50 +00:00
|
|
|
{
|
|
|
|
PyHandler::GetInstance()->RegisterCallback( PyHandler::MakeStr(objKey),
|
|
|
|
callback );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
static void UnRegisterCb( str objKey, object callback )
|
2009-11-23 15:16:50 +00:00
|
|
|
{
|
|
|
|
PyHandler::GetInstance()->UnRegisterCallback( PyHandler::MakeStr(objKey),
|
|
|
|
callback );
|
|
|
|
}
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
static void init_base_utils()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
def ( "ChooseFile", &ChooseFile );
|
|
|
|
def ( "RegisterCallback", &RegisterCb );
|
|
|
|
def ( "UnRegisterCallback", &UnRegisterCb );
|
|
|
|
def ( "GetLastID", &GetLastID );
|
|
|
|
|
|
|
|
def ( "Print", &Print );
|
|
|
|
def ( "Clear", &Clear);
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
// Dummy boost callback
|
|
|
|
static void InitPyModules()
|
|
|
|
{
|
|
|
|
PyHandler::GetInstance()->InitNextModule();
|
|
|
|
}
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* PyHandler */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
// std::vector< T > -> python object implicit conversion
|
|
|
|
template <typename T> struct std_vector_to_tuple
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
static PyObject * makeItem( const wxString & str )
|
|
|
|
{
|
|
|
|
return boost::python::incref( PyHandler::Convert( str ).ptr() );
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject * makeItem( const std::string & str )
|
|
|
|
{
|
|
|
|
return boost::python::incref(
|
|
|
|
boost::python::str( str.c_str() ).ptr() );
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject * makeItem( int item )
|
|
|
|
{
|
|
|
|
return boost::python::incref( PyInt_FromLong( item ) );
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
static PyObject * convert( const T& vect )
|
|
|
|
{
|
|
|
|
PyObject * tuple = PyTuple_New( vect.size() );
|
|
|
|
for ( unsigned int i = 0; i < vect.size() ; i++ )
|
|
|
|
{
|
|
|
|
PyTuple_SET_ITEM( tuple, i, makeItem( vect[i] ) );
|
|
|
|
}
|
|
|
|
return tuple;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
PyHandler* PyHandler::m_instance = NULL;
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Singleton implementation */
|
2009-11-23 15:16:50 +00:00
|
|
|
PyHandler * PyHandler::GetInstance()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
if( !PyHandler::m_instance )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
PyHandler::m_instance = new PyHandler();
|
|
|
|
}
|
|
|
|
return PyHandler::m_instance;
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Init the Python env */
|
2009-11-23 15:16:50 +00:00
|
|
|
PyHandler::PyHandler()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
Py_Initialize();
|
|
|
|
PyEval_InitThreads();
|
|
|
|
m_ModulesLoaded = false;
|
|
|
|
m_current = 0;
|
2009-11-23 15:16:50 +00:00
|
|
|
if( !wxPyCoreAPI_IMPORT() )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
std::cerr << "Can't get wx Python binding\n" ;
|
|
|
|
PyErr_Print();
|
|
|
|
}
|
|
|
|
// m_mainTState = wxPyBeginAllowThreads(); // I can't figure out why this make py crash ...
|
|
|
|
m_mainTState = NULL;
|
|
|
|
|
|
|
|
// Make the console appear in a window:
|
|
|
|
wxString initConsole;
|
|
|
|
initConsole += wxT( "import sys\n" );
|
|
|
|
initConsole += wxT( "import wx\n" );
|
|
|
|
initConsole += wxT( "output = wx.PyOnDemandOutputWindow()\n" );
|
|
|
|
initConsole += wxT( "sys.stdout = sys.stderr = output\n" );
|
|
|
|
RunSimpleString( initConsole );
|
|
|
|
|
|
|
|
AddToModule ( wxT( "common" ), &init_base_utils );
|
|
|
|
|
|
|
|
// Register converters
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
to_python_converter < std::vector< std::string >,
|
|
|
|
std_vector_to_tuple< const std::vector < std::string > > > ();
|
|
|
|
to_python_converter < std::vector< wxString >,
|
|
|
|
std_vector_to_tuple< const std::vector < wxString > > > ();
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
void PyHandler::DoInitModules()
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
if ( m_ModulesLoaded )
|
|
|
|
return;
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
m_ModulesLoaded = true;
|
|
|
|
|
|
|
|
for ( unsigned int i = 0; i < m_ModuleRegistry.size(); i ++ )
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
detail::init_module( m_ModuleRegistry[i].name.mb_str(),
|
|
|
|
&InitPyModules );
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Returns the module index in the registry, -1 if not found*/
|
2009-11-23 15:16:50 +00:00
|
|
|
int PyHandler::GetModuleIndex( const wxString & name ) const
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
for ( unsigned int i = 0; i < m_ModuleRegistry.size(); i ++ )
|
|
|
|
{
|
|
|
|
if ( m_ModuleRegistry[i].name == name ) return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Adds an init function to a python module */
|
2009-11-23 15:16:50 +00:00
|
|
|
void PyHandler::AddToModule( const wxString & name,
|
|
|
|
PyHandler::initfunc_t initfunc )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
if (!initfunc)
|
|
|
|
return;
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
int i = GetModuleIndex( name );
|
|
|
|
|
|
|
|
if ( -1 == i )
|
|
|
|
{
|
|
|
|
m_ModuleRegistry.push_back( ModuleRecord( name ) );
|
|
|
|
i = m_ModuleRegistry.size() - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ModuleRegistry[i].registry.push_back( initfunc );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Called to initialize a module on py 'import module' */
|
2009-11-23 15:16:50 +00:00
|
|
|
void PyHandler::InitNextModule()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
for ( unsigned int j = 0;
|
|
|
|
j < m_ModuleRegistry[m_current].registry.size();
|
|
|
|
j++ )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
m_ModuleRegistry[m_current].registry[j]();
|
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
m_current++;
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Closes the Python env */
|
2009-11-23 15:16:50 +00:00
|
|
|
PyHandler::~PyHandler()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
wxPyEndAllowThreads(m_mainTState);
|
|
|
|
Py_Finalize();
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Run scripts looking in 'base' directory */
|
2009-11-23 15:16:50 +00:00
|
|
|
void PyHandler::RunBaseScripts( const wxString & base )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
const wxString sep = wxFileName().GetPathSeparator();
|
|
|
|
|
|
|
|
// check if we can have a kicad_startup.py around ?
|
|
|
|
wxString script = base + wxT( "scripts" ) + sep + wxT( "kicad_startup.py" );
|
2009-11-23 15:16:50 +00:00
|
|
|
if ( wxFileExists( script ) )
|
|
|
|
RunScript( script );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
// First find scripts/<name>.py and run it if found :
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
script = base + wxString::FromAscii( "scripts" ) + sep + m_appName
|
|
|
|
+ wxString::FromAscii(".py");
|
|
|
|
|
|
|
|
if ( wxFileExists( script ) )
|
|
|
|
RunScript( script );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
// Now lets see if we can find a suitable plugin directory
|
|
|
|
// (plugin/<name>) somewhere
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
wxString pluginDir = base + wxT( "plugins" ) + sep + m_appName;
|
|
|
|
if ( wxDirExists( pluginDir ) )
|
|
|
|
{
|
|
|
|
// We do have a systemwide plugin dir, let's find files in it
|
|
|
|
wxArrayString pluginList;
|
|
|
|
wxDir::GetAllFiles( pluginDir, &pluginList, wxT("*.py") );
|
|
|
|
|
|
|
|
for ( unsigned int i = 0; i < pluginList.Count() ; i++ )
|
|
|
|
{
|
|
|
|
RunScript( pluginList[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Run application startup scripts */
|
2009-11-23 15:16:50 +00:00
|
|
|
void PyHandler::RunScripts()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
// SYSTEMWIDE:
|
|
|
|
|
|
|
|
const wxString sep = wxFileName().GetPathSeparator();
|
|
|
|
|
|
|
|
wxString dataPath = ReturnKicadDatasPath();
|
|
|
|
if ( wxDirExists( dataPath ) ) RunBaseScripts( dataPath );
|
|
|
|
|
|
|
|
// USER Scripts:
|
2009-11-23 15:16:50 +00:00
|
|
|
wxString userDir = wxGetUserHome() + sep
|
|
|
|
+ wxString::FromAscii(".kicad.d") + sep;
|
|
|
|
if ( wxDirExists( userDir ) )
|
|
|
|
RunBaseScripts( userDir );
|
2007-05-28 18:09:49 +00:00
|
|
|
userDir = wxGetUserHome() + sep + wxString::FromAscii("_kicad_d") + sep;
|
2009-11-23 15:16:50 +00:00
|
|
|
if ( wxDirExists( userDir ) )
|
|
|
|
RunBaseScripts( userDir );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Run the script specified by 'name' */
|
2009-11-23 15:16:50 +00:00
|
|
|
bool PyHandler::RunScript( const wxString & name )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
DoInitModules();
|
|
|
|
|
|
|
|
object module( handle<>(borrowed(PyImport_AddModule("__main__"))));
|
|
|
|
object ns = module.attr( "__dict__" );
|
|
|
|
bool ret = true;
|
|
|
|
|
2008-01-28 05:49:15 +00:00
|
|
|
FILE * file = fopen( name.mb_str(), "r" );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
wxPyBlock_t blocked = wxPyBeginBlockThreads();
|
|
|
|
|
|
|
|
if ( !file )
|
|
|
|
{
|
|
|
|
// do something
|
2008-01-28 05:49:15 +00:00
|
|
|
std::cout << "Unable to Load " << name.mb_str() << "\n";
|
2007-05-28 18:09:49 +00:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString currDir = wxGetCwd();
|
|
|
|
|
|
|
|
wxFileName fname( name );
|
|
|
|
wxString pyDir = fname.GetPath();
|
|
|
|
|
|
|
|
wxSetWorkingDirectory( pyDir );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ns["currentScript"] = Convert( name );
|
2009-11-23 15:16:50 +00:00
|
|
|
handle<> ignored( PyRun_File( file, name.mb_str(), Py_file_input,
|
|
|
|
ns.ptr(), ns.ptr() ) );
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
catch ( error_already_set )
|
|
|
|
{
|
|
|
|
PyErr_Print(); // should be printed into an error message ...
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
wxSetWorkingDirectory( currDir );
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose( file );
|
|
|
|
wxPyEndBlockThreads(blocked);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
bool PyHandler::RunSimpleString( const wxString & code )
|
|
|
|
/* Run the code in 'code' */
|
|
|
|
{
|
|
|
|
wxPyBlock_t blocked = wxPyBeginBlockThreads();
|
|
|
|
try
|
|
|
|
{
|
2008-01-28 05:49:15 +00:00
|
|
|
PyRun_SimpleString( code.mb_str() );
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
catch ( error_already_set )
|
|
|
|
{
|
|
|
|
PyErr_Print(); // should be printed into an error message ...
|
|
|
|
wxPyEndBlockThreads(blocked);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPyEndBlockThreads(blocked);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PyHandler::SetAppName( const wxString & name )
|
|
|
|
/* Set the application name in the python scope */
|
|
|
|
{
|
|
|
|
m_appName = name;
|
2009-11-23 15:16:50 +00:00
|
|
|
object module( ( handle<>( borrowed( PyImport_AddModule( "__main__") ) ) ) );
|
2007-05-28 18:09:49 +00:00
|
|
|
object ns = module.attr( "__dict__" );
|
2009-11-23 15:16:50 +00:00
|
|
|
try
|
|
|
|
{
|
2007-05-28 18:09:49 +00:00
|
|
|
ns["kicadApp"] = std::string( name.ToAscii() );
|
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
catch( error_already_set )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
PyErr_Print();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
const char * PyHandler::GetVersion() { return Py_GetVersion(); }
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
// Event handling :
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
void PyHandler::DeclareEvent( const wxString & key )
|
|
|
|
{
|
|
|
|
m_EventRegistry.push_back( Event( key ) );
|
|
|
|
}
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
int PyHandler::GetEventIndex( const wxString & key )
|
|
|
|
{
|
|
|
|
for ( unsigned int i = 0; i < m_EventRegistry.size(); i ++ )
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
if ( m_EventRegistry[i].key == key )
|
|
|
|
return i;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
void PyHandler::TriggerEvent( const wxString & key )
|
|
|
|
{
|
|
|
|
TriggerEvent( key, str( "" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
void PyHandler::TriggerEvent( const wxString & key, const object & param )
|
|
|
|
{
|
|
|
|
|
|
|
|
int i = GetEventIndex( key );
|
2009-11-23 15:16:50 +00:00
|
|
|
if ( -1 == i )
|
|
|
|
return;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
wxPyBlock_t blocked = wxPyBeginBlockThreads();
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
for( unsigned int j = 0; j < m_EventRegistry[i].functors.size(); j++ )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_EventRegistry[i].functors[j]( param );
|
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
catch( error_already_set )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
std::cout << "Error in event " << key.mb_str() << " callback"
|
|
|
|
<< std::endl;
|
2007-05-28 18:09:49 +00:00
|
|
|
PyErr_Print();
|
|
|
|
}
|
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
wxPyEndBlockThreads( blocked );
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
void PyHandler::RegisterCallback( const wxString & key,
|
|
|
|
const object & callback )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
int i = GetEventIndex( key );
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
if( -1 == i )
|
|
|
|
return;
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
m_EventRegistry[i].functors.push_back( callback );
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
void PyHandler::UnRegisterCallback( const wxString & key,
|
|
|
|
const object & callback )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
int i = GetEventIndex( key );
|
2009-11-23 15:16:50 +00:00
|
|
|
if( -1 == i )
|
|
|
|
return;
|
|
|
|
for( unsigned int j = 0; j < m_EventRegistry[i].functors.size() ; j++ )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
if ( callback == m_EventRegistry[i].functors[j] )
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
m_EventRegistry[i].functors.erase(
|
|
|
|
m_EventRegistry[i].functors.begin() + j );
|
2007-05-28 18:09:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
// Object conversion:
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
wxString PyHandler::MakeStr( const object & objStr )
|
|
|
|
{
|
|
|
|
return wxString( extract<const char *>( objStr ), wxConvLocal );
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
object PyHandler::Convert( const wxString & wxStr )
|
|
|
|
{
|
|
|
|
return str( std::string( wxStr.mb_str() ).c_str() );
|
|
|
|
}
|