call_function problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

call_function problem

Tsubasa
A call_function example in Luabind docs I can't understand, who can help me? The example is as follows(irrelevant are hidden):

The return value isn't actually Ret (the template parameter), but a proxy object that will do the function call. This enables you to give policies to the call. You do this with the operator[]. You give the policies within the brackets, like this:
int ret = call_function<int>(
    L
  , "a_lua_function"
  , new complex_class()
)[ adopt(_1) ];

[adopt(_1)]???? Who could understand that sentence mean?
Reply | Threaded
Open this post in threaded view
|

Re: call_function problem

Arvid Norberg-2

On Sep 19, 2006, at 04:46, Tsubasa wrote:

>
> A call_function example in Luabind docs I can't understand, who can  
> help me?
> The example is as follows(irrelevant are hidden):
>
> The return value isn't actually Ret (the template parameter), but a  
> proxy
> object that will do the function call. This enables you to give  
> policies to
> the call. You do this with the operator[]. You give the policies  
> within the
> brackets, like this:
> int ret = call_function<int>(
>     L
>   , "a_lua_function"
>   , new complex_class()
> )[ adopt(_1) ];
>
> [adopt(_1)]???? Who could understand that sentence mean?

see the documentation for the adopt policy:

http://www.rasterbar.com/products/luabind/docs.html#adopt

it means that lua should take over ownership of the pointer you  
passed in. In this case it's obvious that it has to take over  
ownership since a pointer is passed in directly from new, and if it's  
not adopted it will leak.

--
Arvid Norberg



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user