|
Re: instantiating python objects within C++: msg#00299python.c++
"Ralf W. Grosse-Kunstleve" <rwgk@xxxxxxxxx> writes: > --- Stefan Seefeld <seefeld@xxxxxxxxxxxx> wrote: >> David Abrahams wrote: >> >> > The Boost.Python shared library has a converter registry where all of >> > this information is stored. >> >> ok, this seems really to be the key. How does this work ? I'm a bit confused, >> as conceptually the lines >> >> BOOST_PYTHON_MODULE(Sandbox) >> { >> python::class_<Base> base_type("Base"); >> //... >> } >> >> create a type 'Sandbox.Base', i.e. the equivalent in C++ would be >> something like 'Sandbox::Base'. However, 'Sandbox' isn't a type, >> so I wonder how I can access the above type object from inside >> C++. > > I cannot conclusively answer all your questions, but maybe I can help with one > piece of the puzzle: the central Boost.Python type conversion registry is > *not* > scoped. It knows about your type only as, e.g., namespace1::namespace2::base. > If I understand correctly the class_<> constructor does two more or less > independent things (at runtime): > > 1. It registers the type conversions in the central registry with the C++ type > (in some form) as the key. > > 2. It adds a reference to the Python type (created at compile time!) to the > current scope(). The Python type is created at runtime, ... > I am sure the exact details are more involved and my view is maybe not 100% > accurate, but the mental model works for me. ...but your mental model is basically correct. -- Dave Abrahams Boost Consulting www.boost-consulting.com |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: registering simple conversions from/to python: 00299, Brett Calcott |
|---|---|
| Next by Date: | Re: instantiating python objects within C++: 00299, David Abrahams |
| Previous by Thread: | Re: Re: instantiating python objects within C++i: 00299, Ralf W. Grosse-Kunstleve |
| Next by Thread: | Re: instantiating python objects within C++: 00299, David Abrahams |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |