[C++-sig] Problem using the ptr() function

Emmanuel Taurel etaurel at cells.es
Wed Oct 26 15:59:18 CEST 2005


Hello Stefan,

Thank's for your answer, but I don't use string at all. The data type I am
using is our own data type. The problem I have is with the usage of
My_ptr or ptr(My_ptr) in the last parameter of the boost call_method.

Regards,

Emmanuel Taurel (etaurel at cells.es)

-----Original Message-----
From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On
Behalf Of Stefan Seefeld
Sent: Wednesday, October 26, 2005 3:45 PM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] Problem using the ptr() function

Emmanuel Taurel wrote:
> Hello everybody,
> 
>  
> 
> I am using Boost.python to interface a C++ set of classes. In one of my 
> C+++ class, I am calling a method implemented in Python with the
> boost "call_method" call. This method has one parameter of our own data 
> type and return a pointer to this type. I have installed converters for 
> this type as it is adviced in the FAQ "How can I automatically convert 
> my custom string type..." If I call my method like this
> 
>  
> 
> MyType *ret = call_method<MyType *>(my_py_obj,"My_method", my_ptr)
> 
>  
> 
> With my_ptr being a MyType *, it works. But if I call it like this
> 
>  
> 
> MyType *ret = call_method<MyType *>(my_py_obj,"My_method", ptr(my_ptr)) 
> to avoid a copy, I received a run time error complaining that
> 
>  
> 
> "No Python class registered for C++..."

I believe the reason is that strings in python are non-mutable, meaning that
you can't modify them in-place. Instead, string variables are rebound to a
new
value when you modify them.

That is incompatible with the way you want your string type to be handled.

Regards,
		Stefan
_______________________________________________
C++-sig mailing list
C++-sig at python.org
http://mail.python.org/mailman/listinfo/c++-sig




More information about the Cplusplus-sig mailing list