blob: 8e03cb28f50e6d1a11bddec311f5e7840dbf8b1f (
plain) (
tree)
|
|
require 'libnerv'
require 'matrix.init'
-- nerv.class = require 'pl.class'
nerv.utils = require 'pl.utils'
function nerv.error(fmt, ...)
error(nerv.utils.printf("Nerv internal error: " .. fmt, ...))
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
|