The Battle for Wesnoth  1.17.4+dev
Namespaces | Macros | Functions
lua_common.hpp File Reference
#include "config.hpp"
#include "variable_info.hpp"
#include "map/location.hpp"
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for lua_common.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 lua_common
 

Macros

#define deprecate_attrib(name, prefix, level, version, msg)   deprecated_message(prefix "." name, DEP_LEVEL::level, version, msg)
 
#define return_deprecated_attrib(type_macro, name, accessor, prefix, level, version, msg)
 
#define return_tstring_attrib(name, accessor)
 
#define return_tstring_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_deprecated_attrib(return_tstring_attrib, name, accessor, prefix, level, version, msg)
 
#define return_cstring_attrib(name, accessor)
 
#define return_cstring_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_deprecated_attrib(return_cstring_attrib, name, accessor, prefix, level, version, msg)
 
#define return_string_attrib(name, accessor)
 
#define return_string_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_deprecated_attrib(return_string_attrib, name, accessor, prefix, level, version, msg)
 
#define return_int_attrib(name, accessor)
 
#define return_int_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_deprecated_attrib(return_int_attrib, name, accessor, prefix, level, version, msg)
 
#define return_float_attrib(name, accessor)
 
#define return_float_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_deprecated_attrib(return_float_attrib, name, accessor, prefix, level, version, msg)
 
#define return_bool_attrib(name, accessor)
 
#define return_bool_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_deprecated_attrib(return_bool_attrib, name, accessor, prefix, level, version, msg)
 
#define return_cfg_attrib(name, accessor)
 
#define return_cfg_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_cfg_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)
 
#define return_cfgref_attrib(name, accessor)
 
#define return_cfgref_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_deprecated_attrib(return_cfgref_attrib, name, accessor, prefix, level, version, msg)
 
#define return_vector_string_attrib(name, accessor)
 
#define return_vector_string_attrib_deprecated(name, prefix, level, version, msg, accessor)   return_deprecated_attrib(return_vector_string_attrib, name, accessor, prefix, level, version, msg)
 
#define modify_tstring_attrib(name, accessor)
 
#define modify_tstring_attrib_deprecated(name, prefix, level, version, msg, accessor)   modify_tstring_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)
 
#define modify_string_attrib(name, accessor)
 
#define modify_string_attrib_deprecated(name, prefix, level, version, msg, accessor)   modify_string_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)
 
#define modify_int_attrib(name, accessor)
 
#define modify_int_attrib_deprecated(name, prefix, level, version, msg, accessor)   modify_int_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)
 
#define modify_int_attrib_check_range(name, accessor, allowed_min, allowed_max)
 
#define modify_int_attrib_check_range_deprecated(name, prefix, level, version, msg, accessor, allowed_min, allowed_max)   modify_int_attrib_check_range(name, deprecate_attrib(name, prefix, level, version, msg); accessor, allowed_min, allowed_max)
 
#define modify_float_attrib(name, accessor)
 
#define modify_float_attrib_deprecated(name, prefix, level, version, msg, accessor)   modify_float_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)
 
#define modify_float_attrib_check_range(name, accessor, allowed_min, allowed_max)
 
#define modify_float_attrib_check_range_deprecated(name, prefix, level, version, msg, accessor, allowed_min, allowed_max)   modify_float_attrib_check_range(name, deprecate_attrib(name, prefix, level, version, msg); accessor, allowed_min, allowed_max)
 
#define modify_bool_attrib(name, accessor)
 
#define modify_bool_attrib_deprecated(name, prefix, level, version, msg, accessor)   modify_bool_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)
 
#define modify_cfg_attrib(name, accessor)
 
#define modify_cfg_attrib_deprecated(name, prefix, level, version, msg, accessor)   modify_cfg_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)
 
#define modify_vector_string_attrib(name, accessor)
 
#define modify_vector_string_attrib_deprecated(name, prefix, level, version, msg, accessor)   modify_vector_string_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)
 

