pythonBuffer.h
defines an automatic reflection of types and
objects to Python (Python3 stable API targeted). To use this, include
this header file, and then use the following macros to define objects,
functions and types in the Python module being created:
object
to the module. It should be without any namespace
qualifications, as Python cannot copy with colons in identifier names,
but the macro can be used within any namespace.
x=MyType()
, where
MyType
is the name of a C++ type with a default constructor.
Note if you need to pass parameters at construction time, then you
can specify optional argument types:
CLASSDESC_DECLARE_TYPE(IntType,int)
, which gets called form
Python as x=IntType(0)
.
Once all objects are declared with these macros, finish off with
CLASSDESC_PYTHON_MODULE(name)
, where name is the name of the
module, which should match the name of the dynamic library.
NB for Windows users, you may need to compile and link
pythonCAPI.cc
, which provides stub routines for the Python C
API to satisfy the linker.
An example of all this workign can be found in the RESTProcessExample directory.