Skip to content

Commit

Permalink
更新tolua#到1.0.7.367版
Browse files Browse the repository at this point in the history
  • Loading branch information
jarjin2000 committed Aug 22, 2017
1 parent ca2e8af commit 4f93e18
Show file tree
Hide file tree
Showing 35 changed files with 56 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Assets/LuaFramework/ToLua/Core/LuaDLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public string short_src

public class LuaDLL
{
public static string version = "1.0.7.358";
public static string version = "1.0.7.364";
public static int LUA_MULTRET = -1;
public static string[] LuaTypeName = { "none", "nil", "boolean", "lightuserdata", "number", "string", "table", "function", "userdata", "thread" };

Expand Down
8 changes: 8 additions & 0 deletions Assets/LuaFramework/ToLua/Core/ToLua.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,10 @@ static public Type CheckMonoType(IntPtr L, int stackPos)

return null;
}
else if (LuaDLL.lua_isnil(L, stackPos))
{
return null;
}

LuaDLL.luaL_typerror(L, stackPos, "Type");
return null;
Expand All @@ -1052,6 +1056,10 @@ public static IEnumerator CheckIter(IntPtr L, int stackPos)

return null;
}
else if (LuaDLL.lua_isnil(L, stackPos))
{
return null;
}

LuaDLL.luaL_typerror(L, stackPos, "Type");
return null;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/10_Enum/AccessingEnum.unity
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/14_Out/TestOut.unity
Binary file not shown.
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/16_Int64/TestInt64.unity
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/17_Inherit/Inherit.unity
Binary file not shown.
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/19_cjson/testcjson.unity
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/20_utf8/utf8.unity
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/21_String/TestString.unity
Binary file not shown.
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/23_List/UseList.unity
Binary file not shown.
Binary file modified Assets/LuaFramework/ToLua/Examples/24_Struct/Struct.unity
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
51 changes: 23 additions & 28 deletions Assets/LuaFramework/ToLua/Lua/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ function _event:Add(func, obj)

if self.lock then
local node = {value = func, _prev = 0, _next = 0}
table.insert(self.addList, node)
table.insert(self.opList, node)
node.op = list.pushnode
return node
else
return self.list:push(func)
Expand All @@ -88,12 +89,12 @@ end
function _event:Remove(func, obj)
for i, v in ilist(self.list) do
if v.func == func and v.obj == obj then
if self.lock and self.current ~= i then
table.insert(self.rmList, i)
if self.lock then
table.insert(self.opList, i)
node.op = list.remove
else
self.list:remove(i)
end

break
end
end
Expand All @@ -106,23 +107,25 @@ function _event:CreateListener(func, obj)
func = functor(func, obj)
end

return {value = func, _prev = 0, _next = 0}
return {value = func, _prev = 0, _next = 0, removed = true}
end

function _event:AddListener(handle)
function _event:AddListener(handle)
if self.lock then
table.insert(self.addList, handle)
table.insert(self.opList, handle)
handle.op = list.pushnode
else
self.list:pushnode(handle)
end
end
end

function _event:RemoveListener(handle)
if self.lock and self.current ~= handle then
table.insert(self.rmList, handle)
if self.lock then
table.insert(self.opList, handle)
handle.op = list.remove
else
self.list:remove(handle)
end
end
end

function _event:Count()
Expand All @@ -131,8 +134,7 @@ end

function _event:Clear()
self.list:clear()
self.rmList = {}
self.addList = {}
self.opList = {}
self.lock = false
self.keepSafe = false
self.current = nil
Expand All @@ -157,12 +159,11 @@ end
_event.__call = function(self, ...)
local _list = self.list
self.lock = true
local ilist = ilist
local flag, msg = false, nil
local ilist = ilist

for i, f in ilist(_list) do
self.current = i
flag, msg = f(...)
local flag, msg = f(...)

if not flag then
if self.keepSafe then
Expand All @@ -173,23 +174,17 @@ _event.__call = function(self, ...)
end
end

for _, i in ipairs(self.rmList) do
_list:remove(i)
for _, i in ipairs(self.opList) do
i.op(_list, i)
end

self.rmList = {}
self.lock = false

for _, i in ipairs(self.addList) do
_list:pushnode(i)
end

self.addList = {}
end
self.lock = false
self.opList = {}
end

function event(name, safe)
safe = safe or false
return setmetatable({name = name, keepSafe = safe, lock = false, rmList = {}, addList = {}, list = list:new()}, _event)
return setmetatable({name = name, keepSafe = safe, lock = false, opList = {}, list = list:new()}, _event)
end

UpdateBeat = event("Update", true)
Expand Down
36 changes: 17 additions & 19 deletions Assets/LuaFramework/ToLua/Lua/list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,25 @@ function list:clear()
end

function list:push(value)
local node = {value = value, _prev = 0, _next = 0}
--assert(value)
local node = {value = value, _prev = 0, _next = 0, removed = false}

self._prev._next = node
node._next = self
node._prev = self._prev
self._prev = node

node.removed = false
self.length = self.length + 1
return node
end

function list:pushnode(node)
if not node.removed then return end

self._prev._next = node
node._next = self
node._prev = self._prev
self._prev = node

node.removed = false
self.length = self.length + 1
end
Expand All @@ -51,14 +52,13 @@ function list:pop()
end

function list:unshift(v)
local node = {value = v, _prev = 0, _next = 0}
local node = {value = v, _prev = 0, _next = 0, removed = false}

self._next._prev = node
node._prev = self
node._next = self._next
self._next = node

node.removed = false
self.length = self.length + 1
return node
end
Expand All @@ -70,42 +70,41 @@ function list:shift()
end

function list:remove(iter)
if iter.removed then return end

local _prev = iter._prev
local _next = iter._next

if iter.removed == false then
_next._prev = _prev
_prev._next = _next

self.length = math.max(0, self.length - 1)
iter.removed = true
end
_next._prev = _prev
_prev._next = _next

self.length = math.max(0, self.length - 1)
iter.removed = true
end

function list:find(v, iter)
iter = iter or self

while iter do
repeat
if v == iter.value then
return iter
else
iter = iter._next
end
end
until iter == self

return nil
end

function list:findlast(v, iter)
iter = iter or self

while iter do
repeat
if v == iter.value then
return iter
end

iter = iter._prev
end
until iter == self

return nil
end
Expand Down Expand Up @@ -141,7 +140,7 @@ function list:insert(v, iter)
return self:push(v)
end

local node = {value = v, _next = 0, _prev = 0}
local node = {value = v, _next = 0, _prev = 0, removed = false}

if iter._next then
iter._next._prev = node
Expand All @@ -152,7 +151,6 @@ function list:insert(v, iter)

node._prev = iter
iter._next = node
node.removed = false
self.length = self.length + 1
return node
end
Expand Down
4 changes: 2 additions & 2 deletions Assets/Plugins_sproto.zip.meta → Assets/Sproto.New.zip.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ XlsxToLua: https://github.com/zhangqi-ulua/XlsxToLua
UnityHello: https://github.com/woshihuo12/UnityHello
Excel配置:https://github.com/sy-yanghuan/proton

ULUA/TOLUA骏擎Unity素材商店: https://junfine.taobao.com

//-------------2017-08-22-------------
(1)更新tolua#到1.0.7.367版

//-------------2017-08-10-------------
(1)更新tolua#到1.0.7.359版

Expand Down

0 comments on commit 4f93e18

Please sign in to comment.