为什么不使用 lua 实现 google 的协议缓冲区呢? lua有没有更好的解决方案?
为什么不使用 lua 实现 google 的协议缓冲区呢? lua有没有更好的解决方案?
why not a lua implementation of google's protocol buffers? is there already any better solution exist for lua?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如我们所说,我正在努力: https://github.com/haberman/upb/wiki
另外,我我就是上面那个写了 100 行解析器的人。但我的 upb 库功能更齐全。
I'm working on it as we speak: https://github.com/haberman/upb/wiki
Also, I'm the guy who wrote the 100-line parser above. But my upb library is much more full-featured.
我刚刚创建了一个协议缓冲区的 Lua 实现 lua-pb。它动态加载/解析 .proto 文件来创建消息对象,因此不依赖于 Google 的标准 .proto 编译器。
它使用 LPeg 来解析 .proto 文件和 结构 & Lua BitOp 用于编码/解码。
I just created a Lua implementation of protocol buffers lua-pb. It dynamically loads/parsers .proto files to create message objects, so there is no dependence on the standard .proto compiler from Google.
It uses LPeg for parsing .proto files and struct & Lua BitOp for encoding/decoding.
可能是因为 C 或 C++ 实现会更快(并且更容易编写),然后您可以根据需要将数据交给 Lua 来使用。
这里有一个 100 行 C 协议缓冲区解析器: http://blog.reverberate.org/2008/07/12/100-lines-of-c-that-can-parse-any-protocol-buffer/
或者你可以只使用 Google C++,然后将你的数据从那里交给 Lua。
Lua 并不是为了处理位操作而构建的,所以也许这就是为什么还没有人在其中实现协议缓冲区的原因。它甚至没有内置按位运算符: http://lua-users.org/wiki/BitwiseOperators
Probably because a C or C++ implementation would be faster (and easier to write), and then you could hand the data off to Lua to be used if you want.
There's a 100 line C protocol buffer parser here: http://blog.reverberate.org/2008/07/12/100-lines-of-c-that-can-parse-any-protocol-buffer/
Or you could just use the Google C++ one, and then hand your data off to Lua from there.
Lua isn't built for bit twiddling, so perhaps that's why nobody has implemented protocol buffers in it yet. It doesn't even have bitwise operators built in: http://lua-users.org/wiki/BitwiseOperators