Re: Re: [Implementation] Calling wrapped functions, converters, policies

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

> Daniel Wallin <[email protected]> writes:
> 
> 
>>David Abrahams wrote:
>>
>>>Daniel Wallin <[email protected]> writes:
>>>
>>>
>>>>David Abrahams wrote:
>>>>
>>>>
>>>>>I would be strongly inclined to say that unless you _explicitly_ say
>>>>>otherwise, each C++ argument comes from the Py/Lu argument in the
>>>>>same position.  Your example uses implicit argument shifting, which
>>>>>makes me  nervous.  
>>>>
>>>>Why does it make you nervous? Is there any potential danger in doing
>>>>this that I'm missing?
>>>
>>>Well, suppose in a 5-arg function you write:
>>>      getC++.arg(2).from_Python_arg(1)
> 
> 
> This is a policy which maps Python argument 1 to C++ argument 2
> 
> 
>>>[Sorry, can't stop inventing syntax ;-)]
>>>The question is, what happens to to the other 4 arguments?  It's far
>>>from obvious to me.  Now suppose you add
>>>      , getC++.arg(1).from_Python_arg(4)
>>>Now it's even less obvious.
> 
> 
> This is an additional policy that maps Python argument 4 to C++
> argument 1

OK. So we would end up with:

   get(..., mpl::int_<2>)
   {
      return get(..., mpl::int_<1>());
   }

   get(..., mpl::int_<1>)
   {
      return get(..., mpl::int_<4>());
   }

   template<int N>
   get(..., mpl::int_<N> n)
   {
      return whatever_native_thing_we_have(n);
   }

This has nothing to do with (implicit) shifting though, but rather with
argument_package. So in this case, nothing would happen to the other
arguments. I'm missing what's not obvious here, sorry. What I
considered before was just converters that could merge several
(consecutive) Python/Lua arguments into one C++ argument, in which case
implicit shifting would be great. I'm sure that there might be cases
that I haven't thought about though..

-- 
Daniel Wallin



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
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.