Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Hans Meine
Am Donnerstag, 1. September 2011, 22:52:56 schrieb Jim Bosch: > Yup. With boost::shared_ptr, you don't even need to include it as a > template argument of class_, if you instead add the line: > > boost::python::register_ptr_to_python< boost::shared_ptr >(); > > This allows you to return shared_p

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Hans Meine
Am Freitag, 2. September 2011, 04:31:24 schrieb Josh Stratton: > BOOST_PYTHON_MODULE(scene) > { > class_("Scene"); > } > > // later calling this > boost::python::register_ptr_to_python< boost::shared_ptr >(); > PyImport_AppendInittab("scene", &initscene); > > So is this all I really need for

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Josh Stratton
This is where I'm calling the function inside Scene, by the way, and getting that error. object processFileFunc = _pyMainModule.attr("MeshImporter").attr("processFile"); processFileFunc(this, fileName); // right here, where the python func takes a scene object and filename I haven't touched this

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Dave Abrahams
on Thu Sep 01 2011, Jim Bosch wrote: > boost::python::register_ptr_to_python< boost::shared_ptr >(); > > This allows you to return shared_ptr to Python, but because a > boost::shared_ptr can use an arbitrary deleter, Boost.Python can > convert any wrapped Scene object (even one that doesn't hold

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Josh Stratton
Well, right now I'm just passing "this" from inside the scene object, so does that need to be wrapped in a shared pointer? On Fri, Sep 2, 2011 at 12:19 PM, Dave Abrahams wrote: > > on Thu Sep 01 2011, Jim Bosch wrote: > >> boost::python::register_ptr_to_python< boost::shared_ptr >(); >> >> This

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Dave Abrahams
on Fri Sep 02 2011, Josh Stratton wrote: > Well, right now I'm just passing "this" from inside the scene object, > so does that need to be wrapped in a shared pointer? That's a pretty vague description of what you're doing, so it's hard to say. I suggest you reduce your question to a minimal c

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Josh Stratton
Here's a really short example of what I don't understand. Basically I can setup the python function to accept shared pointers, but can I setup it to also use normal pointers? In the example code attached, if I uncomment scene->sendYourselfToPython(); it fails because it's using "this" as the scen

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Dave Abrahams
on Fri Sep 02 2011, Josh Stratton wrote: > Here's a really short example of what I don't understand. Basically I > can setup the python function to accept shared pointers, but can I > setup it to also use normal pointers? Yes, once you've exposed the class to Python, you can pass pointers to