Conversation
|
Thanks for the PR! I did a quick review, but I'll do a full review next week, after my finals. |
I'd like to have this fixed first before merging the MR.
Ah, I now get what you meant. Some possible solutions I can think of are: |
| @@ -0,0 +1,99 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
There was a problem hiding this comment.
I think having one of each key for each child schema would be enough for testing
7e809f6 to
1855d9c
Compare
f035bbd to
ff78919
Compare
ff78919 to
b415a5d
Compare
|
I've updated my PR so that it now promotes flags and enums to be standalone, decoupling them from individual schemas. |
|
Looking good! 👍
Is there a specifc reason why would the user prefer not to generate globals? |
Well, yes. Take the enum here for instance. The alternative would be to just generate everything in the schema in one go, but I've been working on that and it's quite a bit of work, TBH. |
|
Ah, that makes sense indeed. I wonder if it is worth it to push through something like: gen_settings! {
const FILE = "...";
#[gen_settings(id = "...")]
pub struct Settings;
#[gen_settings(id = "...")]
pub struct AnotherSettings;
}It is a rough scratch of the API, but I think something like that would be less confusing and less thinking on the user side whether to generate the globals. |
|
We can also copy gen_settings! {"path/to/schema/file"=>
#[gen_settings(id = "...")]
pub struct Settings;
#[gen_settings(id = "...")]
pub struct AnotherSettings;
}or #[gen_settings(file = "...")]
#[gen_settings_skip(signature = "(ss)")] // global scope
mod settings {
#[gen_settings(id = "...")]
#[gen_settings_skip(signature = "(ss)")] // local scope
pub struct Settings;
#[gen_settings(id = "...")]
pub struct AnotherSettings;
} |
This PR adds initial support for multiple schemas in a single gschema file.
It's pretty basic and there's probably a lot of caveats, for instance:
reusing flags/enums will cause these to be generated twice as aux tokenstream. Having a different key in each schema will make different flag structs/enums, which won't be compatible.
choices using the same key will not work
Is this something you would be willing to pull in?
Edit: I have some ideas to fix this fix the possible issues regarding flags and enums. I propose to to that in an additional PR to keep changesets small.