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

2011-09-03 Thread Josh Stratton
Thanks for everyone's help. I'm posting my updated class that is now working. class Scene : public boost::enable_shared_from_this { public: void sendYourselfToPython() { try { object ignored = exec(EXAMPLE_PY_FUNCTION, pyMainNamespace); object processFileFunc = pyMainModule.at

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

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: > 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
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 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
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 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 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-01 Thread 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 the mapping then? I'm getting an error trying to send the Scene object down to pyt

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

2011-09-01 Thread Jim Bosch
On 09/01/2011 01:01 PM, Josh Stratton wrote: - I'm a bit confused by your python_bindings.cpp file; did you paste together several files? If not, I've never seen anyone try to define more than one module in a single shared library, and I don't it's supposed to work. You can wrap all of your obj

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

2011-09-01 Thread Josh Stratton
>> In my particular scene I have a Scene class, which operates as kind of >> a context for my operations and holds all the meshes in the scene.  I >> send my scene down to the python side so import methods will import >> into the containers in the scene object.  For example, >> addMeshFromFile(scen

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

2011-09-01 Thread Jim Bosch
On 09/01/2011 07:03 AM, Josh Stratton wrote: In my particular scene I have a Scene class, which operates as kind of a context for my operations and holds all the meshes in the scene. I send my scene down to the python side so import methods will import into the containers in the scene object. F

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

2011-09-01 Thread Josh Stratton
In my particular scene I have a Scene class, which operates as kind of a context for my operations and holds all the meshes in the scene. I send my scene down to the python side so import methods will import into the containers in the scene object. For example, addMeshFromFile(scene, fileName) wh