By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

pycxx and multiple new types

P: n/a

I have been using pycxx 5.2.2 to write an extension module which
defines two new types, Point and Bbox. The Bbox is constructed with 2
Point instances

class Point: public Py::PythonExtension<Point> ...

class Bbox: public Py::PythonExtension<Bbox> {
Bbox(Point& ll, Point& ur) : _ll(ll), _ur(ur) {};
static void init_type(void);

// return lower left point
Py::Object ll(const Py::Tuple &args) { return Py::Object(&_ll); }

// return upper right point
Py::Object ur(const Py::Tuple &args) { return Py::Object(&_ur); }

Point& _ll, _ur;
The problem I am having is that if I instantiate a Bbox from 2 point
instances, my python test code hangs after the last line of the script
and doesn't return the shell prompt until I hit CTRL-C.

ll = Point(10, 10)
ur = Point(20, 20)
bbox = Bbox(ll, ur) # this line causes the hang.

I think this is because I am not handling the ref count of the Point
objects properly.

My new_bbox function looks like
Py::Object _transforms_module::new_bbox (const Py::Tuple &args)



Point* ll = (Point*)(args[0].ptr());
Point* ur = (Point*)(args[1].ptr());
return Py::asObject(new Bbox(*ll, *ur) );

Do you have any thoughts on what I am doing wrong?

John Hunter
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.