#include "scripting/lua_kernel_base.hpp"
#include "game_config.hpp"
#include "game_errors.hpp"
#include "gui/core/gui_definition.hpp"
#include "log.hpp"
#include "lua_jailbreak_exception.hpp"
#include "seed_rng.hpp"
#include "deprecation.hpp"
#include "language.hpp"
#include "team.hpp"
#include "scripting/lua_attributes.hpp"
#include "scripting/lua_color.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/lua_cpp_function.hpp"
#include "scripting/lua_fileops.hpp"
#include "scripting/lua_formula_bridge.hpp"
#include "scripting/lua_gui2.hpp"
#include "scripting/lua_wml.hpp"
#include "scripting/lua_stringx.hpp"
#include "scripting/lua_map_location_ops.hpp"
#include "scripting/lua_mathx.hpp"
#include "scripting/lua_rng.hpp"
#include "scripting/lua_widget.hpp"
#include "scripting/push_check.hpp"
#include "game_version.hpp"
#include <functional>
#include "utils/name_generator.hpp"
#include "utils/markov_generator.hpp"
#include "utils/context_free_grammar_generator.hpp"
#include "utils/scope_exit.hpp"
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <numeric>
#include "lua/wrapper_lualib.h"
Go to the source code of this file.
Macros | |
#define | DBG_LUA LOG_STREAM(debug, log_scripting_lua) |
#define | LOG_LUA LOG_STREAM(info, log_scripting_lua) |
#define | WRN_LUA LOG_STREAM(warn, log_scripting_lua) |
#define | ERR_LUA LOG_STREAM(err, log_scripting_lua) |
#define | GAME_CONFIG_SIMPLE_GETTER(name) |
Typedefs | |
typedef int(lua_kernel_base::* | member_callback) (lua_State *L) |
Functions | |
template<VERSION_COMP_OP vop> | |
static int | impl_version_compare (lua_State *L) |
Compares two versions. More... | |
static int | impl_version_get (lua_State *L) |
Decomposes a version into its component parts. More... | |
static int | impl_version_dir (lua_State *L) |
static int | impl_version_finalize (lua_State *L) |
Destroy a version. More... | |
static int | impl_version_tostring (lua_State *L) |
Convert a version to string form. More... | |
static int | intf_make_version (lua_State *L) |
Builds a version from its component parts, or parses it from a string. More... | |
static int | intf_current_version (lua_State *L) |
Returns the current Wesnoth version. More... | |
static void | impl_warn (void *p, const char *msg, int tocont) |
static int | intf_load (lua_State *L) |
Replacement load function. More... | |
static int | intf_pcall (lua_State *L) |
Wrapper for pcall and xpcall functions to rethrow jailbreak exceptions. More... | |
static int | impl_name_generator_call (lua_State *L) |
static int | impl_name_generator_collect (lua_State *L) |
static int | intf_name_generator (lua_State *L) |
static int | intf_log (lua_State *L) |
Logs a message Arg 1: (optional) Logger Arg 2: Message. More... | |
static int | intf_deprecated_message (lua_State *L) |
Logs a deprecation message. More... | |
static int | intf_named_tuple (lua_State *L) |
Converts a Lua array to a named tuple. More... | |
static int | intf_parse_shroud_bitmap (lua_State *L) |
static int | intf_make_shroud_bitmap (lua_State *L) |
static int | intf_ms_since_init (lua_State *L) |
Returns the time stamp, exactly as [set_variable] time=stamp does. More... | |
static int | intf_get_language (lua_State *L) |
static void | dir_meta_helper (lua_State *L, std::vector< std::string > &keys) |
static int | impl_is_deprecated (lua_State *L) |
static int | impl_get_dir_suffix (lua_State *L) |
std::vector< std::string > | luaW_get_attributes (lua_State *L, int idx) |
This function does the actual work of grabbing all the attribute names. More... | |
static int | intf_object_dir (lua_State *L) |
Prints out a list of keys available in an object. More... | |
template<member_callback method> | |
int | dispatch (lua_State *L) |
static void | push_color_palette (lua_State *L, const std::vector< color_t > &palette) |
static int | impl_palette_get (lua_State *L) |
luaW_Registry & | gameConfigReg () |
Variables | |
static lg::log_domain | log_scripting_lua ("scripting/lua") |
static lg::log_domain | log_user ("scripting/lua/user") |
static const char * | Gen = "name generator" |
static const char * | Version = "version" |
static const char * | Interp = "lua interpreter" |
static auto & | dummy = gameConfigReg() |
#define DBG_LUA LOG_STREAM(debug, log_scripting_lua) |
Definition at line 65 of file lua_kernel_base.cpp.
#define ERR_LUA LOG_STREAM(err, log_scripting_lua) |
Definition at line 68 of file lua_kernel_base.cpp.
#define GAME_CONFIG_SIMPLE_GETTER | ( | name | ) |
Definition at line 1282 of file lua_kernel_base.cpp.
#define LOG_LUA LOG_STREAM(info, log_scripting_lua) |
Definition at line 66 of file lua_kernel_base.cpp.
#define WRN_LUA LOG_STREAM(warn, log_scripting_lua) |
Definition at line 67 of file lua_kernel_base.cpp.
typedef int(lua_kernel_base::* member_callback) (lua_State *L) |
Definition at line 733 of file lua_kernel_base.cpp.
|
static |
Definition at line 528 of file lua_kernel_base.cpp.
References lua_push().
Referenced by luaW_get_attributes().
int dispatch | ( | lua_State * | L | ) |
Definition at line 736 of file lua_kernel_base.cpp.
luaW_Registry& gameConfigReg | ( | ) |
Definition at line 1276 of file lua_kernel_base.cpp.
References gameConfigReg().
Referenced by gameConfigReg(), lua_kernel_base::impl_game_config_dir(), lua_kernel_base::impl_game_config_get(), and lua_kernel_base::impl_game_config_set().
|
static |
Definition at line 567 of file lua_kernel_base.cpp.
References luaW_toboolean(), and t.
Referenced by intf_object_dir().
|
static |
Definition at line 549 of file lua_kernel_base.cpp.
References luaW_toboolean().
Referenced by luaW_get_attributes().
|
static |
Definition at line 332 of file lua_kernel_base.cpp.
References name_generator::generate().
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 339 of file lua_kernel_base.cpp.
References name_generator::~name_generator().
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 1266 of file lua_kernel_base.cpp.
References push_color_palette(), and game_config::tc_info().
|
static |
Compares two versions.
Definition at line 84 of file lua_kernel_base.cpp.
References do_version_check(), and Version.
|
static |
Definition at line 124 of file lua_kernel_base.cpp.
References lua_push().
Referenced by intf_make_version().
|
static |
Destroy a version.
Definition at line 134 of file lua_kernel_base.cpp.
References Version.
Referenced by intf_make_version().
|
static |
Decomposes a version into its component parts.
Definition at line 96 of file lua_kernel_base.cpp.
References version_info::components(), version_info::is_canonical(), version_info::major_version(), version_info::minor_version(), n, return_bool_attrib, return_int_attrib, return_string_attrib, version_info::revision_level(), version_info::special_version(), version_info::special_version_separator(), and Version.
Referenced by intf_make_version().
|
static |
Convert a version to string form.
Definition at line 144 of file lua_kernel_base.cpp.
References lua_push(), version_info::str(), and Version.
Referenced by intf_make_version().
|
static |
Definition at line 243 of file lua_kernel_base.cpp.
References lua_push(), luaW_getglobal(), wfl::msg(), and p.
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Returns the current Wesnoth version.
Definition at line 202 of file lua_kernel_base.cpp.
References intf_make_version(), lua_push(), and game_config::wesnoth_version.
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Logs a deprecation message.
See deprecation.cpp for details Arg 1: Element to be deprecated. Arg 2: Deprecation level. Arg 3: Version when element may be removed. Arg 4: Additional detail message.
Definition at line 442 of file lua_kernel_base.cpp.
References deprecated_message(), game_config::images::level, lua_push(), luaW_checktstring(), wfl::msg(), REMOVED, version_info::str(), and game_config::wesnoth_version.
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 522 of file lua_kernel_base.cpp.
References get_language(), and lua_push().
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Replacement load function.
Mostly the same as regular load, but disallows loading binary chunks due to CVE-2018-1999023.
Definition at line 269 of file lua_kernel_base.cpp.
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Logs a message Arg 1: (optional) Logger Arg 2: Message.
Definition at line 416 of file lua_kernel_base.cpp.
References debug, lg::err(), lg::info(), LOG_STREAM, log_user, wfl::msg(), and lg::warn().
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 501 of file lua_kernel_base.cpp.
References shroud_map::clear(), loc, lua_push(), luaW_check_locationset(), shroud_map::set_enabled(), map_location::wml_x(), map_location::wml_y(), and shroud_map::write().
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Builds a version from its component parts, or parses it from a string.
Definition at line 154 of file lua_kernel_base.cpp.
References impl_version_dir(), impl_version_finalize(), impl_version_get(), impl_version_tostring(), and Version.
Referenced by intf_current_version(), and lua_kernel_base::lua_kernel_base().
|
static |
Returns the time stamp, exactly as [set_variable] time=stamp does.
Definition at line 517 of file lua_kernel_base.cpp.
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 346 of file lua_kernel_base.cpp.
References data, deprecated_message(), Gen, INDEFINITE, luaW_checktstring(), utils::parenthetical_split(), utils::split(), t_string::str(), and name_generator_invalid_exception::what().
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Converts a Lua array to a named tuple.
Arg 1: A Lua array Arg 2: An array of strings Ret: A copy of arg 1 that's now a named tuple with the names in arg 2. The copy will only include the array portion of the input array. Any non-integer keys or non-consecutive keys will be gone. Note: This exists so that wml.tag can use it but is not really intended as a public API.
Definition at line 468 of file lua_kernel_base.cpp.
References i, luaW_push_namedtuple(), luaW_type_error(), and names.
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Prints out a list of keys available in an object.
A list of keys is gathered from the following sources:
Definition at line 684 of file lua_kernel_base.cpp.
References flush(), i, impl_get_dir_suffix(), draw::line(), lua_push(), luaW_get_attributes(), luaW_getglobal(), and ON_SCOPE_EXIT.
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 484 of file lua_kernel_base.cpp.
References shroud_map::height(), luaW_push_locationset(), shroud_map::read(), shroud_map::set_enabled(), shroud_map::value(), and shroud_map::width().
Referenced by lua_kernel_base::lua_kernel_base().
|
static |
Wrapper for pcall and xpcall functions to rethrow jailbreak exceptions.
Definition at line 306 of file lua_kernel_base.cpp.
References lua_jailbreak_exception::rethrow().
Referenced by lua_kernel_base::lua_kernel_base().
std::vector<std::string> luaW_get_attributes | ( | lua_State * | L, |
int | idx | ||
) |
This function does the actual work of grabbing all the attribute names.
It's a separate function so that it can be used by tab-completion as well.
Definition at line 608 of file lua_kernel_base.cpp.
References dir_meta_helper(), impl_is_deprecated(), lua_push(), luaW_toboolean(), and ON_SCOPE_EXIT.
Referenced by luaW_Registry::dir(), lua_widget::impl_widget_dir(), and intf_object_dir().
|
static |
Definition at line 1249 of file lua_kernel_base.cpp.
References b, g, i, luaW_push_namedtuple(), and palette().
Referenced by impl_palette_get().
|
static |
Definition at line 1280 of file lua_kernel_base.cpp.
|
static |
Definition at line 71 of file lua_kernel_base.cpp.
Referenced by intf_name_generator(), and lua_kernel_base::lua_kernel_base().
|
static |
Definition at line 74 of file lua_kernel_base.cpp.
Referenced by lua_kernel_base::interactive_run(), lua_kernel_base::lua_kernel_base(), and lua_kernel_base::throwing_run().
|
static |
|
static |
Referenced by intf_log().
|
static |
Definition at line 72 of file lua_kernel_base.cpp.
Referenced by impl_version_compare(), impl_version_finalize(), impl_version_get(), impl_version_tostring(), and intf_make_version().