sdi_class.lua

Lua source files to HTML converted04/22/03 19:13:13

   1  -- SDI_HellCreator
   2  -- Salomatine Dmitry.
   3  -- sdihellcreator@bezeqint.net
   4  -- Israel
   5  -- original class.lua lua.org luausers.wiki
   6  -- revision ???
   7  -- start class lua definition
   8  function Class(members)
   9    members = members or {}
  10    local mt = {
  11      __metatable = members;
  12      __index     = members;
  13    }
  14    local function new(_, init)
  15      return setmetatable(init or {}, mt)
  16    end
  17    local function copy(obj, ...)
  18      local newobj = obj:new(unpack(arg))
  19      for n,v in pairs(obj) do newobj[n] = v end
  20      return newobj
  21    end
  22    members.new  = members.new  or new
  23    members.copy = members.copy or copy
  24    return mt
  25  end