golib  0.5
Python embedding

The namespace goPython contains wrappers and helpers to simplify setting/getting, amongst others, SWIG wrapped objects to and from an embedded interpreter. goPython::init() initialises the interpreter, goPython::final() ends it. There are several set and get functions to enable cooperation between C++ and the python interpreter by sharing variables. All SWIG wrapped variables are shared over their pointers, so there is no deep copying involved. More set/get function pairs can be easily added for other swig wrapped objects by using the provided macros or the setSwigPointer() and getSwigPointer() template functions. More...

Namespaces

 goPython
 Python embedding. Make sure there exists only one python interpreter. Possibly there can be one per thread, but that is not tested. This is all quite new.
 

Macros

#define GOPYTHON_GETSET_DEFINITION(type_spec, py_type_spec, spec)
 Macro to add a definition of a get/set pair to goPython. More...
 

Detailed Description

The namespace goPython contains wrappers and helpers to simplify setting/getting, amongst others, SWIG wrapped objects to and from an embedded interpreter. goPython::init() initialises the interpreter, goPython::final() ends it. There are several set and get functions to enable cooperation between C++ and the python interpreter by sharing variables. All SWIG wrapped variables are shared over their pointers, so there is no deep copying involved. More set/get function pairs can be easily added for other swig wrapped objects by using the provided macros or the setSwigPointer() and getSwigPointer() template functions.

Macro Definition Documentation

◆ GOPYTHON_GETSET_DEFINITION

#define GOPYTHON_GETSET_DEFINITION (   type_spec,
  py_type_spec,
  spec 
)
Value:
type_spec* goPython::get##spec (const char* name, bool own_it) \
{ \
const char* type_str = #py_type_spec " *"; \
printf ("%s\n", type_str); \
return getSwigPointer<type_spec> (name, own_it, type_str); \
} \
void goPython::set (const char* name, type_spec *o, bool own_it) \
{ \
const char* type_str = #py_type_spec " *"; \
setSwigPointer<type_spec> (name, o, own_it, type_str); \
}

Macro to add a definition of a get/set pair to goPython.

adds void goPython::set (const char* name, type_spec* o, bool own_it)
and type_spec* goPython::get##spec (const char* name, bool own_it)

Parameters
type_specc++ Type name
py_type_specpython type identifier (used in getSwigPointer()).
specName extension for the get function.