elua: remove the eo_methods stuff, improve class registration
This commit is contained in:
parent
0061d5a437
commit
85a135d32e
|
@ -137,11 +137,8 @@ M.class_get = function(name)
|
||||||
return classes[name]
|
return classes[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
M.class_register = function(name, val, addr)
|
M.class_register = function(name, val)
|
||||||
classes[name] = val
|
classes[name] = val
|
||||||
if addr then
|
|
||||||
classes[tonumber(ffi.cast("intptr_t", addr))] = val
|
|
||||||
end
|
|
||||||
return val
|
return val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -181,24 +178,20 @@ M.__do_end = function()
|
||||||
-- only for cleanup (dtor)
|
-- only for cleanup (dtor)
|
||||||
end
|
end
|
||||||
|
|
||||||
local eo_methods = {
|
|
||||||
}
|
|
||||||
|
|
||||||
ffi.metatype("Eo", {
|
ffi.metatype("Eo", {
|
||||||
__index = function(self, key)
|
__index = function(self, key)
|
||||||
local v = rawget(eo_methods, key)
|
|
||||||
if v ~= nil then return v end
|
|
||||||
local cl = eo.eo_class_get(self)
|
local cl = eo.eo_class_get(self)
|
||||||
if cl == nil then return nil end
|
if cl == nil then return nil end
|
||||||
local nm = eo.eo_class_name_get(cl)
|
local nm = eo.eo_class_name_get(cl)
|
||||||
if nm == nil then return nil end
|
if nm == nil then return nil end
|
||||||
local mt == classes[nm]
|
local mt == classes[ffi.string(nm)]
|
||||||
if mt == nil then return nil end
|
if mt == nil then return nil end
|
||||||
return mt[key]
|
return mt[key]
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
M.Eo_Base = util.Object:clone {
|
M.Base = util.Object:clone {
|
||||||
}
|
}
|
||||||
|
M.class_register("Eo.Base", M.Base)
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue