summaryrefslogtreecommitdiff
path: root/nerv.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nerv.lua')
-rw-r--r--nerv.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/nerv.lua b/nerv.lua
index ccff0a0..8e03cb2 100644
--- a/nerv.lua
+++ b/nerv.lua
@@ -1,6 +1,6 @@
require 'libnerv'
require 'matrix.init'
-nerv.class = require 'pl.class'
+-- nerv.class = require 'pl.class'
nerv.utils = require 'pl.utils'
function nerv.error(fmt, ...)
@@ -10,3 +10,28 @@ end
function nerv.error_method_not_implement()
nerv.error("method not implemented");
end
+
+function nerv.class(tname, parenttname)
+
+ local function constructor(...)
+ local self = {}
+ nerv.setmetatable(self, tname)
+ if self.__init then
+ self:__init(...)
+ end
+ return self
+ end
+
+ local function factory()
+ local self = {}
+ nerv.setmetatable(self, tname)
+ return self
+ end
+
+ local mt = nerv.newmetatable(tname, parenttname, constructor, nil, factory)
+ local mpt
+ if parenttname then
+ mpt = nerv.getmetatable(parenttname)
+ end
+ return mt, mpt
+end