The Battle for Wesnoth  1.17.0-dev
Macros | Typedefs | Functions | Variables
lua_kernel_base.cpp File Reference
#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_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 <cstring>
#include <exception>
#include <new>
#include <string>
#include <sstream>
#include <vector>
#include "lua/lauxlib.h"
#include "lua/lua.h"
#include "lua/lualib.h"
Include dependency graph for lua_kernel_base.cpp:

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)
 

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_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 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)
 
template<member_callback method>
int dispatch (lua_State *L)
 

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"
 

Macro Definition Documentation

◆ DBG_LUA

#define DBG_LUA   LOG_STREAM(debug, log_scripting_lua)

◆ ERR_LUA

#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)

Definition at line 69 of file lua_kernel_base.cpp.

Referenced by lua_kernel_base::log_error().

◆ LOG_LUA

#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)

◆ WRN_LUA

#define WRN_LUA   LOG_STREAM(warn, log_scripting_lua)

Definition at line 68 of file lua_kernel_base.cpp.

Typedef Documentation

◆ member_callback

typedef int(lua_kernel_base::* member_callback) (lua_State *L)

Definition at line 508 of file lua_kernel_base.cpp.

Function Documentation

◆ dispatch()

template<member_callback method>
int dispatch ( lua_State L)

Definition at line 511 of file lua_kernel_base.cpp.

◆ impl_name_generator_call()

static int impl_name_generator_call ( lua_State L)
static

◆ impl_name_generator_collect()

static int impl_name_generator_collect ( lua_State L)
static

◆ impl_version_compare()

template<VERSION_COMP_OP vop>
static int impl_version_compare ( lua_State L)
static

Compares two versions.

  • Args 1,2: version strings
  • Ret 1: comparison result

Definition at line 85 of file lua_kernel_base.cpp.

References do_version_check(), lua_pushboolean(), luaL_checkudata(), and Version.

◆ impl_version_finalize()

static int impl_version_finalize ( lua_State L)
static

Destroy a version.

Definition at line 128 of file lua_kernel_base.cpp.

References luaL_checkudata(), and Version.

Referenced by intf_make_version().

◆ impl_version_get()

static int impl_version_get ( lua_State L)
static

◆ impl_version_tostring()

static int impl_version_tostring ( lua_State L)
static

Convert a version to string form.

Definition at line 138 of file lua_kernel_base.cpp.

References lua_push(), luaL_checkudata(), version_info::str(), and Version.

Referenced by intf_make_version().

◆ impl_warn()

static void impl_warn ( void *  p,
const char *  msg,
int  tocont 
)
static

◆ intf_current_version()

static int intf_current_version ( lua_State L)
static

Returns the current Wesnoth version.

Definition at line 195 of file lua_kernel_base.cpp.

References intf_make_version(), lua_push(), lua_settop(), and game_config::wesnoth_version.

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_deprecated_message()

static int intf_deprecated_message ( lua_State L)
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 419 of file lua_kernel_base.cpp.

References deprecated_message(), game_config::images::level, lua_error(), lua_isnoneornil, lua_push(), lua_warning(), luaL_checkinteger(), luaL_checkstring, luaW_checktstring(), wfl::msg(), REMOVED, version_info::str(), and game_config::wesnoth_version.

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_get_language()

static int intf_get_language ( lua_State L)
static

Definition at line 499 of file lua_kernel_base.cpp.

References get_language(), and lua_push().

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_load()

static int intf_load ( lua_State L)
static

Replacement load function.

Mostly the same as regular load, but disallows loading binary chunks due to CVE-2018-1999023.

Definition at line 262 of file lua_kernel_base.cpp.

References lua_insert, lua_isnone, LUA_OK, lua_pop, lua_pushnil(), lua_pushvalue(), lua_setupvalue(), luaL_argerror(), luaL_checkstring, luaL_loadbufferx(), and luaL_optstring.

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_log()

static int intf_log ( lua_State L)
static

Logs a message Arg 1: (optional) Logger Arg 2: Message.

Definition at line 393 of file lua_kernel_base.cpp.

References debug, lg::err(), lg::info(), LOG_STREAM, log_user, lua_isstring(), luaL_checkstring, wfl::msg(), and lg::warn().

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_make_shroud_bitmap()

static int intf_make_shroud_bitmap ( lua_State L)
static

◆ intf_make_version()

static int intf_make_version ( lua_State L)
static

◆ intf_ms_since_init()

static int intf_ms_since_init ( lua_State L)
static

Returns the time stamp, exactly as [set_variable] time=stamp does.

  • Ret 1: integer

Definition at line 494 of file lua_kernel_base.cpp.

References lua_pushinteger().

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_name_generator()

static int intf_name_generator ( lua_State L)
static

◆ intf_named_tuple()

static int intf_named_tuple ( lua_State L)
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 445 of file lua_kernel_base.cpp.

References i, lua_geti(), lua_istable, lua_len(), lua_seti(), LUA_TTABLE, lua_typename(), luaL_checkinteger(), luaW_push_namedtuple(), luaW_type_error(), and names.

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_parse_shroud_bitmap()

static int intf_parse_shroud_bitmap ( lua_State L)
static

Variable Documentation

◆ Gen

const char* Gen = "name generator"
static

Definition at line 72 of file lua_kernel_base.cpp.

Referenced by intf_name_generator(), and lua_kernel_base::lua_kernel_base().

◆ Interp

const char* Interp = "lua interpreter"
static

◆ log_scripting_lua

lg::log_domain log_scripting_lua("scripting/lua")
static

◆ log_user

lg::log_domain log_user("scripting/lua/user")
static

Referenced by intf_log().

◆ Version

const char* Version = "version"
static