References to native types

Michael Steinberg <[email protected]> Sun, 29 Sep 2013 14:22:29 +0200
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Hi there,
I was playing around with the rvalue reference stuff whereby I broke a
test case, which happened to declare a function to lua with the
signature "int(int&)".
Now you could make that work by registering "int" as a class and when
passing in a value by reference, it would wrap that one up to a userdata
object. However when you do that, you basically disable the ability to
call functions on the lua side that accept numbers. My question is,
should registering functions taking references to native types even be
allowed?

I think I will have to somewhate differ in all calls between native&user
defined types. Because for example when you call into lua with a rvalue
ref to a user defined type, it could move it to the internal pointer
holder (and on the other end it could move it out, if there was a flag
indicating rvalue reference), however for native types they must be
treated as per-value under all circumstances (probably the passing is
broken in current head because of that, call_function took a const& of
all parameters and the default_converter was somehow "optimized" to
catch const int& (but not int&!) and treat it by value. This stuff is
pretty fragile and I intend to replace it by something that is
reasonably understandable).

Michael

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk