Mô đun:Classic
Giao diện
---- classic---- Copyright (c) 2014, rxi---- This module is free software; you can redistribute it and/or modify it under-- the terms of the MIT license. See LICENSE for details.--local Object = {}Object.__index = Objectfunction Object:new() endfunction Object:extend() local cls = {} for k, v in pairs(self) do if k:find("__") == 1 then cls[k] = v end end cls.__index = cls cls.super = self setmetatable(cls, self) return clsendfunction Object:implement(...) for _, cls in pairs({...}) do for k, v in pairs(cls) do if self[k] == nil and type(v) == "function" then self[k] = v end end endendfunction Object:is(T) local mt = getmetatable(self) while mt do if mt == T then return true end mt = getmetatable(mt) end return falseendfunction Object:__tostring() return "Object" endfunction Object:__call(...) local obj = setmetatable({}, self) obj:new(...) return objendreturn Object