fixes in allocator

This commit is contained in:
p.kosyh@gmail.com 2010-11-06 12:32:43 +00:00
parent 17da7087e8
commit 3b992dfd2c

View file

@ -2223,7 +2223,7 @@ function allocator_save(s, name, h, need, auto)
return return
end end
if need then if need then
if s.auto_allocated then if s.auto_allocated then -- in current realization always false
local m = stead.string.format("allocator:new(%s, %s)\n", local m = stead.string.format("allocator:new(%s, %s)\n",
stead.tostring(s.constructor), stead.tostring(s.constructor),
stead.tostring(s.constructor)); stead.tostring(s.constructor));
@ -2233,6 +2233,12 @@ function allocator_save(s, name, h, need, auto)
stead.tostring(name), stead.tostring(name),
stead.tostring(s.constructor)); stead.tostring(s.constructor));
h:write(name..m); h:write(name..m);
if stead.api_version >= "1.3.0" then
m = stead.string.format("check_object(%s, %s)\n",
stead.tostring(name),
name);
h:write(m);
end
end end
end end
savemembers(h, s, name, false); savemembers(h, s, name, false);
@ -2245,9 +2251,7 @@ function new(str)
if type(str) ~= 'string' then if type(str) ~= 'string' then
error("Non string constructor in new.", 2); error("Non string constructor in new.", 2);
end end
local v = allocator:new(str); return allocator:new(str);
check_object(deref(v), v);
return v
end end
function delete(v) function delete(v)
@ -2801,6 +2805,9 @@ stead.objects = function(s)
allocator = obj { allocator = obj {
nam = 'allocator', nam = 'allocator',
get = function(s, n, c) get = function(s, n, c)
if isObject(ref(n)) and stead.api_version >= "1.3.0" then -- static?
return ref(n);
end
local v = ref(c); local v = ref(c);
if not v then if not v then
error ("Null object in allocator: "..tostring(c)); error ("Null object in allocator: "..tostring(c));
@ -2834,6 +2841,9 @@ stead.objects = function(s)
stead.table.insert(s.objects, v); stead.table.insert(s.objects, v);
v.key_name = 'allocator["objects"]['..stead.table.maxn(s.objects)..']'; v.key_name = 'allocator["objects"]['..stead.table.maxn(s.objects)..']';
end end
if stead.api_version >= "1.3.0" then
check_object(v.key_name, v)
end
return v return v
end, end,
objects = { objects = {