aboutsummaryrefslogblamecommitdiff
path: root/nerv.lua
blob: 33b1affe8ccaeebc3943181932983f8a4f96a4c7 (plain) (tree)
1
2
3
4
5
6
7
                 
                     
                                  


                               
                                                                         




                                          
























                                                                              
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 .. "\n", ...))
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