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.3 support along with some compatibility adjustments. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

admbbs
Copy link

@admbbs admbbs commented Apr 9, 2020

These items include uncompatible changes so you might like to create a new branch for them.

1. The undocumented API luaL_findtable

It is no longer available in Lua 5.3 but turned out practical for this project. We added an auxiliary function "lua_protobuf_find_or_create_nested_table" in lua-protobuf.h/cc with similar implementation. And all its references are replaced by the new function, of course.

2. luaL_register

It is also unavailable in Lua 5.3. We replaced it with the new API "luaL_setfuncs" for each call with a NULL "libname" param. And those with non-NULL "libname" params were replaced with a combination of "luaL_setfuncs" as well as "lua_protobuf_find_or_create_nested_table" mentioned in the first clause above, and maybe a "lua_pop", if necessary, instead.

3. lua_pushinteger for enums rather than lua_pushnumber

As the title says.

4. ternary conditional operator

Lua API lua_pushlstring and lua_pushnil have different return types, and gcc complains if we use them as the second and the third operand for the ternary conditional operator. We changed them to "if ... else ..." statements.

1. The undocumented API luaL_findtable

It is no longer available in Lua 5.3 but turned out practical for this
project.
We added an auxiliary function
"lua_protobuf_find_or_create_nested_table" in
lua-protobuf.h/cc with similar implementation. And all its references
are
replaced by the new function, of course.

2. luaL_register

It is also unavailable in Lua 5.3. We replaced it with the new API
"luaL_setfuncs" for each call with a NULL "libname" param. And those
with
non-NULL "libname" params were replaced with a combination of
"luaL_setfuncs"
as well as "lua_protobuf_find_or_create_nested_table" mentioned in the
first
clause above, and maybe a "lua_pop", if necessary, instead.

3. lua_pushinteger for enums rather than lua_pushnumber

4. ternary conditional operator

Lua API lua_pushlstring and lua_pushnil have different return types, and
gcc
complains if we use them as the second and the third operand for the
ternary
conditional operator. We changed them to "if ... else ..." statements.
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

Successfully merging this pull request may close these issues.

None yet

1 participant