Handle nested wrapped functions in bridge.lua properly
This commit is contained in:
parent
00eb125ad0
commit
09df371d99
16
bridge.lua
16
bridge.lua
|
@ -78,6 +78,8 @@ return function(_python, _bridged)
|
||||||
-- metatables prior to executing the function body
|
-- metatables prior to executing the function body
|
||||||
--==========================================================================
|
--==========================================================================
|
||||||
|
|
||||||
|
local wrapped = false
|
||||||
|
|
||||||
---@class Metatables
|
---@class Metatables
|
||||||
local metatables = {}
|
local metatables = {}
|
||||||
local type_map = {
|
local type_map = {
|
||||||
|
@ -111,10 +113,18 @@ return function(_python, _bridged)
|
||||||
function metawrapper.__newindex(t, k, v)
|
function metawrapper.__newindex(t, k, v)
|
||||||
if type(v) == "function" then
|
if type(v) == "function" then
|
||||||
return rawset(t, k, function(...)
|
return rawset(t, k, function(...)
|
||||||
metatables:overwrite()
|
local _needs_unwrap = false
|
||||||
metatables_original:restore()
|
if not wrapped then
|
||||||
|
metatables:overwrite()
|
||||||
|
metatables_original:restore()
|
||||||
|
_needs_unwrap = true
|
||||||
|
wrapped = true
|
||||||
|
end
|
||||||
local r = {v(...)}
|
local r = {v(...)}
|
||||||
metatables:restore()
|
if _needs_unwrap then
|
||||||
|
metatables:restore()
|
||||||
|
wrapped = false
|
||||||
|
end
|
||||||
return table.unpack(r)
|
return table.unpack(r)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue