Commit graph

108 commits

Author SHA1 Message Date
Chris Beck
616d499c57 fixup 2486b8ba4b
That commit overlooked the tstring_concat_aux function in
lua_common.cpp, a helper function for tstring concatenation. This
caused lua errors when HttT was started, arising in the code to
display objectives.

This commit fixes up the tstring_concat_aux function to more
directly check the tstring type.

It also fixes luaW_totstring and luaW_toconfig so that they don't
immediately flag a type error if they fail to convert userdata to
a tstring... this was caused by inappropriately using
luaL_checkudata when luaL_testudata should be used.
2014-12-27 00:31:50 -05:00
Chris Beck
2486b8ba4b lua: refactor to use lua 5.2 syntax for custom metatables
In lua 5.0, the preferred way to define custom metatables is to
use registry keys defined by pushing pointers as lightuserdata to
lua. (These pointers can be pointers to arbitrary constant objects,
as long as they are unique.)

In lua 5.2, the preferred way is to use constant strings as the
registry indices, and several lua API functions are introduced:
"luaL_newmetatable, luaL_setmetatable, luaL_checkudata,
luaL_testudata" which greatly simplify the operations for creating
the metatable, assigning it to a userdata, and checking if the
userdata has that type.

This commit switches over the keys associated to textdomains,
translatable strings, vconfigs, and lua gui2 dialogs to use the
new style, and simplifies some of the implementation details in
the process. For instance, luaW_toconfig no longer has to have an
optional argument to an index on the stack where the tstring
metatable is... these details are handled by the lua API instead.
2014-12-25 23:58:00 -05:00
Chris Beck
0f9bd0a929 lua: move gettext metatable registration to lua_common 2014-12-25 14:11:12 -05:00
Chris Beck
93fe16a832 lua: move metatable registration for lua_common
this gives better encapsulation
2014-12-25 13:42:54 -05:00
Chris Beck
7e3b4aa1bf move config, vconfig, tstring and helper functions to lua_common
Probably lua_common should be split up further, it's a bit
crowded
2014-11-24 21:44:27 -05:00
Chris Beck
48a14ddadf move lua fcn 'wesnoth.tovconfig' to lua kernel base / lua common
there was no reason for it to only be in the game kernel, most
other vconfig functions were already in lua common.
2014-11-24 01:12:25 -05:00
Chris Beck
3b8e3b6d09 fix includes 2014-11-11 12:40:53 -05:00
Chris Beck
ca309d98b2 branch off "lua_common" functions from api defn file
This includes the gettext and vconfig impl functions, and many
macros used to write lua callbacks. This code can't properly go in
the lua_kernel_base files, so it goes here.
2014-11-09 18:45:14 -05:00