Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pb.encode的时候,如果table的metatable有定义__pairs,则通过__pairs进行遍历 #25

Closed
Jayatubi opened this issue Feb 11, 2018 · 3 comments

Comments

@Jayatubi
Copy link
Contributor

pb.encode的时候,如果table的metatable有定义__pairs,则通过__pairs进行遍历

@diegonc
Copy link

diegonc commented Sep 12, 2018

Sorry, I don't understand this issue. Has it anything to do with the field order at encode time? I'm using two libraries (java and this one) to create the same protobuf and getting different ordering.

https://developers.google.com/protocol-buffers/docs/encoding#order

@starwing
Copy link
Owner

@diegonc Hi, protobuf's spec do not define the order of encoded bytes. So it's valid to just have random order. if you really need specific order, you could write message yourself using pb.buffer low level routines.

@diegonc
Copy link

diegonc commented Sep 13, 2018

Yeah, it's valid for parser but encoders should sort them by number according to the link posted above.

Anyway, I'm trying in the gist below to use pb.buffer but I'm no sure how to send fields and following Lpb_encode is getting hard as it uses things that don't seem to be available in Lua. Can you help me fill the gaps? Thanks

https://gist.github.com/diegonc/d6af5520e8966340ccf27977220beb71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants