[Pyrex] C++ issue
Ravi Lanka
ravi_lanka at acusim.com
Mon Apr 28 18:26:03 CEST 2008
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()
-------------------------
More information about the Pyrex
mailing list