mirror of
https://github.com/cimgui/cimgui.git
synced 2026-03-20 04:51:18 +00:00
cpp2ffi: add deepcopy
This commit is contained in:
@@ -76,6 +76,25 @@ function M.prtable(...)
|
|||||||
print("\n")
|
print("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local function deepcopy(object)
|
||||||
|
local lookup_table = {}
|
||||||
|
local function _copy(object)
|
||||||
|
--assert(object~=REST)
|
||||||
|
if type(object) ~= "table" then
|
||||||
|
return object
|
||||||
|
elseif lookup_table[object] then
|
||||||
|
return lookup_table[object]
|
||||||
|
end
|
||||||
|
local new_table = {}
|
||||||
|
lookup_table[object] = new_table
|
||||||
|
for index, value in pairs(object) do
|
||||||
|
new_table[_copy(index)] = _copy(value)
|
||||||
|
end
|
||||||
|
return setmetatable(new_table, getmetatable(object))
|
||||||
|
end
|
||||||
|
return _copy(object)
|
||||||
|
end
|
||||||
|
M.deepcopy = deepcopy
|
||||||
local function str_split(str, pat)
|
local function str_split(str, pat)
|
||||||
local t = {}
|
local t = {}
|
||||||
local fpat = "(.-)" .. pat
|
local fpat = "(.-)" .. pat
|
||||||
@@ -3025,7 +3044,7 @@ local function func_implementation(FP)
|
|||||||
assert(def)
|
assert(def)
|
||||||
local custom
|
local custom
|
||||||
if FP.custom_implementation then
|
if FP.custom_implementation then
|
||||||
custom = FP.custom_implementation(outtab, def)
|
custom = FP.custom_implementation(outtab, def, FP)
|
||||||
end
|
end
|
||||||
local manual = FP.get_manuals(def)
|
local manual = FP.get_manuals(def)
|
||||||
if not custom and not manual and not def.templated and not FP.get_skipped(def) then
|
if not custom and not manual and not def.templated and not FP.get_skipped(def) then
|
||||||
|
|||||||
Reference in New Issue
Block a user