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

witx: add support for parsing multiple top-level files #145

Merged
merged 3 commits into from
Nov 12, 2019

Conversation

pchickey
Copy link
Contributor

@pchickey pchickey commented Nov 7, 2019

This PR adds support in witx to parse multiple top-level witx files. This is an api-breaking change - public functions that previously took an impl AsRef<Path> to a witx file now take an &[impl AsRef<Path>]

There is still only one global namespace for all type names and module names across all files. This means that if two top-level files define the same name, the second definition will cause an error, just like it would if both definitions are in the same file. However, if two top-level files depend each depend on a third file which defines a name, the name will only be defined once, and each reference to that name will be equal.

I'd like to fix the scoping issue at some point soon, but for now this unblocks #98.

Copy link
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

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

I agree, this looks like a good approach for now. The one thing that would be good to add here is a test for the error case -- when a given name is defined as one type in one file, and another type in another, so that even though we have a single global namespace for these types, we'll catch errors if we have collisions.

@pchickey
Copy link
Contributor Author

pchickey commented Nov 7, 2019

Great idea - done :)

Copy link
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@pchickey pchickey merged commit 3e6d7a7 into master Nov 12, 2019
@pchickey pchickey deleted the pch/multimodule branch November 12, 2019 00:35
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