Functions

int lua_common::intf_textdomain (lua_State *L)
 Creates an interface for gettext. More...
 
int lua_common::intf_tovconfig (lua_State *L)
 Creates a vconfig containing the WML table. More...
 
std::string lua_common::register_gettext_metatable (lua_State *L)
 Adds the gettext metatable. More...
 
std::string lua_common::register_tstring_metatable (lua_State *L)
 Adds the tstring metatable. More...
 
std::string lua_common::register_vconfig_metatable (lua_State *L)
 Adds the vconfig metatable. More...
 
void * operator new (std::size_t sz, lua_State *L, int nuv=0)
 
void operator delete (void *p, lua_State *L, int nuv)
 
bool luaW_getmetafield (lua_State *L, int idx, const char *key)
 Like luaL_getmetafield, but returns false if key is an empty string or begins with two underscores. More...
 
void luaW_pushvconfig (lua_State *L, const vconfig &cfg)
 Pushes a vconfig on the top of the stack. More...
 
void luaW_pushtstring (lua_State *L, const t_string &v)
 Pushes a t_string on the top of the stack. More...
 
void luaW_pushscalar (lua_State *L, const config::attribute_value &v)
 Converts an attribute value into a Lua object pushed at the top of the stack. More...
 
bool luaW_toscalar (lua_State *L, int index, config::attribute_value &v)
 Converts the value at the top of the stack to an attribute value. More...
 
bool luaW_totstring (lua_State *L, int index, t_string &str)
 Converts a scalar to a translatable string. More...
 
t_string luaW_checktstring (lua_State *L, int index)
 Converts a scalar to a translatable string. More...
 
bool luaW_iststring (lua_State *L, int index)
 
void luaW_filltable (lua_State *L, const config &cfg)
 Converts a config object to a Lua table. More...
 
void luaW_push_namedtuple (lua_State *L, const std::vector< std::string > &names)
 Push an empty "named tuple" onto the stack. More...
 
void luaW_pushlocation (lua_State *L, const map_location &loc)
 Converts a map location object to a Lua table pushed at the top of the stack. More...
 
bool luaW_tolocation (lua_State *L, int index, map_location &loc)
 Converts an optional table or pair of integers to a map location object. More...
 
map_location luaW_checklocation (lua_State *L, int index)
 Converts an optional table or pair of integers to a map location object. More...
 
int luaW_push_locationset (lua_State *L, const std::set< map_location > &locs)
 Converts a set of map locations to a Lua table pushed at the top of the stack. More...
 
std::set< map_locationluaW_check_locationset (lua_State *L, int idx)
 Converts a table of integer pairs to a set of map location objects. More...
 
void luaW_pushconfig (lua_State *L, const config &cfg)
 Converts a config object to a Lua table pushed at the top of the stack. More...
 
bool luaW_toconfig (lua_State *L, int index, config &cfg)
 Converts an optional table or vconfig to a config object. More...
 
config luaW_checkconfig (lua_State *L, int index)
 Converts an optional table or vconfig to a config object. More...
 
bool luaW_tovconfig (lua_State *L, int index, vconfig &vcfg)
 Gets an optional vconfig from either a table or a userdata. More...
 
vconfig luaW_checkvconfig (lua_State *L, int index, bool allow_missing=false)
 Gets an optional vconfig from either a table or a userdata. More...
 
config luaW_checkconfig (lua_State *L, int index, const vconfig *&vcfg)
 Like the two-argument version, but if it was a vconfig, also returns a pointer to that vconfig. More...
 
bool luaW_getglobal (lua_State *L, const std::vector< std::string > &path)
 Pushes the value found by following the variadic names (char *), if the value is not nil. More...
 
template<typename... T>
bool luaW_getglobal (lua_State *L, T... path)
 Pushes the value found by following the variadic names (char *), if the value is not nil. More...
 
bool luaW_toboolean (lua_State *L, int n)
 
bool luaW_pushvariable (lua_State *L, variable_access_const &v)
 
bool luaW_checkvariable (lua_State *L, variable_access_create &v, int n)
 
bool luaW_tableget (lua_State *L, int index, const char *key)
 
std::string_view luaW_tostring (lua_State *L, int index)
 
std::string_view luaW_tostring_or_default (lua_State *L, int index, std::string_view def=std::string_view())
 
void chat_message (const std::string &caption, const std::string &msg)
 Displays a message in the chat window. More...
 
bool luaW_pcall (lua_State *L, int nArgs, int nRets, bool allow_wml_error=false)
 Calls a Lua function stored below its nArgs arguments at the top of the stack. More...
 
void push_error_handler (lua_State *L)
 
int luaW_pcall_internal (lua_State *L, int nArgs, int nRets)
 
int luaW_type_error (lua_State *L, int narg, const char *tname)
 
int luaW_type_error (lua_State *L, int narg, const char *kpath, const char *tname)
 

Macro Definition Documentation

◆ deprecate_attrib

#define deprecate_attrib (   name,
  prefix,
  level,
  version,
  msg 
)    deprecated_message(prefix "." name, DEP_LEVEL::level, version, msg)

Definition at line 228 of file lua_common.hpp.

◆ modify_bool_attrib

#define modify_bool_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
bool value = luaW_toboolean(L, 3); \
{accessor;} \
return 0; \
} \
} while(false)
bool luaW_toboolean(lua_State *L, int n)
Definition: lua_common.cpp:971

Definition at line 404 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_end_level_data_set(), game_lua_kernel::impl_game_config_set(), game_lua_kernel::impl_scenario_set(), impl_source_set(), and impl_track_set().

◆ modify_bool_attrib_deprecated

#define modify_bool_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    modify_bool_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)

Definition at line 412 of file lua_common.hpp.

◆ modify_cfg_attrib

#define modify_cfg_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
const config& cfg = luaW_checkconfig(L, 3); \
{accessor;} \
return 0; \
} \
} while(false)
config luaW_checkconfig(lua_State *L, int index)
Converts an optional table or vconfig to a config object.
Definition: lua_common.cpp:900
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60

Definition at line 415 of file lua_common.hpp.

Referenced by impl_unit_variables_set().

◆ modify_cfg_attrib_deprecated

#define modify_cfg_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    modify_cfg_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)

Definition at line 423 of file lua_common.hpp.

◆ modify_float_attrib

#define modify_float_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
lua_Number value = luaL_checknumber(L, 3); \
{accessor;} \
return 0; \
} \
} while(false)

Definition at line 381 of file lua_common.hpp.

◆ modify_float_attrib_check_range

#define modify_float_attrib_check_range (   name,
  accessor,
  allowed_min,
  allowed_max 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
lua_Number value = luaL_checknumber(L, 3); \
if (value < (allowed_min) || (allowed_max) < value) return luaL_argerror(L, 3, "out of bounds"); \
{accessor;} \
return 0; \
} \
} while(false)

Definition at line 392 of file lua_common.hpp.

Referenced by impl_music_set().

◆ modify_float_attrib_check_range_deprecated

#define modify_float_attrib_check_range_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor,
  allowed_min,
  allowed_max 
)    modify_float_attrib_check_range(name, deprecate_attrib(name, prefix, level, version, msg); accessor, allowed_min, allowed_max)

Definition at line 401 of file lua_common.hpp.

◆ modify_float_attrib_deprecated

#define modify_float_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    modify_float_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)

Definition at line 389 of file lua_common.hpp.

◆ modify_int_attrib

#define modify_int_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
int value = static_cast<int>(luaL_checknumber(L, 3)); \
{accessor;} \
return 0; \
} \
} while(false)

Definition at line 358 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_game_config_set(), game_lua_kernel::impl_scenario_set(), game_lua_kernel::impl_schedule_set(), impl_source_set(), impl_track_set(), and impl_unit_attack_set().

◆ modify_int_attrib_check_range

#define modify_int_attrib_check_range (   name,
  accessor,
  allowed_min,
  allowed_max 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
int value = static_cast<int>(luaL_checknumber(L, 3)); \
if (value < (allowed_min) || (allowed_max) < value) return luaL_argerror(L, 3, "out of bounds"); \
{accessor;} \
return 0; \
} \
} while(false)

Definition at line 369 of file lua_common.hpp.

Referenced by impl_music_set().

◆ modify_int_attrib_check_range_deprecated

#define modify_int_attrib_check_range_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor,
  allowed_min,
  allowed_max 
)    modify_int_attrib_check_range(name, deprecate_attrib(name, prefix, level, version, msg); accessor, allowed_min, allowed_max)

Definition at line 378 of file lua_common.hpp.

◆ modify_int_attrib_deprecated

#define modify_int_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    modify_int_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)

Definition at line 366 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_game_config_set().

◆ modify_string_attrib

#define modify_string_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
const char *value = luaL_checkstring(L, 3); \
{accessor;} \
return 0; \
} \
} while(false)

Definition at line 347 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_end_level_data_set(), game_lua_kernel::impl_game_config_set(), game_lua_kernel::impl_scenario_set(), game_lua_kernel::impl_schedule_set(), impl_track_set(), and impl_unit_attack_set().

◆ modify_string_attrib_deprecated

#define modify_string_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    modify_string_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)

Definition at line 355 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_game_config_set().

◆ modify_tstring_attrib

#define modify_tstring_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
t_string value = luaW_checktstring(L, 3); \
{accessor;} \
return 0; \
} \
} while(false)
t_string luaW_checktstring(lua_State *L, int index)
Converts a scalar to a translatable string.
Definition: lua_common.cpp:626

Definition at line 336 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_scenario_set(), and impl_unit_attack_set().

◆ modify_tstring_attrib_deprecated

#define modify_tstring_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    modify_tstring_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)

Definition at line 344 of file lua_common.hpp.

◆ modify_vector_string_attrib

#define modify_vector_string_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
std::vector<std::string> value; \
char const* message = "table with unnamed indices holding strings expected"; \
if (!lua_istable(L, 3)) return luaL_argerror(L, 3, message); \
unsigned length = lua_rawlen(L, 3); \
for (unsigned i = 1; i <= length; ++i) { \
lua_rawgeti(L, 3, i); \
char const* string = lua_tostring(L, 4); \
if(!string) return luaL_argerror(L, 2 + i, message); \
value.push_back(string); \
lua_pop(L, 1); \
} \
{accessor;} \
return 0; \
} \
} while(false)
std::size_t i
Definition: function.cpp:967

Definition at line 426 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_scenario_set().

◆ modify_vector_string_attrib_deprecated

#define modify_vector_string_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    modify_vector_string_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)

Definition at line 444 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_game_config_set().

◆ return_bool_attrib

#define return_bool_attrib (   name,
  accessor 
)

◆ return_bool_attrib_deprecated

#define return_bool_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_deprecated_attrib(return_bool_attrib, name, accessor, prefix, level, version, msg)

Definition at line 294 of file lua_common.hpp.

◆ return_cfg_attrib

#define return_cfg_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
config cfg; \
{accessor;} \
luaW_pushconfig(L, cfg); \
return 1; \
} \
} while(false)

Definition at line 297 of file lua_common.hpp.

Referenced by impl_end_level_data_get(), impl_side_get(), impl_source_get(), and impl_track_get().

◆ return_cfg_attrib_deprecated

#define return_cfg_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_cfg_attrib(name, deprecate_attrib(name, prefix, level, version, msg); accessor)

Definition at line 306 of file lua_common.hpp.

◆ return_cfgref_attrib

#define return_cfgref_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
luaW_pushconfig(L, (accessor)); \
return 1; \
} \
} while(false)

Definition at line 309 of file lua_common.hpp.

