C++ issue

Ravi Lanka <[email protected]>
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
Pyrex gurus,

  I am trying to wrap a C++ library and have been successful for the 
most part (thanks to you guys).  One of the classes that I need to wrap 
does not contain a default constructor (see code below ).  The cpp file 
that gets created complains that "foo" does not contain a default 
constructor [ cdef foo f  is invalid ].  At the same time, I cannot say 
"cdef foo f = b.getFoo()". My solution was to build the cpp file from 
the pyrex code below and then create a line that says;

cdef foo f = b.getFoo() instead of  "f = b.getFoo",

and remove the initial declaration.  It works for what I am doing, but I 
am afraid that there could be some reference count issues.  
Unfortunately, the argument required by the constructor of foo class is 
neither required nor available in my wrapper code.

Any Ideas ?
thanks in advance.

Ravi

------------------
class foo {
    public:
        foo( templatedClassObject  unAvailable );
        int (*getItems) { return 1; }
};

class bar {
    public:
        bar();
        foo& getFoo() { return fooObj; }
};

pyrex:

cdef extern from "foo.h":
    ctypedef struct foo "foo":
        int (*getItems)()

cdef extern from "bar.h":
    ctypedef struct bar "bar":
        foo (*getFoo)()

    bar *barFactory "new bar"()
    void deleteBar "delete "(bar *barObj)

def test():
    cdef    bar   b
    cdef    foo   f
    ### b is populated through some calculations here
    f = b.getFoo()
-------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.