Boost logo

Boost :

From: Xavier Warin (xavier.warin_at_[hidden])
Date: 2001-04-09 02:40:06

I like to now if it is possible to map a python object to a C++ object
and to use this object to construct
a second object i want to bind with BPL.

For example :
// create the first object
class Data {
private :
  const double w ;
public :
  Data( double v ) : w(v) {} ;
  ~Data() {}
} ;

// create a second object : its constructor needs a Data object
class world
  const double tu ;
public :
  world(Data data, double ti) :tu(ti) {};

// do the binding
extern "C"
void initriskneut()
    // Create an object representing this extension module.
    python::module_builder this_module("alltest");

    // Create the Python type object
    boost::python::class_builder< Data > Data_class(this_module, "Data"
    Data_class.def(boost::python::constructor< double >());

    // Create the Python type object for our extension class world
    boost::python::class_builder<world> world_mod(this_module, "world");

    // constructor
    // How to define the mapping Between the Data python object (created
via BPL) and the
    // a Data C++ object to give to the constructor ?
    world_mod(boost::python::constructor< const Data & , double >());
    boost::python::handle_exception(); // Deal with the exception for
Thank you for your help.

Boost list run by bdawes at, gregod at, cpdaniel at, john at