-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
Tested with commit d0e9a5 (Feb 9, 2015).
It's impossible to wrap a C++ function returning a reference variable (even when "&" is omitted),
because the generated ".pyx"-file is invalid.
(Autowrap succeeds to generate the ".pyx"-file, but Cython fails to compile it.)
Test code:
cdef extern from "<string>" namespace "std":
cdef cppclass string:
string()
string& assign (string&)
and the result:
<snip>
Autwrap has wrapped 1 classes, 2 methods and 0 enums
Error compiling Cython file:
------------------------------------------------------------
...
self.inst = shared_ptr[_string](new _string())
def assign(self, string in_0 ):
assert isinstance(in_0, string), 'arg in_0 wrong type'
cdef _string & * _r = new _string &(self.inst.get().assign((deref(in_0.inst.get()))))
^
------------------------------------------------------------
something.pyx:30:93: Expected ')', found 'NEWLINE'
And if the "&" is omitted, such that the code becomes:
cdef extern from "<string>" namespace "std":
cdef cppclass string:
string()
string assign (string&)
then the result becomes:
<snip>
Autwrap has wrapped 1 classes, 2 methods and 0 enums
Error compiling Cython file:
------------------------------------------------------------
...
self.inst = shared_ptr[_string](new _string())
def assign(self, string in_0 ):
assert isinstance(in_0, string), 'arg in_0 wrong type'
cdef _string * _r = new _string(self.inst.get().assign((deref(in_0.inst.get()))))
^
------------------------------------------------------------
something.pyx:30:39: Call with wrong number of arguments (expected 0, got 1)
Metadata
Metadata
Assignees
Labels
No labels