From 39e1834c449a55a44e95f2cfb6b24887fd3cec70 Mon Sep 17 00:00:00 2001 From: Determinant Date: Sun, 24 May 2015 19:02:09 +0800 Subject: add nerv.class and try to let Lua class inherit from ParamFile --- nerv.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'nerv.c') diff --git a/nerv.c b/nerv.c index 55ae5b6..d586867 100644 --- a/nerv.c +++ b/nerv.c @@ -1,14 +1,25 @@ -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" +#include "common.h" extern void nerv_point_init(lua_State *L); extern void nerv_matrix_init(lua_State *L); extern void nerv_param_init(lua_State *L); +static const luaL_Reg nerv_utils_methods[] = { + {"setmetatable", luaT_lua_setmetatable}, + {"getmetatable", luaT_lua_getmetatable}, + {"newmetatable", luaT_lua_newmetatable}, + {NULL, NULL} +}; + +void nerv_utils_init(lua_State *L) { + luaL_register(L, NULL, nerv_utils_methods); +} + int luaopen_libnerv(lua_State *L) { lua_newtable(L); + lua_pushvalue(L, -1); lua_setfield(L, LUA_GLOBALSINDEX, "nerv"); + nerv_utils_init(L); nerv_point_init(L); nerv_matrix_init(L); nerv_param_init(L); -- cgit v1.2.3