Re: [C++-sig] [Implementation] Calling wrapped functions, converters, policies

David Abrahams <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding
Message-ID <[email protected]>
David Abrahams <[email protected]> writes:

> I'd like to see a templated protocol to access the actual
> argument list, e.g.:
>
>      get<1>(args)  ->  "argument 1"
>
> we'd define a get<> which operates on PyObject* (argument tuples) but
> we could also wrap the argument tuple in a kind of mapping to drop the
> first argument (or inject a faux argument, in the case of an out
> parameter which doesn't actually appear in the incoming argument
> list).  For handling lone conversions (like extract<T>(obj)) we could
> wrap a single PyObject* (argument) in a class for which only get<0>(x)
> (but not get<1>, get<2>,...) was defined.

OK, I implemented this in Boost.Python as part of injected constructor
support.  It's not clear I have the best possible interface.  Clearly,
this version of get<N>(a) would have to be moved into boost::python so
that people could customize it, but they'd have to overload in
boost::python directly (not so cool).  If you search the headers for
"argpkg" you can see one alternative, which would allow Koenig Lookup
(ADL) to find the get/arity functions in the namespace of the argument
package.  Still another possibility is to tie the interface into the
CallPolicies, which would eliminate some questions about where users
who define new policies customize (and would let constructor_policy
continue to use PyObject* as an argument_package, but then requires
the CallPolicies to be passed to the converters (ugly).  Still another
possibility is to require a class type with member get/arity for
argument_package.

Thoughts?
-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.