Re: [C++-sig] Boost Python Question - Multiple Classes and Modules not appearing as attribute

2016-09-09 Thread Holger Joukl
Hi, "Cplusplus-sig" schrieb am 09.09.2016 02:33:57: > Hi, > > And here is yet another person who seems to encounter the same issue: > http://stackoverflow.com/questions/9140572/c-boost-python-2-problems > > -Jon Python expects an init function for extension modules named initNAME where NAME is

Re: [C++-sig] boost python exposing const*

2015-09-09 Thread Holger Joukl
Hi, > I have a c++ class T that I succesfully expose via: > > class_ ... > > later on, I have > > struct S { >   const T* underlying; > }; > > class_("S"). >     .def_readonly("underlying", &S::underlying) > ; > > From python, when I call: > > s.underlying > > where s is a python instance of S, i

Re: [C++-sig] Returning values to Python in C++ reference arguments

2015-05-26 Thread Holger Joukl
Hi, > Von: Jason Addison > You can return results via function arguments from C to Python (see > code below). > > Why is something similar impossible with Boost Python? > > my_module2.c > > /* > clang -c -I/usr/include/python2.7 my_module2.c > clang -dynamiclib -o my_module2.so -lpython2.7 my

Re: [C++-sig] Returning values to Python in C++ reference arguments

2015-05-26 Thread Holger Joukl
> Von: Jason Addison > > How can results be returned in function arguments? > > I've include my example C++ extension and Python code below. > > I've tried, what I think, are some obvious approaches (Python objects, > ctypes), though none have worked. > > It seems like this should be doable. As a

Re: [C++-sig] Boost python exposing abstract class , function returning boost::shared_ptr

2015-03-30 Thread Holger Joukl
Hi, > Thank you for the reply. > It compiles but same error on execution. If I change the A2 exposure to bp::class_, boost::noncopyable>("A2", bp::no_init) ... then f1() successfully returns a B2 object. But of course we then lose the Python-callback abilities provided by the wrapper cl

Re: [C++-sig] Boost python exposing abstract class , function returning boost::shared_ptr

2015-03-27 Thread Holger Joukl
Hi, > [...] > // expose to python > BOOST_PYTHON_MODULE(grids) > { > class_ , boost::noncopyable >("A2") >.def("ret",pure_virtual(&A2::ret)); > > class_,bases>("B2"); > def("f1",f1); > } > > > I get the following result on execution : > > >import grids > >>> a = grids.f1() > > T

Re: [C++-sig] Subclassing C++ classes in Python

2015-03-16 Thread Holger Joukl
Hi Ernie, >   When I tries to use class exposed as ’wrapper’ as substitute for C > ++ original class i am getting a segfault error (see example below). > Is there is something wrong with a way i create a wrapper-class or > it is not intended to work as substitute for a base class? I haven't trie

Re: [C++-sig] Wrapping virtual method returning void

2015-02-22 Thread Holger Joukl
Hi, not boost.python- but C/C++ syntax-related. You never reach the Base class call in your wrapper class: > struct SongWrapper : Song, bp::wrapper > { > void chorus() > { > if (bp::override chorus = this->get_override("chorus")) > chorus(); > re

Re: [C++-sig] [Boost Python] Cannot call base method from within python extended class method

2015-01-13 Thread Holger Joukl
> > > For ElementWrap::get_float, try: > > > float get_float() { return this->get_override("get_float")(); } > > > > > > Binding to Python of that function should then be: > > > .def("get_float", pure_virtual(&Element::get_float)) > > > > > > See also: > > > http://www.boost.org/doc/libs/1_57_0/lib

Re: [C++-sig] [Boost Python] Cannot call base method from within python extended class method

2015-01-13 Thread Holger Joukl
Hi, > For ElementWrap::get_float, try: > float get_float() { return this->get_override("get_float")(); } > > Binding to Python of that function should then be: > .def("get_float", pure_virtual(&Element::get_float)) > > See also: > http://www.boost.org/doc/libs/1_57_0/libs/python/doc/tutorial/doc/

Re: [C++-sig] boost python wrapping boost message queue problem

2015-01-09 Thread Holger Joukl
Hi, > I wrapped the boost ipc message queue into Python using Boost.Python. > Everything goes fine except I found that > > 1. the try_receive / try_send will block python when the mq is empty / full. > 2. when I use the wrapped message queue in one Python thread, any > other Python thread would be

Re: [C++-sig] question on boost.python exception mechanisms

2013-04-29 Thread Holger Joukl
Hi, > From: "Niall Douglas" > On 17 Apr 2013 at 17:13, Holger Joukl wrote: > > > // the global per-thread exception storage > > boost::unordered_map exception_map; > > You can't assume pthread_t is of integral type. You can a thread_t > (from C11)

Re: [C++-sig] question on boost.python exception mechanisms

2013-04-18 Thread Holger Joukl
Before trying out Niall's wealth of suggestions, just to fix up my own erroneous example: > From: Holger Joukl > A bit of a simplified example version using Boost's partial C++11 exception > support > would then be s.th. like: > > 0 $ cat dispatch_main

Re: [C++-sig] question on boost.python exception mechanisms

2013-04-17 Thread Holger Joukl
Hi, > From: "Niall Douglas" > On 10 Apr 2013 at 13:48, Holger Joukl wrote: > > > > If you don't have C++11 in your C++, Boost provides an okay partial > > > implementation of C++11 exception support. I'm currently using gcc 4.6.1 which supports t

Re: [C++-sig] question on boost.python exception mechanisms

2013-04-17 Thread Holger Joukl
Hi, Giuseppe Corbelli wrote on 09.04.2013 09:09:14: > On 08/04/2013 14:11, Holger Joukl wrote: > >> I have found a couple of references. > >> http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html (see static-libgcc) > >> http://gcc.gnu.org/wiki/Visibility > >

Re: [C++-sig] question on boost.python exception mechanisms

2013-04-10 Thread Holger Joukl
Hi, "Cplusplus-sig" wrote on 09.04.2013 03:04:33: > From: "Niall Douglas" > On 8 Apr 2013 at 14:11, Holger Joukl wrote: > > > > I have found a couple of references. > > > http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html (see static-l

Re: [C++-sig] question on boost.python exception mechanisms

2013-04-08 Thread Holger Joukl
Hi, Giuseppe Corbelli wrote on 08.04.2013 11:29:10: > On 03/04/2013 10:08, Holger Joukl wrote: > > Hi Giuseppe, > > > > thanks for answering and sorry for the delayed response. Easter > > holidays :-) > > To punish you here's another late reply. ;-) >

Re: [C++-sig] question on boost.python exception mechanisms

2013-04-03 Thread Holger Joukl
Hi Giuseppe, thanks for answering and sorry for the delayed response. Easter holidays :-) Giuseppe Corbelli wrote on 28.03.2013 09:37:39: > On 26/03/2013 18:51, Holger Joukl wrote: > > > > Hi, > > > > I'm wrapping a C++ library that's actually j

[C++-sig] question on boost.python exception mechanisms

2013-03-26 Thread Holger Joukl
Hi, I'm wrapping a C++ library that's actually just a thin wrapper around a C lib. Through a dispatch() method of a Dispatcher class there's an invocation of callbacks which get implemented on the Python side, by subclassing callback classes exposed through Boost.Python. Now, for performing the

Re: [C++-sig] How to make a python function as callback of a c++ function

2012-09-03 Thread Holger Joukl
Hi, "Cplusplus-sig" schrieb am 02.09.2012 17:00:38: > I have to make a python function as callback of a c++ function.How > to do?Where can I find some examples?? I want to use boost.python. > I want my code look something like this: In C++ : >  typedef void (*MyCallback_t) (CallbackInfo); >  c

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

2012-02-28 Thread Holger Joukl
Hi, > The docs regarding the mutable copying problem are very misleading. > Following Python [1] and Boost [2] scripts do not produce the same results: > > > [1] > b = a = [] > c = list(a) > a.append("s1") > print a.count("s1"), b.count("s1"), c.count("s1") #prints 1 1 0 > > [2] > list a, b, c; >

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

2012-02-28 Thread Holger Joukl
> > To actually write to my instance dict I currently do > > > > PyObject* __dict__ = PyObject_GetAttrString(m_self, const_cast > > ("__dict__")); > > PyDict_SetItemString(__dict__, name, value.ptr()); > > > > inside MyExtensionClass::setattr (where m_self is PyObj*) > > > > Is there a be

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 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(); > > } > >

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

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

2012-02-23 Thread Holger Joukl
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 analogon in C++ to >> class Foo(object): ...

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

2012-02-23 Thread Holger Joukl
Hi, 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 isMyExtensionClass(pyobj) (strcmp(pyobj->ob_type->tp_name, "MyExtensionClass") == 0) on PyObj* pyobj. I bet there is a better way but just ca

Re: [C++-sig] Inheritance problem

2011-10-14 Thread Holger Joukl
Hi, > Ok lets say my BaseClass has a member function called init( vector4 ): > > class Base > { > public: > void init( vector4 &vec ) { //doWhatEver } > //a lot of other functions > }; > > Unfortunetaly i can not expose this init function directly to python so > i am writing a BaseWrapp

Re: [C++-sig] Inheritance problem

2011-10-14 Thread Holger Joukl
Hi, > currently i am facing a problem regarding inheritance with boost::python > > Here is a simple code snippet: > > > class Base > { > public: > virtual void print() { std::cout << "hello" << std::endl; } > > }; > > [...] > > And in python i want to have the following reslut: > > >>import

Re: [C++-sig] void* (void pointer) function arguments

2011-08-16 Thread Holger Joukl
Hi Jim, > > I am a bit unsure about how to work the void-pointers. A viable way seems > > to wrap the original > > API functions with thin wrappers that take a boost::python::object and hand > > the "raw" PyObject* > > into the original function: > > > > I don't see anything wrong with this approa

[C++-sig] void* (void pointer) function arguments

2011-08-15 Thread Holger Joukl
Hi, I'm trying to wrap a C++-API that uses void* to pass around arbitrary, application-specific stuff. I am a bit unsure about how to work the void-pointers. A viable way seems to wrap the original API functions with thin wrappers that take a boost::python::object and hand the "raw" PyObject* in

[C++-sig] py++ site down? Project moved?

2011-05-17 Thread Holger Joukl
Hi, has py++ moved somewhere else? This seems to be unreachable: http://language-binding.net/pyplusplus/pyplusplus.html Regards Holger Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart _

Re: [C++-sig] BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS default args core dump

2011-05-11 Thread Holger Joukl
Hi Ralf, > You don't need the BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS macro if > you support keyword arguments (which is usually best). It should be > as simple as: > > .def("foo", &DefaultArgs::foo, (bp::arg("arg1")=100, bp::arg("arg2")=10)) > > > The FUNCTION_OVERLOADS macros are more or less a

[C++-sig] BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS default args core dump

2011-05-09 Thread Holger Joukl
Hi, this is basically a re-post of a problem I posted 5 weeks ago, on which there's been no echo whatsoever. Now, I'm unsure if this is because I posted on April 1st, nobody has ever seen this problem on his platform, nobody ever uses the BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS macro this way or I

[C++-sig] BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS with default args dumps core

2011-04-01 Thread Holger Joukl
[ 2nd try due to user stupidity, please ignore if this is being delivered twice ] Hi all, I'm having trouble wrapping a very simple member function with Boost.Python using the BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS macro, getting a segmentation fault. I run into the problem both with Boost 1.44

[C++-sig] BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS with default args dumps core

2011-04-01 Thread Holger Joukl
Hi all, I'm having trouble wrapping a very simple member function with Boost.Python using the BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS macro, getting a segmentation fault. I run into the problem both with Boost 1.44.0 and 1.46.1, running on Solaris 10/Sparc using gcc 4.5.1 and Python 2.7.1. What'