This is a binding of Google Protocol Buffer to Lua
zhanjunxiong / luapb Goto Github PK
View Code? Open in Web Editor NEWThis is a binding of Google Protocol Buffer to Lua
This is a binding of Google Protocol Buffer to Lua
current: int val = static_cast(luaL_checkinteger(L, 3));
should be: int val = static_cast(lua_toboolean(L, 3));
I guess..
After recompiling the lib boolean type set is correct and there is no error msg.
I cant find anything that will deal with
" field->type() == google::protobuf::FieldDescriptor::TYPE_MESSAGE "
in pb_set and pb_repeated_set functions. Is it intentionally or me just can't understand? I can't put fields of type another msg hence i found, that there is no code to deal with this type. I see such code in pb_get , pb_repeated_get and pb_repeated_add thou.
Any help?
需要接rpc
提示 bad argument #3 to '__newindex' (number expected, got boolean)
1,proto文件
package db;
enum Source{
MYSQL= 1;
INFORMIX=2;
}
message Message{
required Source sr = 1;
required string conStr = 2;
}
设置为MYSQL,但是反序列化后
print(msg.sr)
输出为sr
if(field->type() == google::protobuf::FieldDescriptor::TYPE_INT32)
has no type TYPE_SFIXED32 or TYPE_SFIXED64.
Using field->cpp_type()
is better.
hi,先感谢老兄,这个项目真棒!
但是使用的时候遇到问题,我在cocos2dx中集成了luapb,运行时先依照test.lua编写了test.proto,然后运行。如果我首先调用test.lua里的代码,会打印出正确的结果,但是如果我调用了cocos2dx绑定的那些(用tolua绑定,还有些ui操作什么的)就会报错" attempt to index local 'msg' (a userdata value)"
请教老兄,这个可能是怎么引起的,有什么解决办法比较好?
非常感谢!
如何使用luapb
如题
lua: error loading module 'luapb' from file './../luapb.so':
libprotobuf.so.9: cannot open shared object file: No such file or directory
我把这个库用于安卓时,import无法读入文件,主要是Importer的OpenVirtualFile方法中的open操作无法打开文件
require("luapb");
--package lm;
--message test
--{
-- required int32 uid = 1;
-- required int32 param = 2;
-- optional string param1 = 3;
-- repeated string param2 = 4;
--};
pb.import("test.proto");
function testAdd()
local msg = pb.new("lm.test");
msg.uid = 12345;
msg.param = 9876;
msg.param1 = "zjx";
--print("type: " .. type(msg.param2));
msg.param2.add("first");
msg.param2.add("second");
msg.param2.add("three");
print("uid: " .. msg.uid);
print("param: " .. msg.param);
print("param1: " .. msg.param1);
for i = 1, msg.param2.len() do
local value = msg.param2[i];
print("i: " .. i .. " value: " .. value);
end
print("str: " .. pb.tostring(msg));
print("hello world");
end
testAdd()
testAdd()
封装成函数的时候,多次调用,repeated filed的个数会和之前调用的累加,比如这个函数里
msg.param2.add("first");
msg.param2.add("second");
msg.param2.add("three");
第一次调用testAdd()执行了add了三次, msg.param2.len() 为3
第二次调用testAdd()又执行了add了三次, 局部作用域,msg.param2.len() 应该为3,但实际为6
作为一个刚接触的新手,对于编译so和dll完全不懂,能简单教下怎么编译dll和so吗?谢谢了。
我用lua5.3和protobuf-3.0.0编译so文件,改了makefile的两个地方
LUA_INC_DIR ?= /f/lua-5.3.5/src
PROTOBUF_INC_DIR ?=/F/protobuf-3.0.0/src
编译时候报错:
$ make
g++ -g -Wall -fpic -c -Iinclude -I/f/lua-5.3.5/src -I/F/protobuf-3.0.0/src src/*.cc
src/LuaPB.cc:486:30: error: elements of array 'const luaL_reg lib []' have incomplete type
static const struct luaL_reg lib[] =
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.