-/**
- * \brief Ensures that a value in the stack is a host and returns it.
- *
- * This function is called from C and helps to verify that a specific
- * userdatum on the stack is in fact a sg_host_t.
+/** @brief Ensures that the pointed stack value is an host userdatum and returns it.
luaL_checktype(L, index, LUA_TTABLE);
lua_getfield(L, index, HOST_FIELDNAME);
luaL_checktype(L, index, LUA_TTABLE);
lua_getfield(L, index, HOST_FIELDNAME);
static int l_host_get_by_name(lua_State * L)
{
const char *name = luaL_checkstring(L, 1);
static int l_host_get_by_name(lua_State * L)
{
const char *name = luaL_checkstring(L, 1);
lua_newtable(L); /* table */
sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t)); /* table userdatum */
*lua_host = host;
luaL_getmetatable(L, HOST_MODULE_NAME); /* table userdatum metatable */
lua_setmetatable(L, -2); /* table userdatum */
lua_newtable(L); /* table */
sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t)); /* table userdatum */
*lua_host = host;
luaL_getmetatable(L, HOST_MODULE_NAME); /* table userdatum metatable */
lua_setmetatable(L, -2); /* table userdatum */