fixed isInstanceOf

This commit is contained in:
kikito 2013-09-17 00:48:47 +02:00
parent 219550cd58
commit 1be9e39deb

View File

@ -126,12 +126,13 @@ end
function Object.static:subclassed(other) end function Object.static:subclassed(other) end
function Object.static:isSubclassOf(other) function Object.static:isSubclassOf(other)
if type(other) ~= 'table' or return type(other) == 'table' and
type(self) ~= 'table' or type(self) == 'table' and
type(self.super) ~= 'table' or type(self.super) == 'table' and
type(self.super.isSubclassOf) ~= 'function' then return false end ( self.super == other or
type(self.super.isSubclassOf) == 'function' and
return self.super == other or self.super:isSubclassOf(other) self.super:isSubclassOf(other)
)
end end
function Object.static:include( ... ) function Object.static:include( ... )
@ -145,12 +146,13 @@ function Object:initialize() end
function Object:__tostring() return "instance of " .. tostring(self.class) end function Object:__tostring() return "instance of " .. tostring(self.class) end
function Object:isInstanceOf(aClass) function Object:isInstanceOf(aClass)
if type(self) ~= 'table' or return type(self) == 'table' and
type(self.class) ~= 'table' or type(self.class) == 'table' and
type(aClass) ~= 'table' or type(aClass) == 'table' and
type(aClass.isSubclassOf) ~= 'function' then return false end ( aClass == self.class or
type(aClass.isSubclassOf) == 'function' and
return aClass == self.class or aClass:isSubclassOf(self.class) self.class:isSubclassOf(aClass)
)
end end
function includes(mixin, aClass) function includes(mixin, aClass)