exposing a class with a member class object
Hi - Using boost.python, I am trying to expose an object member from a class. As a simple example, consider : class A { A( double x, double y): s.h(0.0), s.v(0.0) {} struct S { double h, double v } s; }; I would like the C++ type A to be mapped into a corresponding Python type that once instantiated can be used with the obvious syntax a = A() a.s.h = 1.0 a.s.v = 2.0 a2 = A() a2.s.h = 3.0 a2.s.v = 4.0 As usual, I am grateful for any help or hints. -Francois ---------------------------------------------------------------------------- Dr. Jean-Francois OSTIGUY voice: (630) 840-2231 Beam Physics Dept MS220 FAX: (630) 840-6039 Fermi National Accelerator Laboratory email: ostiguy@fnal.gov Batavia IL 60510-0500 WWW:www-ap.fnal.gov/~ostiguy
Hi, Francois Ostiguy wrote:
Hi -
Using boost.python, I am trying to expose an object member from a class. As a simple example, consider :
class A {
A( double x, double y): s.h(0.0), s.v(0.0) {}
struct S { double h, double v } s;
};
I would like the C++ type A to be mapped into a corresponding Python type that once instantiated can be used with the obvious syntax
Hope that helps (untested): { scope s ( class_<A>("A", init<double, double>()); ); class_<S>("S")...; } Cheers, Nicodemus.
participants (2)
-
Francois Ostiguy -
Nicodemus