protobuf 在lua中使用(3)

proto文件导出lua文件工具参考http://download.csdn.net/detail/c471961491/9414388通过前两篇的介绍已经能搭建一个lua的probuf使用结构了前两篇博文地址http://blog.csdn.net/daydayup_chf/article/details/49904785http://blog.csdn.ne
摘要由CSDN通过智能技术生成

proto文件导出lua文件工具参考

http://download.csdn.net/detail/c471961491/9414388


通过前两篇的介绍已经能搭建一个lua的probuf使用结构了

前两篇博文地址

http://blog.csdn.net/daydayup_chf/article/details/49904785

http://blog.csdn.net/daydayup_chf/article/details/49994023


然而在使用过程中,碰到了以下情况


TestA.proto

package Google;

message TestA
{
	required uint32 id   = 1;	
	optional uint32 name   = 2;
	required string year    = 3;
	optional uint32 nettype   = 4;	
}



TestB.proto

package Google;

message TestB
{
	required uint32 aa   = 1;	
	optional uint32 bb   = 2;
	required string cc    = 3;	
}



TestC.proto

import "TestA.proto";
import "TestB.proto";

package Google;

message TestC
{
	required TestA	testa  = 1;	
	required TestB testb = 2; 
}

message TestD
{
	required uint32	dddd  = 1;	
}

message TestE
{
	required TestD testd  = 1;	
}


当使用 message TestC 时出现错误

具体原因是报message_type是个空值


改正这个的处理方法是对导出的lua文件做修改


TestA.lua

-- Generated By protoc-gen-lua Do not Edit
local protobuf = require "protobuf"
module('TestA_pb')


TESTA = protobuf.Descriptor(); --此处去掉local
local TESTA_ID_FIELD = protobuf.FieldDescriptor();
local TESTA_NAME_FIELD = protobuf.F
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值