-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
SwIPC generator: the awakening #248
Conversation
Implement an IPC client code generator based on SwIPC definitions. The goal is to eventually remove all manually defined IPC client code from libuser in favor of being all automatically generated. This first draft defines vi.id using SwIPC, and swaps the libuser manual client code with this version. The generator is implemented as a proc macro. The parser is implemented using a pest grammar and a quick-n-dirty AST layered on top.
(BTW this is totally untested, so please don't merge unless you make sure it actually runs - not that I expect this to get merged without objections anyways :P. I'll test it tomorrow) |
forcing travis build after repo transfer : closing and reopening PR |
@roblabla being an higher-kinded programmer, the legend has it that he hasn't written a single line of code since the beginning of the year, and he is stuck at the meta level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, the parser is really simple, I like it.
- Added the ability to decorate service names. - Added the ability to parse unknown decorators. - Added a @managedport service decorator, allowing to differenciate between services hosted by sm: and those managed by the kernel.
We now inject `const _: &[u8] = include_bytes!(file.id);` in the generated output. This tells the rust compiler that we depend on the file.id file, without actually including it in the final binary. As such, the crate will be recompiled if file.id changes.
We now turn KHandle<_, type> into an instance of the real underlying type instead of just a generic Handle. For instance, client_session is turned into a ClientSession. Not all types are supported yet.
Fixes crashes on IPC calls that send/receive handles.
How else are we supposed to access it ^^'.
We now have two different code path for the raw_new, one handling the Managed Port, and the other handling normal service ports.
Requires an update to cargo-make 0.17.1! - Keep a single list with the clippy lints in an environment variable, shared between all clippy rules. - Remove clippy-ci. Use cargo make clippy -- -D warnings instead. - Run clippy on swipc-gen/swipc-parser. Requires a separate rule to handle running clippy on crates that require std.
When running cargo clippy twice, there will be no output as cargo check, for whatever reason, decides not to rerun. To fix this, we add a rule dependency on cargo make clippy that touches all the crates. Unfortunately, this likely breaks on windows...
This will simplify testing later.
Mod attributes still require rustc to resolve the module, so swipc mods should be defined as an empty in-line module instead of an external file module, e.g.: ```rust #[gen_ipc()] pub mod sm {} ``` We also fix the namespace path of ViInterface which wrongly used libuser instead of kfs_libuser.
KFS got renamed to Sunrise, rename everything. Small fix to vi.id: get_resolution should be called get_screen_resolution.
AHCI and SM client code are now generated based on SwIPC definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great
Calling any function that had objects would cause a panic when attempting to push it to the move_handles arrayvec, due to them not being counted as handles. Objects are now counted as handles.
The introduction of SwIPC-gen in the workspace broke documentation building due to it depending on stdlib, which is not available when building with --target=i386-unknown-none. Documentation shall now be built without passing a target. Instead, any cfg blocking out based on target architecture or OS should additionally allow rustdoc, e.g: ```rust ``` This will allow rustdoc to punch through the cfg. It brings a few issues however: we cannot define lang items, as they would be duplicated. Those should not allow rustdoc through. Furthermore, we might have problem in the future with multiple architectures. We'll see when it comes.
Make some light touches on the documentation of the generator. Renames the clippy-kfs target to clippy-sunrise.
The SwIPC-Gen binary now has a better interface to play around with the code generated. Furthermore, to make using it simple, a Makefile rule, swipc-gen, was added, that will build and run the tool with the required arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
We currently use common variable names in the function implementation, such as buf, msg, etc... This can cause conflicts with argument names, causing hard to debug errors. Ideally, we'd create separate spans for everything, for proper hygiene. But doing this would require refactoring the code to not use strings everywhere. As a temporary band-aid, we should suffix __ to all internal variable names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great
More thorough keyword sanitizer in swipc generator.The SwIPC generator does little to no sanitizing of argument names that may be keywords in rust. We should have a list of keywords and a central function to fix them up. SunriseOS/swipc-gen/src/gen_rust_code.rs Lines 105 to 115 in 52d9e02
This comment was generated by todo based on a
|
Handle return C buffers.SunriseOS/swipc-gen/src/gen_rust_code.rs Lines 312 to 322 in 52d9e02
This comment was generated by todo based on a
|
Support nested typeSunriseOS/swipc-gen/src/gen_rust_code.rs Lines 365 to 375 in 52d9e02
This comment was generated by todo based on a
|
Deduce from templateSunriseOS/swipc-gen/src/gen_rust_code.rs Lines 378 to 388 in 52d9e02
This comment was generated by todo based on a
|
Prevent alias of buffer/pid/handlesSunriseOS/swipc-gen/src/gen_rust_code.rs Lines 389 to 399 in 52d9e02
This comment was generated by todo based on a
|
Bring the SwIPC parser in-line with new upstream format.Unknown can now carry a size (which behaves like bytes). Unsized unknown should be treated as an unsupported struct. SunriseOS/swipc-parser/src/lib.rs Lines 39 to 49 in 52d9e02
This comment was generated by todo based on a
|
SwIPC-parser: Merge multiple type/interface definitionWhen the parser encounters multiple definitions of a type or interface, it should try to merge them into a single one. SunriseOS/swipc-parser/src/lib.rs Lines 625 to 635 in 52d9e02
This comment was generated by todo based on a
|
Implement an IPC client code generator based on SwIPC definitions. The goal is to eventually remove all manually defined IPC client code from libuser in favor of being all automatically generated.
This first draft defines vi.id using SwIPC, and swaps the libuser manual client code with this version. The generator is implemented as a proc macro. The parser is implemented using a pest grammar and a quick-n-dirty AST layered on top.