Referenced by impl_mp_settings_get(), impl_race_get(), game_lua_kernel::impl_scenario_get(), impl_unit_attack_get(), impl_unit_type_get(), and impl_unit_variables_get().

◆ return_cfgref_attrib_deprecated

#define return_cfgref_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_deprecated_attrib(return_cfgref_attrib, name, accessor, prefix, level, version, msg)

Definition at line 316 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_game_config_get().

◆ return_cstring_attrib

#define return_cstring_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
lua_pushstring(L, (accessor)); \
return 1; \
} \
} while(false)

Definition at line 246 of file lua_common.hpp.

Referenced by impl_end_level_data_get().

◆ return_cstring_attrib_deprecated

#define return_cstring_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_deprecated_attrib(return_cstring_attrib, name, accessor, prefix, level, version, msg)

Definition at line 253 of file lua_common.hpp.

◆ return_deprecated_attrib

#define return_deprecated_attrib (   type_macro,
  name,
  accessor,
  prefix,
  level,
  version,
  msg 
)
Value:
type_macro(name, ( \
deprecate_attrib(name, prefix, level, version, msg), \
accessor \
))
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:110
#define deprecate_attrib(name, prefix, level, version, msg)
Definition: lua_common.hpp:228

Definition at line 230 of file lua_common.hpp.

◆ return_float_attrib

#define return_float_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
lua_pushnumber(L, (accessor)); \
return 1; \
} \
} while(false)

Definition at line 277 of file lua_common.hpp.

Referenced by impl_music_get(), impl_side_get(), and impl_unit_attack_get().

◆ return_float_attrib_deprecated

#define return_float_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_deprecated_attrib(return_float_attrib, name, accessor, prefix, level, version, msg)

Definition at line 284 of file lua_common.hpp.

◆ return_int_attrib

#define return_int_attrib (   name,
  accessor 
)

◆ return_int_attrib_deprecated

#define return_int_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_deprecated_attrib(return_int_attrib, name, accessor, prefix, level, version, msg)

Definition at line 274 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_game_config_get().

◆ return_string_attrib

#define return_string_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
const std::string& str = (accessor); \
lua_pushlstring(L, str.c_str(), str.length()); \
return 1; \
} \
} while(false)

Definition at line 256 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_current_get(), impl_end_level_data_get(), game_lua_kernel::impl_game_config_get(), impl_mp_settings_get(), impl_race_get(), game_lua_kernel::impl_scenario_get(), game_lua_kernel::impl_schedule_get(), impl_side_get(), impl_source_get(), impl_terrainmap_get(), impl_track_get(), impl_unit_attack_get(), impl_unit_type_get(), and impl_version_get().

◆ return_string_attrib_deprecated

#define return_string_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_deprecated_attrib(return_string_attrib, name, accessor, prefix, level, version, msg)

◆ return_tstring_attrib

#define return_tstring_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
luaW_pushtstring(L, (accessor)); \
return 1; \
} \
} while(false)

Definition at line 236 of file lua_common.hpp.

Referenced by impl_race_get(), game_lua_kernel::impl_scenario_get(), impl_side_get(), and impl_unit_type_get().

◆ return_tstring_attrib_deprecated

#define return_tstring_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_deprecated_attrib(return_tstring_attrib, name, accessor, prefix, level, version, msg)

Definition at line 243 of file lua_common.hpp.

◆ return_vector_string_attrib

#define return_vector_string_attrib (   name,
  accessor 
)
Value:
do { \
if (strcmp(m, (name)) == 0) { \
const std::vector<std::string>& vector = (accessor); \
lua_createtable(L, vector.size(), 0); \
int i = 1; \
for (const std::string& s : vector) { \
lua_pushlstring(L, s.c_str(), s.length()); \
lua_rawseti(L, -2, i); \
++i; \
} \
return 1; \
} \
} while(false)
std::size_t i
Definition: function.cpp:967
static map_location::DIRECTION s

