wrapping abstract classes in python

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

wrapping abstract classes in python

Robert Jones-2
As best as I can decipher from the Swig guide, I should be able to do this....

%module Test

%{
struct A {
    A( ) { }
    virtual void afunction( ) = 0;
    };
%}

struct A {
    A( );
    virtual void afunction( ) = 0;
    };

in my interface file, and then run swig...

swig -v -c++ -python Test.i

all works perfectly, except that I cannot derive from the 'A' class in Python because the
proxy class generated by Swig has an __init__ function which just invokes a RuntimeError
exception. Any ideas anyone?

Rob.
Reply | Threaded
Open this post in threaded view
|

Re: wrapping abstract classes in python

Marcelo Matus
Since A is abstract, it can't be constructed at the python side,
unless you use directors.

Check the docs for directors.

Marcelo


Robert Jones wrote:

> As best as I can decipher from the Swig guide, I should be able to do
> this....
>
> %module Test
>
> %{
> struct A {
>     A( ) { }
>     virtual void afunction( ) = 0;
>     };
> %}
>
> struct A {
>     A( );
>     virtual void afunction( ) = 0;
>     };
>
> in my interface file, and then run swig...
>
> swig -v -c++ -python Test.i
>
> all works perfectly, except that I cannot derive from the 'A' class in
> Python because the
> proxy class generated by Swig has an __init__ function which just
> invokes a RuntimeError
> exception. Any ideas anyone?
>
> Rob.




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user