Extending a C++ App

Bwuce_Wee bwucew at yahoo.com
Fri Sep 13 03:52:12 EDT 2002


Thanks for your help

I looked at SWIG
However I have a few concerns (forgive me if Im being dense)

(1) All the examples are created as DLLs (ie APIs)
    This is fine - except how would my C++ App use the same object instances?
    (ie. share the memory and API objects)

(2) SWIG does not do a nice job of object wrapping (in my opinion)
    For instance instead of saying
      c = example.Circle
      c.x = 10
      c.y = 20
      del c

    I need to do this:
      c = example.new_Circle()
      example.Shape_x_set(c,10)
      example.Shape_y_set(c,20)
      delete_Circle(c)

    Isn't there a cleaner library somewhere to do this?
    SIP has no documentation - so I don't know what to expect of it

    I'm busy investigating Boost.Python...

Thanks again for the help

Greg Green <gregory.p.green at boeing.com> wrote in message news:<n0qnhvfn.fsf at boeing.com>...
> Embedding python inside an application can be simple. The basic step
> is to call Py_Initialize(). After that you can execute python code
> with the PyRun_* functions. Of course, in practice, there is a lot
> more to worry about. Threads and the GIL, if you are using a GUI, you
> have to worry about the event loop, etc.
> 
> Accessing your c++ object model requires you to wrap them just as if
> you were going to use the model in a python program. The normal
> answers are swig, sip, boost and some others. I've used both swig,
> sip, and writing the wrapper by hand. All will work. Once the api is
> wrapped, the resulting code is either statically or dynamically linked to
> your exe.



More information about the Python-list mailing list