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

Add flag to MessageDef for whether fields have presence. #43

Merged
merged 3 commits into from
Oct 21, 2015

Conversation

haberman
Copy link
Member

As a step towards proto2 (descriptor.proto) support.

Review to @tbetbetbe.

@haberman haberman force-pushed the presenceflag branch 5 times, most recently from 497e7a7 to ba4b6f5 Compare October 15, 2015 21:39
@haberman
Copy link
Member Author

Sounds like @tbetbetbe is on vacation, @scwhittle want to take a look?

Context is: we want to support proto2/proto3 simultaneously, which means having a flag in each message indicating whether it has proto2 presence semantics or proto3.


/* Primitive field: return true unless there is a message that specifies
* presence should not exist. */
if (f->msg_is_symbolic || !f->msg.def) return true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be better to assert that the msg is not symbolic?
Returning true unconditionally seems incorrect

and a reminder, when would the message def be null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would only be NULL before the field has been added to a message.

To me this is just implementing a sane default: presence defaults to true, but is false in cases where it is known to be false.

@haberman
Copy link
Member Author

PTAL.

haberman added a commit that referenced this pull request Oct 21, 2015
Add flag to MessageDef for whether fields have presence.
@haberman haberman merged commit a1c8f7c into protocolbuffers:master Oct 21, 2015
@haberman haberman deleted the presenceflag branch February 18, 2016 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants