The Battle for Wesnoth  1.19.5+dev
Typedefs | Functions
lua_common Namespace Reference

Typedefs

typedef std::pair< vconfig::all_children_iterator, vconfig::all_children_iteratorvconfig_child_range
 

Functions

static int impl_gettext (lua_State *L)
 Creates a t_string object (__call metamethod). More...
 
static int impl_gettext_tostr (lua_State *L)
 
int intf_textdomain (lua_State *L)
 Creates an interface for gettext. More...
 
static void tstring_concat_aux (lua_State *L, t_string &dst, int src)
 Converts a Lua value at position src and appends it to dst. More...
 
static int impl_tstring_concat (lua_State *L)
 Appends a scalar to a t_string object (__concat metamethod). More...
 
static int impl_tstring_len (lua_State *L)
 
static int impl_tstring_collect (lua_State *L)
 Destroys a t_string object before it is collected (__gc metamethod). More...
 
static int impl_tstring_lt (lua_State *L)
 
static int impl_tstring_le (lua_State *L)
 
static int impl_tstring_eq (lua_State *L)
 
static int impl_tstring_tostring (lua_State *L)
 Converts a t_string object to a string (__tostring metamethod); that is, performs a translation. More...
 
static int impl_vconfig_get (lua_State *L)
 Gets the parsed field of a vconfig object (_index metamethod). More...
 
static int impl_vconfig_dir (lua_State *L)
 
static int impl_vconfig_size (lua_State *L)
 Returns the number of a child of a vconfig object. More...
 
static int impl_vconfig_collect (lua_State *L)
 Destroys a vconfig object before it is collected (__gc metamethod). More...
 
static int impl_vconfig_pairs_iter (lua_State *L)
 Iterate through the attributes of a vconfig. More...
 
static int impl_vconfig_pairs_collect (lua_State *L)
 Destroy a vconfig pairs iterator. More...
 
static int impl_vconfig_pairs (lua_State *L)
 Construct an iterator to iterate through the attributes of a vconfig. More...
 
static int impl_vconfig_ipairs_iter (lua_State *L)
 Iterate through the subtags of a vconfig. More...
 
static int impl_vconfig_ipairs_collect (lua_State *L)
 Destroy a vconfig ipairs iterator. More...
 
static int impl_vconfig_ipairs (lua_State *L)
 Construct an iterator to iterate through the subtags of a vconfig. More...
 
int intf_tovconfig (lua_State *L)
 Creates a vconfig containing the WML table. More...
 
std::string register_gettext_metatable (lua_State *L)
 Adds the gettext metatable. More...
 
std::string register_tstring_metatable (lua_State *L)
 Adds the tstring metatable. More...
 
std::string register_vconfig_metatable (lua_State *L)
 Adds the vconfig metatable. More...
 

Typedef Documentation

◆ vconfig_child_range

Definition at line 356 of file lua_common.cpp.

Function Documentation

◆ impl_gettext()

static int lua_common::impl_gettext ( lua_State *  L)
static

Creates a t_string object (__call metamethod).

  • Arg 1: userdata containing the domain.
  • Arg 2: string to translate.
  • Ret 1: string containing the translatable string.

Definition at line 64 of file lua_common.cpp.

References d, and luaW_pushtstring().

Referenced by register_gettext_metatable().

◆ impl_gettext_tostr()

static int lua_common::impl_gettext_tostr ( lua_State *  L)
static

Definition at line 79 of file lua_common.cpp.

References d, lua_push(), and s.

Referenced by register_gettext_metatable().

◆ impl_tstring_collect()

static int lua_common::impl_tstring_collect ( lua_State *  L)
static

Destroys a t_string object before it is collected (__gc metamethod).

Definition at line 157 of file lua_common.cpp.

References t.

Referenced by register_tstring_metatable().

◆ impl_tstring_concat()

static int lua_common::impl_tstring_concat ( lua_State *  L)
static

Appends a scalar to a t_string object (__concat metamethod).

Definition at line 134 of file lua_common.cpp.

References t, tstring_concat_aux(), and tstringKey.

Referenced by register_tstring_metatable().

◆ impl_tstring_eq()

static int lua_common::impl_tstring_eq ( lua_State *  L)
static

Definition at line 180 of file lua_common.cpp.

References translation::compare(), and t_string::get().

Referenced by register_tstring_metatable().

◆ impl_tstring_le()

static int lua_common::impl_tstring_le ( lua_State *  L)
static

Definition at line 172 of file lua_common.cpp.

References translation::compare(), t_string::get(), and tstringKey.

Referenced by register_tstring_metatable().

◆ impl_tstring_len()

static int lua_common::impl_tstring_len ( lua_State *  L)
static

Definition at line 147 of file lua_common.cpp.

References t.

Referenced by register_tstring_metatable().

◆ impl_tstring_lt()

static int lua_common::impl_tstring_lt ( lua_State *  L)
static

Definition at line 164 of file lua_common.cpp.

References translation::compare(), t_string::get(), and tstringKey.

Referenced by register_tstring_metatable().

◆ impl_tstring_tostring()

static int lua_common::impl_tstring_tostring ( lua_State *  L)
static

Converts a t_string object to a string (__tostring metamethod); that is, performs a translation.

Definition at line 192 of file lua_common.cpp.

References t.

Referenced by register_tstring_metatable().

◆ impl_vconfig_collect()

static int lua_common::impl_vconfig_collect ( lua_State *  L)
static

Destroys a vconfig object before it is collected (__gc metamethod).

Definition at line 293 of file lua_common.cpp.

References vconfig::~vconfig().

Referenced by register_vconfig_metatable().

◆ impl_vconfig_dir()

static int lua_common::impl_vconfig_dir ( lua_State *  L)
static

Definition at line 268 of file lua_common.cpp.

References config::attribute_range(), vconfig::get_config(), and lua_push().

Referenced by register_vconfig_metatable().

◆ impl_vconfig_get()

static int lua_common::impl_vconfig_get ( lua_State *  L)
static

Gets the parsed field of a vconfig object (_index metamethod).

Special fields __literal, __shallow_literal, __parsed, and __shallow_parsed, return Lua tables.

Definition at line 204 of file lua_common.cpp.

References config::attribute_range(), vconfig::expand(), vconfig::get_config(), vconfig::get_parsed_config(), vconfig::has_attribute(), i, luaW_push_namedtuple(), luaW_pushconfig(), luaW_pushscalar(), luaW_pushvconfig(), vconfig::null(), vconfig::ordered_begin(), and vconfig::ordered_end().

Referenced by register_vconfig_metatable().

◆ impl_vconfig_ipairs()

static int lua_common::impl_vconfig_ipairs ( lua_State *  L)
static

Construct an iterator to iterate through the subtags of a vconfig.

Definition at line 394 of file lua_common.cpp.

References impl_vconfig_ipairs_iter(), luaW_checkvconfig(), vconfig::ordered_begin(), vconfig::ordered_end(), and vconfigipairsKey.

Referenced by register_vconfig_metatable().

◆ impl_vconfig_ipairs_collect()

static int lua_common::impl_vconfig_ipairs_collect ( lua_State *  L)
static

Destroy a vconfig ipairs iterator.

Definition at line 383 of file lua_common.cpp.

References p.

Referenced by register_vconfig_metatable().

◆ impl_vconfig_ipairs_iter()

static int lua_common::impl_vconfig_ipairs_iter ( lua_State *  L)
static

Iterate through the subtags of a vconfig.

Definition at line 361 of file lua_common.cpp.

References i, luaW_checkvconfig(), luaW_pushvconfig(), p, and vconfigipairsKey.

Referenced by impl_vconfig_ipairs().

◆ impl_vconfig_pairs()

static int lua_common::impl_vconfig_pairs ( lua_State *  L)
static

Construct an iterator to iterate through the attributes of a vconfig.

Definition at line 345 of file lua_common.cpp.

References config::attribute_range(), vconfig::get_config(), impl_vconfig_pairs_iter(), luaW_checkvconfig(), and vconfigpairsKey.

Referenced by register_vconfig_metatable().

◆ impl_vconfig_pairs_collect()

static int lua_common::impl_vconfig_pairs_collect ( lua_State *  L)
static

Destroy a vconfig pairs iterator.

Definition at line 321 of file lua_common.cpp.

References p.

Referenced by register_vconfig_metatable().

◆ impl_vconfig_pairs_iter()

static int lua_common::impl_vconfig_pairs_iter ( lua_State *  L)
static

Iterate through the attributes of a vconfig.

Definition at line 303 of file lua_common.cpp.

References luaW_checkvconfig(), luaW_pushscalar(), p, and vconfigpairsKey.

Referenced by impl_vconfig_pairs().

◆ impl_vconfig_size()

static int lua_common::impl_vconfig_size ( lua_State *  L)
static

Returns the number of a child of a vconfig object.

Definition at line 282 of file lua_common.cpp.

References vconfig::null(), vconfig::ordered_begin(), and vconfig::ordered_end().

Referenced by register_vconfig_metatable().

◆ intf_textdomain()

int lua_common::intf_textdomain ( lua_State *  L)

Creates an interface for gettext.

  • Arg 1: string containing the domain.
  • Ret 1: a full userdata with __call pointing to lua_gettext.

Definition at line 93 of file lua_common.cpp.

References gettextKey, and p.

Referenced by lua_kernel_base::lua_kernel_base().

◆ intf_tovconfig()

int lua_common::intf_tovconfig ( lua_State *  L)

Creates a vconfig containing the WML table.

  • Arg 1: WML table.
  • Ret 1: vconfig userdata.

Definition at line 411 of file lua_common.cpp.

References luaW_checkvconfig(), and luaW_pushvconfig().

Referenced by game_lua_kernel::game_lua_kernel(), and mapgen_lua_kernel::mapgen_lua_kernel().

◆ register_gettext_metatable()

std::string lua_common::register_gettext_metatable ( lua_State *  L)

Adds the gettext metatable.

Definition at line 421 of file lua_common.cpp.

References gettextKey, impl_gettext(), and impl_gettext_tostr().

Referenced by lua_kernel_base::lua_kernel_base().

◆ register_tstring_metatable()

std::string lua_common::register_tstring_metatable ( lua_State *  L)

◆ register_vconfig_metatable()

std::string lua_common::register_vconfig_metatable ( lua_State *  L)

◆ tstring_concat_aux()

static void lua_common::tstring_concat_aux ( lua_State *  L,
t_string dst,
int  src 
)
static

Converts a Lua value at position src and appends it to dst.

Note
This function is private to lua_tstring_concat. It expects two things. First, the t_string metatable is at the top of the stack on entry. (It is still there on exit.) Second, the caller hasn't any valuable object with dynamic lifetime, since they would be leaked on error.

Definition at line 112 of file lua_common.cpp.

References dst, luaW_type_error(), src, and tstringKey.

Referenced by impl_tstring_concat().