您的位置:首页 > 编程语言 > Lua

Protobuf-Lua 中使用 Enum

2015-12-12 02:16 756 查看
--Student.proto

message Course
{
required int32 id=1;
required int32 name=2;

required SomeEnum bar=3;
}

enum SomeEnum
{
VALUE_A=0;
VALUE_B=5;
VALUE_C=1234;
}

测试代码

StudentTest.lua

package.path = package.path .. ';./protobuf/?.lua;./protobuf/luascript/?.lua'

require("Student_pb")

local msgCourse=Student_pb.Course()
msgCourse.bar=Student_pb.VALUE_A
print(msgCourse.bar)

msgCourse.bar=Student_pb.VALUE_B
print(msgCourse.bar)

msgCourse.bar=Student_pb.VALUE_C
print(msgCourse.bar)

输出
0

5

1234

[Finished in 0.1s]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: