MCPcopy Create free account
hub / github.com/Tencent/UnLua / LegacySupport

Function LegacySupport

Plugins/UnLua/Source/UnLua/Private/UnLuaLib.cpp:146–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144 };
145
146 static void LegacySupport(lua_State* L)
147 {
148 static const char* Chunk = R"(
149 local rawget = _G.rawget
150 local rawset = _G.rawset
151 local rawequal = _G.rawequal
152 local type = _G.type
153 local getmetatable = _G.getmetatable
154 local require = _G.require
155
156 local GetUProperty = GetUProperty
157 local SetUProperty = SetUProperty
158
159 local function Index(t, k)
160 local mt = getmetatable(t)
161 local super = mt
162 while super do
163 local v = rawget(super, k)
164 if v ~= nil then
165 rawset(t, k, v)
166 return v
167 end
168 super = rawget(super, "Super")
169 end
170
171 local p = mt[k]
172 if p ~= nil then
173 if type(p) == "userdata" then
174 return GetUProperty(t, p)
175 elseif type(p) == "function" then
176 rawset(t, k, p)
177 end
178 end
179
180 return p
181 end
182
183 local function NewIndex(t, k, v)
184 local mt = getmetatable(t)
185 local p = mt[k]
186 if type(p) == "userdata" then
187 return SetUProperty(t, p, v)
188 end
189 rawset(t, k, v)
190 end
191
192 local function Class(super_name)
193 local super_class = nil
194 if super_name ~= nil then
195 super_class = require(super_name)
196 end
197
198 local new_class = {}
199 new_class.__index = Index
200 new_class.__newindex = NewIndex
201 new_class.Super = super_class
202
203 return new_class

Callers 1

OpenFunction · 0.85

Calls 5

luaL_loadstringFunction · 0.85
lua_getglobalFunction · 0.85
lua_setfieldFunction · 0.85
luaL_setfuncsFunction · 0.85
lua_setupvalueFunction · 0.85

Tested by

no test coverage detected