Definition at line 319 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_scenario_get(), impl_source_get(), and impl_unit_type_get().

◆ return_vector_string_attrib_deprecated

#define return_vector_string_attrib_deprecated (   name,
  prefix,
  level,
  version,
  msg,
  accessor 
)    return_deprecated_attrib(return_vector_string_attrib, name, accessor, prefix, level, version, msg)

Definition at line 333 of file lua_common.hpp.

Referenced by game_lua_kernel::impl_game_config_get().

Function Documentation

◆ chat_message()

void chat_message ( const std::string &  caption,
const std::string &  msg 
)

◆ luaW_check_locationset()

std::set<map_location> luaW_check_locationset ( lua_State *  L,
int  idx 
)

◆ luaW_checkconfig() [1/2]

config luaW_checkconfig ( lua_State *  L,
int  index 
)

◆ luaW_checkconfig() [2/2]

config luaW_checkconfig ( lua_State *  L,
int  index,
const vconfig *&  vcfg 
)

Like the two-argument version, but if it was a vconfig, also returns a pointer to that vconfig.

Definition at line 908 of file lua_common.cpp.

References luaW_checkconfig(), p, and vconfigKey.

◆ luaW_checklocation()

map_location luaW_checklocation ( lua_State *  L,
int  index 
)

◆ luaW_checktstring()

t_string luaW_checktstring ( lua_State *  L,
int  index 
)

◆ luaW_checkvariable()

bool luaW_checkvariable ( lua_State *  L,
variable_access_create v,
int  n 
)

◆ luaW_checkvconfig()

vconfig luaW_checkvconfig ( lua_State *  L,
int  index,
bool  allow_missing = false 
)

◆ luaW_filltable()

void luaW_filltable ( lua_State *  L,
const config cfg 
)

Converts a config object to a Lua table.

The destination table should be at the top of the stack on entry. It is still at the top on exit.

Definition at line 645 of file lua_common.cpp.

References config::all_children_range(), config::attribute_range(), luaW_filltable(), luaW_push_namedtuple(), and luaW_pushscalar().

Referenced by luaW_filltable(), luaW_pushconfig(), and luaW_pushvariable().

◆ luaW_getglobal() [1/2]

bool luaW_getglobal ( lua_State *  L,
const std::vector< std::string > &  path 
)

◆ luaW_getglobal() [2/2]

template<typename... T>
bool luaW_getglobal ( lua_State *  L,
T...  path 
)

Pushes the value found by following the variadic names (char *), if the value is not nil.

Returns
true if an element was pushed.

Definition at line 190 of file lua_common.hpp.

References chat_message(), utf8::index(), luaW_checkvariable(), luaW_getglobal(), luaW_pcall(), luaW_pcall_internal(), luaW_pushvariable(), luaW_tableget(), luaW_toboolean(), luaW_tostring(), luaW_tostring_or_default(), luaW_type_error(), wfl::msg(), n, game_config::path, and push_error_handler().

◆ luaW_getmetafield()

bool luaW_getmetafield ( lua_State *  L,
int  idx,
const char *  key 
)

Like luaL_getmetafield, but returns false if key is an empty string or begins with two underscores.

Definition at line 515 of file lua_common.cpp.

References n.

Referenced by impl_animator_get(), impl_floating_label_getmethod(), impl_music_get(), impl_source_get(), impl_track_get(), and impl_unit_attack_get().

◆ luaW_iststring()

bool luaW_iststring ( lua_State *  L,
int  index 
)

Definition at line 634 of file lua_common.cpp.

References tstringKey.

Referenced by game_lua_kernel::intf_allow_end_turn(), and lua_stringx::intf_str_format().

◆ luaW_pcall()

bool luaW_pcall ( lua_State *  L,
int  nArgs,
int  nRets,
bool  allow_wml_error = false 
)

◆ luaW_pcall_internal()

int luaW_pcall_internal ( lua_State *  L,
int  nArgs,
int  nRets 
)

◆ luaW_push_locationset()

int luaW_push_locationset ( lua_State *  L,
const std::set< map_location > &  locs 
)

Converts a set of map locations to a Lua table pushed at the top of the stack.

Definition at line 782 of file lua_common.cpp.

References i, and luaW_pushlocation().

Referenced by ai::cfun_ai_get_avoid(), game_lua_kernel::impl_schedule_get(), game_lua_kernel::intf_get_locations(), intf_mg_get_locations_part2(), intf_mg_get_tiles_radius(), and intf_parse_shroud_bitmap().

◆ luaW_push_namedtuple()

void luaW_push_namedtuple ( lua_State *  L,
const std::vector< std::string > &  names 
)

Push an empty "named tuple" onto the stack.

A named tuple is an array where each index can also be accessed by name. Once it's pushed, you can set the elements, eg with lua_rawseti.

Definition at line 697 of file lua_common.cpp.

References impl_namedtuple_get(), impl_namedtuple_tostring(), and lua_push().

Referenced by game_lua_kernel::intf_find_cost_map(), game_lua_kernel::intf_find_reach(), game_lua_kernel::intf_find_vision_range(), intf_named_tuple(), luaW_filltable(), and luaW_pushlocation().

◆ luaW_pushconfig()

void luaW_pushconfig ( lua_State *  L,
const config cfg 
)

◆ luaW_pushlocation()

void luaW_pushlocation ( lua_State *  L,
const map_location loc 
)

◆ luaW_pushscalar()

void luaW_pushscalar ( lua_State *  L,
const config::attribute_value v 
)

Converts an attribute value into a Lua object pushed at the top of the stack.

Definition at line 569 of file lua_common.cpp.

References config_attribute_value::apply_visitor().

Referenced by impl_preferences_get(), lua_common::impl_vconfig_get(), lua_common::impl_vconfig_pairs_iter(), luaW_filltable(), and luaW_pushvariable().

◆ luaW_pushtstring()

void luaW_pushtstring ( lua_State *  L,
const t_string v 
)

◆ luaW_pushvariable()

bool luaW_pushvariable ( lua_State *  L,
variable_access_const v 
)

◆ luaW_pushvconfig()

void luaW_pushvconfig ( lua_State *  L,
const vconfig cfg 
)

◆ luaW_tableget()

bool luaW_tableget ( lua_State *  L,
int  index,
const char *  key 
)

◆ luaW_toboolean()

bool luaW_toboolean ( lua_State *  L,
int  n 
)

◆ luaW_toconfig()

bool luaW_toconfig ( lua_State *  L,
int  index,
config cfg 
)

Converts an optional table or vconfig to a config object.

Parameters
Lthe pointer to the lua interpreter.
indexstack position of the table.
cfgthe config to write the data to.
Returns
false if some attributes had not the proper type.
Note
If the table has holes in the integer keys or floating-point keys, some keys will be ignored and the error will go undetected.

Definition at line 823 of file lua_common.cpp.

References config::add_child(), i, luaW_toconfig(), luaW_toscalar(), return_misformed, config_attribute_value::str(), config::valid_attribute(), config::valid_tag(), and vconfigKey.

Referenced by mapgen_lua_kernel::create_scenario(), ai::lua_ai_context::get_arguments(), ai::lua_ai_context::get_persistent_data(), impl_context_accessor(), impl_music_set(), impl_sndsrc_set(), game_lua_kernel::intf_log_replay(), intf_modify_ai_old(), game_lua_kernel::intf_scroll(), game_lua_kernel::intf_skip_messages(), lua_wml::intf_wml_valid(), luaW_checkconfig(), luaW_checkvariable(), luaW_toconfig(), luaW_tovconfig(), game_lua_kernel::save_game(), lua_gui2::show_message_dialog(), and ai::lua_object< T >::to_type().

◆ luaW_tolocation()

bool luaW_tolocation ( lua_State *  L,
int  index,
map_location loc 
)

