erlang自定义二进制协议
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1853 行
37 KiB

  1. function test()
  2. local tb = {}
  3. tb.msgId =1
  4. t.aa = ""
  5. tb.encode = function(byteArray)
  6. byteArray.write_string(tb.aa)
  7. return byteArray
  8. end
  9. tb.decode = function(byteArray)
  10. tb.aa = byteArray.read_string()
  11. end
  12. tb.build = function(byteArray)
  13. byteArray.write_uint16(1)
  14. return tb.encode(byteArray)
  15. end
  16. return tb
  17. end
  18. function phoneNumber()
  19. local tb = {}
  20. tb.msgId =2
  21. t.number = {}
  22. t.type = 0
  23. tb.encode = function(byteArray)
  24. if tb.number and next(tb.number) then
  25. byteArray.write_uint8(1)
  26. tb.number.encode(byteArray)
  27. else
  28. byteArray.write_uint8(0)
  29. end
  30. byteArray.write_int32(tb.type)
  31. return byteArray
  32. end
  33. tb.decode = function(byteArray)
  34. local isNilnumber = byteArray.read_uint8()
  35. if isNilnumber > 0 then
  36. tb.number = test()
  37. tb.number.decode(byteArray)
  38. else
  39. tb.number = {}
  40. end
  41. tb.type = byteArray.read_int32()
  42. end
  43. tb.build = function(byteArray)
  44. byteArray.write_uint16(2)
  45. return tb.encode(byteArray)
  46. end
  47. return tb
  48. end
  49. function person()
  50. local tb = {}
  51. tb.msgId =3
  52. t.name = ""
  53. t.id = 0
  54. t.email = ""
  55. t.phone = {}
  56. tb.encode = function(byteArray)
  57. byteArray.write_string(tb.name)
  58. byteArray.write_int32(tb.id)
  59. byteArray.write_string(tb.email)
  60. byteArray.write_uint16(#(tb.phone))
  61. for k, v in pairs(tb.phone) do
  62. byteArray = v.encode(byteArray)
  63. end
  64. return byteArray
  65. end
  66. tb.decode = function(byteArray)
  67. tb.name = byteArray.read_string()
  68. tb.id = byteArray.read_int32()
  69. tb.email = byteArray.read_string()
  70. local cntOfphone = byteArray.read_uint16()
  71. tb.phone = {}
  72. for i = 1, cntOfphone do
  73. local temp = phoneNumber()
  74. temp.decode(byteArray)
  75. table.insert(tb.phone, temp)
  76. end
  77. end
  78. tb.build = function(byteArray)
  79. byteArray.write_uint16(3)
  80. return tb.encode(byteArray)
  81. end
  82. return tb
  83. end
  84. function addressBook()
  85. local tb = {}
  86. tb.msgId =4
  87. t.person = {}
  88. t.other = {}
  89. tb.encode = function(byteArray)
  90. byteArray.write_uint16(#(tb.person))
  91. for k, v in pairs(tb.person) do
  92. byteArray = v.encode(byteArray)
  93. end
  94. byteArray.write_uint16(#(tb.other))
  95. for k, v in pairs(tb.other) do
  96. byteArray = v.encode(byteArray)
  97. end
  98. return byteArray
  99. end
  100. tb.decode = function(byteArray)
  101. local cntOfperson = byteArray.read_uint16()
  102. tb.person = {}
  103. for i = 1, cntOfperson do
  104. local temp = person()
  105. temp.decode(byteArray)
  106. table.insert(tb.person, temp)
  107. end
  108. local cntOfother = byteArray.read_uint16()
  109. tb.other = {}
  110. for i = 1, cntOfother do
  111. local temp = person()
  112. temp.decode(byteArray)
  113. table.insert(tb.other, temp)
  114. end
  115. end
  116. tb.build = function(byteArray)
  117. byteArray.write_uint16(4)
  118. return tb.encode(byteArray)
  119. end
  120. return tb
  121. end
  122. function union()
  123. local tb = {}
  124. tb.msgId =5
  125. t.test = ""
  126. t.type = 0
  127. tb.encode = function(byteArray)
  128. byteArray.write_string(tb.test)
  129. byteArray.write_int32(tb.type)
  130. return byteArray
  131. end
  132. tb.decode = function(byteArray)
  133. tb.test = byteArray.read_string()
  134. tb.type = byteArray.read_int32()
  135. end
  136. tb.build = function(byteArray)
  137. byteArray.write_uint16(5)
  138. return tb.encode(byteArray)
  139. end
  140. return tb
  141. end
  142. function tbool()
  143. local tb = {}
  144. tb.msgId =6
  145. t.bool = false
  146. tb.encode = function(byteArray)
  147. byteArray.write_bool(tb.bool)
  148. return byteArray
  149. end
  150. tb.decode = function(byteArray)
  151. tb.bool = byteArray.read_bool()
  152. end
  153. tb.build = function(byteArray)
  154. byteArray.write_uint16(6)
  155. return tb.encode(byteArray)
  156. end
  157. return tb
  158. end
  159. function tint8()
  160. local tb = {}
  161. tb.msgId =7
  162. t.int1 = 0
  163. t.int2 = 0
  164. tb.encode = function(byteArray)
  165. byteArray.write_int8(tb.int1)
  166. byteArray.write_int8(tb.int2)
  167. return byteArray
  168. end
  169. tb.decode = function(byteArray)
  170. tb.int1 = byteArray.read_int8()
  171. tb.int2 = byteArray.read_int8()
  172. end
  173. tb.build = function(byteArray)
  174. byteArray.write_uint16(7)
  175. return tb.encode(byteArray)
  176. end
  177. return tb
  178. end
  179. function tuint8()
  180. local tb = {}
  181. tb.msgId =8
  182. t.int1 = 0
  183. t.int2 = 0
  184. tb.encode = function(byteArray)
  185. byteArray.write_uint8(tb.int1)
  186. byteArray.write_uint8(tb.int2)
  187. return byteArray
  188. end
  189. tb.decode = function(byteArray)
  190. tb.int1 = byteArray.read_uint8()
  191. tb.int2 = byteArray.read_uint8()
  192. end
  193. tb.build = function(byteArray)
  194. byteArray.write_uint16(8)
  195. return tb.encode(byteArray)
  196. end
  197. return tb
  198. end
  199. function tint16()
  200. local tb = {}
  201. tb.msgId =9
  202. t.int1 = 0
  203. t.int2 = 0
  204. tb.encode = function(byteArray)
  205. byteArray.write_int16(tb.int1)
  206. byteArray.write_int16(tb.int2)
  207. return byteArray
  208. end
  209. tb.decode = function(byteArray)
  210. tb.int1 = byteArray.read_int16()
  211. tb.int2 = byteArray.read_int16()
  212. end
  213. tb.build = function(byteArray)
  214. byteArray.write_uint16(9)
  215. return tb.encode(byteArray)
  216. end
  217. return tb
  218. end
  219. function tuint16()
  220. local tb = {}
  221. tb.msgId =10
  222. t.int1 = 0
  223. t.int2 = 0
  224. tb.encode = function(byteArray)
  225. byteArray.write_uint16(tb.int1)
  226. byteArray.write_uint16(tb.int2)
  227. return byteArray
  228. end
  229. tb.decode = function(byteArray)
  230. tb.int1 = byteArray.read_uint16()
  231. tb.int2 = byteArray.read_uint16()
  232. end
  233. tb.build = function(byteArray)
  234. byteArray.write_uint16(10)
  235. return tb.encode(byteArray)
  236. end
  237. return tb
  238. end
  239. function tint32()
  240. local tb = {}
  241. tb.msgId =11
  242. t.int1 = 0
  243. t.int2 = 0
  244. t.int3 = 0
  245. t.int4 = 0
  246. t.int5 = 0
  247. t.int6 = 0
  248. t.int7 = 0
  249. t.int8 = 0
  250. t.int9 = 0
  251. t.int10 = 0
  252. tb.encode = function(byteArray)
  253. byteArray.write_int32(tb.int1)
  254. byteArray.write_int32(tb.int2)
  255. byteArray.write_int32(tb.int3)
  256. byteArray.write_int32(tb.int4)
  257. byteArray.write_int32(tb.int5)
  258. byteArray.write_int32(tb.int6)
  259. byteArray.write_int32(tb.int7)
  260. byteArray.write_int32(tb.int8)
  261. byteArray.write_int32(tb.int9)
  262. byteArray.write_int32(tb.int10)
  263. return byteArray
  264. end
  265. tb.decode = function(byteArray)
  266. tb.int1 = byteArray.read_int32()
  267. tb.int2 = byteArray.read_int32()
  268. tb.int3 = byteArray.read_int32()
  269. tb.int4 = byteArray.read_int32()
  270. tb.int5 = byteArray.read_int32()
  271. tb.int6 = byteArray.read_int32()
  272. tb.int7 = byteArray.read_int32()
  273. tb.int8 = byteArray.read_int32()
  274. tb.int9 = byteArray.read_int32()
  275. tb.int10 = byteArray.read_int32()
  276. end
  277. tb.build = function(byteArray)
  278. byteArray.write_uint16(11)
  279. return tb.encode(byteArray)
  280. end
  281. return tb
  282. end
  283. function tuint32()
  284. local tb = {}
  285. tb.msgId =12
  286. t.int1 = 0
  287. t.int2 = 0
  288. tb.encode = function(byteArray)
  289. byteArray.write_uint32(tb.int1)
  290. byteArray.write_uint32(tb.int2)
  291. return byteArray
  292. end
  293. tb.decode = function(byteArray)
  294. tb.int1 = byteArray.read_uint32()
  295. tb.int2 = byteArray.read_uint32()
  296. end
  297. tb.build = function(byteArray)
  298. byteArray.write_uint16(12)
  299. return tb.encode(byteArray)
  300. end
  301. return tb
  302. end
  303. function tint64()
  304. local tb = {}
  305. tb.msgId =13
  306. t.int1 = 0
  307. t.int2 = 0
  308. tb.encode = function(byteArray)
  309. byteArray.write_int64(tb.int1)
  310. byteArray.write_int64(tb.int2)
  311. return byteArray
  312. end
  313. tb.decode = function(byteArray)
  314. tb.int1 = byteArray.read_int64()
  315. tb.int2 = byteArray.read_int64()
  316. end
  317. tb.build = function(byteArray)
  318. byteArray.write_uint16(13)
  319. return tb.encode(byteArray)
  320. end
  321. return tb
  322. end
  323. function tuint64()
  324. local tb = {}
  325. tb.msgId =14
  326. t.int1 = 0
  327. t.int2 = 0
  328. tb.encode = function(byteArray)
  329. byteArray.write_uint64(tb.int1)
  330. byteArray.write_uint64(tb.int2)
  331. return byteArray
  332. end
  333. tb.decode = function(byteArray)
  334. tb.int1 = byteArray.read_uint64()
  335. tb.int2 = byteArray.read_uint64()
  336. end
  337. tb.build = function(byteArray)
  338. byteArray.write_uint16(14)
  339. return tb.encode(byteArray)
  340. end
  341. return tb
  342. end
  343. function tinteger()
  344. local tb = {}
  345. tb.msgId =15
  346. t.int1 = {}
  347. t.int2 = {}
  348. t.int3 = {}
  349. t.int4 = {}
  350. t.int5 = {}
  351. t.int6 = {}
  352. t.int7 = {}
  353. t.int8 = {}
  354. tb.encode = function(byteArray)
  355. if tb.int1 and next(tb.int1) then
  356. byteArray.write_uint8(1)
  357. tb.int1.encode(byteArray)
  358. else
  359. byteArray.write_uint8(0)
  360. end
  361. if tb.int2 and next(tb.int2) then
  362. byteArray.write_uint8(1)
  363. tb.int2.encode(byteArray)
  364. else
  365. byteArray.write_uint8(0)
  366. end
  367. if tb.int3 and next(tb.int3) then
  368. byteArray.write_uint8(1)
  369. tb.int3.encode(byteArray)
  370. else
  371. byteArray.write_uint8(0)
  372. end
  373. if tb.int4 and next(tb.int4) then
  374. byteArray.write_uint8(1)
  375. tb.int4.encode(byteArray)
  376. else
  377. byteArray.write_uint8(0)
  378. end
  379. if tb.int5 and next(tb.int5) then
  380. byteArray.write_uint8(1)
  381. tb.int5.encode(byteArray)
  382. else
  383. byteArray.write_uint8(0)
  384. end
  385. if tb.int6 and next(tb.int6) then
  386. byteArray.write_uint8(1)
  387. tb.int6.encode(byteArray)
  388. else
  389. byteArray.write_uint8(0)
  390. end
  391. if tb.int7 and next(tb.int7) then
  392. byteArray.write_uint8(1)
  393. tb.int7.encode(byteArray)
  394. else
  395. byteArray.write_uint8(0)
  396. end
  397. if tb.int8 and next(tb.int8) then
  398. byteArray.write_uint8(1)
  399. tb.int8.encode(byteArray)
  400. else
  401. byteArray.write_uint8(0)
  402. end
  403. return byteArray
  404. end
  405. tb.decode = function(byteArray)
  406. local isNilint1 = byteArray.read_uint8()
  407. if isNilint1 > 0 then
  408. tb.int1 = integer()
  409. tb.int1.decode(byteArray)
  410. else
  411. tb.int1 = {}
  412. end
  413. local isNilint2 = byteArray.read_uint8()
  414. if isNilint2 > 0 then
  415. tb.int2 = integer()
  416. tb.int2.decode(byteArray)
  417. else
  418. tb.int2 = {}
  419. end
  420. local isNilint3 = byteArray.read_uint8()
  421. if isNilint3 > 0 then
  422. tb.int3 = integer()
  423. tb.int3.decode(byteArray)
  424. else
  425. tb.int3 = {}
  426. end
  427. local isNilint4 = byteArray.read_uint8()
  428. if isNilint4 > 0 then
  429. tb.int4 = integer()
  430. tb.int4.decode(byteArray)
  431. else
  432. tb.int4 = {}
  433. end
  434. local isNilint5 = byteArray.read_uint8()
  435. if isNilint5 > 0 then
  436. tb.int5 = integer()
  437. tb.int5.decode(byteArray)
  438. else
  439. tb.int5 = {}
  440. end
  441. local isNilint6 = byteArray.read_uint8()
  442. if isNilint6 > 0 then
  443. tb.int6 = integer()
  444. tb.int6.decode(byteArray)
  445. else
  446. tb.int6 = {}
  447. end
  448. local isNilint7 = byteArray.read_uint8()
  449. if isNilint7 > 0 then
  450. tb.int7 = integer()
  451. tb.int7.decode(byteArray)
  452. else
  453. tb.int7 = {}
  454. end
  455. local isNilint8 = byteArray.read_uint8()
  456. if isNilint8 > 0 then
  457. tb.int8 = integer()
  458. tb.int8.decode(byteArray)
  459. else
  460. tb.int8 = {}
  461. end
  462. end
  463. tb.build = function(byteArray)
  464. byteArray.write_uint16(15)
  465. return tb.encode(byteArray)
  466. end
  467. return tb
  468. end
  469. function tnumber()
  470. local tb = {}
  471. tb.msgId =16
  472. t.int1 = {}
  473. t.int2 = {}
  474. t.int3 = {}
  475. t.int4 = {}
  476. t.int5 = {}
  477. t.int6 = {}
  478. t.int7 = {}
  479. t.int8 = {}
  480. t.float1 = {}
  481. t.float2 = {}
  482. tb.encode = function(byteArray)
  483. if tb.int1 and next(tb.int1) then
  484. byteArray.write_uint8(1)
  485. tb.int1.encode(byteArray)
  486. else
  487. byteArray.write_uint8(0)
  488. end
  489. if tb.int2 and next(tb.int2) then
  490. byteArray.write_uint8(1)
  491. tb.int2.encode(byteArray)
  492. else
  493. byteArray.write_uint8(0)
  494. end
  495. if tb.int3 and next(tb.int3) then
  496. byteArray.write_uint8(1)
  497. tb.int3.encode(byteArray)
  498. else
  499. byteArray.write_uint8(0)
  500. end
  501. if tb.int4 and next(tb.int4) then
  502. byteArray.write_uint8(1)
  503. tb.int4.encode(byteArray)
  504. else
  505. byteArray.write_uint8(0)
  506. end
  507. if tb.int5 and next(tb.int5) then
  508. byteArray.write_uint8(1)
  509. tb.int5.encode(byteArray)
  510. else
  511. byteArray.write_uint8(0)
  512. end
  513. if tb.int6 and next(tb.int6) then
  514. byteArray.write_uint8(1)
  515. tb.int6.encode(byteArray)
  516. else
  517. byteArray.write_uint8(0)
  518. end
  519. if tb.int7 and next(tb.int7) then
  520. byteArray.write_uint8(1)
  521. tb.int7.encode(byteArray)
  522. else
  523. byteArray.write_uint8(0)
  524. end
  525. if tb.int8 and next(tb.int8) then
  526. byteArray.write_uint8(1)
  527. tb.int8.encode(byteArray)
  528. else
  529. byteArray.write_uint8(0)
  530. end
  531. if tb.float1 and next(tb.float1) then
  532. byteArray.write_uint8(1)
  533. tb.float1.encode(byteArray)
  534. else
  535. byteArray.write_uint8(0)
  536. end
  537. if tb.float2 and next(tb.float2) then
  538. byteArray.write_uint8(1)
  539. tb.float2.encode(byteArray)
  540. else
  541. byteArray.write_uint8(0)
  542. end
  543. return byteArray
  544. end
  545. tb.decode = function(byteArray)
  546. local isNilint1 = byteArray.read_uint8()
  547. if isNilint1 > 0 then
  548. tb.int1 = number()
  549. tb.int1.decode(byteArray)
  550. else
  551. tb.int1 = {}
  552. end
  553. local isNilint2 = byteArray.read_uint8()
  554. if isNilint2 > 0 then
  555. tb.int2 = number()
  556. tb.int2.decode(byteArray)
  557. else
  558. tb.int2 = {}
  559. end
  560. local isNilint3 = byteArray.read_uint8()
  561. if isNilint3 > 0 then
  562. tb.int3 = number()
  563. tb.int3.decode(byteArray)
  564. else
  565. tb.int3 = {}
  566. end
  567. local isNilint4 = byteArray.read_uint8()
  568. if isNilint4 > 0 then
  569. tb.int4 = number()
  570. tb.int4.decode(byteArray)
  571. else
  572. tb.int4 = {}
  573. end
  574. local isNilint5 = byteArray.read_uint8()
  575. if isNilint5 > 0 then
  576. tb.int5 = number()
  577. tb.int5.decode(byteArray)
  578. else
  579. tb.int5 = {}
  580. end
  581. local isNilint6 = byteArray.read_uint8()
  582. if isNilint6 > 0 then
  583. tb.int6 = number()
  584. tb.int6.decode(byteArray)
  585. else
  586. tb.int6 = {}
  587. end
  588. local isNilint7 = byteArray.read_uint8()
  589. if isNilint7 > 0 then
  590. tb.int7 = number()
  591. tb.int7.decode(byteArray)
  592. else
  593. tb.int7 = {}
  594. end
  595. local isNilint8 = byteArray.read_uint8()
  596. if isNilint8 > 0 then
  597. tb.int8 = number()
  598. tb.int8.decode(byteArray)
  599. else
  600. tb.int8 = {}
  601. end
  602. local isNilfloat1 = byteArray.read_uint8()
  603. if isNilfloat1 > 0 then
  604. tb.float1 = number()
  605. tb.float1.decode(byteArray)
  606. else
  607. tb.float1 = {}
  608. end
  609. local isNilfloat2 = byteArray.read_uint8()
  610. if isNilfloat2 > 0 then
  611. tb.float2 = number()
  612. tb.float2.decode(byteArray)
  613. else
  614. tb.float2 = {}
  615. end
  616. end
  617. tb.build = function(byteArray)
  618. byteArray.write_uint16(16)
  619. return tb.encode(byteArray)
  620. end
  621. return tb
  622. end
  623. function tfloat()
  624. local tb = {}
  625. tb.msgId =17
  626. t.int1 = 0
  627. t.int2 = 0
  628. tb.encode = function(byteArray)
  629. byteArray.write_float(tb.int1)
  630. byteArray.write_float(tb.int2)
  631. return byteArray
  632. end
  633. tb.decode = function(byteArray)
  634. tb.int1 = byteArray.read_float()
  635. tb.int2 = byteArray.read_float()
  636. end
  637. tb.build = function(byteArray)
  638. byteArray.write_uint16(17)
  639. return tb.encode(byteArray)
  640. end
  641. return tb
  642. end
  643. function tdouble()
  644. local tb = {}
  645. tb.msgId =18
  646. t.int1 = 0
  647. t.int2 = 0
  648. tb.encode = function(byteArray)
  649. byteArray.write_double(tb.int1)
  650. byteArray.write_double(tb.int2)
  651. return byteArray
  652. end
  653. tb.decode = function(byteArray)
  654. tb.int1 = byteArray.read_double()
  655. tb.int2 = byteArray.read_double()
  656. end
  657. tb.build = function(byteArray)
  658. byteArray.write_uint16(18)
  659. return tb.encode(byteArray)
  660. end
  661. return tb
  662. end
  663. function tstring()
  664. local tb = {}
  665. tb.msgId =19
  666. t.int1 = ""
  667. t.int2 = ""
  668. tb.encode = function(byteArray)
  669. byteArray.write_string(tb.int1)
  670. byteArray.write_string(tb.int2)
  671. return byteArray
  672. end
  673. tb.decode = function(byteArray)
  674. tb.int1 = byteArray.read_string()
  675. tb.int2 = byteArray.read_string()
  676. end
  677. tb.build = function(byteArray)
  678. byteArray.write_uint16(19)
  679. return tb.encode(byteArray)
  680. end
  681. return tb
  682. end
  683. function tlistbool()
  684. local tb = {}
  685. tb.msgId =20
  686. t.int1 = {}
  687. tb.encode = function(byteArray)
  688. byteArray.write_uint16(#(tb.int1))
  689. for k, v in pairs (tb.int1) do
  690. byteArray.write_bool(v)
  691. end
  692. return byteArray
  693. end
  694. tb.decode = function(byteArray)
  695. local cntOfint1 = byteArray.read_uint16()
  696. tb.int1 = {}
  697. for i = 1, cntOfint1 do
  698. table.insert(tb.int1, byteArray.read_bool())
  699. end
  700. end
  701. tb.build = function(byteArray)
  702. byteArray.write_uint16(20)
  703. return tb.encode(byteArray)
  704. end
  705. return tb
  706. end
  707. function tlistint8()
  708. local tb = {}
  709. tb.msgId =21
  710. t.int1 = {}
  711. tb.encode = function(byteArray)
  712. byteArray.write_uint16(#(tb.int1))
  713. for k, v in pairs (tb.int1) do
  714. byteArray.write_int8(v)
  715. end
  716. return byteArray
  717. end
  718. tb.decode = function(byteArray)
  719. local cntOfint1 = byteArray.read_uint16()
  720. tb.int1 = {}
  721. for i = 1, cntOfint1 do
  722. table.insert(tb.int1, byteArray.read_int8())
  723. end
  724. end
  725. tb.build = function(byteArray)
  726. byteArray.write_uint16(21)
  727. return tb.encode(byteArray)
  728. end
  729. return tb
  730. end
  731. function tlistuint8()
  732. local tb = {}
  733. tb.msgId =22
  734. t.int1 = {}
  735. tb.encode = function(byteArray)
  736. byteArray.write_uint16(#(tb.int1))
  737. for k, v in pairs (tb.int1) do
  738. byteArray.write_uint8(v)
  739. end
  740. return byteArray
  741. end
  742. tb.decode = function(byteArray)
  743. local cntOfint1 = byteArray.read_uint16()
  744. tb.int1 = {}
  745. for i = 1, cntOfint1 do
  746. table.insert(tb.int1, byteArray.read_uint8())
  747. end
  748. end
  749. tb.build = function(byteArray)
  750. byteArray.write_uint16(22)
  751. return tb.encode(byteArray)
  752. end
  753. return tb
  754. end
  755. function tlistint16()
  756. local tb = {}
  757. tb.msgId =23
  758. t.int1 = {}
  759. tb.encode = function(byteArray)
  760. byteArray.write_uint16(#(tb.int1))
  761. for k, v in pairs (tb.int1) do
  762. byteArray.write_int16(v)
  763. end
  764. return byteArray
  765. end
  766. tb.decode = function(byteArray)
  767. local cntOfint1 = byteArray.read_uint16()
  768. tb.int1 = {}
  769. for i = 1, cntOfint1 do
  770. table.insert(tb.int1, byteArray.read_int16())
  771. end
  772. end
  773. tb.build = function(byteArray)
  774. byteArray.write_uint16(23)
  775. return tb.encode(byteArray)
  776. end
  777. return tb
  778. end
  779. function tlistuint16()
  780. local tb = {}
  781. tb.msgId =24
  782. t.int1 = {}
  783. tb.encode = function(byteArray)
  784. byteArray.write_uint16(#(tb.int1))
  785. for k, v in pairs (tb.int1) do
  786. byteArray.write_uint16(v)
  787. end
  788. return byteArray
  789. end
  790. tb.decode = function(byteArray)
  791. local cntOfint1 = byteArray.read_uint16()
  792. tb.int1 = {}
  793. for i = 1, cntOfint1 do
  794. table.insert(tb.int1, byteArray.read_uint16())
  795. end
  796. end
  797. tb.build = function(byteArray)
  798. byteArray.write_uint16(24)
  799. return tb.encode(byteArray)
  800. end
  801. return tb
  802. end
  803. function tlistint32()
  804. local tb = {}
  805. tb.msgId =25
  806. t.int1 = {}
  807. tb.encode = function(byteArray)
  808. byteArray.write_uint16(#(tb.int1))
  809. for k, v in pairs (tb.int1) do
  810. byteArray.write_int32(v)
  811. end
  812. return byteArray
  813. end
  814. tb.decode = function(byteArray)
  815. local cntOfint1 = byteArray.read_uint16()
  816. tb.int1 = {}
  817. for i = 1, cntOfint1 do
  818. table.insert(tb.int1, byteArray.read_int32())
  819. end
  820. end
  821. tb.build = function(byteArray)
  822. byteArray.write_uint16(25)
  823. return tb.encode(byteArray)
  824. end
  825. return tb
  826. end
  827. function tlistuint32()
  828. local tb = {}
  829. tb.msgId =26
  830. t.int1 = {}
  831. tb.encode = function(byteArray)
  832. byteArray.write_uint16(#(tb.int1))
  833. for k, v in pairs (tb.int1) do
  834. byteArray.write_uint32(v)
  835. end
  836. return byteArray
  837. end
  838. tb.decode = function(byteArray)
  839. local cntOfint1 = byteArray.read_uint16()
  840. tb.int1 = {}
  841. for i = 1, cntOfint1 do
  842. table.insert(tb.int1, byteArray.read_uint32())
  843. end
  844. end
  845. tb.build = function(byteArray)
  846. byteArray.write_uint16(26)
  847. return tb.encode(byteArray)
  848. end
  849. return tb
  850. end
  851. function tlistint64()
  852. local tb = {}
  853. tb.msgId =27
  854. t.int1 = {}
  855. tb.encode = function(byteArray)
  856. byteArray.write_uint16(#(tb.int1))
  857. for k, v in pairs (tb.int1) do
  858. byteArray.write_int64(v)
  859. end
  860. return byteArray
  861. end
  862. tb.decode = function(byteArray)
  863. local cntOfint1 = byteArray.read_uint16()
  864. tb.int1 = {}
  865. for i = 1, cntOfint1 do
  866. table.insert(tb.int1, byteArray.read_int64())
  867. end
  868. end
  869. tb.build = function(byteArray)
  870. byteArray.write_uint16(27)
  871. return tb.encode(byteArray)
  872. end
  873. return tb
  874. end
  875. function tlistuint64()
  876. local tb = {}
  877. tb.msgId =28
  878. t.int1 = {}
  879. tb.encode = function(byteArray)
  880. byteArray.write_uint16(#(tb.int1))
  881. for k, v in pairs (tb.int1) do
  882. byteArray.write_uint64(v)
  883. end
  884. return byteArray
  885. end
  886. tb.decode = function(byteArray)
  887. local cntOfint1 = byteArray.read_uint16()
  888. tb.int1 = {}
  889. for i = 1, cntOfint1 do
  890. table.insert(tb.int1, byteArray.read_uint64())
  891. end
  892. end
  893. tb.build = function(byteArray)
  894. byteArray.write_uint16(28)
  895. return tb.encode(byteArray)
  896. end
  897. return tb
  898. end
  899. function tlistinteger()
  900. local tb = {}
  901. tb.msgId =29
  902. t.int1 = {}
  903. tb.encode = function(byteArray)
  904. byteArray.write_uint16(#(tb.int1))
  905. for k, v in pairs(tb.int1) do
  906. byteArray = v.encode(byteArray)
  907. end
  908. return byteArray
  909. end
  910. tb.decode = function(byteArray)
  911. local cntOfint1 = byteArray.read_uint16()
  912. tb.int1 = {}
  913. for i = 1, cntOfint1 do
  914. local temp = integer()
  915. temp.decode(byteArray)
  916. table.insert(tb.int1, temp)
  917. end
  918. end
  919. tb.build = function(byteArray)
  920. byteArray.write_uint16(29)
  921. return tb.encode(byteArray)
  922. end
  923. return tb
  924. end
  925. function tlistnumber()
  926. local tb = {}
  927. tb.msgId =30
  928. t.int1 = {}
  929. tb.encode = function(byteArray)
  930. byteArray.write_uint16(#(tb.int1))
  931. for k, v in pairs(tb.int1) do
  932. byteArray = v.encode(byteArray)
  933. end
  934. return byteArray
  935. end
  936. tb.decode = function(byteArray)
  937. local cntOfint1 = byteArray.read_uint16()
  938. tb.int1 = {}
  939. for i = 1, cntOfint1 do
  940. local temp = number()
  941. temp.decode(byteArray)
  942. table.insert(tb.int1, temp)
  943. end
  944. end
  945. tb.build = function(byteArray)
  946. byteArray.write_uint16(30)
  947. return tb.encode(byteArray)
  948. end
  949. return tb
  950. end
  951. function tlistfloat()
  952. local tb = {}
  953. tb.msgId =31
  954. t.int1 = {}
  955. tb.encode = function(byteArray)
  956. byteArray.write_uint16(#(tb.int1))
  957. for k, v in pairs (tb.int1) do
  958. byteArray.write_float(v)
  959. end
  960. return byteArray
  961. end
  962. tb.decode = function(byteArray)
  963. local cntOfint1 = byteArray.read_uint16()
  964. tb.int1 = {}
  965. for i = 1, cntOfint1 do
  966. table.insert(tb.int1, byteArray.read_float())
  967. end
  968. end
  969. tb.build = function(byteArray)
  970. byteArray.write_uint16(31)
  971. return tb.encode(byteArray)
  972. end
  973. return tb
  974. end
  975. function tlistdouble()
  976. local tb = {}
  977. tb.msgId =32
  978. t.int1 = {}
  979. tb.encode = function(byteArray)
  980. byteArray.write_uint16(#(tb.int1))
  981. for k, v in pairs (tb.int1) do
  982. byteArray.write_double(v)
  983. end
  984. return byteArray
  985. end
  986. tb.decode = function(byteArray)
  987. local cntOfint1 = byteArray.read_uint16()
  988. tb.int1 = {}
  989. for i = 1, cntOfint1 do
  990. table.insert(tb.int1, byteArray.read_double())
  991. end
  992. end
  993. tb.build = function(byteArray)
  994. byteArray.write_uint16(32)
  995. return tb.encode(byteArray)
  996. end
  997. return tb
  998. end
  999. function tliststring()
  1000. local tb = {}
  1001. tb.msgId =33
  1002. t.int1 = {}
  1003. tb.encode = function(byteArray)
  1004. byteArray.write_uint16(#(tb.int1))
  1005. for k, v in pairs (tb.int1) do
  1006. byteArray.write_string(v)
  1007. end
  1008. return byteArray
  1009. end
  1010. tb.decode = function(byteArray)
  1011. local cntOfint1 = byteArray.read_uint16()
  1012. tb.int1 = {}
  1013. for i = 1, cntOfint1 do
  1014. table.insert(tb.int1, byteArray.read_string())
  1015. end
  1016. end
  1017. tb.build = function(byteArray)
  1018. byteArray.write_uint16(33)
  1019. return tb.encode(byteArray)
  1020. end
  1021. return tb
  1022. end
  1023. function tlistunion()
  1024. local tb = {}
  1025. tb.msgId =34
  1026. t.int1 = {}
  1027. tb.encode = function(byteArray)
  1028. byteArray.write_uint16(#(tb.int1))
  1029. for k, v in pairs(tb.int1) do
  1030. byteArray = v.encode(byteArray)
  1031. end
  1032. return byteArray
  1033. end
  1034. tb.decode = function(byteArray)
  1035. local cntOfint1 = byteArray.read_uint16()
  1036. tb.int1 = {}
  1037. for i = 1, cntOfint1 do
  1038. local temp = union()
  1039. temp.decode(byteArray)
  1040. table.insert(tb.int1, temp)
  1041. end
  1042. end
  1043. tb.build = function(byteArray)
  1044. byteArray.write_uint16(34)
  1045. return tb.encode(byteArray)
  1046. end
  1047. return tb
  1048. end
  1049. function allType()
  1050. local tb = {}
  1051. tb.msgId =35
  1052. t.bool = false
  1053. t.int8 = 0
  1054. t.uint8 = 0
  1055. t.int16 = 0
  1056. t.uint16 = 0
  1057. t.int32 = 0
  1058. t.uint32 = 0
  1059. t.int64 = 0
  1060. t.uint64 = 0
  1061. t.inte8 = {}
  1062. t.uinte8 = {}
  1063. t.inte16 = {}
  1064. t.uinte16 = {}
  1065. t.inte32 = {}
  1066. t.uinte32 = {}
  1067. t.inte64 = {}
  1068. t.uinte64 = {}
  1069. t.num8 = {}
  1070. t.unum8 = {}
  1071. t.num16 = {}
  1072. t.unum16 = {}
  1073. t.num32 = {}
  1074. t.unum32 = {}
  1075. t.num64 = {}
  1076. t.unum64 = {}
  1077. t.numfloat = {}
  1078. t.numdouble = {}
  1079. t.float = 0
  1080. t.double = 0
  1081. t.string1 = ""
  1082. t.string2 = ""
  1083. t.union = {}
  1084. t.lbool = {}
  1085. t.lint8 = {}
  1086. t.luint8 = {}
  1087. t.lint16 = {}
  1088. t.luint16 = {}
  1089. t.lint32 = {}
  1090. t.luint32 = {}
  1091. t.lint64 = {}
  1092. t.luint64 = {}
  1093. t.linte8 = {}
  1094. t.linte16 = {}
  1095. t.linte32 = {}
  1096. t.linte64 = {}
  1097. t.lnum8 = {}
  1098. t.lnum16 = {}
  1099. t.lnum32 = {}
  1100. t.lnum64 = {}
  1101. t.lnfloat32 = {}
  1102. t.lnfloat64 = {}
  1103. t.lfloat = {}
  1104. t.ldouble = {}
  1105. t.lstring = {}
  1106. t.lunion = {}
  1107. tb.encode = function(byteArray)
  1108. byteArray.write_bool(tb.bool)
  1109. byteArray.write_int8(tb.int8)
  1110. byteArray.write_uint8(tb.uint8)
  1111. byteArray.write_int16(tb.int16)
  1112. byteArray.write_uint16(tb.uint16)
  1113. byteArray.write_int32(tb.int32)
  1114. byteArray.write_uint32(tb.uint32)
  1115. byteArray.write_int64(tb.int64)
  1116. byteArray.write_uint64(tb.uint64)
  1117. if tb.inte8 and next(tb.inte8) then
  1118. byteArray.write_uint8(1)
  1119. tb.inte8.encode(byteArray)
  1120. else
  1121. byteArray.write_uint8(0)
  1122. end
  1123. if tb.uinte8 and next(tb.uinte8) then
  1124. byteArray.write_uint8(1)
  1125. tb.uinte8.encode(byteArray)
  1126. else
  1127. byteArray.write_uint8(0)
  1128. end
  1129. if tb.inte16 and next(tb.inte16) then
  1130. byteArray.write_uint8(1)
  1131. tb.inte16.encode(byteArray)
  1132. else
  1133. byteArray.write_uint8(0)
  1134. end
  1135. if tb.uinte16 and next(tb.uinte16) then
  1136. byteArray.write_uint8(1)
  1137. tb.uinte16.encode(byteArray)
  1138. else
  1139. byteArray.write_uint8(0)
  1140. end
  1141. if tb.inte32 and next(tb.inte32) then
  1142. byteArray.write_uint8(1)
  1143. tb.inte32.encode(byteArray)
  1144. else
  1145. byteArray.write_uint8(0)
  1146. end
  1147. if tb.uinte32 and next(tb.uinte32) then
  1148. byteArray.write_uint8(1)
  1149. tb.uinte32.encode(byteArray)
  1150. else
  1151. byteArray.write_uint8(0)
  1152. end
  1153. if tb.inte64 and next(tb.inte64) then
  1154. byteArray.write_uint8(1)
  1155. tb.inte64.encode(byteArray)
  1156. else
  1157. byteArray.write_uint8(0)
  1158. end
  1159. if tb.uinte64 and next(tb.uinte64) then
  1160. byteArray.write_uint8(1)
  1161. tb.uinte64.encode(byteArray)
  1162. else
  1163. byteArray.write_uint8(0)
  1164. end
  1165. if tb.num8 and next(tb.num8) then
  1166. byteArray.write_uint8(1)
  1167. tb.num8.encode(byteArray)
  1168. else
  1169. byteArray.write_uint8(0)
  1170. end
  1171. if tb.unum8 and next(tb.unum8) then
  1172. byteArray.write_uint8(1)
  1173. tb.unum8.encode(byteArray)
  1174. else
  1175. byteArray.write_uint8(0)
  1176. end
  1177. if tb.num16 and next(tb.num16) then
  1178. byteArray.write_uint8(1)
  1179. tb.num16.encode(byteArray)
  1180. else
  1181. byteArray.write_uint8(0)
  1182. end
  1183. if tb.unum16 and next(tb.unum16) then
  1184. byteArray.write_uint8(1)
  1185. tb.unum16.encode(byteArray)
  1186. else
  1187. byteArray.write_uint8(0)
  1188. end
  1189. if tb.num32 and next(tb.num32) then
  1190. byteArray.write_uint8(1)
  1191. tb.num32.encode(byteArray)
  1192. else
  1193. byteArray.write_uint8(0)
  1194. end
  1195. if tb.unum32 and next(tb.unum32) then
  1196. byteArray.write_uint8(1)
  1197. tb.unum32.encode(byteArray)
  1198. else
  1199. byteArray.write_uint8(0)
  1200. end
  1201. if tb.num64 and next(tb.num64) then
  1202. byteArray.write_uint8(1)
  1203. tb.num64.encode(byteArray)
  1204. else
  1205. byteArray.write_uint8(0)
  1206. end
  1207. if tb.unum64 and next(tb.unum64) then
  1208. byteArray.write_uint8(1)
  1209. tb.unum64.encode(byteArray)
  1210. else
  1211. byteArray.write_uint8(0)
  1212. end
  1213. if tb.numfloat and next(tb.numfloat) then
  1214. byteArray.write_uint8(1)
  1215. tb.numfloat.encode(byteArray)
  1216. else
  1217. byteArray.write_uint8(0)
  1218. end
  1219. if tb.numdouble and next(tb.numdouble) then
  1220. byteArray.write_uint8(1)
  1221. tb.numdouble.encode(byteArray)
  1222. else
  1223. byteArray.write_uint8(0)
  1224. end
  1225. byteArray.write_float(tb.float)
  1226. byteArray.write_double(tb.double)
  1227. byteArray.write_string(tb.string1)
  1228. byteArray.write_string(tb.string2)
  1229. if tb.union and next(tb.union) then
  1230. byteArray.write_uint8(1)
  1231. tb.union.encode(byteArray)
  1232. else
  1233. byteArray.write_uint8(0)
  1234. end
  1235. byteArray.write_uint16(#(tb.lbool))
  1236. for k, v in pairs (tb.lbool) do
  1237. byteArray.write_bool(v)
  1238. end
  1239. byteArray.write_uint16(#(tb.lint8))
  1240. for k, v in pairs (tb.lint8) do
  1241. byteArray.write_int8(v)
  1242. end
  1243. byteArray.write_uint16(#(tb.luint8))
  1244. for k, v in pairs (tb.luint8) do
  1245. byteArray.write_uint8(v)
  1246. end
  1247. byteArray.write_uint16(#(tb.lint16))
  1248. for k, v in pairs (tb.lint16) do
  1249. byteArray.write_int16(v)
  1250. end
  1251. byteArray.write_uint16(#(tb.luint16))
  1252. for k, v in pairs (tb.luint16) do
  1253. byteArray.write_uint16(v)
  1254. end
  1255. byteArray.write_uint16(#(tb.lint32))
  1256. for k, v in pairs (tb.lint32) do
  1257. byteArray.write_int32(v)
  1258. end
  1259. byteArray.write_uint16(#(tb.luint32))
  1260. for k, v in pairs (tb.luint32) do
  1261. byteArray.write_uint32(v)
  1262. end
  1263. byteArray.write_uint16(#(tb.lint64))
  1264. for k, v in pairs (tb.lint64) do
  1265. byteArray.write_int64(v)
  1266. end
  1267. byteArray.write_uint16(#(tb.luint64))
  1268. for k, v in pairs (tb.luint64) do
  1269. byteArray.write_uint64(v)
  1270. end
  1271. byteArray.write_uint16(#(tb.linte8))
  1272. for k, v in pairs(tb.linte8) do
  1273. byteArray = v.encode(byteArray)
  1274. end
  1275. byteArray.write_uint16(#(tb.linte16))
  1276. for k, v in pairs(tb.linte16) do
  1277. byteArray = v.encode(byteArray)
  1278. end
  1279. byteArray.write_uint16(#(tb.linte32))
  1280. for k, v in pairs(tb.linte32) do
  1281. byteArray = v.encode(byteArray)
  1282. end
  1283. byteArray.write_uint16(#(tb.linte64))
  1284. for k, v in pairs(tb.linte64) do
  1285. byteArray = v.encode(byteArray)
  1286. end
  1287. byteArray.write_uint16(#(tb.lnum8))
  1288. for k, v in pairs(tb.lnum8) do
  1289. byteArray = v.encode(byteArray)
  1290. end
  1291. byteArray.write_uint16(#(tb.lnum16))
  1292. for k, v in pairs(tb.lnum16) do
  1293. byteArray = v.encode(byteArray)
  1294. end
  1295. byteArray.write_uint16(#(tb.lnum32))
  1296. for k, v in pairs(tb.lnum32) do
  1297. byteArray = v.encode(byteArray)
  1298. end
  1299. byteArray.write_uint16(#(tb.lnum64))
  1300. for k, v in pairs(tb.lnum64) do
  1301. byteArray = v.encode(byteArray)
  1302. end
  1303. byteArray.write_uint16(#(tb.lnfloat32))
  1304. for k, v in pairs(tb.lnfloat32) do
  1305. byteArray = v.encode(byteArray)
  1306. end
  1307. byteArray.write_uint16(#(tb.lnfloat64))
  1308. for k, v in pairs(tb.lnfloat64) do
  1309. byteArray = v.encode(byteArray)
  1310. end
  1311. byteArray.write_uint16(#(tb.lfloat))
  1312. for k, v in pairs (tb.lfloat) do
  1313. byteArray.write_float(v)
  1314. end
  1315. byteArray.write_uint16(#(tb.ldouble))
  1316. for k, v in pairs (tb.ldouble) do
  1317. byteArray.write_double(v)
  1318. end
  1319. byteArray.write_uint16(#(tb.lstring))
  1320. for k, v in pairs (tb.lstring) do
  1321. byteArray.write_string(v)
  1322. end
  1323. byteArray.write_uint16(#(tb.lunion))
  1324. for k, v in pairs(tb.lunion) do
  1325. byteArray = v.encode(byteArray)
  1326. end
  1327. return byteArray
  1328. end
  1329. tb.decode = function(byteArray)
  1330. tb.bool = byteArray.read_bool()
  1331. tb.int8 = byteArray.read_int8()
  1332. tb.uint8 = byteArray.read_uint8()
  1333. tb.int16 = byteArray.read_int16()
  1334. tb.uint16 = byteArray.read_uint16()
  1335. tb.int32 = byteArray.read_int32()
  1336. tb.uint32 = byteArray.read_uint32()
  1337. tb.int64 = byteArray.read_int64()
  1338. tb.uint64 = byteArray.read_uint64()
  1339. local isNilinte8 = byteArray.read_uint8()
  1340. if isNilinte8 > 0 then
  1341. tb.inte8 = integer()
  1342. tb.inte8.decode(byteArray)
  1343. else
  1344. tb.inte8 = {}
  1345. end
  1346. local isNiluinte8 = byteArray.read_uint8()
  1347. if isNiluinte8 > 0 then
  1348. tb.uinte8 = integer()
  1349. tb.uinte8.decode(byteArray)
  1350. else
  1351. tb.uinte8 = {}
  1352. end
  1353. local isNilinte16 = byteArray.read_uint8()
  1354. if isNilinte16 > 0 then
  1355. tb.inte16 = integer()
  1356. tb.inte16.decode(byteArray)
  1357. else
  1358. tb.inte16 = {}
  1359. end
  1360. local isNiluinte16 = byteArray.read_uint8()
  1361. if isNiluinte16 > 0 then
  1362. tb.uinte16 = integer()
  1363. tb.uinte16.decode(byteArray)
  1364. else
  1365. tb.uinte16 = {}
  1366. end
  1367. local isNilinte32 = byteArray.read_uint8()
  1368. if isNilinte32 > 0 then
  1369. tb.inte32 = integer()
  1370. tb.inte32.decode(byteArray)
  1371. else
  1372. tb.inte32 = {}
  1373. end
  1374. local isNiluinte32 = byteArray.read_uint8()
  1375. if isNiluinte32 > 0 then
  1376. tb.uinte32 = integer()
  1377. tb.uinte32.decode(byteArray)
  1378. else
  1379. tb.uinte32 = {}
  1380. end
  1381. local isNilinte64 = byteArray.read_uint8()
  1382. if isNilinte64 > 0 then
  1383. tb.inte64 = integer()
  1384. tb.inte64.decode(byteArray)
  1385. else
  1386. tb.inte64 = {}
  1387. end
  1388. local isNiluinte64 = byteArray.read_uint8()
  1389. if isNiluinte64 > 0 then
  1390. tb.uinte64 = integer()
  1391. tb.uinte64.decode(byteArray)
  1392. else
  1393. tb.uinte64 = {}
  1394. end
  1395. local isNilnum8 = byteArray.read_uint8()
  1396. if isNilnum8 > 0 then
  1397. tb.num8 = number()
  1398. tb.num8.decode(byteArray)
  1399. else
  1400. tb.num8 = {}
  1401. end
  1402. local isNilunum8 = byteArray.read_uint8()
  1403. if isNilunum8 > 0 then
  1404. tb.unum8 = number()
  1405. tb.unum8.decode(byteArray)
  1406. else
  1407. tb.unum8 = {}
  1408. end
  1409. local isNilnum16 = byteArray.read_uint8()
  1410. if isNilnum16 > 0 then
  1411. tb.num16 = number()
  1412. tb.num16.decode(byteArray)
  1413. else
  1414. tb.num16 = {}
  1415. end
  1416. local isNilunum16 = byteArray.read_uint8()
  1417. if isNilunum16 > 0 then
  1418. tb.unum16 = number()
  1419. tb.unum16.decode(byteArray)
  1420. else
  1421. tb.unum16 = {}
  1422. end
  1423. local isNilnum32 = byteArray.read_uint8()
  1424. if isNilnum32 > 0 then
  1425. tb.num32 = number()
  1426. tb.num32.decode(byteArray)
  1427. else
  1428. tb.num32 = {}
  1429. end
  1430. local isNilunum32 = byteArray.read_uint8()
  1431. if isNilunum32 > 0 then
  1432. tb.unum32 = number()
  1433. tb.unum32.decode(byteArray)
  1434. else
  1435. tb.unum32 = {}
  1436. end
  1437. local isNilnum64 = byteArray.read_uint8()
  1438. if isNilnum64 > 0 then
  1439. tb.num64 = number()
  1440. tb.num64.decode(byteArray)
  1441. else
  1442. tb.num64 = {}
  1443. end
  1444. local isNilunum64 = byteArray.read_uint8()
  1445. if isNilunum64 > 0 then
  1446. tb.unum64 = number()
  1447. tb.unum64.decode(byteArray)
  1448. else
  1449. tb.unum64 = {}
  1450. end
  1451. local isNilnumfloat = byteArray.read_uint8()
  1452. if isNilnumfloat > 0 then
  1453. tb.numfloat = number()
  1454. tb.numfloat.decode(byteArray)
  1455. else
  1456. tb.numfloat = {}
  1457. end
  1458. local isNilnumdouble = byteArray.read_uint8()
  1459. if isNilnumdouble > 0 then
  1460. tb.numdouble = number()
  1461. tb.numdouble.decode(byteArray)
  1462. else
  1463. tb.numdouble = {}
  1464. end
  1465. tb.float = byteArray.read_float()
  1466. tb.double = byteArray.read_double()
  1467. tb.string1 = byteArray.read_string()
  1468. tb.string2 = byteArray.read_string()
  1469. local isNilunion = byteArray.read_uint8()
  1470. if isNilunion > 0 then
  1471. tb.union = union()
  1472. tb.union.decode(byteArray)
  1473. else
  1474. tb.union = {}
  1475. end
  1476. local cntOflbool = byteArray.read_uint16()
  1477. tb.lbool = {}
  1478. for i = 1, cntOflbool do
  1479. table.insert(tb.lbool, byteArray.read_bool())
  1480. end
  1481. local cntOflint8 = byteArray.read_uint16()
  1482. tb.lint8 = {}
  1483. for i = 1, cntOflint8 do
  1484. table.insert(tb.lint8, byteArray.read_int8())
  1485. end
  1486. local cntOfluint8 = byteArray.read_uint16()
  1487. tb.luint8 = {}
  1488. for i = 1, cntOfluint8 do
  1489. table.insert(tb.luint8, byteArray.read_uint8())
  1490. end
  1491. local cntOflint16 = byteArray.read_uint16()
  1492. tb.lint16 = {}
  1493. for i = 1, cntOflint16 do
  1494. table.insert(tb.lint16, byteArray.read_int16())
  1495. end
  1496. local cntOfluint16 = byteArray.read_uint16()
  1497. tb.luint16 = {}
  1498. for i = 1, cntOfluint16 do
  1499. table.insert(tb.luint16, byteArray.read_uint16())
  1500. end
  1501. local cntOflint32 = byteArray.read_uint16()
  1502. tb.lint32 = {}
  1503. for i = 1, cntOflint32 do
  1504. table.insert(tb.lint32, byteArray.read_int32())
  1505. end
  1506. local cntOfluint32 = byteArray.read_uint16()
  1507. tb.luint32 = {}
  1508. for i = 1, cntOfluint32 do
  1509. table.insert(tb.luint32, byteArray.read_uint32())
  1510. end
  1511. local cntOflint64 = byteArray.read_uint16()
  1512. tb.lint64 = {}
  1513. for i = 1, cntOflint64 do
  1514. table.insert(tb.lint64, byteArray.read_int64())
  1515. end
  1516. local cntOfluint64 = byteArray.read_uint16()
  1517. tb.luint64 = {}
  1518. for i = 1, cntOfluint64 do
  1519. table.insert(tb.luint64, byteArray.read_uint64())
  1520. end
  1521. local cntOflinte8 = byteArray.read_uint16()
  1522. tb.linte8 = {}
  1523. for i = 1, cntOflinte8 do
  1524. local temp = integer()
  1525. temp.decode(byteArray)
  1526. table.insert(tb.linte8, temp)
  1527. end
  1528. local cntOflinte16 = byteArray.read_uint16()
  1529. tb.linte16 = {}
  1530. for i = 1, cntOflinte16 do
  1531. local temp = integer()
  1532. temp.decode(byteArray)
  1533. table.insert(tb.linte16, temp)
  1534. end
  1535. local cntOflinte32 = byteArray.read_uint16()
  1536. tb.linte32 = {}
  1537. for i = 1, cntOflinte32 do
  1538. local temp = integer()
  1539. temp.decode(byteArray)
  1540. table.insert(tb.linte32, temp)
  1541. end
  1542. local cntOflinte64 = byteArray.read_uint16()
  1543. tb.linte64 = {}
  1544. for i = 1, cntOflinte64 do
  1545. local temp = integer()
  1546. temp.decode(byteArray)
  1547. table.insert(tb.linte64, temp)
  1548. end
  1549. local cntOflnum8 = byteArray.read_uint16()
  1550. tb.lnum8 = {}
  1551. for i = 1, cntOflnum8 do
  1552. local temp = number()
  1553. temp.decode(byteArray)
  1554. table.insert(tb.lnum8, temp)
  1555. end
  1556. local cntOflnum16 = byteArray.read_uint16()
  1557. tb.lnum16 = {}
  1558. for i = 1, cntOflnum16 do
  1559. local temp = number()
  1560. temp.decode(byteArray)
  1561. table.insert(tb.lnum16, temp)
  1562. end
  1563. local cntOflnum32 = byteArray.read_uint16()
  1564. tb.lnum32 = {}
  1565. for i = 1, cntOflnum32 do
  1566. local temp = number()
  1567. temp.decode(byteArray)
  1568. table.insert(tb.lnum32, temp)
  1569. end
  1570. local cntOflnum64 = byteArray.read_uint16()
  1571. tb.lnum64 = {}
  1572. for i = 1, cntOflnum64 do
  1573. local temp = number()
  1574. temp.decode(byteArray)
  1575. table.insert(tb.lnum64, temp)
  1576. end
  1577. local cntOflnfloat32 = byteArray.read_uint16()
  1578. tb.lnfloat32 = {}
  1579. for i = 1, cntOflnfloat32 do
  1580. local temp = number()
  1581. temp.decode(byteArray)
  1582. table.insert(tb.lnfloat32, temp)
  1583. end
  1584. local cntOflnfloat64 = byteArray.read_uint16()
  1585. tb.lnfloat64 = {}
  1586. for i = 1, cntOflnfloat64 do
  1587. local temp = number()
  1588. temp.decode(byteArray)
  1589. table.insert(tb.lnfloat64, temp)
  1590. end
  1591. local cntOflfloat = byteArray.read_uint16()
  1592. tb.lfloat = {}
  1593. for i = 1, cntOflfloat do
  1594. table.insert(tb.lfloat, byteArray.read_float())
  1595. end
  1596. local cntOfldouble = byteArray.read_uint16()
  1597. tb.ldouble = {}
  1598. for i = 1, cntOfldouble do
  1599. table.insert(tb.ldouble, byteArray.read_double())
  1600. end
  1601. local cntOflstring = byteArray.read_uint16()
  1602. tb.lstring = {}
  1603. for i = 1, cntOflstring do
  1604. table.insert(tb.lstring, byteArray.read_string())
  1605. end
  1606. local cntOflunion = byteArray.read_uint16()
  1607. tb.lunion = {}
  1608. for i = 1, cntOflunion do
  1609. local temp = union()
  1610. temp.decode(byteArray)
  1611. table.insert(tb.lunion, temp)
  1612. end
  1613. end
  1614. tb.build = function(byteArray)
  1615. byteArray.write_uint16(35)
  1616. return tb.encode(byteArray)
  1617. end
  1618. return tb
  1619. end
  1620. function testnull()
  1621. local tb = {}
  1622. tb.msgId =36
  1623. tb.encode = function(byteArray)
  1624. return byteArray
  1625. end
  1626. tb.decode = function(byteArray)
  1627. end
  1628. tb.build = function(byteArray)
  1629. byteArray.write_uint16(36)
  1630. return tb.encode(byteArray)
  1631. end
  1632. return tb
  1633. end
  1634. function person1()
  1635. local tb = {}
  1636. tb.msgId =1001
  1637. t.name = ""
  1638. t.id = 0
  1639. t.email = ""
  1640. t.phone = {}
  1641. tb.encode = function(byteArray)
  1642. byteArray.write_string(tb.name)
  1643. byteArray.write_int32(tb.id)
  1644. byteArray.write_string(tb.email)
  1645. byteArray.write_uint16(#(tb.phone))
  1646. for k, v in pairs(tb.phone) do
  1647. byteArray = v.encode(byteArray)
  1648. end
  1649. return byteArray
  1650. end
  1651. tb.decode = function(byteArray)
  1652. tb.name = byteArray.read_string()
  1653. tb.id = byteArray.read_int32()
  1654. tb.email = byteArray.read_string()
  1655. local cntOfphone = byteArray.read_uint16()
  1656. tb.phone = {}
  1657. for i = 1, cntOfphone do
  1658. local temp = phoneNumber()
  1659. temp.decode(byteArray)
  1660. table.insert(tb.phone, temp)
  1661. end
  1662. end
  1663. tb.build = function(byteArray)
  1664. byteArray.write_uint16(1001)
  1665. return tb.encode(byteArray)
  1666. end
  1667. return tb
  1668. end