jinq0123/LuaPbIntf

Can't resolve this format of proto3

eeeeegit opened this issue · 2 comments

message A
{
repeated uint64 img_pos =1 [packed=true];
}

message AAA
{
repeated enum_win_type enType =1 [packed=true]; //
repeated A win_pos = 2 ; //
}

I want to decode AAA message from our server send data.
I can use c++ decode it, but lubpbint can't.
Do you have any time to resolve this?

Only need to decode it, do not need encode it.

I need the test data.

In my test, it encodes and decodes correctly.

Add in test.proto:

message A
{
    repeated uint64 img_pos = 1 [packed=true];
}

message AAA
{
    enum enum_win_type { WIN_TYPE_UNSPECIFIED = 0; WIN_TYPE_1 = 1; }
    repeated enum_win_type enType = 1 [packed=true];
    repeated A win_pos = 2;
}

Add test in test.lua and run it:

-- test for issue #11: Can't resolve this format of proto3
function M.test_packed2()
    local msg_a = {img_pos = {1,2,3}}
    local msg = { enType = {1, 1, 1}, win_pos = {msg_a, msg_a, msg_a} }
    local s = pb.encode("test.AAA", msg)
    local msg2 = pb.decode("test.AAA", s)
    print(require("inspect")(msg2))
    assert(msg2.win_pos[1].img_pos[3] == 3)
end 
λ lua53pp test.lua                  
{                                   
  enType = { 1, 1, 1 },             
  win_pos = { {                     
      img_pos = { 1, 2, 3 }         
    }, {                            
      img_pos = { 1, 2, 3 }         
    }, {                            
      img_pos = { 1, 2, 3 }         
    } }                             
}                                   
Test OK!                            

ok, thanks, I will check my code, maybe the reason is I use luajit instead of Lua 5.3, I am not sure not, by the way, thank you for test.