|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2001-04-09 07:16:30
Your code looks correct to me, except for that your world constructor takes
Data by value and you specified in initriskneut that it was passed by
const&.
Regards,
Dave
----- Original Message -----
From: "Xavier Warin" <xavier.warin_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, April 09, 2001 3:40 AM
Subject: [boost] question BPL mapping
> 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
> {
> private:
> const double tu ;
> public :
> world(Data data, double ti) :tu(ti) {};
> };
>
> // do the binding
> 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
> // a Data C++ object to give to the constructor ?
> world_mod(boost::python::constructor< const Data & , double >());
> }
> catch(...)
> {
> boost::python::handle_exception(); // Deal with the exception for
> Python
> }
> }
> Thank you for your help.
>
>
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk