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 _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
Hello again,
digging through the list I found this issue to pop up again and again. People were trying to use refs to native types, or there were complaining why luabind wouldn't support it etc.. Maybe it would be wise to add a paragraph to the documentation stating that is just not possible to implement that, since lua does not know about references/pointers? The only thing that I can imagine one could do would be to provide an opt-in type boxing support. So you could inject boxed native types into lua that could be unboxed into references on the c++ side again (I think this is quite similar to what Java has?). And some way to box native types on the lua side to, to simulate references. One would then have to differ between lua and c++ boxes, because c++ boxes would contain pointers to a c++ value, whereas boxes created in lua would have a true datamember... The unboxing converter would then have to differ between c++ boxes and lua boxes, because the latter would have to write back to the table, whereas the former supplied the true pointer and wouldn't have to do anything. But any way, we'd have to manually box and unbox the types in native and in lua code. So I really doubt that it's worth the great effort that is necessary to implement that. 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 _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
Free forum by Nabble | Edit this page |