__luaBindIndexStatic
Definition
-- @/lua/common/luaBinding.lua:43
function __luaBindIndexStatic(t, k)
local mt = getmetatable(t)
-- log('E', '', ' __index invoked on ' .. tostring(mt.___type))
local res = rawget(mt, k)
if res ~= nil then return res end
local origgetters = rawget(mt, 1) -- 1 = getters
local getFunc = rawget(origgetters or {}, k)
if getFunc ~= nil then
-- log('E', '', ' getter hit: ' .. tostring(k) .. ' = ' .. tostring(res))
if type(getFunc) == 'function' then
return getFunc()
else
return getFunc -- variables exposed through "addConstant()" return the value directly here (rather than a function)
end
end
local origmt = mt
while true do
mt = rawget(mt, 3) -- 3 = super
if not mt then
--log('E', '', string.format("property '%s.%s' is not found", origmt.___type, k))
return
end
res = rawget(mt, k)
if res ~= nil then
rawset(origmt, k, res)
return res
end
local getters = rawget(mt, 1) -- 1 = getters
if getters then
local getFunc = rawget(getters, k)
if type(getFunc) == 'function' then
-- log('E', '', ' getter hit: ' .. tostring(k) .. ' = ' .. tostring(res))
rawset(origgetters, k, getFunc)
return getFunc()
end
end
end
end
Callers