Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,19 @@
-- Supports lists, property lists, images, script instances and scalar values (integer, float, string, symbol).
on deepcopy (var, cycleCheck)
case ilk(var) of
#list, #propList, #image:
return var.duplicate()
#instance:
if string(var) starts "<Xtra " then return var -- deep copy makes no sense for Xtra instances
if voidP(cycleCheck) then cycleCheck = [:]
if not voidP(cycleCheck[var]) then return cycleCheck[var]
copy = var.script.rawNew()
cycleCheck[var] = copy
repeat with i = 1 to var.count
copy.setProp(var.getPropAt(i), deepcopy(var[i], cycleCheck))
end repeat
return copy
otherwise:
return var
end case
end

View file

@ -0,0 +1,8 @@
val = [#foo:42, "bar":[1,2,3, "Hello world!"]]
put deepcopy(val)
-- [#foo: 42, "bar": [1, 2, 3, "Hello world!"]]
val = script("MyClass").new()
val.foo = 42
val.bar = [1, 2, 3, "Hello world!"]]
copy = deepcopy(val)