Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
b0b3a6d5
Commit
b0b3a6d5
authored
Aug 12, 2007
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move Python.h up so things would even compile
parent
74f295d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
64 deletions
+76
-64
pyhandler.h
include/pyhandler.h
+76
-64
No files found.
include/pyhandler.h
View file @
b0b3a6d5
/****************************/
/* pyhandler.h */
/****************************/
/****************************/
/* pyhandler.h */
/****************************/
#ifndef PYHANDLER_H
#define PYHANDLER_H
#include <wx/string.h>
#include <Python.h>
#include <wx/wxPython/wxPython.h>
#include <vector>
/* Use the boost library : */
#include <boost/python.hpp>
#include <Python.h>
class
PyHandler
{
typedef
void
(
*
initfunc_t
)();
private
:
static
PyHandler
*
m_instance
;
bool
m_ModulesLoaded
;
int
m_current
;
PyThreadState
*
m_mainTState
;
private
:
static
PyHandler
*
m_instance
;
bool
m_ModulesLoaded
;
int
m_current
;
PyThreadState
*
m_mainTState
;
protected
:
PyHandler
();
protected
:
PyHandler
();
wxString
m_appName
;
void
RunBaseScripts
(
const
wxString
&
base
);
// Modules
struct
ModuleRecord
{
wxString
name
;
std
::
vector
<
initfunc_t
>
registry
;
wxString
m_appName
;
void
RunBaseScripts
(
const
wxString
&
base
);
ModuleRecord
(
const
wxString
&
modName
)
:
name
(
modName
)
{}
};
std
::
vector
<
ModuleRecord
>
m_ModuleRegistry
;
void
DoInitModules
();
// Modules
struct
ModuleRecord
{
wxString
name
;
std
::
vector
<
initfunc_t
>
registry
;
// Events
struct
Event
ModuleRecord
(
const
wxString
&
modName
)
:
name
(
modName
)
{
wxString
key
;
std
::
vector
<
boost
::
python
::
object
>
functors
;
}
};
std
::
vector
<
ModuleRecord
>
m_ModuleRegistry
;
void
DoInitModules
();
// Events
struct
Event
{
wxString
key
;
std
::
vector
<
boost
::
python
::
object
>
functors
;
Event
(
const
wxString
&
strKey
)
:
key
(
strKey
)
{
}
};
std
::
vector
<
Event
>
m_EventRegistry
;
Event
(
const
wxString
&
strKey
)
:
key
(
strKey
)
{}
};
std
::
vector
<
Event
>
m_EventRegistry
;
public
:
public
:
// Singletton handling:
static
PyHandler
*
GetInstance
();
// Singletton handling:
static
PyHandler
*
GetInstance
();
~
PyHandler
();
~
PyHandler
();
// Scope params/handling:
void
SetAppName
(
const
wxString
&
name
);
// Scope params/handling:
void
SetAppName
(
const
wxString
&
name
);
void
AddToModule
(
const
wxString
&
name
,
initfunc_t
initfunc
);
int
GetModuleIndex
(
const
wxString
&
name
)
const
;
void
AddToModule
(
const
wxString
&
name
,
initfunc_t
initfunc
);
int
GetModuleIndex
(
const
wxString
&
name
)
const
;
// Script and direct call
void
RunScripts
();
bool
RunScript
(
const
wxString
&
name
);
bool
RunSimpleString
(
const
wxString
&
code
);
// Script and direct call
void
RunScripts
();
bool
RunScript
(
const
wxString
&
name
);
bool
RunSimpleString
(
const
wxString
&
code
);
// Common Informations
const
char
*
GetVersion
();
// Common Informations
const
char
*
GetVersion
();
void
InitNextModule
();
void
InitNextModule
();
// Event triggering
// Event triggering
// - C++ interface
void
DeclareEvent
(
const
wxString
&
key
);
void
TriggerEvent
(
const
wxString
&
key
);
void
TriggerEvent
(
const
wxString
&
key
,
const
boost
::
python
::
object
&
param
);
int
GetEventIndex
(
const
wxString
&
key
);
// - C++ interface
void
DeclareEvent
(
const
wxString
&
key
);
void
TriggerEvent
(
const
wxString
&
key
);
void
TriggerEvent
(
const
wxString
&
key
,
const
boost
::
python
::
object
&
param
);
int
GetEventIndex
(
const
wxString
&
key
);
// - Py Interface
void
RegisterCallback
(
const
wxString
&
key
,
const
boost
::
python
::
object
&
obj
);
void
UnRegisterCallback
(
const
wxString
&
key
,
const
boost
::
python
::
object
&
obj
);
// - Py Interface
void
RegisterCallback
(
const
wxString
&
key
,
const
boost
::
python
::
object
&
obj
);
void
UnRegisterCallback
(
const
wxString
&
key
,
const
boost
::
python
::
object
&
obj
);
// Object conversions
// Object conversions
// - Py -> C++
static
wxString
MakeStr
(
const
boost
::
python
::
object
&
objStr
);
// - Py -> C++
static
wxString
MakeStr
(
const
boost
::
python
::
object
&
objStr
);
// - C++ -> Py
static
boost
::
python
::
object
Convert
(
const
wxString
&
wxStr
);
// - C++ -> Py
static
boost
::
python
::
object
Convert
(
const
wxString
&
wxStr
);
};
#define KICAD_PY_BIND_MODULE( mod ) PyHandler::GetInstance()->AddModule( init#mod )
#endif //PYHANDLER_H
#define KICAD_PY_BIND_MODULE( mod ) PyHandler::GetInstance()->AddModule( init # mod )
#endif //PYHANDLER_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment