[C++-sig] Calling python from c++ with tuple and dict args.

Alex Mohr amohr at pixar.com
Tue Mar 7 22:29:03 CET 2006


> Huh, it looks like we should really extend all the overloads on object
> so you can do:
> 
>    o(1, 2, 3, *t, **d)
> 
> That might be a touch more complex.

You're right.  Looks like we need to support:
o(A1..N)
o(A1..N, unpacked_tuple_args)
o(A1..N, unpacked_tuple_args, unpacked_dict_args)

My intuition says that we can just add the extra two along with each 
instance of operator().  So in object_core.hpp it'd be:

object operator()() const;
object operator()(unpacked_tuple const &) const;
object operator()(unpacked_tuple const &, unpacked_dict const &) const;

And then in the iterated object_call.hpp, we'd add the two other 
versions (tuple and tuple + dict) to provide the multi-leading arg 
versions (stuff along these lines):

template <BOOST_PP_ENUM_PARAMS_Z(1, N, class A)>
typename detail::dependent<object, A0>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(1, N, A, const &a),
     unpacked_tuple const &args, unpacked_dict const &kw) const

Then we would modify bp::call<> similarly to accept trailing unpacked 
tuples and dicts, and call through to python with the combined arguments.

Anything seem out-of-line here?  If not, I'm willing to try it.  Seems 
plausible.

Alex



More information about the Cplusplus-sig mailing list