Converts an optional table or pair of integers to a map location object.

Parameters
Lthe pointer to the lua interpreter.
indexstack position of the table or first integer.
locthe location to write to.
Returns
false if a map location couldn't be matched.

Definition at line 725 of file lua_common.cpp.

References map_location::set_wml_x(), map_location::set_wml_y(), and vconfig::unconstructed_vconfig().

Referenced by ai::ai_recall(), ai::ai_recruit(), impl_add_animation(), impl_source_set(), impl_terrainmap_get(), impl_terrainmap_set(), lua_map_location::intf_distance_between(), game_lua_kernel::intf_erase_unit(), game_lua_kernel::intf_fire_event(), lua_map_location::intf_get_adjacent_tiles(), lua_map_location::intf_get_direction(), lua_map_location::intf_get_in_basis_N_NE(), lua_map_location::intf_get_relative_dir(), lua_map_location::intf_get_tiles_in_radius(), game_lua_kernel::intf_get_time_area(), game_lua_kernel::intf_get_time_of_day(), game_lua_kernel::intf_get_unit(), game_lua_kernel::intf_get_units(), game_lua_kernel::intf_match_unit(), game_lua_kernel::intf_put_unit(), lua_map_location::intf_rotate_right_around_center(), lua_map_location::intf_tiles_adjacent(), intf_unit_defense(), intf_unit_jamming_cost(), intf_unit_movement_cost(), intf_unit_vision_cost(), lua_map_location::intf_vector_diff(), lua_map_location::intf_vector_negation(), lua_map_location::intf_vector_sum(), load_fake_units(), lua_check_impl::lua_to_or_default(), luaW_checklocation(), luaW_to_locationset(), and luaW_tofaivariant().

◆ luaW_toscalar()

bool luaW_toscalar ( lua_State *  L,
int  index,
config::attribute_value v 
)

Converts the value at the top of the stack to an attribute value.

Definition at line 574 of file lua_common.cpp.

References luaW_toboolean(), and tstringKey.

Referenced by impl_preferences_set(), and luaW_toconfig().

◆ luaW_tostring()

std::string_view luaW_tostring ( lua_State *  L,
int  index 
)

◆ luaW_tostring_or_default()

std::string_view luaW_tostring_or_default ( lua_State *  L,
int  index,
std::string_view  def = std::string_view() 
)

Definition at line 1069 of file lua_common.cpp.

Referenced by lua_check_impl::lua_to_or_default(), and luaW_getglobal().

◆ luaW_totstring()

bool luaW_totstring ( lua_State *  L,
int  index,
t_string str 
)

◆ luaW_tovconfig()

bool luaW_tovconfig ( lua_State *  L,
int  index,
vconfig vcfg 
)

Gets an optional vconfig from either a table or a userdata.

Returns
false in case of failure.

Definition at line 917 of file lua_common.cpp.

References luaW_toconfig(), and vconfigKey.

Referenced by game_lua_kernel::intf_add_time_area(), game_lua_kernel::intf_find_cost_map(), luaW_checkvconfig(), luaW_tofaivariant(), and ai::lua_object< T >::to_type().

◆ luaW_type_error() [1/2]

int luaW_type_error ( lua_State *  L,
int  narg,
const char *  tname 
)

◆ luaW_type_error() [2/2]

int luaW_type_error ( lua_State *  L,
int  narg,
const char *  kpath,
const char *  tname 
)

Definition at line 1165 of file lua_common.cpp.

References wfl::msg().

◆ operator delete()

void operator delete ( void *  p,
lua_State *  L,
int  nuv 
)

Definition at line 507 of file lua_common.cpp.

◆ operator new()

void* operator new ( std::size_t  sz,
lua_State *  L,
int  nuv = 0 
)

Definition at line 502 of file lua_common.cpp.

◆ push_error_handler()

void push_error_handler ( lua_State *  L)

Definition at line 1086 of file lua_common.cpp.

References executeKey, and luaW_getglobal().

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