Extending a C++ App

Phil Thompson phil at river-bank.demon.co.uk
Fri Sep 13 10:25:22 CEST 2002


Bwuce_Wee wrote:

> 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


A .sip file containing...

%Module example

class Circle
{
%HeaderCode
#include "circle.h"
%End
public:
     int x, y;
};

...would generate a module where you...

import example

c = example.Circle()
c.x = 10
c.y = 20
del c

While documentation is obviously a problem, there are enough people on 
the PyKDE mailing list who have made the necessary blood sacrifices to 
be able to help.

Phil





More information about the Python-list mailing list