[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Changing base class arguments
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2012-08-24 9:20:36
Message-ID: d66e948fc0b6b0556621c1bf2304e168 () localhost
[Download RAW message or body]

On Thu, 23 Aug 2012 16:37:45 +0200, Marco Meier <marco.meier@ifak.eu>
wrote:
> Hi,
> 
> i'm trying to wrap a C++ class with virtual methods using SIP. This
> class takes an auto_ptr pointing to another class as argument to the
> only defined constructor.
> 
> Without virtual methods, i used %MethodCode to create an object of this
> class using a const char * as argument. With virtual methods, this is
> not possible, since the constructor of the base class is called prior to
> the constructor.
> 
> Is there a way to change the initializer list to something like
> 
> sipwrapped_class(const char *a0) :
> wrapped_class(some_static_method(a0)), .. {}
> 
> or is there another way to do this with SIP?

The way to do it is to specify an explicit signature for the ctor and to
use %MethodCode...

typedef void *auto_ptr;

class Foo
{
public:
    Foo(const char *) [(auto_ptr)];
%MethodCode
        sipCpp = new sipFoo(some_static_method(a0));
%End
};

The only odd thing here is the auto_ptr typedef which is needed (although
never used in the generated code) because SIP needs to know a fundamental
type (but not necessarily the correct fundamental type) for every argument
of a C++ signature. I will change it so that the typedef isn't needed - but
it doesn't do any harm.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic