Class: minor changes
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
local setMetaTable, tableCopy = setmetatable, table.copy_with_metatables
|
local tableMerge, setmetatable, tableCopy = table.merge, setmetatable, table.copy_with_metatables
|
||||||
|
|
||||||
---@class Class
|
---@class Class
|
||||||
Class = {}
|
Class = {}
|
||||||
@@ -7,7 +7,7 @@ Class = {}
|
|||||||
---@param parent table
|
---@param parent table
|
||||||
---@param child table?
|
---@param child table?
|
||||||
function Class.extend(parent, child)
|
function Class.extend(parent, child)
|
||||||
return setMetaTable(child or {}, { __index = tableCopy(parent) })
|
return tableMerge(child or {}, tableCopy(parent))
|
||||||
end
|
end
|
||||||
|
|
||||||
---Intended for class constructors.
|
---Intended for class constructors.
|
||||||
@@ -25,7 +25,7 @@ function Class.getInstance(self, params, metatable)
|
|||||||
|
|
||||||
metatable.__index = tableCopy(self)
|
metatable.__index = tableCopy(self)
|
||||||
|
|
||||||
local instance = setMetaTable(params, metatable)
|
local instance = setmetatable(params, metatable)
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
@@ -1 +1,2 @@
|
|||||||
name = smc__system__class
|
name = smc__system__class
|
||||||
|
depends = smc__system__table
|
||||||
|
|||||||
Reference in New Issue
Block a user