#include <windows.h>
#include "../uimodel.h"

// ----------------------------------------------------------------------------------
static const struct luaL_reg g_modelTable [] = {
	{NULL, NULL}
};

// ----------------------------------------------------------------------------------
void CUiLuaModel::OpenLib(lua_State* L)
{
	luaL_newmetatable(L, UI_LUA_TYPE_MODEL);			// create new metatable
	luaL_getmetatable(L, UI_LUA_TYPE_FRAME);			// inherit base table
	lua_setmetatable(L, -2);
	lua_pushstring(L, "__index");
	lua_pushvalue(L, -2);
	lua_settable(L, -3);
	luaL_openlib(L, NULL, g_modelTable, 0);
}

// ----------------------------------------------------------------------------------
int	CUiLuaModel::SetMetaTable(lua_State* L)
{
	if (lua_istable(L, -1))
	{
		luaL_getmetatable(L, UI_LUA_TYPE_MODEL);
		lua_setmetatable(L, -2);
		return 1;
	}
	return 0;
}