auto save fix
This commit is contained in:
parent
e42a6c431a
commit
5ea6dd3a11
|
@ -113,7 +113,7 @@ function list_check(self, name) -- force using of objects, instead refs
|
||||||
end
|
end
|
||||||
if isObject(deref(v)) and not v._dynamic_type then -- no named object!
|
if isObject(deref(v)) and not v._dynamic_type then -- no named object!
|
||||||
local n = stead.string.format("%s[%d]", name, ii);
|
local n = stead.string.format("%s[%d]", name, ii);
|
||||||
v = allocator:new(n);
|
v = allocator:new(n, n);
|
||||||
self[ii] = v;
|
self[ii] = v;
|
||||||
v.auto_allocated = true;
|
v.auto_allocated = true;
|
||||||
for_each(v, n, check_list, isList, deref(v));
|
for_each(v, n, check_list, isList, deref(v));
|
||||||
|
|
|
@ -1617,7 +1617,7 @@ function savevar (h, v, n, need)
|
||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
if v == _G then return end
|
if v == _G then return end
|
||||||
if type(v.key_name) == 'string' and v.key_name ~= n then -- just xref
|
if type(v.key_name) == 'string' and v.key_name ~= n then -- just xref
|
||||||
if v.auto_allocated and not v.auto_saved then
|
if v.auto_allocated and not v.auto_saved and need then
|
||||||
v:save(v.key_name, h, true, true);
|
v:save(v.key_name, h, true, true);
|
||||||
end
|
end
|
||||||
if need then
|
if need then
|
||||||
|
@ -2057,10 +2057,17 @@ function allocator_save(s, name, h, need, auto)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if need then
|
if need then
|
||||||
local m = stead.string.format(" = allocator:get(%s, %s)\n",
|
if s.auto_allocated then
|
||||||
stead.tostring(name),
|
local m = stead.string.format("allocator:new(%s, %s)\n",
|
||||||
stead.tostring(s.constructor));
|
stead.tostring(s.constructor),
|
||||||
h:write(name..m);
|
stead.tostring(s.constructor));
|
||||||
|
h:write(m);
|
||||||
|
else
|
||||||
|
local m = stead.string.format(" = allocator:get(%s, %s)\n",
|
||||||
|
stead.tostring(name),
|
||||||
|
stead.tostring(s.constructor));
|
||||||
|
h:write(name..m);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
savemembers(h, s, name, false);
|
savemembers(h, s, name, false);
|
||||||
if s.auto_allocated then
|
if s.auto_allocated then
|
||||||
|
@ -2642,15 +2649,20 @@ stead.objects = function(s)
|
||||||
f();
|
f();
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
new = function(s, n)
|
new = function(s, n, key)
|
||||||
local v = ref(n);
|
local v = ref(n);
|
||||||
if type(v) ~= 'table' or type(n) ~= 'string' then
|
if type(v) ~= 'table' or type(n) ~= 'string' then
|
||||||
error ("Error in new.", 2);
|
error ("Error in new.", 2);
|
||||||
end
|
end
|
||||||
v.save = allocator_save;
|
v.save = allocator_save;
|
||||||
v.constructor = n;
|
v.constructor = n;
|
||||||
stead.table.insert(s.objects, v);
|
if key then
|
||||||
v.key_name = 'allocator["objects"]['..stead.table.maxn(s.objects)..']';
|
s.objects[key] = v
|
||||||
|
v.key_name = stead.string.format('allocator["objects"][%s]', stead.tostring(key));
|
||||||
|
else
|
||||||
|
stead.table.insert(s.objects, v);
|
||||||
|
v.key_name = 'allocator["objects"]['..stead.table.maxn(s.objects)..']';
|
||||||
|
end
|
||||||
return v
|
return v
|
||||||
end,
|
end,
|
||||||
objects = {
|
objects = {
|
||||||
|
|
Reference in a new issue