On Mon, 2010-03-15 at 21:25 -0600, Fabzter wrote: > void export_jugada() > { > class_<MyClass>("MyClass") > .def("setPos", setPosicion_with_int(&MyClass::setPos) ) > .def("setPos", setPosicion_with_vect(&MyClass::setPos) ) > > .def("getPosicion", &MyClass::getPosicion, > return_value_policy<reference_existing_object>()) > ; > }
Unless you've also wrapped std::vector<int>, I don't think your getPosicion() wrapper will work in Python (it should throw an exception when you call it). And by the way, you probably want "return_internal_reference<>" instead of "reference_existing_object" to be a little safer - that tells Python your MyClass instance owns the vector, rather than stating "I promise this reference will stay valid". > ------------------------------------------------------------------------------------------- > > Now, I have a little script that does something like: > > ------------------------------------------------------------------------------------------- > ... > def get() > m = MyClass() > m.setPos(4, 9) > return m > ... > ------------------------------------------------------------------------------------------- > > I have debugged (as much as my knowledge lets me!!!) to this point and > everything seem fine. "get()" gets properly called, and when it calls > MyClass::setPos(int, int), it seems to do everything fine (filling up > the vector). Well, now, in the main program, after reading the script, > I do something like this: > > ------------------------------------------------------------------------------------------- > ...extracting get() from script... > MyClass m ( getObj() ); > ------------------------------------------------------------------------------------------- > I don't really understand what you're doing here. Where is getObj() defined, and what does it do? I gather that your "main program" is written in C++, not Python - are you embedding? I'm not sure the std::vector stuff above is related to your problem, but without knowing more I can't say. Jim Bosch _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig