Skip to content

Commit

Permalink
Merge pull request #314 from xiejiangzhi/fix_class_index
Browse files Browse the repository at this point in the history
Fix lua class Index
  • Loading branch information
xuyanghuang-tencent authored Dec 23, 2021
2 parents f1add8f + 8b5693f commit c65ca01
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 34 deletions.
32 changes: 15 additions & 17 deletions Content/Script/UnLua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@ local function Index(t, k)
local super = mt
while super do
local v = rawget(super, k)
if v~= nil then
if rawequal(v, NotExist) then
return nil
end
if v ~= nil and not rawequal(v, NotExist) then
rawset(t, k, v)
return v
end
super = rawget(super, "Super")
end
local p = mt[k]

if p ~= nil then
if type(p) == "userdata" then
return GetUProperty(t, p)
elseif type(p) == "function" then
rawset(t, k, p)
elseif rawequal(p, NotExist) then
return nil
end
else
rawset(mt, k, NotExist)
end
local p = mt[k]
if p ~= nil then
if type(p) == "userdata" then
return GetUProperty(t, p)
elseif type(p) == "function" then
rawset(t, k, p)
elseif rawequal(p, NotExist) then
return nil
end
else
rawset(mt, k, NotExist)
end

return p
end

Expand All @@ -65,7 +63,7 @@ local function Class(super_name)
new_class.__newindex = NewIndex
new_class.Super = super_class

return new_class
return new_class
end

local function global_index(t, k)
Expand Down
33 changes: 16 additions & 17 deletions Plugins/UnLua/Content/UnLua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@ local function Index(t, k)
local super = mt
while super do
local v = rawget(super, k)
if v~= nil then
if rawequal(v, NotExist) then
return nil
end
if v ~= nil and not rawequal(v, NotExist) then
rawset(t, k, v)
return v
end
super = rawget(super, "Super")
end
local p = mt[k]

if p ~= nil then
if type(p) == "userdata" then
return GetUProperty(t, p)
elseif type(p) == "function" then
rawset(t, k, p)
elseif rawequal(p, NotExist) then
return nil
end
else
rawset(mt, k, NotExist)
end
local p = mt[k]
if p ~= nil then
if type(p) == "userdata" then
return GetUProperty(t, p)
elseif type(p) == "function" then
rawset(t, k, p)
elseif rawequal(p, NotExist) then
return nil
end
else
rawset(mt, k, NotExist)
end

return p
end

Expand All @@ -65,7 +63,7 @@ local function Class(super_name)
new_class.__newindex = NewIndex
new_class.Super = super_class

return new_class
return new_class
end

local function global_index(t, k)
Expand All @@ -87,6 +85,7 @@ else
global_mt.__index = global_index
setmetatable(_G, global_mt)
UE4 = _G
UE = _G

print("WITH_UE4_NAMESPACE==false");
end
Expand Down

0 comments on commit c65ca01

Please sign in to comment.