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 changes #1516

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion old-configure
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,10 @@ test_lua() {
test_lua "lua >= 5.1.0 lua < 5.2.0"
test_lua "lua5.1 >= 5.1.0" # debian
test_lua "luajit >= 2.0.0"
test_lua "lua >= 5.2.0"
test_lua "lua >= 5.2.0 lua < 5.3.0"
test_lua "lua5.2 >= 5.2.0" # debian
test_lua "lua >= 5.3.0"
test_lua "lua5.3 >= 5.3.0" # debian

test "$_lua" != yes && check_yes_no no LUA

Expand Down
29 changes: 23 additions & 6 deletions player/lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ static int mp_cpcall (lua_State *L, lua_CFunction func, void *ud)
#define mp_lua_len lua_rawlen
#endif

#if LUA_VERSION_NUM < 503
#define mp_luaL_checkinteger(L, arg, def) luaL_checkinteger(L, arg)
#else
static int mp_luaL_checkinteger(lua_State *L, int arg, int def)
{
lua_Integer res;
lua_Number num = luaL_checknumber(L, arg);
if (!lua_numbertointeger(num, &res))
return def;
return res;
}
#endif

// Ensure that the given argument exists, even if it's nil. Can be used to
// avoid confusing the last missing optional arg with the first temporary value
// pushed to the stack.
Expand Down Expand Up @@ -825,7 +838,11 @@ static void pushnode(lua_State *L, mpv_node *node)
lua_pushstring(L, node->u.string);
break;
case MPV_FORMAT_INT64:
#if LUA_VERSION_NUM < 503
lua_pushnumber(L, node->u.int64);
#else
lua_pushinteger(L, node->u.int64);
#endif
break;
case MPV_FORMAT_DOUBLE:
lua_pushnumber(L, node->u.double_);
Expand Down Expand Up @@ -941,8 +958,8 @@ static int script_command_native(lua_State *L)
static int script_set_osd_ass(lua_State *L)
{
struct MPContext *mpctx = get_mpctx(L);
int res_x = luaL_checkinteger(L, 1);
int res_y = luaL_checkinteger(L, 2);
int res_x = mp_luaL_checkinteger(L, 1, 0);
int res_y = mp_luaL_checkinteger(L, 2, 0);
const char *text = luaL_checkstring(L, 3);
osd_set_external(mpctx->osd, res_x, res_y, (char *)text);
mp_input_wakeup(mpctx->input);
Expand Down Expand Up @@ -1050,10 +1067,10 @@ static int script_input_set_section_mouse_area(lua_State *L)
osd_object_get_scale_factor(mpctx->osd, OSDTYPE_EXTERNAL, &sw, &sh);

char *section = (char *)luaL_checkstring(L, 1);
int x0 = sw ? luaL_checkinteger(L, 2) / sw : 0;
int y0 = sh ? luaL_checkinteger(L, 3) / sh : 0;
int x1 = sw ? luaL_checkinteger(L, 4) / sw : 0;
int y1 = sh ? luaL_checkinteger(L, 5) / sh : 0;
int x0 = sw ? mp_luaL_checkinteger(L, 2, 0) / sw : 0;
int y0 = sh ? mp_luaL_checkinteger(L, 3, 0) / sh : 0;
int x1 = sw ? mp_luaL_checkinteger(L, 4, 0) / sw : 0;
int y1 = sh ? mp_luaL_checkinteger(L, 5, 0) / sh : 0;
mp_input_set_section_mouse_area(mpctx->input, section, x0, y0, x1, y1);
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ function render_elements(master_ass)
end

style_ass:append(string.format("{\\1a&H%X&\\2a&H%X&\\3a&H%X&\\4a&H%X&}",
ar[1], ar[2], ar[3], ar[4]))
math.floor(ar[1]), math.floor(ar[2]),
math.floor(ar[3]), math.floor(ar[4])))

if (state.active_element == n) then

Expand Down
8 changes: 7 additions & 1 deletion waftools/checks/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ def check_lua(ctx, dependency_identifier):
( '51', 'lua >= 5.1.0 lua < 5.2.0'),
( '51deb', 'lua5.1 >= 5.1.0'), # debian
( '51fbsd', 'lua-5.1 >= 5.1.0'), # FreeBSD
( '52', 'lua >= 5.2.0' ),
( '52', 'lua >= 5.2.0 lua < 5.3.0' ),
( '52deb', 'lua5.2 >= 5.2.0'), # debian
( '52fbsd', 'lua-5.2 >= 5.2.0'), # FreeBSD
( '53', 'lua >= 5.3.0' ),
( '53deb', 'lua5.2 >= 5.3.0'), # debian
( '53fbsd', 'lua-5.2 >= 5.3.0'), # FreeBSD
( 'luajit', 'luajit >= 2.0.0' ),
]

Expand All @@ -72,6 +75,9 @@ def check_lua(ctx, dependency_identifier):
ctx.mark_satisfied(lua_version)
ctx.add_optional_message(dependency_identifier,
'version found: ' + lua_version)
if lua_version.startswith('53'):
print 'Lua 5.3 is very unlikely to work properly...'
return False
return True
return False

Expand Down