Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wO={}
- wO.global={}
- wO.global.clone=function(self) local cloneObj={} setmetatable(cloneObj, {__index=self}) return cloneObj end
- wO.global.isA=function(self, arg)
- if self.className==arg then
- return true
- elseif self.className~="base" then
- if wO.classes[self.extends]:isA(arg) then
- return true
- end
- else
- return false
- end
- end
- wO.global.className="base"
- wO.classes={base=wO.global}
- function wO.newClass(a, ...)
- arg={...}
- b=(arg[1] or {})
- b.className=a
- b.name=a.."Obj"
- if #arg==2 then
- b.mt={__index=wO.classes[arg[2]]}
- b.extends=arg[2]
- else
- b.mt={__index=wO.classes["base"]}
- b.extends="base"
- end
- b.mt.__tostring=function(a) return "Class "..a end
- setmetatable(b, b.mt)
- wO.classes[a]=b
- end
- function wO.newObj(a, ...)
- arg={...}
- local o=(arg[1] or {})
- local mt={__index=wO.classes[a]}
- mt.__tostring=function(a) return "Object "..o.name..", a "..o.className end
- setmetatable(o, mt)
- return o
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement