Skip to content
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

Lua 5.4 - 'cimport' has no member named 'lua_objlen' #58

Closed
b4rti opened this issue Feb 4, 2024 · 2 comments
Closed

Lua 5.4 - 'cimport' has no member named 'lua_objlen' #58

b4rti opened this issue Feb 4, 2024 · 2 comments

Comments

@b4rti
Copy link

b4rti commented Feb 4, 2024

Hello there.

lib/ziglua/src/lib.zig:1345:17: error: root struct of file 'cimport' has no member named 'lua_objlen'
        return c.lua_objlen(lua.state, index);

Not sure if it's a bug or me being fresh to Lua, but it looks like there was a change in Lua5.2+ and there is no lua_objlen function anymore. Insted there is lua_len, which pushes the result onto the stack.

Lua5.1 Docs

size_t lua_objlen (lua_State *L, int index);
Returns the "length" of the value at the given acceptable index: for strings, this is the string length; for tables, this is the result of the length operator ('#'); for userdata, this is the size of the block of memory allocated for the userdata; for other values, it is 0.

Lua(5.2, 5.3, 5.4) Docs

void lua_len (lua_State *L, int index);
Returns the length of the value at the given index. It is equivalent to the '#' operator in Lua (see §3.4.7) and may trigger a metamethod for the "length" event (see §2.4). The result is pushed on the stack.

@b4rti
Copy link
Author

b4rti commented Feb 4, 2024

Ahh Ok found it. I probably should call Lua.len in this case. Sorry my bad. Both of this functions are available, but in Lua5.2+ i have to remember to call the right one.

@natecraddock
Copy link
Owner

natecraddock commented Feb 4, 2024

Hey! Yep, there are several things that change between versions of Lua.

We recently made a big change (#54) that merged all of the separate Lua language targets into a single lib file. The documentation still needs work though, so sorry for any confusion you might find while we work on that :) Thanks for asking, no need to feel bad!

And as a note, the function in lua 5.2+ that is most similar to lua_objlen is lua_rawlen.

@b4rti b4rti closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants