Fixup d192d0712393 and move wesnoth.debug() to lua_kernel_base

This commit is contained in:
Celtic Minstrel 2017-08-14 13:09:52 -04:00
parent a4172bddc1
commit 00443dd8a4
4 changed files with 21 additions and 23 deletions

View file

@ -150,7 +150,7 @@ local _ = wesnoth.textdomain "wesnoth"
-- Note: When using version (for level 2 or 3 deprecation), specify the first version
-- in which the feature could be removed... NOT the version at which it was deprecated.
local function wesnoth.deprecation_message(elem_name, level, version, detail)
function wesnoth.deprecation_message(elem_name, level, version, detail)
local message_params = {elem = elem_name}
local logger
local message
@ -174,7 +174,7 @@ local function wesnoth.deprecation_message(elem_name, level, version, detail)
else
error(_"Invalid deprecation level (should be 1-4)")
end
if len(detail) > 0 then
if #detail > 0 then
logger(message .. "\n " .. detail)
else
logger(message)
@ -354,8 +354,10 @@ end
-- Some C++ functions are deprecated; apply the messages here.
-- Note: It must happen AFTER the C++ functions are reassigned above to their new location.
-- These deprecated functions will probably never be removed.
wesnoth.get_variable = wesnoth.deprecate_api('wesnoth.get_variable', 'wml.variable.get', 1, nil, wesnoth.get_variable)
wesnoth.set_variable = wesnoth.deprecate_api('wesnoth.set_variable', 'wml.variable.set', 1, nil, wesnoth.set_variable)
wesnoth.get_all_vars = wesnoth.deprecate_api('wesnoth.get_all_vars', 'wml.variable.get_all', 1, nil, wesnoth.get_all_vars)
if wesnoth.kernel_type() == "Game Lua Kernel" then
wesnoth.get_variable = wesnoth.deprecate_api('wesnoth.get_variable', 'wml.variable.get', 1, nil, wesnoth.get_variable)
wesnoth.set_variable = wesnoth.deprecate_api('wesnoth.set_variable', 'wml.variable.set', 1, nil, wesnoth.set_variable)
wesnoth.get_all_vars = wesnoth.deprecate_api('wesnoth.get_all_vars', 'wml.variable.get_all', 1, nil, wesnoth.get_all_vars)
end
wesnoth.tovconfig = wesnoth.deprecate_api('wesnoth.tovconfig', 'wml.tovconfig', 1, nil, wesnoth.tovconfig)
wesnoth.debug = wesnoth.deprecate_api('wesnoth.debug', 'wml.tostring', 1, nil, wesnoth.debug)

View file

@ -335,13 +335,10 @@ helper.shallow_parsed = wml.shallow_parsed
helper.distance_between = wesnoth.deprecate_api('helper.distance_between', 'wesnoth.map.distance_between', 1, nil, helper.distance_between)
helper.get_child = wesnoth.deprecate_api('helper.get_child', 'wml.get_child', 1, nil, wml.get_child)
helper.get_nth_child = wesnoth.deprecate('helper.get_nth_child', 'wml.get_nth_child', 1, nil, wml.get_nth_child)
helper.get_nth_child = wesnoth.deprecate_api('helper.get_nth_child', 'wml.get_nth_child', 1, nil, wml.get_nth_child)
helper.child_count = wesnoth.deprecate_api('helper.child_count', 'wml.child_count', 1, nil, wml.child_count)
helper.child_range = wesnoth.deprecate_api('helper.child_range', 'wml.child_range', 1, nil, wml.child_range)
helper.child_array = wesnoth.deprecate_api('helper.child_array', 'wml.child_array', 1, nil, wml.child_array)
helper.get_variable_array = wesnoth.deprecate_api('helper.get_variable_array', 'wml.variable.get_array', 1, nil, wml.variable.get_array)
helper.set_variable_array = wesnoth.deprecate_api('helper.set_variable_array', 'wml.variable.set_array', 1, nil, wml.variable.set_array)
helper.get_variable_proxy_array = wesnoth.deprecate_api('helper.get_variable_proxy_array', 'wml.variable.get_proxy_array', 1, nil, wml.variable.get_proxy_array)
helper.literal = wesnoth.deprecate_api('helper.literal', 'wml.literal', 1, nil, wml.literal)
helper.parsed = wesnoth.deprecate_api('helper.parsed', 'wml.parsed', 1, nil, wml.parsed)
helper.shallow_literal = wesnoth.deprecate_api('helper.shallow_literal', 'wml.shallow_literal', 1, nil, wml.shallow_literal)

View file

@ -1429,19 +1429,6 @@ int game_lua_kernel::intf_zoom(lua_State* L)
return 1;
}
/**
* Dumps a wml table or userdata wml object into a pretty string.
* - Arg 1: wml table or vconfig userdata
* - Ret 1: string
*/
static int intf_debug(lua_State* L)
{
const config& arg = luaW_checkconfig(L, 1);
const std::string& result = arg.debug();
lua_pushstring(L, result.c_str());
return 1;
}
/**
* Removes all messages from the chat window.
*/
@ -3978,7 +3965,6 @@ game_lua_kernel::game_lua_kernel(game_state & gs, play_controller & pc, reports
{ "copy_unit", &intf_copy_unit },
{ "create_animator", &intf_create_animator },
{ "create_unit", &intf_create_unit },
{ "debug", &intf_debug },
{ "debug_ai", &intf_debug_ai },
{ "eval_conditional", &intf_eval_conditional },
{ "get_era", &intf_get_era },

View file

@ -327,6 +327,18 @@ static int intf_format_list(lua_State* L)
return 1;
}
/**
* Dumps a wml table or userdata wml object into a pretty string.
* - Arg 1: wml table or vconfig userdata
* - Ret 1: string
*/
static int intf_debug(lua_State* L) {
const config& arg = luaW_checkconfig(L, 1);
const std::string& result = arg.debug();
lua_pushstring(L, result.c_str());
return 1;
}
// End Callback implementations
// Template which allows to push member functions to the lua kernel base into lua as C functions, using a shim
@ -422,6 +434,7 @@ lua_kernel_base::lua_kernel_base()
static luaL_Reg const callbacks[] {
{ "compare_versions", &intf_compare_versions },
{ "debug", &intf_debug },
{ "have_file", &lua_fileops::intf_have_file },
{ "read_file", &lua_fileops::intf_read_file },
{ "textdomain", &lua_common::intf_textdomain },