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: [email protected]
[mailto:[email protected]] 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
<[email protected]<mailto:[email protected]>> 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
[email protected]<mailto:[email protected]>
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
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig