The Battle for Wesnoth  1.15.5+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 "random.hpp"
#include "seed_rng.hpp"
#include "deprecation.hpp"
#include "language.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_rng.hpp"
#include "scripting/lua_widget.hpp"
#include "scripting/lua_widget_methods.hpp"
#include "scripting/push_check.hpp"
#include "game_version.hpp"
#include "picture.hpp"
#include "utils/functional.hpp"
#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

static int intf_compare_versions (lua_State *L)
 Compares 2 version strings - which is newer. More...
 
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_random (lua_State *L)
 Returns a random numer, same interface as math.random. More...
 
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_get_image_size (lua_State *L)
 Gets the dimension of an image. More...
 
static int intf_get_time_stamp (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 * 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 369 of file lua_kernel_base.cpp.

Function Documentation

◆ dispatch()

template<member_callback method>
int dispatch ( lua_State L)

Definition at line 372 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

◆ intf_compare_versions()

static int intf_compare_versions ( lua_State L)
static

Compares 2 version strings - which is newer.

  • Args 1,3: version strings
  • Arg 2: comparison operator (string)
  • Ret 1: comparison result

Definition at line 84 of file lua_kernel_base.cpp.

References do_version_check(), lua_pushboolean(), luaL_argerror(), luaL_checkstring, OP_INVALID, and parse_version_op().

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 319 of file lua_kernel_base.cpp.

References deprecated_message(), lua_error(), lua_isnoneornil, lua_push(), luaL_checkinteger(), luaL_checkstring, luaW_checktstring(), wfl::msg(), REMOVED, version_info::str(), mariadb::value::string, and game_config::wesnoth_version.

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_get_image_size()

static int intf_get_image_size ( lua_State L)
static

Gets the dimension of an image.

  • Arg 1: string.
  • Ret 1: width.
  • Ret 2: height.

Definition at line 341 of file lua_kernel_base.cpp.

References image::locator::file_exists(), image::get_image(), lua_pushinteger(), luaL_checkstring, and s.

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_get_language()

static int intf_get_language ( lua_State L)
static

Definition at line 360 of file lua_kernel_base.cpp.

References get_language(), and lua_push().

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_get_time_stamp()

static int intf_get_time_stamp ( lua_State L)
static

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

  • Ret 1: integer

Definition at line 355 of file lua_kernel_base.cpp.

References lua_pushinteger().

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 137 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(), luaL_optstring, and mariadb::value::string.

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 293 of file lua_kernel_base.cpp.

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

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_name_generator()

static int intf_name_generator ( lua_State L)
static

◆ intf_random()

static int intf_random ( lua_State L)
static

Returns a random numer, same interface as math.random.

Definition at line 261 of file lua_kernel_base.cpp.

References randomness::generator, lua_isnoneornil, lua_isnumber(), lua_push(), luaL_argerror(), and randomness::rng::next_random().

Referenced by lua_kernel_base::lua_kernel_base().

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().