luaaA: add luaA_unregister()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-11-10 17:26:24 +01:00
parent e9916d34b6
commit 4e37a6cde2
1 changed files with 12 additions and 1 deletions

13
luaa.h
View File

@ -262,7 +262,7 @@ luaA_usemetatable(lua_State *L, int idxobj, int idxfield)
/** Register an Lua object. /** Register an Lua object.
* \param L The Lua stack. * \param L The Lua stack.
* \param idx Index of the object in the stack. * \param idx Index of the object in the stack.
* \param fct A luaA_ref address: it will be filled with the luaA_ref * \param ref A luaA_ref address: it will be filled with the luaA_ref
* registered. If the adresse point to an already registered object, it will * registered. If the adresse point to an already registered object, it will
* be unregistered. * be unregistered.
* \return Always 0. * \return Always 0.
@ -277,6 +277,17 @@ luaA_register(lua_State *L, int idx, luaA_ref *ref)
return 0; return 0;
} }
/** Unregister a Lua object.
* \param L The Lua stack.
* \param ref A reference to an Lua object.
*/
static inline void
luaA_unregister(lua_State *L, luaA_ref *ref)
{
luaL_unref(L, LUA_REGISTRYINDEX, *ref);
*ref = LUA_REFNIL;
}
/** Register a function. /** Register a function.
* \param L The Lua stack. * \param L The Lua stack.
* \param idx Index of the function in the stack. * \param idx Index of the function in the stack.