新结算页面
parent
728a07e106
commit
9f240c2ae2
|
|
@ -2,7 +2,7 @@
|
||||||
--author:--
|
--author:--
|
||||||
|
|
||||||
-- a net client
|
-- a net client
|
||||||
NetClient = {
|
NetClient= {
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionProtocol = {
|
ConnectionProtocol = {
|
||||||
|
|
@ -59,21 +59,21 @@ local LuaNetClient = taurus.unity.LuaNetClient
|
||||||
-- @param #string game
|
-- @param #string game
|
||||||
-- @param #number protocol
|
-- @param #number protocol
|
||||||
-- @return #NetClient the created NetClient
|
-- @return #NetClient the created NetClient
|
||||||
function NetClient.new(host, game, protocol)
|
function NetClient.new(host, game,protocol)
|
||||||
local self = {}
|
local self = {}
|
||||||
self.host = host or ""
|
self.host = host or ""
|
||||||
self.game = game or ""
|
self.game = game or ""
|
||||||
self.protocol = protocol or ConnectionProtocol.Tcp
|
self.protocol = protocol or ConnectionProtocol.Tcp
|
||||||
-- self.responseMap = {}
|
-- self.responseMap = {}
|
||||||
self.onevent = event("onevent", false)
|
self.onevent = event("onevent",false)
|
||||||
self.onconnect = event("onconnect", false)
|
self.onconnect = event("onconnect",false)
|
||||||
---- print("222222222222222222222222222222222222222222 ",host," ",host," ",game," ",self.protocol)
|
--print("222222222222222222222222222222222222222222 ",host," ",host," ",game," ",self.protocol)
|
||||||
|
|
||||||
self.c__netClient = LuaNetClient(host, game, self, self.protocol)
|
self.c__netClient = LuaNetClient(host,game,self,self.protocol)
|
||||||
self.c__netClient:SetCallBackListener(R.c__ondata)
|
self.c__netClient:SetCallBackListener(R.c__ondata)
|
||||||
self.c__netClient:SetNetEventListener(R.c__onevent)
|
self.c__netClient:SetNetEventListener(R.c__onevent)
|
||||||
self.c__netClient:SetNetConnectListener(R.c__onconnect)
|
self.c__netClient:SetNetConnectListener(R.c__onconnect)
|
||||||
setmetatable(self, { __index = R })
|
setmetatable(self, {__index = R})
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -83,17 +83,16 @@ function R.connect(self)
|
||||||
end
|
end
|
||||||
self.c__netClient:Connect()
|
self.c__netClient:Connect()
|
||||||
end
|
end
|
||||||
|
|
||||||
local TYPE_STRING = "string"
|
local TYPE_STRING = "string"
|
||||||
local TYPE_FUNC = "function"
|
local TYPE_FUNC = "function"
|
||||||
local TYPE_TABLE = "table"
|
local TYPE_TABLE = "table"
|
||||||
local NULL_JSON = "{}"
|
local NULL_JSON = "{}"
|
||||||
|
|
||||||
--- send
|
--- send
|
||||||
function R.send(self, cmd, data, callback)
|
function R.send(self,cmd, data, callback)
|
||||||
if (debug_print) then
|
if(debug_print) then
|
||||||
-- print("send host:" .. self.host)
|
print("send host:"..self.host)
|
||||||
end
|
end
|
||||||
if self.c__netClient == nil then
|
if self.c__netClient == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -105,22 +104,23 @@ function R.send(self, cmd, data, callback)
|
||||||
if data then
|
if data then
|
||||||
str = json.encode(data)
|
str = json.encode(data)
|
||||||
end
|
end
|
||||||
self.c__netClient:Send(cmd, str, callback)
|
self.c__netClient:Send(cmd,str,callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
---c#网络层回调函数
|
|
||||||
function R.c__ondata(self, cmd, result, data, func)
|
|
||||||
local _response = nil
|
|
||||||
|
|
||||||
|
---c#网络层回调函数
|
||||||
|
function R.c__ondata(self,cmd,result,data,func)
|
||||||
|
local _response = nil
|
||||||
|
|
||||||
if type(data) == TYPE_STRING and string.len(data) > 0 then
|
if type(data) == TYPE_STRING and string.len(data) > 0 then
|
||||||
_response = json.decode(data)
|
_response = json.decode(data)
|
||||||
end
|
end
|
||||||
local new_response = {}
|
local new_response = {}
|
||||||
new_response.ReturnCode = result
|
new_response.ReturnCode = result
|
||||||
new_response.Data = _response
|
new_response.Data = _response
|
||||||
|
|
||||||
|
|
||||||
|
if self.holdCallback ~=nil then
|
||||||
if self.holdCallback ~= nil then
|
|
||||||
if self.holdCallback(new_response) then
|
if self.holdCallback(new_response) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -129,9 +129,9 @@ function R.c__ondata(self, cmd, result, data, func)
|
||||||
func(new_response)
|
func(new_response)
|
||||||
end
|
end
|
||||||
|
|
||||||
function R.setSession(self, session)
|
function R.setSession(self,session)
|
||||||
printlog("setSession==>>>", session)
|
printlog("setSession==>>>",session)
|
||||||
|
|
||||||
self.session = session
|
self.session = session
|
||||||
if self.c__netClient == nil then
|
if self.c__netClient == nil then
|
||||||
return
|
return
|
||||||
|
|
@ -140,7 +140,7 @@ function R.setSession(self, session)
|
||||||
end
|
end
|
||||||
|
|
||||||
function R.getSession(self)
|
function R.getSession(self)
|
||||||
printlog("getSession===>>>", self.session)
|
printlog("getSession===>>>",self.session)
|
||||||
return self.session
|
return self.session
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -151,13 +151,15 @@ function R.getAveragePingTime(self)
|
||||||
return self.c__netClient.AveragePingTime
|
return self.c__netClient.AveragePingTime
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---c#网络层回调函数
|
---c#网络层回调函数
|
||||||
function R.c__onevent(self, cmd, data)
|
function R.c__onevent(self,cmd,data)
|
||||||
local new_response = {}
|
local new_response = {}
|
||||||
local _response = data and json.decode(data) or nil
|
local _response = data and json.decode(data) or nil
|
||||||
new_response.Command = cmd
|
new_response.Command = cmd
|
||||||
new_response.Data = _response
|
new_response.Data = _response
|
||||||
self.onevent(new_response)
|
self.onevent(new_response)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function R.clearActionQueue(self)
|
function R.clearActionQueue(self)
|
||||||
|
|
@ -168,19 +170,19 @@ function R.clearActionQueue(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
---c#网络层回调函数
|
---c#网络层回调函数
|
||||||
function R.c__onconnect(self, code)
|
function R.c__onconnect(self,code)
|
||||||
if (debug_print) then
|
if(debug_print) then
|
||||||
-- print("codeccccccccccccccccccccccccccccccccccccccc" .. code)
|
print("codeccccccccccccccccccccccccccccccccccccccc"..code)
|
||||||
end
|
end
|
||||||
self.onconnect(code)
|
self.onconnect(code)
|
||||||
end
|
end
|
||||||
|
|
||||||
function R.clearEvent(self)
|
function R.clearEvent(self)
|
||||||
self.onevent:Clear()
|
self.onevent:Clear()
|
||||||
self.onconnect:Clear()
|
self.onconnect:Clear()
|
||||||
end
|
end
|
||||||
|
|
||||||
function R.setHold(self, func)
|
function R.setHold(self,func)
|
||||||
self.holdcallback = func
|
self.holdcallback = func
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -188,5 +190,5 @@ function R.destroy(self)
|
||||||
if self.c__netClient then self.c__netClient:Destroy() end
|
if self.c__netClient then self.c__netClient:Destroy() end
|
||||||
self.onconnect:Clear()
|
self.onconnect:Clear()
|
||||||
self.onevent:Clear()
|
self.onevent:Clear()
|
||||||
self.c__netClient = nil
|
self.c__netClient=nil
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ Queue = {}
|
||||||
|
|
||||||
|
|
||||||
function Queue.new(capacity)
|
function Queue.new(capacity)
|
||||||
local self = {}
|
local self = {}
|
||||||
setmetatable(self, { __index = Queue })
|
setmetatable(self,{__index = Queue})
|
||||||
self.capacity = capacity
|
self.capacity = capacity
|
||||||
self.queue = {}
|
self.queue = {}
|
||||||
self.size_ = 0
|
self.size_ = 0
|
||||||
|
|
@ -20,12 +20,12 @@ function Queue:Enqueue(element)
|
||||||
self.queue[self.rear] = element
|
self.queue[self.rear] = element
|
||||||
else
|
else
|
||||||
local temp = (self.rear + 1) % self.capacity
|
local temp = (self.rear + 1) % self.capacity
|
||||||
---- print("1111111111111111111====>>>>")
|
--print("1111111111111111111====>>>>")
|
||||||
---- print(temp)
|
--print(temp)
|
||||||
if temp == self.head then
|
if temp == self.head then
|
||||||
error("Error: capacity is full.")
|
error("Error: capacity is full.")
|
||||||
ViewUtil.ErrorTip(10001, "Error: capacity is full.")
|
ViewUtil.ErrorTip(10001,"Error: capacity is full.")
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
self.rear = temp
|
self.rear = temp
|
||||||
end
|
end
|
||||||
|
|
@ -33,11 +33,12 @@ function Queue:Enqueue(element)
|
||||||
self.queue[self.rear] = element
|
self.queue[self.rear] = element
|
||||||
self.size_ = self.size_ + 1
|
self.size_ = self.size_ + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Queue:Dequeue()
|
function Queue:Dequeue()
|
||||||
if self:IsEmpty() then
|
if self:IsEmpty() then
|
||||||
ViewUtil.ErrorTip(10002, "Error: The Queue is empty.")
|
ViewUtil.ErrorTip(10002,"Error: The Queue is empty.")
|
||||||
error("Error: The Queue is empty.")
|
error("Error: The Queue is empty.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -73,16 +74,16 @@ function Queue:dump()
|
||||||
local first_flag = true
|
local first_flag = true
|
||||||
while h ~= r do
|
while h ~= r do
|
||||||
if first_flag == true then
|
if first_flag == true then
|
||||||
str = "{" .. self.queue[h]
|
str = "{"..self.queue[h]
|
||||||
h = (h + 1) % self.capacity
|
h = (h + 1) % self.capacity
|
||||||
first_flag = false
|
first_flag = false
|
||||||
else
|
else
|
||||||
str = str .. "," .. self.queue[h]
|
str = str..","..self.queue[h]
|
||||||
h = (h + 1) % self.capacity
|
h = (h + 1) % self.capacity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
str = str .. "," .. self.queue[r] .. "}"
|
str = str..","..self.queue[r].."}"
|
||||||
if (debug_print) then
|
if(debug_print) then
|
||||||
-- print(str)
|
print(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,135 +1,136 @@
|
||||||
--[[
|
--[[
|
||||||
位操作
|
位操作
|
||||||
]]
|
]]
|
||||||
--bit={data32={}}
|
--bit={data32={}}
|
||||||
bit = bit or {}
|
bit = bit or {}
|
||||||
function bit.init32()
|
function bit.init32()
|
||||||
bit.data32 = {}
|
bit.data32 = {}
|
||||||
for i = 1, 32 do
|
for i=1,32 do
|
||||||
bit.data32[i] = 2 ^ (32 - i)
|
bit.data32[i]=2^(32-i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bit.init32()
|
bit.init32()
|
||||||
|
|
||||||
|
function bit:d2b(arg) --bit:d2b
|
||||||
|
local tr={}
|
||||||
|
for i=1,32 do
|
||||||
|
if arg >= self.data32[i] then
|
||||||
|
tr[i]=1
|
||||||
|
arg=arg-self.data32[i]
|
||||||
|
else
|
||||||
|
tr[i]=0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tr
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:b2d(arg) --bit:b2d
|
||||||
|
local nr=0
|
||||||
|
for i=1,32 do
|
||||||
|
if arg[i] ==1 then
|
||||||
|
nr=nr+2^(32-i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:_xor(a,b) --bit:xor
|
||||||
|
local op1=self:d2b(a)
|
||||||
|
local op2=self:d2b(b)
|
||||||
|
local r={}
|
||||||
|
|
||||||
|
for i=1,32 do
|
||||||
|
if op1[i]==op2[i] then
|
||||||
|
r[i]=0
|
||||||
|
else
|
||||||
|
r[i]=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:b2d(r)
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:_and(a,b) --bit:_and
|
||||||
|
local op1=self:d2b(a)
|
||||||
|
local op2=self:d2b(b)
|
||||||
|
local r={}
|
||||||
|
|
||||||
function bit:d2b(arg) --bit:d2b
|
for i=1,32 do
|
||||||
local tr = {}
|
if op1[i]==1 and op2[i]==1 then
|
||||||
for i = 1, 32 do
|
r[i]=1
|
||||||
if arg >= self.data32[i] then
|
else
|
||||||
tr[i] = 1
|
r[i]=0
|
||||||
arg = arg - self.data32[i]
|
end
|
||||||
else
|
end
|
||||||
tr[i] = 0
|
return self:b2d(r)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return tr
|
|
||||||
end
|
function bit:_or(a,b) --bit:_or
|
||||||
|
local op1=self:d2b(a)
|
||||||
function bit:b2d(arg) --bit:b2d
|
local op2=self:d2b(b)
|
||||||
local nr = 0
|
local r={}
|
||||||
for i = 1, 32 do
|
|
||||||
if arg[i] == 1 then
|
for i=1,32 do
|
||||||
nr = nr + 2 ^ (32 - i)
|
if op1[i]==1 or op2[i]==1 then
|
||||||
end
|
r[i]=1
|
||||||
end
|
else
|
||||||
return nr
|
r[i]=0
|
||||||
end
|
end
|
||||||
|
end
|
||||||
function bit:_xor(a, b) --bit:xor
|
return self:b2d(r)
|
||||||
local op1 = self:d2b(a)
|
end
|
||||||
local op2 = self:d2b(b)
|
|
||||||
local r = {}
|
function bit:_not(a) --bit:_not
|
||||||
|
local op1=self:d2b(a)
|
||||||
for i = 1, 32 do
|
local r={}
|
||||||
if op1[i] == op2[i] then
|
|
||||||
r[i] = 0
|
for i=1,32 do
|
||||||
else
|
if op1[i]==1 then
|
||||||
r[i] = 1
|
r[i]=0
|
||||||
end
|
else
|
||||||
end
|
r[i]=1
|
||||||
return self:b2d(r)
|
end
|
||||||
end
|
end
|
||||||
|
return self:b2d(r)
|
||||||
function bit:_and(a, b) --bit:_and
|
end
|
||||||
local op1 = self:d2b(a)
|
|
||||||
local op2 = self:d2b(b)
|
function bit:_rshift(a,n) --bit:_rshift
|
||||||
local r = {}
|
local op1=self:d2b(a)
|
||||||
|
local r=self:d2b(0)
|
||||||
for i = 1, 32 do
|
|
||||||
if op1[i] == 1 and op2[i] == 1 then
|
if n < 32 and n > 0 then
|
||||||
r[i] = 1
|
for i=1,n do
|
||||||
else
|
for i=31,1,-1 do
|
||||||
r[i] = 0
|
op1[i+1]=op1[i]
|
||||||
end
|
end
|
||||||
end
|
op1[1]=0
|
||||||
return self:b2d(r)
|
end
|
||||||
end
|
r=op1
|
||||||
|
end
|
||||||
function bit:_or(a, b) --bit:_or
|
return self:b2d(r)
|
||||||
local op1 = self:d2b(a)
|
end
|
||||||
local op2 = self:d2b(b)
|
|
||||||
local r = {}
|
function bit:_lshift(a,n) --bit:_lshift
|
||||||
|
local op1=self:d2b(a)
|
||||||
for i = 1, 32 do
|
local r=self:d2b(0)
|
||||||
if op1[i] == 1 or op2[i] == 1 then
|
|
||||||
r[i] = 1
|
if n < 32 and n > 0 then
|
||||||
else
|
for i=1,n do
|
||||||
r[i] = 0
|
for i=1,31 do
|
||||||
end
|
op1[i]=op1[i+1]
|
||||||
end
|
end
|
||||||
return self:b2d(r)
|
op1[32]=0
|
||||||
end
|
end
|
||||||
|
r=op1
|
||||||
function bit:_not(a) --bit:_not
|
end
|
||||||
local op1 = self:d2b(a)
|
return self:b2d(r)
|
||||||
local r = {}
|
end
|
||||||
|
|
||||||
for i = 1, 32 do
|
|
||||||
if op1[i] == 1 then
|
function bit:print(ta)
|
||||||
r[i] = 0
|
local sr=""
|
||||||
else
|
for i=1,32 do
|
||||||
r[i] = 1
|
sr=sr..ta[i]
|
||||||
end
|
end
|
||||||
end
|
print(sr)
|
||||||
return self:b2d(r)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function bit:_rshift(a, n) --bit:_rshift
|
|
||||||
local op1 = self:d2b(a)
|
|
||||||
local r = self:d2b(0)
|
|
||||||
|
|
||||||
if n < 32 and n > 0 then
|
|
||||||
for i = 1, n do
|
|
||||||
for i = 31, 1, -1 do
|
|
||||||
op1[i + 1] = op1[i]
|
|
||||||
end
|
|
||||||
op1[1] = 0
|
|
||||||
end
|
|
||||||
r = op1
|
|
||||||
end
|
|
||||||
return self:b2d(r)
|
|
||||||
end
|
|
||||||
|
|
||||||
function bit:_lshift(a, n) --bit:_lshift
|
|
||||||
local op1 = self:d2b(a)
|
|
||||||
local r = self:d2b(0)
|
|
||||||
|
|
||||||
if n < 32 and n > 0 then
|
|
||||||
for i = 1, n do
|
|
||||||
for i = 1, 31 do
|
|
||||||
op1[i] = op1[i + 1]
|
|
||||||
end
|
|
||||||
op1[32] = 0
|
|
||||||
end
|
|
||||||
r = op1
|
|
||||||
end
|
|
||||||
return self:b2d(r)
|
|
||||||
end
|
|
||||||
|
|
||||||
function bit:print(ta)
|
|
||||||
local sr = ""
|
|
||||||
for i = 1, 32 do
|
|
||||||
sr = sr .. ta[i]
|
|
||||||
end
|
|
||||||
-- print(sr)
|
|
||||||
end
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
string._htmlspecialchars_set = {}
|
string._htmlspecialchars_set = {}
|
||||||
string._htmlspecialchars_set["&"] = "&"
|
string._htmlspecialchars_set["&"] = "&"
|
||||||
string._htmlspecialchars_set["\""] = """
|
string._htmlspecialchars_set["\""] = """
|
||||||
|
|
@ -8,7 +10,7 @@ string._htmlspecialchars_set[">"] = ">"
|
||||||
--[[--
|
--[[--
|
||||||
将特殊字符转为 HTML 转义符
|
将特殊字符转为 HTML 转义符
|
||||||
~~~ lua
|
~~~ lua
|
||||||
-- print(string.htmlspecialchars("<ABC>"))
|
print(string.htmlspecialchars("<ABC>"))
|
||||||
-- 输出 <ABC>
|
-- 输出 <ABC>
|
||||||
~~~
|
~~~
|
||||||
@param string input 输入字符串
|
@param string input 输入字符串
|
||||||
|
|
@ -24,7 +26,7 @@ end
|
||||||
--[[--
|
--[[--
|
||||||
将 HTML 转义符还原为特殊字符,功能与 string.htmlspecialchars() 正好相反
|
将 HTML 转义符还原为特殊字符,功能与 string.htmlspecialchars() 正好相反
|
||||||
~~~ lua
|
~~~ lua
|
||||||
-- print(string.restorehtmlspecialchars("<ABC>"))
|
print(string.restorehtmlspecialchars("<ABC>"))
|
||||||
-- 输出 <ABC>
|
-- 输出 <ABC>
|
||||||
~~~
|
~~~
|
||||||
@param string input 输入字符串
|
@param string input 输入字符串
|
||||||
|
|
@ -40,7 +42,7 @@ end
|
||||||
--[[--
|
--[[--
|
||||||
将字符串中的 \n 换行符转换为 HTML 标记
|
将字符串中的 \n 换行符转换为 HTML 标记
|
||||||
~~~ lua
|
~~~ lua
|
||||||
-- print(string.nl2br("Hello\nWorld"))
|
print(string.nl2br("Hello\nWorld"))
|
||||||
-- 输出
|
-- 输出
|
||||||
-- Hello<br />World
|
-- Hello<br />World
|
||||||
~~~
|
~~~
|
||||||
|
|
@ -54,7 +56,7 @@ end
|
||||||
--[[--
|
--[[--
|
||||||
将字符串中的特殊字符和 \n 换行符转换为 HTML 转移符和标记
|
将字符串中的特殊字符和 \n 换行符转换为 HTML 转移符和标记
|
||||||
~~~ lua
|
~~~ lua
|
||||||
-- print(string.nl2br("<Hello>\nWorld"))
|
print(string.nl2br("<Hello>\nWorld"))
|
||||||
-- 输出
|
-- 输出
|
||||||
-- <Hello><br />World
|
-- <Hello><br />World
|
||||||
~~~
|
~~~
|
||||||
|
|
@ -86,10 +88,10 @@ local res = string.split(input, "-+-")
|
||||||
function string.split(input, delimiter)
|
function string.split(input, delimiter)
|
||||||
input = tostring(input)
|
input = tostring(input)
|
||||||
delimiter = tostring(delimiter)
|
delimiter = tostring(delimiter)
|
||||||
if (delimiter == '') then return false end
|
if (delimiter=='') then return false end
|
||||||
local pos, arr = 0, {}
|
local pos,arr = 0, {}
|
||||||
-- for each divider found
|
-- for each divider found
|
||||||
for st, sp in function() return string.find(input, delimiter, pos, true) end do
|
for st,sp in function() return string.find(input, delimiter, pos, true) end do
|
||||||
table.insert(arr, string.sub(input, pos, st - 1))
|
table.insert(arr, string.sub(input, pos, st - 1))
|
||||||
pos = sp + 1
|
pos = sp + 1
|
||||||
end
|
end
|
||||||
|
|
@ -101,7 +103,7 @@ end
|
||||||
去除输入字符串头部的空白字符,返回结果
|
去除输入字符串头部的空白字符,返回结果
|
||||||
~~~ lua
|
~~~ lua
|
||||||
local input = " ABC"
|
local input = " ABC"
|
||||||
-- print(string.ltrim(input))
|
print(string.ltrim(input))
|
||||||
-- 输出 ABC,输入字符串前面的两个空格被去掉了
|
-- 输出 ABC,输入字符串前面的两个空格被去掉了
|
||||||
~~~
|
~~~
|
||||||
空白字符包括:
|
空白字符包括:
|
||||||
|
|
@ -121,7 +123,7 @@ end
|
||||||
去除输入字符串尾部的空白字符,返回结果
|
去除输入字符串尾部的空白字符,返回结果
|
||||||
~~~ lua
|
~~~ lua
|
||||||
local input = "ABC "
|
local input = "ABC "
|
||||||
-- print(string.ltrim(input))
|
print(string.ltrim(input))
|
||||||
-- 输出 ABC,输入字符串最后的两个空格被去掉了
|
-- 输出 ABC,输入字符串最后的两个空格被去掉了
|
||||||
~~~
|
~~~
|
||||||
@param string input 输入字符串
|
@param string input 输入字符串
|
||||||
|
|
@ -147,7 +149,7 @@ end
|
||||||
将字符串的第一个字符转为大写,返回结果
|
将字符串的第一个字符转为大写,返回结果
|
||||||
~~~ lua
|
~~~ lua
|
||||||
local input = "hello"
|
local input = "hello"
|
||||||
-- print(string.ucfirst(input))
|
print(string.ucfirst(input))
|
||||||
-- 输出 Hello
|
-- 输出 Hello
|
||||||
~~~
|
~~~
|
||||||
@param string input 输入字符串
|
@param string input 输入字符串
|
||||||
|
|
@ -165,7 +167,7 @@ end
|
||||||
将字符串转换为符合 URL 传递要求的格式,并返回转换结果
|
将字符串转换为符合 URL 传递要求的格式,并返回转换结果
|
||||||
~~~ lua
|
~~~ lua
|
||||||
local input = "hello world"
|
local input = "hello world"
|
||||||
-- print(string.urlencode(input))
|
print(string.urlencode(input))
|
||||||
-- 输出
|
-- 输出
|
||||||
-- hello%20world
|
-- hello%20world
|
||||||
~~~
|
~~~
|
||||||
|
|
@ -186,7 +188,7 @@ end
|
||||||
将 URL 中的特殊字符还原,并返回结果
|
将 URL 中的特殊字符还原,并返回结果
|
||||||
~~~ lua
|
~~~ lua
|
||||||
local input = "hello%20world"
|
local input = "hello%20world"
|
||||||
-- print(string.urldecode(input))
|
print(string.urldecode(input))
|
||||||
-- 输出
|
-- 输出
|
||||||
-- hello world
|
-- hello world
|
||||||
~~~
|
~~~
|
||||||
|
|
@ -195,9 +197,9 @@ local input = "hello%20world"
|
||||||
@see string.urlencode
|
@see string.urlencode
|
||||||
]]
|
]]
|
||||||
function string.urldecode(input)
|
function string.urldecode(input)
|
||||||
input = string.gsub(input, "+", " ")
|
input = string.gsub (input, "+", " ")
|
||||||
input = string.gsub(input, "%%(%x%x)", function(h) return string.char(checknumber(h, 16)) end)
|
input = string.gsub (input, "%%(%x%x)", function(h) return string.char(checknumber(h,16)) end)
|
||||||
input = string.gsub(input, "\r\n", "\n")
|
input = string.gsub (input, "\r\n", "\n")
|
||||||
return input
|
return input
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -205,7 +207,7 @@ end
|
||||||
计算 UTF8 字符串的长度,每一个中文算一个字符
|
计算 UTF8 字符串的长度,每一个中文算一个字符
|
||||||
~~~ lua
|
~~~ lua
|
||||||
local input = "你好World"
|
local input = "你好World"
|
||||||
-- print(string.utf8len(input))
|
print(string.utf8len(input))
|
||||||
-- 输出 7
|
-- 输出 7
|
||||||
~~~
|
~~~
|
||||||
@param string input 输入字符串
|
@param string input 输入字符串
|
||||||
|
|
@ -217,7 +219,7 @@ function string.utf8len(input)
|
||||||
local len = string.len(input)
|
local len = string.len(input)
|
||||||
local left = len
|
local left = len
|
||||||
local cnt = 0
|
local cnt = 0
|
||||||
local arr = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc }
|
local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}
|
||||||
while left ~= 0 do
|
while left ~= 0 do
|
||||||
local tmp = string.byte(input, -left)
|
local tmp = string.byte(input, -left)
|
||||||
local i = #arr
|
local i = #arr
|
||||||
|
|
@ -241,15 +243,15 @@ end
|
||||||
]]
|
]]
|
||||||
function string.utf8sub(input, index, endIndex)
|
function string.utf8sub(input, index, endIndex)
|
||||||
if input == nil or type(input) ~= "string" then return nil end
|
if input == nil or type(input) ~= "string" then return nil end
|
||||||
if not endIndex then
|
if not endIndex then
|
||||||
endIndex = index
|
endIndex = index
|
||||||
index = 1
|
index = 1
|
||||||
end
|
end
|
||||||
local len = string.len(input)
|
local len = string.len(input)
|
||||||
local left = len
|
local left = len
|
||||||
local cnt = 0
|
local cnt = 0
|
||||||
local head, tail = 0, 0
|
local head, tail = 0, 0
|
||||||
local arr = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc }
|
local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}
|
||||||
while left ~= 0 do
|
while left ~= 0 do
|
||||||
if cnt + 1 == index then
|
if cnt + 1 == index then
|
||||||
head = len - left + 1
|
head = len - left + 1
|
||||||
|
|
@ -276,7 +278,7 @@ end
|
||||||
--[[--
|
--[[--
|
||||||
将数值格式化为包含千分位分隔符的字符串
|
将数值格式化为包含千分位分隔符的字符串
|
||||||
~~~ lua
|
~~~ lua
|
||||||
-- print(string.formatnumberthousands(1924235))
|
print(string.formatnumberthousands(1924235))
|
||||||
-- 输出 1,924,235
|
-- 输出 1,924,235
|
||||||
~~~
|
~~~
|
||||||
@param number num 数值
|
@param number num 数值
|
||||||
|
|
@ -292,11 +294,12 @@ function string.formatnumberthousands(num)
|
||||||
return formatted
|
return formatted
|
||||||
end
|
end
|
||||||
|
|
||||||
function string.concat(...)
|
|
||||||
|
function string.concat( ... )
|
||||||
local str = {}
|
local str = {}
|
||||||
local tem = { ... }
|
local tem = {...}
|
||||||
for _, v in ipairs(tem) do
|
for _,v in ipairs(tem) do
|
||||||
str[#str + 1] = v
|
str[#str + 1] = v
|
||||||
end
|
end
|
||||||
return table.concat(str, "")
|
return table.concat(str , "")
|
||||||
end
|
end
|
||||||
|
|
@ -1,46 +1,46 @@
|
||||||
EventContext = FairyGUI.EventContext
|
EventContext = FairyGUI.EventContext
|
||||||
EventListener = FairyGUI.EventListener
|
EventListener = FairyGUI.EventListener
|
||||||
EventDispatcher = FairyGUI.EventDispatcher
|
EventDispatcher = FairyGUI.EventDispatcher
|
||||||
InputEvent = FairyGUI.InputEvent
|
InputEvent = FairyGUI.InputEvent
|
||||||
NTexture = FairyGUI.NTexture
|
NTexture = FairyGUI.NTexture
|
||||||
Container = FairyGUI.Container
|
Container = FairyGUI.Container
|
||||||
Image = FairyGUI.Image
|
Image = FairyGUI.Image
|
||||||
Stage = FairyGUI.Stage
|
Stage = FairyGUI.Stage
|
||||||
Controller = FairyGUI.Controller
|
Controller = FairyGUI.Controller
|
||||||
GObject = FairyGUI.GObject
|
GObject = FairyGUI.GObject
|
||||||
GGraph = FairyGUI.GGraph
|
GGraph = FairyGUI.GGraph
|
||||||
GGroup = FairyGUI.GGroup
|
GGroup = FairyGUI.GGroup
|
||||||
GImage = FairyGUI.GImage
|
GImage = FairyGUI.GImage
|
||||||
GLoader = FairyGUI.GLoader
|
GLoader = FairyGUI.GLoader
|
||||||
GMovieClip = FairyGUI.GMovieClip
|
GMovieClip = FairyGUI.GMovieClip
|
||||||
TextFormat = FairyGUI.TextFormat
|
TextFormat = FairyGUI.TextFormat
|
||||||
GTextField = FairyGUI.GTextField
|
GTextField = FairyGUI.GTextField
|
||||||
GRichTextField = FairyGUI.GRichTextField
|
GRichTextField = FairyGUI.GRichTextField
|
||||||
GTextInput = FairyGUI.GTextInput
|
GTextInput = FairyGUI.GTextInput
|
||||||
GComponent = FairyGUI.GComponent
|
GComponent = FairyGUI.GComponent
|
||||||
GList = FairyGUI.GList
|
GList = FairyGUI.GList
|
||||||
GRoot = FairyGUI.GRoot
|
GRoot = FairyGUI.GRoot
|
||||||
GLabel = FairyGUI.GLabel
|
GLabel = FairyGUI.GLabel
|
||||||
GButton = FairyGUI.GButton
|
GButton = FairyGUI.GButton
|
||||||
GComboBox = FairyGUI.GComboBox
|
GComboBox = FairyGUI.GComboBox
|
||||||
GProgressBar = FairyGUI.GProgressBar
|
GProgressBar = FairyGUI.GProgressBar
|
||||||
GSlider = FairyGUI.GSlider
|
GSlider = FairyGUI.GSlider
|
||||||
PopupMenu = FairyGUI.PopupMenu
|
PopupMenu = FairyGUI.PopupMenu
|
||||||
ScrollPane = FairyGUI.ScrollPane
|
ScrollPane = FairyGUI.ScrollPane
|
||||||
Transition = FairyGUI.Transition
|
Transition = FairyGUI.Transition
|
||||||
UIPackage = FairyGUI.UIPackage
|
UIPackage = FairyGUI.UIPackage
|
||||||
Window = FairyGUI.Window
|
Window = FairyGUI.Window
|
||||||
GObjectPool = FairyGUI.GObjectPool
|
GObjectPool = FairyGUI.GObjectPool
|
||||||
Relations = FairyGUI.Relations
|
Relations = FairyGUI.Relations
|
||||||
RelationType = FairyGUI.RelationType
|
RelationType = FairyGUI.RelationType
|
||||||
UIPanel = FairyGUI.UIPanel
|
UIPanel = FairyGUI.UIPanel
|
||||||
UIPainter = FairyGUI.UIPainter
|
UIPainter = FairyGUI.UIPainter
|
||||||
TypingEffect = FairyGUI.TypingEffect
|
TypingEffect = FairyGUI.TypingEffect
|
||||||
GTween = FairyGUI.GTween
|
GTween = FairyGUI.GTween
|
||||||
GTweener = FairyGUI.GTweener
|
GTweener = FairyGUI.GTweener
|
||||||
EaseType = FairyGUI.EaseType
|
EaseType = FairyGUI.EaseType
|
||||||
|
|
||||||
fgui = {}
|
fgui = {}
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
用于继承FairyGUI的Window类,同时派生的Window类可以继续被继承。可以重写的方法有(与Window类里的同名方法含义完全相同)
|
用于继承FairyGUI的Window类,同时派生的Window类可以继续被继承。可以重写的方法有(与Window类里的同名方法含义完全相同)
|
||||||
|
|
@ -48,11 +48,11 @@ OnInit、DoHideAnimation、DoShowAnimation、OnShown、OnHide。
|
||||||
例子:
|
例子:
|
||||||
MyWinClass = fgui.window_class()
|
MyWinClass = fgui.window_class()
|
||||||
function MyWinClass:ctor()
|
function MyWinClass:ctor()
|
||||||
-- print('MyWinClass-ctor')
|
print('MyWinClass-ctor')
|
||||||
self.contentPane = UIPackage.CreateObject("Basics", "WindowA")
|
self.contentPane = UIPackage.CreateObject("Basics", "WindowA")
|
||||||
end
|
end
|
||||||
function MyWinClass:OnShown()
|
function MyWinClass:OnShown()
|
||||||
-- print('MyWinClass-onShown')
|
print('MyWinClass-onShown')
|
||||||
end
|
end
|
||||||
local win = MyWinClass.New()
|
local win = MyWinClass.New()
|
||||||
win:Show()
|
win:Show()
|
||||||
|
|
@ -74,7 +74,7 @@ function fgui.window_class(base)
|
||||||
tolua.setpeer(ins, t)
|
tolua.setpeer(ins, t)
|
||||||
ins:SetLuaPeer(t)
|
ins:SetLuaPeer(t)
|
||||||
if t.ctor then
|
if t.ctor then
|
||||||
t.ctor(ins, ...)
|
t.ctor(ins,...)
|
||||||
end
|
end
|
||||||
|
|
||||||
return ins
|
return ins
|
||||||
|
|
@ -92,12 +92,12 @@ MyButton = fgui.extension_class(GButton)
|
||||||
fgui.register_extension("ui://包名/我的按钮", MyButton)
|
fgui.register_extension("ui://包名/我的按钮", MyButton)
|
||||||
|
|
||||||
function MyButton:ctor() --当组件构建完成时此方法被调用
|
function MyButton:ctor() --当组件构建完成时此方法被调用
|
||||||
-- print(self:GetChild("n1"))
|
print(self:GetChild("n1"))
|
||||||
end
|
end
|
||||||
|
|
||||||
--添加自定义的方法和字段
|
--添加自定义的方法和字段
|
||||||
function MyButton:Test()
|
function MyButton:Test()
|
||||||
-- print('test')
|
print('test')
|
||||||
end
|
end
|
||||||
|
|
||||||
local get = tolua.initget(MyButton)
|
local get = tolua.initget(MyButton)
|
||||||
|
|
@ -133,7 +133,7 @@ function fgui.extension_class(base)
|
||||||
o.Extend = function(ins)
|
o.Extend = function(ins)
|
||||||
local t = {}
|
local t = {}
|
||||||
setmetatable(t, o)
|
setmetatable(t, o)
|
||||||
tolua.setpeer(ins, t)
|
tolua.setpeer(ins,t)
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ function ControllerManager.Init()
|
||||||
_controllerMap[GroupMgrController] = GroupMgrController.new()
|
_controllerMap[GroupMgrController] = GroupMgrController.new()
|
||||||
|
|
||||||
local hostIp = GetGameInfo("login_url")
|
local hostIp = GetGameInfo("login_url")
|
||||||
if (debug_print) then
|
if(debug_print) then
|
||||||
-- print("hostIp:::" .. hostIp)
|
print("hostIp:::"..hostIp)
|
||||||
end
|
end
|
||||||
ControllerManager.WebClient = NetClient.new(hostIp, "majiang", ConnectionProtocol.Web)
|
ControllerManager.WebClient = NetClient.new(hostIp, "majiang", ConnectionProtocol.Web)
|
||||||
--ControllerManager.GroupClient = nil--NetClient.new("http://192.168.0.1:8081/", "web_group", ConnectionProtocol.Web)
|
--ControllerManager.GroupClient = nil--NetClient.new("http://192.168.0.1:8081/", "web_group", ConnectionProtocol.Web)
|
||||||
end
|
end
|
||||||
|
|
@ -76,7 +76,6 @@ function ControllerManager.SetGameNetClient(client)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ControllerManager.OnConnect(code)
|
function ControllerManager.OnConnect(code)
|
||||||
-- print("=======================================ControllerManager", code)
|
|
||||||
if (code ~= SocketCode.Connect) then
|
if (code ~= SocketCode.Connect) then
|
||||||
ControllerManager.SetGameNetClient(nil)
|
ControllerManager.SetGameNetClient(nil)
|
||||||
if code ~= SocketCode.DisconnectByServer then
|
if code ~= SocketCode.DisconnectByServer then
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,12 @@ end
|
||||||
function TableBG.GetTableBG(game_id)
|
function TableBG.GetTableBG(game_id)
|
||||||
local id = -1
|
local id = -1
|
||||||
local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code)
|
local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code)
|
||||||
-- -- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id)
|
-- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id)
|
||||||
if json_data ~= nil then
|
if json_data ~= nil then
|
||||||
local config_data = json.decode(json_data)
|
local config_data = json.decode(json_data)
|
||||||
id = GetBG(config_data, game_id)
|
id = GetBG(config_data, game_id)
|
||||||
end
|
end
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
function TableBG.LoadTableBG(id, game_id, main_view, config)
|
function TableBG.LoadTableBG(id, game_id, main_view, config)
|
||||||
|
|
|
||||||
|
|
@ -303,9 +303,6 @@ function M:UpdateFamilyRoom(fgCtr, id)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
local roomList = self._group.rooms
|
local roomList = self._group.rooms
|
||||||
-- print("=========================playList,rooms")
|
|
||||||
pt(playList)
|
|
||||||
pt(roomList)
|
|
||||||
local roomCtr = ControllerManager.GetController(RoomController)
|
local roomCtr = ControllerManager.GetController(RoomController)
|
||||||
list_room.itemRenderer = function(index, obj)
|
list_room.itemRenderer = function(index, obj)
|
||||||
if index < #roomList then
|
if index < #roomList then
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ local function __NetTip(txt_msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function __OnGameConnectAction(state)
|
local function __OnGameConnectAction(state)
|
||||||
---- print("state:"..state)
|
--print("state:"..state)
|
||||||
NetResetConnectWindow.CloseNetReset()
|
NetResetConnectWindow.CloseNetReset()
|
||||||
if state == SocketCode.Connect then
|
if state == SocketCode.Connect then
|
||||||
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
|
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
|
||||||
|
|
@ -150,14 +150,14 @@ function ViewManager.ChangeView(id, game_id, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ViewManager.OnApplicationPause()
|
function ViewManager.OnApplicationPause()
|
||||||
-- -- print("game pause")
|
-- print("game pause")
|
||||||
if (_currenView ~= nil) then
|
if (_currenView ~= nil) then
|
||||||
_currenView:OnApplicationPause()
|
_currenView:OnApplicationPause()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ViewManager.OnApplicationActive()
|
function ViewManager.OnApplicationActive()
|
||||||
-- -- print("game active")
|
-- print("game active")
|
||||||
if (_currenView ~= nil) then
|
if (_currenView ~= nil) then
|
||||||
_currenView:OnApplicationActive()
|
_currenView:OnApplicationActive()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -152,35 +152,35 @@ function ShareScreenShot(n, callback)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function shareQRCodePicture(url, secene)
|
function shareQRCodePicture(url,secene)
|
||||||
---- print(debug.traceback())
|
--print(debug.traceback())
|
||||||
-- print(url)
|
print(url)
|
||||||
-- print(secene)
|
print(secene)
|
||||||
local json_data = {}
|
local json_data = {}
|
||||||
json_data["title"] = "湘北联赛"
|
json_data["title"] = "湘北联赛"
|
||||||
local mediaObject = {}
|
local mediaObject = {}
|
||||||
local filename = "qrcode" .. DataManager.SelfUser.account_id
|
local filename = "qrcode" .. DataManager.SelfUser.account_id
|
||||||
-- print(Application.persistentDataPath)
|
print(Application.persistentDataPath)
|
||||||
mediaObject["path"] = Application.persistentDataPath
|
mediaObject["path"] = Application.persistentDataPath
|
||||||
mediaObject["filename"] = filename
|
mediaObject["filename"] = filename
|
||||||
mediaObject["type"] = 1
|
mediaObject["type"] = 1
|
||||||
json_data["mediaObject"] = mediaObject
|
json_data["mediaObject"] = mediaObject
|
||||||
json_data["description"] = "一款现实中朋友约局休闲娱乐的场所!速度约朋友一起来玩吧!"
|
json_data["description"] = "一款现实中朋友约局休闲娱乐的场所!速度约朋友一起来玩吧!"
|
||||||
json_data["scene"] = secene
|
json_data["scene"] = secene
|
||||||
-- print("json_data==================")
|
print("json_data==================")
|
||||||
local json_str = json.encode(json_data)
|
local json_str = json.encode(json_data)
|
||||||
pt(json_str)
|
pt(json_str)
|
||||||
local tex2 = QRCodePicture.GenerateQRcode(url, 250, 250)
|
local tex2 = QRCodePicture.GenerateQRcode(url, 250, 250)
|
||||||
local tex1 = ResourcesManager.LoadObject("base/lobby/bg/bg.png", typeof(UnityEngine.Texture2D))
|
local tex1 = ResourcesManager.LoadObject("base/lobby/bg/bg.png",typeof(UnityEngine.Texture2D))
|
||||||
filename = filename .. ".jpg"
|
filename = filename ..".jpg"
|
||||||
-- print("text2==========")
|
print("text2==========")
|
||||||
-- print(tex2)
|
print(tex2)
|
||||||
-- print("text1==========")
|
print("text1==========")
|
||||||
-- print(tex1)
|
print(tex1)
|
||||||
-- print("filename==========")
|
print("filename==========")
|
||||||
-- print(filename)
|
print(filename)
|
||||||
QRCodePicture.CombanitePicture(tex1, tex2, 393, 1334 - 802 - 250, filename)
|
QRCodePicture.CombanitePicture(tex1,tex2,393,1334-802-250,filename)
|
||||||
|
|
||||||
GameApplication.Instance:ShareLink(1, json_str, nil)
|
GameApplication.Instance:ShareLink(1, json_str, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -201,9 +201,7 @@ local bg_url = nil
|
||||||
function LoadGameBg(url, main_view)
|
function LoadGameBg(url, main_view)
|
||||||
local win_mode = main_view:GetChild("win_mode")
|
local win_mode = main_view:GetChild("win_mode")
|
||||||
win_mode:RemoveChildren(0, -1, true)
|
win_mode:RemoveChildren(0, -1, true)
|
||||||
local tex_bg = ResourcesManager.LoadObjectByGroup(url .. ".png", typeof(UnityEngine.Texture), url)
|
local tex_bg = ResourcesManager.LoadObjectByGroup(url..".png",typeof(UnityEngine.Texture), url)
|
||||||
-- print("===========================mainbg")
|
|
||||||
-- print(url..".png",typeof(UnityEngine.Texture), url)
|
|
||||||
local bg = GImage()
|
local bg = GImage()
|
||||||
bg.texture = FairyGUI.NTexture(tex_bg)
|
bg.texture = FairyGUI.NTexture(tex_bg)
|
||||||
bg.width = win_mode.width
|
bg.width = win_mode.width
|
||||||
|
|
@ -364,7 +362,7 @@ function LuaPrint(lua_table, limit, indent, step)
|
||||||
end
|
end
|
||||||
|
|
||||||
function printlog(...)
|
function printlog(...)
|
||||||
if debug_print then
|
if debug_print then
|
||||||
-- print(...)
|
print(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -6,585 +6,236 @@ local EXClearingView = {}
|
||||||
local M = EXClearingView
|
local M = EXClearingView
|
||||||
|
|
||||||
function EXClearingView.new(blur_view)
|
function EXClearingView.new(blur_view)
|
||||||
setmetatable(M, { __index = ResultView })
|
setmetatable(M, { __index = ResultView })
|
||||||
local self = setmetatable({}, { __index = M })
|
local self = setmetatable({}, { __index = M })
|
||||||
self._full = true
|
self._full = true
|
||||||
ResultView.init(self, "ui://Main_Majiang/clearing")
|
ResultView.init(self, "ui://Main_Majiang/clearing_jiangxi")
|
||||||
|
|
||||||
self._currenIndex = 0
|
self._currenIndex = 0
|
||||||
self._blur_view = blur_view
|
self._blur_view = blur_view
|
||||||
self._close_zone = false
|
self._close_zone = false
|
||||||
self:InitMaPai()
|
-- self:InitMaPai()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:InitMaPai()
|
-- function M:InitMaPai()
|
||||||
self.maPaiCtr = self._view:GetController("mapai")
|
-- self.maPaiCtr = self._view:GetController("mapai")
|
||||||
self.maPaiCtr.selectedIndex = 0
|
-- self.maPaiCtr.selectedIndex = 0
|
||||||
|
|
||||||
self.maPaiList = {}
|
-- self.maPaiList = {}
|
||||||
|
|
||||||
for i = 1, 8 do
|
-- for i = 1, 8 do
|
||||||
local tempMP = self._view:GetChild("niao" .. i)
|
-- local tempMP = self._view:GetChild("niao" .. i)
|
||||||
table.insert(self.maPaiList, tempMP)
|
-- table.insert(self.maPaiList, tempMP)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function M:IsMapaiShow(niao, isShow)
|
|
||||||
if niao then
|
|
||||||
niao.visible = isShow
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:SetMaPaiValue(niao, value)
|
|
||||||
if niao then
|
|
||||||
niao.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:SetMaPaiColor(niao, num)
|
|
||||||
niao:GetController("color").selectedIndex = num
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:HideAllMapai()
|
|
||||||
for i = 1, #self.maPaiList do
|
|
||||||
self:IsMapaiShow(self.maPaiList[i], false)
|
|
||||||
self:SetMaPaiColor(self.maPaiList[i], 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:ShowSelectMaPai(niaoList)
|
|
||||||
if niaoList and #niaoList > 0 then
|
|
||||||
self.maPaiCtr.selectedIndex = 1
|
|
||||||
self:HideAllMapai()
|
|
||||||
for i = 1, #niaoList do
|
|
||||||
self:IsMapaiShow(self.maPaiList[i], true)
|
|
||||||
self:SetMaPaiValue(self.maPaiList[i], niaoList[i].card)
|
|
||||||
if niaoList[i].score > 0 then
|
|
||||||
self:SetMaPaiColor(self.maPaiList[i], 2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.maPaiCtr.selectedIndex = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:CalculatePaixingInfo(result)
|
|
||||||
self.WinList = {}
|
|
||||||
if result.info_list and #result.info_list > 0 then
|
|
||||||
for i = 1, #result.info_list do
|
|
||||||
if result.info_list[i].win_list and #result.info_list[i].win_list > 0 then
|
|
||||||
table.insert(self.WinList, result.info_list[i].win_list)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
printlog("牌型列表====>>>")
|
|
||||||
pt(self.WinList)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:SetPaixingxiangqing(num)
|
|
||||||
for i = 1, #self.PaiXingXiangQingCtrList do
|
|
||||||
if self.PaiXingXiangQingCtrList[i] then
|
|
||||||
self.PaiXingXiangQingCtrList[i].selectedIndex = num
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:InitData(over, room, result, total_result, callback)
|
function M:InitData(over, room, result, total_result, callback)
|
||||||
self._callback = callback
|
self._callback = callback
|
||||||
local _overCtr = self._view:GetController("over")
|
local showClearMainBtn = self._view:GetChild("btn_showClearMain")
|
||||||
local btn_confirm = self._view:GetChild("btn_confirm")
|
local nextRoundBtn = self._view:GetChild("btn_nextRound")
|
||||||
local btn_result = self._view:GetChild("btn_showResult")
|
local nextRoundBtn2 = self._view:GetChild("Btn_NextRound2")
|
||||||
local btn_close = self._view:GetChild("big_result"):GetChild("btn_close")
|
local endRound = self._view:GetChild("Btn_EndRound")
|
||||||
local _btnCtr = self._view:GetController("button")
|
local _overCtr = self._view:GetController("over")
|
||||||
local _sdkCtr = self._view:GetController("sdk")
|
local mainCtr = self._view:GetController("main")
|
||||||
local ctr_type = self._view:GetController("type")
|
local playerNum = self._view:GetController("playerNum")
|
||||||
|
|
||||||
self._view:GetChild("tex_roominfo").text = string.format("房号%s 局%s/%s %s", room.room_id, room.curren_round,
|
local peopleNum = room.room_config.people_num
|
||||||
room.room_config.round, os.date("%Y-%m-%d %H:%M:%S", os.time()))
|
|
||||||
self._view:GetChild("tex_gameinfo").text = string.gsub(room.room_config:GetDes2(), "\r", "")
|
|
||||||
|
|
||||||
if result then
|
playerNum.selectedIndex = peopleNum - 2
|
||||||
self:ShowSelectMaPai(result.niao)
|
|
||||||
self:CalculatePaixingInfo(result)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.PaiXingXiangQingCtrList = {}
|
showClearMainBtn.onClick:Set(function()
|
||||||
|
mainCtr.selectedIndex = 1
|
||||||
|
end)
|
||||||
|
|
||||||
local paixingxiangqing = self._view:GetChild("btn_detal")
|
nextRoundBtn.onClick:Set(function()
|
||||||
local fanhuipaixing = self._view:GetChild("btn_fanhuipaixing")
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
fanhuipaixing.visible = false
|
_gamectr:PlayerReady()
|
||||||
paixingxiangqing.visible = true
|
self:DestroyWithCallback()
|
||||||
paixingxiangqing.onClick:Add(function()
|
end)
|
||||||
paixingxiangqing.visible = false
|
|
||||||
fanhuipaixing.visible = true
|
|
||||||
self:SetPaixingxiangqing(1)
|
|
||||||
end)
|
|
||||||
fanhuipaixing.onClick:Add(function()
|
|
||||||
paixingxiangqing.visible = true
|
|
||||||
fanhuipaixing.visible = false
|
|
||||||
self:SetPaixingxiangqing(0)
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
nextRoundBtn2.onClick:Set(function()
|
||||||
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
_gamectr:PlayerReady()
|
||||||
|
self:DestroyWithCallback()
|
||||||
|
end)
|
||||||
|
|
||||||
if over ~= 2 then
|
endRound.onClick:Set(function()
|
||||||
if result.liuju then
|
ViewManager.ChangeView(ViewManager.View_Family)
|
||||||
ctr_type.selectedIndex = 3
|
end)
|
||||||
else
|
|
||||||
local info_list = result.info_list
|
|
||||||
for i = 1, #info_list do
|
|
||||||
local is_win = info_list[i].is_win
|
|
||||||
if is_win then
|
|
||||||
if info_list[i].seat == room.self_player.seat then
|
|
||||||
ctr_type.selectedIndex = 1
|
|
||||||
else
|
|
||||||
ctr_type.selectedIndex = 2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if over == 0 then
|
if over == 0 then
|
||||||
_btnCtr.selectedIndex = 0
|
_overCtr.selectedIndex = 0
|
||||||
_sdkCtr.selectedIndex = 1
|
self:fillResult0(room, peopleNum, result)
|
||||||
btn_confirm.onClick:Add(function()
|
else
|
||||||
local _gamectr = ControllerManager.GetController(GameController)
|
_overCtr.selectedIndex = 1
|
||||||
_gamectr:PlayerReady()
|
self:fillResult1(room, peopleNum, total_result)
|
||||||
self:DestroyWithCallback()
|
end
|
||||||
end)
|
|
||||||
self:AddClearItem(room, result.info_list, nil, over, result.niao, result.active_player)
|
|
||||||
elseif over == 1 then
|
|
||||||
_btnCtr.selectedIndex = 1
|
|
||||||
_sdkCtr.selectedIndex = 1
|
|
||||||
btn_result.onClick:Add(function()
|
|
||||||
self.maPaiCtr.selectedIndex = 0
|
|
||||||
_overCtr.selectedIndex = 1
|
|
||||||
_btnCtr.selectedIndex = 0
|
|
||||||
_sdkCtr.selectedIndex = 0
|
|
||||||
if self._qsinfo_view then
|
|
||||||
self._qsinfo_view:Dispose()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
btn_close.onClick:Add(function()
|
|
||||||
ViewManager.ChangeView(ViewManager.View_Lobby)
|
|
||||||
end)
|
|
||||||
|
|
||||||
self:AddClearItem(room, result.info_list, total_result.info_list, over, result.niao, result.active_player)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
_overCtr.selectedIndex = 1
|
|
||||||
self.maPaiCtr.selectedIndex = 0
|
|
||||||
btn_close.onClick:Add(function()
|
|
||||||
ViewManager.ChangeView(ViewManager.View_Lobby)
|
|
||||||
end)
|
|
||||||
|
|
||||||
self:AddClearItem(room, nil, total_result.info_list, over)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:AddClearItem(room, data, total_data, over, niao, active_player)
|
function M:fillResult0(room, peopleNum, result)
|
||||||
local n = over + 1
|
local config = ExtendManager.GetExtendConfig(room.game_id)
|
||||||
local list_view1 = self._view:GetChild("player_list_1")
|
local mode = config:GetGameInfo()
|
||||||
local list_view2 = self._view:GetChild("player_list_2")
|
local gamePlay = mode:LoadConfigToDetail(json.encode(room.room_config.config))
|
||||||
|
self._view:GetChild("Label_GamePlay").title = string.format("第%s/%s局,%s", room.curren_round,
|
||||||
|
room.room_config.round, gamePlay)
|
||||||
|
for i = 1, peopleNum do
|
||||||
|
local playerInfoComp = self._view:GetChild(string.format("Comp_Player%d", i))
|
||||||
|
|
||||||
if 0 == over or 1 == over then
|
local allCardsList = playerInfoComp:GetChild("list_allCards")
|
||||||
table.sort(data, function(a, b) return a.seat < b.seat end)
|
local huCardBtn = playerInfoComp:GetChild("Btn_Card_Hu")
|
||||||
list_view1:RemoveChildrenToPool()
|
local jiangMaList = playerInfoComp:GetChild("list_JiangMa")
|
||||||
|
local ziMoCtr = playerInfoComp:GetController("isZiMo")
|
||||||
|
local dianPaoCtr = playerInfoComp:GetController("isPao")
|
||||||
|
local isMeCtr = playerInfoComp:GetController("IsMe")
|
||||||
|
|
||||||
for i = 1, #data do
|
local infoList = result.info_list[i]
|
||||||
local item = list_view1:AddItemFromPool()
|
local playInfo = room:GetPlayerBySeat(infoList.seat)
|
||||||
self:FillItemData(room, data[i], item, active_player, niao)
|
local fzCardInfo = playInfo.fz_list
|
||||||
end
|
local fzInfoNum = #fzCardInfo
|
||||||
if #data == 3 then
|
local handInfoNum = #infoList.hand_card
|
||||||
list_view1.lineGap = 54
|
|
||||||
elseif #data == 2 then
|
self:fillHead(playInfo.self_user.head_url, playerInfoComp)
|
||||||
list_view1.lineGap = 108
|
|
||||||
end
|
playerInfoComp:GetChild("text_name").text = playInfo.self_user.nick_name
|
||||||
if 1 == over then
|
playerInfoComp:GetChild("Text_BoJing").text = infoList.jing_score >= 0 and
|
||||||
self:FillItemData2(room, total_data, list_view2)
|
string.format("+%d", infoList.jing_score) or infoList.jing_score
|
||||||
end
|
playerInfoComp:GetChild("Text_Gang").text = infoList.gang_score >= 0 and
|
||||||
elseif 2 == over then
|
string.format("+%d", infoList.gang_score) or infoList.gang_score
|
||||||
self:FillItemData2(room, total_data, list_view2)
|
playerInfoComp:GetChild("Text_Hu").text = infoList.hu_score >= 0 and string.format("+%d", infoList.hu_score) or
|
||||||
end
|
infoList.hu_score
|
||||||
|
playerInfoComp:GetChild("Text_Tatal").text = infoList.round_score >= 0 and
|
||||||
|
string.format("+%d", infoList.round_score) or infoList.round_score
|
||||||
|
|
||||||
|
for j = 1, fzInfoNum do
|
||||||
|
if fzCardInfo[j].type == FZType.Peng then
|
||||||
|
local item = allCardsList:AddItemFromPool("ui://Main_Majiang/Comp_FZ_3")
|
||||||
|
for l = 1, 3 do
|
||||||
|
local card = item:GetChild(string.format("Btn_Card%d", l))
|
||||||
|
card.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), fzCardInfo[j].card)
|
||||||
|
end
|
||||||
|
elseif fzCardInfo[j].type == FZType.Chi then
|
||||||
|
local item = allCardsList:AddItemFromPool("ui://Main_Majiang/Comp_FZ_3")
|
||||||
|
for l = 1, 3 do
|
||||||
|
local card = item:GetChild(string.format("Btn_Card%d", l))
|
||||||
|
card.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), fzCardInfo[j].opcard
|
||||||
|
[l])
|
||||||
|
end
|
||||||
|
elseif fzCardInfo[j].type == FZType.Gang or fzCardInfo[j].type == FZType.Gang_An or fzCardInfo[j].type == FZType.Gang_Peng then
|
||||||
|
local item = allCardsList:AddItemFromPool("ui://Main_Majiang/Comp_FZ_4")
|
||||||
|
for l = 1, 4 do
|
||||||
|
local card = item:GetChild(string.format("Btn_Card%d", l))
|
||||||
|
if fzCardInfo[j].type == FZType.Gang_An and j == 4 then
|
||||||
|
card.icon = "ui://Main_Majiang/202_00"
|
||||||
|
else
|
||||||
|
card.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), fzCardInfo[j].card)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local handCardItem = allCardsList:AddItemFromPool("ui://Main_Majiang/Comp_HandCard")
|
||||||
|
local handCardList = handCardItem:GetChild("list")
|
||||||
|
handCardList:SetVirtual()
|
||||||
|
handCardList.itemRenderer = function(index, obj)
|
||||||
|
obj.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), infoList.hand_card[index + 1])
|
||||||
|
end
|
||||||
|
handCardList.numItems = handInfoNum
|
||||||
|
allCardsList.width = 172 * fzInfoNum + 60 + (handInfoNum - 1) * 56 + 36 * (fzInfoNum)
|
||||||
|
|
||||||
|
if infoList.seat == room.self_player.seat then
|
||||||
|
isMeCtr.selectedIndex = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if infoList.is_win then
|
||||||
|
local winInfo = ""
|
||||||
|
for j = 1, #infoList.win_list do
|
||||||
|
winInfo = string.format("%s,%s", winInfo, Hu_Type_Name[infoList.win_list[j].type])
|
||||||
|
end
|
||||||
|
winInfo = string.sub(winInfo, 2, -1)
|
||||||
|
playerInfoComp:GetChild("text_huShow").text = winInfo
|
||||||
|
|
||||||
|
if room.isZiMoHu then
|
||||||
|
ziMoCtr.selectedIndex = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
huCardBtn.icon = string.format("ui://Main_Majiang/202_%d", infoList.win_card)
|
||||||
|
huCardBtn.visible = true
|
||||||
|
|
||||||
|
jiangMaList.visible = false
|
||||||
|
else
|
||||||
|
playerInfoComp:GetChild("text_huShow").text = ""
|
||||||
|
if not room.isZiMoHu and playInfo.self_user.account_id == result.active_player then
|
||||||
|
dianPaoCtr.selectedIndex = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
huCardBtn.visible = false
|
||||||
|
jiangMaList.visible = false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:FillItemData(room, data, item, active_player, niao)
|
function M:fillResult1(room, peopleNum, total_result)
|
||||||
local _gamectr = ControllerManager.GetController(GameController)
|
local gameNameAndRoomIDText = self._view:GetChild("Text_GameNameAndRoomID")
|
||||||
local p = room:GetPlayerBySeat(data["seat"])
|
local familyIDText = self._view:GetChild("Text_FamilyID")
|
||||||
item:GetChild("playerName").text = p.self_user.nick_name
|
for i, v in pairs(room.self_player.self_user.games) do
|
||||||
item:GetChild("lab_hp").text = "" --抓马
|
if v.game_id == room.game_id then
|
||||||
local user = room:GetPlayerBySeat(data["seat"]).self_user
|
gameNameAndRoomIDText.text = string.format("%s 房号:%s", v.name, room.room_id)
|
||||||
local head = item:GetChild('head'):GetChild('n4')
|
end
|
||||||
ImageLoad.Load(user.head_url, head)
|
end
|
||||||
|
if #gameNameAndRoomIDText.text <= 0 then
|
||||||
|
gameNameAndRoomIDText.text = string.format("房号:%s", room.room_id)
|
||||||
|
end
|
||||||
|
if room.group_id ~= 0 then
|
||||||
|
familyIDText.text = string.format("俱乐部:%s", room.group_id)
|
||||||
|
else
|
||||||
|
familyIDText.visible = false
|
||||||
|
end
|
||||||
|
self._view:GetChild("Text_RoundNum").text = string.format("局数:%s/%s", room.curren_round, room.room_config.round)
|
||||||
|
self._view:GetChild("Text_Time").text = os.date("%Y-%m-%d %H:%M:%S", os.time())
|
||||||
|
|
||||||
-- 手牌
|
for i = 1, peopleNum do
|
||||||
local hand_cards = data["hand_card"]
|
local resultInfoComp = self._view:GetChild(string.format("Comp_ResultInfo%d", i))
|
||||||
table.sort(hand_cards, ViewUtil.HandCardSort)
|
local totalInfoList = total_result.info_list[i]
|
||||||
local hand_list_view = item:GetChild("hand_card_list")
|
local playInfo = room:GetPlayerBySeat(totalInfoList.seat)
|
||||||
hand_list_view:RemoveChildrenToPool()
|
|
||||||
for i = 1, #hand_cards do
|
|
||||||
local card = hand_list_view:AddItemFromPool()
|
|
||||||
card.icon = "ui://Main_Majiang/202_" .. hand_cards[i]
|
|
||||||
end
|
|
||||||
hand_list_view.width = 52 * #hand_cards
|
|
||||||
|
|
||||||
local fz_card = p.fz_list
|
self:fillHead(playInfo.self_user.head_url, resultInfoComp)
|
||||||
local fz_card_list = item:GetChild("fz_card_list")
|
|
||||||
fz_card_list.width = 157 * #fz_card * 0.8
|
|
||||||
fz_card_list:RemoveChildrenToPool()
|
|
||||||
|
|
||||||
for i = 1, #fz_card do
|
resultInfoComp:GetChild('Text_Name').text = playInfo.self_user.nick_name
|
||||||
if fz_card[i].type == FZType.Peng then
|
resultInfoComp:GetChild('Text_ID').text = string.format("ID:%s", playInfo.self_user.account_id)
|
||||||
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3")
|
resultInfoComp:GetChild('Text_TotalScore').text = totalInfoList.total_score >= 0 and
|
||||||
for j = 1, 3 do
|
string.format("+%s", totalInfoList.total_score) or totalInfoList.total_score
|
||||||
local card = item:GetChild("card_" .. j)
|
resultInfoComp:GetChild('Text_ZiMo').text = string.format("自摸 %d次", totalInfoList.settle_log.zimo or 0)
|
||||||
card.icon = "ui://Main_Majiang/202_" .. fz_card[i].card
|
resultInfoComp:GetChild('Text_JiePao').text = string.format("接炮 %d次", totalInfoList.settle_log.jiepao or 0)
|
||||||
end
|
resultInfoComp:GetChild('Text_FangPao').text = string.format("放炮 %d次", totalInfoList.settle_log.fangpao or 0)
|
||||||
elseif fz_card[i].type == FZType.Chi then
|
resultInfoComp:GetChild('Text_AnGang').text = string.format("暗杠 %d次", totalInfoList.settle_log.an_kong or 0)
|
||||||
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3")
|
resultInfoComp:GetChild('Text_MingGang').text = string.format("明杠 %d次",
|
||||||
for j = 1, 3 do
|
totalInfoList.settle_log.ming_kong or 0)
|
||||||
local card = item:GetChild("card_" .. j)
|
resultInfoComp:GetChild('Text_FangGang').text = string.format("放杠 %d次",
|
||||||
card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. fz_card[i].opcard[j]
|
totalInfoList.settle_log.fanggang or 0)
|
||||||
end
|
|
||||||
elseif fz_card[i].type == FZType.Gang or fz_card[i].type == FZType.Gang_An or fz_card[i].type == FZType.Gang_Peng then
|
|
||||||
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_4")
|
|
||||||
for j = 1, 4 do
|
|
||||||
local card = item:GetChild("card_" .. j)
|
|
||||||
if fz_card[i].type == FZType.Gang_An and j == 4 then
|
|
||||||
card.icon = "ui://Main_Majiang/202_00"
|
|
||||||
else
|
|
||||||
card.icon = "ui://Main_Majiang/202_" .. fz_card[i].card
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local huadd = data["hu_score"]
|
resultInfoComp:GetController("win").selectedIndex = totalInfoList.total_score >= 0 and 1 or 0
|
||||||
local gangadd = data["gang_score"]
|
end
|
||||||
local jingadd = data["jing_score"]
|
|
||||||
local total = data["round_score"]
|
|
||||||
local geng_zhuan = data["geng_zhuan"]
|
|
||||||
local sp = " "
|
|
||||||
local str = "胡:" .. huadd .. "分"
|
|
||||||
if gangadd then
|
|
||||||
str = str .. sp .. "杠:" .. gangadd .. "分"
|
|
||||||
end
|
|
||||||
if jingadd then
|
|
||||||
str = str .. sp .. "博精:" .. jingadd .. "分"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
item:GetChild("score1").text = str
|
|
||||||
-- local total_score = data["total_score"]
|
|
||||||
if total >= 0 then
|
|
||||||
item:GetChild("score2").text = "+" .. total
|
|
||||||
item:GetChild("score2").grayed = false
|
|
||||||
else
|
|
||||||
item:GetChild("score2").text = total
|
|
||||||
item:GetChild("score2").grayed = true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--计算牌型
|
|
||||||
local totalPeson = DataManager.CurrenRoom.room_config.people_num - 1
|
|
||||||
local win_list = data["win_list"]
|
|
||||||
local is_win = data["is_win"] or false
|
|
||||||
local str1 = ""
|
|
||||||
sp = "、"
|
|
||||||
if is_win then
|
|
||||||
if win_list then
|
|
||||||
if DataManager.CurrenRoom.isZiMoHu then
|
|
||||||
str1 = "自摸"
|
|
||||||
else
|
|
||||||
str1 = "接炮"
|
|
||||||
end
|
|
||||||
for i = 1, #win_list do
|
|
||||||
local huName = Hu_Type_Name[win_list[i].type]
|
|
||||||
if huName then
|
|
||||||
str1 = str1 .. sp .. huName .. "x" .. win_list[i].score
|
|
||||||
end
|
|
||||||
end
|
|
||||||
str1 = str1 .. " +" .. huadd .. "分"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
printlog("输家============")
|
|
||||||
if DataManager.CurrenRoom.isZiMoHu then
|
|
||||||
printlog("自摸处理============")
|
|
||||||
--str1=""
|
|
||||||
if #self.WinList == 1 then
|
|
||||||
for i = 1, #self.WinList do
|
|
||||||
for j = 1, #self.WinList[i] do
|
|
||||||
local huName = Hu_Type_Name[self.WinList[i][j].type]
|
|
||||||
if huName then
|
|
||||||
if j == 1 then
|
|
||||||
str1 = str1 .. huName .. "x" .. self.WinList[i][j].score
|
|
||||||
else
|
|
||||||
str1 = str1 .. sp .. huName .. "x" .. self.WinList[i][j].score
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
str1 = str1 .. " " .. huadd .. "分"
|
|
||||||
else
|
|
||||||
printlog("服务端自摸计算异常===>>>")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
printlog("非自摸处理====>>>")
|
|
||||||
--点炮 一炮多响
|
|
||||||
local yipaoduoxiang = false
|
|
||||||
if #self.WinList > 1 then
|
|
||||||
yipaoduoxiang = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if yipaoduoxiang then
|
|
||||||
printlog("一炮多响====>>>")
|
|
||||||
str = "点炮"
|
|
||||||
local allTypeList = {}
|
|
||||||
local isHas = false
|
|
||||||
for i = 1, #self.WinList do
|
|
||||||
for j = 1, #self.WinList[i] do
|
|
||||||
isHas = IsHasDictionary(self.WinList[i][j].type, allTypeList)
|
|
||||||
if isHas == false then
|
|
||||||
table.insert(allTypeList, self.WinList[i][j].type)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if #allTypeList > 0 then
|
|
||||||
for i = 1, #allTypeList do
|
|
||||||
local huName = Hu_Type_Name[allTypeList[i]]
|
|
||||||
if huName then
|
|
||||||
str1 = str1 .. huName .. "、"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
str1 = str1 .. " " .. huadd .. "分"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if p.self_user.account_id == active_player and is_win == false and not data["liuju"] then
|
|
||||||
str1 = "点炮"
|
|
||||||
if #self.WinList == 1 then
|
|
||||||
for i = 1, # self.WinList do
|
|
||||||
for j = 1, #self.WinList[i] do
|
|
||||||
local huName = Hu_Type_Name[self.WinList[i][j].type]
|
|
||||||
if huName then
|
|
||||||
str1 = str1 .. sp .. huName .. "x" .. self.WinList[i][j].score
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
str1 = str1 .. " " .. huadd .. "分"
|
|
||||||
else
|
|
||||||
printlog("服务端自摸计算异常===>>>")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--
|
|
||||||
printlog("牌型计算==>>>", str1)
|
|
||||||
|
|
||||||
if data["ming_gang_num"] > 0 then
|
|
||||||
str1 = str1 .. " 明杠x" .. data["ming_gang_num"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if data["an_gang_num"] > 0 then
|
|
||||||
str1 = str1 .. " 暗杠x" .. data["an_gang_num"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if data["dian_gang_num"] > 0 then
|
|
||||||
str1 = str1 .. " 点杠x" .. data["dian_gang_num"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if gangadd ~= 0 then
|
|
||||||
if gangadd > 0 then
|
|
||||||
str1 = str1 .. " +" .. gangadd .. "分"
|
|
||||||
else
|
|
||||||
str1 = str1 .. " " .. gangadd .. "分"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if data["ma_geng_gong"] and data["ma_geng_gong"] ~= 0 then
|
|
||||||
if data["ma_geng_gong"] > 0 then
|
|
||||||
str1 = str1 .. " 马跟杠:+" .. data["ma_geng_gong"] .. "分"
|
|
||||||
else
|
|
||||||
str1 = str1 .. " 马跟杠:" .. data["ma_geng_gong"] .. "分"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if geng_zhuan and geng_zhuan ~= 0 then
|
|
||||||
if geng_zhuan > 0 then
|
|
||||||
str1 = str1 .. " 跟庄:+" .. geng_zhuan .. "分"
|
|
||||||
else
|
|
||||||
str1 = str1 .. " 跟庄:" .. geng_zhuan .. "分"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
item:GetChild("score3").text = str1
|
|
||||||
item:GetChild("score4").text = str1
|
|
||||||
local paixingCtr = item:GetController("detail")
|
|
||||||
table.insert(self.PaiXingXiangQingCtrList, paixingCtr)
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
local hp_nonnegative = room:checkHpNonnegative()
|
|
||||||
item:GetController("nonnegative").selectedIndex = hp_nonnegative and 1 or 0
|
|
||||||
if hp_nonnegative then
|
|
||||||
local hp_info = data.hp_info
|
|
||||||
local ctr_hp_limit = item:GetController("hp_limit")
|
|
||||||
local hp = d2ad(hp_info.round_actual_hp)
|
|
||||||
if hp >= 0 then hp = "+" .. tostring(hp) end
|
|
||||||
item:GetChild("tex_hp").text = hp
|
|
||||||
ctr_hp_limit.selectedIndex = hp_info.upper_limit and 1 or 0
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
item:GetController("win").selectedIndex = is_win and 0 or 1
|
|
||||||
if p.self_user.account_id == active_player and is_win == false and total < 0 then
|
|
||||||
item:GetController("win").selectedIndex = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
if is_win then
|
|
||||||
item:GetController("bg").selectedIndex = 1
|
|
||||||
else
|
|
||||||
item:GetController("bg").selectedIndex = 0
|
|
||||||
end
|
|
||||||
local win_card = item:GetChild("win_card")
|
|
||||||
win_card.icon = "ui://Main_Majiang/202_" .. data["win_card"]
|
|
||||||
|
|
||||||
if niao and #niao > 0 then
|
|
||||||
local currentNiaoList = self:CalculateNiao(niao, data["seat"])
|
|
||||||
if currentNiaoList and #currentNiaoList > 0 then
|
|
||||||
local lst_niao = item:GetChild("list_niao")
|
|
||||||
lst_niao:RemoveChildrenToPool()
|
|
||||||
for i = 1, #currentNiaoList do
|
|
||||||
if currentNiaoList[i].score > 0 then
|
|
||||||
local card_niao = lst_niao:AddItemFromPool()
|
|
||||||
card_niao.icon = "ui://Main_Majiang/202_" .. currentNiaoList[i].card
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if p.seat == room.banker_seat then
|
|
||||||
item:GetController("bank").selectedIndex = 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:CalculateNiao(niaoList, seat)
|
function M:fillHead(url, view)
|
||||||
local tempNiao = {}
|
ImageLoad.Load(url, view:GetChild("Btn_Head")._iconObject)
|
||||||
for i = 1, #niaoList do
|
|
||||||
if niaoList[i].seat == seat then
|
|
||||||
table.insert(tempNiao, niaoList[i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return tempNiao
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:FillItemData2(room, data, list)
|
|
||||||
-- 赋值result_info,聊天室分享需要
|
|
||||||
local player_list = {}
|
|
||||||
for i = 1, #data do
|
|
||||||
player_list[i] = {}
|
|
||||||
local user = room:GetPlayerBySeat(data[i].seat).self_user
|
|
||||||
player_list[i].id = user.account_id
|
|
||||||
player_list[i].hp_info = data[i].hp_info
|
|
||||||
player_list[i].score = data[i].total_score
|
|
||||||
player_list[i].house = room.owner_id == player_list[i].id and 1 or 0
|
|
||||||
player_list[i].nick = user.nick_name
|
|
||||||
player_list[i].head_url = user.head_url
|
|
||||||
|
|
||||||
local settle_log = data[i].settle_log
|
|
||||||
player_list[i].param = {}
|
|
||||||
player_list[i].param[1] = {}
|
|
||||||
player_list[i].param[1].key = "自摸次数:"
|
|
||||||
player_list[i].param[1].value = tostring(data[i].settle_log.zimo)
|
|
||||||
player_list[i].param[2] = {}
|
|
||||||
player_list[i].param[2].key = "接炮次数:"
|
|
||||||
player_list[i].param[2].value = tostring(data[i].settle_log.jie_pao)
|
|
||||||
player_list[i].param[3] = {}
|
|
||||||
player_list[i].param[3].key = "点炮次数:"
|
|
||||||
player_list[i].param[3].value = tostring(data[i].settle_log.dian_pao)
|
|
||||||
player_list[i].param[4] = {}
|
|
||||||
player_list[i].param[4].key = "暗杠次数:"
|
|
||||||
player_list[i].param[4].value = tostring(data[i].settle_log.an_kong)
|
|
||||||
player_list[i].param[5] = {}
|
|
||||||
player_list[i].param[5].key = "明杠次数:"
|
|
||||||
player_list[i].param[5].value = tostring(data[i].settle_log.ming_kong)
|
|
||||||
end
|
|
||||||
|
|
||||||
local round = room.room_config.round
|
|
||||||
self:GenerateRoomResultInfo(round, room.room_config:GetGameName(), room.room_id, room.create_time, player_list)
|
|
||||||
local big_result = self._view:GetChild("big_result")
|
|
||||||
big_result:GetChild("txt_room_info").text = string.format("%s 房号%s 局%s/%s", os.date("%Y/%m/%d", os.time()),
|
|
||||||
room.room_id, room.curren_round, room.room_config.round)
|
|
||||||
local lst_p = big_result:GetChild("player_list")
|
|
||||||
if #player_list == 3 then
|
|
||||||
lst_p.columnGap = 108
|
|
||||||
elseif #player_list == 2 then
|
|
||||||
lst_p.columnGap = 208
|
|
||||||
end
|
|
||||||
|
|
||||||
self:InitBigResult(room, 30)
|
|
||||||
local show_detail = room.hpOnOff == 1
|
|
||||||
for i = 1, lst_p.numChildren do
|
|
||||||
local com_p = lst_p:GetChildAt(i - 1)
|
|
||||||
com_p:GetController("jsicon").selectedIndex = i - 1
|
|
||||||
local list_param = com_p:GetChild("list_param")
|
|
||||||
for j = 1, list_param.numChildren do
|
|
||||||
local tem = list_param:GetChildAt(j - 1)
|
|
||||||
tem:GetChild("txt_value").textFormat.size = 30
|
|
||||||
end
|
|
||||||
if show_detail then
|
|
||||||
local score = 0
|
|
||||||
if com_p:GetController("pn").selectedIndex == 0 then
|
|
||||||
score = com_p:GetChild("txt_navigate").text
|
|
||||||
else
|
|
||||||
score = com_p:GetChild("txt_positive").text
|
|
||||||
end
|
|
||||||
score = score / room.score_times
|
|
||||||
com_p:GetChild("tex_detail_score").text = string.format("%s × %s倍", score, room.score_times)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if room.group_id ~= 0 then
|
|
||||||
big_result:GetController("group").selectedIndex = 1
|
|
||||||
end
|
|
||||||
DataManager.CurrenRoom = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:LoadHead(p, room)
|
|
||||||
local btn_head = self._view:GetChild("btn_head")
|
|
||||||
for i = 1, #room.player_list do
|
|
||||||
local player = room.player_list[i]
|
|
||||||
if p.seat == player.seat and player.self_user.head_url ~= "" then
|
|
||||||
ImageLoad.Load(player.self_user.head_url, btn_head.icon)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local prefix
|
local prefix
|
||||||
function M:GetPrefix()
|
function M:GetPrefix()
|
||||||
-- if not prefix then
|
-- if not prefix then
|
||||||
prefix = get_majiang_prefix(10)
|
prefix = get_majiang_prefix(10)
|
||||||
-- end
|
-- end
|
||||||
return prefix
|
return prefix
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:DestroyWithCallback()
|
function M:DestroyWithCallback()
|
||||||
if self._callback then
|
if self._callback then
|
||||||
self._callback()
|
self._callback()
|
||||||
end
|
end
|
||||||
self:Destroy()
|
self:Destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -1,605 +0,0 @@
|
||||||
require("Game.View.ResultView")
|
|
||||||
local Hu_Type_Name = import(".CS_Win_Type")
|
|
||||||
|
|
||||||
local EXClearingView = {}
|
|
||||||
|
|
||||||
local M = EXClearingView
|
|
||||||
|
|
||||||
function EXClearingView.new(blur_view)
|
|
||||||
setmetatable(M, { __index = ResultView })
|
|
||||||
local self = setmetatable({}, { __index = M })
|
|
||||||
self._full = true
|
|
||||||
ResultView.init(self, "ui://Main_Majiang/clearing_jiangxi")
|
|
||||||
|
|
||||||
self._currenIndex = 0
|
|
||||||
self._blur_view = blur_view
|
|
||||||
self._close_zone = false
|
|
||||||
self:InitMaPai()
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:InitMaPai()
|
|
||||||
self.maPaiCtr = self._view:GetController("mapai")
|
|
||||||
self.maPaiCtr.selectedIndex = 0
|
|
||||||
|
|
||||||
self.maPaiList = {}
|
|
||||||
|
|
||||||
for i = 1, 8 do
|
|
||||||
local tempMP = self._view:GetChild("niao" .. i)
|
|
||||||
table.insert(self.maPaiList, tempMP)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:IsMapaiShow(niao, isShow)
|
|
||||||
if niao then
|
|
||||||
niao.visible = isShow
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:SetMaPaiValue(niao, value)
|
|
||||||
if niao then
|
|
||||||
niao.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:SetMaPaiColor(niao, num)
|
|
||||||
niao:GetController("color").selectedIndex = num
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:HideAllMapai()
|
|
||||||
for i = 1, #self.maPaiList do
|
|
||||||
self:IsMapaiShow(self.maPaiList[i], false)
|
|
||||||
self:SetMaPaiColor(self.maPaiList[i], 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:ShowSelectMaPai(niaoList)
|
|
||||||
if niaoList and #niaoList > 0 then
|
|
||||||
self.maPaiCtr.selectedIndex = 1
|
|
||||||
self:HideAllMapai()
|
|
||||||
for i = 1, #niaoList do
|
|
||||||
self:IsMapaiShow(self.maPaiList[i], true)
|
|
||||||
self:SetMaPaiValue(self.maPaiList[i], niaoList[i].card)
|
|
||||||
if niaoList[i].score > 0 then
|
|
||||||
self:SetMaPaiColor(self.maPaiList[i], 2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.maPaiCtr.selectedIndex = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:CalculatePaixingInfo(result)
|
|
||||||
self.WinList = {}
|
|
||||||
if result.info_list and #result.info_list > 0 then
|
|
||||||
for i = 1, #result.info_list do
|
|
||||||
if result.info_list[i].win_list and #result.info_list[i].win_list > 0 then
|
|
||||||
table.insert(self.WinList, result.info_list[i].win_list)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
printlog("牌型列表====>>>")
|
|
||||||
pt(self.WinList)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:SetPaixingxiangqing(num)
|
|
||||||
for i = 1, #self.PaiXingXiangQingCtrList do
|
|
||||||
if self.PaiXingXiangQingCtrList[i] then
|
|
||||||
self.PaiXingXiangQingCtrList[i].selectedIndex = num
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:InitData(over, room, result, total_result, callback)
|
|
||||||
self._callback = callback
|
|
||||||
local _overCtr = self._view:GetController("over")
|
|
||||||
local btn_confirm = self._view:GetChild("btn_confirm")
|
|
||||||
local btn_result = self._view:GetChild("btn_showResult")
|
|
||||||
local btn_close = self._view:GetChild("big_result"):GetChild("btn_close")
|
|
||||||
local _btnCtr = self._view:GetController("button")
|
|
||||||
local _sdkCtr = self._view:GetController("sdk")
|
|
||||||
local ctr_type = self._view:GetController("type")
|
|
||||||
|
|
||||||
self._view:GetChild("tex_roominfo").text = string.format("房号%s 局%s/%s %s", room.room_id, room.curren_round,
|
|
||||||
room.room_config.round, os.date("%Y-%m-%d %H:%M:%S", os.time()))
|
|
||||||
self._view:GetChild("tex_gameinfo").text = string.gsub(room.room_config:GetDes2(), "\r", "")
|
|
||||||
|
|
||||||
if result then
|
|
||||||
self:ShowSelectMaPai(result.niao)
|
|
||||||
self:CalculatePaixingInfo(result)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.PaiXingXiangQingCtrList = {}
|
|
||||||
|
|
||||||
local paixingxiangqing = self._view:GetChild("btn_detal")
|
|
||||||
local fanhuipaixing = self._view:GetChild("btn_fanhuipaixing")
|
|
||||||
fanhuipaixing.visible = false
|
|
||||||
paixingxiangqing.visible = true
|
|
||||||
paixingxiangqing.onClick:Add(function()
|
|
||||||
paixingxiangqing.visible = false
|
|
||||||
fanhuipaixing.visible = true
|
|
||||||
self:SetPaixingxiangqing(1)
|
|
||||||
end)
|
|
||||||
fanhuipaixing.onClick:Add(function()
|
|
||||||
paixingxiangqing.visible = true
|
|
||||||
fanhuipaixing.visible = false
|
|
||||||
self:SetPaixingxiangqing(0)
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
if over ~= 2 then
|
|
||||||
if result.liuju then
|
|
||||||
ctr_type.selectedIndex = 3
|
|
||||||
else
|
|
||||||
local info_list = result.info_list
|
|
||||||
for i = 1, #info_list do
|
|
||||||
local is_win = info_list[i].is_win
|
|
||||||
if is_win then
|
|
||||||
if info_list[i].seat == room.self_player.seat then
|
|
||||||
ctr_type.selectedIndex = 1
|
|
||||||
else
|
|
||||||
ctr_type.selectedIndex = 2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if over == 0 then
|
|
||||||
_btnCtr.selectedIndex = 0
|
|
||||||
_sdkCtr.selectedIndex = 1
|
|
||||||
btn_confirm.onClick:Add(function()
|
|
||||||
local _gamectr = ControllerManager.GetController(GameController)
|
|
||||||
_gamectr:PlayerReady()
|
|
||||||
self:DestroyWithCallback()
|
|
||||||
end)
|
|
||||||
self:AddClearItem(room, result.info_list, nil, over, result.niao, result.active_player)
|
|
||||||
elseif over == 1 then
|
|
||||||
_btnCtr.selectedIndex = 1
|
|
||||||
_sdkCtr.selectedIndex = 1
|
|
||||||
btn_result.onClick:Add(function()
|
|
||||||
self.maPaiCtr.selectedIndex = 0
|
|
||||||
_overCtr.selectedIndex = 1
|
|
||||||
_btnCtr.selectedIndex = 0
|
|
||||||
_sdkCtr.selectedIndex = 0
|
|
||||||
if self._qsinfo_view then
|
|
||||||
self._qsinfo_view:Dispose()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
btn_close.onClick:Add(function()
|
|
||||||
ViewManager.ChangeView(ViewManager.View_Lobby)
|
|
||||||
end)
|
|
||||||
|
|
||||||
self:AddClearItem(room, result.info_list, total_result.info_list, over, result.niao, result.active_player)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
_overCtr.selectedIndex = 1
|
|
||||||
self.maPaiCtr.selectedIndex = 0
|
|
||||||
btn_close.onClick:Add(function()
|
|
||||||
ViewManager.ChangeView(ViewManager.View_Lobby)
|
|
||||||
end)
|
|
||||||
|
|
||||||
self:AddClearItem(room, nil, total_result.info_list, over)
|
|
||||||
end
|
|
||||||
-----------------------lingmeng----------------------------
|
|
||||||
local showClearMainBtn = self._view:GetChild("btn_showClearMain")
|
|
||||||
local nextRoundBtn = self._view:GetChild("btn_nextRound")
|
|
||||||
local MainCtr = self._view:GetController("main")
|
|
||||||
|
|
||||||
showClearMainBtn.onClick:Set(function()
|
|
||||||
MainCtr.selectedIndex = 1
|
|
||||||
end)
|
|
||||||
|
|
||||||
nextRoundBtn.onClick:Set(function()
|
|
||||||
local _gamectr = ControllerManager.GetController(GameController)
|
|
||||||
_gamectr:PlayerReady()
|
|
||||||
self:DestroyWithCallback()
|
|
||||||
end)
|
|
||||||
-----------------------------------------------------------
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:AddClearItem(room, data, total_data, over, niao, active_player)
|
|
||||||
local n = over + 1
|
|
||||||
local list_view1 = self._view:GetChild("player_list_1")
|
|
||||||
local list_view2 = self._view:GetChild("player_list_2")
|
|
||||||
|
|
||||||
if 0 == over or 1 == over then
|
|
||||||
table.sort(data, function(a, b) return a.seat < b.seat end)
|
|
||||||
list_view1:RemoveChildrenToPool()
|
|
||||||
|
|
||||||
for i = 1, #data do
|
|
||||||
local item = list_view1:AddItemFromPool()
|
|
||||||
self:FillItemData(room, data[i], item, active_player, niao)
|
|
||||||
end
|
|
||||||
if #data == 3 then
|
|
||||||
list_view1.lineGap = 54
|
|
||||||
elseif #data == 2 then
|
|
||||||
list_view1.lineGap = 108
|
|
||||||
end
|
|
||||||
if 1 == over then
|
|
||||||
self:FillItemData2(room, total_data, list_view2)
|
|
||||||
end
|
|
||||||
elseif 2 == over then
|
|
||||||
self:FillItemData2(room, total_data, list_view2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:FillItemData(room, data, item, active_player, niao)
|
|
||||||
local _gamectr = ControllerManager.GetController(GameController)
|
|
||||||
local p = room:GetPlayerBySeat(data["seat"])
|
|
||||||
item:GetChild("playerName").text = p.self_user.nick_name
|
|
||||||
item:GetChild("lab_hp").text = "" --抓马
|
|
||||||
local user = room:GetPlayerBySeat(data["seat"]).self_user
|
|
||||||
local head = item:GetChild('head'):GetChild('n4')
|
|
||||||
ImageLoad.Load(user.head_url, head)
|
|
||||||
|
|
||||||
-- 手牌
|
|
||||||
local hand_cards = data["hand_card"]
|
|
||||||
table.sort(hand_cards, ViewUtil.HandCardSort)
|
|
||||||
local hand_list_view = item:GetChild("hand_card_list")
|
|
||||||
hand_list_view:RemoveChildrenToPool()
|
|
||||||
for i = 1, #hand_cards do
|
|
||||||
local card = hand_list_view:AddItemFromPool()
|
|
||||||
card.icon = "ui://Main_Majiang/202_" .. hand_cards[i]
|
|
||||||
end
|
|
||||||
hand_list_view.width = 52 * #hand_cards
|
|
||||||
|
|
||||||
local fz_card = p.fz_list
|
|
||||||
local fz_card_list = item:GetChild("fz_card_list")
|
|
||||||
fz_card_list.width = 157 * #fz_card * 0.8
|
|
||||||
fz_card_list:RemoveChildrenToPool()
|
|
||||||
|
|
||||||
for i = 1, #fz_card do
|
|
||||||
if fz_card[i].type == FZType.Peng then
|
|
||||||
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3")
|
|
||||||
for j = 1, 3 do
|
|
||||||
local card = item:GetChild("card_" .. j)
|
|
||||||
card.icon = "ui://Main_Majiang/202_" .. fz_card[i].card
|
|
||||||
end
|
|
||||||
elseif fz_card[i].type == FZType.Chi then
|
|
||||||
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3")
|
|
||||||
for j = 1, 3 do
|
|
||||||
local card = item:GetChild("card_" .. j)
|
|
||||||
card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. fz_card[i].opcard[j]
|
|
||||||
end
|
|
||||||
elseif fz_card[i].type == FZType.Gang or fz_card[i].type == FZType.Gang_An or fz_card[i].type == FZType.Gang_Peng then
|
|
||||||
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_4")
|
|
||||||
for j = 1, 4 do
|
|
||||||
local card = item:GetChild("card_" .. j)
|
|
||||||
if fz_card[i].type == FZType.Gang_An and j == 4 then
|
|
||||||
card.icon = "ui://Main_Majiang/202_00"
|
|
||||||
else
|
|
||||||
card.icon = "ui://Main_Majiang/202_" .. fz_card[i].card
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local huadd = data["hu_score"]
|
|
||||||
local gangadd = data["gang_score"]
|
|
||||||
local jingadd = data["jing_score"]
|
|
||||||
local total = data["round_score"]
|
|
||||||
local geng_zhuan = data["geng_zhuan"]
|
|
||||||
local sp = " "
|
|
||||||
local str = "胡:" .. huadd .. "分"
|
|
||||||
if gangadd then
|
|
||||||
str = str .. sp .. "杠:" .. gangadd .. "分"
|
|
||||||
end
|
|
||||||
if jingadd then
|
|
||||||
str = str .. sp .. "博精:" .. jingadd .. "分"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
item:GetChild("score1").text = str
|
|
||||||
-- local total_score = data["total_score"]
|
|
||||||
if total >= 0 then
|
|
||||||
item:GetChild("score2").text = "+" .. total
|
|
||||||
item:GetChild("score2").grayed = false
|
|
||||||
else
|
|
||||||
item:GetChild("score2").text = total
|
|
||||||
item:GetChild("score2").grayed = true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--计算牌型
|
|
||||||
local totalPeson = DataManager.CurrenRoom.room_config.people_num - 1
|
|
||||||
local win_list = data["win_list"]
|
|
||||||
local is_win = data["is_win"] or false
|
|
||||||
local str1 = ""
|
|
||||||
sp = "、"
|
|
||||||
if is_win then
|
|
||||||
if win_list then
|
|
||||||
if DataManager.CurrenRoom.isZiMoHu then
|
|
||||||
str1 = "自摸"
|
|
||||||
else
|
|
||||||
str1 = "接炮"
|
|
||||||
end
|
|
||||||
for i = 1, #win_list do
|
|
||||||
local huName = Hu_Type_Name[win_list[i].type]
|
|
||||||
if huName then
|
|
||||||
str1 = str1 .. sp .. huName .. "x" .. win_list[i].score
|
|
||||||
end
|
|
||||||
end
|
|
||||||
str1 = str1 .. " +" .. huadd .. "分"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
printlog("输家============")
|
|
||||||
if DataManager.CurrenRoom.isZiMoHu then
|
|
||||||
printlog("自摸处理============")
|
|
||||||
--str1=""
|
|
||||||
if #self.WinList == 1 then
|
|
||||||
for i = 1, #self.WinList do
|
|
||||||
for j = 1, #self.WinList[i] do
|
|
||||||
local huName = Hu_Type_Name[self.WinList[i][j].type]
|
|
||||||
if huName then
|
|
||||||
if j == 1 then
|
|
||||||
str1 = str1 .. huName .. "x" .. self.WinList[i][j].score
|
|
||||||
else
|
|
||||||
str1 = str1 .. sp .. huName .. "x" .. self.WinList[i][j].score
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
str1 = str1 .. " " .. huadd .. "分"
|
|
||||||
else
|
|
||||||
printlog("服务端自摸计算异常===>>>")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
printlog("非自摸处理====>>>")
|
|
||||||
--点炮 一炮多响
|
|
||||||
local yipaoduoxiang = false
|
|
||||||
if #self.WinList > 1 then
|
|
||||||
yipaoduoxiang = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if yipaoduoxiang then
|
|
||||||
printlog("一炮多响====>>>")
|
|
||||||
str = "点炮"
|
|
||||||
local allTypeList = {}
|
|
||||||
local isHas = false
|
|
||||||
for i = 1, #self.WinList do
|
|
||||||
for j = 1, #self.WinList[i] do
|
|
||||||
isHas = IsHasDictionary(self.WinList[i][j].type, allTypeList)
|
|
||||||
if isHas == false then
|
|
||||||
table.insert(allTypeList, self.WinList[i][j].type)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if #allTypeList > 0 then
|
|
||||||
for i = 1, #allTypeList do
|
|
||||||
local huName = Hu_Type_Name[allTypeList[i]]
|
|
||||||
if huName then
|
|
||||||
str1 = str1 .. huName .. "、"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
str1 = str1 .. " " .. huadd .. "分"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if p.self_user.account_id == active_player and is_win == false and not data["liuju"] then
|
|
||||||
str1 = "点炮"
|
|
||||||
if #self.WinList == 1 then
|
|
||||||
for i = 1, # self.WinList do
|
|
||||||
for j = 1, #self.WinList[i] do
|
|
||||||
local huName = Hu_Type_Name[self.WinList[i][j].type]
|
|
||||||
if huName then
|
|
||||||
str1 = str1 .. sp .. huName .. "x" .. self.WinList[i][j].score
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
str1 = str1 .. " " .. huadd .. "分"
|
|
||||||
else
|
|
||||||
printlog("服务端自摸计算异常===>>>")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--
|
|
||||||
printlog("牌型计算==>>>", str1)
|
|
||||||
|
|
||||||
if data["ming_gang_num"] > 0 then
|
|
||||||
str1 = str1 .. " 明杠x" .. data["ming_gang_num"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if data["an_gang_num"] > 0 then
|
|
||||||
str1 = str1 .. " 暗杠x" .. data["an_gang_num"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if data["dian_gang_num"] > 0 then
|
|
||||||
str1 = str1 .. " 点杠x" .. data["dian_gang_num"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if gangadd ~= 0 then
|
|
||||||
if gangadd > 0 then
|
|
||||||
str1 = str1 .. " +" .. gangadd .. "分"
|
|
||||||
else
|
|
||||||
str1 = str1 .. " " .. gangadd .. "分"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if data["ma_geng_gong"] and data["ma_geng_gong"] ~= 0 then
|
|
||||||
if data["ma_geng_gong"] > 0 then
|
|
||||||
str1 = str1 .. " 马跟杠:+" .. data["ma_geng_gong"] .. "分"
|
|
||||||
else
|
|
||||||
str1 = str1 .. " 马跟杠:" .. data["ma_geng_gong"] .. "分"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if geng_zhuan and geng_zhuan ~= 0 then
|
|
||||||
if geng_zhuan > 0 then
|
|
||||||
str1 = str1 .. " 跟庄:+" .. geng_zhuan .. "分"
|
|
||||||
else
|
|
||||||
str1 = str1 .. " 跟庄:" .. geng_zhuan .. "分"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
item:GetChild("score3").text = str1
|
|
||||||
item:GetChild("score4").text = str1
|
|
||||||
local paixingCtr = item:GetController("detail")
|
|
||||||
table.insert(self.PaiXingXiangQingCtrList, paixingCtr)
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
local hp_nonnegative = room:checkHpNonnegative()
|
|
||||||
item:GetController("nonnegative").selectedIndex = hp_nonnegative and 1 or 0
|
|
||||||
if hp_nonnegative then
|
|
||||||
local hp_info = data.hp_info
|
|
||||||
local ctr_hp_limit = item:GetController("hp_limit")
|
|
||||||
local hp = d2ad(hp_info.round_actual_hp)
|
|
||||||
if hp >= 0 then hp = "+" .. tostring(hp) end
|
|
||||||
item:GetChild("tex_hp").text = hp
|
|
||||||
ctr_hp_limit.selectedIndex = hp_info.upper_limit and 1 or 0
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
item:GetController("win").selectedIndex = is_win and 0 or 1
|
|
||||||
if p.self_user.account_id == active_player and is_win == false and total < 0 then
|
|
||||||
item:GetController("win").selectedIndex = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
if is_win then
|
|
||||||
item:GetController("bg").selectedIndex = 1
|
|
||||||
else
|
|
||||||
item:GetController("bg").selectedIndex = 0
|
|
||||||
end
|
|
||||||
local win_card = item:GetChild("win_card")
|
|
||||||
win_card.icon = "ui://Main_Majiang/202_" .. data["win_card"]
|
|
||||||
|
|
||||||
if niao and #niao > 0 then
|
|
||||||
local currentNiaoList = self:CalculateNiao(niao, data["seat"])
|
|
||||||
if currentNiaoList and #currentNiaoList > 0 then
|
|
||||||
local lst_niao = item:GetChild("list_niao")
|
|
||||||
lst_niao:RemoveChildrenToPool()
|
|
||||||
for i = 1, #currentNiaoList do
|
|
||||||
if currentNiaoList[i].score > 0 then
|
|
||||||
local card_niao = lst_niao:AddItemFromPool()
|
|
||||||
card_niao.icon = "ui://Main_Majiang/202_" .. currentNiaoList[i].card
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if p.seat == room.banker_seat then
|
|
||||||
item:GetController("bank").selectedIndex = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:CalculateNiao(niaoList, seat)
|
|
||||||
local tempNiao = {}
|
|
||||||
for i = 1, #niaoList do
|
|
||||||
if niaoList[i].seat == seat then
|
|
||||||
table.insert(tempNiao, niaoList[i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return tempNiao
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:FillItemData2(room, data, list)
|
|
||||||
-- 赋值result_info,聊天室分享需要
|
|
||||||
local player_list = {}
|
|
||||||
for i = 1, #data do
|
|
||||||
player_list[i] = {}
|
|
||||||
local user = room:GetPlayerBySeat(data[i].seat).self_user
|
|
||||||
player_list[i].id = user.account_id
|
|
||||||
player_list[i].hp_info = data[i].hp_info
|
|
||||||
player_list[i].score = data[i].total_score
|
|
||||||
player_list[i].house = room.owner_id == player_list[i].id and 1 or 0
|
|
||||||
player_list[i].nick = user.nick_name
|
|
||||||
player_list[i].head_url = user.head_url
|
|
||||||
|
|
||||||
local settle_log = data[i].settle_log
|
|
||||||
player_list[i].param = {}
|
|
||||||
player_list[i].param[1] = {}
|
|
||||||
player_list[i].param[1].key = "自摸次数:"
|
|
||||||
player_list[i].param[1].value = tostring(data[i].settle_log.zimo)
|
|
||||||
player_list[i].param[2] = {}
|
|
||||||
player_list[i].param[2].key = "接炮次数:"
|
|
||||||
player_list[i].param[2].value = tostring(data[i].settle_log.jie_pao)
|
|
||||||
player_list[i].param[3] = {}
|
|
||||||
player_list[i].param[3].key = "点炮次数:"
|
|
||||||
player_list[i].param[3].value = tostring(data[i].settle_log.dian_pao)
|
|
||||||
player_list[i].param[4] = {}
|
|
||||||
player_list[i].param[4].key = "暗杠次数:"
|
|
||||||
player_list[i].param[4].value = tostring(data[i].settle_log.an_kong)
|
|
||||||
player_list[i].param[5] = {}
|
|
||||||
player_list[i].param[5].key = "明杠次数:"
|
|
||||||
player_list[i].param[5].value = tostring(data[i].settle_log.ming_kong)
|
|
||||||
end
|
|
||||||
|
|
||||||
local round = room.room_config.round
|
|
||||||
self:GenerateRoomResultInfo(round, room.room_config:GetGameName(), room.room_id, room.create_time, player_list)
|
|
||||||
local big_result = self._view:GetChild("big_result")
|
|
||||||
big_result:GetChild("txt_room_info").text = string.format("%s 房号%s 局%s/%s", os.date("%Y/%m/%d", os.time()),
|
|
||||||
room.room_id, room.curren_round, room.room_config.round)
|
|
||||||
local lst_p = big_result:GetChild("player_list")
|
|
||||||
if #player_list == 3 then
|
|
||||||
lst_p.columnGap = 108
|
|
||||||
elseif #player_list == 2 then
|
|
||||||
lst_p.columnGap = 208
|
|
||||||
end
|
|
||||||
|
|
||||||
self:InitBigResult(room, 30)
|
|
||||||
local show_detail = room.hpOnOff == 1
|
|
||||||
for i = 1, lst_p.numChildren do
|
|
||||||
local com_p = lst_p:GetChildAt(i - 1)
|
|
||||||
com_p:GetController("jsicon").selectedIndex = i - 1
|
|
||||||
local list_param = com_p:GetChild("list_param")
|
|
||||||
for j = 1, list_param.numChildren do
|
|
||||||
local tem = list_param:GetChildAt(j - 1)
|
|
||||||
tem:GetChild("txt_value").textFormat.size = 30
|
|
||||||
end
|
|
||||||
if show_detail then
|
|
||||||
local score = 0
|
|
||||||
if com_p:GetController("pn").selectedIndex == 0 then
|
|
||||||
score = com_p:GetChild("txt_navigate").text
|
|
||||||
else
|
|
||||||
score = com_p:GetChild("txt_positive").text
|
|
||||||
end
|
|
||||||
score = score / room.score_times
|
|
||||||
com_p:GetChild("tex_detail_score").text = string.format("%s × %s倍", score, room.score_times)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if room.group_id ~= 0 then
|
|
||||||
big_result:GetController("group").selectedIndex = 1
|
|
||||||
end
|
|
||||||
DataManager.CurrenRoom = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:LoadHead(p, room)
|
|
||||||
local btn_head = self._view:GetChild("btn_head")
|
|
||||||
for i = 1, #room.player_list do
|
|
||||||
local player = room.player_list[i]
|
|
||||||
if p.seat == player.seat and player.self_user.head_url ~= "" then
|
|
||||||
ImageLoad.Load(player.self_user.head_url, btn_head.icon)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local prefix
|
|
||||||
function M:GetPrefix()
|
|
||||||
-- if not prefix then
|
|
||||||
prefix = get_majiang_prefix(10)
|
|
||||||
-- end
|
|
||||||
return prefix
|
|
||||||
end
|
|
||||||
|
|
||||||
function M:DestroyWithCallback()
|
|
||||||
if self._callback then
|
|
||||||
self._callback()
|
|
||||||
end
|
|
||||||
self:Destroy()
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
|
|
@ -306,7 +306,7 @@ end
|
||||||
|
|
||||||
function M:OneventResult1(evt_data)
|
function M:OneventResult1(evt_data)
|
||||||
local over = evt_data.type
|
local over = evt_data.type
|
||||||
printlog("OneventResult1")
|
print("OneventResult1")
|
||||||
pt(evt_data)
|
pt(evt_data)
|
||||||
--0:小结算 1:小大结算 2:大结算
|
--0:小结算 1:小大结算 2:大结算
|
||||||
self._room._reload_flag = false
|
self._room._reload_flag = false
|
||||||
|
|
|
||||||
|
|
@ -4,181 +4,181 @@ local M = EXGameInfo
|
||||||
|
|
||||||
|
|
||||||
function EXGameInfo.new(blur_view)
|
function EXGameInfo.new(blur_view)
|
||||||
setmetatable(M, { __index = IGameInfo })
|
setmetatable(M, { __index = IGameInfo })
|
||||||
local self = setmetatable({}, { __index = M })
|
local self = setmetatable({}, { __index = M })
|
||||||
self.class = "EXGameInfo"
|
self.class = "EXGameInfo"
|
||||||
UIPackage.AddPackage("extend/majiang/lichuan/ui/Info_MJ_LiChuan")
|
UIPackage.AddPackage("extend/majiang/lichuan/ui/Info_MJ_LiChuan")
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:FillData()
|
function M:FillData()
|
||||||
self._maxPlayer = 4 -- 默认玩家人数
|
self._maxPlayer = 4 -- 默认玩家人数
|
||||||
self._roundChoice = 3 -- 回合选项数
|
self._roundChoice = 3 -- 回合选项数
|
||||||
self._config = UIPackage.CreateObjectFromURL("ui://Info_MJ_LiChuan/Label_Detail_83")
|
self._config = UIPackage.CreateObjectFromURL("ui://Info_MJ_LiChuan/Label_Detail_83")
|
||||||
|
|
||||||
-- if oldGameVersion == 2 then
|
-- if oldGameVersion == 2 then
|
||||||
-- self._config:GetController("xipai").selectedIndex = 0
|
-- self._config:GetController("xipai").selectedIndex = 0
|
||||||
|
|
||||||
-- self.xipaiValueText = self._config:GetChild('xipaifen')
|
-- self.xipaiValueText = self._config:GetChild('xipaifen')
|
||||||
-- self.xipaiValueText.text = 1
|
-- self.xipaiValueText.text = 1
|
||||||
-- self.xipaiValue = 1
|
-- self.xipaiValue = 1
|
||||||
|
|
||||||
-- self.anchouValueText = self._config:GetChild('anchoufen')
|
-- self.anchouValueText = self._config:GetChild('anchoufen')
|
||||||
-- self.anchouValueText.text = 1
|
-- self.anchouValueText.text = 1
|
||||||
-- self.anchouValue = 1
|
-- self.anchouValue = 1
|
||||||
|
|
||||||
-- local btn_cr = self._config:GetChild('sdsrbtn')
|
-- local btn_cr = self._config:GetChild('sdsrbtn')
|
||||||
-- btn_cr.onClick:Set(
|
-- btn_cr.onClick:Set(
|
||||||
-- function()
|
-- function()
|
||||||
-- local gniv = GroupNumberInputView_Game.new(nil, function(num)
|
-- local gniv = GroupNumberInputView_Game.new(nil, function(num)
|
||||||
-- local value = limit
|
-- local value = limit
|
||||||
-- if otype == 1 then
|
-- if otype == 1 then
|
||||||
-- value = value + ad2d(num)
|
-- value = value + ad2d(num)
|
||||||
-- elseif otype == -1 then
|
-- elseif otype == -1 then
|
||||||
-- value = value - ad2d(num)
|
-- value = value - ad2d(num)
|
||||||
-- else
|
-- else
|
||||||
-- value = ad2d(num)
|
-- value = ad2d(num)
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
-- if value < 0 then
|
-- if value < 0 then
|
||||||
-- ViewUtil.ErrorTip(1, "输入数据异常!")
|
-- ViewUtil.ErrorTip(1, "输入数据异常!")
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
-- self.xipaiValueText.text = value / 1000
|
-- self.xipaiValueText.text = value / 1000
|
||||||
-- self.xipaiValue = value / 1000
|
-- self.xipaiValue = value / 1000
|
||||||
-- end, 3, nil)
|
-- end, 3, nil)
|
||||||
-- gniv:Show()
|
-- gniv:Show()
|
||||||
-- end
|
-- end
|
||||||
-- )
|
-- )
|
||||||
|
|
||||||
|
|
||||||
-- local btn_cr2 = self._config:GetChild('anchoubtn')
|
-- local btn_cr2 = self._config:GetChild('anchoubtn')
|
||||||
-- btn_cr2.onClick:Set(
|
-- btn_cr2.onClick:Set(
|
||||||
-- function()
|
-- function()
|
||||||
-- local gniv = GroupNumberInputView_Game.new(nil, function(num)
|
-- local gniv = GroupNumberInputView_Game.new(nil, function(num)
|
||||||
-- local value = limit
|
-- local value = limit
|
||||||
-- if otype == 1 then
|
-- if otype == 1 then
|
||||||
-- value = value + ad2d(num)
|
-- value = value + ad2d(num)
|
||||||
-- elseif otype == -1 then
|
-- elseif otype == -1 then
|
||||||
-- value = value - ad2d(num)
|
-- value = value - ad2d(num)
|
||||||
-- else
|
-- else
|
||||||
-- value = ad2d(num)
|
-- value = ad2d(num)
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
-- if value < 0 then
|
-- if value < 0 then
|
||||||
-- ViewUtil.ErrorTip(1, "输入数据异常!")
|
-- ViewUtil.ErrorTip(1, "输入数据异常!")
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
-- self.anchouValueText.text = value / 1000
|
-- self.anchouValueText.text = value / 1000
|
||||||
-- self.anchouValue = value / 1000
|
-- self.anchouValue = value / 1000
|
||||||
-- end, 3, nil)
|
-- end, 3, nil)
|
||||||
-- gniv:Show()
|
-- gniv:Show()
|
||||||
-- end
|
-- end
|
||||||
-- )
|
-- )
|
||||||
-- end
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _help_url = "ui://Info_MJ_LiChuan/Com_help"
|
local _help_url = "ui://Info_MJ_LiChuan/Com_help"
|
||||||
function M:GetHelpUrl()
|
function M:GetHelpUrl()
|
||||||
return _help_url
|
return _help_url
|
||||||
end
|
end
|
||||||
|
|
||||||
local _icon_url = "ui://Info_MJ_LiChuan/icon"
|
local _icon_url = "ui://Info_MJ_LiChuan/icon"
|
||||||
function M:GetIconUrl()
|
function M:GetIconUrl()
|
||||||
return _icon_url
|
return _icon_url
|
||||||
end
|
end
|
||||||
|
|
||||||
local _icon_url1 = "ui://Info_MJ_LiChuan/icon1"
|
local _icon_url1 = "ui://Info_MJ_LiChuan/icon1"
|
||||||
function M:GetIconUrl1()
|
function M:GetIconUrl1()
|
||||||
return _icon_url1
|
return _icon_url1
|
||||||
end
|
end
|
||||||
|
|
||||||
local _play_list = {}
|
local _play_list = {}
|
||||||
function M:GetPlayList()
|
function M:GetPlayList()
|
||||||
return _play_list
|
return _play_list
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:SelectedConfigData()
|
function M:SelectedConfigData()
|
||||||
local _config = self._config
|
local _config = self._config
|
||||||
local round = _config:GetController("round").selectedIndex + 1
|
local round = _config:GetController("round").selectedIndex + 1
|
||||||
local people = _config:GetController("peopleNum").selectedIndex + 2
|
local people = _config:GetController("peopleNum").selectedIndex + 2
|
||||||
|
|
||||||
local zimo = _config:GetController("ZiMo").selectedIndex
|
local zimo = _config:GetController("ZiMo").selectedIndex
|
||||||
local jingbibo = _config:GetController("jingbibo").selectedIndex
|
local jingbibo = _config:GetController("jingbibo").selectedIndex
|
||||||
|
|
||||||
|
|
||||||
local xi_pai = false
|
local xi_pai = false
|
||||||
local xi_paifen = 0
|
local xi_paifen = 0
|
||||||
if _config:GetChild("xipai") then
|
if _config:GetChild("xipai") then
|
||||||
xi_pai = _config:GetChild("xipai").selected
|
xi_pai = _config:GetChild("xipai").selected
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------
|
------
|
||||||
local _data = {}
|
local _data = {}
|
||||||
_data["opt"] = round
|
_data["opt"] = round
|
||||||
_data["maxPlayers"] = people
|
_data["maxPlayers"] = people
|
||||||
|
|
||||||
_data["zimo"] = zimo
|
_data["zimo"] = zimo
|
||||||
_data["jingbibo"] = jingbibo
|
_data["jingbibo"] = jingbibo
|
||||||
_data["jiangma"] = 0
|
_data["jiangma"] = 0
|
||||||
|
|
||||||
_data['xi_pai'] = xi_pai
|
_data['xi_pai'] = xi_pai
|
||||||
|
|
||||||
local xi_pai_score = 0
|
local xi_pai_score = 0
|
||||||
local an_chou_score = 0
|
local an_chou_score = 0
|
||||||
-- if oldGameVersion == 2 then
|
-- if oldGameVersion == 2 then
|
||||||
-- xi_pai_score = self.xipaiValue
|
-- xi_pai_score = self.xipaiValue
|
||||||
-- an_chou_score = self.anchouValue
|
-- an_chou_score = self.anchouValue
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
_data['xi_pai_score'] = xi_pai_score * 1000
|
_data['xi_pai_score'] = xi_pai_score * 1000
|
||||||
_data['an_chou_score'] = an_chou_score * 1000
|
_data['an_chou_score'] = an_chou_score * 1000
|
||||||
|
|
||||||
|
|
||||||
return _data
|
return _data
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:LoadConfigData(data)
|
function M:LoadConfigData(data)
|
||||||
--printlog("加载房间配置=========>>>")
|
--printlog("加载房间配置=========>>>")
|
||||||
--pt(data)
|
--pt(data)
|
||||||
local _config = self._config
|
local _config = self._config
|
||||||
_config:GetController("round").selectedIndex = data.opt - 1
|
_config:GetController("round").selectedIndex = data.opt - 1
|
||||||
_config:GetController("play_list").selectedIndex = data.maxPlayers - 2
|
_config:GetController("play_list").selectedIndex = data.maxPlayers - 2
|
||||||
|
|
||||||
|
|
||||||
_config:GetController("fengding").selectedIndex = data.fengding
|
_config:GetController("fengding").selectedIndex = data.fengding
|
||||||
|
|
||||||
_config:GetController("wanfa").selectedIndex = data.wanfa
|
_config:GetController("wanfa").selectedIndex = data.wanfa
|
||||||
_config:GetChild("btn_qidui").selected = data.qiduijiafan
|
_config:GetChild("btn_qidui").selected = data.qiduijiafan
|
||||||
_config:GetChild("btn_shoudailong").selected = data.shoudailongjiafan
|
_config:GetChild("btn_shoudailong").selected = data.shoudailongjiafan
|
||||||
_config:GetChild("btn_loudilong").selected = data.loudilongjiafan
|
_config:GetChild("btn_loudilong").selected = data.loudilongjiafan
|
||||||
_config:GetChild("btn_bunengchi").selected = data.bunengchi
|
_config:GetChild("btn_bunengchi").selected = data.bunengchi
|
||||||
|
|
||||||
_config:GetChild("btn_doudizhu").selected = data.doudizhu
|
_config:GetChild("btn_doudizhu").selected = data.doudizhu
|
||||||
_config:GetChild("btn_doudizhufanbei").selected = data.doudizhufanbei
|
_config:GetChild("btn_doudizhufanbei").selected = data.doudizhufanbei
|
||||||
|
|
||||||
if _config:GetChild("xipai") then
|
if _config:GetChild("xipai") then
|
||||||
_config:GetChild("xipai").selected = data.xi_pai
|
_config:GetChild("xipai").selected = data.xi_pai
|
||||||
end
|
end
|
||||||
|
|
||||||
if oldGameVersion == 2 then
|
if oldGameVersion == 2 then
|
||||||
self.xipaiValueText.text = data.xi_pai_score / 1000
|
self.xipaiValueText.text = data.xi_pai_score / 1000
|
||||||
self.xipaiValue = data.xi_pai_score / 1000
|
self.xipaiValue = data.xi_pai_score / 1000
|
||||||
|
|
||||||
self.anchouValueText.text = data.an_chou_score / 1000
|
self.anchouValueText.text = data.an_chou_score / 1000
|
||||||
self.anchouValue = data.an_chou_score / 1000
|
self.anchouValue = data.an_chou_score / 1000
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:LoadConfigToDetail(data)
|
function M:LoadConfigToDetail(data)
|
||||||
local configData = json.decode(data)
|
local configData = json.decode(data)
|
||||||
local returnString = string.format("人数%s人%s%s,%s", configData.maxPlayers,
|
local returnString = string.format("人数%s人,%s,%s,%s", configData.maxPlayers,
|
||||||
configData.zimo and ",只能自摸" or ",自摸可点炮",
|
configData.zimo and "只能自摸" or "自摸可点炮",
|
||||||
configData.tuoguan and string.format(",%d秒后自动托管", configData.tuoguan_active_time) or "不能托管",
|
configData.tuoguan and string.format("%d秒后自动托管", configData.tuoguan_active_time) or "不能托管",
|
||||||
configData.jingbibo and "有精必博" or "有精可胡")
|
configData.jingbibo and "有精必博" or "有精可胡")
|
||||||
return returnString
|
return returnString
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
|
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
|
||||||
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
|
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
|
||||||
local MJMainView = require("main.majiang.MJMainView")
|
local MJMainView = require("main.majiang.MJMainView")
|
||||||
local EXClearingView = import(".EXClearingView_JiangXi")
|
local EXClearingView = import(".EXClearingView")
|
||||||
local TX_GameEvent = import(".GameEvent")
|
local TX_GameEvent = import(".GameEvent")
|
||||||
local HuTipView = import("main.majiang.HuTipView")
|
local HuTipView = import("main.majiang.HuTipView")
|
||||||
local SettingView = import(".EXSettingView")
|
local SettingView = import(".EXSettingView")
|
||||||
|
|
@ -473,7 +473,7 @@ function M:EventInit()
|
||||||
-- info:UpdateScore()
|
-- info:UpdateScore()
|
||||||
info._view:GetChild("zhanji").visible = true
|
info._view:GetChild("zhanji").visible = true
|
||||||
local num = data[i].hp_info.total_hp
|
local num = data[i].hp_info.total_hp
|
||||||
if num > 0 then
|
if num >= 0 then
|
||||||
info._view:GetController("text_color").selectedIndex = 0
|
info._view:GetController("text_color").selectedIndex = 0
|
||||||
info._view:GetChild("text_jifen").text = "+" .. d2ad(num)
|
info._view:GetChild("text_jifen").text = "+" .. d2ad(num)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ local function run_test(testname, func, input, should_work, output)
|
||||||
if status ~= nil then
|
if status ~= nil then
|
||||||
name = name .. statusmap[status]
|
name = name .. statusmap[status]
|
||||||
end
|
end
|
||||||
-- print(("[%s] %s"):format(name, serialise_value(value, false)))
|
print(("[%s] %s"):format(name, serialise_value(value, false)))
|
||||||
end
|
end
|
||||||
|
|
||||||
local result = { pcall(func, unpack(input)) }
|
local result = { pcall(func, unpack(input)) }
|
||||||
|
|
@ -200,7 +200,7 @@ local function run_test(testname, func, input, should_work, output)
|
||||||
test_count_total = test_count_total + 1
|
test_count_total = test_count_total + 1
|
||||||
|
|
||||||
local teststatus = { [true] = "PASS", [false] = "FAIL" }
|
local teststatus = { [true] = "PASS", [false] = "FAIL" }
|
||||||
-- print(("==> Test [%d] %s: %s"):format(test_count_total, testname,
|
print(("==> Test [%d] %s: %s"):format(test_count_total, testname,
|
||||||
teststatus[correct]))
|
teststatus[correct]))
|
||||||
|
|
||||||
status_line("Input", nil, input)
|
status_line("Input", nil, input)
|
||||||
|
|
@ -208,7 +208,7 @@ local function run_test(testname, func, input, should_work, output)
|
||||||
status_line("Expected", should_work, output)
|
status_line("Expected", should_work, output)
|
||||||
end
|
end
|
||||||
status_line("Received", success, result)
|
status_line("Received", success, result)
|
||||||
-- print()
|
print()
|
||||||
|
|
||||||
return correct, result
|
return correct, result
|
||||||
end
|
end
|
||||||
|
|
@ -216,11 +216,11 @@ end
|
||||||
local function run_test_group(tests)
|
local function run_test_group(tests)
|
||||||
local function run_helper(name, func, input)
|
local function run_helper(name, func, input)
|
||||||
if type(name) == "string" and #name > 0 then
|
if type(name) == "string" and #name > 0 then
|
||||||
-- print("==> " .. name)
|
print("==> " .. name)
|
||||||
end
|
end
|
||||||
-- Not a protected call, these functions should never generate errors.
|
-- Not a protected call, these functions should never generate errors.
|
||||||
func(unpack(input or {}))
|
func(unpack(input or {}))
|
||||||
-- print()
|
print()
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in ipairs(tests) do
|
for _, v in ipairs(tests) do
|
||||||
|
|
|
||||||
|
|
@ -18,49 +18,49 @@ local ilist = ilist
|
||||||
local _xpcall = {}
|
local _xpcall = {}
|
||||||
|
|
||||||
_xpcall.__call = function(self, ...)
|
_xpcall.__call = function(self, ...)
|
||||||
if jit then
|
if jit then
|
||||||
if nil == self.obj then
|
if nil == self.obj then
|
||||||
return xpcall(self.func, traceback, ...)
|
return xpcall(self.func, traceback, ...)
|
||||||
else
|
else
|
||||||
return xpcall(self.func, traceback, self.obj, ...)
|
return xpcall(self.func, traceback, self.obj, ...)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
|
|
||||||
if nil == self.obj then
|
if nil == self.obj then
|
||||||
local func = function() self.func(unpack(args, 1, maxn(args))) end
|
local func = function() self.func(unpack(args, 1, maxn(args))) end
|
||||||
return xpcall(func, traceback)
|
return xpcall(func, traceback)
|
||||||
else
|
else
|
||||||
local func = function() self.func(self.obj, unpack(args, 1, maxn(args))) end
|
local func = function() self.func(self.obj, unpack(args, 1, maxn(args))) end
|
||||||
return xpcall(func, traceback)
|
return xpcall(func, traceback)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_xpcall.__eq = function(lhs, rhs)
|
_xpcall.__eq = function(lhs, rhs)
|
||||||
return lhs.func == rhs.func and lhs.obj == rhs.obj
|
return lhs.func == rhs.func and lhs.obj == rhs.obj
|
||||||
end
|
end
|
||||||
|
|
||||||
local function xfunctor(func, obj)
|
local function xfunctor(func, obj)
|
||||||
return setmetatable({ func = func, obj = obj }, _xpcall)
|
return setmetatable({ func = func, obj = obj }, _xpcall)
|
||||||
end
|
end
|
||||||
|
|
||||||
local _pcall = {}
|
local _pcall = {}
|
||||||
|
|
||||||
_pcall.__call = function(self, ...)
|
_pcall.__call = function(self, ...)
|
||||||
if nil == self.obj then
|
if nil == self.obj then
|
||||||
return pcall(self.func, ...)
|
return pcall(self.func, ...)
|
||||||
else
|
else
|
||||||
return pcall(self.func, self.obj, ...)
|
return pcall(self.func, self.obj, ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_pcall.__eq = function(lhs, rhs)
|
_pcall.__eq = function(lhs, rhs)
|
||||||
return lhs.func == rhs.func and lhs.obj == rhs.obj
|
return lhs.func == rhs.func and lhs.obj == rhs.obj
|
||||||
end
|
end
|
||||||
|
|
||||||
local function functor(func, obj)
|
local function functor(func, obj)
|
||||||
return setmetatable({ func = func, obj = obj }, _pcall)
|
return setmetatable({ func = func, obj = obj }, _pcall)
|
||||||
end
|
end
|
||||||
|
|
||||||
local _event = {}
|
local _event = {}
|
||||||
|
|
@ -68,123 +68,122 @@ _event.__index = _event
|
||||||
|
|
||||||
--废弃
|
--废弃
|
||||||
function _event:Add(func, obj)
|
function _event:Add(func, obj)
|
||||||
assert(func)
|
assert(func)
|
||||||
|
|
||||||
if self.keepSafe then
|
if self.keepSafe then
|
||||||
func = xfunctor(func, obj)
|
func = xfunctor(func, obj)
|
||||||
else
|
else
|
||||||
func = functor(func, obj)
|
func = functor(func, obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.lock then
|
if self.lock then
|
||||||
local node = { value = func, _prev = 0, _next = 0, removed = true }
|
local node = { value = func, _prev = 0, _next = 0, removed = true }
|
||||||
table.insert(self.opList, function() self.list:pushnode(node) end)
|
table.insert(self.opList, function() self.list:pushnode(node) end)
|
||||||
return node
|
return node
|
||||||
else
|
else
|
||||||
return self.list:push(func)
|
return self.list:push(func)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--废弃
|
--废弃
|
||||||
function _event:Remove(func, obj)
|
function _event:Remove(func, obj)
|
||||||
for i, v in ilist(self.list) do
|
for i, v in ilist(self.list) do
|
||||||
if v.func == func and v.obj == obj then
|
if v.func == func and v.obj == obj then
|
||||||
if self.lock then
|
if self.lock then
|
||||||
table.insert(self.opList, function() self.list:remove(i) end)
|
table.insert(self.opList, function() self.list:remove(i) end)
|
||||||
else
|
else
|
||||||
self.list:remove(i)
|
self.list:remove(i)
|
||||||
end
|
end
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _event:CreateListener(func, obj)
|
function _event:CreateListener(func, obj)
|
||||||
if self.keepSafe then
|
if self.keepSafe then
|
||||||
func = xfunctor(func, obj)
|
func = xfunctor(func, obj)
|
||||||
else
|
else
|
||||||
func = functor(func, obj)
|
func = functor(func, obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
return { value = func, _prev = 0, _next = 0, removed = true }
|
return { value = func, _prev = 0, _next = 0, removed = true }
|
||||||
end
|
end
|
||||||
|
|
||||||
function _event:AddListener(handle)
|
function _event:AddListener(handle)
|
||||||
assert(handle)
|
assert(handle)
|
||||||
|
|
||||||
if self.lock then
|
if self.lock then
|
||||||
table.insert(self.opList, function() self.list:pushnode(handle) end)
|
table.insert(self.opList, function() self.list:pushnode(handle) end)
|
||||||
else
|
else
|
||||||
self.list:pushnode(handle)
|
self.list:pushnode(handle)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _event:RemoveListener(handle)
|
function _event:RemoveListener(handle)
|
||||||
assert(handle)
|
assert(handle)
|
||||||
|
|
||||||
if self.lock then
|
if self.lock then
|
||||||
table.insert(self.opList, function() self.list:remove(handle) end)
|
table.insert(self.opList, function() self.list:remove(handle) end)
|
||||||
else
|
else
|
||||||
self.list:remove(handle)
|
self.list:remove(handle)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _event:Count()
|
function _event:Count()
|
||||||
return self.list.length
|
return self.list.length
|
||||||
end
|
end
|
||||||
|
|
||||||
function _event:Clear()
|
function _event:Clear()
|
||||||
self.list:clear()
|
self.list:clear()
|
||||||
self.opList = {}
|
self.opList = {}
|
||||||
self.lock = false
|
self.lock = false
|
||||||
self.keepSafe = false
|
self.keepSafe = false
|
||||||
self.current = nil
|
self.current = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function _event:Dump()
|
function _event:Dump()
|
||||||
local count = 0
|
local count = 0
|
||||||
|
|
||||||
for _, v in ilist(self.list) do
|
for _, v in ilist(self.list) do
|
||||||
if v.obj then
|
if v.obj then
|
||||||
-- print("update function:", v.func, "object name:", v.obj.name)
|
print("update function:", v.func, "object name:", v.obj.name)
|
||||||
else
|
else
|
||||||
-- print("update function: ", v.func)
|
print("update function: ", v.func)
|
||||||
end
|
end
|
||||||
|
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print("all function is:", count)
|
print("all function is:", count)
|
||||||
end
|
end
|
||||||
|
|
||||||
_event.__call = function(self, ...)
|
_event.__call = function(self, ...)
|
||||||
local _list = self.list
|
local _list = self.list
|
||||||
self.lock = true
|
self.lock = true
|
||||||
local ilist = ilist
|
local ilist = ilist
|
||||||
|
|
||||||
for i, f in ilist(_list) do
|
for i, f in ilist(_list) do
|
||||||
self.current = i
|
self.current = i
|
||||||
local flag, msg = f(...)
|
local flag, msg = f(...)
|
||||||
|
if not flag then
|
||||||
|
_list:remove(i)
|
||||||
|
self.lock = false
|
||||||
|
error(msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if not flag then
|
local opList = self.opList
|
||||||
_list:remove(i)
|
self.lock = false
|
||||||
self.lock = false
|
|
||||||
error(msg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local opList = self.opList
|
for i, op in ipairs(opList) do
|
||||||
self.lock = false
|
op()
|
||||||
|
opList[i] = nil
|
||||||
for i, op in ipairs(opList) do
|
end
|
||||||
op()
|
|
||||||
opList[i] = nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function event(name, safe)
|
function event(name, safe)
|
||||||
safe = safe or false
|
safe = safe or false
|
||||||
return setmetatable({ name = name, keepSafe = safe, lock = false, opList = {}, list = list:new() }, _event)
|
return setmetatable({ name = name, keepSafe = safe, lock = false, opList = {}, list = list:new() }, _event)
|
||||||
end
|
end
|
||||||
|
|
||||||
UpdateBeat = event("Update", true)
|
UpdateBeat = event("Update", true)
|
||||||
|
|
@ -200,23 +199,23 @@ local CoUpdateBeat = CoUpdateBeat
|
||||||
|
|
||||||
--逻辑update
|
--逻辑update
|
||||||
function Update(deltaTime, unscaledDeltaTime)
|
function Update(deltaTime, unscaledDeltaTime)
|
||||||
Time:SetDeltaTime(deltaTime, unscaledDeltaTime)
|
Time:SetDeltaTime(deltaTime, unscaledDeltaTime)
|
||||||
UpdateBeat()
|
UpdateBeat()
|
||||||
end
|
end
|
||||||
|
|
||||||
function LateUpdate()
|
function LateUpdate()
|
||||||
LateUpdateBeat()
|
LateUpdateBeat()
|
||||||
CoUpdateBeat()
|
CoUpdateBeat()
|
||||||
Time:SetFrameCount()
|
Time:SetFrameCount()
|
||||||
end
|
end
|
||||||
|
|
||||||
--物理update
|
--物理update
|
||||||
function FixedUpdate(fixedDeltaTime)
|
function FixedUpdate(fixedDeltaTime)
|
||||||
Time:SetFixedDelta(fixedDeltaTime)
|
Time:SetFixedDelta(fixedDeltaTime)
|
||||||
FixedUpdateBeat()
|
FixedUpdateBeat()
|
||||||
end
|
end
|
||||||
|
|
||||||
function PrintEvents()
|
function PrintEvents()
|
||||||
UpdateBeat:Dump()
|
UpdateBeat:Dump()
|
||||||
FixedUpdateBeat:Dump()
|
FixedUpdateBeat:Dump()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
--
|
--
|
||||||
-- Example usage:
|
-- Example usage:
|
||||||
--
|
--
|
||||||
-- luajit -jbc -e 'local x=0; for i=1,1e6 do x=x+i end; -- print(x)'
|
-- luajit -jbc -e 'local x=0; for i=1,1e6 do x=x+i end; print(x)'
|
||||||
-- luajit -jbc=- foo.lua
|
-- luajit -jbc=- foo.lua
|
||||||
-- luajit -jbc=foo.list foo.lua
|
-- luajit -jbc=foo.list foo.lua
|
||||||
--
|
--
|
||||||
|
|
@ -24,10 +24,10 @@
|
||||||
--
|
--
|
||||||
-- local bc = require("jit.bc")
|
-- local bc = require("jit.bc")
|
||||||
--
|
--
|
||||||
-- local function foo() -- print("hello") end
|
-- local function foo() print("hello") end
|
||||||
--
|
--
|
||||||
-- bc.dump(foo) --> -- BYTECODE -- [...]
|
-- bc.dump(foo) --> -- BYTECODE -- [...]
|
||||||
-- -- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello"
|
-- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello"
|
||||||
--
|
--
|
||||||
-- local out = {
|
-- local out = {
|
||||||
-- -- Do something with each line:
|
-- -- Do something with each line:
|
||||||
|
|
@ -55,14 +55,10 @@ local stdout, stderr = io.stdout, io.stderr
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
local function ctlsub(c)
|
local function ctlsub(c)
|
||||||
if c == "\n" then
|
if c == "\n" then return "\\n"
|
||||||
return "\\n"
|
elseif c == "\r" then return "\\r"
|
||||||
elseif c == "\r" then
|
elseif c == "\t" then return "\\t"
|
||||||
return "\\r"
|
else return format("\\%03d", byte(c))
|
||||||
elseif c == "\t" then
|
|
||||||
return "\\t"
|
|
||||||
else
|
|
||||||
return format("\\%03d", byte(c))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -70,41 +66,41 @@ end
|
||||||
local function bcline(func, pc, prefix)
|
local function bcline(func, pc, prefix)
|
||||||
local ins, m = funcbc(func, pc)
|
local ins, m = funcbc(func, pc)
|
||||||
if not ins then return end
|
if not ins then return end
|
||||||
local ma, mb, mc = band(m, 7), band(m, 15 * 8), band(m, 15 * 128)
|
local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128)
|
||||||
local a = band(shr(ins, 8), 0xff)
|
local a = band(shr(ins, 8), 0xff)
|
||||||
local oidx = 6 * band(ins, 0xff)
|
local oidx = 6*band(ins, 0xff)
|
||||||
local op = sub(bcnames, oidx + 1, oidx + 6)
|
local op = sub(bcnames, oidx+1, oidx+6)
|
||||||
local s = format("%04d %s %-6s %3s ",
|
local s = format("%04d %s %-6s %3s ",
|
||||||
pc, prefix or " ", op, ma == 0 and "" or a)
|
pc, prefix or " ", op, ma == 0 and "" or a)
|
||||||
local d = shr(ins, 16)
|
local d = shr(ins, 16)
|
||||||
if mc == 13 * 128 then -- BCMjump
|
if mc == 13*128 then -- BCMjump
|
||||||
return format("%s=> %04d\n", s, pc + d - 0x7fff)
|
return format("%s=> %04d\n", s, pc+d-0x7fff)
|
||||||
end
|
end
|
||||||
if mb ~= 0 then
|
if mb ~= 0 then
|
||||||
d = band(d, 0xff)
|
d = band(d, 0xff)
|
||||||
elseif mc == 0 then
|
elseif mc == 0 then
|
||||||
return s .. "\n"
|
return s.."\n"
|
||||||
end
|
end
|
||||||
local kc
|
local kc
|
||||||
if mc == 10 * 128 then -- BCMstr
|
if mc == 10*128 then -- BCMstr
|
||||||
kc = funck(func, -d - 1)
|
kc = funck(func, -d-1)
|
||||||
kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub))
|
kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub))
|
||||||
elseif mc == 9 * 128 then -- BCMnum
|
elseif mc == 9*128 then -- BCMnum
|
||||||
kc = funck(func, d)
|
kc = funck(func, d)
|
||||||
if op == "TSETM " then kc = kc - 2 ^ 52 end
|
if op == "TSETM " then kc = kc - 2^52 end
|
||||||
elseif mc == 12 * 128 then -- BCMfunc
|
elseif mc == 12*128 then -- BCMfunc
|
||||||
local fi = funcinfo(funck(func, -d - 1))
|
local fi = funcinfo(funck(func, -d-1))
|
||||||
if fi.ffid then
|
if fi.ffid then
|
||||||
kc = vmdef.ffnames[fi.ffid]
|
kc = vmdef.ffnames[fi.ffid]
|
||||||
else
|
else
|
||||||
kc = fi.loc
|
kc = fi.loc
|
||||||
end
|
end
|
||||||
elseif mc == 5 * 128 then -- BCMuv
|
elseif mc == 5*128 then -- BCMuv
|
||||||
kc = funcuvname(func, d)
|
kc = funcuvname(func, d)
|
||||||
end
|
end
|
||||||
if ma == 5 then -- BCMuv
|
if ma == 5 then -- BCMuv
|
||||||
local ka = funcuvname(func, a)
|
local ka = funcuvname(func, a)
|
||||||
if kc then kc = ka .. " ; " .. kc else kc = ka end
|
if kc then kc = ka.." ; "..kc else kc = ka end
|
||||||
end
|
end
|
||||||
if mb ~= 0 then
|
if mb ~= 0 then
|
||||||
local b = shr(ins, 24)
|
local b = shr(ins, 24)
|
||||||
|
|
@ -112,17 +108,17 @@ local function bcline(func, pc, prefix)
|
||||||
return format("%s%3d %3d\n", s, b, d)
|
return format("%s%3d %3d\n", s, b, d)
|
||||||
end
|
end
|
||||||
if kc then return format("%s%3d ; %s\n", s, d, kc) end
|
if kc then return format("%s%3d ; %s\n", s, d, kc) end
|
||||||
if mc == 7 * 128 and d > 32767 then d = d - 65536 end -- BCMlits
|
if mc == 7*128 and d > 32767 then d = d - 65536 end -- BCMlits
|
||||||
return format("%s%3d\n", s, d)
|
return format("%s%3d\n", s, d)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Collect branch targets of a function.
|
-- Collect branch targets of a function.
|
||||||
local function bctargets(func)
|
local function bctargets(func)
|
||||||
local target = {}
|
local target = {}
|
||||||
for pc = 1, 1000000000 do
|
for pc=1,1000000000 do
|
||||||
local ins, m = funcbc(func, pc)
|
local ins, m = funcbc(func, pc)
|
||||||
if not ins then break end
|
if not ins then break end
|
||||||
if band(m, 15 * 128) == 13 * 128 then target[pc + shr(ins, 16) - 0x7fff] = true end
|
if band(m, 15*128) == 13*128 then target[pc+shr(ins, 16)-0x7fff] = true end
|
||||||
end
|
end
|
||||||
return target
|
return target
|
||||||
end
|
end
|
||||||
|
|
@ -132,7 +128,7 @@ local function bcdump(func, out, all)
|
||||||
if not out then out = stdout end
|
if not out then out = stdout end
|
||||||
local fi = funcinfo(func)
|
local fi = funcinfo(func)
|
||||||
if all and fi.children then
|
if all and fi.children then
|
||||||
for n = -1, -1000000000, -1 do
|
for n=-1,-1000000000,-1 do
|
||||||
local k = funck(func, n)
|
local k = funck(func, n)
|
||||||
if not k then break end
|
if not k then break end
|
||||||
if type(k) == "proto" then bcdump(k, out, true) end
|
if type(k) == "proto" then bcdump(k, out, true) end
|
||||||
|
|
@ -140,7 +136,7 @@ local function bcdump(func, out, all)
|
||||||
end
|
end
|
||||||
out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined))
|
out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined))
|
||||||
local target = bctargets(func)
|
local target = bctargets(func)
|
||||||
for pc = 1, 1000000000 do
|
for pc=1,1000000000 do
|
||||||
local s = bcline(func, pc, target[pc] and "=>")
|
local s = bcline(func, pc, target[pc] and "=>")
|
||||||
if not s then break end
|
if not s then break end
|
||||||
out:write(s)
|
out:write(s)
|
||||||
|
|
@ -191,3 +187,4 @@ return {
|
||||||
off = bclistoff,
|
off = bclistoff,
|
||||||
start = bcliston -- For -j command line option.
|
start = bcliston -- For -j command line option.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
--
|
--
|
||||||
-- Example usage:
|
-- Example usage:
|
||||||
--
|
--
|
||||||
-- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; -- print(x)"
|
-- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; print(x)"
|
||||||
-- luajit -jdump=im -e "for i=1,1000 do for j=1,1000 do end end" | less -R
|
-- luajit -jdump=im -e "for i=1,1000 do for j=1,1000 do end end" | less -R
|
||||||
-- luajit -jdump=is myapp.lua | less -R
|
-- luajit -jdump=is myapp.lua | less -R
|
||||||
-- luajit -jdump=-b myapp.lua
|
-- luajit -jdump=-b myapp.lua
|
||||||
|
|
@ -28,15 +28,15 @@
|
||||||
--
|
--
|
||||||
-- The following dump features are available (* marks the default):
|
-- The following dump features are available (* marks the default):
|
||||||
--
|
--
|
||||||
-- * t -- print a line for each started, ended or aborted trace (see also -jv).
|
-- * t Print a line for each started, ended or aborted trace (see also -jv).
|
||||||
-- * b Dump the traced bytecode.
|
-- * b Dump the traced bytecode.
|
||||||
-- * i Dump the IR (intermediate representation).
|
-- * i Dump the IR (intermediate representation).
|
||||||
-- r Augment the IR with register/stack slots.
|
-- r Augment the IR with register/stack slots.
|
||||||
-- s Dump the snapshot map.
|
-- s Dump the snapshot map.
|
||||||
-- * m Dump the generated machine code.
|
-- * m Dump the generated machine code.
|
||||||
-- x -- print each taken trace exit.
|
-- x Print each taken trace exit.
|
||||||
-- X -- print each taken trace exit and the contents of all registers.
|
-- X Print each taken trace exit and the contents of all registers.
|
||||||
-- a -- print the IR of aborted traces, too.
|
-- a Print the IR of aborted traces, too.
|
||||||
--
|
--
|
||||||
-- The output format can be set with the following characters:
|
-- The output format can be set with the following characters:
|
||||||
--
|
--
|
||||||
|
|
@ -89,9 +89,9 @@ local function fillsymtab_tr(tr, nexit)
|
||||||
t[traceexitstub(tr, 0)] = "exit"
|
t[traceexitstub(tr, 0)] = "exit"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for i = 0, nexit - 1 do
|
for i=0,nexit-1 do
|
||||||
local addr = traceexitstub(tr, i)
|
local addr = traceexitstub(tr, i)
|
||||||
if addr < 0 then addr = addr + 2 ^ 32 end
|
if addr < 0 then addr = addr + 2^32 end
|
||||||
t[addr] = tostring(i)
|
t[addr] = tostring(i)
|
||||||
end
|
end
|
||||||
local addr = traceexitstub(tr, nexit)
|
local addr = traceexitstub(tr, nexit)
|
||||||
|
|
@ -103,26 +103,26 @@ local function fillsymtab(tr, nexit)
|
||||||
local t = symtab
|
local t = symtab
|
||||||
if nexitsym == 0 then
|
if nexitsym == 0 then
|
||||||
local ircall = vmdef.ircall
|
local ircall = vmdef.ircall
|
||||||
for i = 0, #ircall do
|
for i=0,#ircall do
|
||||||
local addr = ircalladdr(i)
|
local addr = ircalladdr(i)
|
||||||
if addr ~= 0 then
|
if addr ~= 0 then
|
||||||
if addr < 0 then addr = addr + 2 ^ 32 end
|
if addr < 0 then addr = addr + 2^32 end
|
||||||
t[addr] = ircall[i]
|
t[addr] = ircall[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if nexitsym == 1000000 then -- Per-trace exit stubs.
|
if nexitsym == 1000000 then -- Per-trace exit stubs.
|
||||||
fillsymtab_tr(tr, nexit)
|
fillsymtab_tr(tr, nexit)
|
||||||
elseif nexit > nexitsym then -- Shared exit stubs.
|
elseif nexit > nexitsym then -- Shared exit stubs.
|
||||||
for i = nexitsym, nexit - 1 do
|
for i=nexitsym,nexit-1 do
|
||||||
local addr = traceexitstub(i)
|
local addr = traceexitstub(i)
|
||||||
if addr == nil then -- Fall back to per-trace exit stubs.
|
if addr == nil then -- Fall back to per-trace exit stubs.
|
||||||
fillsymtab_tr(tr, nexit)
|
fillsymtab_tr(tr, nexit)
|
||||||
setmetatable(symtab, symtabmt)
|
setmetatable(symtab, symtabmt)
|
||||||
nexit = 1000000
|
nexit = 1000000
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if addr < 0 then addr = addr + 2 ^ 32 end
|
if addr < 0 then addr = addr + 2^32 end
|
||||||
t[addr] = tostring(i)
|
t[addr] = tostring(i)
|
||||||
end
|
end
|
||||||
nexitsym = nexit
|
nexitsym = nexit
|
||||||
|
|
@ -140,18 +140,18 @@ local function dump_mcode(tr)
|
||||||
if not info then return end
|
if not info then return end
|
||||||
local mcode, addr, loop = tracemc(tr)
|
local mcode, addr, loop = tracemc(tr)
|
||||||
if not mcode then return end
|
if not mcode then return end
|
||||||
if not disass then disass = require("jit.dis_" .. jit.arch) end
|
if not disass then disass = require("jit.dis_"..jit.arch) end
|
||||||
if addr < 0 then addr = addr + 2 ^ 32 end
|
if addr < 0 then addr = addr + 2^32 end
|
||||||
out:write("---- TRACE ", tr, " mcode ", #mcode, "\n")
|
out:write("---- TRACE ", tr, " mcode ", #mcode, "\n")
|
||||||
local ctx = disass.create(mcode, addr, dumpwrite)
|
local ctx = disass.create(mcode, addr, dumpwrite)
|
||||||
ctx.hexdump = 0
|
ctx.hexdump = 0
|
||||||
ctx.symtab = fillsymtab(tr, info.nexit)
|
ctx.symtab = fillsymtab(tr, info.nexit)
|
||||||
if loop ~= 0 then
|
if loop ~= 0 then
|
||||||
symtab[addr + loop] = "LOOP"
|
symtab[addr+loop] = "LOOP"
|
||||||
ctx:disass(0, loop)
|
ctx:disass(0, loop)
|
||||||
out:write("->LOOP:\n")
|
out:write("->LOOP:\n")
|
||||||
ctx:disass(loop, #mcode - loop)
|
ctx:disass(loop, #mcode-loop)
|
||||||
symtab[addr + loop] = nil
|
symtab[addr+loop] = nil
|
||||||
else
|
else
|
||||||
ctx:disass(0, #mcode)
|
ctx:disass(0, #mcode)
|
||||||
end
|
end
|
||||||
|
|
@ -222,11 +222,8 @@ local function colorize_ansi(s, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
local irtype_ansi = setmetatable({},
|
local irtype_ansi = setmetatable({},
|
||||||
{
|
{ __index = function(tab, t)
|
||||||
__index = function(tab, t)
|
local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s; end })
|
||||||
local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s;
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
local html_escape = { ["<"] = "<", [">"] = ">", ["&"] = "&", }
|
local html_escape = { ["<"] = "<", [">"] = ">", ["&"] = "&", }
|
||||||
|
|
||||||
|
|
@ -236,11 +233,8 @@ local function colorize_html(s, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
local irtype_html = setmetatable({},
|
local irtype_html = setmetatable({},
|
||||||
{
|
{ __index = function(tab, t)
|
||||||
__index = function(tab, t)
|
local s = colorize_html(irtype_text[t], t); tab[t] = s; return s; end })
|
||||||
local s = colorize_html(irtype_text[t], t); tab[t] = s; return s;
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
local header_html = [[
|
local header_html = [[
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
@ -267,31 +261,27 @@ local colorize, irtype
|
||||||
|
|
||||||
-- Lookup tables to convert some literals into names.
|
-- Lookup tables to convert some literals into names.
|
||||||
local litname = {
|
local litname = {
|
||||||
["SLOAD "] = setmetatable({}, {
|
["SLOAD "] = setmetatable({}, { __index = function(t, mode)
|
||||||
__index = function(t, mode)
|
local s = ""
|
||||||
local s = ""
|
if band(mode, 1) ~= 0 then s = s.."P" end
|
||||||
if band(mode, 1) ~= 0 then s = s .. "P" end
|
if band(mode, 2) ~= 0 then s = s.."F" end
|
||||||
if band(mode, 2) ~= 0 then s = s .. "F" end
|
if band(mode, 4) ~= 0 then s = s.."T" end
|
||||||
if band(mode, 4) ~= 0 then s = s .. "T" end
|
if band(mode, 8) ~= 0 then s = s.."C" end
|
||||||
if band(mode, 8) ~= 0 then s = s .. "C" end
|
if band(mode, 16) ~= 0 then s = s.."R" end
|
||||||
if band(mode, 16) ~= 0 then s = s .. "R" end
|
if band(mode, 32) ~= 0 then s = s.."I" end
|
||||||
if band(mode, 32) ~= 0 then s = s .. "I" end
|
t[mode] = s
|
||||||
t[mode] = s
|
return s
|
||||||
return s
|
end}),
|
||||||
end
|
|
||||||
}),
|
|
||||||
["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", },
|
["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", },
|
||||||
["CONV "] = setmetatable({}, {
|
["CONV "] = setmetatable({}, { __index = function(t, mode)
|
||||||
__index = function(t, mode)
|
local s = irtype[band(mode, 31)]
|
||||||
local s = irtype[band(mode, 31)]
|
s = irtype[band(shr(mode, 5), 31)].."."..s
|
||||||
s = irtype[band(shr(mode, 5), 31)] .. "." .. s
|
if band(mode, 0x800) ~= 0 then s = s.." sext" end
|
||||||
if band(mode, 0x800) ~= 0 then s = s .. " sext" end
|
local c = shr(mode, 14)
|
||||||
local c = shr(mode, 14)
|
if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end
|
||||||
if c == 2 then s = s .. " index" elseif c == 3 then s = s .. " check" end
|
t[mode] = s
|
||||||
t[mode] = s
|
return s
|
||||||
return s
|
end}),
|
||||||
end
|
|
||||||
}),
|
|
||||||
["FLOAD "] = vmdef.irfield,
|
["FLOAD "] = vmdef.irfield,
|
||||||
["FREF "] = vmdef.irfield,
|
["FREF "] = vmdef.irfield,
|
||||||
["FPMATH"] = vmdef.irfpm,
|
["FPMATH"] = vmdef.irfpm,
|
||||||
|
|
@ -300,14 +290,10 @@ local litname = {
|
||||||
}
|
}
|
||||||
|
|
||||||
local function ctlsub(c)
|
local function ctlsub(c)
|
||||||
if c == "\n" then
|
if c == "\n" then return "\\n"
|
||||||
return "\\n"
|
elseif c == "\r" then return "\\r"
|
||||||
elseif c == "\r" then
|
elseif c == "\t" then return "\\t"
|
||||||
return "\\r"
|
else return format("\\%03d", byte(c))
|
||||||
elseif c == "\t" then
|
|
||||||
return "\\t"
|
|
||||||
else
|
|
||||||
return format("\\%03d", byte(c))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -331,7 +317,7 @@ local function formatk(tr, idx, sn)
|
||||||
if tn == "number" then
|
if tn == "number" then
|
||||||
if band(sn or 0, 0x30000) ~= 0 then
|
if band(sn or 0, 0x30000) ~= 0 then
|
||||||
s = band(sn, 0x20000) ~= 0 and "contpc" or "ftsz"
|
s = band(sn, 0x20000) ~= 0 and "contpc" or "ftsz"
|
||||||
elseif k == 2 ^ 52 + 2 ^ 51 then
|
elseif k == 2^52+2^51 then
|
||||||
s = "bias"
|
s = "bias"
|
||||||
else
|
else
|
||||||
s = format(0 < k and k < 0x1p-1026 and "%+a" or "%+.14g", k)
|
s = format(0 < k and k < 0x1p-1026 and "%+a" or "%+.14g", k)
|
||||||
|
|
@ -351,11 +337,11 @@ local function formatk(tr, idx, sn)
|
||||||
end
|
end
|
||||||
elseif t == 21 then -- int64_t
|
elseif t == 21 then -- int64_t
|
||||||
s = sub(tostring(k), 1, -3)
|
s = sub(tostring(k), 1, -3)
|
||||||
if sub(s, 1, 1) ~= "-" then s = "+" .. s end
|
if sub(s, 1, 1) ~= "-" then s = "+"..s end
|
||||||
elseif sn == 0x1057fff then -- SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL)
|
elseif sn == 0x1057fff then -- SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL)
|
||||||
return "----" -- Special case for LJ_FR2 slot 1.
|
return "----" -- Special case for LJ_FR2 slot 1.
|
||||||
else
|
else
|
||||||
s = tostring(k) -- For primitives.
|
s = tostring(k) -- For primitives.
|
||||||
end
|
end
|
||||||
s = colorize(format("%-4s", s), t)
|
s = colorize(format("%-4s", s), t)
|
||||||
if slot then
|
if slot then
|
||||||
|
|
@ -366,18 +352,18 @@ end
|
||||||
|
|
||||||
local function printsnap(tr, snap)
|
local function printsnap(tr, snap)
|
||||||
local n = 2
|
local n = 2
|
||||||
for s = 0, snap[1] - 1 do
|
for s=0,snap[1]-1 do
|
||||||
local sn = snap[n]
|
local sn = snap[n]
|
||||||
if shr(sn, 24) == s then
|
if shr(sn, 24) == s then
|
||||||
n = n + 1
|
n = n + 1
|
||||||
local ref = band(sn, 0xffff) - 0x8000 -- REF_BIAS
|
local ref = band(sn, 0xffff) - 0x8000 -- REF_BIAS
|
||||||
if ref < 0 then
|
if ref < 0 then
|
||||||
out:write(formatk(tr, ref, sn))
|
out:write(formatk(tr, ref, sn))
|
||||||
elseif band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM
|
elseif band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM
|
||||||
out:write(colorize(format("%04d/%04d", ref, ref + 1), 14))
|
out:write(colorize(format("%04d/%04d", ref, ref+1), 14))
|
||||||
else
|
else
|
||||||
local m, ot, op1, op2 = traceir(tr, ref)
|
local m, ot, op1, op2 = traceir(tr, ref)
|
||||||
out:write(colorize(format("%04d", ref), band(ot, 31)))
|
out:write(colorize(format("%04d", ref), band(ot, 31)))
|
||||||
end
|
end
|
||||||
out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME
|
out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME
|
||||||
else
|
else
|
||||||
|
|
@ -390,7 +376,7 @@ end
|
||||||
-- Dump snapshots (not interleaved with IR).
|
-- Dump snapshots (not interleaved with IR).
|
||||||
local function dump_snap(tr)
|
local function dump_snap(tr)
|
||||||
out:write("---- TRACE ", tr, " snapshots\n")
|
out:write("---- TRACE ", tr, " snapshots\n")
|
||||||
for i = 0, 1000000000 do
|
for i=0,1000000000 do
|
||||||
local snap = tracesnap(tr, i)
|
local snap = tracesnap(tr, i)
|
||||||
if not snap then break end
|
if not snap then break end
|
||||||
out:write(format("#%-3d %04d [ ", i, snap[0]))
|
out:write(format("#%-3d %04d [ ", i, snap[0]))
|
||||||
|
|
@ -400,12 +386,12 @@ end
|
||||||
|
|
||||||
-- Return a register name or stack slot for a rid/sp location.
|
-- Return a register name or stack slot for a rid/sp location.
|
||||||
local function ridsp_name(ridsp, ins)
|
local function ridsp_name(ridsp, ins)
|
||||||
if not disass then disass = require("jit.dis_" .. jit.arch) end
|
if not disass then disass = require("jit.dis_"..jit.arch) end
|
||||||
local rid, slot = band(ridsp, 0xff), shr(ridsp, 8)
|
local rid, slot = band(ridsp, 0xff), shr(ridsp, 8)
|
||||||
if rid == 253 or rid == 254 then
|
if rid == 253 or rid == 254 then
|
||||||
return (slot == 0 or slot == 255) and " {sink" or format(" {%04d", ins - slot)
|
return (slot == 0 or slot == 255) and " {sink" or format(" {%04d", ins-slot)
|
||||||
end
|
end
|
||||||
if ridsp > 255 then return format("[%x]", slot * 4) end
|
if ridsp > 255 then return format("[%x]", slot*4) end
|
||||||
if rid < 128 then return disass.regname(rid) end
|
if rid < 128 then return disass.regname(rid) end
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
@ -434,14 +420,14 @@ local function dumpcallargs(tr, ins)
|
||||||
out:write(formatk(tr, ins))
|
out:write(formatk(tr, ins))
|
||||||
else
|
else
|
||||||
local m, ot, op1, op2 = traceir(tr, ins)
|
local m, ot, op1, op2 = traceir(tr, ins)
|
||||||
local oidx = 6 * shr(ot, 8)
|
local oidx = 6*shr(ot, 8)
|
||||||
local op = sub(vmdef.irnames, oidx + 1, oidx + 6)
|
local op = sub(vmdef.irnames, oidx+1, oidx+6)
|
||||||
if op == "CARG " then
|
if op == "CARG " then
|
||||||
dumpcallargs(tr, op1)
|
dumpcallargs(tr, op1)
|
||||||
if op2 < 0 then
|
if op2 < 0 then
|
||||||
out:write(" ", formatk(tr, op2))
|
out:write(" ", formatk(tr, op2))
|
||||||
else
|
else
|
||||||
out:write(" ", format("%04d", op2))
|
out:write(" ", format("%04d", op2))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
out:write(format("%04d", ins))
|
out:write(format("%04d", ins))
|
||||||
|
|
@ -463,12 +449,12 @@ local function dump_ir(tr, dumpsnap, dumpreg)
|
||||||
snapref = snap[0]
|
snapref = snap[0]
|
||||||
snapno = 0
|
snapno = 0
|
||||||
end
|
end
|
||||||
for ins = 1, nins do
|
for ins=1,nins do
|
||||||
if ins >= snapref then
|
if ins >= snapref then
|
||||||
if dumpreg then
|
if dumpreg then
|
||||||
out:write(format(".... SNAP #%-3d [ ", snapno))
|
out:write(format(".... SNAP #%-3d [ ", snapno))
|
||||||
else
|
else
|
||||||
out:write(format(".... SNAP #%-3d [ ", snapno))
|
out:write(format(".... SNAP #%-3d [ ", snapno))
|
||||||
end
|
end
|
||||||
printsnap(tr, snap)
|
printsnap(tr, snap)
|
||||||
snapno = snapno + 1
|
snapno = snapno + 1
|
||||||
|
|
@ -476,62 +462,62 @@ local function dump_ir(tr, dumpsnap, dumpreg)
|
||||||
snapref = snap and snap[0] or 65536
|
snapref = snap and snap[0] or 65536
|
||||||
end
|
end
|
||||||
local m, ot, op1, op2, ridsp = traceir(tr, ins)
|
local m, ot, op1, op2, ridsp = traceir(tr, ins)
|
||||||
local oidx, t = 6 * shr(ot, 8), band(ot, 31)
|
local oidx, t = 6*shr(ot, 8), band(ot, 31)
|
||||||
local op = sub(irnames, oidx + 1, oidx + 6)
|
local op = sub(irnames, oidx+1, oidx+6)
|
||||||
if op == "LOOP " then
|
if op == "LOOP " then
|
||||||
if dumpreg then
|
if dumpreg then
|
||||||
out:write(format("%04d ------------ LOOP ------------\n", ins))
|
out:write(format("%04d ------------ LOOP ------------\n", ins))
|
||||||
else
|
else
|
||||||
out:write(format("%04d ------ LOOP ------------\n", ins))
|
out:write(format("%04d ------ LOOP ------------\n", ins))
|
||||||
end
|
end
|
||||||
elseif op ~= "NOP " and op ~= "CARG " and
|
elseif op ~= "NOP " and op ~= "CARG " and
|
||||||
(dumpreg or op ~= "RENAME") then
|
(dumpreg or op ~= "RENAME") then
|
||||||
local rid = band(ridsp, 255)
|
local rid = band(ridsp, 255)
|
||||||
if dumpreg then
|
if dumpreg then
|
||||||
out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins)))
|
out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins)))
|
||||||
else
|
else
|
||||||
out:write(format("%04d ", ins))
|
out:write(format("%04d ", ins))
|
||||||
end
|
end
|
||||||
out:write(format("%s%s %s %s ",
|
out:write(format("%s%s %s %s ",
|
||||||
(rid == 254 or rid == 253) and "}" or
|
(rid == 254 or rid == 253) and "}" or
|
||||||
(band(ot, 128) == 0 and " " or ">"),
|
(band(ot, 128) == 0 and " " or ">"),
|
||||||
band(ot, 64) == 0 and " " or "+",
|
band(ot, 64) == 0 and " " or "+",
|
||||||
irtype[t], op))
|
irtype[t], op))
|
||||||
local m1, m2 = band(m, 3), band(m, 3 * 4)
|
local m1, m2 = band(m, 3), band(m, 3*4)
|
||||||
if sub(op, 1, 4) == "CALL" then
|
if sub(op, 1, 4) == "CALL" then
|
||||||
local ctype
|
local ctype
|
||||||
if m2 == 1 * 4 then -- op2 == IRMlit
|
if m2 == 1*4 then -- op2 == IRMlit
|
||||||
out:write(format("%-10s (", vmdef.ircall[op2]))
|
out:write(format("%-10s (", vmdef.ircall[op2]))
|
||||||
else
|
else
|
||||||
ctype = dumpcallfunc(tr, op2)
|
ctype = dumpcallfunc(tr, op2)
|
||||||
end
|
end
|
||||||
if op1 ~= -1 then dumpcallargs(tr, op1) end
|
if op1 ~= -1 then dumpcallargs(tr, op1) end
|
||||||
out:write(")")
|
out:write(")")
|
||||||
if ctype then out:write(" ctype ", ctype) end
|
if ctype then out:write(" ctype ", ctype) end
|
||||||
elseif op == "CNEW " and op2 == -1 then
|
elseif op == "CNEW " and op2 == -1 then
|
||||||
out:write(formatk(tr, op1))
|
out:write(formatk(tr, op1))
|
||||||
elseif m1 ~= 3 then -- op1 != IRMnone
|
elseif m1 ~= 3 then -- op1 != IRMnone
|
||||||
if op1 < 0 then
|
if op1 < 0 then
|
||||||
out:write(formatk(tr, op1))
|
out:write(formatk(tr, op1))
|
||||||
else
|
else
|
||||||
out:write(format(m1 == 0 and "%04d" or "#%-3d", op1))
|
out:write(format(m1 == 0 and "%04d" or "#%-3d", op1))
|
||||||
end
|
end
|
||||||
if m2 ~= 3 * 4 then -- op2 != IRMnone
|
if m2 ~= 3*4 then -- op2 != IRMnone
|
||||||
if m2 == 1 * 4 then -- op2 == IRMlit
|
if m2 == 1*4 then -- op2 == IRMlit
|
||||||
local litn = litname[op]
|
local litn = litname[op]
|
||||||
if litn and litn[op2] then
|
if litn and litn[op2] then
|
||||||
out:write(" ", litn[op2])
|
out:write(" ", litn[op2])
|
||||||
elseif op == "UREFO " or op == "UREFC " then
|
elseif op == "UREFO " or op == "UREFC " then
|
||||||
out:write(format(" #%-3d", shr(op2, 8)))
|
out:write(format(" #%-3d", shr(op2, 8)))
|
||||||
else
|
else
|
||||||
out:write(format(" #%-3d", op2))
|
out:write(format(" #%-3d", op2))
|
||||||
end
|
end
|
||||||
elseif op2 < 0 then
|
elseif op2 < 0 then
|
||||||
out:write(" ", formatk(tr, op2))
|
out:write(" ", formatk(tr, op2))
|
||||||
else
|
else
|
||||||
out:write(format(" %04d", op2))
|
out:write(format(" %04d", op2))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
out:write("\n")
|
out:write("\n")
|
||||||
end
|
end
|
||||||
|
|
@ -563,11 +549,8 @@ end
|
||||||
-- Dump trace states.
|
-- Dump trace states.
|
||||||
local function dump_trace(what, tr, func, pc, otr, oex)
|
local function dump_trace(what, tr, func, pc, otr, oex)
|
||||||
if what == "stop" or (what == "abort" and dumpmode.a) then
|
if what == "stop" or (what == "abort" and dumpmode.a) then
|
||||||
if dumpmode.i then
|
if dumpmode.i then dump_ir(tr, dumpmode.s, dumpmode.r and what == "stop")
|
||||||
dump_ir(tr, dumpmode.s, dumpmode.r and what == "stop")
|
elseif dumpmode.s then dump_snap(tr) end
|
||||||
elseif dumpmode.s then
|
|
||||||
dump_snap(tr)
|
|
||||||
end
|
|
||||||
if dumpmode.m then dump_mcode(tr) end
|
if dumpmode.m then dump_mcode(tr) end
|
||||||
end
|
end
|
||||||
if what == "start" then
|
if what == "start" then
|
||||||
|
|
@ -583,11 +566,11 @@ local function dump_trace(what, tr, func, pc, otr, oex)
|
||||||
local info = traceinfo(tr)
|
local info = traceinfo(tr)
|
||||||
local link, ltype = info.link, info.linktype
|
local link, ltype = info.link, info.linktype
|
||||||
if link == tr or link == 0 then
|
if link == tr or link == 0 then
|
||||||
out:write(" -> ", ltype, "\n")
|
out:write(" -> ", ltype, "\n")
|
||||||
elseif ltype == "root" then
|
elseif ltype == "root" then
|
||||||
out:write(" -> ", link, "\n")
|
out:write(" -> ", link, "\n")
|
||||||
else
|
else
|
||||||
out:write(" -> ", link, " ", ltype, "\n")
|
out:write(" -> ", link, " ", ltype, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if dumpmode.H then out:write("</pre>\n\n") else out:write("\n") end
|
if dumpmode.H then out:write("</pre>\n\n") else out:write("\n") end
|
||||||
|
|
@ -609,7 +592,7 @@ local function dump_record(tr, func, pc, depth, callee)
|
||||||
line = bcline(func, pc, recprefix)
|
line = bcline(func, pc, recprefix)
|
||||||
if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end
|
if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end
|
||||||
else
|
else
|
||||||
line = "0000 " .. recprefix .. " FUNCC \n"
|
line = "0000 "..recprefix.." FUNCC \n"
|
||||||
callee = func
|
callee = func
|
||||||
end
|
end
|
||||||
if pc <= 0 then
|
if pc <= 0 then
|
||||||
|
|
@ -618,7 +601,7 @@ local function dump_record(tr, func, pc, depth, callee)
|
||||||
out:write(line)
|
out:write(line)
|
||||||
end
|
end
|
||||||
if pc >= 0 and band(funcbc(func, pc), 0xff) < 16 then -- ORDER BC
|
if pc >= 0 and band(funcbc(func, pc), 0xff) < 16 then -- ORDER BC
|
||||||
out:write(bcline(func, pc + 1, recprefix)) -- Write JMP for cond.
|
out:write(bcline(func, pc+1, recprefix)) -- Write JMP for cond.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -628,27 +611,27 @@ end
|
||||||
local function dump_texit(tr, ex, ngpr, nfpr, ...)
|
local function dump_texit(tr, ex, ngpr, nfpr, ...)
|
||||||
out:write("---- TRACE ", tr, " exit ", ex, "\n")
|
out:write("---- TRACE ", tr, " exit ", ex, "\n")
|
||||||
if dumpmode.X then
|
if dumpmode.X then
|
||||||
local regs = { ... }
|
local regs = {...}
|
||||||
if jit.arch == "x64" then
|
if jit.arch == "x64" then
|
||||||
for i = 1, ngpr do
|
for i=1,ngpr do
|
||||||
out:write(format(" %016x", regs[i]))
|
out:write(format(" %016x", regs[i]))
|
||||||
if i % 4 == 0 then out:write("\n") end
|
if i % 4 == 0 then out:write("\n") end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for i = 1, ngpr do
|
for i=1,ngpr do
|
||||||
out:write(" ", tohex(regs[i]))
|
out:write(" ", tohex(regs[i]))
|
||||||
if i % 8 == 0 then out:write("\n") end
|
if i % 8 == 0 then out:write("\n") end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if jit.arch == "mips" or jit.arch == "mipsel" then
|
if jit.arch == "mips" or jit.arch == "mipsel" then
|
||||||
for i = 1, nfpr, 2 do
|
for i=1,nfpr,2 do
|
||||||
out:write(format(" %+17.14g", regs[ngpr + i]))
|
out:write(format(" %+17.14g", regs[ngpr+i]))
|
||||||
if i % 8 == 7 then out:write("\n") end
|
if i % 8 == 7 then out:write("\n") end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for i = 1, nfpr do
|
for i=1,nfpr do
|
||||||
out:write(format(" %+17.14g", regs[ngpr + i]))
|
out:write(format(" %+17.14g", regs[ngpr+i]))
|
||||||
if i % 4 == 0 then out:write("\n") end
|
if i % 4 == 0 then out:write("\n") end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -675,16 +658,14 @@ local function dumpon(opt, outfile)
|
||||||
local term = os.getenv("TERM")
|
local term = os.getenv("TERM")
|
||||||
local colormode = (term and term:match("color") or os.getenv("COLORTERM")) and "A" or "T"
|
local colormode = (term and term:match("color") or os.getenv("COLORTERM")) and "A" or "T"
|
||||||
if opt then
|
if opt then
|
||||||
opt = gsub(opt, "[TAH]", function(mode)
|
opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end)
|
||||||
colormode = mode; return "";
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local m = { t = true, b = true, i = true, m = true, }
|
local m = { t=true, b=true, i=true, m=true, }
|
||||||
if opt and opt ~= "" then
|
if opt and opt ~= "" then
|
||||||
local o = sub(opt, 1, 1)
|
local o = sub(opt, 1, 1)
|
||||||
if o ~= "+" and o ~= "-" then m = {} end
|
if o ~= "+" and o ~= "-" then m = {} end
|
||||||
for i = 1, #opt do m[sub(opt, i, i)] = (o ~= "-") end
|
for i=1,#opt do m[sub(opt, i, i)] = (o ~= "-") end
|
||||||
end
|
end
|
||||||
dumpmode = m
|
dumpmode = m
|
||||||
|
|
||||||
|
|
@ -728,3 +709,4 @@ return {
|
||||||
off = dumpoff,
|
off = dumpoff,
|
||||||
start = dumpon -- For -j command line option.
|
start = dumpon -- For -j command line option.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,31 +99,31 @@ end
|
||||||
local function dump_trace(what, tr, func, pc, otr, oex)
|
local function dump_trace(what, tr, func, pc, otr, oex)
|
||||||
if what == "start" then
|
if what == "start" then
|
||||||
startloc = fmtfunc(func, pc)
|
startloc = fmtfunc(func, pc)
|
||||||
startex = otr and "(" .. otr .. "/" .. (oex == -1 and "stitch" or oex) .. ") " or ""
|
startex = otr and "("..otr.."/"..(oex == -1 and "stitch" or oex)..") " or ""
|
||||||
else
|
else
|
||||||
if what == "abort" then
|
if what == "abort" then
|
||||||
local loc = fmtfunc(func, pc)
|
local loc = fmtfunc(func, pc)
|
||||||
if loc ~= startloc then
|
if loc ~= startloc then
|
||||||
-- print(format("[TRACE --- %s%s -- %s at %s]\n", startex, startloc, fmterr(otr, oex), loc))
|
print(format("[TRACE --- %s%s -- %s at %s]\n", startex, startloc, fmterr(otr, oex), loc))
|
||||||
else
|
else
|
||||||
-- print(format("[TRACE --- %s%s -- %s]\n", startex, startloc, fmterr(otr, oex)))
|
print(format("[TRACE --- %s%s -- %s]\n", startex, startloc, fmterr(otr, oex)))
|
||||||
end
|
end
|
||||||
elseif what == "stop" then
|
elseif what == "stop" then
|
||||||
local info = traceinfo(tr)
|
local info = traceinfo(tr)
|
||||||
local link, ltype = info.link, info.linktype
|
local link, ltype = info.link, info.linktype
|
||||||
if ltype == "interpreter" then
|
if ltype == "interpreter" then
|
||||||
-- print(format("[TRACE %3s %s%s -- fallback to interpreter]\n", tr, startex, startloc))
|
print(format("[TRACE %3s %s%s -- fallback to interpreter]\n", tr, startex, startloc))
|
||||||
elseif ltype == "stitch" then
|
elseif ltype == "stitch" then
|
||||||
-- print(format("[TRACE %3s %s%s %s %s]\n", tr, startex, startloc, ltype, fmtfunc(func, pc)))
|
print(format("[TRACE %3s %s%s %s %s]\n", tr, startex, startloc, ltype, fmtfunc(func, pc)))
|
||||||
elseif link == tr or link == 0 then
|
elseif link == tr or link == 0 then
|
||||||
-- print(format("[TRACE %3s %s%s %s]\n", tr, startex, startloc, ltype))
|
print(format("[TRACE %3s %s%s %s]\n", tr, startex, startloc, ltype))
|
||||||
elseif ltype == "root" then
|
elseif ltype == "root" then
|
||||||
-- print(format("[TRACE %3s %s%s -> %d]\n", tr, startex, startloc, link))
|
print(format("[TRACE %3s %s%s -> %d]\n", tr, startex, startloc, link))
|
||||||
else
|
else
|
||||||
-- print(format("[TRACE %3s %s%s -> %d %s]\n", tr, startex, startloc, link, ltype))
|
print(format("[TRACE %3s %s%s -> %d %s]\n", tr, startex, startloc, link, ltype))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- print(format("[TRACE %s]\n", what))
|
print(format("[TRACE %s]\n", what))
|
||||||
end
|
end
|
||||||
out:flush()
|
out:flush()
|
||||||
end
|
end
|
||||||
|
|
@ -150,7 +150,7 @@ local function dumpon(outfile)
|
||||||
else
|
else
|
||||||
out = stderr
|
out = stderr
|
||||||
end
|
end
|
||||||
jit.attach(dump_trace, "trace")
|
jit.attach(dump_trace, "trace")
|
||||||
active = true
|
active = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -160,3 +160,4 @@ return {
|
||||||
off = dumpoff,
|
off = dumpoff,
|
||||||
start = dumpon -- For -j command line option.
|
start = dumpon -- For -j command line option.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,362 +2,361 @@
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
bcnames =
|
bcnames = "ISLT ISGE ISLE ISGT ISEQV ISNEV ISEQS ISNES ISEQN ISNEN ISEQP ISNEP ISTC ISFC IST ISF ISTYPEISNUM MOV NOT UNM LEN ADDVN SUBVN MULVN DIVVN MODVN ADDNV SUBNV MULNV DIVNV MODNV ADDVV SUBVV MULVV DIVVV MODVV POW CAT KSTR KCDATAKSHORTKNUM KPRI KNIL UGET USETV USETS USETN USETP UCLO FNEW TNEW TDUP GGET GSET TGETV TGETS TGETB TGETR TSETV TSETS TSETB TSETM TSETR CALLM CALL CALLMTCALLT ITERC ITERN VARG ISNEXTRETM RET RET0 RET1 FORI JFORI FORL IFORL JFORL ITERL IITERLJITERLLOOP ILOOP JLOOP JMP FUNCF IFUNCFJFUNCFFUNCV IFUNCVJFUNCVFUNCC FUNCCW",
|
||||||
"ISLT ISGE ISLE ISGT ISEQV ISNEV ISEQS ISNES ISEQN ISNEN ISEQP ISNEP ISTC ISFC IST ISF ISTYPEISNUM MOV NOT UNM LEN ADDVN SUBVN MULVN DIVVN MODVN ADDNV SUBNV MULNV DIVNV MODNV ADDVV SUBVV MULVV DIVVV MODVV POW CAT KSTR KCDATAKSHORTKNUM KPRI KNIL UGET USETV USETS USETN USETP UCLO FNEW TNEW TDUP GGET GSET TGETV TGETS TGETB TGETR TSETV TSETS TSETB TSETM TSETR CALLM CALL CALLMTCALLT ITERC ITERN VARG ISNEXTRETM RET RET0 RET1 FORI JFORI FORL IFORL JFORL ITERL IITERLJITERLLOOP ILOOP JLOOP JMP FUNCF IFUNCFJFUNCFFUNCV IFUNCVJFUNCVFUNCC FUNCCW",
|
|
||||||
|
|
||||||
irnames =
|
irnames = "LT GE LE GT ULT UGE ULE UGT EQ NE ABC RETF NOP BASE PVAL GCSTEPHIOP LOOP USE PHI RENAMEPROF KPRI KINT KGC KPTR KKPTR KNULL KNUM KINT64KSLOT BNOT BSWAP BAND BOR BXOR BSHL BSHR BSAR BROL BROR ADD SUB MUL DIV MOD POW NEG ABS ATAN2 LDEXP MIN MAX FPMATHADDOV SUBOV MULOV AREF HREFK HREF NEWREFUREFO UREFC FREF STRREFLREF ALOAD HLOAD ULOAD FLOAD XLOAD SLOAD VLOAD ASTOREHSTOREUSTOREFSTOREXSTORESNEW XSNEW TNEW TDUP CNEW CNEWI BUFHDRBUFPUTBUFSTRTBAR OBAR XBAR CONV TOBIT TOSTR STRTO CALLN CALLA CALLL CALLS CALLXSCARG ",
|
||||||
"LT GE LE GT ULT UGE ULE UGT EQ NE ABC RETF NOP BASE PVAL GCSTEPHIOP LOOP USE PHI RENAMEPROF KPRI KINT KGC KPTR KKPTR KNULL KNUM KINT64KSLOT BNOT BSWAP BAND BOR BXOR BSHL BSHR BSAR BROL BROR ADD SUB MUL DIV MOD POW NEG ABS ATAN2 LDEXP MIN MAX FPMATHADDOV SUBOV MULOV AREF HREFK HREF NEWREFUREFO UREFC FREF STRREFLREF ALOAD HLOAD ULOAD FLOAD XLOAD SLOAD VLOAD ASTOREHSTOREUSTOREFSTOREXSTORESNEW XSNEW TNEW TDUP CNEW CNEWI BUFHDRBUFPUTBUFSTRTBAR OBAR XBAR CONV TOBIT TOSTR STRTO CALLN CALLA CALLL CALLS CALLXSCARG ",
|
|
||||||
|
|
||||||
irfpm = { [0] = "floor", "ceil", "trunc", "sqrt", "exp", "exp2", "log", "log2", "log10", "sin", "cos", "tan", "other", },
|
irfpm = { [0]="floor", "ceil", "trunc", "sqrt", "exp", "exp2", "log", "log2", "log10", "sin", "cos", "tan", "other", },
|
||||||
|
|
||||||
irfield = { [0] = "str.len", "func.env", "func.pc", "func.ffid", "thread.env", "tab.meta", "tab.array", "tab.node", "tab.asize", "tab.hmask", "tab.nomm", "udata.meta", "udata.udtype", "udata.file", "cdata.ctypeid", "cdata.ptr", "cdata.int", "cdata.int64", "cdata.int64_4", },
|
irfield = { [0]="str.len", "func.env", "func.pc", "func.ffid", "thread.env", "tab.meta", "tab.array", "tab.node", "tab.asize", "tab.hmask", "tab.nomm", "udata.meta", "udata.udtype", "udata.file", "cdata.ctypeid", "cdata.ptr", "cdata.int", "cdata.int64", "cdata.int64_4", },
|
||||||
|
|
||||||
ircall = {
|
ircall = {
|
||||||
[0] = "lj_str_cmp",
|
[0]="lj_str_cmp",
|
||||||
"lj_str_find",
|
"lj_str_find",
|
||||||
"lj_str_new",
|
"lj_str_new",
|
||||||
"lj_strscan_num",
|
"lj_strscan_num",
|
||||||
"lj_strfmt_int",
|
"lj_strfmt_int",
|
||||||
"lj_strfmt_num",
|
"lj_strfmt_num",
|
||||||
"lj_strfmt_char",
|
"lj_strfmt_char",
|
||||||
"lj_strfmt_putint",
|
"lj_strfmt_putint",
|
||||||
"lj_strfmt_putnum",
|
"lj_strfmt_putnum",
|
||||||
"lj_strfmt_putquoted",
|
"lj_strfmt_putquoted",
|
||||||
"lj_strfmt_putfxint",
|
"lj_strfmt_putfxint",
|
||||||
"lj_strfmt_putfnum_int",
|
"lj_strfmt_putfnum_int",
|
||||||
"lj_strfmt_putfnum_uint",
|
"lj_strfmt_putfnum_uint",
|
||||||
"lj_strfmt_putfnum",
|
"lj_strfmt_putfnum",
|
||||||
"lj_strfmt_putfstr",
|
"lj_strfmt_putfstr",
|
||||||
"lj_strfmt_putfchar",
|
"lj_strfmt_putfchar",
|
||||||
"lj_buf_putmem",
|
"lj_buf_putmem",
|
||||||
"lj_buf_putstr",
|
"lj_buf_putstr",
|
||||||
"lj_buf_putchar",
|
"lj_buf_putchar",
|
||||||
"lj_buf_putstr_reverse",
|
"lj_buf_putstr_reverse",
|
||||||
"lj_buf_putstr_lower",
|
"lj_buf_putstr_lower",
|
||||||
"lj_buf_putstr_upper",
|
"lj_buf_putstr_upper",
|
||||||
"lj_buf_putstr_rep",
|
"lj_buf_putstr_rep",
|
||||||
"lj_buf_puttab",
|
"lj_buf_puttab",
|
||||||
"lj_buf_tostr",
|
"lj_buf_tostr",
|
||||||
"lj_tab_new_ah",
|
"lj_tab_new_ah",
|
||||||
"lj_tab_new1",
|
"lj_tab_new1",
|
||||||
"lj_tab_dup",
|
"lj_tab_dup",
|
||||||
"lj_tab_clear",
|
"lj_tab_clear",
|
||||||
"lj_tab_newkey",
|
"lj_tab_newkey",
|
||||||
"lj_tab_len",
|
"lj_tab_len",
|
||||||
"lj_gc_step_jit",
|
"lj_gc_step_jit",
|
||||||
"lj_gc_barrieruv",
|
"lj_gc_barrieruv",
|
||||||
"lj_mem_newgco",
|
"lj_mem_newgco",
|
||||||
"lj_math_random_step",
|
"lj_math_random_step",
|
||||||
"lj_vm_modi",
|
"lj_vm_modi",
|
||||||
"sinh",
|
"sinh",
|
||||||
"cosh",
|
"cosh",
|
||||||
"tanh",
|
"tanh",
|
||||||
"fputc",
|
"fputc",
|
||||||
"fwrite",
|
"fwrite",
|
||||||
"fflush",
|
"fflush",
|
||||||
"lj_vm_floor",
|
"lj_vm_floor",
|
||||||
"lj_vm_ceil",
|
"lj_vm_ceil",
|
||||||
"lj_vm_trunc",
|
"lj_vm_trunc",
|
||||||
"sqrt",
|
"sqrt",
|
||||||
"exp",
|
"exp",
|
||||||
"lj_vm_exp2",
|
"lj_vm_exp2",
|
||||||
"log",
|
"log",
|
||||||
"lj_vm_log2",
|
"lj_vm_log2",
|
||||||
"log10",
|
"log10",
|
||||||
"sin",
|
"sin",
|
||||||
"cos",
|
"cos",
|
||||||
"tan",
|
"tan",
|
||||||
"lj_vm_powi",
|
"lj_vm_powi",
|
||||||
"pow",
|
"pow",
|
||||||
"atan2",
|
"atan2",
|
||||||
"ldexp",
|
"ldexp",
|
||||||
"lj_vm_tobit",
|
"lj_vm_tobit",
|
||||||
"softfp_add",
|
"softfp_add",
|
||||||
"softfp_sub",
|
"softfp_sub",
|
||||||
"softfp_mul",
|
"softfp_mul",
|
||||||
"softfp_div",
|
"softfp_div",
|
||||||
"softfp_cmp",
|
"softfp_cmp",
|
||||||
"softfp_i2d",
|
"softfp_i2d",
|
||||||
"softfp_d2i",
|
"softfp_d2i",
|
||||||
"lj_vm_sfmin",
|
"lj_vm_sfmin",
|
||||||
"lj_vm_sfmax",
|
"lj_vm_sfmax",
|
||||||
"softfp_ui2d",
|
"softfp_ui2d",
|
||||||
"softfp_f2d",
|
"softfp_f2d",
|
||||||
"softfp_d2ui",
|
"softfp_d2ui",
|
||||||
"softfp_d2f",
|
"softfp_d2f",
|
||||||
"softfp_i2f",
|
"softfp_i2f",
|
||||||
"softfp_ui2f",
|
"softfp_ui2f",
|
||||||
"softfp_f2i",
|
"softfp_f2i",
|
||||||
"softfp_f2ui",
|
"softfp_f2ui",
|
||||||
"fp64_l2d",
|
"fp64_l2d",
|
||||||
"fp64_ul2d",
|
"fp64_ul2d",
|
||||||
"fp64_l2f",
|
"fp64_l2f",
|
||||||
"fp64_ul2f",
|
"fp64_ul2f",
|
||||||
"fp64_d2l",
|
"fp64_d2l",
|
||||||
"fp64_d2ul",
|
"fp64_d2ul",
|
||||||
"fp64_f2l",
|
"fp64_f2l",
|
||||||
"fp64_f2ul",
|
"fp64_f2ul",
|
||||||
"lj_carith_divi64",
|
"lj_carith_divi64",
|
||||||
"lj_carith_divu64",
|
"lj_carith_divu64",
|
||||||
"lj_carith_modi64",
|
"lj_carith_modi64",
|
||||||
"lj_carith_modu64",
|
"lj_carith_modu64",
|
||||||
"lj_carith_powi64",
|
"lj_carith_powi64",
|
||||||
"lj_carith_powu64",
|
"lj_carith_powu64",
|
||||||
"lj_cdata_newv",
|
"lj_cdata_newv",
|
||||||
"lj_cdata_setfin",
|
"lj_cdata_setfin",
|
||||||
"strlen",
|
"strlen",
|
||||||
"memcpy",
|
"memcpy",
|
||||||
"memset",
|
"memset",
|
||||||
"lj_vm_errno",
|
"lj_vm_errno",
|
||||||
"lj_carith_mul64",
|
"lj_carith_mul64",
|
||||||
"lj_carith_shl64",
|
"lj_carith_shl64",
|
||||||
"lj_carith_shr64",
|
"lj_carith_shr64",
|
||||||
"lj_carith_sar64",
|
"lj_carith_sar64",
|
||||||
"lj_carith_rol64",
|
"lj_carith_rol64",
|
||||||
"lj_carith_ror64",
|
"lj_carith_ror64",
|
||||||
},
|
},
|
||||||
|
|
||||||
traceerr = {
|
traceerr = {
|
||||||
[0] = "error thrown or hook called during recording",
|
[0]="error thrown or hook called during recording",
|
||||||
"trace too short",
|
"trace too short",
|
||||||
"trace too long",
|
"trace too long",
|
||||||
"trace too deep",
|
"trace too deep",
|
||||||
"too many snapshots",
|
"too many snapshots",
|
||||||
"blacklisted",
|
"blacklisted",
|
||||||
"retry recording",
|
"retry recording",
|
||||||
"NYI: bytecode %d",
|
"NYI: bytecode %d",
|
||||||
"leaving loop in root trace",
|
"leaving loop in root trace",
|
||||||
"inner loop in root trace",
|
"inner loop in root trace",
|
||||||
"loop unroll limit reached",
|
"loop unroll limit reached",
|
||||||
"bad argument type",
|
"bad argument type",
|
||||||
"JIT compilation disabled for function",
|
"JIT compilation disabled for function",
|
||||||
"call unroll limit reached",
|
"call unroll limit reached",
|
||||||
"down-recursion, restarting",
|
"down-recursion, restarting",
|
||||||
"NYI: unsupported variant of FastFunc %s",
|
"NYI: unsupported variant of FastFunc %s",
|
||||||
"NYI: return to lower frame",
|
"NYI: return to lower frame",
|
||||||
"store with nil or NaN key",
|
"store with nil or NaN key",
|
||||||
"missing metamethod",
|
"missing metamethod",
|
||||||
"looping index lookup",
|
"looping index lookup",
|
||||||
"NYI: mixed sparse/dense table",
|
"NYI: mixed sparse/dense table",
|
||||||
"symbol not in cache",
|
"symbol not in cache",
|
||||||
"NYI: unsupported C type conversion",
|
"NYI: unsupported C type conversion",
|
||||||
"NYI: unsupported C function type",
|
"NYI: unsupported C function type",
|
||||||
"guard would always fail",
|
"guard would always fail",
|
||||||
"too many PHIs",
|
"too many PHIs",
|
||||||
"persistent type instability",
|
"persistent type instability",
|
||||||
"failed to allocate mcode memory",
|
"failed to allocate mcode memory",
|
||||||
"machine code too long",
|
"machine code too long",
|
||||||
"hit mcode limit (retrying)",
|
"hit mcode limit (retrying)",
|
||||||
"too many spill slots",
|
"too many spill slots",
|
||||||
"inconsistent register allocation",
|
"inconsistent register allocation",
|
||||||
"NYI: cannot assemble IR instruction %d",
|
"NYI: cannot assemble IR instruction %d",
|
||||||
"NYI: PHI shuffling too complex",
|
"NYI: PHI shuffling too complex",
|
||||||
"NYI: register coalescing too complex",
|
"NYI: register coalescing too complex",
|
||||||
},
|
},
|
||||||
|
|
||||||
ffnames = {
|
ffnames = {
|
||||||
[0] = "Lua",
|
[0]="Lua",
|
||||||
"C",
|
"C",
|
||||||
"assert",
|
"assert",
|
||||||
"type",
|
"type",
|
||||||
"next",
|
"next",
|
||||||
"pairs",
|
"pairs",
|
||||||
"ipairs_aux",
|
"ipairs_aux",
|
||||||
"ipairs",
|
"ipairs",
|
||||||
"getmetatable",
|
"getmetatable",
|
||||||
"setmetatable",
|
"setmetatable",
|
||||||
"getfenv",
|
"getfenv",
|
||||||
"setfenv",
|
"setfenv",
|
||||||
"rawget",
|
"rawget",
|
||||||
"rawset",
|
"rawset",
|
||||||
"rawequal",
|
"rawequal",
|
||||||
"unpack",
|
"unpack",
|
||||||
"select",
|
"select",
|
||||||
"tonumber",
|
"tonumber",
|
||||||
"tostring",
|
"tostring",
|
||||||
"error",
|
"error",
|
||||||
"pcall",
|
"pcall",
|
||||||
"xpcall",
|
"xpcall",
|
||||||
"loadfile",
|
"loadfile",
|
||||||
"load",
|
"load",
|
||||||
"loadstring",
|
"loadstring",
|
||||||
"dofile",
|
"dofile",
|
||||||
"gcinfo",
|
"gcinfo",
|
||||||
"collectgarbage",
|
"collectgarbage",
|
||||||
"newproxy",
|
"newproxy",
|
||||||
"print",
|
"print",
|
||||||
"coroutine.status",
|
"coroutine.status",
|
||||||
"coroutine.running",
|
"coroutine.running",
|
||||||
"coroutine.create",
|
"coroutine.create",
|
||||||
"coroutine.yield",
|
"coroutine.yield",
|
||||||
"coroutine.resume",
|
"coroutine.resume",
|
||||||
"coroutine.wrap_aux",
|
"coroutine.wrap_aux",
|
||||||
"coroutine.wrap",
|
"coroutine.wrap",
|
||||||
"math.abs",
|
"math.abs",
|
||||||
"math.floor",
|
"math.floor",
|
||||||
"math.ceil",
|
"math.ceil",
|
||||||
"math.sqrt",
|
"math.sqrt",
|
||||||
"math.log10",
|
"math.log10",
|
||||||
"math.exp",
|
"math.exp",
|
||||||
"math.sin",
|
"math.sin",
|
||||||
"math.cos",
|
"math.cos",
|
||||||
"math.tan",
|
"math.tan",
|
||||||
"math.asin",
|
"math.asin",
|
||||||
"math.acos",
|
"math.acos",
|
||||||
"math.atan",
|
"math.atan",
|
||||||
"math.sinh",
|
"math.sinh",
|
||||||
"math.cosh",
|
"math.cosh",
|
||||||
"math.tanh",
|
"math.tanh",
|
||||||
"math.frexp",
|
"math.frexp",
|
||||||
"math.modf",
|
"math.modf",
|
||||||
"math.log",
|
"math.log",
|
||||||
"math.atan2",
|
"math.atan2",
|
||||||
"math.pow",
|
"math.pow",
|
||||||
"math.fmod",
|
"math.fmod",
|
||||||
"math.ldexp",
|
"math.ldexp",
|
||||||
"math.min",
|
"math.min",
|
||||||
"math.max",
|
"math.max",
|
||||||
"math.random",
|
"math.random",
|
||||||
"math.randomseed",
|
"math.randomseed",
|
||||||
"bit.tobit",
|
"bit.tobit",
|
||||||
"bit.bnot",
|
"bit.bnot",
|
||||||
"bit.bswap",
|
"bit.bswap",
|
||||||
"bit.lshift",
|
"bit.lshift",
|
||||||
"bit.rshift",
|
"bit.rshift",
|
||||||
"bit.arshift",
|
"bit.arshift",
|
||||||
"bit.rol",
|
"bit.rol",
|
||||||
"bit.ror",
|
"bit.ror",
|
||||||
"bit.band",
|
"bit.band",
|
||||||
"bit.bor",
|
"bit.bor",
|
||||||
"bit.bxor",
|
"bit.bxor",
|
||||||
"bit.tohex",
|
"bit.tohex",
|
||||||
"string.byte",
|
"string.byte",
|
||||||
"string.char",
|
"string.char",
|
||||||
"string.sub",
|
"string.sub",
|
||||||
"string.rep",
|
"string.rep",
|
||||||
"string.reverse",
|
"string.reverse",
|
||||||
"string.lower",
|
"string.lower",
|
||||||
"string.upper",
|
"string.upper",
|
||||||
"string.dump",
|
"string.dump",
|
||||||
"string.find",
|
"string.find",
|
||||||
"string.match",
|
"string.match",
|
||||||
"string.gmatch_aux",
|
"string.gmatch_aux",
|
||||||
"string.gmatch",
|
"string.gmatch",
|
||||||
"string.gsub",
|
"string.gsub",
|
||||||
"string.format",
|
"string.format",
|
||||||
"table.maxn",
|
"table.maxn",
|
||||||
"table.insert",
|
"table.insert",
|
||||||
"table.concat",
|
"table.concat",
|
||||||
"table.sort",
|
"table.sort",
|
||||||
"table.new",
|
"table.new",
|
||||||
"table.clear",
|
"table.clear",
|
||||||
"io.method.close",
|
"io.method.close",
|
||||||
"io.method.read",
|
"io.method.read",
|
||||||
"io.method.write",
|
"io.method.write",
|
||||||
"io.method.flush",
|
"io.method.flush",
|
||||||
"io.method.seek",
|
"io.method.seek",
|
||||||
"io.method.setvbuf",
|
"io.method.setvbuf",
|
||||||
"io.method.lines",
|
"io.method.lines",
|
||||||
"io.method.__gc",
|
"io.method.__gc",
|
||||||
"io.method.__tostring",
|
"io.method.__tostring",
|
||||||
"io.open",
|
"io.open",
|
||||||
"io.popen",
|
"io.popen",
|
||||||
"io.tmpfile",
|
"io.tmpfile",
|
||||||
"io.close",
|
"io.close",
|
||||||
"io.read",
|
"io.read",
|
||||||
"io.write",
|
"io.write",
|
||||||
"io.flush",
|
"io.flush",
|
||||||
"io.input",
|
"io.input",
|
||||||
"io.output",
|
"io.output",
|
||||||
"io.lines",
|
"io.lines",
|
||||||
"io.type",
|
"io.type",
|
||||||
"os.execute",
|
"os.execute",
|
||||||
"os.remove",
|
"os.remove",
|
||||||
"os.rename",
|
"os.rename",
|
||||||
"os.tmpname",
|
"os.tmpname",
|
||||||
"os.getenv",
|
"os.getenv",
|
||||||
"os.exit",
|
"os.exit",
|
||||||
"os.clock",
|
"os.clock",
|
||||||
"os.date",
|
"os.date",
|
||||||
"os.time",
|
"os.time",
|
||||||
"os.difftime",
|
"os.difftime",
|
||||||
"os.setlocale",
|
"os.setlocale",
|
||||||
"debug.getregistry",
|
"debug.getregistry",
|
||||||
"debug.getmetatable",
|
"debug.getmetatable",
|
||||||
"debug.setmetatable",
|
"debug.setmetatable",
|
||||||
"debug.getfenv",
|
"debug.getfenv",
|
||||||
"debug.setfenv",
|
"debug.setfenv",
|
||||||
"debug.getinfo",
|
"debug.getinfo",
|
||||||
"debug.getlocal",
|
"debug.getlocal",
|
||||||
"debug.setlocal",
|
"debug.setlocal",
|
||||||
"debug.getupvalue",
|
"debug.getupvalue",
|
||||||
"debug.setupvalue",
|
"debug.setupvalue",
|
||||||
"debug.upvalueid",
|
"debug.upvalueid",
|
||||||
"debug.upvaluejoin",
|
"debug.upvaluejoin",
|
||||||
"debug.sethook",
|
"debug.sethook",
|
||||||
"debug.gethook",
|
"debug.gethook",
|
||||||
"debug.debug",
|
"debug.debug",
|
||||||
"debug.traceback",
|
"debug.traceback",
|
||||||
"jit.on",
|
"jit.on",
|
||||||
"jit.off",
|
"jit.off",
|
||||||
"jit.flush",
|
"jit.flush",
|
||||||
"jit.status",
|
"jit.status",
|
||||||
"jit.attach",
|
"jit.attach",
|
||||||
"jit.util.funcinfo",
|
"jit.util.funcinfo",
|
||||||
"jit.util.funcbc",
|
"jit.util.funcbc",
|
||||||
"jit.util.funck",
|
"jit.util.funck",
|
||||||
"jit.util.funcuvname",
|
"jit.util.funcuvname",
|
||||||
"jit.util.traceinfo",
|
"jit.util.traceinfo",
|
||||||
"jit.util.traceir",
|
"jit.util.traceir",
|
||||||
"jit.util.tracek",
|
"jit.util.tracek",
|
||||||
"jit.util.tracesnap",
|
"jit.util.tracesnap",
|
||||||
"jit.util.tracemc",
|
"jit.util.tracemc",
|
||||||
"jit.util.traceexitstub",
|
"jit.util.traceexitstub",
|
||||||
"jit.util.ircalladdr",
|
"jit.util.ircalladdr",
|
||||||
"jit.opt.start",
|
"jit.opt.start",
|
||||||
"jit.profile.start",
|
"jit.profile.start",
|
||||||
"jit.profile.stop",
|
"jit.profile.stop",
|
||||||
"jit.profile.dumpstack",
|
"jit.profile.dumpstack",
|
||||||
"ffi.meta.__index",
|
"ffi.meta.__index",
|
||||||
"ffi.meta.__newindex",
|
"ffi.meta.__newindex",
|
||||||
"ffi.meta.__eq",
|
"ffi.meta.__eq",
|
||||||
"ffi.meta.__len",
|
"ffi.meta.__len",
|
||||||
"ffi.meta.__lt",
|
"ffi.meta.__lt",
|
||||||
"ffi.meta.__le",
|
"ffi.meta.__le",
|
||||||
"ffi.meta.__concat",
|
"ffi.meta.__concat",
|
||||||
"ffi.meta.__call",
|
"ffi.meta.__call",
|
||||||
"ffi.meta.__add",
|
"ffi.meta.__add",
|
||||||
"ffi.meta.__sub",
|
"ffi.meta.__sub",
|
||||||
"ffi.meta.__mul",
|
"ffi.meta.__mul",
|
||||||
"ffi.meta.__div",
|
"ffi.meta.__div",
|
||||||
"ffi.meta.__mod",
|
"ffi.meta.__mod",
|
||||||
"ffi.meta.__pow",
|
"ffi.meta.__pow",
|
||||||
"ffi.meta.__unm",
|
"ffi.meta.__unm",
|
||||||
"ffi.meta.__tostring",
|
"ffi.meta.__tostring",
|
||||||
"ffi.meta.__pairs",
|
"ffi.meta.__pairs",
|
||||||
"ffi.meta.__ipairs",
|
"ffi.meta.__ipairs",
|
||||||
"ffi.clib.__index",
|
"ffi.clib.__index",
|
||||||
"ffi.clib.__newindex",
|
"ffi.clib.__newindex",
|
||||||
"ffi.clib.__gc",
|
"ffi.clib.__gc",
|
||||||
"ffi.callback.free",
|
"ffi.callback.free",
|
||||||
"ffi.callback.set",
|
"ffi.callback.set",
|
||||||
"ffi.cdef",
|
"ffi.cdef",
|
||||||
"ffi.new",
|
"ffi.new",
|
||||||
"ffi.cast",
|
"ffi.cast",
|
||||||
"ffi.typeof",
|
"ffi.typeof",
|
||||||
"ffi.typeinfo",
|
"ffi.typeinfo",
|
||||||
"ffi.istype",
|
"ffi.istype",
|
||||||
"ffi.sizeof",
|
"ffi.sizeof",
|
||||||
"ffi.alignof",
|
"ffi.alignof",
|
||||||
"ffi.offsetof",
|
"ffi.offsetof",
|
||||||
"ffi.errno",
|
"ffi.errno",
|
||||||
"ffi.string",
|
"ffi.string",
|
||||||
"ffi.copy",
|
"ffi.copy",
|
||||||
"ffi.fill",
|
"ffi.fill",
|
||||||
"ffi.abi",
|
"ffi.abi",
|
||||||
"ffi.metatype",
|
"ffi.metatype",
|
||||||
"ffi.gc",
|
"ffi.gc",
|
||||||
"ffi.load",
|
"ffi.load",
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@
|
||||||
-- ...
|
-- ...
|
||||||
-- zone("A*")
|
-- zone("A*")
|
||||||
-- ...
|
-- ...
|
||||||
-- -- print(zone:get()) --> "A*"
|
-- print(zone:get()) --> "A*"
|
||||||
-- ...
|
-- ...
|
||||||
-- zone()
|
-- zone()
|
||||||
-- ...
|
-- ...
|
||||||
-- -- print(zone:get()) --> "AI"
|
-- print(zone:get()) --> "AI"
|
||||||
-- ...
|
-- ...
|
||||||
-- zone()
|
-- zone()
|
||||||
--
|
--
|
||||||
|
|
@ -28,7 +28,7 @@ local remove = table.remove
|
||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
flush = function(t)
|
flush = function(t)
|
||||||
for i = #t, 1, -1 do t[i] = nil end
|
for i=#t,1,-1 do t[i] = nil end
|
||||||
end,
|
end,
|
||||||
get = function(t)
|
get = function(t)
|
||||||
return t[#t]
|
return t[#t]
|
||||||
|
|
@ -36,9 +36,10 @@ return setmetatable({
|
||||||
}, {
|
}, {
|
||||||
__call = function(t, zone)
|
__call = function(t, zone)
|
||||||
if zone then
|
if zone then
|
||||||
t[#t + 1] = zone
|
t[#t+1] = zone
|
||||||
else
|
else
|
||||||
return (assert(remove(t), "empty zone stack"))
|
return (assert(remove(t), "empty zone stack"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
-- imported functions and modules
|
-- imported functions and modules
|
||||||
local tonumber, type, print, error = tonumber, type, print, error
|
local tonumber, type, print, error = tonumber, type, print, error
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local m = require "lpeg"
|
local m = require"lpeg"
|
||||||
|
|
||||||
-- 'm' will be used to parse expressions, and 'mm' will be used to
|
-- 'm' will be used to parse expressions, and 'mm' will be used to
|
||||||
-- create expressions; that is, 're' runs on 'm', creating patterns
|
-- create expressions; that is, 're' runs on 'm', creating patterns
|
||||||
|
|
@ -24,7 +24,7 @@ local any = m.P(1)
|
||||||
|
|
||||||
|
|
||||||
-- Pre-defined names
|
-- Pre-defined names
|
||||||
local Predef = { nl = m.P "\n" }
|
local Predef = { nl = m.P"\n" }
|
||||||
|
|
||||||
|
|
||||||
local mem
|
local mem
|
||||||
|
|
@ -32,7 +32,7 @@ local fmem
|
||||||
local gmem
|
local gmem
|
||||||
|
|
||||||
|
|
||||||
local function updatelocale()
|
local function updatelocale ()
|
||||||
mm.locale(Predef)
|
mm.locale(Predef)
|
||||||
Predef.a = Predef.alpha
|
Predef.a = Predef.alpha
|
||||||
Predef.c = Predef.cntrl
|
Predef.c = Predef.cntrl
|
||||||
|
|
@ -54,10 +54,10 @@ local function updatelocale()
|
||||||
Predef.U = any - Predef.u
|
Predef.U = any - Predef.u
|
||||||
Predef.W = any - Predef.w
|
Predef.W = any - Predef.w
|
||||||
Predef.X = any - Predef.x
|
Predef.X = any - Predef.x
|
||||||
mem = {} -- restart memoization
|
mem = {} -- restart memoization
|
||||||
fmem = {}
|
fmem = {}
|
||||||
gmem = {}
|
gmem = {}
|
||||||
local mt = { __mode = "v" }
|
local mt = {__mode = "v"}
|
||||||
setmetatable(mem, mt)
|
setmetatable(mem, mt)
|
||||||
setmetatable(fmem, mt)
|
setmetatable(fmem, mt)
|
||||||
setmetatable(gmem, mt)
|
setmetatable(gmem, mt)
|
||||||
|
|
@ -68,49 +68,47 @@ updatelocale()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local I = m.P(function(s, i)
|
local I = m.P(function (s,i) print(i, s:sub(1, i-1)); return i end)
|
||||||
print(i, s:sub(1, i - 1)); return i
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
local function getdef(id, defs)
|
local function getdef (id, defs)
|
||||||
local c = defs and defs[id]
|
local c = defs and defs[id]
|
||||||
if not c then error("undefined name: " .. id) end
|
if not c then error("undefined name: " .. id) end
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function patt_error(s, i)
|
local function patt_error (s, i)
|
||||||
local msg = (#s < i + 20) and s:sub(i)
|
local msg = (#s < i + 20) and s:sub(i)
|
||||||
or s:sub(i, i + 20) .. "..."
|
or s:sub(i,i+20) .. "..."
|
||||||
msg = ("pattern error near '%s'"):format(msg)
|
msg = ("pattern error near '%s'"):format(msg)
|
||||||
error(msg, 2)
|
error(msg, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function mult(p, n)
|
local function mult (p, n)
|
||||||
local np = mm.P(true)
|
local np = mm.P(true)
|
||||||
while n >= 1 do
|
while n >= 1 do
|
||||||
if n % 2 >= 1 then np = np * p end
|
if n%2 >= 1 then np = np * p end
|
||||||
p = p * p
|
p = p * p
|
||||||
n = n / 2
|
n = n/2
|
||||||
end
|
end
|
||||||
return np
|
return np
|
||||||
end
|
end
|
||||||
|
|
||||||
local function equalcap(s, i, c)
|
local function equalcap (s, i, c)
|
||||||
if type(c) ~= "string" then return nil end
|
if type(c) ~= "string" then return nil end
|
||||||
local e = #c + i
|
local e = #c + i
|
||||||
if s:sub(i, e - 1) == c then return e else return nil end
|
if s:sub(i, e - 1) == c then return e else return nil end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local S = (Predef.space + "--" * (any - Predef.nl) ^ 0) ^ 0
|
local S = (Predef.space + "--" * (any - Predef.nl)^0)^0
|
||||||
|
|
||||||
local name = m.R("AZ", "az", "__") * m.R("AZ", "az", "__", "09") ^ 0
|
local name = m.R("AZ", "az", "__") * m.R("AZ", "az", "__", "09")^0
|
||||||
|
|
||||||
local arrow = S * "<-"
|
local arrow = S * "<-"
|
||||||
|
|
||||||
local seq_follow = m.P "/" + ")" + "}" + ":}" + "~}" + "|}" + (name * arrow) + -1
|
local seq_follow = m.P"/" + ")" + "}" + ":}" + "~}" + "|}" + (name * arrow) + -1
|
||||||
|
|
||||||
name = m.C(name)
|
name = m.C(name)
|
||||||
|
|
||||||
|
|
@ -118,102 +116,101 @@ name = m.C(name)
|
||||||
-- a defined name only have meaning in a given environment
|
-- a defined name only have meaning in a given environment
|
||||||
local Def = name * m.Carg(1)
|
local Def = name * m.Carg(1)
|
||||||
|
|
||||||
local num = m.C(m.R "09" ^ 1) * S / tonumber
|
local num = m.C(m.R"09"^1) * S / tonumber
|
||||||
|
|
||||||
local String = "'" * m.C((any - "'") ^ 0) * "'" +
|
local String = "'" * m.C((any - "'")^0) * "'" +
|
||||||
'"' * m.C((any - '"') ^ 0) * '"'
|
'"' * m.C((any - '"')^0) * '"'
|
||||||
|
|
||||||
|
|
||||||
local defined = "%" * Def / function(c, Defs)
|
local defined = "%" * Def / function (c,Defs)
|
||||||
local cat = Defs and Defs[c] or Predef[c]
|
local cat = Defs and Defs[c] or Predef[c]
|
||||||
if not cat then error("name '" .. c .. "' undefined") end
|
if not cat then error ("name '" .. c .. "' undefined") end
|
||||||
return cat
|
return cat
|
||||||
end
|
end
|
||||||
|
|
||||||
local Range = m.Cs(any * (m.P "-" / "") * (any - "]")) / mm.R
|
local Range = m.Cs(any * (m.P"-"/"") * (any - "]")) / mm.R
|
||||||
|
|
||||||
local item = defined + Range + m.C(any)
|
local item = defined + Range + m.C(any)
|
||||||
|
|
||||||
local Class =
|
local Class =
|
||||||
"["
|
"["
|
||||||
* (m.C(m.P "^" ^ -1)) -- optional complement symbol
|
* (m.C(m.P"^"^-1)) -- optional complement symbol
|
||||||
* m.Cf(item * (item - "]") ^ 0, mt.__add) /
|
* m.Cf(item * (item - "]")^0, mt.__add) /
|
||||||
function(c, p) return c == "^" and any - p or p end
|
function (c, p) return c == "^" and any - p or p end
|
||||||
* "]"
|
* "]"
|
||||||
|
|
||||||
local function adddef(t, k, exp)
|
local function adddef (t, k, exp)
|
||||||
if t[k] then
|
if t[k] then
|
||||||
error("'" .. k .. "' already defined as a rule")
|
error("'"..k.."' already defined as a rule")
|
||||||
else
|
else
|
||||||
t[k] = exp
|
t[k] = exp
|
||||||
end
|
end
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
local function firstdef(n, r) return adddef({ n }, n, r) end
|
local function firstdef (n, r) return adddef({n}, n, r) end
|
||||||
|
|
||||||
|
|
||||||
local function NT(n, b)
|
local function NT (n, b)
|
||||||
if not b then
|
if not b then
|
||||||
error("rule '" .. n .. "' used outside a grammar")
|
error("rule '"..n.."' used outside a grammar")
|
||||||
else
|
else return mm.V(n)
|
||||||
return mm.V(n)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local exp = m.P { "Exp",
|
local exp = m.P{ "Exp",
|
||||||
Exp = S * (m.V "Grammar"
|
Exp = S * ( m.V"Grammar"
|
||||||
+ m.Cf(m.V "Seq" * ("/" * S * m.V "Seq") ^ 0, mt.__add)),
|
+ m.Cf(m.V"Seq" * ("/" * S * m.V"Seq")^0, mt.__add) );
|
||||||
Seq = m.Cf(m.Cc(m.P "") * m.V "Prefix" ^ 0, mt.__mul)
|
Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix"^0 , mt.__mul)
|
||||||
* (#seq_follow + patt_error),
|
* (#seq_follow + patt_error);
|
||||||
Prefix = "&" * S * m.V "Prefix" / mt.__len
|
Prefix = "&" * S * m.V"Prefix" / mt.__len
|
||||||
+ "!" * S * m.V "Prefix" / mt.__unm
|
+ "!" * S * m.V"Prefix" / mt.__unm
|
||||||
+ m.V "Suffix",
|
+ m.V"Suffix";
|
||||||
Suffix = m.Cf(m.V "Primary" * S *
|
Suffix = m.Cf(m.V"Primary" * S *
|
||||||
((m.P "+" * m.Cc(1, mt.__pow)
|
( ( m.P"+" * m.Cc(1, mt.__pow)
|
||||||
+ m.P "*" * m.Cc(0, mt.__pow)
|
+ m.P"*" * m.Cc(0, mt.__pow)
|
||||||
+ m.P "?" * m.Cc(-1, mt.__pow)
|
+ m.P"?" * m.Cc(-1, mt.__pow)
|
||||||
+ "^" * (m.Cg(num * m.Cc(mult))
|
+ "^" * ( m.Cg(num * m.Cc(mult))
|
||||||
+ m.Cg(m.C(m.S "+-" * m.R "09" ^ 1) * m.Cc(mt.__pow))
|
+ m.Cg(m.C(m.S"+-" * m.R"09"^1) * m.Cc(mt.__pow))
|
||||||
)
|
)
|
||||||
+ "->" * S * (m.Cg((String + num) * m.Cc(mt.__div))
|
+ "->" * S * ( m.Cg((String + num) * m.Cc(mt.__div))
|
||||||
+ m.P "{}" * m.Cc(nil, m.Ct)
|
+ m.P"{}" * m.Cc(nil, m.Ct)
|
||||||
+ m.Cg(Def / getdef * m.Cc(mt.__div))
|
+ m.Cg(Def / getdef * m.Cc(mt.__div))
|
||||||
)
|
)
|
||||||
+ "=>" * S * m.Cg(Def / getdef * m.Cc(m.Cmt))
|
+ "=>" * S * m.Cg(Def / getdef * m.Cc(m.Cmt))
|
||||||
) * S
|
) * S
|
||||||
) ^ 0, function(a, b, f) return f(a, b) end),
|
)^0, function (a,b,f) return f(a,b) end );
|
||||||
Primary = "(" * m.V "Exp" * ")"
|
Primary = "(" * m.V"Exp" * ")"
|
||||||
+ String / mm.P
|
+ String / mm.P
|
||||||
+ Class
|
+ Class
|
||||||
+ defined
|
+ defined
|
||||||
+ "{:" * (name * ":" + m.Cc(nil)) * m.V "Exp" * ":}" /
|
+ "{:" * (name * ":" + m.Cc(nil)) * m.V"Exp" * ":}" /
|
||||||
function(n, p) return mm.Cg(p, n) end
|
function (n, p) return mm.Cg(p, n) end
|
||||||
+ "=" * name / function(n) return mm.Cmt(mm.Cb(n), equalcap) end
|
+ "=" * name / function (n) return mm.Cmt(mm.Cb(n), equalcap) end
|
||||||
+ m.P "{}" / mm.Cp
|
+ m.P"{}" / mm.Cp
|
||||||
+ "{~" * m.V "Exp" * "~}" / mm.Cs
|
+ "{~" * m.V"Exp" * "~}" / mm.Cs
|
||||||
+ "{|" * m.V "Exp" * "|}" / mm.Ct
|
+ "{|" * m.V"Exp" * "|}" / mm.Ct
|
||||||
+ "{" * m.V "Exp" * "}" / mm.C
|
+ "{" * m.V"Exp" * "}" / mm.C
|
||||||
+ m.P "." * m.Cc(any)
|
+ m.P"." * m.Cc(any)
|
||||||
+ (name * -arrow + "<" * name * ">") * m.Cb("G") / NT,
|
+ (name * -arrow + "<" * name * ">") * m.Cb("G") / NT;
|
||||||
Definition = name * arrow * m.V "Exp",
|
Definition = name * arrow * m.V"Exp";
|
||||||
Grammar = m.Cg(m.Cc(true), "G") *
|
Grammar = m.Cg(m.Cc(true), "G") *
|
||||||
m.Cf(m.V "Definition" / firstdef * m.Cg(m.V "Definition") ^ 0,
|
m.Cf(m.V"Definition" / firstdef * m.Cg(m.V"Definition")^0,
|
||||||
adddef) / mm.P
|
adddef) / mm.P
|
||||||
}
|
}
|
||||||
|
|
||||||
local pattern = S * m.Cg(m.Cc(false), "G") * exp / mm.P * (-any + patt_error)
|
local pattern = S * m.Cg(m.Cc(false), "G") * exp / mm.P * (-any + patt_error)
|
||||||
|
|
||||||
|
|
||||||
local function compile(p, defs)
|
local function compile (p, defs)
|
||||||
if mm.type(p) == "pattern" then return p end -- already compiled
|
if mm.type(p) == "pattern" then return p end -- already compiled
|
||||||
local cp = pattern:match(p, 1, defs)
|
local cp = pattern:match(p, 1, defs)
|
||||||
if not cp then error("incorrect pattern", 3) end
|
if not cp then error("incorrect pattern", 3) end
|
||||||
return cp
|
return cp
|
||||||
end
|
end
|
||||||
|
|
||||||
local function match(s, p, i)
|
local function match (s, p, i)
|
||||||
local cp = mem[p]
|
local cp = mem[p]
|
||||||
if not cp then
|
if not cp then
|
||||||
cp = compile(p)
|
cp = compile(p)
|
||||||
|
|
@ -222,28 +219,26 @@ local function match(s, p, i)
|
||||||
return cp:match(s, i or 1)
|
return cp:match(s, i or 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function find(s, p, i)
|
local function find (s, p, i)
|
||||||
local cp = fmem[p]
|
local cp = fmem[p]
|
||||||
if not cp then
|
if not cp then
|
||||||
cp = compile(p) / 0
|
cp = compile(p) / 0
|
||||||
cp = mm.P { mm.Cp() * cp * mm.Cp() + 1 * mm.V(1) }
|
cp = mm.P{ mm.Cp() * cp * mm.Cp() + 1 * mm.V(1) }
|
||||||
fmem[p] = cp
|
fmem[p] = cp
|
||||||
end
|
end
|
||||||
local i, e = cp:match(s, i or 1)
|
local i, e = cp:match(s, i or 1)
|
||||||
if i then
|
if i then return i, e - 1
|
||||||
return i, e - 1
|
else return i
|
||||||
else
|
|
||||||
return i
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function gsub(s, p, rep)
|
local function gsub (s, p, rep)
|
||||||
local g = gmem[p] or {} -- ensure gmem[p] is not collected while here
|
local g = gmem[p] or {} -- ensure gmem[p] is not collected while here
|
||||||
gmem[p] = g
|
gmem[p] = g
|
||||||
local cp = g[rep]
|
local cp = g[rep]
|
||||||
if not cp then
|
if not cp then
|
||||||
cp = compile(p)
|
cp = compile(p)
|
||||||
cp = mm.Cs((cp / rep + 1) ^ 0)
|
cp = mm.Cs((cp / rep + 1)^0)
|
||||||
g[rep] = cp
|
g[rep] = cp
|
||||||
end
|
end
|
||||||
return cp:match(s)
|
return cp:match(s)
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ local function _SimpleDecoder(wire_type, decode_value)
|
||||||
return function(field_number, is_repeated, is_packed, key, new_default)
|
return function(field_number, is_repeated, is_packed, key, new_default)
|
||||||
if is_packed then
|
if is_packed then
|
||||||
local DecodeVarint = _DecodeVarint
|
local DecodeVarint = _DecodeVarint
|
||||||
return function(buffer, pos, pend, message, field_dict)
|
return function (buffer, pos, pend, message, field_dict)
|
||||||
local value = field_dict[key]
|
local value = field_dict[key]
|
||||||
if value == nil then
|
if value == nil then
|
||||||
value = new_default(message)
|
value = new_default(message)
|
||||||
|
|
@ -79,7 +79,7 @@ local function _SimpleDecoder(wire_type, decode_value)
|
||||||
local element, new_pos = decode_value(buffer, pos)
|
local element, new_pos = decode_value(buffer, pos)
|
||||||
value:append(element)
|
value:append(element)
|
||||||
pos = new_pos + tag_len
|
pos = new_pos + tag_len
|
||||||
if sub(buffer, new_pos + 1, pos) ~= tag_bytes or new_pos >= pend then
|
if sub(buffer, new_pos+1, pos) ~= tag_bytes or new_pos >= pend then
|
||||||
if new_pos > pend then
|
if new_pos > pend then
|
||||||
error('Truncated message.')
|
error('Truncated message.')
|
||||||
end
|
end
|
||||||
|
|
@ -88,7 +88,7 @@ local function _SimpleDecoder(wire_type, decode_value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return function(buffer, pos, pend, message, field_dict)
|
return function (buffer, pos, pend, message, field_dict)
|
||||||
field_dict[key], pos = decode_value(buffer, pos)
|
field_dict[key], pos = decode_value(buffer, pos)
|
||||||
if pos > pend then
|
if pos > pend then
|
||||||
field_dict[key] = nil
|
field_dict[key] = nil
|
||||||
|
|
@ -101,7 +101,7 @@ local function _SimpleDecoder(wire_type, decode_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _ModifiedDecoder(wire_type, decode_value, modify_value)
|
local function _ModifiedDecoder(wire_type, decode_value, modify_value)
|
||||||
local InnerDecode = function(buffer, pos)
|
local InnerDecode = function (buffer, pos)
|
||||||
local result, new_pos = decode_value(buffer, pos)
|
local result, new_pos = decode_value(buffer, pos)
|
||||||
return modify_value(result), new_pos
|
return modify_value(result), new_pos
|
||||||
end
|
end
|
||||||
|
|
@ -116,7 +116,6 @@ local function _StructPackDecoder(wire_type, value_size, format)
|
||||||
local result = struct_unpack(format, buffer, pos)
|
local result = struct_unpack(format, buffer, pos)
|
||||||
return result, new_pos
|
return result, new_pos
|
||||||
end
|
end
|
||||||
|
|
||||||
return _SimpleDecoder(wire_type, InnerDecode)
|
return _SimpleDecoder(wire_type, InnerDecode)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -124,16 +123,16 @@ local function _Boolean(value)
|
||||||
return value ~= 0
|
return value ~= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
Int32Decoder = _SimpleDecoder(wire_format.WIRETYPE_VARINT, _DecodeSignedVarint32)
|
Int32Decoder = _SimpleDecoder(wire_format.WIRETYPE_VARINT, _DecodeSignedVarint32)
|
||||||
EnumDecoder = Int32Decoder
|
EnumDecoder = Int32Decoder
|
||||||
|
|
||||||
Int64Decoder = _SimpleDecoder(wire_format.WIRETYPE_VARINT, _DecodeSignedVarint64)
|
Int64Decoder = _SimpleDecoder(wire_format.WIRETYPE_VARINT, _DecodeSignedVarint64)
|
||||||
|
|
||||||
UInt32Decoder = _SimpleDecoder(wire_format.WIRETYPE_VARINT, _DecodeVarint32)
|
UInt32Decoder = _SimpleDecoder(wire_format.WIRETYPE_VARINT, _DecodeVarint32)
|
||||||
UInt64Decoder = _SimpleDecoder(wire_format.WIRETYPE_VARINT, _DecodeVarint64)
|
UInt64Decoder = _SimpleDecoder(wire_format.WIRETYPE_VARINT, _DecodeVarint64)
|
||||||
|
|
||||||
SInt32Decoder = _ModifiedDecoder(wire_format.WIRETYPE_VARINT, _DecodeVarint32, wire_format.ZigZagDecode32)
|
SInt32Decoder = _ModifiedDecoder(wire_format.WIRETYPE_VARINT, _DecodeVarint32, wire_format.ZigZagDecode32)
|
||||||
SInt64Decoder = _ModifiedDecoder(wire_format.WIRETYPE_VARINT, _DecodeVarint64, wire_format.ZigZagDecode64)
|
SInt64Decoder = _ModifiedDecoder(wire_format.WIRETYPE_VARINT, _DecodeVarint64, wire_format.ZigZagDecode64)
|
||||||
|
|
||||||
Fixed32Decoder = _StructPackDecoder(wire_format.WIRETYPE_FIXED32, 4, string.byte('I'))
|
Fixed32Decoder = _StructPackDecoder(wire_format.WIRETYPE_FIXED32, 4, string.byte('I'))
|
||||||
Fixed64Decoder = _StructPackDecoder(wire_format.WIRETYPE_FIXED64, 8, string.byte('Q'))
|
Fixed64Decoder = _StructPackDecoder(wire_format.WIRETYPE_FIXED64, 8, string.byte('Q'))
|
||||||
|
|
@ -154,7 +153,7 @@ function StringDecoder(field_number, is_repeated, is_packed, key, new_default)
|
||||||
if is_repeated then
|
if is_repeated then
|
||||||
local tag_bytes = encoder.TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
|
local tag_bytes = encoder.TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
|
||||||
local tag_len = #tag_bytes
|
local tag_len = #tag_bytes
|
||||||
return function(buffer, pos, pend, message, field_dict)
|
return function (buffer, pos, pend, message, field_dict)
|
||||||
local value = field_dict[key]
|
local value = field_dict[key]
|
||||||
if value == nil then
|
if value == nil then
|
||||||
value = new_default(message)
|
value = new_default(message)
|
||||||
|
|
@ -167,7 +166,7 @@ function StringDecoder(field_number, is_repeated, is_packed, key, new_default)
|
||||||
if new_pos > pend then
|
if new_pos > pend then
|
||||||
error('Truncated string.')
|
error('Truncated string.')
|
||||||
end
|
end
|
||||||
value:append(sub(buffer, pos + 1, new_pos))
|
value:append(sub(buffer, pos+1, new_pos))
|
||||||
pos = new_pos + tag_len
|
pos = new_pos + tag_len
|
||||||
if sub(buffer, new_pos + 1, pos) ~= tag_bytes or new_pos == pend then
|
if sub(buffer, new_pos + 1, pos) ~= tag_bytes or new_pos == pend then
|
||||||
return new_pos
|
return new_pos
|
||||||
|
|
@ -175,7 +174,7 @@ function StringDecoder(field_number, is_repeated, is_packed, key, new_default)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return function(buffer, pos, pend, message, field_dict)
|
return function (buffer, pos, pend, message, field_dict)
|
||||||
local size, new_pos
|
local size, new_pos
|
||||||
size, pos = DecodeVarint(buffer, pos)
|
size, pos = DecodeVarint(buffer, pos)
|
||||||
new_pos = pos + size
|
new_pos = pos + size
|
||||||
|
|
@ -195,7 +194,7 @@ function BytesDecoder(field_number, is_repeated, is_packed, key, new_default)
|
||||||
if is_repeated then
|
if is_repeated then
|
||||||
local tag_bytes = encoder.TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
|
local tag_bytes = encoder.TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
|
||||||
local tag_len = #tag_bytes
|
local tag_len = #tag_bytes
|
||||||
return function(buffer, pos, pend, message, field_dict)
|
return function (buffer, pos, pend, message, field_dict)
|
||||||
local value = field_dict[key]
|
local value = field_dict[key]
|
||||||
if value == nil then
|
if value == nil then
|
||||||
value = new_default(message)
|
value = new_default(message)
|
||||||
|
|
@ -237,7 +236,7 @@ function MessageDecoder(field_number, is_repeated, is_packed, key, new_default)
|
||||||
if is_repeated then
|
if is_repeated then
|
||||||
local tag_bytes = encoder.TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
|
local tag_bytes = encoder.TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
|
||||||
local tag_len = #tag_bytes
|
local tag_len = #tag_bytes
|
||||||
return function(buffer, pos, pend, message, field_dict)
|
return function (buffer, pos, pend, message, field_dict)
|
||||||
local value = field_dict[key]
|
local value = field_dict[key]
|
||||||
if value == nil then
|
if value == nil then
|
||||||
value = new_default(message)
|
value = new_default(message)
|
||||||
|
|
@ -260,7 +259,7 @@ function MessageDecoder(field_number, is_repeated, is_packed, key, new_default)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return function(buffer, pos, pend, message, field_dict)
|
return function (buffer, pos, pend, message, field_dict)
|
||||||
local value = field_dict[key]
|
local value = field_dict[key]
|
||||||
if value == nil then
|
if value == nil then
|
||||||
value = new_default(message)
|
value = new_default(message)
|
||||||
|
|
@ -288,7 +287,7 @@ end
|
||||||
|
|
||||||
function _SkipFixed64(buffer, pos, pend)
|
function _SkipFixed64(buffer, pos, pend)
|
||||||
pos = pos + 8
|
pos = pos + 8
|
||||||
if pos > pend then
|
if pos > pend then
|
||||||
error('Truncated message.')
|
error('Truncated message.')
|
||||||
end
|
end
|
||||||
return pos
|
return pos
|
||||||
|
|
@ -328,11 +327,11 @@ function _FieldSkipper()
|
||||||
_RaiseInvalidWireType,
|
_RaiseInvalidWireType,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- wiretype_mask = wire_format.TAG_TYPE_MASK
|
-- wiretype_mask = wire_format.TAG_TYPE_MASK
|
||||||
local ord = string.byte
|
local ord = string.byte
|
||||||
local sub = string.sub
|
local sub = string.sub
|
||||||
|
|
||||||
return function(buffer, pos, pend, tag_bytes)
|
return function (buffer, pos, pend, tag_bytes)
|
||||||
local wire_type = ord(sub(tag_bytes, 1, 1)) % 8 + 1
|
local wire_type = ord(sub(tag_bytes, 1, 1)) % 8 + 1
|
||||||
return WIRETYPE_TO_SKIPPER[wire_type](buffer, pos, pend)
|
return WIRETYPE_TO_SKIPPER[wire_type](buffer, pos, pend)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ local error = error
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local print = print
|
local print = print
|
||||||
local table = table
|
local table = table
|
||||||
local string = string
|
local string = string
|
||||||
local tostring = tostring
|
local tostring = tostring
|
||||||
local type = type
|
local type = type
|
||||||
|
|
@ -47,7 +47,7 @@ local function make_descriptor(name, descriptor, usable_key)
|
||||||
if usable_key[key] then
|
if usable_key[key] then
|
||||||
rawset(self, key, value)
|
rawset(self, key, value)
|
||||||
else
|
else
|
||||||
error("error key: " .. key)
|
error("error key: "..key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
};
|
};
|
||||||
|
|
@ -60,7 +60,7 @@ local function make_descriptor(name, descriptor, usable_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
make_descriptor("Descriptor", {}, {
|
make_descriptor("Descriptor", {}, {
|
||||||
name = true,
|
name = true,
|
||||||
full_name = true,
|
full_name = true,
|
||||||
filename = true,
|
filename = true,
|
||||||
|
|
@ -92,11 +92,11 @@ make_descriptor("FieldDescriptor", FieldDescriptor, {
|
||||||
})
|
})
|
||||||
|
|
||||||
make_descriptor("EnumDescriptor", {}, {
|
make_descriptor("EnumDescriptor", {}, {
|
||||||
name = true,
|
name = true,
|
||||||
full_name = true,
|
full_name = true,
|
||||||
values = true,
|
values = true,
|
||||||
containing_type = true,
|
containing_type = true,
|
||||||
options = true
|
options = true
|
||||||
})
|
})
|
||||||
|
|
||||||
make_descriptor("EnumValueDescriptor", {}, {
|
make_descriptor("EnumValueDescriptor", {}, {
|
||||||
|
|
@ -138,14 +138,14 @@ local NON_PACKABLE_TYPES = {
|
||||||
|
|
||||||
local _VALUE_CHECKERS = {
|
local _VALUE_CHECKERS = {
|
||||||
[FieldDescriptor.CPPTYPE_INT32] = type_checkers.Int32ValueChecker(),
|
[FieldDescriptor.CPPTYPE_INT32] = type_checkers.Int32ValueChecker(),
|
||||||
[FieldDescriptor.CPPTYPE_INT64] = type_checkers.TypeChecker({ string = true, number = true }),
|
[FieldDescriptor.CPPTYPE_INT64] = type_checkers.TypeChecker({string = true, number = true}),
|
||||||
[FieldDescriptor.CPPTYPE_UINT32] = type_checkers.Uint32ValueChecker(),
|
[FieldDescriptor.CPPTYPE_UINT32] = type_checkers.Uint32ValueChecker(),
|
||||||
[FieldDescriptor.CPPTYPE_UINT64] = type_checkers.TypeChecker({ string = true, number = true }),
|
[FieldDescriptor.CPPTYPE_UINT64] = type_checkers.TypeChecker({string = true, number = true}),
|
||||||
[FieldDescriptor.CPPTYPE_DOUBLE] = type_checkers.TypeChecker({ number = true }),
|
[FieldDescriptor.CPPTYPE_DOUBLE] = type_checkers.TypeChecker({number = true}),
|
||||||
[FieldDescriptor.CPPTYPE_FLOAT] = type_checkers.TypeChecker({ number = true }),
|
[FieldDescriptor.CPPTYPE_FLOAT] = type_checkers.TypeChecker({number = true}),
|
||||||
[FieldDescriptor.CPPTYPE_BOOL] = type_checkers.TypeChecker({ boolean = true, bool = true, int = true }),
|
[FieldDescriptor.CPPTYPE_BOOL] = type_checkers.TypeChecker({boolean = true, bool = true, int=true}),
|
||||||
[FieldDescriptor.CPPTYPE_ENUM] = type_checkers.Int32ValueChecker(),
|
[FieldDescriptor.CPPTYPE_ENUM] = type_checkers.Int32ValueChecker(),
|
||||||
[FieldDescriptor.CPPTYPE_STRING] = type_checkers.TypeChecker({ string = true })
|
[FieldDescriptor.CPPTYPE_STRING] = type_checkers.TypeChecker({string = true})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -267,30 +267,30 @@ end
|
||||||
|
|
||||||
local function _DefaultValueConstructorForField(field)
|
local function _DefaultValueConstructorForField(field)
|
||||||
if field.label == FieldDescriptor.LABEL_REPEATED then
|
if field.label == FieldDescriptor.LABEL_REPEATED then
|
||||||
if type(field.default_value) ~= "table" or #(field.default_value) ~= 0 then
|
if type(field.default_value) ~= "table" or #(field.default_value) ~= 0 then
|
||||||
error('Repeated field default value not empty list:' .. tostring(field.default_value))
|
error('Repeated field default value not empty list:' .. tostring(field.default_value))
|
||||||
end
|
end
|
||||||
if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE then
|
if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE then
|
||||||
local message_type = field.message_type
|
local message_type = field.message_type
|
||||||
return function(message)
|
return function (message)
|
||||||
return containers.RepeatedCompositeFieldContainer(message._listener_for_children, message_type)
|
return containers.RepeatedCompositeFieldContainer(message._listener_for_children, message_type)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local type_checker = GetTypeChecker(field.cpp_type, field.type)
|
local type_checker = GetTypeChecker(field.cpp_type, field.type)
|
||||||
return function(message)
|
return function (message)
|
||||||
return containers.RepeatedScalarFieldContainer(message._listener_for_children, type_checker)
|
return containers.RepeatedScalarFieldContainer(message._listener_for_children, type_checker)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE then
|
if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE then
|
||||||
local message_type = field.message_type
|
local message_type = field.message_type
|
||||||
return function(message)
|
return function (message)
|
||||||
result = message_type._concrete_class()
|
result = message_type._concrete_class()
|
||||||
result._SetListener(message._listener_for_children)
|
result._SetListener(message._listener_for_children)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return function(message)
|
return function (message)
|
||||||
return field.default_value
|
return field.default_value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -299,18 +299,15 @@ local function _AttachFieldHelpers(message_meta, field_descriptor)
|
||||||
local is_repeated = (field_descriptor.label == FieldDescriptor.LABEL_REPEATED)
|
local is_repeated = (field_descriptor.label == FieldDescriptor.LABEL_REPEATED)
|
||||||
local is_packed = (field_descriptor.has_options and field_descriptor.GetOptions().packed)
|
local is_packed = (field_descriptor.has_options and field_descriptor.GetOptions().packed)
|
||||||
|
|
||||||
rawset(field_descriptor, "_encoder",
|
rawset(field_descriptor, "_encoder", TYPE_TO_ENCODER[field_descriptor.type](field_descriptor.number, is_repeated, is_packed))
|
||||||
TYPE_TO_ENCODER[field_descriptor.type](field_descriptor.number, is_repeated, is_packed))
|
rawset(field_descriptor, "_sizer", TYPE_TO_SIZER[field_descriptor.type](field_descriptor.number, is_repeated, is_packed))
|
||||||
rawset(field_descriptor, "_sizer",
|
|
||||||
TYPE_TO_SIZER[field_descriptor.type](field_descriptor.number, is_repeated, is_packed))
|
|
||||||
rawset(field_descriptor, "_default_constructor", _DefaultValueConstructorForField(field_descriptor))
|
rawset(field_descriptor, "_default_constructor", _DefaultValueConstructorForField(field_descriptor))
|
||||||
|
|
||||||
local AddDecoder = function(wiretype, is_packed)
|
local AddDecoder = function(wiretype, is_packed)
|
||||||
local tag_bytes = encoder.TagBytes(field_descriptor.number, wiretype)
|
local tag_bytes = encoder.TagBytes(field_descriptor.number, wiretype)
|
||||||
message_meta._decoders_by_tag[tag_bytes] = TYPE_TO_DECODER[field_descriptor.type](field_descriptor.number,
|
message_meta._decoders_by_tag[tag_bytes] = TYPE_TO_DECODER[field_descriptor.type](field_descriptor.number, is_repeated, is_packed, field_descriptor, field_descriptor._default_constructor)
|
||||||
is_repeated, is_packed, field_descriptor, field_descriptor._default_constructor)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
AddDecoder(FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type], False)
|
AddDecoder(FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type], False)
|
||||||
if is_repeated and IsTypePackable(field_descriptor.type) then
|
if is_repeated and IsTypePackable(field_descriptor.type) then
|
||||||
AddDecoder(wire_format.WIRETYPE_LENGTH_DELIMITED, True)
|
AddDecoder(wire_format.WIRETYPE_LENGTH_DELIMITED, True)
|
||||||
|
|
@ -333,7 +330,7 @@ local function _InitMethod(message_meta)
|
||||||
self._fields = {}
|
self._fields = {}
|
||||||
self._is_present_in_parent = false
|
self._is_present_in_parent = false
|
||||||
self._listener = listener_mod.NullMessageListener()
|
self._listener = listener_mod.NullMessageListener()
|
||||||
self._listener_for_children = listener_mod.Listener(self)
|
self._listener_for_children = listener_mod.Listener(self)
|
||||||
return setmetatable(self, message_meta)
|
return setmetatable(self, message_meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -367,7 +364,7 @@ local function _AddPropertiesForNonRepeatedCompositeField(field, message_meta)
|
||||||
local field_value = self._fields[field]
|
local field_value = self._fields[field]
|
||||||
if field_value == nil then
|
if field_value == nil then
|
||||||
field_value = message_type._concrete_class()
|
field_value = message_type._concrete_class()
|
||||||
field_value:_SetListener(self._listener_for_children)
|
field_value:_SetListener(self._listener_for_children)
|
||||||
self._fields[field] = field_value
|
self._fields[field] = field_value
|
||||||
|
|
||||||
if not self._cached_byte_size_dirty then
|
if not self._cached_byte_size_dirty then
|
||||||
|
|
@ -377,7 +374,7 @@ local function _AddPropertiesForNonRepeatedCompositeField(field, message_meta)
|
||||||
return field_value
|
return field_value
|
||||||
end
|
end
|
||||||
message_meta._setter[property_name] = function(self, new_value)
|
message_meta._setter[property_name] = function(self, new_value)
|
||||||
error('Assignment not allowed to composite field' .. property_name .. 'in protocol message object.')
|
error('Assignment not allowed to composite field' .. property_name .. 'in protocol message object.' )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -387,7 +384,7 @@ local function _AddPropertiesForNonRepeatedScalarField(field, message)
|
||||||
local default_value = field.default_value
|
local default_value = field.default_value
|
||||||
|
|
||||||
message._getter[property_name] = function(self)
|
message._getter[property_name] = function(self)
|
||||||
local value = self._fields[field]
|
local value = self._fields[field]
|
||||||
if value ~= nil then
|
if value ~= nil then
|
||||||
return self._fields[field]
|
return self._fields[field]
|
||||||
else
|
else
|
||||||
|
|
@ -438,9 +435,8 @@ local _ED_meta = {
|
||||||
__newindex = function(self, extension_handle, value)
|
__newindex = function(self, extension_handle, value)
|
||||||
local _extended_message = rawget(self, "_extended_message")
|
local _extended_message = rawget(self, "_extended_message")
|
||||||
if (extension_handle.label == FieldDescriptor.LABEL_REPEATED or
|
if (extension_handle.label == FieldDescriptor.LABEL_REPEATED or
|
||||||
extension_handle.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE) then
|
extension_handle.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE) then
|
||||||
error('Cannot assign to extension "' ..
|
error('Cannot assign to extension "'.. extension_handle.full_name .. '" because it is a repeated or composite type.')
|
||||||
extension_handle.full_name .. '" because it is a repeated or composite type.')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local type_checker = GetTypeChecker(extension_handle.cpp_type, extension_handle.type)
|
local type_checker = GetTypeChecker(extension_handle.cpp_type, extension_handle.type)
|
||||||
|
|
@ -466,11 +462,11 @@ local function _AddPropertiesForFields(descriptor, message_meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _AddPropertiesForExtensions(descriptor, message_meta)
|
local function _AddPropertiesForExtensions(descriptor, message_meta)
|
||||||
local extension_dict = descriptor._extensions_by_name
|
local extension_dict = descriptor._extensions_by_name
|
||||||
for extension_name, extension_field in pairs(extension_dict) do
|
for extension_name, extension_field in pairs(extension_dict) do
|
||||||
local constant_name = string.upper(extension_name) .. "_FIELD_NUMBER"
|
local constant_name = string.upper(extension_name) .. "_FIELD_NUMBER"
|
||||||
message_meta._member[constant_name] = extension_field.number
|
message_meta._member[constant_name] = extension_field.number
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _AddStaticMethods(message_meta)
|
local function _AddStaticMethods(message_meta)
|
||||||
|
|
@ -509,33 +505,30 @@ end
|
||||||
function sortFunc(a, b)
|
function sortFunc(a, b)
|
||||||
return a.index < b.index
|
return a.index < b.index
|
||||||
end
|
end
|
||||||
|
function pairsByKeys (t, f)
|
||||||
function pairsByKeys(t, f)
|
|
||||||
local a = {}
|
local a = {}
|
||||||
for n in pairs(t) do table.insert(a, n) end
|
for n in pairs(t) do table.insert(a, n) end
|
||||||
table.sort(a, f)
|
table.sort(a, f)
|
||||||
local i = 0 -- iterator variable
|
local i = 0 -- iterator variable
|
||||||
local iter = function() -- iterator function
|
local iter = function () -- iterator function
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if a[i] == nil then
|
if a[i] == nil then return nil
|
||||||
return nil
|
else return a[i], t[a[i]]
|
||||||
else
|
end
|
||||||
return a[i], t[a[i]]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return iter
|
return iter
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _AddListFieldsMethod(message_descriptor, message_meta)
|
local function _AddListFieldsMethod(message_descriptor, message_meta)
|
||||||
message_meta._member.ListFields = function(self)
|
message_meta._member.ListFields = function (self)
|
||||||
local list_field = function(fields)
|
local list_field = function(fields)
|
||||||
--local f, s, v = pairs(self._fields)
|
--local f, s, v = pairs(self._fields)
|
||||||
local f, s, v = pairsByKeys(self._fields, sortFunc)
|
local f,s,v = pairsByKeys(self._fields, sortFunc)
|
||||||
local iter = function(a, i)
|
local iter = function(a, i)
|
||||||
while true do
|
while true do
|
||||||
local descriptor, value = f(a, i)
|
local descriptor, value = f(a, i)
|
||||||
if descriptor == nil then
|
if descriptor == nil then
|
||||||
return
|
return
|
||||||
elseif _IsPresent(descriptor, value) then
|
elseif _IsPresent(descriptor, value) then
|
||||||
return descriptor, value
|
return descriptor, value
|
||||||
end
|
end
|
||||||
|
|
@ -554,23 +547,23 @@ local function _AddHasFieldMethod(message_descriptor, message_meta)
|
||||||
singular_fields[field.name] = field
|
singular_fields[field.name] = field
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
message_meta._member.HasField = function(self, field_name)
|
message_meta._member.HasField = function (self, field_name)
|
||||||
field = singular_fields[field_name]
|
field = singular_fields[field_name]
|
||||||
if field == nil then
|
if field == nil then
|
||||||
error('Protocol message has no singular "' .. field_name .. '" field.')
|
error('Protocol message has no singular "'.. field_name.. '" field.')
|
||||||
end
|
end
|
||||||
if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE then
|
if field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE then
|
||||||
value = self._fields[field]
|
value = self._fields[field]
|
||||||
return value ~= nil and value._is_present_in_parent
|
return value ~= nil and value._is_present_in_parent
|
||||||
else
|
else
|
||||||
local valueTmp = self._fields[field]
|
local valueTmp = self._fields[field]
|
||||||
return valueTmp ~= nil
|
return valueTmp ~= nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _AddClearFieldMethod(message_descriptor, message_meta)
|
local function _AddClearFieldMethod(message_descriptor, message_meta)
|
||||||
local singular_fields = {}
|
local singular_fields = {}
|
||||||
for _, field in ipairs(message_descriptor.fields) do
|
for _, field in ipairs(message_descriptor.fields) do
|
||||||
if field.label ~= FieldDescriptor.LABEL_REPEATED then
|
if field.label ~= FieldDescriptor.LABEL_REPEATED then
|
||||||
singular_fields[field.name] = field
|
singular_fields[field.name] = field
|
||||||
|
|
@ -578,16 +571,16 @@ local function _AddClearFieldMethod(message_descriptor, message_meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
message_meta._member.ClearField = function(self, field_name)
|
message_meta._member.ClearField = function(self, field_name)
|
||||||
field = singular_fields[field_name]
|
field = singular_fields[field_name]
|
||||||
if field == nil then
|
if field == nil then
|
||||||
error('Protocol message has no singular "' .. field_name .. '" field.')
|
error('Protocol message has no singular "'.. field_name.. '" field.')
|
||||||
end
|
end
|
||||||
|
|
||||||
if self._fields[field] then
|
if self._fields[field] then
|
||||||
self._fields[field] = nil
|
self._fields[field] = nil
|
||||||
end
|
end
|
||||||
message_meta._member._Modified(self)
|
message_meta._member._Modified(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _AddClearExtensionMethod(message_meta)
|
local function _AddClearExtensionMethod(message_meta)
|
||||||
|
|
@ -609,7 +602,7 @@ end
|
||||||
local function _AddStrMethod(message_meta)
|
local function _AddStrMethod(message_meta)
|
||||||
local format = text_format.msg_format
|
local format = text_format.msg_format
|
||||||
message_meta.__tostring = function(self)
|
message_meta.__tostring = function(self)
|
||||||
return format(self)
|
return format(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -659,14 +652,14 @@ end
|
||||||
local function _AddSerializeToStringMethod(message_descriptor, message_meta)
|
local function _AddSerializeToStringMethod(message_descriptor, message_meta)
|
||||||
message_meta._member.SerializeToString = function(self)
|
message_meta._member.SerializeToString = function(self)
|
||||||
if not message_meta._member.IsInitialized(self) then
|
if not message_meta._member.IsInitialized(self) then
|
||||||
error('Message is missing required fields: ' ..
|
error('Message is missing required fields: ' ..
|
||||||
table.concat(message_meta._member.FindInitializationErrors(self), ','))
|
table.concat(message_meta._member.FindInitializationErrors(self), ','))
|
||||||
end
|
end
|
||||||
return message_meta._member.SerializePartialToString(self)
|
return message_meta._member.SerializePartialToString(self)
|
||||||
end
|
end
|
||||||
message_meta._member.SerializeToIOString = function(self, iostring)
|
message_meta._member.SerializeToIOString = function(self, iostring)
|
||||||
if not message_meta._member.IsInitialized(self) then
|
if not message_meta._member.IsInitialized(self) then
|
||||||
error('Message is missing required fields: ' ..
|
error('Message is missing required fields: ' ..
|
||||||
table.concat(message_meta._member.FindInitializationErrors(self), ','))
|
table.concat(message_meta._member.FindInitializationErrors(self), ','))
|
||||||
end
|
end
|
||||||
return message_meta._member.SerializePartialToIOString(self, iostring)
|
return message_meta._member.SerializePartialToIOString(self, iostring)
|
||||||
|
|
@ -684,10 +677,10 @@ local function _AddSerializePartialToStringMethod(message_descriptor, message_me
|
||||||
local _serialize_partial_to_iostring = function(self, iostring)
|
local _serialize_partial_to_iostring = function(self, iostring)
|
||||||
local w = iostring.write
|
local w = iostring.write
|
||||||
local write = function(value)
|
local write = function(value)
|
||||||
w(iostring, value)
|
w(iostring, value)
|
||||||
end
|
end
|
||||||
_internal_serialize(self, write)
|
_internal_serialize(self, write)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local _serialize_partial_to_string = function(self)
|
local _serialize_partial_to_string = function(self)
|
||||||
|
|
@ -714,7 +707,7 @@ local function _AddMergeFromStringMethod(message_descriptor, message_meta)
|
||||||
local _internal_parse = function(self, buffer, pos, pend)
|
local _internal_parse = function(self, buffer, pos, pend)
|
||||||
message_meta._member._Modified(self)
|
message_meta._member._Modified(self)
|
||||||
local field_dict = self._fields
|
local field_dict = self._fields
|
||||||
local tag_bytes, new_pos
|
local tag_bytes, new_pos
|
||||||
local field_decoder
|
local field_decoder
|
||||||
while pos ~= pend do
|
while pos ~= pend do
|
||||||
tag_bytes, new_pos = ReadTag(buffer, pos)
|
tag_bytes, new_pos = ReadTag(buffer, pos)
|
||||||
|
|
@ -731,14 +724,14 @@ local function _AddMergeFromStringMethod(message_descriptor, message_meta)
|
||||||
end
|
end
|
||||||
return pos
|
return pos
|
||||||
end
|
end
|
||||||
message_meta._member._InternalParse = _internal_parse
|
message_meta._member._InternalParse = _internal_parse
|
||||||
|
|
||||||
local merge_from_string = function(self, serialized)
|
local merge_from_string = function(self, serialized)
|
||||||
local length = #serialized
|
local length = #serialized
|
||||||
if _internal_parse(self, serialized, 0, length) ~= length then
|
if _internal_parse(self, serialized, 0, length) ~= length then
|
||||||
error('Unexpected end-group tag.')
|
error('Unexpected end-group tag.')
|
||||||
end
|
end
|
||||||
return length
|
return length
|
||||||
end
|
end
|
||||||
message_meta._member.MergeFromString = merge_from_string
|
message_meta._member.MergeFromString = merge_from_string
|
||||||
|
|
||||||
|
|
@ -758,7 +751,7 @@ local function _AddIsInitializedMethod(message_descriptor, message_meta)
|
||||||
|
|
||||||
message_meta._member.IsInitialized = function(self, errors)
|
message_meta._member.IsInitialized = function(self, errors)
|
||||||
for _, field in ipairs(required_fields) do
|
for _, field in ipairs(required_fields) do
|
||||||
if self._fields[field] == nil or
|
if self._fields[field] == nil or
|
||||||
(field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE and not self._fields[field]._is_present_in_parent) then
|
(field.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE and not self._fields[field]._is_present_in_parent) then
|
||||||
if errors ~= nil then
|
if errors ~= nil then
|
||||||
errors[#errors + 1] = message_meta._member.FindInitializationErrors(self)
|
errors[#errors + 1] = message_meta._member.FindInitializationErrors(self)
|
||||||
|
|
@ -792,7 +785,7 @@ local function _AddIsInitializedMethod(message_descriptor, message_meta)
|
||||||
message_meta._member.FindInitializationErrors = function(self)
|
message_meta._member.FindInitializationErrors = function(self)
|
||||||
local errors = {}
|
local errors = {}
|
||||||
|
|
||||||
for _, field in ipairs(required_fields) do
|
for _,field in ipairs(required_fields) do
|
||||||
if not message_meta._member.HasField(self, field.name) then
|
if not message_meta._member.HasField(self, field.name) then
|
||||||
errors[#errors + 1] = field.name
|
errors[#errors + 1] = field.name
|
||||||
end
|
end
|
||||||
|
|
@ -830,7 +823,7 @@ local function _AddMergeFromMethod(message_meta)
|
||||||
local LABEL_REPEATED = FieldDescriptor.LABEL_REPEATED
|
local LABEL_REPEATED = FieldDescriptor.LABEL_REPEATED
|
||||||
local CPPTYPE_MESSAGE = FieldDescriptor.CPPTYPE_MESSAGE
|
local CPPTYPE_MESSAGE = FieldDescriptor.CPPTYPE_MESSAGE
|
||||||
|
|
||||||
message_meta._member.MergeFrom = function(self, msg)
|
message_meta._member.MergeFrom = function (self, msg)
|
||||||
assert(msg ~= self)
|
assert(msg ~= self)
|
||||||
message_meta._member._Modified(self)
|
message_meta._member._Modified(self)
|
||||||
|
|
||||||
|
|
@ -860,7 +853,7 @@ local function _AddMessageMethods(message_descriptor, message_meta)
|
||||||
_AddHasExtensionMethod(message_meta)
|
_AddHasExtensionMethod(message_meta)
|
||||||
end
|
end
|
||||||
_AddClearMethod(message_descriptor, message_meta)
|
_AddClearMethod(message_descriptor, message_meta)
|
||||||
-- _AddEqualsMethod(message_descriptor, message_meta)
|
-- _AddEqualsMethod(message_descriptor, message_meta)
|
||||||
_AddStrMethod(message_meta)
|
_AddStrMethod(message_meta)
|
||||||
_AddSetListenerMethod(message_meta)
|
_AddSetListenerMethod(message_meta)
|
||||||
_AddByteSizeMethod(message_descriptor, message_meta)
|
_AddByteSizeMethod(message_descriptor, message_meta)
|
||||||
|
|
@ -872,7 +865,7 @@ local function _AddMessageMethods(message_descriptor, message_meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _AddPrivateHelperMethods(message_meta)
|
local function _AddPrivateHelperMethods(message_meta)
|
||||||
local Modified = function(self)
|
local Modified = function (self)
|
||||||
if not self._cached_byte_size_dirty then
|
if not self._cached_byte_size_dirty then
|
||||||
self._cached_byte_size_dirty = true
|
self._cached_byte_size_dirty = true
|
||||||
self._listener_for_children.dirty = true
|
self._listener_for_children.dirty = true
|
||||||
|
|
@ -887,28 +880,28 @@ end
|
||||||
local function property_getter(message_meta)
|
local function property_getter(message_meta)
|
||||||
local getter = message_meta._getter
|
local getter = message_meta._getter
|
||||||
local member = message_meta._member
|
local member = message_meta._member
|
||||||
|
|
||||||
return function(self, property)
|
return function (self, property)
|
||||||
local g = getter[property]
|
local g = getter[property]
|
||||||
if g then
|
if g then
|
||||||
return g(self)
|
return g(self)
|
||||||
else
|
else
|
||||||
return member[property]
|
return member[property]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function property_setter(message_meta)
|
local function property_setter(message_meta)
|
||||||
local setter = message_meta._setter
|
local setter = message_meta._setter
|
||||||
|
|
||||||
return function(self, property, value)
|
return function (self, property, value)
|
||||||
local s = setter[property]
|
local s = setter[property]
|
||||||
if s then
|
if s then
|
||||||
s(self, value)
|
s(self, value)
|
||||||
else
|
else
|
||||||
error(property .. " not found")
|
error(property .. " not found")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _AddClassAttributesForNestedExtensions(descriptor, message_meta)
|
function _AddClassAttributesForNestedExtensions(descriptor, message_meta)
|
||||||
|
|
@ -936,16 +929,16 @@ local function Message(descriptor)
|
||||||
message_meta._getter = {}
|
message_meta._getter = {}
|
||||||
message_meta._setter = {}
|
message_meta._setter = {}
|
||||||
message_meta._member = {}
|
message_meta._member = {}
|
||||||
-- message_meta._name = descriptor.full_name
|
-- message_meta._name = descriptor.full_name
|
||||||
|
|
||||||
local ns = setmetatable({}, message_meta._member)
|
local ns = setmetatable({}, message_meta._member)
|
||||||
message_meta._member.__call = _InitMethod(message_meta)
|
message_meta._member.__call = _InitMethod(message_meta)
|
||||||
message_meta._member.__index = message_meta._member
|
message_meta._member.__index = message_meta._member
|
||||||
message_meta._member.type = ns
|
message_meta._member.type = ns
|
||||||
|
|
||||||
if rawget(descriptor, "_concrete_class") == nil then
|
if rawget(descriptor, "_concrete_class") == nil then
|
||||||
rawset(descriptor, "_concrete_class", ns)
|
rawset(descriptor, "_concrete_class", ns)
|
||||||
for k, field in ipairs(descriptor.fields) do
|
for k, field in ipairs(descriptor.fields) do
|
||||||
_AttachFieldHelpers(message_meta, field)
|
_AttachFieldHelpers(message_meta, field)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -958,9 +951,10 @@ local function Message(descriptor)
|
||||||
_AddPrivateHelperMethods(message_meta)
|
_AddPrivateHelperMethods(message_meta)
|
||||||
|
|
||||||
message_meta.__index = property_getter(message_meta)
|
message_meta.__index = property_getter(message_meta)
|
||||||
message_meta.__newindex = property_setter(message_meta)
|
message_meta.__newindex = property_setter(message_meta)
|
||||||
|
|
||||||
return ns
|
return ns
|
||||||
end
|
end
|
||||||
|
|
||||||
_M.Message = Message
|
_M.Message = Message
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,13 @@ local descriptor = require "protobuf.descriptor"
|
||||||
module "protobuf.text_format"
|
module "protobuf.text_format"
|
||||||
|
|
||||||
function format(buffer)
|
function format(buffer)
|
||||||
local len = string.len(buffer)
|
local len = string.len( buffer )
|
||||||
for i = 1, len, 16 do
|
for i = 1, len, 16 do
|
||||||
local text = ""
|
local text = ""
|
||||||
for j = i, math.min(i + 16 - 1, len) do
|
for j = i, math.min( i + 16 - 1, len ) do
|
||||||
text = string.format("%s %02x", text, string.byte(buffer, j))
|
text = string.format( "%s %02x", text, string.byte( buffer, j ) )
|
||||||
end
|
end
|
||||||
print(text)
|
print( text )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -76,3 +76,4 @@ function msg_format(msg)
|
||||||
msg_format_indent(write, msg, 0)
|
msg_format_indent(write, msg, 0)
|
||||||
return table.concat(out)
|
return table.concat(out)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,36 +3,36 @@
|
||||||
-- All rights reserved.
|
-- All rights reserved.
|
||||||
-- Use, modification and distribution are subject to the "MIT License"
|
-- Use, modification and distribution are subject to the "MIT License"
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
if jit then
|
if jit then
|
||||||
if jit.opt then
|
if jit.opt then
|
||||||
jit.opt.start(3)
|
jit.opt.start(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print("ver"..jit.version_num.." jit: ", jit.status())
|
print("ver"..jit.version_num.." jit: ", jit.status())
|
||||||
-- print(string.format("os: %s, arch: %s", jit.os, jit.arch))
|
print(string.format("os: %s, arch: %s", jit.os, jit.arch))
|
||||||
end
|
end
|
||||||
|
|
||||||
if DebugServerIp then
|
if DebugServerIp then
|
||||||
require("mobdebug").start(DebugServerIp)
|
require("mobdebug").start(DebugServerIp)
|
||||||
end
|
end
|
||||||
|
|
||||||
require "misc.functions"
|
require "misc.functions"
|
||||||
Mathf = require "UnityEngine.Mathf"
|
Mathf = require "UnityEngine.Mathf"
|
||||||
Vector3 = require "UnityEngine.Vector3"
|
Vector3 = require "UnityEngine.Vector3"
|
||||||
Quaternion = require "UnityEngine.Quaternion"
|
Quaternion = require "UnityEngine.Quaternion"
|
||||||
Vector2 = require "UnityEngine.Vector2"
|
Vector2 = require "UnityEngine.Vector2"
|
||||||
Vector4 = require "UnityEngine.Vector4"
|
Vector4 = require "UnityEngine.Vector4"
|
||||||
Color = require "UnityEngine.Color"
|
Color = require "UnityEngine.Color"
|
||||||
Ray = require "UnityEngine.Ray"
|
Ray = require "UnityEngine.Ray"
|
||||||
Bounds = require "UnityEngine.Bounds"
|
Bounds = require "UnityEngine.Bounds"
|
||||||
RaycastHit = require "UnityEngine.RaycastHit"
|
RaycastHit = require "UnityEngine.RaycastHit"
|
||||||
Touch = require "UnityEngine.Touch"
|
Touch = require "UnityEngine.Touch"
|
||||||
LayerMask = require "UnityEngine.LayerMask"
|
LayerMask = require "UnityEngine.LayerMask"
|
||||||
Plane = require "UnityEngine.Plane"
|
Plane = require "UnityEngine.Plane"
|
||||||
Time = reimport "UnityEngine.Time"
|
Time = reimport "UnityEngine.Time"
|
||||||
|
|
||||||
list = require "list"
|
list = require "list"
|
||||||
utf8 = require "misc.utf8"
|
utf8 = require "misc.utf8"
|
||||||
|
|
||||||
require "event"
|
require "event"
|
||||||
require "typeof"
|
require "typeof"
|
||||||
|
|
@ -42,4 +42,4 @@ require "System.coroutine"
|
||||||
require "System.ValueType"
|
require "System.ValueType"
|
||||||
require "System.Reflection.BindingFlags"
|
require "System.Reflection.BindingFlags"
|
||||||
|
|
||||||
--require "misc.strict"
|
--require "misc.strict"
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -88,5 +88,5 @@ TextureImporter:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
pSDShowRemoveMatteOption: 0
|
pSDShowRemoveMatteOption: 0
|
||||||
userData:
|
userData:
|
||||||
assetBundleName: base/main_majiang/d2fa434d27dc07bf09395dc32491060b
|
assetBundleName: base/main_majiang/abf0e2af8fb6daf78fa8ebcdd8acc4f0
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 965 KiB After Width: | Height: | Size: 483 KiB |
|
|
@ -88,5 +88,5 @@ TextureImporter:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
pSDShowRemoveMatteOption: 0
|
pSDShowRemoveMatteOption: 0
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName: base/main_majiang/abf0e2af8fb6daf78fa8ebcdd8acc4f0
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 166 KiB |
|
|
@ -0,0 +1,92 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ffe28b30c5a6cf24298b352cb37c18b2
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 11
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -100
|
||||||
|
wrapU: -1
|
||||||
|
wrapV: -1
|
||||||
|
wrapW: -1
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID:
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spritePackingTag:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
pSDShowRemoveMatteOption: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName: base/main_majiang/abf0e2af8fb6daf78fa8ebcdd8acc4f0
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -88,5 +88,5 @@ TextureImporter:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
pSDShowRemoveMatteOption: 0
|
pSDShowRemoveMatteOption: 0
|
||||||
userData:
|
userData:
|
||||||
assetBundleName: base/main_majiang/d2fa434d27dc07bf09395dc32491060b
|
assetBundleName: base/main_majiang/abf0e2af8fb6daf78fa8ebcdd8acc4f0
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|
|
||||||
|
|
@ -88,5 +88,5 @@ TextureImporter:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
pSDShowRemoveMatteOption: 0
|
pSDShowRemoveMatteOption: 0
|
||||||
userData:
|
userData:
|
||||||
assetBundleName: base/main_majiang/d2fa434d27dc07bf09395dc32491060b
|
assetBundleName: base/main_majiang/abf0e2af8fb6daf78fa8ebcdd8acc4f0
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|
|
||||||
|
|
@ -88,5 +88,5 @@ TextureImporter:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
pSDShowRemoveMatteOption: 0
|
pSDShowRemoveMatteOption: 0
|
||||||
userData:
|
userData:
|
||||||
assetBundleName: base/main_majiang/d2fa434d27dc07bf09395dc32491060b
|
assetBundleName: base/main_majiang/abf0e2af8fb6daf78fa8ebcdd8acc4f0
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|
|
||||||
|
|
@ -88,5 +88,5 @@ TextureImporter:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
pSDShowRemoveMatteOption: 0
|
pSDShowRemoveMatteOption: 0
|
||||||
userData:
|
userData:
|
||||||
assetBundleName: base/main_majiang/d2fa434d27dc07bf09395dc32491060b
|
assetBundleName: base/main_majiang/abf0e2af8fb6daf78fa8ebcdd8acc4f0
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@ guid: 326fa64ee0dd8b94aa86fa1978e56fa5
|
||||||
TextScriptImporter:
|
TextScriptImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
assetBundleName: base/main_majiang/d2fa434d27dc07bf09395dc32491060b
|
assetBundleName: base/main_majiang/abf0e2af8fb6daf78fa8ebcdd8acc4f0
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue