Просмотр исходного кода

remove: 移除java版的api文档生成器

Wendal Chen 4 лет назад
Родитель
Сommit
4e41bd59d6
90 измененных файлов с 0 добавлено и 6082 удалено
  1. 0 1
      README.md
  2. 0 551
      bsp/win32/lib/mqtt.lua
  3. 0 230
      bsp/win32/lib/mqtt2.lua
  4. 0 63
      docs.md
  5. 0 70
      supported.md
  6. 0 1
      tools/java/.gitignore
  7. 0 44
      tools/java/README.md
  8. 0 124
      tools/java/pom.xml
  9. 0 157
      tools/java/src/main/java/com/luatos/toolkit/LuatDocEntry.java
  10. 0 247
      tools/java/src/main/java/com/luatos/toolkit/LuatDocGenerator.java
  11. 0 49
      tools/java/src/main/java/com/luatos/toolkit/LuatDocSetup.java
  12. 0 57
      tools/java/src/main/java/com/luatos/toolkit/LuatRenderingSetup.java
  13. 0 64
      tools/java/src/main/java/com/luatos/toolkit/Luats.java
  14. 0 9
      tools/java/src/main/java/com/luatos/toolkit/api/FnSignParser.java
  15. 0 9
      tools/java/src/main/java/com/luatos/toolkit/api/LuDocParser.java
  16. 0 12
      tools/java/src/main/java/com/luatos/toolkit/api/LuDocRender.java
  17. 0 11
      tools/java/src/main/java/com/luatos/toolkit/api/LuDocSetRender.java
  18. 0 7
      tools/java/src/main/java/com/luatos/toolkit/api/TagParser.java
  19. 0 77
      tools/java/src/main/java/com/luatos/toolkit/bean/FnExample.java
  20. 0 7
      tools/java/src/main/java/com/luatos/toolkit/bean/FnLang.java
  21. 0 88
      tools/java/src/main/java/com/luatos/toolkit/bean/FnParam.java
  22. 0 105
      tools/java/src/main/java/com/luatos/toolkit/bean/FnReturn.java
  23. 0 327
      tools/java/src/main/java/com/luatos/toolkit/bean/FnSign.java
  24. 0 7
      tools/java/src/main/java/com/luatos/toolkit/bean/LuCmtAppend.java
  25. 0 64
      tools/java/src/main/java/com/luatos/toolkit/bean/LuCmtType.java
  26. 0 197
      tools/java/src/main/java/com/luatos/toolkit/bean/LuComment.java
  27. 0 146
      tools/java/src/main/java/com/luatos/toolkit/bean/LuDocument.java
  28. 0 182
      tools/java/src/main/java/com/luatos/toolkit/bean/LuHead.java
  29. 0 86
      tools/java/src/main/java/com/luatos/toolkit/bean/LuatDocSet.java
  30. 0 105
      tools/java/src/main/java/com/luatos/toolkit/impl/CFnSignParser.java
  31. 0 234
      tools/java/src/main/java/com/luatos/toolkit/impl/CLuDocParser.java
  32. 0 123
      tools/java/src/main/java/com/luatos/toolkit/impl/ComboDocSetRender.java
  33. 0 197
      tools/java/src/main/java/com/luatos/toolkit/impl/DoxyFnSignParser.java
  34. 0 30
      tools/java/src/main/java/com/luatos/toolkit/impl/JsonLuDocRender.java
  35. 0 23
      tools/java/src/main/java/com/luatos/toolkit/impl/LuHeadParser.java
  36. 0 164
      tools/java/src/main/java/com/luatos/toolkit/impl/MarkdownLuDocRender.java
  37. 0 96
      tools/java/src/main/java/com/luatos/toolkit/impl/NutMapTagParser.java
  38. 0 92
      tools/java/src/main/java/com/luatos/toolkit/util/ComboLuDocRender.java
  39. 0 7
      tools/java/src/main/resources/dft_readme.md
  40. 0 14
      tools/java/src/main/resources/doc-gen-air302.json
  41. 0 34
      tools/java/src/main/resources/doc-gen-luatos.json
  42. 0 14
      tools/java/src/main/resources/log4j.properties
  43. 0 13
      tools/java/src/main/resources/log4j2.xml
  44. 0 11
      tools/java/src/test/java/com/luatos/toolkit/AllLuTookietTest.java
  45. 0 157
      tools/java/src/test/java/com/luatos/toolkit/bean/FnSignTest.java
  46. 0 8
      tools/java/src/test/java/com/luatos/toolkit/bean/LuAllBeanTest.java
  47. 0 65
      tools/java/src/test/java/com/luatos/toolkit/bean/LuCommentTest.java
  48. 0 45
      tools/java/src/test/java/com/luatos/toolkit/impl/CLuDocParserTest.java
  49. 0 8
      tools/java/src/test/java/com/luatos/toolkit/impl/LuAllParserTest.java
  50. 0 37
      tools/java/src/test/java/com/luatos/toolkit/impl/TagParserTest.java
  51. 0 15
      tools/java/src/test/resources/expec/c_sign_fn_0.json
  52. 0 14
      tools/java/src/test/resources/expec/c_sign_fn_1.json
  53. 0 20
      tools/java/src/test/resources/expec/c_sign_fn_2.json
  54. 0 20
      tools/java/src/test/resources/expec/c_sign_fn_3.json
  55. 0 21
      tools/java/src/test/resources/expec/c_sign_fn_4.json
  56. 0 15
      tools/java/src/test/resources/expec/c_sign_fn_5.json
  57. 0 24
      tools/java/src/test/resources/expec/c_sign_fn_6.json
  58. 0 17
      tools/java/src/test/resources/expec/c_sign_fn_7.json
  59. 0 15
      tools/java/src/test/resources/expec/c_sign_fn_8.json
  60. 0 3
      tools/java/src/test/resources/expec/cmt_c_multi_0.txt
  61. 0 4
      tools/java/src/test/resources/expec/cmt_c_multi_1.txt
  62. 0 4
      tools/java/src/test/resources/expec/cmt_c_single_0.txt
  63. 0 4
      tools/java/src/test/resources/expec/cmt_c_single_1.txt
  64. 0 9
      tools/java/src/test/resources/expec/cmt_lua_0.txt
  65. 0 239
      tools/java/src/test/resources/expec/doc_parse_0.json
  66. 0 288
      tools/java/src/test/resources/expec/doc_parse_1.json
  67. 0 6
      tools/java/src/test/resources/expec/head_0.json
  68. 0 24
      tools/java/src/test/resources/expec/lua_cmt_fn_0.json
  69. 0 30
      tools/java/src/test/resources/expec/lua_cmt_fn_1.json
  70. 0 23
      tools/java/src/test/resources/expec/lua_cmt_fn_2.json
  71. 0 1
      tools/java/src/test/resources/input/c_sign_fn_0.txt
  72. 0 1
      tools/java/src/test/resources/input/c_sign_fn_1.txt
  73. 0 1
      tools/java/src/test/resources/input/c_sign_fn_2.txt
  74. 0 1
      tools/java/src/test/resources/input/c_sign_fn_3.txt
  75. 0 1
      tools/java/src/test/resources/input/c_sign_fn_4.txt
  76. 0 1
      tools/java/src/test/resources/input/c_sign_fn_5.txt
  77. 0 1
      tools/java/src/test/resources/input/c_sign_fn_6.txt
  78. 0 1
      tools/java/src/test/resources/input/c_sign_fn_7.txt
  79. 0 1
      tools/java/src/test/resources/input/c_sign_fn_8.txt
  80. 0 4
      tools/java/src/test/resources/input/cmt_c_multi_0.txt
  81. 0 6
      tools/java/src/test/resources/input/cmt_c_multi_1.txt
  82. 0 4
      tools/java/src/test/resources/input/cmt_c_single_0.txt
  83. 0 4
      tools/java/src/test/resources/input/cmt_c_single_1.txt
  84. 0 11
      tools/java/src/test/resources/input/cmt_lua_0.txt
  85. 0 237
      tools/java/src/test/resources/input/doc_parse_0.c
  86. 0 514
      tools/java/src/test/resources/input/doc_parse_1.c
  87. 0 4
      tools/java/src/test/resources/input/head_0.txt
  88. 0 9
      tools/java/src/test/resources/input/lua_cmt_fn_0.txt
  89. 0 10
      tools/java/src/test/resources/input/lua_cmt_fn_1.txt
  90. 0 6
      tools/java/src/test/resources/input/lua_cmt_fn_2.txt

+ 0 - 1
README.md

