From 7dadb31a364c3dbe30c05c9a9040c48f1d4a9095 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 25 May 2015 16:20:50 +0800 Subject: add comments to nerv.c --- nerv.c | 10 ++++++++++ nerv.lua | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/nerv.c b/nerv.c index d586867..0bc661e 100644 --- a/nerv.c +++ b/nerv.c @@ -17,8 +17,18 @@ void nerv_utils_init(lua_State *L) { int luaopen_libnerv(lua_State *L) { lua_newtable(L); + /* duplicate table */ lua_pushvalue(L, -1); + /* set table to global index */ lua_setfield(L, LUA_GLOBALSINDEX, "nerv"); + /* A table reference still remains. + * + * The following initialization functions should obey to the rule that they + * maintain the stack properly to guarantee the stack stays the same before + * and after invoking the call (i.e. stay balanced). + * + * Also note that they can make use of the value at top of the stack which + * references to the `nerv` global table. */ nerv_utils_init(L); nerv_point_init(L); nerv_matrix_init(L); diff --git a/nerv.lua b/nerv.lua index 1c4ba39..d7f7e91 100644 --- a/nerv.lua +++ b/nerv.lua @@ -1,7 +1,6 @@ require 'libnerv' require 'matrix.init' require 'io.init' --- nerv.class = require 'pl.class' nerv.utils = require 'pl.utils' function nerv.error(fmt, ...) @@ -12,6 +11,7 @@ function nerv.error_method_not_implement() nerv.error("method not implemented"); end +-- Torch C API wrapper function nerv.class(tname, parenttname) local function constructor(...) -- cgit v1.2.3-70-g09d2