-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not work when more than one userdef data in one lua function #140
Comments
I encountered the same problem with the use of metatables for lightuserdata. Tests to show that are prepared and the causing source locations are marked with FIXME comments. @lucklove I read through your repo to understand the solution using full userdata. You use I hope we find a solution where C++ objects of type |
@AnonymousProgrammerLandau You are right, I use std::reference_wrapper and T to distinguish reference and value(just like the use of std::bind). It's hard to guess whether user want to use reference(T&), const reference(const T&) or just a value(T) when a lvalue reference of type T was given, so I force user to choice one of them by reference wrapper. As a result, there are separate metatables, however, upsetly, I don't understand that |
@lucklove Suppose you have registered some C++ functions:
As Selene uses the same metatable for both
If I understood your approach, you would register:
Lua code then needs to distinguish two valid combinations:
from two incompatible ones:
Viewed from Lua this distinction seems artificial to me. In essence both return values from |
@AnonymousProgrammerLandau Thanks for your patient. |
Sorry to drop in like this, but is it the same bug that trigger that: Given a lua function:
A C++ code:
I get the output:
Instead of:
Any advices on how to workaround the problem ? Cheers, |
@daedric Hello, I test your code in both selene and nua, the result is that it print out
in selene, and print out
in nua. |
@deadric Possible workaround: If you do not need reference semantics, you might get around the bug by copying. Change |
I see, this is why you were talking about wrapping a reference. @lucklove too bad you did not write your readme in english, nua could have been interesting for me to evaluate as well :) |
To find code that can cause the bug, disable push for references and pointers in |
@daedric The use of nua is basically the same with selene, to make you clear, I post a english version readme. |
For example. this not work:
The text was updated successfully, but these errors were encountered: