12345678910111213141516171819202122 |
- function class(parent)
- if not parent then parent = {} end
- local c = {}
- c.__index = c
- setmetatable(c, {
- __index = parent,
- __call = function (c, ...)
- local inst = setmetatable({}, c)
- if c.init == nil then
- parent.init(inst, ...)
- end
- inst:init(...)
- return inst
- end
- })
- return c
- end
|