py cxx callable

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::pythonExtension<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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top