The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Typedefs | Functions
lua_common Namespace Reference

Typedefs

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

Functions

static int impl_gettext (lua_State *L)
 Creates a t_string object (__call metamethod). More...
 
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_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

Definition at line 324 of file lua_common.cpp.

Function Documentation

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 preferences::editor::TransitionUpdateMode::count, d, lua_isstring(), lua_touserdata(), luaL_checkinteger(), luaL_checkstring, and luaW_pushtstring().

Referenced by register_gettext_metatable().

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 148 of file lua_common.cpp.

References lua_touserdata(), and t.

Referenced by register_tstring_metatable().

static int lua_common::impl_tstring_concat ( lua_State L)
static

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

Definition at line 125 of file lua_common.cpp.

References luaL_setmetatable(), t, tstring_concat_aux(), and tstringKey.

Referenced by register_tstring_metatable().

static int lua_common::impl_tstring_eq ( lua_State L)
static
static int lua_common::impl_tstring_le ( lua_State L)
static
static int lua_common::impl_tstring_len ( lua_State L)
static

Definition at line 138 of file lua_common.cpp.

References lua_pushnumber(), lua_touserdata(), t_string::size(), and t.

Referenced by register_tstring_metatable().

static int lua_common::impl_tstring_lt ( lua_State L)
static
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 183 of file lua_common.cpp.

References t_string::c_str(), lua_pushstring(), lua_touserdata(), and t.

Referenced by register_tstring_metatable().

static int lua_common::impl_vconfig_collect ( lua_State L)
static

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

Definition at line 273 of file lua_common.cpp.

References lua_touserdata(), and vconfig::~vconfig().

Referenced by register_vconfig_metatable().

static int lua_common::impl_vconfig_get ( lua_State L)
static
static int lua_common::impl_vconfig_ipairs ( lua_State L)
static
static int lua_common::impl_vconfig_ipairs_collect ( lua_State L)
static

Destroy a vconfig ipairs iterator.

Definition at line 351 of file lua_common.cpp.

References lua_touserdata(), and p.

Referenced by register_vconfig_metatable().

static int lua_common::impl_vconfig_ipairs_iter ( lua_State L)
static
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 313 of file lua_common.cpp.

References config::attribute_range(), vconfig::get_config(), impl_vconfig_pairs_iter(), lua_pushcclosure(), lua_pushvalue(), lua_setmetatable(), luaL_newmetatable(), luaW_checkvconfig(), and vconfigpairsKey.

Referenced by register_vconfig_metatable().

static int lua_common::impl_vconfig_pairs_collect ( lua_State L)
static

Destroy a vconfig pairs iterator.

Definition at line 301 of file lua_common.cpp.

References lua_touserdata(), and p.

Referenced by register_vconfig_metatable().

static int lua_common::impl_vconfig_pairs_iter ( lua_State L)
static

Iterate through the attributes of a vconfig.

Definition at line 283 of file lua_common.cpp.

References lua_pushlstring(), lua_upvalueindex, luaL_checkudata(), luaW_checkvconfig(), luaW_pushscalar(), p, and vconfigpairsKey.

Referenced by impl_vconfig_pairs().

static int lua_common::impl_vconfig_size ( lua_State L)
static

Returns the number of a child of a vconfig object.

Definition at line 262 of file lua_common.cpp.

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

Referenced by register_vconfig_metatable().

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 84 of file lua_common.cpp.

References gettextKey, lua_newuserdata(), luaL_checklstring(), luaL_setmetatable(), and p.

Referenced by lua_kernel_base::lua_kernel_base().

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 379 of file lua_common.cpp.

References luaW_checkvconfig(), and luaW_pushvconfig().

Referenced by lua_kernel_base::lua_kernel_base().

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

Adds the gettext metatable.

Definition at line 389 of file lua_common.cpp.

References gettextKey, impl_gettext(), lua_pushstring(), lua_setfield(), luaL_newmetatable(), and luaL_setfuncs().

Referenced by lua_kernel_base::lua_kernel_base().

std::string lua_common::register_tstring_metatable ( lua_State L)
std::string lua_common::register_vconfig_metatable ( lua_State L)
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 103 of file lua_common.cpp.

References LUA_TNUMBER, lua_tostring, LUA_TSTRING, LUA_TUSERDATA, lua_type(), luaL_testudata(), luaW_type_error(), and tstringKey.

Referenced by impl_tstring_concat().