diff --git a/src/hlua.c b/src/hlua.c index 2ea15b995..2ad52d14c 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -8607,6 +8607,11 @@ __LJMP static int hlua_register_init(lua_State *L) MAY_LJMP(check_args(L, 1, "register_init")); + if (hlua_gethlua(L)) { + /* runtime processing */ + WILL_LJMP(luaL_error(L, "register_init: not available outside of body context")); + } + ref = MAY_LJMP(hlua_checkfunction(L, 1)); init = calloc(1, sizeof(*init)); @@ -8974,6 +8979,11 @@ __LJMP static int hlua_register_converters(lua_State *L) MAY_LJMP(check_args(L, 2, "register_converters")); + if (hlua_gethlua(L)) { + /* runtime processing */ + WILL_LJMP(luaL_error(L, "register_converters: not available outside of body context")); + } + /* First argument : converter name. */ name = MAY_LJMP(luaL_checkstring(L, 1)); @@ -9053,6 +9063,11 @@ __LJMP static int hlua_register_fetches(lua_State *L) MAY_LJMP(check_args(L, 2, "register_fetches")); + if (hlua_gethlua(L)) { + /* runtime processing */ + WILL_LJMP(luaL_error(L, "register_fetches: not available outside of body context")); + } + /* First argument : sample-fetch name. */ name = MAY_LJMP(luaL_checkstring(L, 1)); @@ -9894,6 +9909,11 @@ __LJMP static int hlua_register_action(lua_State *L) if (lua_gettop(L) < 3 || lua_gettop(L) > 4) WILL_LJMP(luaL_error(L, "'register_action' needs between 3 and 4 arguments")); + if (hlua_gethlua(L)) { + /* runtime processing */ + WILL_LJMP(luaL_error(L, "register_action: not available outside of body context")); + } + /* First argument : converter name. */ name = MAY_LJMP(luaL_checkstring(L, 1)); @@ -10060,6 +10080,11 @@ __LJMP static int hlua_register_service(lua_State *L) MAY_LJMP(check_args(L, 3, "register_service")); + if (hlua_gethlua(L)) { + /* runtime processing */ + WILL_LJMP(luaL_error(L, "register_service: not available outside of body context")); + } + /* First argument : converter name. */ name = MAY_LJMP(luaL_checkstring(L, 1)); @@ -10337,6 +10362,11 @@ __LJMP static int hlua_register_cli(lua_State *L) MAY_LJMP(check_args(L, 3, "register_cli")); + if (hlua_gethlua(L)) { + /* runtime processing */ + WILL_LJMP(luaL_error(L, "register_cli: not available outside of body context")); + } + /* First argument : an array of maximum 5 keywords. */ if (!lua_istable(L, 1)) WILL_LJMP(luaL_argerror(L, 1, "1st argument must be a table")); @@ -11154,6 +11184,11 @@ __LJMP static int hlua_register_filter(lua_State *L) MAY_LJMP(check_args(L, 3, "register_filter")); + if (hlua_gethlua(L)) { + /* runtime processing */ + WILL_LJMP(luaL_error(L, "register_filter: not available outside of body context")); + } + /* First argument : filter name. */ name = MAY_LJMP(luaL_checkstring(L, 1));