On Feb 8, 2010, at 7:33 AM, Stefan Behnel wrote: > Hi, > > I'm trying to implement the PyBindGen micro-benchmarks in cython- > devel by > wrapping this source file: > > http://bazaar.launchpad.net/~gjc/pybindgen/trunk/annotate/735/benchmarks/testapi.cc > http://bazaar.launchpad.net/~gjc/pybindgen/trunk/annotate/735/benchmarks/testapi.h > > (I know, few Cython users would wrap code at that granularity, but > that's > about the limit of what PyBindGen can handle.) > > The API is basically this (I attached the two wrapper source files I > wrote): > > ------------------ > cdef extern from "testapi.h": > void func1() > double func2(double x, double y, double z) > > cdef cppclass Multiplier: > Multiplier() > Multiplier(double factor) > void SetFactor() > void SetFactor(double f) > double GetFactor() > double Multiply(double value) > > double call_virtual_from_cpp (Multiplier *obj, double value) > ------------------ > > Cython parses this just fine - however, when I try to call the > SetFactor > method in Cython code, I get this: > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > def __dealloc__(self): > del self.multiplier > > def SetFactor(self, f=None): > if f is None: > self.multiplier.SetFactor() > ^ > ------------------------------------------------------------ > .../pytestapi.pyx:18:37: Call with wrong number of arguments > (expected 1, > got 0) > > The exact error depends on the order in which I declare the two > methods. It > seems that the last declaration wins. And Cython also doesn't complain > about the constructor call right two methods above, so that seems to > have > worked. > > Is this supposed to work for regular C++ methods?
Yes, this should have worked. I'm surprised there aren't any tests for this... - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