@@ -25,7 +25,6 @@ LuatOS-SoC是一款实时操作系统,用户编写Lua代码就可完成各种功
 
 * [详细介绍](README_FULL.md)
 * [wiki@luatos](https://wiki.luatos.com)
-* [设备支持情况](supported.md)
 
 ## 授权协议
 

+ 0 - 551
bsp/win32/lib/mqtt.lua

@@ -1,551 +0,0 @@
-
---- 模块功能:MQTT客户端
--- @module mqtt
--- @author openLuat
--- @license MIT
--- @copyright openLuat
--- @release 2017.10.24
-
-local mqtt = {}
-
--- MQTT 指令id
-local CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, PINGREQ, PINGRESP, DISCONNECT = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
-local CLIENT_COMMAND_TIMEOUT = 60000
-
-local sys = require "sys"
-local pack = _G.pack
-local string = _G.string
-local encodeLen = mqttcore.encodeLen
---local encodeUTF8 = mqttcore.encodeUTF8
--- local function encodeLen(len)
---     local s = ""
---     local digit
---     repeat
---         digit = len % 128
---         len = (len - digit) / 128
---         if len > 0 then
---             --digit = bit.bor(digit, 0x80)
---             digit = digit | 0x80
---         end
---         s = s .. string.char(digit)
---     until (len <= 0)
---     return s
--- end
-
-local encodeUTF8 = mqttcore.encodeUTF8
--- local function encodeUTF8(s)
---     if not s or #s == 0 then
---         return ""
---     else
---         return pack.pack(">P", s)
---     end
--- end
-
-local packCONNECT = mqttcore.packCONNECT
-
--- local function packCONNECT(clientId, keepAlive, username, password, cleanSession, will, version)
---     local content = pack.pack(">PbbHPAAAA",
---         version == "3.1" and "MQIsdp" or "MQTT",
---         version == "3.1" and 3 or 4,
---         (#username == 0 and 0 or 1) * 128 + (#password == 0 and 0 or 1) * 64 + will.retain * 32 + will.qos * 8 + will.flag * 4 + cleanSession * 2,
---         keepAlive,
---         clientId,
---         encodeUTF8(will.topic),
---         encodeUTF8(will.payload),
---         encodeUTF8(username),
---         encodeUTF8(password))
---     local mydata = pack.pack(">bAA",
---         CONNECT * 16,
---         encodeLen(string.len(content)),
---         content)
---     local tdata = mqttcore.packCONNECT(clientId, keepAlive, username, password, cleanSession, will, version)
---     log.info("mqtt", "true", mydata:toHex())
---     log.info("mqtt", "false", tdata:toHex())
---     return mydata
--- end
-
-local packSUBSCRIBE = mqttcore.packSUBSCRIBE
-
--- local function packSUBSCRIBE(dup, packetId, topics)
---     local header = SUBSCRIBE * 16 + dup * 8 + 2
---     local data = pack.pack(">H", packetId)
---     for topic, qos in pairs(topics) do
---         data = data .. pack.pack(">Pb", topic, qos)
---     end
---     local mydata = pack.pack(">bAA", header, encodeLen(#data), data)
---     log.info("mqtt", "true", mydata:toHex())
---     local tdata = mqttcore.packSUBSCRIBE(dup, packetId, topics)
---     log.info("mqtt", "false", tdata:toHex())
---     return mydata
--- end
-
-local packUNSUBSCRIBE = mqttcore.packUNSUBSCRIBE
--- local function packUNSUBSCRIBE(dup, packetId, topics)
---     local header = UNSUBSCRIBE * 16 + dup * 8 + 2
---     local data = pack.pack(">H", packetId)
---     for k, topic in pairs(topics) do
---         data = data .. pack.pack(">P", topic)
---     end
---     return pack.pack(">bAA", header, encodeLen(#data), data)
--- end
-
-local packPUBLISH = mqttcore.packPUBLISH
-
--- local function packPUBLISH(dup, qos, retain, packetId, topic, payload)
---     local header = PUBLISH * 16 + dup * 8 + qos * 2 + retain
---     local len = 2 + #topic + #payload
---     local mydata = nil
---     if qos > 0 then
---         mydata = pack.pack(">bAPHA", header, encodeLen(len + 2), topic, packetId, payload)
---     else
---         mydata = pack.pack(">bAPA", header, encodeLen(len), topic, payload)
---     end
---     local tdata = mqttcore.packPUBLISH(dup, qos, retain, packetId, topic, payload)
---     log.info("mqtt", "true", mydata:toHex())
---     log.info("mqtt", "false", tdata:toHex())
---     return mydata
--- end
-
-local packACK = mqttcore.packACK
-
--- local function packACK(id, dup, packetId)
---     return pack.pack(">bbH", id * 16 + dup * 8 + (id == PUBREL and 1 or 0) * 2, 0x02, packetId)
--- end
-
-local packZeroData = mqttcore.packZeroData
-
--- local function packZeroData(id, dup, qos, retain)
---     dup = dup or 0
---     qos = qos or 0
---     retain = retain or 0
---     return pack.pack(">bb", id * 16 + dup * 8 + qos * 2 + retain, 0)
--- end
-
-local function unpack(s)
-    if #s < 2 then return end
-    log.debug("mqtt.unpack", #s, string.toHex(string.sub(s, 1, 50)))
-    
-    -- read remaining length
-    local len = 0
-    local multiplier = 1
-    local pos = 2
-    
-    repeat
-        if pos > #s then return end
-        local digit = string.byte(s, pos)
-        len = len + ((digit % 128) * multiplier)
-        multiplier = multiplier * 128
-        pos = pos + 1
-    until digit < 128
-    
-    if #s < len + pos - 1 then return end
-    
-    local header = string.byte(s, 1)
-    
-    --local packet = {id = (header - (header % 16)) / 16, dup = ((header % 16) - ((header % 16) % 8)) / 8, qos = bit.band(header, 0x06) / 2, retain = bit.band(header, 0x01)}
-    local packet = {id = (header - (header % 16)) >> 4, dup = ((header % 16) - ((header % 16) % 8)) >> 3, qos = (header & 0x06) >> 1, retain = (header & 0x01)}
-    local nextpos
-    
-    if packet.id == CONNACK then
-        nextpos, packet.ackFlag, packet.rc = pack.unpack(s, "bb", pos)
-    elseif packet.id == PUBLISH then
-        nextpos, packet.topic = pack.unpack(s, ">P", pos)
-        if packet.qos > 0 then
-            nextpos, packet.packetId = pack.unpack(s, ">H", nextpos)
-        end
-        packet.payload = string.sub(s, nextpos, pos + len - 1)
-    elseif packet.id ~= PINGRESP then
-        if len >= 2 then
-            nextpos, packet.packetId = pack.unpack(s, ">H", pos)
-        else
-            packet.packetId = 0
-        end
-    end
-    
-    return packet, pos + len
-end
-
-local mqttc = {}
-mqttc.__index = mqttc
-
---- 创建一个mqtt client实例
--- @string clientId
--- @number[opt=300] keepAlive 心跳间隔(单位为秒),默认300秒
--- @string[opt=""] username 用户名,用户名为空配置为""或者nil
--- @string[opt=""] password 密码,密码为空配置为""或者nil
--- @number[opt=1] cleanSession 1/0
--- @table[opt=nil] will 遗嘱参数,格式为{qos=, retain=, topic=, payload=}
--- @string[opt="3.1.1"] version MQTT版本号
--- @return table mqttc client实例
--- @usage
--- mqttc = mqtt.client("clientid-123")
--- mqttc = mqtt.client("clientid-123",200)
--- mqttc = mqtt.client("clientid-123",nil,"user","password")
--- mqttc = mqtt.client("clientid-123",nil,"user","password",nil,nil,"3.1")
-function mqtt.client(clientId, keepAlive, username, password, cleanSession, will, version)
-    local o = {}
-    local packetId = 1
-    
-    if will then
-        will.flag = 1
-    else
-        will = {flag = 0, qos = 0, retain = 0, topic = "", payload = ""}
-    end
-    
-    o.clientId = clientId
-    o.keepAlive = keepAlive or 300
-    o.username = username or ""
-    o.password = password or ""
-    o.cleanSession = cleanSession or 1
-    o.version = version or "3.1.1"
-    o.will = will
-    o.commandTimeout = CLIENT_COMMAND_TIMEOUT
-    o.cache = {}-- 接收到的mqtt数据包缓冲
-    o.inbuf = "" -- 未完成的数据缓冲
-    o.connected = false
-    o.getNextPacketId = function()
-        packetId = packetId == 65535 and 1 or (packetId + 1)
-        return packetId
-    end
-    o.lastOTime = 0
-    o.pkgs = {}
-    
-    setmetatable(o, mqttc)
-    
-    return o
-end
-
--- 检测是否需要发送心跳包
-function mqttc:checkKeepAlive()
-    if self.keepAlive == 0 then return true end
-    if os.time() - self.lastOTime >= self.keepAlive then
-        if not self:write(packZeroData(PINGREQ)) then
-            log.info("mqtt.client:", "pingreq send fail")
-            return false
-        end
-    end
-    return true
-end
-
--- 发送mqtt数据
-function mqttc:write(data)
-    log.debug("mqtt.client:write", string.toHex(string.sub(data, 1, 50)))
-    local r = self.io:send(data)
-    if r then self.lastOTime = os.time() end
-    return r
-end
-
--- 接收mqtt数据包
-function mqttc:read(timeout, msg, msgNoResume)
-    if not self:checkKeepAlive() then
-        log.warn("mqtt.read checkKeepAlive fail")
-        return false
-    end
-
-    local topic = "MQTTC_PKG_" .. tostring(self.io:id())
-    local result, data, param = sys.waitUntil({topic, msg}, timeout)
-    --log.debug("mqtt.read", result, data, param)
-    if result then -- 收到topic消息
-        local pkg = table.remove(self.pkgs, 1)
-        if pkg ~= nil then
-            --log.debug("mqtt", "get packet", pkg.id, pkg.packetId)
-            return true, pkg
-        end
-        --log.debug("mqtt", "get sys.msg", msg, data)
-        return false, msg, data
-    else
-        if self.io:closed() == 1 then
-            return false
-        else
-            return false, "timeout"
-        end
-    end
-end
-
-local function update_resp(_self, data)
-    if #data > 0 then
-        if #_self.inbuf > 0 then
-            _self.inbuf = _self.inbuf .. data
-        else
-            _self.inbuf = data
-        end
-    end
-    --log.debug("mqttc", "data recv to unpack", _self.inbuf:toHex())
-    local packet, nextpos = unpack(_self.inbuf)
-    if packet then
-        log.info("mqttc", "msg unpack ok", packet.id)
-        _self.inbuf = string.sub(_self.inbuf, nextpos)
-        table.insert(_self.pkgs, packet)
-        sys.publish("MQTTC_PKG_" .. tostring(_self.io:id()))
-        if #_self.inbuf > 0 then
-            update_resp(_self, "")
-        end
-    else
-        log.info("mqttc", "data not full")
-    end
-
-    return true
-end
-
--- 等待接收指定的mqtt消息
-function mqttc:waitfor(id, timeout, msg, msgNoResume)
-    for index, packet in ipairs(self.cache) do
-        if packet.id == id then
-            return true, table.remove(self.cache, index)
-        end
-    end
-    
-    while true do
-        local insertCache = true
-        local r, data, param = self:read(timeout, msg, msgNoResume)
-        if r then
-            if data.id == PUBLISH then
-                if data.qos > 0 then
-                    if not self:write(packACK(data.qos == 1 and PUBACK or PUBREC, 0, data.packetId)) then
-                        log.info("mqtt.client:waitfor", "send publish ack failed", data.qos)
-                        return false
-                    end
-                end
-            elseif data.id == PUBREC or data.id == PUBREL then
-                if not self:write(packACK(data.id == PUBREC and PUBREL or PUBCOMP, 0, data.packetId)) then
-                    log.info("mqtt.client:waitfor", "send ack fail", data.id == PUBREC and "PUBREC" or "PUBCOMP")
-                    return false
-                end
-                insertCache = false
-            end
-            
-            if data.id == id then
-                return true, data
-            end
-            if insertCache then table.insert(self.cache, data) end
-        else
-            return false, data, param
-        end
-    end
-end
-
---- 连接mqtt服务器
--- @string host 服务器地址
--- @param port string或者number类型,服务器端口
--- @string[opt="tcp"] transport "tcp"或者"tcp_ssl"
--- @table[opt=nil] cert,table或者nil类型,ssl证书,当transport为"tcp_ssl"时,此参数才有意义。cert格式如下:
--- {
---     caCert = "ca.crt", --CA证书文件(Base64编码 X.509格式),如果存在此参数,则表示客户端会对服务器的证书进行校验;不存在则不校验
---     clientCert = "client.crt", --客户端证书文件(Base64编码 X.509格式),服务器对客户端的证书进行校验时会用到此参数
---     clientKey = "client.key", --客户端私钥文件(Base64编码 X.509格式)
---     clientPassword = "123456", --客户端证书文件密码[可选]
--- }
--- @number timeout, 链接服务器最长超时时间
--- @return result true表示成功,false或者nil表示失败
--- @usage mqttc = mqtt.client("clientid-123", nil, nil, false); mqttc:connect("mqttserver.com", 1883, "tcp", 5)
-function mqttc:connect(host, port, transport, cert, timeout)
-    if self.connected then
-        log.info("mqtt.client:connect", "has connected")
-        return false
-    end
-    
-    if self.io then
-        self.io:clean()
-        self.io:close()
-        self.io = nil
-    end
-    
-    if transport and transport ~= "tcp" and transport ~= "tcp_ssl" then
-        log.info("mqtt.client:connect", "invalid transport", transport)
-        return false
-    end
-
-    self.io = socket.tcp(transport == "tcp_ssl" or type(cert) == "table", cert)
-    self.io:host(host)
-    self.io:port(port)
-    local connect_topic = "NETC_CONNECT_" .. tostring(self.io:id())
-    self.io:on("connect", function(id, re)
-        log.info("mqtt", "connect result", re, re == 1 and "OK" or "FAIL")
-        sys.publish(connect_topic, re == 1)
-        if re == 0 then
-            self.io:clean()
-            self.io:close()
-        end
-    end)
-    self.io:on("recv", function(id, data)
-        if not update_resp(self, data) then
-            log.info("mqtt", "close connect for bad data")
-            self.io:clean()
-            self.io:close()
-        end
-    end)
-    if not self.io:start() then
-        self.io:clean()
-        self.io:close()
-        log.info("mqtt", "fail to start socket thread")
-        return false
-    end
-    --log.info("mqtt", "wait for connect")
-    local result, linked = sys.waitUntil(connect_topic, self.commandTimeout) -- 原本是15秒,在NBIOT下超时的概率不低,改成用commandTimeout
-    if not result then
-        log.info("mqtt", "connect timeout")
-        self.io:clean()
-        self.io:close()
-        return false
-    end
-    if not linked  or self.io:closed() == 1 then
-        log.info("mqtt", "connect fail", result, linked, self.io:closed() == 1)
-        self.io:clean()
-        self.io:close()
-        return false
-    end
-    --log.info("mqtt", "send packCONNECT")
-    if not self:write(packCONNECT(self.clientId, self.keepAlive, self.username, self.password, self.cleanSession, self.will, self.version)) then
-        log.info("mqtt.client:connect", "send fail")
-        return false
-    end
-    --log.info("mqtt", "waitfor CONNACK")
-    local r, packet = self:waitfor(CONNACK, self.commandTimeout, nil, true)
-    if not r or packet.rc ~= 0 then
-        log.info("mqtt.client:connect", "connack error", r and packet.rc or -1)
-        return false
-    end
-    
-    self.connected = true
-    --log.info("mqtt", "connected!~!")
-    
-    return true
-end
-
---- 订阅主题
--- @param topic,string或者table类型,一个主题时为string类型,多个主题时为table类型,主题内容为UTF8编码
--- @param[opt=0] qos,number或者nil,topic为一个主题时,qos为number类型(0/1/2,默认0);topic为多个主题时,qos为nil
--- @return bool true表示成功,false或者nil表示失败
--- @usage
--- mqttc:subscribe("/abc", 0) -- subscribe topic "/abc" with qos = 0
--- mqttc:subscribe({["/topic1"] = 0, ["/topic2"] = 1, ["/topic3"] = 2}) -- subscribe multi topic
-function mqttc:subscribe(topic, qos)
-    if not self.connected then
-        log.info("mqtt.client:subscribe", "not connected")
-        return false
-    end
-    
-    local topics
-    if type(topic) == "string" then
-        topics = {[topic] = qos and qos or 0}
-    else
-        topics = topic
-    end
-    
-    if not self:write(packSUBSCRIBE(0, self.getNextPacketId(), topics)) then
-        log.info("mqtt.client:subscribe", "send failed")
-        return false
-    end
-    
-    if not self:waitfor(SUBACK, self.commandTimeout, nil, true) then
-        log.info("mqtt.client:subscribe", "wait ack failed")
-        return false
-    end
-    
-    return true
-end
-
---- 取消订阅主题
--- @param topic,string或者table类型,一个主题时为string类型,多个主题时为table类型,主题内容为UTF8编码
--- @return bool true表示成功,false或者nil表示失败
--- @usage
--- mqttc:unsubscribe("/abc") -- unsubscribe topic "/abc"
--- mqttc:unsubscribe({"/topic1", "/topic2", "/topic3"}) -- unsubscribe multi topic
-function mqttc:unsubscribe(topic)
-    if not self.connected then
-        log.info("mqtt.client:unsubscribe", "not connected")
-        return false
-    end
-    
-    local topics
-    if type(topic) == "string" then
-        topics = {topic}
-    else
-        topics = topic
-    end
-    
-    if not self:write(packUNSUBSCRIBE(0, self.getNextPacketId(), topics)) then
-        log.info("mqtt.client:unsubscribe", "send failed")
-        return false
-    end
-    
-    if not self:waitfor(UNSUBACK, self.commandTimeout, nil, true) then
-        log.info("mqtt.client:unsubscribe", "wait ack failed")
-        return false
-    end
-    
-    return true
-end
-
---- 发布一条消息
--- @string topic UTF8编码的字符串
--- @string payload 用户自己控制payload的编码,mqtt.lua不会对payload做任何编码转换
--- @number[opt=0] qos 0/1/2, default 0
--- @number[opt=0] retain 0或者1
--- @return bool 发布成功返回true,失败返回false
--- @usage
--- mqttc = mqtt.client("clientid-123", nil, nil, false)
--- mqttc:connect("mqttserver.com", 1883, "tcp")
--- mqttc:publish("/topic", "publish from luat mqtt client", 0)
-function mqttc:publish(topic, payload, qos, retain)
-    if not self.connected then
-        log.info("mqtt.client:publish", "not connected")
-        return false
-    end
-    
-    qos = qos or 0
-    retain = retain or 0
-    
-    if not self:write(packPUBLISH(0, qos, retain, qos > 0 and self.getNextPacketId() or 0, topic, payload)) then
-        log.info("mqtt.client:publish", "socket send failed")
-        return false
-    end
-    
-    if qos == 0 then return true end
-    
-    if not self:waitfor(qos == 1 and PUBACK or PUBCOMP, self.commandTimeout, nil, true) then
-        log.warn("mqtt.client:publish", "wait ack timeout")
-        return false
-    end
-    
-    return true
-end
-
---- 接收消息
--- @number timeout 接收超时时间,单位毫秒
--- @string[opt=nil] msg 可选参数,控制socket所在的线程退出recv阻塞状态
--- @return result 数据接收结果,true表示成功,false表示失败
--- @return data 如果result为true,表示服务器发过来的包;如果result为false,表示错误信息,超时失败时为"timeout"
--- @return param msg控制退出时,返回msg的字符串
--- @usage
--- true, packet = mqttc:receive(2000)
--- false, error_message = mqttc:receive(2000)
--- false, msg, para = mqttc:receive(2000)
-function mqttc:receive(timeout, msg)
-    if not self.connected then
-        log.info("mqtt.client:receive", "not connected")
-        return false
-    end
-    
-    return self:waitfor(PUBLISH, timeout, msg)
-end
-
---- 断开与服务器的连接
--- @return nil
--- @usage
--- mqttc = mqtt.client("clientid-123", nil, nil, false)
--- mqttc:connect("mqttserver.com", 1883, "tcp")
--- process data
--- mqttc:disconnect()
-function mqttc:disconnect()
-    if self.io then
-        if self.connected then self:write(packZeroData(DISCONNECT)) end
-        self.io:close()
-        self.io = nil
-    end
-    self.cache = {}
-    self.inbuf = ""
-    self.connected = false
-end
-
-return mqtt

+ 0 - 230
bsp/win32/lib/mqtt2.lua

@@ -1,230 +0,0 @@
---[[
-异步MQTT客户端
-1. 自动重连
-2. 异步收发信息
-
-暂不支持的特性:
-1. qos 2的消息不被支持,以后也不会添加
-2. 不支持取消订阅(也许会添加,也许不会)
-
-用法请参考demo
-
-]]
-
--- MQTT 指令id
-local CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, PINGREQ, PINGRESP, DISCONNECT = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
-local CLIENT_COMMAND_TIMEOUT = 60000
-
-local packCONNECT = mqttcore.packCONNECT
-local packPUBLISH = mqttcore.packPUBLISH
-local packSUBSCRIBE = mqttcore.packSUBSCRIBE
-local packACK = mqttcore.packACK
-local packZeroData = mqttcore.packZeroData
-
-local mclog = log.debug
-local unpack = mqttcore.unpack
-
-local mqtt2 = {}
-
-local mqttc = {}
-mqttc.__index = mqttc
-
-function mqtt2.new(clientId, keepAlive, username, password, cleanSession, host, port, topics, cb, ckey)
-    local c = {
-        clientId = clientId,
-        keepAlive = keepAlive or 300,
-        username = username or "",
-        password = password or "",
-        cleanSession = cleanSession == nil and 1 or 0,
-        host = host,
-        port = port,
-        lping = 0,
-        stat = 0, -- 状态 0, 未连接, 1 已连接成功
-        nextid = 0, -- pkg的ID
-        running = false,
-        inpkgs = {},
-        outpkgs = {},
-        buff = "",
-        topics = topics or {},
-        cb = cb,
-        ckey = ckey or ""
-    }
-    if c.ckey == "" then c.ckey = "mqtt_" .. tostring(c) end
-    --mclog("mqtt", "MQTT Client Key", c.ckey)
-    setmetatable(c, mqttc)
-    return c
-end
-
--- 内部方法, 用于获取下一个pkg的id
-function mqttc:genId()
-    self.nextid = self.nextid == 65535 and 1 or (self.nextid + 1)
-    --mclog("mqtt", "next packet id", self.nextid)
-    return self.nextid
-end
-
--- 内部方法,用于处理待处理的数据包
-function mqttc:handle(netc)
-    local mc = self
-    -- 先处理服务器下发的数据包
-    if #mc.inpkgs > 0 then
-        --mclog("mqtt", "inpkgs count", #mc.inpkgs)
-        while 1 do
-            local pkg = table.remove( mc.inpkgs, 1 )
-            if pkg == nil then
-                break
-            end
-            -- 处理服务器下发的包
-            --mclog("mqtt", "handle pkg", json.encode(pkg))
-            if pkg.id == CONNACK then
-                mc.stat = 1
-                mc.lping = os.time()
-                --mclog("mqtt", "GOT CONNACK")
-                for k, v in pairs(mc.topics) do
-                    --mclog("mqtt", "sub topics", json.encode(mc.topics))
-                    netc:send(packSUBSCRIBE(0, mc:genId(), mc.topics))
-                    break
-                end
-            elseif pkg.id == PUBACK then
-                --mclog("mqtt", "GOT PUBACK")
-                sys.publish(mc.ckey .. "PUBACK")
-            elseif pkg.id == SUBACK then
-                --mclog("mqtt", "GOT SUBACK")
-                sys.publish(mc.ckey .. "SUBACK")
-            elseif pkg.id == PINGRESP then
-                mc.lping = os.time()
-                --mclog("mqtt", "GOT PINGRESP", mc.lping)
-            elseif pkg.id == UNSUBACK then
-                --mclog("mqtt", "GOT UNSUBACK")
-            elseif pkg.id == DISCONNECT then
-                --mclog("mqtt", "GOT DISCONNECT")
-            elseif pkg.id == PUBLISH then
-                --mclog("mqtt", "GOT PUBLISH", pkg.topic, pkg.qos)
-                if pkg.qos > 0 then
-                    -- 发送PUBACK
-                    --mclog("mqtt", "send back PUBACK")
-                    table.insert( mc.outpkgs, packACK(PUBACK, 0, pkg.packetId))
-                end
-                if mc.cb then
-                    --mclog("mqtt", "Callback for PUBLISH", mc.cb)
-                    mc.cb(pkg)
-                end
-            end
-        end
-    end
-    -- 处理需要上报的数据包
-    if #mc.outpkgs > 0 then
-        --mclog("mqtt", "outpkgs count", #mc.outpkgs)
-        while 1 do
-            local buff = table.remove( mc.outpkgs, 1)
-            if buff == nil then
-                break
-            end
-            --mclog("mqtt", "netc send", buff:toHex())
-            netc:send(buff)
-        end
-    end
-    -- 是否需要发心跳
-    if mc.lping > 0 and os.time() - mc.lping > mc.keepAlive * 0.75 then
-        --mclog("mqtt", "time for ping", mc.lping)
-        mc.lping = os.time()
-        netc:send(packZeroData(PINGREQ)) -- 发送心跳包
-    end
-end
-
--- 启动mqtt task, 要么在task里面执行, 要么新建一个task执行本方法
-function mqttc:run()
-    local mc = self
-    mc.running = true
-    while mc.running do
-        if socket.isReady() then
-            -- 先复位全部临时对象
-            mc.buff = ""
-            mc.inpkgs = {}
-            mc.outpkgs = {}
-            -- 建立socket对象
-            --mclog("mqtt", "try connect")
-            local netc = socket.tcp()
-            netc:host(mc.host)
-            netc:port(mc.port)
-            netc:on("connect", function(id, re)
-                --mclog("mqtt", "connect", id , re)
-                if re then
-                    -- 发送CONN包
-                    table.insert(mc.outpkgs, packCONNECT(mc.clientId, mc.keepAlive, mc.username, mc.password, mc.cleanSession, {topic="",payload="",qos=0,retain=0,flag=0}))
-                    sys.publish(mc.ckey)
-                end
-            end)
-            netc:on("recv", function(id, data)
-                --mclog("mqtt", "recv", id , data:sub(1, 10):toHex())
-                mc.buff = mc.buff .. data
-                while 1 do
-                    local packet, nextpos = unpack(mc.buff)
-                    if not packet then
-                        if #mc.buff > 4096 then
-                            log.warn("mqtt", "packet is too big!!!")
-                            netc:close()
-                        end
-                        break
-                    else
-                        mc.buff = mc.buff:sub(nextpos)
-                        --mclog("mqtt", "recv new pkg", json.encode(packet))
-                        table.insert( mc.inpkgs, packet)
-                        if #mc.buff < 2 then
-                            break
-                        end
-                    end
-                end
-                if #mc.inpkgs > 0 then
-                    sys.publish(mc.ckey)
-                end
-            end)
-            if netc:start() == 0 then
-                --mclog("mqtt", "start success")
-                local endTopic = "NETC_END_" .. netc:id()
-                while (netc:closed()) == 0 do
-                    mc:handle(netc)
-                    sys.waitUntil({endTopic, mc.ckey}, 30000)
-                    if not mc.running then netc:close() end
-                    --mclog("mqtt", "handle/timeout/ping", (netc:closed()))
-                end
-            end
-            -- 清理socket上下文
-            mclog("mqtt", "clean up")
-            netc:clean()
-            netc:close()
-            -- 将所有状态复位
-            mc.stat = 0
-
-            mclog("mqtt", "wait 5s for next loop")
-            sys.wait(5*1000) -- TODO 使用级数递增进行延时
-        else
-            sys.wait(1000)
-        end
-    end
-    -- 线程退出, 只可能是用户主动shutdown
-    mclog("mqtt", self.ckey, "exit")
-end
-
--- 订阅topic, table形式
-function mqttc:sub(topics)
-    table.insert(self.outpkgs, packSUBSCRIBE(0, self:genId(), topics))
-    sys.publish(self.ckey)
-    return sys.waitUntil(self.ckey .. "SUBACK", 30000)
-end
-
--- 上报数据
-function mqttc:pub(topic, qos, payload)
-    -- local function packPUBLISH(dup, qos, retain, packetId, topic, payload)
-    table.insert(self.outpkgs, packPUBLISH(0, qos, 0, qos > 0 and self:genId() or 0, topic, payload))
-    sys.publish(self.ckey)
-    if qos > 0 then
-        return sys.waitUntil(self.ckey .. "PUBACK", 30000)
-    end
-end
-
-function mqttc:shutdown()
-    self.running = false
-    sys.publish(self.ckey)
-end
-
-return mqtt2

+ 0 - 63
docs.md

@@ -1,63 +0,0 @@
-# LuatOS 基于Luat的嵌入式实时系统平台
-
-
-
-## 项目管理文档
-
-* [平台架构图](markdown/proj/system_struct.md) 项目的总体架构
-* [项目管理](markdown/proj/project_manager.md) 描述项目角色及分工
-* [环境搭建](markdown/proj/build_sdk.md) 描述从0搭建整个编译过程
-* [编码规范](markdown/proj/code_style.md) 主要是规范代码风格
-
-## 核心层文档
-
-* [平台层](markdown/core/luat_platform.md) 平台层设计
-* [flash存储规划](markdown/core/flash_zone.md) flash空间分配
-* [内存管理](markdown/core/luat_memory.md) 内存分配与管理
-* [定时器](markdown/core/luat_timer.md) 定时器(单次/循环)API
-* [消息总线](markdown/core/luat_msgbus.md) 消息总线机制
-* [底层核心](markdown/core/luat_core.md) Luat核心层
-* [低功耗API](markdown/core/luat_pm.md) 低功耗管理
-* [FOTA](markdown/core/fota.md) 在线升级
-* [文件系统](markdown/core/luat_fs.md) 文件系统操作
-* [API列表](markdown/core/luat_api.md) API列表
-
-## 外设API设计
-
-* [io操作](markdown/device/luat_io.md)
-* [GPIO外设](markdown/device/luat_gpio.md)
-* [UART外设](markdown/device/luat_usart.md)
-* [ADC外设](markdown/device/luat_adc.md)
-* [I2C外设](markdown/device/luat_i2c.md)
-* [SPI外设](markdown/device/luat_spi.md)
-
-## 网络通信层
-
-* [lwip](markdown/network/luat_lwip.md)
-* [aliyun-iot](markdown/network/luat_aliyun.md)
-* [onenet](markdown/network/luat_onenet.md)
-* [coap](markdown/network/luat_coap.md)
-* [mqtt](markdown/network/luat_mqtt.md)
-* [ping](markdown/network/luat_ping.md)
-* [sntp](markdown/network/luat_sntp.md)
-* [http](markdown/network/luat_http.md)
-
-## 应用层
-
-* [cjson](markdown/LuaTask/luat_cjson.md) 提供cjson的Lua绑定
-* [protobuf](markdown/LuaTask/luat_protobuf.md) 提供protobuf的Lua绑定
-
-## 工具支持
-
-* [Luatools]() 日志读取/脚本下载/底层刷机/合并刷机包
-* [批量刷机]()
-
-## 技术讨论
-
-* [Lua版本对比]()
-
-## 相关平台及链接
-
-* [持续构建]() 对每一个提交进行编译检查
-* [API文档]() 对代码API进行展示
-

+ 0 - 70
supported.md

@@ -1,70 +0,0 @@
-
-# 设备支持情况/Supported Devices
-
-## 基础外设支持
-
-| Libs                                                  | Air101 | Air103 | Air105 | Air302 | Air640W | ESP32 |
-|------------------------------------------------------ |--------|--------|--------|--------|---------|--------|
-| [gpio](https://wiki.luatos.com/api/gpio.html)         | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [i2c](https://wiki.luatos.com/api/i2c.html)           | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [spi](https://wiki.luatos.com/api/spi.html)           | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [adc](https://wiki.luatos.com/api/adc.html)           | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [dac](https://wiki.luatos.com/api/dac.html)           | ✖      | ✖     | ✔      | ✖     | ✖      | ⚠      |
-| [usb](https://wiki.luatos.com/api/usb.html)           | ✖      | ✖     | ✔      | ✖     | ✖      | ⚠      |
-| [keyboard](https://wiki.luatos.com/api/keyboard.html) | ✖      | ✖     | ✔      | ✖     | ✖      | ✖      |
-| [lcdseg](https://wiki.luatos.com/api/lcdseg.html)     | ✔      | ✔     | ✖      | ✖     | ✖      | ✖      |
-| [otp](https://wiki.luatos.com/api/otp.html)           | ✔      | ✔     | ✔      | ✖     | ✖      | ✖      |
-| [pin](https://wiki.luatos.com/api/pin.html)           | ✔      | ✔     | ✔      | ✔     | ✖      | ⚠      |
-| [rtc](https://wiki.luatos.com/api/rtc.html)           | ✔      | ✔     | ✔      | ✔     | ⚠      | ⚠      |
-| [pwm](https://wiki.luatos.com/api/pwm.html)           | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [sdio](https://wiki.luatos.com/api/sdio.html)         | ✔      | ✔     | ✖      | ✖     | ✖      | ✖      |
-| [wdt](https://wiki.luatos.com/api/wdt.html)           | ✔      | ✔     | ✔      | ✖     | ⚠      | ⚠      |
-| [crypto](https://wiki.luatos.com/api/crypto.html)     | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [hwtimer](https://wiki.luatos.com/api/hwtimer.html)   | ✔      | ✔     | ⚠      | ⚠     | ⚠      | ⚠      |
-
-补充说明:
-* air101与air103固件的区别在于flash大小, 兼容xt804内核的芯片, 例如联盛德的W800/W801/W805/W806
-* lcdseg支持与否,与封装有关, qfn56封装的xt804支持, qfn32的不支持
-
-## 功能库支持
-
-| Libs                                                  | Air101 | Air103 | Air105 | Air302 | Air640W | ESP32 |
-|-------------------------------------------------------|--------|--------|--------|--------|---------|--------|
-| [json](https://wiki.luatos.com/api/json.html)         | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [zbuff](https://wiki.luatos.com/api/zbuff.html)       | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [pack](https://wiki.luatos.com/api/pack.html)         | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [libgnss](https://wiki.luatos.com/api/libgnss.html)   | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [libcoap](https://wiki.luatos.com/api/libcoap.html)   | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [lcd](https://wiki.luatos.com/api/lcd.html)           | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [eink](https://wiki.luatos.com/api/eink.html)         | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [u8g2](https://wiki.luatos.com/api/u8g2.html)         | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [disp](https://wiki.luatos.com/api/disp.html)         | ✔      | ✔     | ✔      | ✔     | ✔      | ✔      |
-| [dbg](https://wiki.luatos.com/api/dbg.html)           | ✔      | ✔     | ⚠      | ⚠     | ⚠      | ⚠      |
-| [lpmem](https://wiki.luatos.com/api/lpmem.html)       | ✖      | ✖     | ✖      | ✔     | ✖      | ✖      |
-| [gtfont](https://wiki.luatos.com/api/gtfont.html)     | ✔      | ✔     | ⚠      | ⚠     | ⚠      | ⚠      |
-| [coremark](https://wiki.luatos.com/api/coremark.html) | ✔      | ✔     | ✔      | ⚠     | ⚠      | ⚠      |
-| [fdb](https://wiki.luatos.com/api/fdb.html)           | ✔      | ✔     | ⚠      | ⚠     | ⚠      | ⚠      |
-| [lvgl](https://wiki.luatos.com/api/lvgl.html)         | ✔      | ✔     | ✔      | ⚠     | ⚠      | ⚠      |
-| [sfd](https://wiki.luatos.com/api/sfd.html)           | ✔      | ✔     | ⚠      | ⚠     | ⚠      | ⚠      |
-| [sfud](https://wiki.luatos.com/api/sfud.html)         | ✔      | ✔     | ✔      | ⚠     | ⚠      | ⚠      |
-| [statem](https://wiki.luatos.com/api/statem.html)     | ✔      | ✔     | ⚠      | ⚠     | ⚠      | ⚠      |
-
-## 联网/射频支持
-
-| Libs                                                  | Air101 | Air103 | Air105 | Air302 | Air640W | ESP32 |
-|-------------------------------------------------------|--------|--------|--------|--------|---------|--------|
-| [socket](https://wiki.luatos.com/api/socket.html)     | ✖      | ✖     | ✖      | ✔     | ✔      | ⚠      |
-| [ctiot](https://wiki.luatos.com/api/ctiot.html)       | ✖      | ✖     | ✖      | ✔     | ✖      | ✖      |
-| [nbiot](https://wiki.luatos.com/api/nbiot.html)       | ✖      | ✖     | ✖      | ✔     | ✖      | ✖      |
-| [wlan](https://wiki.luatos.com/api/wlan.html)         | ✖      | ✖     | ✖      | ✖     | ✔      | ⚠      |
-| [nimble](https://wiki.luatos.com/api/nimble.html)     | ✔      | ✔     | ✖      | ✖     | ✖      | ⚠      |
-| [http](https://wiki.luatos.com/api/http.html)         | ✖      | ✖     | ✖      | ✔     | ✔      | ⚠      |
-| [espnow](https://wiki.luatos.com/api/espnow.html)     | ✖      | ✖     | ✖      | ✖     | ✖      | ⚠      |
-
-## 图示含义 Table Legend
-
-|  图示 | 含义  |
-|-------|-------|
-|✔ |已支持 Supported|
-|⚠ |进行中/部分支持 WIP/partial support|
-|✖ |不支持 Not supported|

+ 0 - 1
tools/java/.gitignore

@@ -1 +0,0 @@
-/bin/

+ 0 - 44
tools/java/README.md

@@ -1,44 +0,0 @@
-# LuatOS 文档生成工具
-
-```js
-{
-  // 工作目录:即项目目录
-  "workdir": "D:/github/LuatOS/",
-  // 要生成什么类型的文档
-  // 支持: md | json
-  "as": ["md"],
-  // 搜索文档的入口
-  "entries": [{
-    // 入口标题
-    "title": "LuaAPI模块",
-    // 入口路径,相对 workdir
-    "path": "luat/modules",
-    // 搜索的文件前缀
-    // 从 workdir+path 之后的路径开始算,一定不是 "/" 开头
-    "prefix": [],
-    // 搜索文件后缀
-    "suffix": [".c"],
-    // 仅输入下面指定的 API
-    // 支持, "C" 和 "LUA"
-    // !! 注意,需要全部大写
-    // 默认的,都会输出(即,只要解析器收集到的函数签名,都会输出为文档)
-    "lang" : ["C", "LUA"],
-    // 这个开关如果设置为 true,所有空白的函数签名都会被无视
-    // 默认 false
-    "dropEmptyComment": true,
-    // 文档集用那个文件作为模板,默认是入口目录下的 README.md 文件
-    // 模板文件的 ${index} 占位符会放置生成的索引列表
-    // 占位符 ${index} 则为本配置声明的 title 段
-    "readme" : "README.md"
-    // 输出路径,相对 output
-    // 占位符 ${name} 表示 path 对应目录的名字
-    // 本例中,它表示 "modules"
-    "out": "${name}",
-    // 是否递归深层搜索目录
-    "deep": true
-  }],
-  // 输出文档的目录
-  // 占位符 ${workdir} 就是工作目录
-  "output": "${workdir}/docs/api/"
-}
-```

+ 0 - 124
tools/java/pom.xml

@@ -1,124 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.nutz</groupId>
-  <artifactId>luatos</artifactId>
-  <version>1.r.68.v20201205</version>
-  <name>LuatOSTool</name>
-  <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <elasticsearch.version>6.3.2</elasticsearch.version>
-    </properties>
-    <licenses>
-        <license>
-            <name>The Apache Software License, Version 2.0</name>
-            <url>http://apache.org/licenses/LICENSE-2.0.txt</url>
-        </license>
-    </licenses>
-    <developers>
-        <developer>
-            <id>zozoh</id>
-            <name>zozoh</name>
-            <email>zozohtnt@gmail.com</email>
-            <url>http://weibo.com/zozoh</url>
-        </developer>
-        <developer>
-            <id>wendal</id>
-            <name>Wendal Chen</name>
-            <email>wendal1985@gmail.com</email>
-            <url>http://wendal.net/</url>
-        </developer>
-    </developers>
-    <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.13.1</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>javax.servlet-api</artifactId>
-            <version>3.1.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.nutz</groupId>
-            <artifactId>nutz</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-        	<groupId>org.apache.logging.log4j</groupId>
-        	<artifactId>log4j-1.2-api</artifactId>
-        	<version>2.13.3</version>
-        </dependency>
-        <dependency>
-        	<groupId>org.apache.logging.log4j</groupId>
-        	<artifactId>log4j-core</artifactId>
-        	<version>2.15.0</version>
-        </dependency>
-    </dependencies>
-	<build>
-		<plugins>
-			<plugin>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<version>3.3</version>
-				<configuration>
-					<source>1.8</source>
-					<target>1.8</target>
-					<compilerArgs>
-						<arg>-parameters</arg>
-					</compilerArgs>
-					<useIncrementalCompilation>false</useIncrementalCompilation>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-javadoc-plugin</artifactId>
-				<version>2.10.4</version>
-				<configuration>
-					<additionalparam>-Xdoclint:none</additionalparam>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-jar-plugin</artifactId>
-				<version>3.0.2</version>
-				<configuration>
-					<archive>
-						<manifest>
-							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
-						</manifest>
-					</archive>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
-
-	<distributionManagement>
-		<snapshotRepository>
-			<id>nutzcn-snapshots</id>
-			<name>NutzCN snapshot repository</name>
-			<url>https://jfrog.nutz.cn/artifactory/snapshots</url>
-		</snapshotRepository>
-
-		<repository>
-			<id>sonatype-release-staging</id>
-			<name>Sonatype Nexus release repository</name>
-			<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
-		</repository>
-	</distributionManagement>
-
-	<pluginRepositories>
-		<pluginRepository>
-			<id>nutz-snapshots</id>
-			<url>https://jfrog.nutz.cn/artifactory/snapshots</url>
-			<snapshots>
-				<enabled>true</enabled>
-				<updatePolicy>always</updatePolicy>
-			</snapshots>
-			<releases>
-				<enabled>false</enabled>
-			</releases>
-		</pluginRepository>
-	</pluginRepositories>
-</project>

+ 0 - 157
tools/java/src/main/java/com/luatos/toolkit/LuatDocEntry.java

@@ -1,157 +0,0 @@
-package com.luatos.toolkit;
-
-import org.nutz.lang.Files;
-import org.nutz.lang.Strings;
-
-public class LuatDocEntry extends LuatRenderingSetup {
-
-    private String title;
-
-    private String[] paths;
-
-    /**
-     * 从 workdir+path 之后的路径开始算,一定不是 "/" 开头
-     */
-    private String[] prefix;
-
-    private String[] suffix;
-
-    // 文档集用那个文件作为模板,默认是入口目录下的 README.md 文件
-    // 模板文件的 ${index} 占位符会放置生成的索引列表
-    private String readme;
-
-    /**
-     * 输数模板:占位符:
-     * 
-     * <ul>
-     * <li><code>${name}</code>: path 所在目录名
-     * </ul>
-     */
-    private String out;
-
-    private boolean deep;
-
-    public String getTitle() {
-        return title;
-    }
-
-    public String getTitle2() {
-        if (!Strings.isBlank(title)) {
-            return this.title;
-        }
-        if (null != paths && paths.length > 0) {
-            return Files.getName(paths[0]);
-        }
-        return "NoTitle";
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public String[] getPaths() {
-        return paths;
-    }
-
-    public void setPaths(String[] path) {
-        this.paths = path;
-    }
-
-    public String[] getPrefix() {
-        return prefix;
-    }
-
-    public void setPrefix(String[] prefix) {
-        this.prefix = prefix;
-    }
-
-    public String[] getSuffix() {
-        return suffix;
-    }
-
-    public void setSuffix(String[] suffix) {
-        this.suffix = suffix;
-    }
-
-    public String getReadme() {
-        return readme;
-    }
-
-    public String getReadmeFilePath() {
-        return Strings.sBlank(readme, "README.md");
-    }
-
-    public void setReadme(String readme) {
-        this.readme = readme;
-    }
-
-    public boolean isMatch(String rph) {
-        // 先看后缀
-        if (hasSuffix()) {
-            boolean found = false;
-            for (String sufx : this.suffix) {
-                if (rph.endsWith(sufx)) {
-                    found = true;
-                    break;
-                }
-            }
-            if (!found)
-                return false;
-        }
-
-        // 再看前缀
-        if (hasPrefix()) {
-            boolean found = false;
-            for (String prfx : this.prefix) {
-                if (rph.startsWith(prfx)) {
-                    found = true;
-                    break;
-                }
-            }
-            if (!found)
-                return false;
-        }
-
-        // 那么就过咯
-        return true;
-    }
-
-    public boolean hasPrefix() {
-        return null != this.prefix && this.prefix.length > 0;
-    }
-
-    public boolean hasSuffix() {
-        return null != this.suffix && this.suffix.length > 0;
-    }
-
-    public String getOut() {
-        return out;
-    }
-
-    public void setOut(String out) {
-        this.out = out;
-    }
-
-    public boolean isDeep() {
-        return deep;
-    }
-
-    public void setDeep(boolean deep) {
-        this.deep = deep;
-    }
-
-    public String toString() {
-        String s = String.format("# %s->%s", this.getTitle2(), this.paths);
-        if (this.hasPrefix()) {
-            s += "\n#  prefix: " + Strings.join(", ", this.prefix);
-        }
-        if (this.hasSuffix()) {
-            s += "\n#  suffix: " + Strings.join(", ", this.suffix);
-        }
-        s += "\n#    deep: " + this.deep;
-        s += "\n#     out: " + this.out;
-        s += "\n#";
-        return s;
-    }
-
-}

+ 0 - 247
tools/java/src/main/java/com/luatos/toolkit/LuatDocGenerator.java

@@ -1,247 +0,0 @@
-package com.luatos.toolkit;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.nutz.json.Json;
-import org.nutz.lang.Files;
-import org.nutz.lang.Lang;
-import org.nutz.lang.Stopwatch;
-import org.nutz.lang.Strings;
-import org.nutz.lang.util.Disks;
-import org.nutz.lang.util.FileVisitor;
-import org.nutz.log.Log;
-import org.nutz.log.Logs;
-
-import com.luatos.toolkit.api.LuDocParser;
-import com.luatos.toolkit.bean.LuDocument;
-import com.luatos.toolkit.bean.LuatDocSet;
-import com.luatos.toolkit.impl.CLuDocParser;
-import com.luatos.toolkit.impl.ComboDocSetRender;
-import com.luatos.toolkit.util.ComboLuDocRender;
-
-public class LuatDocGenerator {
-
-    private static final String HR0 = Strings.dup('#', 60);
-    private static final String HR = Strings.dup('-', 60);
-
-    private static final Log log = Logs.get();
-
-    private static final LuDocParser docParser = new CLuDocParser();
-
-    public static void main(String[] args) throws IOException {
-        // .....................................................
-        log.info(HR0);
-        log.infof("# Luat Document Generator");
-        log.infof("# v1.0");
-        log.infof("# @auth LuatOS Team");
-        log.infof("# @since 2020");
-        log.info(HR0);
-        // .....................................................
-        List<String> inputs = new ArrayList<>(args.length);
-        String conf = null;
-        String outdir = null;
-        String outas = null;
-        Stopwatch sw = Stopwatch.begin();
-        // .....................................................
-        // 分析参数
-        for (int i = 0; i < args.length; i++) {
-            String arg = args[i];
-            // 配置文件
-            if ("-conf".equals(arg)) {
-                conf = args[++i];
-            }
-            // 指定了输出目录
-            else if ("-out".equals(arg)) {
-                outdir = args[++i];
-            }
-            // 指定了输出类型
-            else if ("-as".equals(arg)) {
-                outas = args[++i];
-            }
-            // 那就是输入文件咯
-            else {
-                inputs.add(arg);
-            }
-        }
-        // .....................................................
-        // 渲染类型拆一下数组
-
-        // .....................................................
-        // 指定了每个输入文件
-        if (!inputs.isEmpty()) {
-            genForFiles(inputs, outdir, outas);
-        }
-        // 要扫描工作目录
-        else if (null != conf) {
-            File fConf = Files.checkFile(conf);
-            String json = Files.read(fConf);
-            LuatDocSetup setup = Json.fromJson(LuatDocSetup.class, json);
-            genForSetup(setup, outdir, outas);
-        }
-        // 靠
-        else {
-            throw Lang.makeThrow("No inputs or config");
-        }
-
-        // .....................................................
-        // 全部搞定
-        sw.stop();
-        log.info(HR);
-        log.infof("All done %s", sw.toString());
-    }
-
-    private static void genForSetup(LuatDocSetup setup, String outdir, String outas)
-            throws IOException {
-        // .....................................................
-        // 覆盖默认值
-        if (!Strings.isBlank(outdir)) {
-            setup.setOutput(outdir);
-        }
-        if (!Strings.isBlank(outas)) {
-            setup.setAs(Strings.splitIgnoreBlank(outas));
-        }
-
-        log.infof("# Scan %d entries << %s:", setup.getEntryCount(), setup.getWorkdir());
-
-        // 防守一下
-        if (0 == setup.getEntryCount()) {
-            log.info("No Entries!");
-            return;
-        }
-
-        // 准备文档集的渲染器
-        ComboDocSetRender dr = new ComboDocSetRender(setup);
-
-        // .....................................................
-        // 解析文档集
-        for (LuatDocEntry en : setup.getEntries()) {
-            // 输出
-            log.info(HR);
-            log.infof("%s", en.toString());
-
-            // 准备文档集
-            LuatDocSet ds = new LuatDocSet(en.getTitle2());
-            ds.setEntry(en);
-
-            // 建立文档集合
-            for (String ph : en.getPaths()) {
-                // 文档集主目录
-                String aph = Disks.appendPath(setup.getWorkdir(), ph);
-                File dirHome = Files.checkFile(aph);
-                if (!dirHome.isDirectory()) {
-                    throw Lang.makeThrow("path '%s' must be DIR", aph);
-                }
-
-                log.infof("scan files in %s", ph);
-                joinDocSet(ds, dirHome, en);
-            }
-
-            // 渲染文档
-            log.info("");
-            log.infof("render %d files ...", ds.getDocumentsCount());
-            dr.render(ds);
-        }
-    }
-
-    private static LuatDocSet joinDocSet(LuatDocSet ds, File dirHome, LuatDocEntry en)
-            throws IOException {
-        // 准备索引模板
-        if (null == ds.getReadme()) {
-            File fReadme = Files.getFile(dirHome, en.getReadmeFilePath());
-            if (!fReadme.exists()) {
-                fReadme = Files.findFile("dft_readme.md");
-            }
-            String tmpl = "${index}";
-            if (null != fReadme) {
-                tmpl = Files.read(fReadme);
-            }
-            ds.setReadme(tmpl);
-        }
-
-        // 递归的解析文档
-        Disks.visitFile(dirHome, new FileVisitor() {
-            public void visit(File f) {
-                String rph = Disks.getRelativePath(dirHome, f);
-                log.infof("  + %s", rph);
-
-                // 解析
-                String input = Files.read(f);
-                LuDocument doc = docParser.parse(input);
-                doc.setDefaultTitle(Files.getMajorName(f));
-                doc.setPath(rph);
-
-                // 计入
-                if (doc.hasFunctions()) {
-                    ds.addDoc(doc);
-                }
-            }
-        }, new FileFilter() {
-            public boolean accept(File f) {
-                // 无视隐藏文件
-                if (f.isHidden()) {
-                    return false;
-                }
-                // 目录是否递归
-                if (f.isDirectory()) {
-                    return en.isDeep();
-                }
-                // 获取相对路径
-                String rph = Disks.getRelativePath(dirHome, f);
-                if (!en.isMatch(rph)) {
-                    log.debugf("  ~ ignore: %s", rph);
-                    return false;
-                }
-
-                return true;
-            }
-        });
-
-        return ds;
-    }
-
-    private static void genForFiles(List<String> inputs, String outdir, String outas)
-            throws IOException {
-        // .....................................................
-        // 确认输出类型
-        String[] ass = Strings.splitIgnoreBlank(Strings.sBlank(outas, "md,json"));
-        // .....................................................
-        // 准备输出目录
-        File dirOut;
-        // 默认当前目录
-        if (Strings.isBlank(outdir)) {
-            dirOut = Files.findFile(".").getCanonicalFile();
-        }
-        // 否则
-        else {
-            dirOut = Files.createDirIfNoExists(outdir);
-            if (dirOut.isFile()) {
-                dirOut = dirOut.getParentFile();
-            }
-        }
-        log.infof("# Gen %d files -> %s:", inputs.size(), dirOut);
-        log.info(HR);
-        log.info("");
-        // .....................................................
-        // 准备渲染器
-        ComboLuDocRender dr = new ComboLuDocRender(ass);
-        // .....................................................
-        // 循环解析输出
-        int i = 0;
-        for (String fph : inputs) {
-            File f = Files.findFile(fph);
-            log.infof(" %2d) %s\n", ++i, f);
-
-            // 解析
-            String text = Files.read(f);
-            LuDocument doc = docParser.parse(text);
-
-            // 渲染输出
-            dr.output(doc, dirOut, f.getName(), null);
-        }
-    }
-
-}

+ 0 - 49
tools/java/src/main/java/com/luatos/toolkit/LuatDocSetup.java

@@ -1,49 +0,0 @@
-package com.luatos.toolkit;
-
-public class LuatDocSetup {
-
-    private String workdir;
-
-    private String[] as;
-
-    private LuatDocEntry[] entries;
-
-    private String output;
-
-    public String getWorkdir() {
-        return workdir;
-    }
-
-    public void setWorkdir(String workdir) {
-        this.workdir = workdir;
-    }
-
-    public String[] getAs() {
-        return as;
-    }
-
-    public void setAs(String[] as) {
-        this.as = as;
-    }
-
-    public LuatDocEntry[] getEntries() {
-        return entries;
-    }
-
-    public int getEntryCount() {
-        return null != entries ? entries.length : 0;
-    }
-
-    public void setEntries(LuatDocEntry[] entries) {
-        this.entries = entries;
-    }
-
-    public String getOutput() {
-        return output;
-    }
-
-    public void setOutput(String output) {
-        this.output = output;
-    }
-
-}

+ 0 - 57
tools/java/src/main/java/com/luatos/toolkit/LuatRenderingSetup.java

@@ -1,57 +0,0 @@
-package com.luatos.toolkit;
-
-import com.luatos.toolkit.bean.FnLang;
-
-public class LuatRenderingSetup {
-
-    /**
-     * 仅输入下面指定的 API<br>
-     * 支持, "C" 和 "LUA"
-     * <p>
-     * !! 注意,需要全部大写 默认的,都会输出(即,只要解析器收集到的函数签名,都会输出为文档)
-     */
-    private String[] lang;
-    /**
-     * 这个开关如果设置为 true,所有空白的函数签名都会被无视<br>
-     * 默认 false
-     */
-    private boolean dropEmptyComment;
-
-    public LuatRenderingSetup() {
-        super();
-    }
-
-    public boolean hasLang() {
-        return null != lang && lang.length > 0;
-    }
-
-    public String[] getLang() {
-        return lang;
-    }
-
-    public FnLang[] getLangEnum() {
-        if (!this.hasLang()) {
-            return new FnLang[0];
-        }
-        FnLang[] langs = new FnLang[this.lang.length];
-        for (int i = 0; i < this.lang.length; i++) {
-            String la = this.lang[i].toUpperCase();
-            FnLang l2 = FnLang.valueOf(la);
-            langs[i] = l2;
-        }
-        return langs;
-    }
-
-    public void setLang(String[] lang) {
-        this.lang = lang;
-    }
-
-    public boolean isDropEmptyComment() {
-        return dropEmptyComment;
-    }
-
-    public void setDropEmptyComment(boolean dropEmptyComment) {
-        this.dropEmptyComment = dropEmptyComment;
-    }
-
-}

+ 0 - 64
tools/java/src/main/java/com/luatos/toolkit/Luats.java

@@ -1,64 +0,0 @@
-package com.luatos.toolkit;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.nutz.lang.Strings;
-
-import com.luatos.toolkit.bean.LuComment;
-
-public abstract class Luats {
-
-    public static boolean isSame(Object o1, Object o2) {
-        if (null != o1) {
-            if (!o1.equals(o2)) {
-                return false;
-            }
-        } else if (null != o2) {
-            return false;
-        }
-        return true;
-    }
-
-    public static boolean isSameList(List<?> l1, List<?> l2) {
-        if (null != l1) {
-            if (null == l2)
-                return false;
-
-            if (l1.size() != l2.size())
-                return false;
-
-            Iterator<?> it1 = l1.iterator();
-            Iterator<?> it2 = l2.iterator();
-
-            while (it1.hasNext()) {
-                Object o1 = it1.next();
-                Object o2 = it2.next();
-                if (!isSame(o1, o2)) {
-                    return false;
-                }
-                return true;
-            }
-
-        } else if (null != l2) {
-            return false;
-        }
-        return true;
-    }
-
-    public static void printEntities(List<Object> entities) {
-        // 测试打印一下
-        String hr = Strings.dup('-', 40);
-        for (Object en : entities) {
-            System.out.println(hr);
-            if (en instanceof LuComment) {
-                System.out.printf("- {%s}\n", ((LuComment) en).getType());
-            } else {
-                System.out.println("- <CFunction>");
-            }
-            System.out.println("-");
-            System.out.println(en.toString());
-        }
-    }
-
-}

+ 0 - 9
tools/java/src/main/java/com/luatos/toolkit/api/FnSignParser.java

@@ -1,9 +0,0 @@
-package com.luatos.toolkit.api;
-
-import com.luatos.toolkit.bean.FnSign;
-
-public interface FnSignParser {
-
-    FnSign parse(String block);
-
-}

+ 0 - 9
tools/java/src/main/java/com/luatos/toolkit/api/LuDocParser.java

@@ -1,9 +0,0 @@
-package com.luatos.toolkit.api;
-
-import com.luatos.toolkit.bean.LuDocument;
-
-public interface LuDocParser {
-
-    LuDocument parse(String input);
-
-}

+ 0 - 12
tools/java/src/main/java/com/luatos/toolkit/api/LuDocRender.java

@@ -1,12 +0,0 @@
-package com.luatos.toolkit.api;
-
-import java.io.OutputStream;
-
-import com.luatos.toolkit.LuatRenderingSetup;
-import com.luatos.toolkit.bean.LuDocument;
-
-public interface LuDocRender {
-
-    boolean render(LuDocument doc, OutputStream ops, LuatRenderingSetup setup);
-
-}

+ 0 - 11
tools/java/src/main/java/com/luatos/toolkit/api/LuDocSetRender.java

@@ -1,11 +0,0 @@
-package com.luatos.toolkit.api;
-
-import java.io.IOException;
-
-import com.luatos.toolkit.bean.LuatDocSet;
-
-public interface LuDocSetRender {
-
-    void render(LuatDocSet ds) throws IOException;
-
-}

+ 0 - 7
tools/java/src/main/java/com/luatos/toolkit/api/TagParser.java

@@ -1,7 +0,0 @@
-package com.luatos.toolkit.api;
-
-public interface TagParser<T> {
-
-    T parse(String input);
-
-}

+ 0 - 77
tools/java/src/main/java/com/luatos/toolkit/bean/FnExample.java

@@ -1,77 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.nutz.lang.Strings;
-
-import com.luatos.toolkit.Luats;
-
-public class FnExample {
-
-    private List<String> summary;
-
-    private List<String> code;
-
-    public boolean hasSummary() {
-        return null != summary && !summary.isEmpty();
-    }
-
-    public List<String> getSummary() {
-        return summary;
-    }
-
-    public void setSummary(List<String> summary) {
-        this.summary = summary;
-    }
-
-    public void appendSummary(String summary) {
-        if (null == this.summary) {
-            this.summary = new LinkedList<>();
-        }
-        this.summary.add(summary);
-    }
-
-    public boolean hasCode() {
-        return null != code && !code.isEmpty();
-    }
-
-    public List<String> getCode() {
-        return code;
-    }
-
-    public void setCode(List<String> code) {
-        this.code = code;
-    }
-
-    public void appendCode(String code) {
-        if (null == this.code) {
-            this.code = new LinkedList<>();
-        }
-        this.code.add(code);
-    }
-
-    public String toString() {
-        String str = "";
-        if (this.hasSummary()) {
-            str += Strings.join("\n--", this.summary) + "\n";
-        }
-        str += Strings.join("\n", code);
-        return str;
-    }
-
-    public boolean equals(Object o) {
-        if (o instanceof FnExample) {
-            FnExample fe = (FnExample) o;
-            if (!Luats.isSameList(this.summary, fe.summary))
-                return false;
-
-            if (!Luats.isSameList(this.code, fe.code))
-                return false;
-
-            return true;
-        }
-        return false;
-    }
-
-}

+ 0 - 7
tools/java/src/main/java/com/luatos/toolkit/bean/FnLang.java

@@ -1,7 +0,0 @@
-package com.luatos.toolkit.bean;
-
-public enum FnLang {
-
-    C, LUA
-
-}

+ 0 - 88
tools/java/src/main/java/com/luatos/toolkit/bean/FnParam.java

@@ -1,88 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import org.nutz.lang.Strings;
-
-import com.luatos.toolkit.Luats;
-
-public class FnParam extends FnReturn {
-
-    private String name;
-
-    public boolean hasName() {
-        return !Strings.isBlank(name);
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        if (Strings.isBlank(name)) {
-            this.name = null;
-        } else {
-            this.name = name;
-        }
-    }
-
-    public boolean isName(String name) {
-        return Luats.isSame(this.name, name);
-    }
-
-    public boolean isNameEndsWith(String name) {
-        if (null != this.name) {
-            return this.name.endsWith(name);
-        }
-        return false;
-    }
-
-    public String toString() {
-        String str = toTypeName();
-        if (!Strings.isBlank(comment)) {
-            str += "/* " + comment + " */";
-        }
-        return str;
-    }
-
-    private String toTypeName() {
-        String str = null == name ? "" : name;
-        if (!Strings.isBlank(type)) {
-            if (type.endsWith("*")) {
-                str = type.substring(0, type.length() - 1) + " *" + str;
-            } else if (Strings.isBlank(str)) {
-                str = type;
-            } else {
-                str = type + " " + str;
-            }
-        }
-        if (null != this.modifier) {
-            return this.modifier.toLowerCase() + " " + str;
-        }
-        return str;
-    }
-
-    public String toSignature(boolean withType) {
-        if (withType) {
-            if (this.hasType()) {
-                return this.toTypeName();
-            }
-        }
-        return this.name;
-    }
-
-    public boolean equals(Object o) {
-        if (o instanceof FnParam) {
-            FnParam fp = (FnParam) o;
-
-            if (!super.equals(fp)) {
-                return false;
-            }
-
-            if (!Luats.isSame(this.name, fp.name))
-                return false;
-
-            return true;
-        }
-        return false;
-    }
-
-}

+ 0 - 105
tools/java/src/main/java/com/luatos/toolkit/bean/FnReturn.java

@@ -1,105 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import org.nutz.lang.Strings;
-
-import com.luatos.toolkit.Luats;
-
-public class FnReturn {
-
-    protected String type;
-
-    protected String comment;
-
-    protected String modifier;
-
-    public String getModifier() {
-        return modifier;
-    }
-
-    public void setModifier(String mod) {
-        if (!Strings.isBlank(mod)) {
-            this.modifier = Strings.trim(mod);
-        } else {
-            this.modifier = null;
-        }
-    }
-
-    public FnReturn() {}
-
-    public FnReturn(String type) {
-        this.setType(type);
-    }
-
-    public FnReturn(String type, String comment) {
-        this.comment = comment;
-        this.setType(type);
-    }
-
-    public boolean isType(String type) {
-        return Luats.isSame(this.type, type);
-    }
-
-    public boolean hasType() {
-        return !Strings.isBlank(type);
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        if (null != type) {
-            this.type = type.replace(" ", "");
-        }
-    }
-
-    public boolean hasComment() {
-        return !Strings.isBlank(comment);
-    }
-
-    public String getComment() {
-        return comment;
-    }
-
-    public void setComment(String comment) {
-        this.comment = comment;
-    }
-
-    public String toString() {
-        String str = type;
-        if (!Strings.isBlank(comment)) {
-            str += "/* " + comment + " */";
-        }
-        if (null != this.modifier) {
-            return this.modifier.toString().toLowerCase() + " " + str;
-        }
-        return str;
-    }
-
-    public String toSignature() {
-        String str = this.hasType() ? this.type : "";
-        if (null != this.modifier) {
-            return this.modifier.toLowerCase() + " " + str;
-        }
-        return str;
-    }
-
-    public boolean equals(Object o) {
-        if (o instanceof FnReturn) {
-            FnReturn fr = (FnReturn) o;
-
-            if (!Luats.isSame(this.modifier, fr.modifier))
-                return false;
-
-            if (!Luats.isSame(this.type, fr.type))
-                return false;
-
-            if (!Luats.isSame(this.comment, fr.comment))
-                return false;
-
-            return true;
-        }
-        return false;
-    }
-
-}

+ 0 - 327
tools/java/src/main/java/com/luatos/toolkit/bean/FnSign.java

@@ -1,327 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.nutz.lang.Strings;
-
-import com.luatos.toolkit.Luats;
-
-public class FnSign {
-
-    /**
-     * 原始的输入
-     */
-    private String rawText;
-
-    private String summary;
-
-    private FnLang lang;
-
-    private String modifier;
-
-    private String name;
-
-    private List<FnReturn> returns;
-
-    private List<FnParam> params;
-
-    private List<FnExample> examples;
-
-    private FnSign refer;
-
-    public String toString() {
-        String str = "";
-        if (null != summary) {
-            str += "/*\n" + summary + "\n*/\n";
-        }
-        if (null != modifier) {
-            str += this.modifier.toString().toLowerCase() + " ";
-        }
-
-        String pmStr = "";
-        if (null != params) {
-            List<String> pms = new ArrayList<>(params.size());
-            for (FnParam pm : params) {
-                pms.add(pm.toString());
-            }
-            pmStr = Strings.join(", ", pms);
-        }
-
-        String res = "";
-        if (null != returns) {
-            List<String> reList = new ArrayList<>(this.returns.size());
-            for (FnReturn re : returns) {
-                reList.add(re.getType());
-            }
-            res = Strings.join(",", reList);
-        }
-
-        str += String.format("%s %s(%s)", res, name, pmStr);
-
-        if (!Strings.isBlank(rawText)) {
-            str += "\n-----------\nraw:\n" + rawText;
-        }
-
-        return str;
-    }
-
-    public String toSignature() {
-        String str = "";
-        if (null != modifier) {
-            str += this.modifier.toString().toLowerCase() + " ";
-        }
-
-        String pmStr = "";
-        if (null != params) {
-            List<String> pms = new ArrayList<>(params.size());
-            for (FnParam pm : params) {
-                pms.add(pm.toSignature(this.isLangC()));
-            }
-            pmStr = Strings.join(", ", pms);
-        }
-
-        String res = "";
-        if (null != returns && this.isLangC()) {
-            List<String> reList = new ArrayList<>(this.returns.size());
-            for (FnReturn re : returns) {
-                reList.add(re.toSignature());
-            }
-            res = Strings.join(",", reList);
-            if (!res.endsWith("*")) {
-                res += " ";
-            }
-        }
-
-        str += String.format("%s%s(%s)", res, name, pmStr);
-
-        return str;
-    }
-
-    public boolean equals(Object o) {
-        if (o instanceof FnSign) {
-            FnSign fn = (FnSign) o;
-            return isSame(fn, true);
-        }
-        return false;
-    }
-
-    public boolean isSame(FnSign fn, boolean ignoreRawText) {
-        if (!ignoreRawText) {
-            if (!Luats.isSame(this.rawText, fn.rawText)) {
-                return false;
-            }
-        }
-        if (!Luats.isSame(this.lang, fn.lang))
-            return false;
-
-        if (!Luats.isSame(this.modifier, fn.modifier))
-            return false;
-
-        if (!Luats.isSame(this.name, fn.name))
-            return false;
-
-        if (!Luats.isSameList(this.returns, fn.returns))
-            return false;
-
-        if (!Luats.isSameList(this.params, fn.params))
-            return false;
-
-        if (!Luats.isSameList(this.examples, fn.examples))
-            return false;
-
-        return true;
-    }
-
-    public String getRawText() {
-        return rawText;
-    }
-
-    public void setRawText(String rawText) {
-        this.rawText = rawText;
-    }
-
-    public boolean hasSummary() {
-        return !Strings.isBlank(summary);
-    }
-
-    public String getSummary() {
-        return summary;
-    }
-
-    public void setSummary(String comment) {
-        this.summary = comment;
-    }
-
-    public boolean isLangC() {
-        return FnLang.C == this.lang;
-    }
-
-    public boolean isLangLua() {
-        return FnLang.LUA == this.lang;
-    }
-
-    public FnLang getLang() {
-        return lang;
-    }
-
-    public String getLangName() {
-        return null == lang ? "" : lang.toString().toLowerCase();
-    }
-
-    public void setLang(FnLang type) {
-        this.lang = type;
-    }
-
-    public boolean isLocal() {
-        return this.isModifier("local");
-    }
-
-    public boolean isStatic() {
-        return this.isModifier("static");
-    }
-
-    public boolean isModifier(String mod) {
-        if (null != this.modifier) {
-            return this.modifier.contains(mod);
-        }
-        return false;
-    }
-
-    public String getModifier() {
-        return modifier;
-    }
-
-    public void setModifier(String mod) {
-        if (!Strings.isBlank(mod)) {
-            this.modifier = Strings.trim(mod);
-        } else {
-            this.modifier = null;
-        }
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public boolean isName(String name) {
-        return Luats.isSame(this.name, name);
-    }
-
-    public boolean isNameEndsWith(String name) {
-        if (null != this.name) {
-            return this.name.endsWith(name);
-        }
-        return false;
-    }
-
-    public boolean hasReturns() {
-        return null != this.returns && !this.returns.isEmpty();
-    }
-
-    public List<FnReturn> getReturns() {
-        return returns;
-    }
-
-    public void setReturns(List<FnReturn> returns) {
-        this.returns = returns;
-    }
-
-    public void addReturn(FnReturn fr) {
-        if (null == this.returns) {
-            this.returns = new LinkedList<>();
-        }
-        this.returns.add(fr);
-    }
-
-    public int getReturnCount() {
-        if (null != this.returns) {
-            return this.returns.size();
-        }
-        return 0;
-    }
-
-    public boolean isReturnMatch(int index, String type) {
-        if (index >= 0 && index < this.getReturnCount()) {
-            FnReturn fr = this.returns.get(index);
-            return fr.isType(type);
-        }
-        return false;
-    }
-
-    public boolean hasParams() {
-        return null != this.params && !this.params.isEmpty();
-    }
-
-    public List<FnParam> getParams() {
-        return params;
-    }
-
-    public void setParams(List<FnParam> params) {
-        this.params = params;
-    }
-
-    public void addParam(FnParam param) {
-        if (null == this.params) {
-            this.params = new LinkedList<>();
-        }
-        this.params.add(param);
-    }
-
-    public int getParamsCount() {
-        if (null != this.params) {
-            return this.params.size();
-        }
-        return 0;
-    }
-
-    public boolean isParamMatch(int index, String type, String name) {
-        if (index >= 0 && index < this.getParamsCount()) {
-            FnParam fp = this.params.get(index);
-            if (!fp.isType(type))
-                return false;
-            if (!fp.isName(name))
-                return false;
-
-            return true;
-        }
-        return false;
-    }
-
-    public boolean hasExamples() {
-        return null != this.examples && !this.examples.isEmpty();
-    }
-
-    public List<FnExample> getExamples() {
-        return examples;
-    }
-
-    public void setExamples(List<FnExample> examples) {
-        this.examples = examples;
-    }
-
-    public void addExample(FnExample example) {
-        if (null == this.examples) {
-            this.examples = new LinkedList<>();
-        }
-        this.examples.add(example);
-    }
-
-    public boolean hasRefer() {
-        return null != this.refer;
-    }
-
-    public FnSign getRefer() {
-        return refer;
-    }
-
-    public void setRefer(FnSign refer) {
-        this.refer = refer;
-    }
-
-}

+ 0 - 7
tools/java/src/main/java/com/luatos/toolkit/bean/LuCmtAppend.java

@@ -1,7 +0,0 @@
-package com.luatos.toolkit.bean;
-
-public enum LuCmtAppend {
-
-    ACCEPT, REJECT, CLOSED
-
-}

+ 0 - 64
tools/java/src/main/java/com/luatos/toolkit/bean/LuCmtType.java

@@ -1,64 +0,0 @@
-package com.luatos.toolkit.bean;
-
-public enum LuCmtType {
-
-    /**
-     * Lua 模块抬头部分
-     * 
-     * <pre>
-     * /&lowast; 
-     * &otimes;module  ctiot
-     * &otimes;summary 中国电信CTIOT集成
-     * &otimes;version 1.0
-     * &otimes;date    2020.08.30
-     * &lowast;/
-     * </pre>
-     */
-    LUA_HEAD,
-
-    /**
-     * 标识了 Lua 的特殊注释
-     * 
-     * <pre>
-     * /&lowast; 
-     * 显示屏初始化
-     * &otimes;api disp.init(conf)
-     * ...
-     * </pre>
-     * 
-     */
-    LUA_SIGN,
-
-    /**
-     * 多行注释
-     * 
-     * <pre>
-     * /&lowast; 
-     * &otimes;xxxxx
-     * &otimes;xxxxx
-     * &otimes;xxxxx
-     * &lowast;/
-     * </pre>
-     * 
-     * 当然,也可以是
-     * 
-     * <pre>
-     * /&lowast; 
-     *  &lowast; &otimes;xxxxx
-     *  &lowast; &otimes;xxxxx
-     *  &lowast; &otimes;xxxxx
-     *  &lowast;/
-     * </pre>
-     */
-    BLOCK,
-
-    /**
-     * 单行注释
-     * 
-     * <pre>
-     * // xxxx
-     * </pre>
-     */
-    LINES
-
-}

+ 0 - 197
tools/java/src/main/java/com/luatos/toolkit/bean/LuComment.java

@@ -1,197 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.regex.Matcher;
-
-import org.nutz.lang.Strings;
-import org.nutz.lang.util.Regex;
-
-public class LuComment {
-
-    private boolean closed;
-
-    private int space;
-
-    private LuCmtType type;
-
-    private List<String> lines;
-
-    public LuComment() {}
-
-    public LuComment(String block) {
-        this.parse(block);
-    }
-
-    public void clear() {
-        this.type = null;
-        this.lines = null;
-    }
-
-    public boolean isLuaHead() {
-        return LuCmtType.LUA_HEAD == this.type;
-    }
-
-    public boolean isLuaSign() {
-        return LuCmtType.LUA_SIGN == this.type;
-    }
-
-    public boolean isBlock() {
-        return LuCmtType.BLOCK == this.type;
-    }
-
-    public boolean isLines() {
-        return LuCmtType.LINES == this.type;
-    }
-
-    public boolean isEmpty() {
-        return null == lines || lines.isEmpty();
-    }
-
-    public int getSpace() {
-        return space;
-    }
-
-    public void setSpace(int space) {
-        this.space = space;
-    }
-
-    public LuCmtType getType() {
-        return type;
-    }
-
-    public void setType(LuCmtType type) {
-        this.type = type;
-    }
-
-    public boolean isClosed() {
-        return closed;
-    }
-
-    public void setClosed(boolean closed) {
-        this.closed = closed;
-    }
-
-    public List<String> getLines() {
-        return lines;
-    }
-
-    public void setLines(List<String> lines) {
-        this.lines = lines;
-    }
-
-    private static final String BLK_BEGIN = "^(\\s*)(/[*][*]*) ?(.*)$";
-    private static final String BLK_LINE = "^(\\s*[*]\\s)(.*)$";
-    private static final String BLK_END = "^(.*) *([*]/)\\s*$";
-    private static final String LIN_CMT = "^(\\s*)(// ?)(.*)$";
-
-    /**
-     * @param line
-     * @return LuCmtAppend
-     */
-    public LuCmtAppend appendLine(String line) {
-        if (null == lines) {
-            lines = new LinkedList<>();
-        }
-
-        // 已经关闭了
-        if (this.closed) {
-            return LuCmtAppend.REJECT;
-        }
-
-        Matcher m;
-
-        // 单行注释
-        m = Regex.getPattern(LIN_CMT).matcher(line);
-        if (m.find()) {
-            if (null == this.type) {
-                this.type = LuCmtType.LINES;
-                this.space = m.group(1).length();
-            }
-            // 必须自己也是单行注释
-            else if (!this.isLines()) {
-                return LuCmtAppend.REJECT;
-            }
-
-            // 成功加入
-            lines.add(m.group(3));
-            return LuCmtAppend.ACCEPT;
-        }
-
-        // 多行注释:
-        // -> /*
-        // -> **
-        // -> *
-        m = Regex.getPattern(BLK_BEGIN).matcher(line);
-        if (m.find()) {
-            if (null == this.type) {
-                this.type = LuCmtType.BLOCK;
-                this.space = m.group(1).length();
-            }
-            // 必须自己也是块注释
-            else if (!this.isBlock()) {
-                return LuCmtAppend.REJECT;
-            }
-            // 成功加入
-            String str = m.group(3);
-            // 计入(如果已经开始计入注释行了,那么空行也加进来,当然最后一行除外
-            if (!Strings.isBlank(str) || !this.isEmpty()) {
-                lines.add(str);
-            }
-            return LuCmtAppend.ACCEPT;
-        }
-
-        // 多行注释: 结尾
-        m = Regex.getPattern(BLK_END).matcher(line);
-        if (m.find()) {
-            if (this.isBlock()) {
-                String str = m.group(1);
-                if (!Strings.isBlank(str))
-                    lines.add(str);
-            }
-            this.closed = true;
-            return LuCmtAppend.CLOSED;
-        }
-
-        // 其他的普通行,只有多行注释才能接受
-        if (this.isBlock() || this.isLuaSign() || this.isLuaHead()) {
-            // 多行注释的话,试图去掉前面的星星
-            m = Regex.getPattern(BLK_LINE).matcher(line);
-            if (m.find()) {
-                line = m.group(2).trim();
-            }
-            // 记入行
-            lines.add(line);
-            // 如果这个行是一个函数声明,那么切换特殊类型
-            if (this.isBlock()) {
-                if (line.startsWith("@function")) {
-                    this.setType(LuCmtType.LUA_SIGN);
-                } else if (line.startsWith("@api")) {
-                    this.setType(LuCmtType.LUA_SIGN);
-                } else if (line.startsWith("@module")) {
-                    this.setType(LuCmtType.LUA_HEAD);
-                }
-            }
-            return LuCmtAppend.ACCEPT;
-        }
-
-        return LuCmtAppend.REJECT;
-    }
-
-    public void parse(String block) {
-        String[] ss = block.split("\r?\n");
-        for (String s : ss) {
-            if (LuCmtAppend.ACCEPT != this.appendLine(s)) {
-                return;
-            }
-        }
-    }
-
-    public String toString() {
-        if (this.isEmpty()) {
-            return "";
-        }
-        return Strings.join(System.lineSeparator(), lines);
-    }
-
-}

+ 0 - 146
tools/java/src/main/java/com/luatos/toolkit/bean/LuDocument.java

@@ -1,146 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.nutz.lang.Lang;
-import org.nutz.lang.Strings;
-
-import com.luatos.toolkit.LuatRenderingSetup;
-import com.luatos.toolkit.Luats;
-
-public class LuDocument {
-
-    private LuHead head;
-
-    private List<FnSign> functions;
-
-    public boolean hasHead() {
-        return null != head;
-    }
-
-    public LuHead getHead() {
-        return head;
-    }
-
-    public void setHead(LuHead title) {
-        this.head = title;
-    }
-
-    public void mergeHead(LuHead head) {
-        if (null == this.head) {
-            this.head = head;
-        } else {
-            this.head.mergeWith(head);
-        }
-    }
-
-    public String getTitle() {
-        if (null != head)
-            return head.getTitle();
-        return null;
-    }
-    
-    public String getDisplayTitle() {
-        if (null != head)
-            return head.getDisplayTitle();
-        return null;
-    }
-    
-    public String getDisplaySummary() {
-        if (null != head)
-            return Strings.sBlank(head.getSummary(), head.getDisplayTitle());
-        return null;
-    }
-
-    public void setDefaultTitle(String title) {
-        if (null == head) {
-            head = new LuHead();
-        }
-        if (!head.hasTitle()) {
-            head.setTitle(title);
-        }
-    }
-
-    public String getPath() {
-        if (null != head)
-            return head.getPath();
-        return null;
-    }
-
-    public void setPath(String path) {
-        if (null == head) {
-            head = new LuHead();
-        }
-        head.setPath(path);
-    }
-
-    public boolean hasFunctions() {
-        return null != this.functions && !this.functions.isEmpty();
-    }
-
-    public List<FnSign> getFunctions() {
-        return functions;
-    }
-
-    public List<FnSign> fetchFunctions(LuatRenderingSetup setup) {
-        // 木有函数
-        if (!this.hasFunctions()) {
-            return new LinkedList<FnSign>();
-        }
-        // 木有约束
-        if (null == setup || (!setup.isDropEmptyComment() && !setup.hasLang())) {
-            return this.functions;
-        }
-
-        List<FnSign> list = new ArrayList<>(this.functions.size());
-
-        // 首先整理一下要过滤的语言
-        FnLang[] langs = setup.getLangEnum();
-
-        // 逐个判断一下
-        for (FnSign fn : this.functions) {
-            // 没有匹配语言
-            if (langs.length > 0) {
-                if (!Lang.contains(langs, fn.getLang())) {
-                    continue;
-                }
-            }
-            // 没有匹配注释
-            if (setup.isDropEmptyComment()) {
-                if (Strings.isBlank(fn.getSummary())) {
-                    continue;
-                }
-            }
-            // 嗯,这下可以加入
-            list.add(fn);
-        }
-        return list;
-    }
-
-    public void setFunctions(List<FnSign> functions) {
-        this.functions = functions;
-    }
-
-    public void addFunctions(FnSign func) {
-        if (null == this.functions) {
-            this.functions = new LinkedList<>();
-        }
-        this.functions.add(func);
-    }
-
-    public boolean equals(Object o) {
-        if (o instanceof LuDocument) {
-            LuDocument doc = (LuDocument) o;
-            if (!Luats.isSame(head, doc.head))
-                return false;
-            if (!Luats.isSameList(functions, doc.functions))
-                return false;
-
-            return true;
-        }
-        return false;
-    }
-
-}

+ 0 - 182
tools/java/src/main/java/com/luatos/toolkit/bean/LuHead.java

@@ -1,182 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import org.nutz.lang.Files;
-import org.nutz.lang.Strings;
-import org.nutz.lang.util.NutMap;
-
-import com.luatos.toolkit.Luats;
-
-public class LuHead {
-
-    private String title;
-
-    private String path;
-
-    private String module;
-
-    private String summary;
-
-    private String version;
-
-    private String date;
-
-    public boolean hasTitle() {
-        return !Strings.isBlank(title);
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public String getDisplayTitle() {
-        if (!Strings.isBlank(this.module)) {
-            return this.module;
-        }
-        if (!Strings.isBlank(this.title)) {
-            return this.title;
-        }
-        if (!Strings.isBlank(this.path)) {
-            return Files.getMajorName(this.path);
-        }
-        return null;
-    }
-
-    public String getPath() {
-        return path;
-    }
-
-    public void setPath(String path) {
-        this.path = path;
-    }
-
-    public String getModule() {
-        return module;
-    }
-
-    public void setModule(String module) {
-        this.module = module;
-    }
-
-    public String getSummary() {
-        return summary;
-    }
-
-    public void setSummary(String summary) {
-        this.summary = summary;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public void setVersion(String version) {
-        this.version = version;
-    }
-
-    public String getDate() {
-        return date;
-    }
-
-    public void setDate(String date) {
-        this.date = date;
-    }
-
-    public boolean equals(Object o) {
-        if (o instanceof LuHead) {
-            LuHead he = (LuHead) o;
-            if (!Luats.isSame(title, he.title))
-                return false;
-            if (!Luats.isSame(path, he.path))
-                return false;
-            if (!Luats.isSame(module, he.module))
-                return false;
-            if (!Luats.isSame(summary, he.summary))
-                return false;
-            if (!Luats.isSame(version, he.version))
-                return false;
-            if (!Luats.isSame(date, he.date))
-                return false;
-
-            return true;
-        }
-        return false;
-    }
-
-    public NutMap toMap() {
-        NutMap re = new NutMap();
-
-        if (!Strings.isBlank(title)) {
-            re.put("module", title);
-        }
-
-        if (!Strings.isBlank(module)) {
-            re.put("module", module);
-        }
-
-        if (!Strings.isBlank(summary))
-            re.put("summary", summary);
-
-        if (!Strings.isBlank(version))
-            re.put("version", version);
-
-        if (!Strings.isBlank(date))
-            re.put("date", date);
-        return re;
-    }
-
-    public String toString() {
-        String s = "";
-        if (!Strings.isBlank(title))
-            s += "@title " + title + "\n";
-
-        if (!Strings.isBlank(path))
-            s += "@path " + path + "\n";
-
-        if (!Strings.isBlank(summary))
-            s += "@summary " + summary + "\n";
-
-        if (!Strings.isBlank(module))
-            s += "@module " + module + "\n";
-
-        if (!Strings.isBlank(summary))
-            s += "@summary " + summary + "\n";
-
-        if (!Strings.isBlank(version))
-            s += "@version " + version + "\n";
-
-        if (!Strings.isBlank(date))
-            s += "@date " + date;
-        return s;
-    }
-
-    public void mergeWith(LuHead head) {
-        if (null == head)
-            return;
-
-        if (!Strings.isBlank(head.title))
-            this.title = head.title;
-
-        if (!Strings.isBlank(head.path))
-            this.path = head.path;
-
-        if (!Strings.isBlank(head.summary))
-            this.summary = head.summary;
-
-        if (!Strings.isBlank(head.module))
-            this.module = head.module;
-
-        if (!Strings.isBlank(head.summary))
-            this.summary = head.summary;
-
-        if (!Strings.isBlank(head.version))
-            this.version = head.version;
-
-        if (!Strings.isBlank(head.date))
-            this.date = head.date;
-    }
-
-}

+ 0 - 86
tools/java/src/main/java/com/luatos/toolkit/bean/LuatDocSet.java

@@ -1,86 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.nutz.lang.Files;
-import org.nutz.lang.Strings;
-import org.nutz.lang.tmpl.Tmpl;
-
-import com.luatos.toolkit.LuatDocEntry;
-
-public class LuatDocSet {
-
-    private String name;
-
-    private Tmpl readme;
-
-    /**
-     * 即 workdir + path 的全路径, 下面的文档路径会根据这个路径计算相对路径
-     */
-    private String homePath;
-
-    private LuatDocEntry entry;
-
-    private List<LuDocument> documents;
-
-    public LuatDocSet(String name) {
-        this.name = name;
-        this.documents = new LinkedList<>();
-    }
-
-    public LuatDocEntry getEntry() {
-        return entry;
-    }
-
-    public void setEntry(LuatDocEntry entry) {
-        this.entry = entry;
-    }
-
-    public String getTitle() {
-        if (entry != null) {
-            return entry.getTitle();
-        }
-        if (!Strings.isBlank(name)) {
-            return name;
-        }
-        return Strings.sBlank(Files.getName(homePath), "NoTitle");
-    }
-
-    public void addDoc(LuDocument doc) {
-        this.documents.add(doc);
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Tmpl getReadme() {
-        return readme;
-    }
-
-    public void setReadme(Tmpl readme) {
-        this.readme = readme;
-    }
-
-    public void setReadme(String readme) {
-        this.readme = Tmpl.parse(readme);
-    }
-
-    public boolean hasDocuments() {
-        return null != this.documents && !this.documents.isEmpty();
-    }
-
-    public List<LuDocument> getDocuments() {
-        return documents;
-    }
-
-    public int getDocumentsCount() {
-        return null == documents ? 0 : documents.size();
-    }
-
-}

+ 0 - 105
tools/java/src/main/java/com/luatos/toolkit/impl/CFnSignParser.java

@@ -1,105 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.nutz.lang.Lang;
-import org.nutz.lang.Strings;
-import org.nutz.lang.util.Regex;
-
-import com.luatos.toolkit.api.FnSignParser;
-import com.luatos.toolkit.bean.FnLang;
-import com.luatos.toolkit.bean.FnParam;
-import com.luatos.toolkit.bean.FnReturn;
-import com.luatos.toolkit.bean.FnSign;
-
-public class CFnSignParser implements FnSignParser {
-
-    private static String _r0 = "^\\s*((((static|local|inline)\\s+)*))?\\s*(\\w+(\\s*[*])?)\\s*(\\w+)\\s*\\(([^)]*)\\).*$";
-    private static Pattern PT = Regex.getPattern(_r0);
-
-    @Override
-    public FnSign parse(String block) {
-        // 变成一行
-        String str = block.replaceAll("\r?\n", " ");
-
-        // 分析
-        Matcher m = PT.matcher(str);
-
-        // 不合法
-        if (!m.find()) {
-            throw Lang.makeThrow("invalid CFunction sign", block);
-        }
-
-        // 提取值
-        String mod = m.group(2);
-        String retp = m.group(5);
-        String name = m.group(7);
-        String params = m.group(8);
-
-        // 准备返回
-        FnSign fn = new FnSign();
-        fn.setRawText(block);
-        fn.setLang(FnLang.C);
-
-        fn.setModifier(mod);
-        fn.setName(name);
-
-        fn.addReturn(new FnReturn(retp));
-
-        // 分析参数
-        String[] ss = Strings.splitIgnoreBlank(params);
-        if (ss.length == 0) {
-            fn.setParams(new ArrayList<>(0));
-        }
-        // 循环判断参数
-        else {
-            for (String s : ss) {
-                String[] mm = Strings.splitIgnoreBlank(s, "\\s+");
-                String md = null;
-                String tp = null;
-                String nm = null;
-                // 只有一个
-                if (1 == mm.length) {
-                    nm = mm[0];
-                }
-                // 两个的话,那么前面一个是类型
-                else if (2 == mm.length) {
-                    tp = mm[0];
-                    nm = mm[1];
-                }
-                // 超过两个,第一个是类型,最后一个是名称
-                else {
-                    int last = mm.length - 1;
-                    md = mm[0];
-                    String[] tps = Arrays.copyOfRange(mm, 1, last);
-                    tp = Strings.join(" ", tps);
-                    nm = mm[last];
-                }
-                // 弄一下指针
-                if (nm.startsWith("*")) {
-                    nm = nm.substring(1).trim();
-                    tp += "*";
-                }
-                // void 类型
-                if (null == tp && "void".equals(nm)) {
-                    tp = nm;
-                    nm = null;
-                }
-
-                // 生成参数对象
-                FnParam pm = new FnParam();
-                pm.setModifier(md);
-                pm.setType(tp);
-                pm.setName(nm);
-                fn.addParam(pm);
-            }
-        }
-
-        // 搞定
-        return fn;
-    }
-
-}

+ 0 - 234
tools/java/src/main/java/com/luatos/toolkit/impl/CLuDocParser.java

@@ -1,234 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.nutz.lang.Lang;
-import org.nutz.lang.Strings;
-import org.nutz.lang.util.Regex;
-
-import com.luatos.toolkit.api.FnSignParser;
-import com.luatos.toolkit.api.LuDocParser;
-import com.luatos.toolkit.bean.FnSign;
-import com.luatos.toolkit.bean.LuCmtAppend;
-import com.luatos.toolkit.bean.LuComment;
-import com.luatos.toolkit.bean.LuDocument;
-import com.luatos.toolkit.bean.LuHead;
-
-public class CLuDocParser implements LuDocParser {
-
-    private LuHeadParser headParser = new LuHeadParser();
-    private FnSignParser cFnParser = new CFnSignParser();
-    private FnSignParser docxyFnParser = new DoxyFnSignParser();
-
-    @Override
-    public LuDocument parse(String input) {
-        // 准备
-        String[] lines = input.split("\r?\n");
-
-        // 准备归纳的实体列表,元素有两种类型
-        // - String - 一个 C 函数的签名定义
-        // - LuComment - 声明的注释,可以是 LUA_HEAD/LUA_SIGN/BLOCK/LINES
-        List<Object> entities = new ArrayList<>(lines.length / 2);
-
-        // 归纳需要解析的实体
-        createEntities(lines, entities);
-
-        // 打印测试
-        // Luats.printEntities(entities);
-
-        // 准备要生成的文档
-        LuDocument doc = new LuDocument();
-
-        joinEntities(doc, entities);
-
-        return doc;
-    }
-
-    private void joinEntities(LuDocument doc, List<Object> entities) {
-        // 最后一次生成的 Fn, 以备函数融合(将 c 函数关联至 lua 的函数定义)
-        LuComment lastCmt = null;
-        FnSign lastFn = null;
-
-        // 循环开始了
-        for (Object en : entities) {
-            try {
-                // 处理注释
-                if (en instanceof LuComment) {
-                    LuComment cmt = (LuComment) en;
-                    // 头部·头部
-                    if (cmt.isLuaHead()) {
-                        LuHead head = headParser.parse(cmt.toString());
-                        doc.mergeHead(head);
-                        continue;
-                    }
-
-                    // 函数
-                    if (cmt.isLuaSign()) {
-                        // 推入旧的
-                        if (lastFn != null) {
-                            doc.addFunctions(lastFn);
-                        }
-                        // 开始新的
-                        lastCmt = null;
-                        lastFn = docxyFnParser.parse(cmt.toString());
-                    }
-                    // 普通注释
-                    else {
-                        lastCmt = cmt;
-                    }
-                    // 无论如何,后面的逻辑就不需要了
-                    continue;
-                }
-                // 处理C方法
-                FnSign fn = null;
-                if (en instanceof String) {
-                    fn = cFnParser.parse(en.toString());
-                }
-                // 呃,什么鬼?
-                else {
-                    throw Lang.impossible();
-                }
-
-                // 看看有木有可能融合
-                if (lastFn != null) {
-                    // 当前方式是个 lua 的 C 签名
-                    if (fn.isStatic()
-                        && fn.isReturnMatch(0, "int")
-                        && fn.getParamsCount() == 1
-                        && fn.isParamMatch(0, "lua_State*", "L")) {
-                        // 前序方法名称与当前方法匹配
-                        String lastFnName = lastFn.getName();
-                        int pos = lastFnName.lastIndexOf('.');
-                        if (pos < 0) {
-                            pos = lastFnName.lastIndexOf(':');
-                        }
-                        if (pos > 0) {
-                            lastFnName = lastFnName.substring(pos + 1).trim();
-                        }
-                        lastFnName = Strings.lowerWord(lastFnName, '_');
-                        if (fn.isNameEndsWith(lastFnName)) {
-                            // 融合吧
-                            lastFn.setRefer(fn);
-                            doc.addFunctions(lastFn);
-                            lastFn = null;
-                            lastCmt = null;
-                            continue;
-                        }
-                        // 否则先把前面的函数推入
-                        else {
-                            doc.addFunctions(lastFn);
-                            lastFn = null;
-                        }
-                    }
-                }
-
-                // 融合注释
-                if (null != lastCmt) {
-                    fn.setSummary(lastCmt.toString());
-                    lastCmt = null;
-                }
-
-                // 记入文档
-                doc.addFunctions(fn);
-
-                // 清理之前
-                lastFn = null;
-                lastCmt = null;
-            }
-            catch (Exception e) {
-                System.err.printf("!!!Fail to parse entity:\n %s\n", en.toString());
-                // throw e;
-            }
-        }
-
-        // 最后一个函数
-        if (lastFn != null) {
-            doc.addFunctions(lastFn);
-        }
-    }
-
-    private void createEntities(String[] lines, List<Object> entities) {
-        // 当前注释
-        LuComment cmt = null;
-        Matcher m;
-
-        // 准备注释行的判断
-        Pattern P_CMT = Regex.getPattern("^\\s*(/[/*]).*$");
-        Pattern P_FNC = Regex.getPattern("^\\s*static [\\w\\d ]+\\(.*\\).*$");
-
-        // 逐行循环
-        for (int i = 0; i < lines.length; i++) {
-            String line = lines[i];
-            // if (i == 40) {
-            // System.out.printf("%d) %s\n", i + 1, line);
-            // }
-            // 嗯单行注释行
-            // 嗯多行注释
-            m = P_CMT.matcher(line);
-            if (m.find()) {
-                if (null == cmt) {
-                    cmt = new LuComment();
-                }
-                // 不能加入,那么注释类型变了,清空当前注释,重来一遍
-                LuCmtAppend are = cmt.appendLine(line);
-                if (LuCmtAppend.REJECT == are) {
-                    cmt = null;
-                    i--;
-                }
-                continue;
-            }
-            // 嗯,看看是不是可以加入注释
-            if (null != cmt && !cmt.isClosed()) {
-                LuCmtAppend are = cmt.appendLine(line);
-                // 不能加入,那么这就不是注释了,继续往下
-                // 只有单行注释才可能 REJECT
-                if (LuCmtAppend.REJECT == are) {
-                    // 啥都不做,继续往下
-                }
-                // 关闭的话
-                else if (LuCmtAppend.CLOSED == are) {
-                    if (cmt.isLuaHead() || cmt.isLuaSign()) {
-                        entities.add(cmt);
-                        cmt = null;
-                    }
-                    continue;
-                }
-                // 接受了,继续读下一行
-                else {
-                    continue;
-                }
-
-            }
-
-            // 嗯 静态函数
-            m = P_FNC.matcher(line);
-            if (m.find()) {
-                // 尝试推入之前的注释
-                this.addComment(entities, cmt);
-                // 这玩意先不管,函数里还有注释
-                if (line.indexOf("/*") < 0) {
-                    entities.add(line.trim());
-                }
-                cmt = null;
-                continue;
-            }
-
-            // 嗯,啥都不是,把注释清空
-            cmt = null;
-        }
-    }
-
-    private void addComment(List<Object> entities, LuComment cmt) {
-        if (null != cmt && !cmt.isEmpty() && cmt.getSpace() == 0) {
-            // 看看是不是水平线
-            String str = cmt.toString();
-            String lin = Strings.dup(str.charAt(0), str.length());
-            if (!str.equals(lin)) {
-                entities.add(cmt);
-            }
-        }
-    }
-}

+ 0 - 123
tools/java/src/main/java/com/luatos/toolkit/impl/ComboDocSetRender.java

@@ -1,123 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-
-import org.nutz.lang.Files;
-import org.nutz.lang.Lang;
-import org.nutz.lang.Streams;
-import org.nutz.lang.Strings;
-import org.nutz.lang.tmpl.Tmpl;
-import org.nutz.lang.util.Disks;
-import org.nutz.lang.util.NutBean;
-import org.nutz.lang.util.NutMap;
-import org.nutz.log.Log;
-import org.nutz.log.Logs;
-
-import com.luatos.toolkit.LuatDocEntry;
-import com.luatos.toolkit.LuatDocSetup;
-import com.luatos.toolkit.api.LuDocSetRender;
-import com.luatos.toolkit.bean.LuDocument;
-import com.luatos.toolkit.bean.LuatDocSet;
-import com.luatos.toolkit.util.ComboLuDocRender;
-
-public class ComboDocSetRender implements LuDocSetRender {
-
-    private static final Log log = Logs.get();
-
-    private LuatDocSetup setup;
-
-    private ComboLuDocRender render;
-
-    public ComboDocSetRender(LuatDocSetup setup) {
-        this.setup = setup;
-        this.render = new ComboLuDocRender(setup.getAs());
-    }
-
-    @Override
-    public void render(LuatDocSet ds) throws IOException {
-        // 防守一下
-        if (!ds.hasDocuments()) {
-            log.info("~ Empty Document Set ~");
-            return;
-        }
-
-        LuatDocEntry en = ds.getEntry();
-        // 准备输出目录
-        NutBean context = Lang.map("name", Files.getName(en.getPaths()[0]));
-        context.put("workdir", setup.getWorkdir());
-        String tmplOutDir = Disks.appendPath(setup.getOutput(), en.getOut());
-        String phOut = Tmpl.exec(tmplOutDir, context);
-        File dirOut = Files.createDirIfNoExists(phOut);
-        log.infof(">> %s", phOut);
-
-        // 循环渲染文档
-        List<LuDocument> docList = new ArrayList<>(ds.getDocumentsCount());
-        for (LuDocument doc : ds.getDocuments()) {
-            String rph = doc.getPath();
-            log.infof("  => %s", rph);
-            if (render.output(doc, dirOut, rph, en)) {
-                docList.add(doc);
-            }
-        }
-
-        // 生成摘要
-        log.infof("build README.md");
-        buildReadMe(ds, dirOut, docList);
-    }
-
-    private void buildReadMe(LuatDocSet ds, File dirOut, List<LuDocument> docList)
-            throws IOException {
-        // 首先按照名称排序索引
-        docList.sort(new Comparator<LuDocument>() {
-            public int compare(LuDocument o1, LuDocument o2) {
-                String title1 = o1.getDisplayTitle();
-                String title2 = o2.getDisplayTitle();
-                return title1.compareTo(title2);
-            }
-        });
-        // 索引
-        StringBuilder sb = new StringBuilder();
-        wlnf(sb, "模块 | 描述");
-        wlnf(sb, "---|----");
-        for (LuDocument doc : docList) {
-            String rph = doc.getPath();
-            rph = Files.renameSuffix(rph, ".md");
-            wlnf(sb, "[%s](%s) | %s", doc.getDisplayTitle(), rph, doc.getDisplaySummary());
-        }
-
-        // 构建上下文
-        NutMap context = new NutMap();
-        context.put("title", ds.getTitle());
-        context.put("index", sb);
-
-        // 渲染
-        String str = ds.getReadme().render(context);
-
-        File fReadme = Files.getFile(dirOut, "README.md");
-        fReadme = Files.createFileIfNoExists(fReadme);
-        Writer w = Streams.fileOutw(fReadme);
-        BufferedWriter bw = Streams.buffw(w);
-        try {
-            bw.write(str);
-
-        }
-        finally {
-            Streams.safeFlush(bw);
-            Streams.safeClose(w);
-        }
-    }
-
-    private void wlnf(StringBuilder sb, String fmt, Object... args) throws IOException {
-        if (!Strings.isBlank(fmt)) {
-            sb.append(String.format(fmt, args));
-        }
-        sb.append('\n');
-    }
-
-}

+ 0 - 197
tools/java/src/main/java/com/luatos/toolkit/impl/DoxyFnSignParser.java

@@ -1,197 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.nutz.lang.Lang;
-import org.nutz.lang.Strings;
-import org.nutz.lang.util.Regex;
-
-import com.luatos.toolkit.api.FnSignParser;
-import com.luatos.toolkit.bean.FnExample;
-import com.luatos.toolkit.bean.FnLang;
-import com.luatos.toolkit.bean.FnParam;
-import com.luatos.toolkit.bean.FnReturn;
-import com.luatos.toolkit.bean.FnSign;
-
-public class DoxyFnSignParser implements FnSignParser {
-
-    private static final int IN_SUMMARY = 0;
-    private static final int IN_FUNC = 1;
-    private static final int IN_EXAMPLE = 2;
-
-    private static String _r2 = "^\\s*([\\w\\d.:]+)\\s*(\\(([^)]*)\\))?.*$";
-    private static Pattern P2 = Regex.getPattern(_r2);
-
-    private static String _r3 = "^@(function|api)(.+)$";
-    private static Pattern P3 = Regex.getPattern(_r3);
-
-    @Override
-    public FnSign parse(String block) {
-        String[] lines = block.split("\r?\n");
-        List<String> summaries = new ArrayList<>(lines.length);
-        String func;
-        String[] pmnms = null;
-        List<FnParam> params = new ArrayList<>(lines.length);
-        FnExample exmLast = null;
-
-        String feType = null; // @return @string ...
-        String feCmt = "";
-
-        // 准备返回值
-        FnSign fn = new FnSign();
-        fn.setLang(FnLang.LUA);
-
-        // 三种状态
-        int mode = IN_SUMMARY;
-
-        // 逐行搞
-        for (String line : lines) {
-            // 还在摘要部分
-            if (IN_SUMMARY == mode) {
-
-                // 进入函数部分了
-                Matcher m = P3.matcher(line);
-                if (m.find()) {
-                    mode = IN_FUNC;
-                    func = Strings.trim(m.group(2));
-                    // 来,分析一下
-                    m = P2.matcher(func);
-                    if (!m.find()) {
-                        throw Lang.makeThrow("Invalid Lua func", func);
-                    }
-                    fn.setName(m.group(1));
-                    pmnms = Strings.splitIgnoreBlank(m.group(3));
-                    continue;
-                }
-                // 计入摘要
-                summaries.add(line);
-            }
-            // 进入函数部分
-            else if (IN_FUNC == mode) {
-                // 明确的开始例子部分
-                if (line.trim().equals("@usage")) {
-                    mode = IN_EXAMPLE;
-                }
-                // 进入例子部分了
-                else if (line.startsWith("--")) {
-                    if (null != exmLast && exmLast.hasCode()) {
-                        fn.addExample(exmLast);
-                    }
-
-                    exmLast = new FnExample();
-                    exmLast.appendSummary(line.substring(2).trim());
-
-                    mode = IN_EXAMPLE;
-                }
-                // 开始参数或者返回
-                else if (line.startsWith("@")) {
-                    // 推入旧的
-                    if (!Strings.isBlank(feType)) {
-                        pushFnEntity(fn, params, feType, feCmt);
-                    }
-                    // 开启新的
-                    int pos = line.indexOf(' ', 1);
-                    if (pos > 0) {
-                        feType = line.substring(1, pos).trim();
-                        feCmt = line.substring(pos + 1).trim();
-                    } else {
-                        feType = "??";
-                        feCmt = line.substring(1).trim();
-                    }
-                }
-            }
-            // 进入例子部分
-            else if (IN_EXAMPLE == mode) {
-                // 追加说明
-                if (line.startsWith("--")) {
-                    if (null != exmLast && exmLast.hasCode()) {
-                        fn.addExample(exmLast);
-                    }
-                    if (null == exmLast) {
-                        exmLast = new FnExample();
-                    }
-                    exmLast.appendSummary(line.substring(2).trim());
-                }
-                // 明确开始一段示例
-                else if(line.trim().equalsIgnoreCase("@usage")) {
-                    if (null != exmLast && exmLast.hasCode()) {
-                        fn.addExample(exmLast);
-                    }
-                    exmLast = null;
-                }
-                // 那就是例子代码咯
-                else {
-                    if (null == exmLast) {
-                        exmLast = new FnExample();
-                    }
-                    exmLast.appendCode(line);
-                }
-            }
-        }
-
-        // 推入最后一个实体
-        if (!Strings.isBlank(feType)) {
-            pushFnEntity(fn, params, feType, feCmt);
-        }
-
-        // 函数的摘要
-        fn.setSummary(Strings.join(System.lineSeparator(), summaries));
-
-        // 归纳函数参数
-        int plMax = Math.max(params.size(), pmnms.length);
-        for (int i = 0; i < plMax; i++) {
-            String pmnm = i < pmnms.length ? pmnms[i] : "?";
-            FnParam param = i < params.size() ? params.get(i) : null;
-            // 看来只有形参名,木有给定注释说明
-            if (null == param) {
-                param = new FnParam();
-            }
-            param.setName(pmnm);
-            fn.addParam(param);
-        }
-
-        // 最后一个例子
-        if (null != exmLast) {
-            fn.addExample(exmLast);
-        }
-
-        // 搞定
-        return fn;
-    }
-
-    private void pushFnEntity(FnSign fn, List<FnParam> params, String feType, String feCmt) {
-        // 返回值
-        if ("return".equals(feType)) {
-            int pos = feCmt.indexOf(' ');
-            FnReturn fr = new FnReturn();
-            String type = null;
-            String cmt = null;
-            if (pos > 0) {
-                type = feCmt.substring(0, pos).trim();
-                cmt = feCmt.substring(pos + 1).trim();
-            } else {
-                type = "??";
-                cmt = feCmt.trim();
-            }
-            if ("nil".equalsIgnoreCase(type)
-                || "nil".equalsIgnoreCase(cmt)
-                || Strings.isBlank(type)) {
-                return;
-            }
-            fr.setType(type);
-            fr.setComment(cmt);
-            fn.addReturn(fr);
-        }
-        // 参数
-        else {
-            FnParam param = new FnParam();
-            param.setType(feType);
-            param.setComment(feCmt);
-            params.add(param);
-        }
-    }
-
-}

+ 0 - 30
tools/java/src/main/java/com/luatos/toolkit/impl/JsonLuDocRender.java

@@ -1,30 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import java.io.BufferedWriter;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-
-import org.nutz.json.Json;
-import org.nutz.json.JsonFormat;
-import org.nutz.lang.Streams;
-
-import com.luatos.toolkit.LuatRenderingSetup;
-import com.luatos.toolkit.api.LuDocRender;
-import com.luatos.toolkit.bean.LuDocument;
-
-public class JsonLuDocRender implements LuDocRender {
-
-    @Override
-    public boolean render(LuDocument doc, OutputStream ops, LuatRenderingSetup setup) {
-        BufferedWriter br = Streams.buffw(new OutputStreamWriter(ops));
-
-        try {
-            Json.toJson(br, doc, JsonFormat.nice());
-            return true;
-        }
-        finally {
-            Streams.safeFlush(br);
-        }
-    }
-
-}

+ 0 - 23
tools/java/src/main/java/com/luatos/toolkit/impl/LuHeadParser.java

@@ -1,23 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import org.nutz.lang.Lang;
-import org.nutz.lang.util.NutMap;
-
-import com.luatos.toolkit.api.TagParser;
-import com.luatos.toolkit.bean.LuHead;
-
-public class LuHeadParser implements TagParser<LuHead> {
-
-    private NutMapTagParser parser;
-
-    public LuHeadParser() {
-        this.parser = new NutMapTagParser();
-    }
-
-    @Override
-    public LuHead parse(String input) {
-        NutMap map = parser.parse(input);
-        return Lang.map2Object(map, LuHead.class);
-    }
-
-}

+ 0 - 164
tools/java/src/main/java/com/luatos/toolkit/impl/MarkdownLuDocRender.java

@@ -1,164 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.util.List;
-import java.util.Map;
-
-import org.nutz.lang.Lang;
-import org.nutz.lang.Streams;
-import org.nutz.lang.Strings;
-import org.nutz.lang.util.NutMap;
-
-import com.luatos.toolkit.LuatRenderingSetup;
-import com.luatos.toolkit.api.LuDocRender;
-import com.luatos.toolkit.bean.FnExample;
-import com.luatos.toolkit.bean.FnParam;
-import com.luatos.toolkit.bean.FnReturn;
-import com.luatos.toolkit.bean.FnSign;
-import com.luatos.toolkit.bean.LuDocument;
-
-public class MarkdownLuDocRender implements LuDocRender {
-
-    @Override
-    public boolean render(LuDocument doc, OutputStream ops, LuatRenderingSetup setup) {
-        BufferedWriter br = Streams.buffw(new OutputStreamWriter(ops));
-
-        try {
-            return safeWrite(doc, br, setup);
-        }
-        catch (IOException e) {
-            throw Lang.wrapThrow(e);
-        }
-        finally {
-            Streams.safeFlush(br);
-        }
-    }
-
-    private void wlnf(BufferedWriter br, String fmt, Object... args) throws IOException {
-        if (null != fmt) {
-            if (null == args || args.length == 0) {
-                br.write(fmt);
-            } else {
-                String str = String.format(fmt, args);
-                br.write(str);
-            }
-            br.write("\n");
-        }
-    }
-
-    private static final String HR = Strings.dup('-', 50);
-
-    private boolean safeWrite(LuDocument doc, BufferedWriter br, LuatRenderingSetup setup)
-            throws IOException {
-        // 书写头部
-        if (doc.hasHead()) {
-            NutMap map = doc.getHead().toMap();
-            wlnf(br, "---");
-            for (Map.Entry<String, Object> en : map.entrySet()) {
-                wlnf(br, "%s: %s", en.getKey(), en.getValue());
-            }
-            wlnf(br, "---\n");
-        }
-
-        // 木有内容哦 ...
-        List<FnSign> funcs = doc.fetchFunctions(setup);
-        if (funcs.isEmpty())
-            return false;
-
-        // 每个函数一节
-        for (FnSign fn : funcs) {
-            // 输出标题
-            wlnf(br, HR);
-            wlnf(br, "# %s\n", fn.getName());
-
-            // 输出函数原型
-            wlnf(br, "```%s", fn.getLangName());
-            wlnf(br, fn.toSignature());
-            wlnf(br, "```\n");
-
-            // 摘要
-            if (fn.hasSummary()) {
-                wlnf(br, fn.getSummary());
-            }
-
-            // 标题二(参数)
-            wlnf(br, "\n## 参数表\n");
-            if (fn.hasParams()) {
-                wlnf(br, "Name | Type | Description");
-                wlnf(br, "-----|------|--------------");
-                for (FnParam fp : fn.getParams()) {
-                    String brief = tidyBrief(fp.getComment());
-                    wlnf(br, "`%s`|`%s`| %s", fp.getName(), fp.getType(), brief);
-                }
-            } else {
-                wlnf(br, "> 无参数");
-            }
-
-            // 标题二(返回值)
-            wlnf(br, "\n## 返回值\n");
-            if (fn.hasReturns() && !fn.isReturnMatch(0, "void")) {
-                // 只有一个返回值
-                if (fn.getReturnCount() == 1) {
-                    FnReturn fr = fn.getReturns().get(0);
-                    String brief = tidyBrief(fr.getComment());
-                    wlnf(br, "> `%s`: %s", fr.getType(), brief);
-                }
-                // 多个返回值显示表格
-                else {
-                    wlnf(br, "No. | Type | Description");
-                    wlnf(br, "----|------|--------------");
-                    int x = 0;
-                    for (FnReturn fr : fn.getReturns()) {
-                        String brief = tidyBrief(fr.getComment());
-                        wlnf(br, "%d |`%s`| %s", ++x, fr.getType(), brief);
-                    }
-                }
-            } else {
-                wlnf(br, "> *无返回值*");
-            }
-
-            // 标题二(例子)
-            if (fn.hasExamples()) {
-                wlnf(br, "\n## 调用示例\n");
-                wlnf(br, "```%s", fn.getLangName());
-                int i = 0;
-                for (FnExample fe : fn.getExamples()) {
-                    if (i > 0) {
-                        wlnf(br, "-------------------------");
-                    }
-                    i++;
-                    wlnf(br, "-- %s", Strings.join("\n-- ", fe.getSummary()));
-                    wlnf(br, Strings.join("\n", fe.getCode()));
-                }
-                wlnf(br, "```");
-            }
-
-            // 暂时不显示 C API
-            // 标题二(参考函数)
-            // if (fn.hasRefer()) {
-            // wlnf(br, "\n## C API");
-            // wlnf(br, "\n```c");
-            // wlnf(br, fn.getRefer().toSignature());
-            // wlnf(br, "```");
-            // }
-
-            // 最后结束来个空行
-            wlnf(br, "\n");
-        }
-
-        return true;
-    }
-
-    private String tidyBrief(String brief) {
-        if (Strings.isBlank(brief)) {
-            brief = "*无*";
-        } else {
-            brief = brief.replaceAll("\r?\n", " ");
-        }
-        return brief;
-    }
-
-}

+ 0 - 96
tools/java/src/main/java/com/luatos/toolkit/impl/NutMapTagParser.java

@@ -1,96 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.nutz.lang.Strings;
-import org.nutz.lang.util.NutMap;
-import org.nutz.lang.util.Regex;
-
-import com.luatos.toolkit.api.TagParser;
-
-/**
- * 逐行处理输入的标签,类似下面的输入结构
- * 
- * <pre>
- * &#64;module  rtos
- * &#64;summary RTOS底层操作库
- * &#64;version 1.0
- * &#64;date    2020.03.30
- * </pre>
- * 
- * @author zozoh(zozohtnt@gmail.com)
- */
-public class NutMapTagParser implements TagParser<NutMap> {
-
-    /**
-     * 正则,要能提出两个分组,一个表标签名,一个表标签值
-     */
-    private String regex;
-
-    /**
-     * 标签名在正则中的分组
-     */
-    private int keyIndex;
-
-    /**
-     * 标签值在正则中的分组
-     */
-    private int valIndex;
-
-    public NutMapTagParser() {
-        this("^@(\\w+)\\s+(.+)$", 1, 2);
-    }
-
-    public NutMapTagParser(String regex, int keyIndex, int valIndex) {
-        this.regex = regex;
-        this.keyIndex = keyIndex;
-        this.valIndex = valIndex;
-    }
-
-    @Override
-    public NutMap parse(String input) {
-        NutMap map = new NutMap();
-        String[] lines = input.split("\r?\n");
-
-        // 获得模式
-        Pattern p = Regex.getPattern(regex);
-
-        // 准备开始
-        String key = null;
-        List<String> val = null;
-
-        for (String line : lines) {
-            // 无视空行
-            if (Strings.isEmpty(line))
-                continue;
-
-            // 是否是一个标签的开始
-            Matcher m = p.matcher(line);
-            if (m.find()) {
-                // 推入旧的
-                if (null != key) {
-                    map.put(key, Strings.join("\n", val));
-                }
-                // 开启新的
-                key = Strings.trim(m.group(this.keyIndex));
-                val = new LinkedList<>();
-                val.add(Strings.trim(m.group(this.valIndex)));
-            }
-            // 加入旧标签
-            else if (null != key) {
-                val.add(Strings.trim(line));
-            }
-        }
-
-        // 推入最后一个
-        if (null != key) {
-            map.put(key, Strings.join("\n", val));
-        }
-
-        return map;
-    }
-
-}

+ 0 - 92
tools/java/src/main/java/com/luatos/toolkit/util/ComboLuDocRender.java

@@ -1,92 +0,0 @@
-package com.luatos.toolkit.util;
-
-import java.io.File;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.nutz.lang.Files;
-import org.nutz.lang.Lang;
-import org.nutz.lang.Streams;
-import org.nutz.log.Log;
-import org.nutz.log.Logs;
-
-import com.luatos.toolkit.LuatRenderingSetup;
-import com.luatos.toolkit.api.LuDocRender;
-import com.luatos.toolkit.bean.LuDocument;
-import com.luatos.toolkit.impl.JsonLuDocRender;
-import com.luatos.toolkit.impl.MarkdownLuDocRender;
-
-public class ComboLuDocRender {
-
-    private static final Log log = Logs.get();
-
-    private static final Map<String, LuDocRender> renders = new HashMap<>();
-    static {
-        renders.put("md", new MarkdownLuDocRender());
-        renders.put("json", new JsonLuDocRender());
-    }
-
-    private String[] ass;
-
-    private LuDocRender[] reds;
-
-    public ComboLuDocRender(String[] ass) {
-        this.ass = ass;
-        this.reds = new LuDocRender[ass.length];
-        for (int i = 0; i < ass.length; i++) {
-            LuDocRender red = renders.get(ass[i]);
-            if (null == red) {
-                throw Lang.makeThrow("Fail to found the render for type '%s'", ass[i]);
-            }
-            reds[i] = red;
-        }
-    }
-
-    /**
-     * @param doc
-     *            要输出的文档
-     * @param taDir
-     *            目标目录
-     * @param rph
-     *            相对目标目录的路径(后缀会自动被对应类型替换的)
-     * @return true 渲染成功;false 没必要渲染的文档
-     */
-    public boolean output(LuDocument doc, File taDir, String rph, LuatRenderingSetup setup) {
-        boolean re = false;
-        for (int i = 0; i < ass.length; i++) {
-            String as = ass[i];
-            LuDocRender red = reds[i];
-
-            // 准备一下输出文件
-            String ph = Files.renameSuffix(rph, "." + as);
-            File f = Files.getFile(taDir, ph);
-
-            // 确保创建
-            f = Files.createFileIfNoExists(f);
-
-            // 打开
-            OutputStream ops = Streams.fileOut(f);
-            boolean writeOk;
-            try {
-                writeOk = red.render(doc, ops, setup);
-            }
-            finally {
-                Streams.safeClose(ops);
-            }
-
-            // 写日志: 成功
-            if (writeOk) {
-                log.infof("    - OK: %6s : %s", as, ph);
-                re = true;
-            }
-            // 写日志: 空文档
-            else {
-                Files.deleteFile(f);
-                log.infof("    - KO: %6s : %s <blank>", as, ph);
-            }
-        }
-        return re;
-    }
-
-}

+ 0 - 7
tools/java/src/main/resources/dft_readme.md

@@ -1,7 +0,0 @@
----
-title: ${title}
----
-
-# ${title}
-
-${index} 

+ 0 - 14
tools/java/src/main/resources/doc-gen-air302.json

@@ -1,14 +0,0 @@
-{
-  "workdir": "D:/github/air302/",
-  "as": ["md"],
-  "entries": [{
-    "title": "LuaAPI模块",
-    "path": "sdk/luat",
-    "suffix": [".c"],
-    "lang" : ["LUA"],
-    "dropEmptyComment": true,
-    "out": "lua",
-    "deep": true
-  }],
-  "output": "${workdir}/doc/api/"
-}

+ 0 - 34
tools/java/src/main/resources/doc-gen-luatos.json

@@ -1,34 +0,0 @@
-{
-  "workdir": "D:/github/",
-  "as": ["md"],
-  "entries": [{
-    "title": "LuaAPI模块",
-    "paths": [
-        "LuatOS/luat/modules",
-        "LuatOS/luat/rtt",
-        "air302/sdk/luat" 
-    ],
-    "suffix": [".c"],
-    "lang" : ["LUA"],
-    "dropEmptyComment": true,
-    "out": "lua",
-    "deep": true
-  }, {
-    "title": "FreeRTOS集成",
-    "paths": ["LuatOS/luat/freertos"],
-    "suffix": [".c"],
-    "lang" : ["C"],
-    "dropEmptyComment": true,
-    "out": "c_api/${name}",
-    "deep": true
-  }, {
-    "title": "RT-Thread集成",
-    "paths": ["LuatOS/luat/rtt"],
-    "suffix": [".c"],
-    "lang" : ["C"],
-    "dropEmptyComment": true,
-    "out": "c_api/${name}",
-    "deep": true
-  }],
-  "output": "${workdir}/LuatOS/docs/api/"
-}

+ 0 - 14
tools/java/src/main/resources/log4j.properties

@@ -1,14 +0,0 @@
-log4j.rootLogger=error, A
-log4j.logger.org.eclipse=error
-log4j.logger.org.nutz=error
-log4j.logger.com.luatos=info
-
-#-------------------------------------------------------
-# Output to stdout
-#
-log4j.appender.A=org.apache.log4j.ConsoleAppender
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%m%n
-#log4j.appender.A.layout.ConversionPattern=%5p[%t]%d{dd'T'HH:mm:ss.SSS}: %m%n
-#log4j.appender.A.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
-

+ 0 - 13
tools/java/src/main/resources/log4j2.xml

@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="WARN">
-  <Appenders>
-    <Console name="Console" target="SYSTEM_OUT">
-      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
-    </Console>
-  </Appenders>
-  <Loggers>
-    <Root level="debug">
-      <AppenderRef ref="Console"/>
-    </Root>
-  </Loggers>
-</Configuration>

+ 0 - 11
tools/java/src/test/java/com/luatos/toolkit/AllLuTookietTest.java

@@ -1,11 +0,0 @@
-package com.luatos.toolkit;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-import com.luatos.toolkit.bean.LuAllBeanTest;
-import com.luatos.toolkit.impl.LuAllParserTest;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({LuAllBeanTest.class, LuAllParserTest.class})
-public class AllLuTookietTest {}

+ 0 - 157
tools/java/src/test/java/com/luatos/toolkit/bean/FnSignTest.java

@@ -1,157 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.nutz.json.Json;
-import org.nutz.lang.Files;
-
-import com.luatos.toolkit.api.FnSignParser;
-import com.luatos.toolkit.impl.CFnSignParser;
-import com.luatos.toolkit.impl.DoxyFnSignParser;
-
-public class FnSignTest {
-
-    @Test
-    public void test_lua_cmt_fn_0() {
-        String input = Files.read("input/lua_cmt_fn_0.txt");
-        String expec = Files.read("expec/lua_cmt_fn_0.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        FnSignParser fsg = new DoxyFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_lua_cmt_fn_1() {
-        String input = Files.read("input/lua_cmt_fn_1.txt");
-        String expec = Files.read("expec/lua_cmt_fn_1.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        FnSignParser fsg = new DoxyFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_lua_cmt_fn_2() {
-        String input = Files.read("input/lua_cmt_fn_2.txt");
-        String expec = Files.read("expec/lua_cmt_fn_2.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        FnSignParser fsg = new DoxyFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_0() {
-        String input = Files.read("input/c_sign_fn_0.txt");
-        String expec = Files.read("expec/c_sign_fn_0.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_1() {
-        String input = Files.read("input/c_sign_fn_1.txt");
-        String expec = Files.read("expec/c_sign_fn_1.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_2() {
-        String input = Files.read("input/c_sign_fn_2.txt");
-        String expec = Files.read("expec/c_sign_fn_2.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_3() {
-        String input = Files.read("input/c_sign_fn_3.txt");
-        String expec = Files.read("expec/c_sign_fn_3.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_4() {
-        String input = Files.read("input/c_sign_fn_4.txt");
-        String expec = Files.read("expec/c_sign_fn_4.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        // System.out.println(expFn);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_5() {
-        String input = Files.read("input/c_sign_fn_5.txt");
-        String expec = Files.read("expec/c_sign_fn_5.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        // System.out.println(expFn);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_6() {
-        String input = Files.read("input/c_sign_fn_6.txt");
-        String expec = Files.read("expec/c_sign_fn_6.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        // System.out.println(expFn);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_7() {
-        String input = Files.read("input/c_sign_fn_7.txt");
-        String expec = Files.read("expec/c_sign_fn_7.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        // System.out.println(expFn);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-    @Test
-    public void test_c_sign_fn_8() {
-        String input = Files.read("input/c_sign_fn_8.txt");
-        String expec = Files.read("expec/c_sign_fn_8.json");
-        FnSign expFn = Json.fromJson(FnSign.class, expec);
-
-        // System.out.println(expFn);
-
-        FnSignParser fsg = new CFnSignParser();
-        FnSign axuFn = fsg.parse(input);
-        assertTrue(axuFn.equals(expFn));
-    }
-
-}

+ 0 - 8
tools/java/src/test/java/com/luatos/toolkit/bean/LuAllBeanTest.java

@@ -1,8 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({FnSignTest.class, LuCommentTest.class})
-public class LuAllBeanTest {}

+ 0 - 65
tools/java/src/test/java/com/luatos/toolkit/bean/LuCommentTest.java

@@ -1,65 +0,0 @@
-package com.luatos.toolkit.bean;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.nutz.lang.Files;
-
-public class LuCommentTest {
-
-    @Test
-    public void test_lua_0() {
-        String input = Files.read("input/cmt_lua_0.txt");
-        String expec = Files.read("expec/cmt_lua_0.txt");
-
-        LuComment dc = new LuComment(input);
-        assertTrue(dc.isLuaSign());
-        assertEquals(0, dc.getSpace());
-        assertEquals(expec, dc.toString());
-    }
-
-    @Test
-    public void test_multi_0() {
-        String input = Files.read("input/cmt_c_multi_0.txt");
-        String expec = Files.read("expec/cmt_c_multi_0.txt");
-
-        LuComment dc = new LuComment(input);
-        assertTrue(dc.isBlock());
-        assertEquals(0, dc.getSpace());
-        assertEquals(expec, dc.toString());
-    }
-
-    @Test
-    public void test_multi_1() {
-        String input = Files.read("input/cmt_c_multi_1.txt");
-        String expec = Files.read("expec/cmt_c_multi_1.txt");
-
-        LuComment dc = new LuComment(input);
-        assertTrue(dc.isBlock());
-        assertEquals(0, dc.getSpace());
-        assertEquals(expec, dc.toString());
-    }
-
-    @Test
-    public void test_single_0() {
-        String input = Files.read("input/cmt_c_single_0.txt");
-        String expec = Files.read("expec/cmt_c_single_0.txt");
-
-        LuComment dc = new LuComment(input);
-        assertTrue(dc.isLines());
-        assertEquals(0, dc.getSpace());
-        assertEquals(expec, dc.toString());
-    }
-
-    @Test
-    public void test_single_1() {
-        String input = Files.read("input/cmt_c_single_1.txt");
-        String expec = Files.read("expec/cmt_c_single_1.txt");
-
-        LuComment dc = new LuComment(input);
-        assertTrue(dc.isLines());
-        assertEquals(2, dc.getSpace());
-        assertEquals(expec, dc.toString());
-    }
-
-}

+ 0 - 45
tools/java/src/test/java/com/luatos/toolkit/impl/CLuDocParserTest.java

@@ -1,45 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.nutz.json.Json;
-import org.nutz.lang.Files;
-
-import com.luatos.toolkit.api.LuDocParser;
-import com.luatos.toolkit.bean.LuDocument;
-
-public class CLuDocParserTest {
-
-    @Test
-    public void test_parse_0() {
-        String input = Files.read("input/doc_parse_0.c");
-        String expec = Files.read("expec/doc_parse_0.json");
-        LuDocument expDoc = Json.fromJson(LuDocument.class, expec);
-
-        LuDocParser pas = new CLuDocParser();
-        LuDocument axuDoc = pas.parse(input);
-
-        // System.out.println(Json.toJson(axuDoc,
-        // JsonFormat.nice().setQuoteName(true)));
-        assertNotNull(axuDoc);
-        assertTrue(expDoc.equals(axuDoc));
-
-    }
-
-    @Test
-    public void test_parse_1() {
-        String input = Files.read("input/doc_parse_1.c");
-        String expec = Files.read("expec/doc_parse_1.json");
-        LuDocument expDoc = Json.fromJson(LuDocument.class, expec);
-
-        LuDocParser pas = new CLuDocParser();
-        LuDocument axuDoc = pas.parse(input);
-        // System.out.println(Json.toJson(axuDoc,
-        // JsonFormat.nice().setQuoteName(true)));
-        assertNotNull(axuDoc);
-        assertTrue(expDoc.equals(axuDoc));
-
-    }
-
-}

+ 0 - 8
tools/java/src/test/java/com/luatos/toolkit/impl/LuAllParserTest.java

@@ -1,8 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({TagParserTest.class, CLuDocParserTest.class})
-public class LuAllParserTest {}

+ 0 - 37
tools/java/src/test/java/com/luatos/toolkit/impl/TagParserTest.java

@@ -1,37 +0,0 @@
-package com.luatos.toolkit.impl;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.nutz.json.Json;
-import org.nutz.lang.Files;
-import org.nutz.lang.Lang;
-import org.nutz.lang.util.NutMap;
-
-import com.luatos.toolkit.bean.LuHead;
-
-public class TagParserTest {
-
-    @Test
-    public void test_head_0_NutMap() {
-        String input = Files.read("input/head_0.txt");
-        String expec = Files.read("expec/head_0.json");
-        NutMap exMap = Json.fromJson(NutMap.class, expec);
-
-        NutMapTagParser par = new NutMapTagParser();
-        NutMap axMap = par.parse(input);
-        assertTrue(Lang.equals(exMap, axMap));
-    }
-
-    @Test
-    public void test_head_0_LuHead() {
-        String input = Files.read("input/head_0.txt");
-        String expec = Files.read("expec/head_0.json");
-        LuHead exHed = Json.fromJson(LuHead.class, expec);
-
-        LuHeadParser par = new LuHeadParser();
-        LuHead axHed = par.parse(input);
-        assertTrue(exHed.equals(axHed));
-    }
-
-}

+ 0 - 15
tools/java/src/test/resources/expec/c_sign_fn_0.json

@@ -1,15 +0,0 @@
-{
-  "rawText": "static int socket_ntp_sync(lua_State *L)",
-  "summary": null,
-  "lang": "C",
-  "modifier": "static",
-  "returns": [{
-      "type": "int"
-    }],
-  "name": "socket_ntp_sync",
-  "params": [{
-      "type": "lua_State *",
-      "name": "L"
-    }]
-}
-  

+ 0 - 14
tools/java/src/test/resources/expec/c_sign_fn_1.json

@@ -1,14 +0,0 @@
-{
-  "rawText": "void  luat_heap_init(void)",
-  "summary": null,
-  "lang": "C",
-  "modifier": null,
-  "returns": [{
-      "type": "void"
-    }],
-  "name": "luat_heap_init",
-  "params": [{
-      "type": "void",
-      "name": null
-    }]
-}

+ 0 - 20
tools/java/src/test/resources/expec/c_sign_fn_2.json

@@ -1,20 +0,0 @@
-{
-  "rawText": "void *luat_rt_realloc(void *rmem, rt_size_t newsize);",
-  "summary": null,
-  "lang": "C",
-  "modifier": null,
-  "returns": [{
-      "type": "void*"
-    }],
-  "name": "luat_rt_realloc",
-  "params": [{
-      "type": "void*",
-      "name": "rmem"
-    }, {
-      "type": "rt_size_t",
-      "name": "newsize"
-    }]
-}
-  
-
-  

+ 0 - 20
tools/java/src/test/resources/expec/c_sign_fn_3.json

@@ -1,20 +0,0 @@
-{
-  "rawText": "static int l_timer_handler(lua_State *L, void* ptr) {",
-  "summary": null,
-  "lang": "C",
-  "modifier": "static",
-  "returns": [{
-      "type": "int"
-    }],
-  "name": "l_timer_handler",
-  "params": [{
-      "type": "lua_State*",
-      "name": "L"
-    }, {
-      "type": "void*",
-      "name": "ptr"
-    }]
-}
-  
-
-  

+ 0 - 21
tools/java/src/test/resources/expec/c_sign_fn_4.json

@@ -1,21 +0,0 @@
-{
-  "rawText": "static void fixhex(const char* source, char* dst, size_t len) {",
-  "summary": null,
-  "lang": "C",
-  "modifier": "static",
-  "returns": [{
-      "type": "void"
-    }],
-  "name": "fixhex",
-  "params": [{
-      "modifier": "const",
-      "type": "char*",
-      "name": "source"
-    }, {
-      "type": "char*",
-      "name": "dst"
-    }, {
-      "type": "size_t",
-      "name": "len"
-    }]
-}

+ 0 - 15
tools/java/src/test/resources/expec/c_sign_fn_5.json

@@ -1,15 +0,0 @@
-{
-  "rawText": "static void lfs1_superblock_fromle32(struct lfs1_disk_superblock *d) {",
-  "summary": null,
-  "lang": "C",
-  "modifier": "static",
-  "returns": [{
-      "type": "void"
-    }],
-  "name": "lfs1_superblock_fromle32",
-  "params": [{
-      "modifier": "struct",
-      "type": "lfs1_disk_superblock*",
-      "name": "d"
-    }]
-}

+ 0 - 24
tools/java/src/test/resources/expec/c_sign_fn_6.json

@@ -1,24 +0,0 @@
-{
-  "rawText": "static uint8_t u8x8_d_lc7981_common(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)",
-  "summary": null,
-  "lang": "C",
-  "modifier": "static",
-  "returns": [{
-      "type": "uint8_t"
-    }],
-  "name": "u8x8_d_lc7981_common",
-  "params": [{
-      "type": "u8x8_t*",
-      "name": "u8x8"
-    }, {
-      "type": "uint8_t",
-      "name": "msg"
-    }, {
-      "modifier": "U8X8_UNUSED",
-      "type": "uint8_t",
-      "name": "arg_int"
-    }, {
-      "type": "void*",
-      "name": "arg_ptr"
-    }]
-}

+ 0 - 17
tools/java/src/test/resources/expec/c_sign_fn_7.json

@@ -1,17 +0,0 @@
-{
-  "rawText": "static inline void lfs_cache_drop(lfs_t *lfs, lfs_cache_t *rcache) {",
-  "summary": null,
-  "lang": "C",
-  "modifier": "static inline",
-  "returns": [{
-      "type": "void"
-    }],
-  "name": "lfs_cache_drop",
-  "params": [{
-      "type": "lfs_t*",
-      "name": "lfs"
-    }, {
-      "type": "lfs_cache_t*",
-      "name": "rcache"
-    }]
-}

+ 0 - 15
tools/java/src/test/resources/expec/c_sign_fn_8.json

@@ -1,15 +0,0 @@
-{
-  "rawText": "static inline bool lfs_pair_isnull(const lfs_block_t pair[2]) {",
-  "summary": null,
-  "lang": "C",
-  "modifier": "static inline",
-  "returns": [{
-      "type": "bool"
-    }],
-  "name": "lfs_pair_isnull",
-  "params": [{
-      "modifier": "const",
-      "type": "lfs_block_t",
-      "name": "pair[2]"
-    }]
-}

+ 0 - 3
tools/java/src/test/resources/expec/cmt_c_multi_0.txt

@@ -1,3 +0,0 @@
-results:
--1, no space to install fatfs driver
->= 0, there is an space to install littlefs driver

+ 0 - 4
tools/java/src/test/resources/expec/cmt_c_multi_1.txt

@@ -1,4 +0,0 @@
-open upvalues point to values in a thread, so those values should
-be marked when the thread is traversed except in the atomic phase
-(because then the value cannot be changed by the thread and the
-thread may not be traversed again)

+ 0 - 4
tools/java/src/test/resources/expec/cmt_c_single_0.txt

@@ -1,4 +0,0 @@
-Erase a block. A block must be erased before being programmed.
-The state of an erased block is undefined. Negative error codes
-are propogated to the user.
-May return LFS_ERR_CORRUPT if the block should be considered bad.

+ 0 - 4
tools/java/src/test/resources/expec/cmt_c_single_1.txt

@@ -1,4 +0,0 @@
-Erase a block. A block must be erased before being programmed.
-The state of an erased block is undefined. Negative error codes
-are propogated to the user.
-May return LFS_ERR_CORRUPT if the block should be considered bad.

+ 0 - 9
tools/java/src/test/resources/expec/cmt_lua_0.txt

@@ -1,9 +0,0 @@
-ntp时间同步
-@function    socket.ntpSync(server)
-@string ntp服务器域名,默认值ntp1.aliyun.com
-@return int 启动成功返回0, 失败返回1或者2
---  如果读取失败,会返回nil
-socket.ntpSync()
-sys.subscribe("NTP_UPDATE", function(re)
-    log.info("ntp", "result", re)
-end)

+ 0 - 239
tools/java/src/test/resources/expec/doc_parse_0.json

@@ -1,239 +0,0 @@
-{
-   "head": {
-      "module": "rtos",
-      "summary": "RTOS底层操作库",
-      "version": "1.0",
-      "date": "2020.03.30"
-   },
-   "functions": [{
-      "summary": "接受并处理底层消息队列.",
-      "lang": "LUA",
-      "name": "rtos.receive",
-      "returns": [{
-         "type": "msgid",
-         "comment": "如果是定时器消息,会返回定时器消息id及附加信息, 其他消息由底层决定,不向lua层进行任何保证."
-      }],
-      "params": [{
-         "name": "timeout",
-         "type": "int",
-         "comment": "超时时长,通常是-1,永久等待"
-      }],
-      "examples": [{
-         "summary": ["本方法通过sys.run()调用, 普通用户不要使用"],
-         "code": ["rtos.receive(-1)"]
-      }],
-      "refer": {
-         "rawText": "static int l_rtos_receive(lua_State *L) {",
-         "lang": "C",
-         "modifier": "static",
-         "name": "l_rtos_receive",
-         "returns": [{
-            "type": "int"
-         }],
-         "params": [{
-            "name": "L",
-            "type": "lua_State*"
-         }]
-      }
-   }, {
-      "rawText": "static int l_timer_handler(lua_State *L, void* ptr) {",
-      "lang": "C",
-      "modifier": "static",
-      "name": "l_timer_handler",
-      "returns": [{
-         "type": "int"
-      }],
-      "params": [{
-         "name": "L",
-         "type": "lua_State*"
-      }, {
-         "name": "ptr",
-         "type": "void*"
-      }]
-   }, {
-      "summary": "启动一个定时器",
-      "lang": "LUA",
-      "name": "rtos.timer_start",
-      "returns": [{
-         "type": "id",
-         "comment": "如果是定时器消息,会返回定时器消息id及附加信息, 其他消息由底层决定,不向lua层进行任何保证."
-      }],
-      "params": [{
-         "name": "id",
-         "type": "int",
-         "comment": "定时器id"
-      }, {
-         "name": "timeout",
-         "type": "int",
-         "comment": "超时时长,单位毫秒"
-      }, {
-         "name": "_repeat",
-         "type": "int",
-         "comment": "重复次数,默认是0"
-      }],
-      "examples": [{
-         "summary": ["用户代码请使用 sys.timerStart", "启动一个3秒的循环定时器"],
-         "code": ["rtos.timer_start(10000, 3000, -1)"]
-      }],
-      "refer": {
-         "rawText": "static int l_rtos_timer_start(lua_State *L) {",
-         "lang": "C",
-         "modifier": "static",
-         "name": "l_rtos_timer_start",
-         "returns": [{
-            "type": "int"
-         }],
-         "params": [{
-            "name": "L",
-            "type": "lua_State*"
-         }]
-      }
-   }, {
-      "summary": "关闭并释放一个定时器",
-      "lang": "LUA",
-      "name": "rtos.timer_stop",
-      "params": [{
-         "name": "id",
-         "type": "int",
-         "comment": "定时器id"
-      }],
-      "examples": [{
-         "summary": ["用户代码请使用sys.timerStop"],
-         "code": ["rtos.timer_stop(100000)"]
-      }],
-      "refer": {
-         "rawText": "static int l_rtos_timer_stop(lua_State *L) {",
-         "lang": "C",
-         "modifier": "static",
-         "name": "l_rtos_timer_stop",
-         "returns": [{
-            "type": "int"
-         }],
-         "params": [{
-            "name": "L",
-            "type": "lua_State*"
-         }]
-      }
-   }, {
-      "summary": "设备重启",
-      "lang": "LUA",
-      "name": "rtos.reboot",
-      "examples": [{
-         "summary": ["立即重启设备"],
-         "code": ["rtos.reboot()"]
-      }],
-      "refer": {
-         "rawText": "static int l_rtos_reboot(lua_State *L) {",
-         "lang": "C",
-         "modifier": "static",
-         "name": "l_rtos_reboot",
-         "returns": [{
-            "type": "int"
-         }],
-         "params": [{
-            "name": "L",
-            "type": "lua_State*"
-         }]
-      }
-   }, {
-      "rawText": "static int l_rtos_build_date(lua_State *L) {",
-      "lang": "C",
-      "modifier": "static",
-      "name": "l_rtos_build_date",
-      "returns": [{
-         "type": "int"
-      }],
-      "params": [{
-         "name": "L",
-         "type": "lua_State*"
-      }]
-   }, {
-      "summary": "获取硬件bsp型号",
-      "lang": "LUA",
-      "name": "rtos.bsp",
-      "returns": [{
-         "type": "string",
-         "comment": "硬件bsp型号"
-      }],
-      "examples": [{
-         "summary": ["获取编译日期"],
-         "code": ["local bsp = rtos.bsp()"]
-      }],
-      "refer": {
-         "rawText": "static int l_rtos_bsp(lua_State *L) {",
-         "lang": "C",
-         "modifier": "static",
-         "name": "l_rtos_bsp",
-         "returns": [{
-            "type": "int"
-         }],
-         "params": [{
-            "name": "L",
-            "type": "lua_State*"
-         }]
-      }
-   }, {
-      "summary": " 获取固件版本号",
-      "lang": "LUA",
-      "name": "rtos.version",
-      "returns": [{
-         "type": "string",
-         "comment": "固件版本号,例如\"1.0.2\""
-      }],
-      "examples": [{
-         "summary": ["读取版本号"],
-         "code": ["local luatos_version = rtos.version()"]
-      }],
-      "refer": {
-         "rawText": "static int l_rtos_version(lua_State *L) {",
-         "lang": "C",
-         "modifier": "static",
-         "name": "l_rtos_version",
-         "returns": [{
-            "type": "int"
-         }],
-         "params": [{
-            "name": "L",
-            "type": "lua_State*"
-         }]
-      }
-   }, {
-      "summary": "进入待机模式(部分设备可用,例如w60x)",
-      "lang": "LUA",
-      "name": "rtos.standy",
-      "params": [{
-         "name": "timeout",
-         "type": "int",
-         "comment": "休眠时长,单位毫秒"
-      }],
-      "examples": [{
-         "summary": ["读取版本号"],
-         "code": ["local luatos_version = rtos.version()"]
-      }],
-      "refer": {
-         "rawText": "static int l_rtos_standy(lua_State *L) {",
-         "lang": "C",
-         "modifier": "static",
-         "name": "l_rtos_standy",
-         "returns": [{
-            "type": "int"
-         }],
-         "params": [{
-            "name": "L",
-            "type": "lua_State*"
-         }]
-      }
-   }, {
-      "rawText": "static int l_rtos_meminfo(lua_State *L) {",
-      "lang": "C",
-      "modifier": "static",
-      "name": "l_rtos_meminfo",
-      "returns": [{
-         "type": "int"
-      }],
-      "params": [{
-         "name": "L",
-         "type": "lua_State*"
-      }]
-   }]
-}

+ 0 - 288
tools/java/src/test/resources/expec/doc_parse_1.json

@@ -1,288 +0,0 @@
-{
-  "head": {
-     "module": "socket",
-     "summary": "socket操作库",
-     "version": "1.0",
-     "date": "2020.03.30"
-  },
-  "functions": [{
-     "rawText": "static int socket_ntp_sync(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "socket_ntp_sync",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int sal_tls_test(lua_State *L)",
-     "lang": "C",
-     "modifier": "static",
-     "name": "sal_tls_test",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int l_socket_is_ready(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "l_socket_is_ready",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int l_socket_selfip(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "l_socket_selfip",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int luat_lib_netc_msg_handler(lua_State* L, void* ptr) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "luat_lib_netc_msg_handler",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }, {
-        "name": "ptr",
-        "type": "void*"
-     }]
-  }, {
-     "rawText": "static int luat_lib_socket_new(lua_State* L, int netc_type);",
-     "lang": "C",
-     "modifier": "static",
-     "name": "luat_lib_socket_new",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }, {
-        "name": "netc_type",
-        "type": "int"
-     }]
-  }, {
-     "rawText": "static int luat_lib_socket_ent_handler(netc_ent_t* ent) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "luat_lib_socket_ent_handler",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "ent",
-        "type": "netc_ent_t*"
-     }]
-  }, {
-     "rawText": "static int luat_lib_socket_tcp(lua_State* L) {",
-     "summary": "----------------------------------------------------------------",
-     "lang": "C",
-     "modifier": "static",
-     "name": "luat_lib_socket_tcp",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "summary": "新建一个udp socket",
-     "lang": "LUA",
-     "name": "socket.udp",
-     "refer": {
-        "rawText": "static int luat_lib_socket_udp(lua_State* L) {",
-        "lang": "C",
-        "modifier": "static",
-        "name": "luat_lib_socket_udp",
-        "returns": [{
-           "type": "int"
-        }],
-        "params": [{
-           "name": "L",
-           "type": "lua_State*"
-        }]
-     }
-  }, {
-     "rawText": "static int luat_lib_socket_new(lua_State* L, int netc_type) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "luat_lib_socket_new",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }, {
-        "name": "netc_type",
-        "type": "int"
-     }]
-  }, {
-     "rawText": "static int netc_connect(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_connect",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_close(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_close",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_send(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_send",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_gc(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_gc",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_tostring(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_tostring",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_id(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_id",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_host(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_host",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_port(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_port",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_clean(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_clean",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_on(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_on",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static int netc_closed(lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "netc_closed",
-     "returns": [{
-        "type": "int"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }, {
-     "rawText": "static void createmeta (lua_State *L) {",
-     "lang": "C",
-     "modifier": "static",
-     "name": "createmeta",
-     "returns": [{
-        "type": "void"
-     }],
-     "params": [{
-        "name": "L",
-        "type": "lua_State*"
-     }]
-  }]
-}

+ 0 - 6
tools/java/src/test/resources/expec/head_0.json

@@ -1,6 +0,0 @@
-{
-  "module"  : "rtos",
-  "summary" : "RTOS底层操作库",
-  "version" : "1.0",
-  "date"    : "2020.03.30"
-}

+ 0 - 24
tools/java/src/test/resources/expec/lua_cmt_fn_0.json

@@ -1,24 +0,0 @@
-{
-  "rawText": "=INPUT",
-  "summary": "ntp时间同步",
-  "lang": "LUA",
-  "modifier": null,
-  "returns": [{
-      "type": "int",
-      "comment": "启动成功返回0, 失败返回1或者2"
-    }],
-  "name": "socket.ntpSync",
-  "params": [{
-      "type": "string",
-      "name": "server",
-      "comment": "ntp服务器域名,默认值ntp1.aliyun.com"
-    }],
-  "examples": [{
-    "summary": ["如果读取失败,会返回nil"],
-    "code": [
-      "socket.ntpSync()",
-      "sys.subscribe(\"NTP_UPDATE\", function(re)",
-      "    log.info(\"ntp\", \"result\", re)",
-      "end)"]
-  }]
-}

+ 0 - 30
tools/java/src/test/resources/expec/lua_cmt_fn_1.json

@@ -1,30 +0,0 @@
-{
-  "rawText": "=INPUT",
-  "summary": "启动一个定时器",
-  "lang": "LUA",
-  "modifier": null,
-  "returns": [{
-      "type": "id",
-      "comment": "如果是定时器消息,会返回定时器消息id及附加信息, 其他消息由底层决定,不向lua层进行任何保证."
-    }],
-  "name": "rtos.timer_start",
-  "params": [{
-      "type": "int",
-      "name": "id",
-      "comment": "定时器id"
-    }, {
-      "type": "int",
-      "name": "timeout",
-      "comment": "超时时长,单位毫秒"
-    }, {
-      "type": "int",
-      "name": "_repeat",
-      "comment": "重复次数,默认是0"
-    }],
-  "examples": [{
-    "summary": [
-      "用户代码请使用 sys.timerStart",
-      "启动一个3秒的循环定时器"],
-    "code": ["rtos.timer_start(10000, 3000, -1)"]
-  }]
-}

+ 0 - 23
tools/java/src/test/resources/expec/lua_cmt_fn_2.json

@@ -1,23 +0,0 @@
-{
-  "rawText": "=INPUT",
-  "summary": "启动socket线程",
-  "lang": "LUA",
-  "modifier": null,
-  "returns": [{
-      "type": "int",
-      "comment": "成功返回1,失败返回0"
-    }],
-  "name": "so:start",
-  "params": [{
-      "type": "string",
-      "name": "host",
-      "comment": "服务器域名或ip,如果已经使用so:host和so:port配置,就不需要传参数了"
-    }, {
-      "type": "string",
-      "name": "port",
-      "comment": "服务器端口,如果已经使用so:host和so:port配置,就不需要传参数了"
-    }],
-  "examples": [{
-    "summary": ["参考socket.tcp的说明, 并查阅demo"]
-  }]
-}

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_0.txt

@@ -1 +0,0 @@
-static int socket_ntp_sync(lua_State *L) {

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_1.txt

@@ -1 +0,0 @@
-void  luat_heap_init(void) {};

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_2.txt

@@ -1 +0,0 @@
-void *luat_rt_realloc(void *rmem, rt_size_t newsize);

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_3.txt

@@ -1 +0,0 @@
-static int l_timer_handler(lua_State *L, void* ptr) {

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_4.txt

@@ -1 +0,0 @@
-static void fixhex(const char* source, char* dst, size_t len) {

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_5.txt

@@ -1 +0,0 @@
- static void lfs1_superblock_fromle32(struct lfs1_disk_superblock *d) {

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_6.txt

@@ -1 +0,0 @@
- static uint8_t u8x8_d_lc7981_common(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_7.txt

@@ -1 +0,0 @@
-  static inline void lfs_cache_drop(lfs_t *lfs, lfs_cache_t *rcache) {

+ 0 - 1
tools/java/src/test/resources/input/c_sign_fn_8.txt

@@ -1 +0,0 @@
- static inline bool lfs_pair_isnull(const lfs_block_t pair[2]) {

+ 0 - 4
tools/java/src/test/resources/input/cmt_c_multi_0.txt

@@ -1,4 +0,0 @@
-/* results:
- *  -1, no space to install fatfs driver
- *  >= 0, there is an space to install littlefs driver
- */

+ 0 - 6
tools/java/src/test/resources/input/cmt_c_multi_1.txt

@@ -1,6 +0,0 @@
-/*
-** open upvalues point to values in a thread, so those values should
-** be marked when the thread is traversed except in the atomic phase
-** (because then the value cannot be changed by the thread and the
-** thread may not be traversed again)
-*/

+ 0 - 4
tools/java/src/test/resources/input/cmt_c_single_0.txt

@@ -1,4 +0,0 @@
-// Erase a block. A block must be erased before being programmed.
-// The state of an erased block is undefined. Negative error codes
-// are propogated to the user.
-// May return LFS_ERR_CORRUPT if the block should be considered bad.

+ 0 - 4
tools/java/src/test/resources/input/cmt_c_single_1.txt

@@ -1,4 +0,0 @@
-  // Erase a block. A block must be erased before being programmed.
-  // The state of an erased block is undefined. Negative error codes
-  // are propogated to the user.
-  // May return LFS_ERR_CORRUPT if the block should be considered bad.

+ 0 - 11
tools/java/src/test/resources/input/cmt_lua_0.txt

@@ -1,11 +0,0 @@
-/*
-ntp时间同步
-@function    socket.ntpSync(server)
-@string ntp服务器域名,默认值ntp1.aliyun.com
-@return int 启动成功返回0, 失败返回1或者2
---  如果读取失败,会返回nil
-socket.ntpSync()
-sys.subscribe("NTP_UPDATE", function(re)
-    log.info("ntp", "result", re)
-end)
-*/

+ 0 - 237
tools/java/src/test/resources/input/doc_parse_0.c

@@ -1,237 +0,0 @@
-/*
-@module  rtos
-@summary RTOS底层操作库
-@version 1.0
-@date    2020.03.30
-*/
-#include "luat_base.h"
-#include "luat_sys.h"
-#include "luat_msgbus.h"
-#include "luat_timer.h"
-#include "luat_malloc.h"
-
-#define LUAT_LOG_TAG "luat.rtos"
-#include "luat_log.h"
-
-/*
-接受并处理底层消息队列.
-@function    rtos.receive(timeout)   
-@int  超时时长,通常是-1,永久等待
-@return msgid          如果是定时器消息,会返回定时器消息id及附加信息, 其他消息由底层决定,不向lua层进行任何保证.
---  本方法通过sys.run()调用, 普通用户不要使用
-rtos.receive(-1)
-*/
-static int l_rtos_receive(lua_State *L) {
-    rtos_msg_t msg;
-    int re;
-    re = luat_msgbus_get(&msg, luaL_checkinteger(L, 1));
-    if (!re) {
-        //LLOGD("rtos_msg got, invoke it handler=%08X", msg.handler);
-        lua_pushlightuserdata(L, (void*)(&msg));
-        return msg.handler(L, msg.ptr);
-    }
-    else {
-        //LLOGD("rtos_msg get timeout");
-        lua_pushinteger(L, -1);
-        return 1;
-    }
-}
-
-//------------------------------------------------------------------
-static int l_timer_handler(lua_State *L, void* ptr) {
-    luat_timer_t *timer = (luat_timer_t *)ptr;
-    // LLOGD(("l_timer_handler id=%ld\n", timer->id);
-    lua_pushinteger(L, MSG_TIMER);
-    lua_pushinteger(L, timer->id);
-    lua_pushinteger(L, timer->repeat);
-    //lua_pushinteger(L, timer->timeout);
-    if (timer->repeat == 0) {
-        luat_timer_stop(timer);
-        luat_heap_free(timer);
-    }
-    else if (timer->repeat > 0) {
-        timer->repeat --;
-    }
-    return 3;
-}
-
-/*
-启动一个定时器
-@function    rtos.timer_start(id,timeout,_repeat)   
-@int  定时器id
-@int  超时时长,单位毫秒
-@int  重复次数,默认是0
-@return id 如果是定时器消息,会返回定时器消息id及附加信息, 其他消息由底层决定,不向lua层进行任何保证.
-@usage
--- 用户代码请使用 sys.timerStart
--- 启动一个3秒的循环定时器
-rtos.timer_start(10000, 3000, -1)
-*/
-static int l_rtos_timer_start(lua_State *L) {
-    lua_gettop(L);
-    size_t id = (size_t)luaL_checkinteger(L, 1) / 1;
-    size_t timeout = (size_t)luaL_checkinteger(L, 2);
-    int repeat = (size_t)luaL_optinteger(L, 3, 0);
-    // LLOGD(("timer id=%ld\n", id);
-    // LLOGD(("timer timeout=%ld\n", timeout);
-    // LLOGD(("timer repeat=%ld\n", repeat);
-    if (timeout < 1) {
-        lua_pushinteger(L, 0);
-        return 1;
-    }
-    luat_timer_t *timer = (luat_timer_t*)luat_heap_malloc(sizeof(luat_timer_t));
-    timer->id = id;
-    timer->timeout = timeout;
-    timer->repeat = repeat;
-    timer->func = &l_timer_handler;
-
-    int re = luat_timer_start(timer);
-    if (re == 0) {
-        lua_pushinteger(L, 1);
-    }
-    else {
-        lua_pushinteger(L, 0);
-    }
-    return 1;
-}
-
-/*
-关闭并释放一个定时器
-@function    rtos.timer_stop(id)   
-@int  定时器id
-@return nil            无返回值
-@usage
--- 用户代码请使用sys.timerStop
-rtos.timer_stop(100000)
-*/
-static int l_rtos_timer_stop(lua_State *L) {
-    luat_timer_t *timer = NULL;
-    if (lua_islightuserdata(L, 1)) {
-        timer = (luat_timer_t *)lua_touserdata(L, 1);
-    }
-    else if (lua_isinteger(L, 1)) {
-        timer = luat_timer_get(lua_tointeger(L, 1));
-    }
-    if (timer != NULL) {
-        luat_timer_stop(timer);
-        luat_heap_free(timer);
-    }
-    return 0;
-}
-
-/*
-设备重启
-@function    rtos.reboot()   
-@return nil          无返回值
--- 立即重启设备
-rtos.reboot()
-*/
-static int l_rtos_reboot(lua_State *L) {
-    luat_os_reboot(luaL_optinteger(L, 1, 0));
-    return 0;
-}
-
-//-----------------------------------------------------------------
-
-/*
-获取固件编译日期
-@function    rtos.buildDate()
-@return string 固件编译日期
-@usage
--- 获取编译日期
-local d = rtos.buildDate()
-*/
-static int l_rtos_build_date(lua_State *L) {
-    lua_pushstring(L, __DATE__);
-    return 1;
-}
-
-/*
-获取硬件bsp型号
-@function    rtos.bsp()
-@return string 硬件bsp型号
-@usage
--- 获取编译日期
-local bsp = rtos.bsp()
-*/
-static int l_rtos_bsp(lua_State *L) {
-    lua_pushstring(L, luat_os_bsp());
-    return 1;
-}
-
-/*
- 获取固件版本号
-@function    rtos.version()        
-@return string  固件版本号,例如"1.0.2"
-@usage
--- 读取版本号
-local luatos_version = rtos.version()
-*/
-static int l_rtos_version(lua_State *L) {
-    lua_pushstring(L, LUAT_VERSION);
-    return 1;
-}
-
-/*
-进入待机模式(部分设备可用,例如w60x)
-@function    rtos.standy(timeout)
-@int    休眠时长,单位毫秒     
-@return nil  无返回值
-@usage
--- 读取版本号
-local luatos_version = rtos.version()
-*/
-static int l_rtos_standy(lua_State *L) {
-    int timeout = luaL_checkinteger(L, 1);
-    luat_os_standy(timeout);
-    return 0;
-}
-
-static int l_rtos_meminfo(lua_State *L) {
-    size_t len = 0;
-    size_t total = 0;
-    size_t used = 0;
-    size_t max_used = 0;
-    const char * str = luaL_optlstring(L, 1, "lua", &len);
-    if (strcmp("sys", str) == 0) {
-        //lua_gc(L, LUA_GCCOLLECT, 0);
-        //lua_gc(L, LUA_GCCOLLECT, 0);
-        luat_meminfo_sys(&total, &used, &max_used);
-    }
-    else {
-        luat_meminfo_luavm(&total, &used, &max_used);
-    }
-    lua_pushinteger(L, total);
-    lua_pushinteger(L, used);
-    lua_pushinteger(L, max_used);
-    return 3;
-}
-
-//------------------------------------------------------------------
-#include "rotable.h"
-static const rotable_Reg reg_rtos[] =
-{
-    { "timer_start" ,      l_rtos_timer_start, 0},
-    { "timer_stop",        l_rtos_timer_stop,  0},
-    { "receive",           l_rtos_receive,     0},
-    { "reboot",            l_rtos_reboot,      0},
-    { "standy",            l_rtos_standy,      0},
-
-    { "buildDate",         l_rtos_build_date,  0},
-    { "bsp",               l_rtos_bsp,         0},
-    { "version",           l_rtos_version,     0},
-    { "meminfo",           l_rtos_meminfo,     0},
-
-    { "INF_TIMEOUT",        NULL,              -1},
-
-    { "MSG_TIMER",          NULL,              MSG_TIMER},
-    // { "MSG_GPIO",           NULL,              MSG_GPIO},
-    // { "MSG_UART_RX",        NULL,              MSG_UART_RX},
-    // { "MSG_UART_TXDONE",    NULL,              MSG_UART_TXDONE},
-    { NULL,                 NULL,              0}
-};
-
-LUAMOD_API int luaopen_rtos( lua_State *L ) {
-    rotable_newlib(L, reg_rtos);
-    return 1;
-}

+ 0 - 514
tools/java/src/test/resources/input/doc_parse_1.c

@@ -1,514 +0,0 @@
-/*
-@module  socket
-@summary socket操作库
-@version 1.0
-@date    2020.03.30
-*/
-#include "luat_base.h"
-#include "luat_timer.h"
-#include "luat_malloc.h"
-#include "luat_msgbus.h"
-#include "luat_socket.h"
-
-#define LUAT_LOG_TAG "luat.socket"
-#include "luat_log.h"
-
-#define LUAT_NETC_HANDLE "NETC*"
-
-/*
-ntp时间同步
-@function    socket.ntpSync(server)
-@string ntp服务器域名,默认值ntp1.aliyun.com
-@return int 启动成功返回0, 失败返回1或者2
---  如果读取失败,会返回nil
-socket.ntpSync()
-sys.subscribe("NTP_UPDATE", function(re)
-    log.info("ntp", "result", re)
-end)
-*/
-static int socket_ntp_sync(lua_State *L) {
-    const char* hostname = luaL_optstring(L, 1, "ntp1.aliyun.com");
-    int re = luat_socket_ntp_sync(hostname);
-    lua_pushinteger(L, re);
-    return 1;
-}
-
-/*
-直接向地址发送一段数据
-@function    socket.tsend(host, port, data)
-@string 服务器域名或者ip
-@int    服务器端口号
-@string 待发送的数据
-@return nil 无返回值
---  如果读取失败,会返回nil
-socket.tsend("www.baidu.com", 80, "GET / HTTP/1.0\r\n\r\n")
-*/
-static int sal_tls_test(lua_State *L)
-{
-    size_t len;
-    const char* buff = luaL_checklstring(L, 3, &len);
-    luat_socket_tsend(luaL_checkstring(L, 1), luaL_checkinteger(L, 2), (void*)buff, len);
-    return 0;
-}
-
-/*
-网络是否就绪
-@function    socket.isReady()
-@return boolean 已联网返回true,否则返回false
-*/
-static int l_socket_is_ready(lua_State *L) {
-    lua_pushboolean(L, luat_socket_is_ready());
-    return 1;
-}
-
-/*
-获取自身ip,通常是内网ip
-@function    socket.ip()
-@return string 已联网返回ip地址,否则返回nil
-*/
-static int l_socket_selfip(lua_State *L) {
-    uint32_t ip = luat_socket_selfip();
-    if (ip == 0) {
-        return 0;
-    }
-    lua_pushfstring(L, "%d.%d.%d.%d", (ip >> 0) & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF);
-    return 1;
-}
-
-
-#include "netclient.h"
-
-static int luat_lib_netc_msg_handler(lua_State* L, void* ptr) {
-    netc_ent_t* ent = (netc_ent_t*)ptr;
-    if (ent->event == NETC_EVENT_END) {
-        lua_getglobal(L, "sys_pub");
-        if (lua_isfunction(L, -1)) {
-            char buff[32] = {0};
-            sprintf(buff, "NETC_END_%x", ent->netc_id);
-            //LLOGD("FUCK [%s]", buff);
-            lua_pushstring(L, buff);
-            lua_call(L, 1, 0);
-        }
-        goto exit;
-    }
-    LLOGD("luat_lib_netc_msg_handler event=%ld lua_ref=%ld", ent->event, ent->lua_ref);
-    if (ent->lua_ref == 0) {
-        goto exit;
-    }
-    if (lua_rawgeti(L, LUA_REGISTRYINDEX, ent->lua_ref) != LUA_TFUNCTION) {
-        LLOGW("netc[%ld] callback isn't a function", ent->netc_id);
-        goto exit;
-    };
-    lua_pushinteger(L, ent->netc_id);
-    switch (ent->event)
-    {
-    case NETC_EVENT_CONNECT_OK:
-        lua_pushinteger(L, 1);
-        lua_call(L, 2, 0);
-        break;
-    case NETC_EVENT_CONNECT_FAIL:
-        lua_pushinteger(L, 0);
-        lua_call(L, 2, 0);
-        break;
-    //case NETC_EVENT_CLOSE:
-    //    lua_call(L, 1, 0);
-    //    break;
-    case NETC_EVENT_RECV:
-        lua_pushlstring(L, ent->buff, ent->len);
-        //lua_pushliteral(L, "");
-        lua_call(L, 2, 0);
-        break;
-    case NETC_EVENT_ERROR:
-        lua_call(L, 1, 0);
-        break;
-    default:
-        break;
-    }
-exit:
-    if (ent->buff) {
-        luat_heap_free((void*)ent->buff);
-    }
-    luat_heap_free((void*)ent);
-    return 0;
-}
-
-static int luat_lib_socket_new(lua_State* L, int netc_type);
-static int luat_lib_socket_ent_handler(netc_ent_t* ent) {
-    if (ent->event != NETC_EVENT_END && ent->lua_ref == 0) {
-        if (ent->buff) {
-            luat_heap_free((void*)ent->buff);
-        }
-        luat_heap_free((void*)ent);
-        return 0;
-    }
-    rtos_msg_t msg;
-    msg.handler = luat_lib_netc_msg_handler;
-    msg.ptr = ent;
-    luat_msgbus_put(&msg, 1);
-    return 0;
-}
-//----------------------------------------------------------------
-/*
-新建一个tcp socket
-@function    socket.tcp()
-@return object socket对象,如果创建失败会返回nil
---  如果读取失败,会返回nil
-local so = socket.tcp()
-if so then
-    so:host("www.baidu.com")
-    so:port(80)
-    so:on("connect", function(id, re)
-        if re == 1 then
-            so:send("GET / HTTP/1.0\r\n\r\n")
-        end
-    end)
-    so:on("recv", function(id, data)
-        log.info("netc", id, data)
-    end)
-    if so:start() == 1 then
-        sys.waitUntil("NETC_END_" .. so:id())
-    end
-    so:close()
-    so:clean()
-end
-*/
-static int luat_lib_socket_tcp(lua_State* L) {
-    return luat_lib_socket_new(L, NETC_TYPE_TCP);
-}
-/*
-新建一个udp socket
-@function    socket.udp()
-@return nil 暂不支持
-*/
-static int luat_lib_socket_udp(lua_State* L) {
-    return luat_lib_socket_new(L, NETC_TYPE_UDP);
-}
-//-----------------------------------------------------------------
-static int luat_lib_socket_new(lua_State* L, int netc_type) {
-    netclient_t* thiz;
-    //size_t len;
-
-    // 强制GC一次
-    //LOG_D("force execute FULL GC");
-    //lua_gc(L, LUA_GCCOLLECT, 0);
-
-    // 生成netc结构体
-    //LOG_D("init netclient ...");
-    thiz = (netclient_t*)lua_newuserdata(L, sizeof(netclient_t));
-    if (thiz == NULL)
-    {
-        //LOG_W("netclient, fail to create!!!!memory full?!");
-        return 0;
-    }
-
-    memset(thiz, 0, sizeof(netclient_t));
-
-    thiz->sock_fd = -1;
-    thiz->pipe_read_fd = -1;
-    thiz->pipe_write_fd = -1;
-    thiz->rx = luat_lib_socket_ent_handler;
-    thiz->type = netc_type;
-
-    //rt_memset(thiz->hostname, 0, sizeof(thiz->hostname));
-    thiz->hostname[0] = '_';
-    thiz->id = netc_next_no();
-    sprintf(thiz->idStr, "%x", thiz->id);
-
-    luaL_setmetatable(L, LUAT_NETC_HANDLE);
-
-    //LLOGI("netc[%ld] create successd", thiz->id);
-    return 1;
-}
-
-//---------------------------------------------
-#define tonetc(L)	((netclient_t *)luaL_checkudata(L, 1, LUAT_NETC_HANDLE))
-
-/*
-启动socket线程
-@function    so:start(host, port)
-@string 服务器域名或ip,如果已经使用so:host和so:port配置,就不需要传参数了
-@port 服务器端口,如果已经使用so:host和so:port配置,就不需要传参数了
-@return int 成功返回1,失败返回0
--- 参考socket.tcp的说明, 并查阅demo
-*/
-static int netc_connect(lua_State *L) {
-    netclient_t* thiz;
-    size_t len;
-    //uint32_t port;
-    int re;
-    thiz = tonetc(L);
-    if (lua_gettop(L) < 2) {
-        if (thiz->hostname[1] != 0x00 && thiz->port > 0) {
-            // ok
-        }
-        else {
-            //LLOGW("sock:connect require 2 args! top=%d", lua_gettop(L));
-            lua_pushinteger(L, 2);
-            return 1;
-        }
-    }
-    else {
-        const char* hostname = luaL_checklstring(L, 2, &len);
-        if (len >= 32) {
-            //LLOGE("netc[%ld] hostname is too long >= 32", thiz->id);
-            lua_pushinteger(L, 1);
-            return 1;
-        }
-        memcpy(thiz->hostname, hostname, len);
-        thiz->hostname[len] = 0x00;
-        thiz->port = luaL_optinteger(L, 3, 80);
-    }
-    thiz->rx = luat_lib_socket_ent_handler;
-    //LLOGI("netc[%ld] host=%s port=%d type=%s", thiz->id, thiz->hostname, thiz->port, thiz->type == NETC_TYPE_TCP ? "TCP" : "UDP");
-    re = netclient_start(thiz);
-    lua_pushinteger(L, re);
-    return 1;
-}
-
-/*
-关闭socket对象
-@function    so:close()
-@return nil 总会成功
--- 参考socket.tcp的说明, 并查阅demo
-*/
-static int netc_close(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    if (netc->closed == 0) {
-        netclient_close(netc);
-    }
-    return 0;
-}
-
-/*
-通过socket对象发送数据
-@function    so:send(data)
-@string 待发送数据
-@return boolean 发送成功返回true,否则返回false
--- 参考socket.tcp的说明, 并查阅demo
-*/
-static int netc_send(lua_State *L) {
-    size_t len = 0;
-    
-    netclient_t *netc;
-    netc = tonetc(L);
-    const char* data = luaL_checklstring(L, 2, &len);
-    if (len > 0) {
-        int32_t re = netclient_send(netc, (void*)data, len);
-        lua_pushboolean(L, re == len ? 1 : 0);
-    }
-    else {
-        lua_pushboolean(L, 0);
-    }
-    return 1;
-}
-
-static int netc_gc(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    LLOGI("netc[%ld] __gc trigger", netc->id);
-    netclient_close(netc);
-    if (netc->cb_error) {
-        luaL_unref(L, LUA_REGISTRYINDEX, netc->cb_error);
-    }
-    if (netc->cb_recv) {
-        luaL_unref(L, LUA_REGISTRYINDEX, netc->cb_recv);
-    }
-    if (netc->cb_close) {
-        luaL_unref(L, LUA_REGISTRYINDEX, netc->cb_close);
-    }
-    if (netc->cb_connect) {
-        luaL_unref(L, LUA_REGISTRYINDEX, netc->cb_connect);
-    }
-    return 0;
-}
-
-
-static int netc_tostring(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    lua_pushfstring(L, "netc[%d] %s,%d,%s %s", netc->id,
-                                            netc->hostname, netc->port, 
-                                            netc->type == NETC_TYPE_TCP ? "TCP" : "UDP", 
-                                            netc->closed ? "Closed" : "Not-Closed");
-    return 1;
-}
-
-/*
-获取socket对象的id
-@function    so:id()
-@return string 对象id,全局唯一
--- 参考socket.tcp的说明, 并查阅demo
-*/
-static int netc_id(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    lua_pushstring(L, netc->idStr);
-    return 1;
-}
-
-/*
-设置服务器域名或ip
-@function    so:host(host)
-@string 服务器域名或ip
-@return nil 无返回值
--- 参考socket.tcp的说明, 并查阅demo
-*/
-static int netc_host(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    if (lua_gettop(L) > 1 && lua_isstring(L, 2)) {
-        size_t len = 0;
-        const char* hostname = luaL_checklstring(L, 2, &len);
-        if (len >= 64) {
-            LLOGE("hostname is too long!!!!!");
-            lua_pushinteger(L, 1);
-            return 1;
-        }
-        else if (len == 0) {
-            LLOGE("hostname is emtry!!!!!");
-            lua_pushinteger(L, 1);
-            return 1;
-        }
-        memcpy(netc->hostname, hostname, len);
-        netc->hostname[len] = 0x00;
-    }
-    lua_pushstring(L, netc->hostname);
-    return 1;
-}
-
-/*
-设置服务器端口
-@function    so:port(port)
-@int 服务器端口
-@return nil 无返回值
--- 参考socket.tcp的说明, 并查阅demo
-*/
-static int netc_port(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    if (lua_gettop(L) > 1 && lua_isinteger(L, 2)) {
-        netc->port = lua_tointeger(L, 2);
-        //LLOGI("netc[%ld] port=%d", netc->id, netc->port);
-    }
-    lua_pushinteger(L, netc->port);
-    return 1;
-}
-
-/*
-清理socket关联的资源,socket对象在废弃前必须调用
-@function    so:clean(0)
-@return nil 无返回值
--- 参考socket.tcp的说明, 并查阅demo
-*/
-static int netc_clean(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    if (!netc->closed) {
-        netc_close(L);
-    }
-    if (netc->cb_error) {
-        //LOG_D("netc[%ld] unref 0x%08X", netc->id, netc->cb_error);
-        luaL_unref(L, LUA_REGISTRYINDEX, netc->cb_error);
-        netc->cb_error = 0;
-    }
-    if (netc->cb_recv) {
-        //LOG_D("netc[%ld] unref 0x%08X", netc->id, netc->cb_recv);
-        luaL_unref(L, LUA_REGISTRYINDEX, netc->cb_recv);
-        netc->cb_recv = 0;
-    }
-    if (netc->cb_close) {
-        //LOG_D("netc[%ld] unref 0x%08X", netc->id, netc->cb_close);
-        luaL_unref(L, LUA_REGISTRYINDEX, netc->cb_close);
-        netc->cb_close = 0;
-    }
-    if (netc->cb_connect) {
-        //LOG_D("netc[%ld] unref 0x%08X", netc->id, netc->cb_connect);
-        luaL_unref(L, LUA_REGISTRYINDEX, netc->cb_connect);
-        netc->cb_connect = 0;
-    }
-    return 0;
-}
-
-/*
-设置socket的事件回调
-@function    so:port(event, func)
-@string 事件名称
-@function 回调方法
-@return nil 无返回值
--- 参考socket.tcp的说明, 并查阅demo
-*/
-static int netc_on(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    if (lua_gettop(L) < 3) {
-        return 0;
-    }
-    if (lua_isstring(L, 2)) {
-        if (lua_isfunction(L, 3)) {
-            const char* ent = lua_tostring(L, 2);
-            lua_pushvalue(L, 3);
-            if (strcmp("recv", ent) == 0) {
-                netc->cb_recv = luaL_ref(L, LUA_REGISTRYINDEX);
-            }
-            else if (strcmp("close", ent) == 0) {
-                netc->cb_close = luaL_ref(L, LUA_REGISTRYINDEX);
-            }
-            else if (strcmp("connect", ent) == 0) {
-                netc->cb_connect = luaL_ref(L, LUA_REGISTRYINDEX);
-            }
-            //else if (strcmp("any", ent) == 0) {
-            //    netc->cb_any = luaL_ref(L, LUA_REGISTRYINDEX);
-            //}
-            else if (strcmp("error", ent) == 0) {
-                netc->cb_error = luaL_ref(L, LUA_REGISTRYINDEX);
-            }
-            else {
-                //LLOGI("netc[%ld] unkown event type=%s", netc->id, ent);
-            }
-        }
-    }
-    return 0;
-}
-
-static int netc_closed(lua_State *L) {
-    netclient_t *netc = tonetc(L);
-    lua_pushinteger(L, netc->closed);
-    return 1;
-}
-
-static const luaL_Reg lib_netc[] = {
-    {"id",          netc_id},
-    {"host",        netc_host},
-    {"port",        netc_port},
-    {"connect",     netc_connect},
-    {"start",       netc_connect},
-    {"close",       netc_close},
-    {"closed",      netc_closed},
-    {"send",        netc_send},
-    {"clean",       netc_clean},
-    {"on",          netc_on},
-    {"__gc",        netc_gc},
-    {"__tostring",  netc_tostring},
-    {NULL, NULL}
-};
-
-
-static void createmeta (lua_State *L) {
-  luaL_newmetatable(L, LUAT_NETC_HANDLE);  /* create metatable for file handles */
-  lua_pushvalue(L, -1);  /* push metatable */
-  lua_setfield(L, -2, "__index");  /* metatable.__index = metatable */
-  luaL_setfuncs(L, lib_netc, 0);  /* add file methods to new metatable */
-  lua_pop(L, 1);  /* pop new metatable */
-}
-
-
-#include "rotable.h"
-static const rotable_Reg reg_socket[] =
-{
-    { "tcp", luat_lib_socket_tcp, 0},
-    { "udp", luat_lib_socket_udp, 0},
-    { "tsend" ,  sal_tls_test , 0},
-    { "ntpSync", socket_ntp_sync, 0}, // TODO 改成平台无关的UDP实现?
-    { "isReady", l_socket_is_ready, 0},
-    { "ip", l_socket_selfip, 0},
-	{ NULL, NULL , 0}
-};
-
-LUAMOD_API int luaopen_socket( lua_State *L ) {
-    rotable_newlib(L, reg_socket);
-    createmeta(L);
-    return 1;
-}

+ 0 - 4
tools/java/src/test/resources/input/head_0.txt

@@ -1,4 +0,0 @@
-@module  rtos
-@summary RTOS底层操作库
-@version 1.0
-@date    2020.03.30

+ 0 - 9
tools/java/src/test/resources/input/lua_cmt_fn_0.txt

@@ -1,9 +0,0 @@
-ntp时间同步
-@function    socket.ntpSync(server)
-@string ntp服务器域名,默认值ntp1.aliyun.com
-@return int 启动成功返回0, 失败返回1或者2
---  如果读取失败,会返回nil
-socket.ntpSync()
-sys.subscribe("NTP_UPDATE", function(re)
-    log.info("ntp", "result", re)
-end)

+ 0 - 10
tools/java/src/test/resources/input/lua_cmt_fn_1.txt

@@ -1,10 +0,0 @@
-启动一个定时器
-@function    rtos.timer_start(id,timeout,_repeat)   
-@int  定时器id
-@int  超时时长,单位毫秒
-@int  重复次数,默认是0
-@return id 如果是定时器消息,会返回定时器消息id及附加信息, 其他消息由底层决定,不向lua层进行任何保证.
-@usage
--- 用户代码请使用 sys.timerStart
--- 启动一个3秒的循环定时器
-rtos.timer_start(10000, 3000, -1)

+ 0 - 6
tools/java/src/test/resources/input/lua_cmt_fn_2.txt

@@ -1,6 +0,0 @@
-启动socket线程
-@function    so:start(host, port)
-@string 服务器域名或ip,如果已经使用so:host和so:port配置,就不需要传参数了
-@port 服务器端口,如果已经使用so:host和so:port配置,就不需要传参数了
-@return int 成功返回1,失败返回0
--- 参考socket.tcp的说明, 并查阅demo