<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 11, 2015 at 10:09 AM Michael Enßlin <michael@ensslin.cc> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi guys,<br>
<br>
have a look at this:<br>
<br>
$ cat bar.pyx<br>
cdef extern from "foo.h":<br>
    cdef cppclass Foo:<br>
        int operator() (int arg)<br>
        int do_call (int arg)<br>
<br>
<br>
cdef int bar(int arg):<br>
    cdef Foo foo<br>
    foo.do_call(arg)<br>
    return foo(arg)<br>
<br>
$ cython3 --cplus bar.pyx<br>
$ cat bar.cpp<br>
<br>
(...)<br>
<br>
static int __pyx_f_3bar_bar(int __pyx_v_arg) {<br>
  Foo __pyx_v_foo;<br>
  int __pyx_r;<br>
  __Pyx_RefNannyDeclarations<br>
  __Pyx_RefNannySetupContext("bar", 0);<br>
<br>
  /* "bar.pyx":9<br>
 * cdef int bar(int arg):<br>
 *     cdef Foo foo<br>
 *     foo.do_call(arg)             # <<<<<<<<<<<<<<<br>
 *     return foo(arg)<br>
 */<br>
  __pyx_v_foo.do_call(__pyx_v_arg);<br>
<br>
  /* "bar.pyx":10<br>
 *     cdef Foo foo<br>
 *     foo.do_call(arg)<br>
 *     return foo(arg)             # <<<<<<<<<<<<<<<br>
 */<br>
  __pyx_r = operator()(__pyx_v_arg);<br>
  goto __pyx_L0;<br>
<br>
  /* "bar.pyx":7<br>
 *<br>
 *<br>
 * cdef int bar(int arg):             # <<<<<<<<<<<<<<<br>
 *     cdef Foo foo<br>
 *     foo.do_call(arg)<br>
 */<br>
<br>
  /* function exit code */<br>
  __pyx_L0:;<br>
  __Pyx_RefNannyFinishContext();<br>
  return __pyx_r;<br>
}<br>
<br>
(...)<br>
<br>
<br>
<br>
Note how the function invocation for "do_call" is generated correctly,<br>
but the invocation of operator() is nonsensical.<br>
<br>
The correct line would be this:<br>
<br>
  __pyx_r = __pyx_v_foo(__pyx_v_arg);<br>
<br>
Happy debugging :D<br>
<br>
        ~ mic_e<br>
<br>
_______________________________________________<br>
cython-devel mailing list<br>
<a href="mailto:cython-devel@python.org" target="_blank">cython-devel@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/cython-devel" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/cython-devel</a></blockquote><div><br></div><div>There was a patch for this in <a href="https://mail.python.org/pipermail/cython-devel/2015-February/004328.html">https://mail.python.org/pipermail/cython-devel/2015-February/004328.html</a>. I'm not sure what  ever became of it though. I wrote up a workaround on SO at <a href="http://stackoverflow.com/a/25955546/1935144">http://stackoverflow.com/a/25955546/1935144</a> a while ago.</div><div>Best of luck!</div><div>-Ian Henriksen</div></div></div>