Re: [C++-sig] Wrapping a function that takes class type, such as type_info

2012-02-24 Thread Jim Bosch
On 02/24/2012 02:31 AM, Adam Preble wrote: Jim, I'll top post since I think this might get messy nice and fast otherwise. I found I couldn't get to a method wrapped to type a PyTypeObject* and only PyObject* would do. Yeah, that's not surprising. You can also have it take a boost::python::o

Re: [C++-sig] how to override __setattr__ of an extension class

2012-02-24 Thread Jim Bosch
On 02/23/2012 12:04 PM, Holger Joukl wrote: Hi, I'm trying to instrument a wrapped class with custom __setattr__ mechanics: .def("__setattr__",&MyExtensionClass::setattr) How can I call the base class __setattr__ from within setattr and not run into infinite recursion? I.e. the ana

Re: [C++-sig] test if object instance is instance of extension class in C++

2012-02-24 Thread Holger Joukl
> > bp::object itself has reference (smart pointer) semantics, so there is > > no need to pass objects by reference. > > I see. Just out of curiosity: > > If I pass by reference I do save a copy constructor call, don't I? > > In principle, yes. I'm not sure how much of this the compiler would be >

Re: [C++-sig] test if object instance is instance of extension class in C++

2012-02-24 Thread Stefan Seefeld
On 02/24/2012 09:33 AM, Holger Joukl wrote: > bp::object itself has reference (smart pointer) semantics, so there is > no need to pass objects by reference. > I see. Just out of curiosity: > If I pass by reference I do save a copy constructor call, don't I? In principle, yes. I'm not sure how much

Re: [C++-sig] test if object instance is instance of extension class in C++

2012-02-24 Thread Holger Joukl
Hi, > On 02/24/2012 05:44 AM, Holger Joukl wrote: > > Just for the record, this is what I do now: > > > > inline > > bool isMyExtensionClass(PyObject* &pyobj) { > > bp::extract extractor(pyobj); > > return extractor.check(); > > } > > I'm not sure why you use raw PyObject pointers in the f

Re: [C++-sig] test if object instance is instance of extension class in C++

2012-02-24 Thread Stefan Seefeld
On 02/24/2012 05:44 AM, Holger Joukl wrote: > Just for the record, this is what I do now: > > inline > bool isMyExtensionClass(PyObject* &pyobj) { > bp::extract extractor(pyobj); > return extractor.check(); > } I'm not sure why you use raw PyObject pointers in the first place. That should

Re: [C++-sig] test if object instance is instance of extension class in C++

2012-02-24 Thread Holger Joukl
Stefan, many thanks, that of course did the trick. I'm not seeing the wood for the trees any more, I fear. > > what's the recommended way to check if an object instance is an instance of > > my extension class > > in C++ code? > > > > I'm currently doing a very ugly > > > > #define isMyExtensionC