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
{
private:
  const double tu ;
public :
  world(Data data, double ti) :tu(ti) {};
 };

extern "C"
void initriskneut()
{
  try
  {
    // 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
  }
  catch(...)
  {
    boost::python::handle_exception(); // Deal with the exception for
Python
  }
}
I hope that someone will have an answer.
Thank you

Xavier Warin


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk