starwing / lua-protobuf

A Lua module to work with Google protobuf
MIT License
1.73k stars 387 forks source link

pb.hook cannot handle native types #161

Open git-torrent opened 2 years ago

git-torrent commented 2 years ago

I am trying to hook bytes type to encode it into base64.

While I can hook other types, hooking native types gives me unknown type error.

I tried to recursively traverse the luatable proto representation and fix all the fields of type bytes ( by using pb.field() ), but this is tedious. Moreover, pb.hook() seems to be made exactly for this purpose.

Thanks

starwing commented 2 years ago

Sorry for the missing of this feature, but it seems difficult for current implementation. Pull requests are welcome, and I will look into this to find out how to make it up 😑

git-torrent commented 2 years ago

Too bad, I cannot fix this on my own (it requires lot of C-coding). To give some points: having hooks for any type would allow to implement proper JSON mapping as specified in https://developers.google.com/protocol-buffers/docs/proto3#json

Thank you