diff options
| author | the lemons <citrons@mondecitronne.com> | 2022-08-27 01:23:20 -0500 |
|---|---|---|
| committer | the lemons <citrons@mondecitronne.com> | 2022-08-27 01:23:20 -0500 |
| commit | 8bb18a89060ecd581a06238ce3fa5d2170ee3a15 (patch) | |
| tree | 25baba9d2c267b986adfe7af661b3cd99a32b346 /Obj.lua | |
| parent | 001272dbcbaa1110541e0666af3cea1c97bc199f (diff) | |
implement component system
Diffstat (limited to 'Obj.lua')
| -rw-r--r-- | Obj.lua | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/Obj.lua b/Obj.lua deleted file mode 100644 index cbd6f81..0000000 --- a/Obj.lua +++ /dev/null @@ -1,68 +0,0 @@ --- --- 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 = Object - - -function Object:new() -end - - -function 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 cls -end - - -function 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 - end -end - - -function Object:is(T) - local mt = getmetatable(self) - while mt do - if mt == T then - return true - end - mt = getmetatable(mt) - end - return false -end - - -function Object:__tostring() - return "Object" -end - - -function Object:__call(...) - local obj = setmetatable({}, self) - obj:new(...) - return obj -end - - -return Object |
