[Cython] Class methods returning C++ class references are not dealt with correctly?

Yury V. Zaytsev yury at shurup.com
Thu Feb 28 19:38:29 CET 2013


Hi Brad,

On Thu, 2013-02-28 at 08:01 -0800, Bradley M. Froehle wrote:
> 
> cdef extern from "test.h":
>     int* foo2ptr "&foo" ()
> 
> cdef int *x = foo2ptr()

Thank you for this interesting suggestion, but I must be missing
something, because when I do the following:

    cdef extern from "tokenstack.h":
        cppclass TokenStack:
            Token* top "Token&" () except +

    cdef Token* tok = self.pEngine.OStack.top()

I end up with the following generated code, which, of course, doesn't
compile:

    Token *__pyx_t_5;
    __pyx_t_5 = __pyx_v_self->pEngine->OStack.Token&();

whereas, I'd like to see generated this:

    Token *__pyx_t_5;
    __pyx_t_5 = __pyx_v_self->pEngine->OStack->top();

Any ideas?

-- 
Sincerely yours,
Yury V. Zaytsev




More information about the cython-devel mailing list