Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Christopher Schramm
Thomas Berg wrote: > bp::scope sc(main); > bp::def("function", myfunction, "function helpstring"); Now that looks interesting. I'll implement that and let you know if it leads to any further problems. But it sounds like the perfect solution. > Found this out by reading the source

Re: [C++-sig] return_internal_reference & overriding methods in a class.

2009-06-24 Thread Roman Yakovenko
On Thu, Jun 25, 2009 at 6:31 AM, Nicolas Lara wrote: > Hello, > > I'm having trouble trying to override a method on a class exposed to > Python. I cannot modify the original class, so I need to wrap it to > change the behaviour of some methods to be Python compatible. The > classes look like the fo

Re: [C++-sig] return_internal_reference & overriding methods in a class.

2009-06-24 Thread Nicolas Lara
I tried adding: implicitly_convertible(); implicitly_convertible(); but it doesn't appear to change anything. I would apreciate any idea on thes regard. Thanks again! On Thu, Jun 25, 2009 at 3:31 AM, Nicolas Lara wrote: > Hello, > > I'm having trouble trying to override a method on a class

[C++-sig] return_internal_reference & overriding methods in a class.

2009-06-24 Thread Nicolas Lara
Hello, I'm having trouble trying to override a method on a class exposed to Python. I cannot modify the original class, so I need to wrap it to change the behaviour of some methods to be Python compatible. The classes look like the following: struct DocumentWrap : Document, wrapper { DocumentWr

Re: [C++-sig] pybindgen: allow_subclassing option causing reference parameters to be copied?

2009-06-24 Thread J. Michael Owen
That sounds great to me! On Jun 24, 2009, at 5:03 PM, Gustavo Carneiro wrote: I can't really fault your logic. I just thought of something that makes some sense. If the wrapper did something like: _wrap_my_virtual_method (A &a) { PyA *py_A; py_A = PyObject_New(PyA, &PyA_Type);

Re: [C++-sig] pybindgen: allow_subclassing option causing reference parameters to be copied?

2009-06-24 Thread Gustavo Carneiro
2009/6/25 J. Michael Owen > I can see what you're worried about here, but as a practical matter it is > very useful to be able to pass stuff by reference, and copying it under the > hood will break code. For instance, if the virtual functions modify the > state of the parameters passed by refere

Re: [C++-sig] pybindgen: allow_subclassing option causing reference parameters to be copied?

2009-06-24 Thread J. Michael Owen
I can see what you're worried about here, but as a practical matter it is very useful to be able to pass stuff by reference, and copying it under the hood will break code. For instance, if the virtual functions modify the state of the parameters passed by reference it will just not functio

Re: [C++-sig] pybindgen: allow_subclassing option causing reference parameters to be copied?

2009-06-24 Thread Gustavo Carneiro
2009/6/24 J. Michael Owen > Hi again, > > I've run across another issue confusing me as I try to use pybindgen, in > this case it's the treatment of reference parameters in virtual methods > where you're allowing the class to be subclassed from python. It looks like > the helper class that is ge

[C++-sig] pybindgen: allow_subclassing option causing reference parameters to be copied?

2009-06-24 Thread J. Michael Owen
Hi again, I've run across another issue confusing me as I try to use pybindgen, in this case it's the treatment of reference parameters in virtual methods where you're allowing the class to be subclassed from python. It looks like the helper class that is generated is making copies of pa

Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Thomas Berg
On Wed, Jun 24, 2009 at 10:26 PM, Christopher Schramm wrote: > > > Thomas Berg wrote: > >>     bp::object function = bp::object(myfunction); > > > > Great! And it was that simple... > > But wait... Giving that a second thought I don't think that's going to > exhaust bpy's full potential. At least

Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Christopher Schramm
> Thomas Berg wrote: >> bp::object function = bp::object(myfunction); > > Great! And it was that simple... But wait... Giving that a second thought I don't think that's going to exhaust bpy's full potential. At least I don't see a way to use it's docstring handling or call policies. I'll tes

Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Christopher Schramm
Thomas Berg wrote: > bp::object function = bp::object(myfunction); Great! And it was that simple... Thanks! ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Thomas Berg
Hi, On Wed, Jun 24, 2009 at 7:52 AM, Christopher Schramm wrote: > > Stefan Seefeld wrote: > > An alternative is not to use BOOST_PYTHON_MODULE at all, but set up > > converters in ordinary C++ code. In the following I set up a Python > > interpreter in my main application, inject a (C++) base cla