Lua API: Allow WML tags with leading underscore (#3877)
@gfgtdf said that it's more consistent to allow them across the board, which IMHO is a strong enough argument for the API change in master.
This commit is contained in:
parent
7d2e9383a3
commit
81d0d2214a
3 changed files with 10 additions and 3 deletions
|
@ -50,6 +50,7 @@
|
||||||
* wml.tostring() now outputs a string that can be parsed back to WML without loss of data.
|
* wml.tostring() now outputs a string that can be parsed back to WML without loss of data.
|
||||||
* Add wml.clone() function that performs a deep copy of a config or vconfig.
|
* Add wml.clone() function that performs a deep copy of a config or vconfig.
|
||||||
* Organize API functions into several new (sub)modules: gui, wesnoth.units, wesnoth.interface
|
* Organize API functions into several new (sub)modules: gui, wesnoth.units, wesnoth.interface
|
||||||
|
* Allow WML tag names injected with wml.tag to start with underscores.
|
||||||
### User Interface
|
### User Interface
|
||||||
* Don't show in the sidebar the time of day schedule of a shrouded hex. (issue #3638)
|
* Don't show in the sidebar the time of day schedule of a shrouded hex. (issue #3638)
|
||||||
### Packaging
|
### Packaging
|
||||||
|
|
|
@ -56,12 +56,18 @@
|
||||||
wml.tostring(table)
|
wml.tostring(table)
|
||||||
end))
|
end))
|
||||||
|
|
||||||
-- Tag names can't start with underscores.
|
-- Tag names can start with underscores.
|
||||||
assert_equal(false, pcall(function()
|
assert_equal(true, pcall(function()
|
||||||
local table = {T._reserved {}}
|
local table = {T._reserved {}}
|
||||||
wml.tostring(table)
|
wml.tostring(table)
|
||||||
end))
|
end))
|
||||||
|
|
||||||
|
-- An underscore by itself isn't allowed.
|
||||||
|
assert_equal(false, pcall(function()
|
||||||
|
local table = {T._ {}}
|
||||||
|
wml.tostring(table)
|
||||||
|
end))
|
||||||
|
|
||||||
-- Commit 13a4822d made the WML parser accept dollar signs in tag names.
|
-- Commit 13a4822d made the WML parser accept dollar signs in tag names.
|
||||||
-- However, they are supposed to be rejected, and this test enforces
|
-- However, they are supposed to be rejected, and this test enforces
|
||||||
-- that at least the Lua API rejects them.
|
-- that at least the Lua API rejects them.
|
||||||
|
|
|
@ -757,7 +757,7 @@ bool luaW_toconfig(lua_State *L, int index, config &cfg)
|
||||||
if (!lua_istable(L, -1)) return_misformed();
|
if (!lua_istable(L, -1)) return_misformed();
|
||||||
lua_rawgeti(L, -1, 1);
|
lua_rawgeti(L, -1, 1);
|
||||||
char const *m = lua_tostring(L, -1);
|
char const *m = lua_tostring(L, -1);
|
||||||
if (!m || !config::valid_tag(m) || m[0] == '_') return_misformed();
|
if (!m || !config::valid_tag(m)) return_misformed();
|
||||||
lua_rawgeti(L, -2, 2);
|
lua_rawgeti(L, -2, 2);
|
||||||
if (!luaW_toconfig(L, -1, cfg.add_child(m)))
|
if (!luaW_toconfig(L, -1, cfg.add_child(m)))
|
||||||
return_misformed();
|
return_misformed();
|
||||||
|
|
Loading…
Add table
Reference in a new issue