[C++-sig] Boost-python/pybindgen and wrapping member variables
Ben Fitzpatrick
bfitzpatrick at vtiinstruments.com
Wed Jan 20 20:26:03 CET 2010
Gustavo,
I think you win some sort of prize for not only fastest mailing list responses, but also fastest implementation of features. I reviewed the diff, and changed what I was adding to the global annotations table for these pointers to “{‘return_internal_reference’:’true’}” – this seems to be what the new code in foo.h was doing. I am still getting the errors, though – is this the right way of using it?
And just to make sure, I grabbed a new checkout of pybindgen and re-installed it.
From: cplusplus-sig-bounces+bfitzpatrick=vtiinstruments.com at python.org [mailto:cplusplus-sig-bounces+bfitzpatrick=vtiinstruments.com at python.org] On Behalf Of Gustavo Carneiro
Sent: Wednesday, January 20, 2010 1:18 PM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] Boost-python/pybindgen and wrapping member variables
On Wed, Jan 20, 2010 at 5:43 PM, Ben Fitzpatrick <bfitzpatrick at vtiinstruments.com<mailto:bfitzpatrick at vtiinstruments.com>> wrote:
Hi everyone,
I think I’m finally getting the hang of this, I seem to have gotten almost everything in my project working thanks to Gustavo’s latest pybindgen patch. One of the remaining things I am having difficulty with is putting annotations on member variables of a class. I have something of the form:
class foo{
<stuff>
};
class baz {
public:
foo* var;
}
The error I am getting from pybindgen is “WrapperWarning: Return value ‘::foo *’ error (used in baz::var [variable]): TypeConfigurationError(‘Either caller_owns_return or self.reference_existing_object must be given’)
I know that the issue is that I need to stick an annotation on there. Since the pointer is allocated and tracked by the underlying C++ code, I’m pretty sure that I need to put reference_existing_object on it. I’ve tried inserting “{‘reference_existing_object’ : ‘true’}” into the global_annotations table, and also inserting it into the parameter_annotations[“return”] dictionary. For kicks, I even tried both at once. No matter what I do I can’t get rid of the error, or see it show up in my final build, which leads me to believe there’s something I’m missing. I went and looked up the documentation for reference_existing_object, but of course none of their examples show how you could use it on a member variable. What am I missing?
You are not missing anything. Annotations for member variables (pybindgen calls them "instance attributes") were not implemented.
An oversight easily fixed:
http://bazaar.launchpad.net/~gjc/pybindgen/trunk/revision/742
Thanks,
Ben Fitzpatrick
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org<mailto:Cplusplus-sig at python.org>
http://mail.python.org/mailman/listinfo/cplusplus-sig
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100120/cc580117/attachment-0001.htm>
More information about the Cplusplus-sig
mailing list