logo       

Re: Smartpointer and references: msg#00179

programming.swig

Subject: Re: Smartpointer and references


On Mon, 27 Sep 2004, Felix Domke wrote:

> i'm having a usual smartpointer class, let's call it "SmartPtr".
>
> then i have
>
> class Foo;
> typedef SmartPtr<Foo> FooPtr;
>
> class Foo
> {
> static Foo *instance;
> public:
> static RESULT getInstance(FooPtr &ptr) { ptr = instance; return 0; }
> /*... plus error checking */
> };
>
> Now i'd like to use something like
>
> instance = FooPtr()
> Foo.getInstance(instance)
>
> in python, but i get
>
> "TypeError: Expected a pointer" on the "getInstance" call.
>
> Is there something special to account when using references at all?

I'm confused. Your typedef should not give you a FooPtr proxy class (you
need to use %template). However, there should be an unrelated FooPtr
class in Python, due to the way proxy classes are implemented (every class
has a corresponding class named SomethingPtr). However, this should not
have an argumentless constructor. What is "instance", i.e., what is the
result of "print instance"?

Josh

--
Joshua L. Cherry, Ph.D.
NCBI/NLM/NIH (Contractor)
jcherry@xxxxxxxxxxxxxxxx

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise