check c obj dirty when len, pairs and ipairs. Fix issue #219

This commit is contained in:
Cloud Wu
2014-12-28 11:39:25 +08:00
parent 21cd5c9882
commit 52134f9e57

View File

@@ -53,7 +53,7 @@ local function genkey(self)
return key return key
end end
function meta:__index(key) local function getcobj(self)
local obj = self.__obj local obj = self.__obj
if isdirty(obj) then if isdirty(obj) then
local newobj, newtbl = needupdate(self.__gcobj) local newobj, newtbl = needupdate(self.__gcobj)
@@ -67,6 +67,11 @@ function meta:__index(key)
obj = self.__obj obj = self.__obj
end end
end end
return obj
end
function meta:__index(key)
local obj = getcobj(self)
local v = index(obj, key) local v = index(obj, key)
if type(v) == "userdata" then if type(v) == "userdata" then
local r = setmetatable({ local r = setmetatable({
@@ -83,11 +88,11 @@ function meta:__index(key)
end end
function meta:__len() function meta:__len()
return len(self.__obj) return len(getcobj(self))
end end
local function conf_ipairs(self, index) local function conf_ipairs(self, index)
local obj = self.__obj local obj = getcobj(self)
index = index + 1 index = index + 1
local value = rawget(self, index) local value = rawget(self, index)
if value then if value then
@@ -109,7 +114,8 @@ function meta:__pairs()
end end
function conf.next(obj, key) function conf.next(obj, key)
local nextkey = core.nextkey(obj.__obj, key) local cobj = getcobj(obj)
local nextkey = core.nextkey(cobj, key)
if nextkey then if nextkey then
return nextkey, obj[nextkey] return nextkey, obj[nextkey]
end end