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

Support setting and iterating over map keys #511

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

negz
Copy link

@negz negz commented Oct 2, 2023

Fixes #381

This PR introduces a new MapField type, which can be used to set and access map field values by key.

Without this PR I get a panic in toStarlark1 where x.Message() is called on a map field value. (Perhaps because my proto has some map<string, Message> fields):

panic: type mismatch: cannot convert map to message

I've also updated the nascent proto.star unit tests to use their own proto file, to test repeated and map fields.

Separately from the main change, I've included a commit that adds a list-like append method to RepeatedField. I can break that out into a separate PR if you'd prefer.

I'm running go1.20.8, and my gofmt insists on this formatting. Not sure
why it's different from what's in master.

Signed-off-by: Nic Cope <nicc@rk0n.org>
Signed-off-by: Nic Cope <nicc@rk0n.org>
For now with random iteration. I'll work on stable iteration in a future
commit.

Signed-off-by: Nic Cope <nicc@rk0n.org>
Signed-off-by: Nic Cope <nicc@rk0n.org>
This switches to using a dedicated test.proto file, since the
descriptor.proto file previously being used doesn't have any map fields.

Signed-off-by: Nic Cope <nicc@rk0n.org>
It doesn't seem to exist - I don't think it was ever committed to this
public repo.

Signed-off-by: Nic Cope <nicc@rk0n.org>
Signed-off-by: Nic Cope <nicc@rk0n.org>
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.

proto: Support map fields
1 participant