Remove name inference in class.lua.

This commit is contained in:
Matthias Richter 2012-03-31 14:27:24 +02:00
parent f5adba2cb8
commit 9d76e4d020

View File

@ -66,22 +66,6 @@ local function new(args)
class.__is_a = {[class] = true}
class.is_a = function(self, other) return not not self.__is_a[other] end
-- intercept assignment in global environment to infer the class name
if not (type(args) == "table" and args.name) then
local env, env_meta, interceptor = getfenv(0), getmetatable(getfenv(0)), {}
function interceptor:__newindex(key, value)
if value == class then
local name = tostring(key)
getmetatable(class).__tostring = function() return name end
end
-- restore old metatable and insert value
setmetatable(env, env_meta)
if env.global then env.global(key) end -- handle 'strict' module
env[key] = value
end
setmetatable(env, interceptor)
end
-- inherit superclasses (see above)
inherit(class, unpack(super))