From c6f993428ec97de5dd8fa6006e70d88dfe29536b Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 3 Apr 2015 11:03:37 +0800 Subject: [PATCH] bugfix #257 --- lualib/sharemap.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lualib/sharemap.lua b/lualib/sharemap.lua index 5b0e5845..6f9b1bdf 100644 --- a/lualib/sharemap.lua +++ b/lualib/sharemap.lua @@ -30,12 +30,14 @@ function sharemap.writer(typename, obj) local sp = loadsp() obj = obj or {} local stmobj = stm.new(sp:encode(typename,obj)) - obj.__typename = typename - obj.__obj = stmobj - obj.__data = obj - obj.commit = sharemap.commit - obj.copy = sharemap.copy - return setmetatable(obj, { __index = obj.__data, __newindex = obj.__data }) + local ret = { + __typename = typename, + __obj = stmobj, + __data = obj, + commit = sharemap.commit, + copy = sharemap.copy, + } + return setmetatable(ret, { __index = obj, __newindex = obj }) end local function decode(msg, sz, self) @@ -63,7 +65,7 @@ function sharemap.reader(typename, stmcpy) __data = data, update = sharemap.update, } - return setmetatable(obj, { __index = obj.__data, __newindex = error }) + return setmetatable(obj, { __index = data, __newindex = error }) end return sharemap