Python as scripting plug-in for large C++ project

kuhlman dkuhlman at rexx.com
Sat Apr 27 17:35:01 EDT 2002


SWIG is great.  But, if you decide to write your glue code by hand, 
you may want to implement your own Python data types.  It's really 
not that hard. If you decide to do this, be sure to look at 
Objects/xxobject.c in the Python source code distribution.  It 
gives a template for implementing new data types.  And for hints 
and clues, also look at the implementation of some other the other 
Python data types (lists, strings, etc) in the Objects subdirectory.

Also see "2. Defining New Types" in "Extending and Embedding the 
Python Interpreter" in the Python standard documentation.

And, if you have *lots* of Python type extensions that you want to 
implement, you might even want to look at my dtGenerator.py, which 
will generate the implementation of a Python type from a 
specification.  Although, you will probably want to implement one 
type extension in C by hand, and then adjust the templates in 
dtGenerator.py for your own use.  dtGenerator.py assumes that there 
is an underlying C data type (and a struct) that you want to 
"wrapper".  You can find dtGenerator.py at 
http://www.rexx.com/~dkuhlman .

  - Dave


Daniel Dittmar wrote:

> Bjorn Pettersen wrote:
> 
>>  - We extensively (exclusively) use our own basic datatypes,
>>    e.g. NInteger which in addition to keeping a value also
>>    stores whether it is NULL (think databases). How much work
>>    is it going to be to expose these to embedded Python?
> 

-- 
Dave Kuhlman
dkuhlman at rexx.com
http://www.rexx.com/~dkuhlman




More information about the Python-list mailing list