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

Fix field names that collide with generated names #46 #541

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

davidhubbard
Copy link
Collaborator

This is a partial fix of #46

zenhack commented on Sep 17, 2016:

if a name would otherwise collide with a go or go-capnpc name, append
a single underscore. e.g. Struct becomes Struct_

Also see capnproto/capnproto#323

This commit changes the generated getter and setter methods for struct fields. If the field name would collide with code generated for any struct such as Method() or String(), the field getter becomes Method_() and the setter becomes SetMethod_().

Technically only Method_() would be necessary, but who wants to maintain the mental state? If the getter changes, the setter also changing is just simpler conceptually.

The capnp files in this repo under std have $Go.name() annotations due to #46. This removes one of them (std/capnp/compat/json.capnp) and updates the unit tests for code coverage testing purposes.

This is a partial fix of capnproto#46

> zenhack commented on Sep 17, 2016:
>
> if a name would otherwise collide with a go or go-capnpc name, append
> a single underscore. e.g. `Struct` becomes `Struct_`

Also see capnproto/capnproto#323

This commit changes the generated getter and setter methods for
struct fields. If the field name would collide with code generated
for any struct such as `Method()` or `String()`, the field getter
becomes `Method_()` and the setter becomes `SetMethod_()`.

Technically only `Method_()` would be necessary, but who wants to
maintain the mental state? If the getter changes, the setter also
changing is just simpler conceptually.

The capnp files in this repo under `std` have $Go.name() annotations
due to capnproto#46. This removes
one of them (std/capnp/compat/json.capnp) and updates the unit tests
for code coverage testing purposes.
@davidhubbard davidhubbard added this to the 3.0 milestone Aug 8, 2023
@davidhubbard davidhubbard self-assigned this Aug 8, 2023
@lthibault lthibault self-requested a review August 8, 2023 17:37
Copy link
Collaborator

@lthibault lthibault left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@davidhubbard davidhubbard merged commit 1855ade into capnproto:main Aug 8, 2023
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants