summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/nerv.md10
-rw-r--r--examples/cumatrix_example.lua1
2 files changed, 11 insertions, 0 deletions
diff --git a/doc/nerv.md b/doc/nerv.md
index 85a86ca..91bc8c9 100644
--- a/doc/nerv.md
+++ b/doc/nerv.md
@@ -1,5 +1,15 @@
#The Nerv utility functions#
Part of the [Nerv](../README.md) toolkit.
##Methods##
+* __string = nerv.typename(obj a)__
+A registered function, the original function is `luaT_lua_typename`. In some cases if you call `type(a)` for object of some class in __Nerv__(like __Nerv.CuMatrix__) it will only return "userdata"(because it is created in C), in this case you can use this method to get its type.
+
+---
+
+* __metatable = nerv.getmetatable(string tname)__
+A registered function, the original function is `luaT_lua_getmetatable`. `tname` should be a class name that has been registered in __luaT__.
+
+* __metatable = nerv.newmetatable(string tname, string parenttname, function constructor, function destructor, function factory)__
+A registered function, the original function is `luaT_newmetatable`, it returns the metatable of the created class by the name `tname`.
* __string = nerv.setmetatable(table self, string tname)__
A registered function, the original function is `luaT_lua_setmetatable`. It assigns the metatable registered in __luaT__ by the name *tname* to the table *self*. And return *tname* to user.
diff --git a/examples/cumatrix_example.lua b/examples/cumatrix_example.lua
index 544fc7f..ff9dd78 100644
--- a/examples/cumatrix_example.lua
+++ b/examples/cumatrix_example.lua
@@ -2,6 +2,7 @@ m = 4
n = 4
fm = nerv.CuMatrixFloat(m, n)
dm = nerv.CuMatrixDouble(m, n)
+print(type(dm), nerv.typename(dm))
for i = 0, m - 1 do
for j = 0, n - 1 do
-- local t = math.random(10)