Boost logo

Boost :

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

Hi !

I've got a simple question due to the fact that i want to bind an object
with BPL and i want to use this
object in a constructor of a second object (that i want to bind to
Python too) as follows :

namespace python = boost::python;

class Data {
private :
  const double w ;
public :
  Data( double v ) : w(v) {} ;
  ~Data() {}
} ;

class world
  const double tu ;
public :
  world(Data data, double ti) :tu(ti) {};

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 Data C++ object to give to the constructor

    world_mod(boost::python::constructor< Data , double >()); // this
does not work
    boost::python::handle_exception(); // Deal with the exception for
I hope that someone will have an answer.
Thank you

Xavier Warin

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