Code Monkey home page Code Monkey logo

luapb's People

Contributors

zhanjunxiong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luapb's Issues

加载模块 luapb失败

lua: error loading module 'luapb' from file './../luapb.so':
libprotobuf.so.9: cannot open shared object file: No such file or directory

attempt to index local 'msg' (a userdata value)

hi,先感谢老兄,这个项目真棒!

但是使用的时候遇到问题,我在cocos2dx中集成了luapb,运行时先依照test.lua编写了test.proto,然后运行。如果我首先调用test.lua里的代码,会打印出正确的结果,但是如果我调用了cocos2dx绑定的那些(用tolua绑定,还有些ui操作什么的)就会报错" attempt to index local 'msg' (a userdata value)"
请教老兄,这个可能是怎么引起的,有什么解决办法比较好?

非常感谢!

TYPE_SFIXED32 missing

if(field->type() == google::protobuf::FieldDescriptor::TYPE_INT32)
has no type TYPE_SFIXED32 or TYPE_SFIXED64.

Using field->cpp_type() is better.

编译dll和so问题

作为一个刚接触的新手,对于编译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[] =

error in LuaPB.cc function pb_set at line 452

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.

repeated filed,多次add有问题

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

不支持枚举类型

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

There is no: field->type() == google::protobuf::FieldDescriptor::TYPE_MESSAGE

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.