Closed stillcold closed 2 years ago
Below is my code:
local function test()
local P = protoc.new()
P.unknown_import = true
P.unknown_type = true
assert(P:load([[
syntax = "proto2";
import "descriptor.proto";
extend google.protobuf.MessageOptions {
optional string my_option = 51234;
}
]], "extend1.proto"))
P.unknown_import = nil
P.unknown_type = nil
local chunk = assert(P:compile [[
syntax = "proto2";
import "extend1.proto"
message MyMessage {
option (my_option) = "Hello world!";
}
]])
assert(pb.load(chunk))
local data = pb.decode("google.protobuf.FileDescriptorSet", chunk)
table.print(data)
end
test()
And this is what I got:
['file'] = {
[1] = {
['public_dependency'] = {
[1] = 0
},
['syntax'] = 'proto2',
['name'] = '<input>',
['dependency'] = {
[1] = 'extend1.proto'
},
['message_type'] = {
[1] = {
['options'] = {
},
['name'] = 'MyMessage'
}
}
}
}
As we can see, options is a empty table. So how can I get the right option of my message?
Okay, let me see...
There are some bugs of custom option support in protoc.lua, fixed on HEAD, please try again.
Works for me. Thanks~
Hi guys,
Is there a way I can use custom options with this repo?
custom options:
Thanks in advance.