[C++-sig] BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS question

eric andersonT eric.anderson at comcast.net
Thu Sep 11 06:32:29 CEST 2003


In this statement from my example below:

	class<C>( "C", "class C", init<> )
		.def( "bar", &C::bar, bar_overloads( args( "a" ),
"returns object of class B" )
	;

The function bar() is a member of class C. It has a default parameter in
it's declaration. I'm using the macro
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS to generate the variants of the
function with default parameters supplied and not supplied. The function
itself returns a pointer that needs to be adopted by python. I need to
specify this to boost. I don't know the syntax for this when wrapping
the function using the BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS macro.



-----Original Message-----
From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On
Behalf Of David Abrahams
Sent: Wednesday, September 10, 2003 8:45 PM
To: c++-sig at python.org
Subject: [C++-sig] Re: BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS question


eric andersonT <eric.anderson at comcast.net> writes:

> Where does it fit into this (untested pseudo-c++):

Please elaborate.  What do you mean by that question?


-----Original Message-----
From: c++-sig-bounces+eric.anderson=comcast.net at python.org
[mailto:c++-sig-bounces+eric.anderson=comcast.net at python.org] On Behalf
Of eric andersonT
Sent: Wednesday, September 10, 2003 11:10 AM
To: c++-sig at python.org
Subject: [C++-sig] BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS question


Hi everyone, I have a question about the macro in the email subject and
how to specify return_value_policy<manage_new_object>() using it.

Where does it fit into this (untested pseudo-c++):

struct A
{
	int a;
};
struct B
{
	A* foo();
};
struct C
{
	B* bar( int a=0 );
};

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( bar_overloads, C::bar, 0, 1 );

void GlueToPython()
{
	using boost::python;
	class<A>( "A", "class A", init<> )
	;
	class<B>( "B", "class B", init<> )
		.def( "foo", &B::foo, "returns object of class A",
return_value_policy<manage_new_object>() )
	;
	class<C>( "C", "class C", init<> )
		// NEEDED HERE: return_value_policy<manage_new_object>()
		.def( "bar", &C::bar, bar_overloads( args( "a" ),
"returns object of class B" )
	;
}


Thank you,

Eric


_______________________________________________
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