Commit b0b3a6d5 authored by dickelbeck's avatar dickelbeck

move Python.h up so things would even compile

parent 74f295d6
/****************************/ /****************************/
/* pyhandler.h */ /* pyhandler.h */
/****************************/ /****************************/
#ifndef PYHANDLER_H #ifndef PYHANDLER_H
#define PYHANDLER_H #define PYHANDLER_H
#include <wx/string.h> #include <wx/string.h>
#include <Python.h>
#include <wx/wxPython/wxPython.h> #include <wx/wxPython/wxPython.h>
#include <vector> #include <vector>
/* Use the boost library : */ /* Use the boost library : */
#include <boost/python.hpp> #include <boost/python.hpp>
#include <Python.h>
class PyHandler class PyHandler
{ {
typedef void (*initfunc_t )(); typedef void (*initfunc_t )();
private: private:
static PyHandler * m_instance; static PyHandler* m_instance;
bool m_ModulesLoaded; bool m_ModulesLoaded;
int m_current; int m_current;
PyThreadState* m_mainTState; PyThreadState* m_mainTState;
protected: protected:
PyHandler(); PyHandler();
wxString m_appName; wxString m_appName;
void RunBaseScripts( const wxString & base ); void RunBaseScripts( const wxString& base );
// Modules // Modules
struct ModuleRecord struct ModuleRecord
...@@ -38,9 +37,15 @@ class PyHandler ...@@ -38,9 +37,15 @@ class PyHandler
wxString name; wxString name;
std::vector< initfunc_t > registry; std::vector< initfunc_t > registry;
ModuleRecord( const wxString & modName ) : name(modName) {} ModuleRecord( const wxString &modName ) :
name( modName )
{
}
}; };
std::vector< ModuleRecord > m_ModuleRegistry; std::vector< ModuleRecord > m_ModuleRegistry;
void DoInitModules(); void DoInitModules();
// Events // Events
...@@ -49,55 +54,62 @@ class PyHandler ...@@ -49,55 +54,62 @@ class PyHandler
wxString key; wxString key;
std::vector< boost::python::object > functors; std::vector< boost::python::object > functors;
Event( const wxString & strKey ) : key( strKey ) {} Event( const wxString &strKey ) :
key( strKey )
{
}
}; };
std::vector< Event > m_EventRegistry; std::vector< Event > m_EventRegistry;
public: public:
// Singletton handling: // Singletton handling:
static PyHandler * GetInstance(); static PyHandler* GetInstance();
~PyHandler(); ~PyHandler();
// Scope params/handling: // Scope params/handling:
void SetAppName( const wxString & name ); void SetAppName( const wxString& name );
void AddToModule( const wxString & name, initfunc_t initfunc ); void AddToModule( const wxString& name, initfunc_t initfunc );
int GetModuleIndex( const wxString & name ) const; int GetModuleIndex( const wxString& name ) const;
// Script and direct call // Script and direct call
void RunScripts(); void RunScripts();
bool RunScript( const wxString & name ); bool RunScript( const wxString& name );
bool RunSimpleString( const wxString & code ); bool RunSimpleString( const wxString& code );
// Common Informations // Common Informations
const char * GetVersion(); const char* GetVersion();
void InitNextModule(); void InitNextModule();
// Event triggering // Event triggering
// - C++ interface // - C++ interface
void DeclareEvent( const wxString & key ); void DeclareEvent( const wxString& key );
void TriggerEvent( const wxString & key ); void TriggerEvent( const wxString& key );
void TriggerEvent( const wxString & key, const boost::python::object & param ); void TriggerEvent( const wxString& key,
int GetEventIndex( const wxString & key ); const boost::python::object& param );
int GetEventIndex( const wxString& key );
// - Py Interface // - Py Interface
void RegisterCallback ( const wxString & key, const boost::python::object & obj ); void RegisterCallback( const wxString& key,
void UnRegisterCallback( const wxString & key, const boost::python::object & obj ); const boost::python::object& obj );
void UnRegisterCallback( const wxString& key,
const boost::python::object& obj );
// Object conversions // Object conversions
// - Py -> C++ // - Py -> C++
static wxString MakeStr( const boost::python::object & objStr ); static wxString MakeStr( const boost::python::object& objStr );
// - C++ -> Py // - C++ -> Py
static boost::python::object Convert( const wxString & wxStr ); static boost::python::object Convert( const wxString& wxStr );
}; };
#define KICAD_PY_BIND_MODULE( mod ) PyHandler::GetInstance()->AddModule( init#mod ) #define KICAD_PY_BIND_MODULE( mod ) PyHandler::GetInstance()->AddModule( init # mod )
#endif //PYHANDLER_H #endif //PYHANDLER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment