pbc icon indicating copy to clipboard operation
pbc copied to clipboard

lua中怎么样取出enum的值

Open ghost opened this issue 10 years ago • 3 comments

在lua中,test.proto message A{ enum { B = 1; }; };

pb:register 'test.pb'后

在lua怎么拿到 B的值

ghost avatar Aug 01 '14 06:08 ghost

同问,好像到Lua里面Enum都变成string了

linkabox avatar Mar 25 '15 08:03 linkabox

不支持。 如果你有这个需求,请自己实现 binding 。 pbc 的 C api 你可以自己决定读出数字还是字符串。

cloudwu avatar Mar 25 '15 09:03 cloudwu

我们得项目里一直是用 https://github.com/xresloader/xresloader 导出一份lua常量代码得。

java -client -jar xresloader-1.3.1.0.jar -t lua -p protobuf -f XXXXX.pb --pretty 2 -c XXXXX.lua --lua-global

然后require进来就好了

owent avatar Mar 03 '17 08:03 owent