-
Notifications
You must be signed in to change notification settings - Fork 348
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
STL integrations isInstance bug #251
Comments
The main Checking the type of every table item means linear complexity which is slow and inconsistent with usual constant complexity. The I start thinking that it would be a better idea to have a function that would register an luabridge::registerStdVector<int>("vector"); v = std.vector({1, 2})
v:push_back(3)
print(v:at(0)) |
Your idea solves the
For simplicity and correctnes I tend to drop the STL container Maybe another idea is to add a function |
The change doesn't seem to be complicated (unless there are caveats). |
I still tend to drop all
If this way is chosen the I absolutely agree that we require tests for Lua 5.3, 5.4 and even LuaJIT. At the moment LuaBridge doesn't work with LuaJIT but fixing this shouldn't be too much effort. Furthermore I even welcome GitHub actions to run the tests automatically. |
From my understanding the STL container stack specializations provide the isInstance function to indicate if the element on the stack can be converted to the corresponding C++ container. This is the case if:
On the other hand the current implementation for all STL container stack specializations is as following:
static bool isInstance(lua_State* L, int index) { return lua_istable(L, index); }
The first criteria is checked by the implementation. The size check for std::array is trivial to implement. The last criteria can be checked as well but would require more performance. Is this behavior intended?
I suggest to either drop these isInstance functions or to implement them properly. Of course this does not affect the other isInstance functions.
Furthermore there are no tests for the functions available.
If I have some sparetime I can fix this issue but before I want to clarify/discuss the desired behavior.
The text was updated successfully, but these errors were encountered: