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