[Cython] Class methods returning C++ class references are not dealt with correctly?
Bradley M. Froehle
brad.froehle at gmail.com
Thu Feb 28 20:00:18 CET 2013
Hey Yury:
Yes, you are right. I was thinking this was a function and not a method.
As an even ickier workaround:
#define TokenStack_top_p(token_stack) &token_stack->top()
cdef extern from "............":
Token* TokenStack_top_p(TokenStack*) except +
cdef Token* tok = TokenStack_top_p(self.pEngine.OStack)
-Brad
On Thu, Feb 28, 2013 at 10:38 AM, Yury V. Zaytsev <yury at shurup.com> wrote:
> 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
>
>
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20130228/d4220ce7/attachment.html>
More information about the cython-devel
mailing list