J
John Hunter
I am using pycxx 5.2.2. and am trying to write a callable class. The
docs suggest you need to override
virtual Object call( const Object &, const Object & );
in your extension and call supportcall in your init_type function, eg
void XYFunc::init_type()
{
behaviors().name("XYFunc");
behaviors().doc("Map x,y -> x,y");
behaviors().supportCall();
}
I have a couple of questions:
* what are the two Object arguments to call? I would have expected
the signature to be
virtual Object call( const Py::Tuple& args);
* For testing, I defined a do nothing call, that just prints to std
out
class XYFunc : public Py:ythonExtension<XYFunc> {
public:
static void init_type(void);
Py::Object call(const Py::Object &o1, const Py::Object &o2) {
std::cout << "you rang" << std::endl;
return Py::Object();
}
};
but I get the following error when I try and test it
Traceback (most recent call last):
File "_transforms_test.py", line 7, in ?
func()
TypeError: CXX: type error.
Ditto when I pass func(x,y), func((x,y)) etc...
Any insight? I couldn't find any examples in distro that actually use
callable.
JDH
docs suggest you need to override
virtual Object call( const Object &, const Object & );
in your extension and call supportcall in your init_type function, eg
void XYFunc::init_type()
{
behaviors().name("XYFunc");
behaviors().doc("Map x,y -> x,y");
behaviors().supportCall();
}
I have a couple of questions:
* what are the two Object arguments to call? I would have expected
the signature to be
virtual Object call( const Py::Tuple& args);
* For testing, I defined a do nothing call, that just prints to std
out
class XYFunc : public Py:ythonExtension<XYFunc> {
public:
static void init_type(void);
Py::Object call(const Py::Object &o1, const Py::Object &o2) {
std::cout << "you rang" << std::endl;
return Py::Object();
}
};
but I get the following error when I try and test it
Traceback (most recent call last):
File "_transforms_test.py", line 7, in ?
func()
TypeError: CXX: type error.
Ditto when I pass func(x,y), func((x,y)) etc...
Any insight? I couldn't find any examples in distro that actually use
callable.
JDH