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

Add basic struct generation #1

Merged
merged 6 commits into from
Jan 14, 2024
Merged

Add basic struct generation #1

merged 6 commits into from
Jan 14, 2024

Conversation

marv7000
Copy link
Collaborator

What does this PR change?

This PR adds a basic Rust struct generation by parsing a YAML schema using Serde and then reformatting the output.

Tick the applicable box:

  • Add new feature
  • Security changes
  • Tests
  • Documentation changed
  • General Maintenance

@@ -24,10 +25,14 @@ fn main() {

// Welcome Message
println!(
"{} \n(c) The Nezara Project. (github.com/The-Nezara/Project)\n
Copy link
Member

Choose a reason for hiding this comment

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

I knew I had a typo in there somewhere!

Copy link
Member

@ByteOtter ByteOtter left a comment

Choose a reason for hiding this comment

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

So I have looked over it and found that it panics on my machine.
Here's the shortened backtrace, maybe you can figure this one out:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/bindgen.rs:94:70
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/result.rs:1651:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/result.rs:1076:23
   4: thanix::bindgen::gen
             at ./src/bindgen.rs:94:26
   5: thanix::main
             at ./src/main.rs:35:23
   6: core::ops::function::FnOnce::call_once
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Also I would like you to format the code using cargo fmt if not already done so. The workflow shows errors so if you could check that I would greatly appreciate this.

Apart from that, great work and thanks for the help!

@marv7000
Copy link
Collaborator Author

I think you just need to create the "output/" directory, that's an easy fix though.
I did run cargo fmt over it, but clippy will complain because most of the struct fields are still not marked with #[allow(dead_code)].

@ByteOtter
Copy link
Member

I think you just need to create the "output/" directory, that's an easy fix though. I did run cargo fmt over it, but clippy will complain because most of the struct fields are still not marked with #[allow(dead_code)].

You were right that did the trick. Stupid that I didn't think of that. 🤦🏼

Clippy will complain about dead code but as these are classified as warnings they can be ignored for now. But I did see real errors in the workflow output so maybe check tomorrow.

@marv7000
Copy link
Collaborator Author

Should work now, seems like File::write is not optimal.

@ByteOtter
Copy link
Member

Great work on fixing that this quickly.
As this is a complete feature now, I would suggest we merge it tomorrow.
Would you say that adding some tests for this feature would be even possible? Not today of course ...

@marv7000
Copy link
Collaborator Author

Sure, I'll get to it.

Copy link
Member

@ByteOtter ByteOtter left a comment

Choose a reason for hiding this comment

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

LGTM. We're gonna rework the splitting of these structs into different modules later.

@ByteOtter ByteOtter force-pushed the add_struct_generation branch from faa430d to af8cde0 Compare January 14, 2024 14:00
@ByteOtter ByteOtter marked this pull request as ready for review January 14, 2024 14:00
@ByteOtter ByteOtter merged commit b453c42 into main Jan 14, 2024
4 checks passed
@ByteOtter ByteOtter deleted the add_struct_generation branch January 14, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants