-- 不支持继承,主要用于模拟类的封装特性 -- 允许序列化,等同于table local _class = {} local function struct() local classtype = {} classtype.ctor = false classtype.new = function(...) local obj = {} do local create create = function(c, ...) if c.ctor then c.ctor(obj, ...) end end create(classtype, ...) end setmetatable(obj, {__index = _class[classtype]}) return obj end local vtbl = {} _class[classtype] = vtbl setmetatable(classtype, {__newindex = function(t, k, v) vtbl[k] = v end }) return classtype end return struct