meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
programming:lua:protobuf [2017/02/02 14:19] niziak [Neopalium] |
programming:lua:protobuf [2020/07/03 09:48] (current) niziak ↷ Page moved from lua:protobuf to programming:lua:protobuf |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
====== Protocol ====== | ====== Protocol ====== | ||
* Encoding [[https://developers.google.com/protocol-buffers/docs/encoding]] | * Encoding [[https://developers.google.com/protocol-buffers/docs/encoding]] | ||
Line 8: | Line 9: | ||
====== Libraries ====== | ====== Libraries ====== | ||
- | ==== sean-lin based ==== | + | ===== sean-lin based ===== |
[[https://github.com/sean-lin/protoc-gen-lua]] | [[https://github.com/sean-lin/protoc-gen-lua]] | ||
* Latest commit 12 Jun 2014 | * Latest commit 12 Jun 2014 | ||
Line 27: | Line 28: | ||
- | ==== others ==== | + | ===== others ===== |
[[https://github.com/indygreg/lua-protobuf]] | [[https://github.com/indygreg/lua-protobuf]] | ||
* Last commit 27 Mar 2011 | * Last commit 27 Mar 2011 | ||
Line 50: | Line 51: | ||
- pb.io: a module to support binary mode read/write to stdin/stdout. | - pb.io: a module to support binary mode read/write to stdin/stdout. | ||
</code> | </code> | ||
- | ==== Neopalium ==== | + | |
+ | ===== Neopalium ===== | ||
[[https://github.com/Neopallium/lua-pb]] | [[https://github.com/Neopallium/lua-pb]] | ||
* Latest commit 18 Feb 2016 | * Latest commit 18 Feb 2016 | ||
* **Own LUA parser** for .proto files (no need to compile) | * **Own LUA parser** for .proto files (no need to compile) | ||
- | ====== Library API ====== | + | ======= Library API ======= |
<code lua> | <code lua> | ||
Line 72: | Line 74: | ||
</code> | </code> | ||
- | ==== Neopalium ==== | + | ===== Neopalium ===== |
<code lua> | <code lua> | ||
local pb = require 'pb' | local pb = require 'pb' | ||
Line 154: | Line 156: | ||
- | === Issue with 64bit number === | + | ==== Issue with 64bit number ==== |
18446744073709551615 is exactly 2^64-1 | 18446744073709551615 is exactly 2^64-1 | ||
Line 163: | Line 165: | ||
</code> | </code> | ||
- | If library detects LuaJIT with FFI support, it is using FFI cdata to store 64 bit numbers 'int64_t'' or ''uint64_t'' | + | If library detects LuaJIT with FFI support, it is using FFI cdata to store 64 bit numbers ''int64_t'' or ''uint64_t'' |
depends on ''signed'' argument passed to ''make_int64_func''. | depends on ''signed'' argument passed to ''make_int64_func''. | ||
If no LuaJIT is used, big values are represented as 8 bytes strings. | If no LuaJIT is used, big values are represented as 8 bytes strings. | ||
Line 172: | Line 174: | ||
-- make_int64(b8,b7,b6,b5,b4,b3,b2,b1, signed) | -- make_int64(b8,b7,b6,b5,b4,b3,b2,b1, signed) | ||
fakeNodeId = make_int64(0,0,0,0, 0,0,0,1 ) | fakeNodeId = make_int64(0,0,0,0, 0,0,0,1 ) | ||
+ | -- or initialize from string | ||
+ | local v = \255\255\255\255\255\255\255\255" | ||
+ | fakeNodeId = make_int65(v:byte(1,8)) | ||
print (fakeNodeId) | print (fakeNodeId) | ||
-- prints: '1ULL' | -- prints: '1ULL' | ||
Line 181: | Line 186: | ||
But library encoder doesn't work: | But library encoder doesn't work: | ||
+ | <code> | ||
luaData = { | luaData = { | ||
["deviceId"] = 1.844674407371e+19; | ["deviceId"] = 1.844674407371e+19; | ||
Line 189: | Line 195: | ||
binProtoMsg decoded=deviceId: 0 | binProtoMsg decoded=deviceId: 0 | ||
+ | </code> | ||
- | + | ===== djungelorm ===== | |
- | ==== djungelorm ==== | + | |
No documentation. Poor examples. | No documentation. Poor examples. | ||
Need to dig in sources to familiarize. | Need to dig in sources to familiarize. | ||
Line 232: | Line 238: | ||
* _member:ParseFromString(serialized) | * _member:ParseFromString(serialized) | ||
* _member:FindInitalizationErrors() | * _member:FindInitalizationErrors() | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
<code lua> | <code lua> |