tag: add compatibility with old constructor proto

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-02-06 11:55:09 +01:00
parent e0754de9cb
commit dd2c62721c
1 changed files with 13 additions and 1 deletions

14
tag.c
View File

@ -255,7 +255,19 @@ static int
luaA_tag_new(lua_State *L) luaA_tag_new(lua_State *L)
{ {
size_t len; size_t len;
const char *name = luaL_checklstring(L, 2, &len); const char *name;
if(lua_istable(L, 2))
{
/* deprecation warning */
luaA_warn(L, "%s: This function prototype changed, see API documentation",
__FUNCTION__);
lua_getfield(L, 2, "name");
name = luaL_checklstring(L, -1, &len);
}
else
name = luaL_checklstring(L, 2, &len);
return luaA_tag_userdata_new(L, tag_new(name, len)); return luaA_tag_userdata_new(L, tag_new(name, len));
} }