[C++-sig] Re: Creating an instance of a python class derived from a C++ object from C++

Brian Hall bhall at midwaygames.com
Sat Jul 10 19:52:23 CEST 2004


> 
> BOOST_PYTHON_MODULE(MyPythonModule)
> {
>   class_<cState>("State", init<std::string>())
>     .def("value", &cState::Value)
>     .def("set_value", &cState::SetValue)
>     .def("initial_value", &cState::InitialValue)
>     .def("set_initial_value", &cState::SetInitialValue)
>     .def("name", &cState::Name)
>     .def("reset", &cState::Reset)
>     .def("iterate", &cState::Iterate)
>   ;
>   def("call_some_function", call_SomeFunction);
> };
> 


Ack!  How about this for the module definition...

BOOST_PYTHON_MODULE(MyPythonModule)
{
  class_<MyCppClass, MyCppClassWrap, boost::noncopyable>("MyCppClass", 
init<void>())
  ;
  def("call_some_function", call_SomeFunction);
};





More information about the Cplusplus-sig mailing list