Skip to content

Commit

Permalink
Adds FFI macro to generate a yaml file for each class
Browse files Browse the repository at this point in the history
  • Loading branch information
gupnik committed Jan 17, 2025
1 parent 6bae053 commit f140f3d
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 22 deletions.
2 changes: 2 additions & 0 deletions rust/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }
3 changes: 3 additions & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ target/

# These are backup files generated by rustfmt
**/*.rs.bk

# Generated by tw_macros
bindings/
88 changes: 66 additions & 22 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ members = [
"tw_evm",
"tw_hash",
"tw_keypair",
"tw_macros",
"tw_memory",
"tw_misc",
"tw_number",
Expand Down
15 changes: 15 additions & 0 deletions rust/tw_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "tw_macros"
version = "0.1.0"
edition = "2021"

[lib]
proc-macro = true

[dependencies]
derive-syn-parse = "0.2.0"
proc-macro2 = "1.0.93"
quote = "1.0.38"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9.21"
syn = { version = "2.0.96", features = ["full"] }
12 changes: 12 additions & 0 deletions rust/tw_macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use proc_macro::TokenStream;

mod tw_ffi;

#[proc_macro_attribute]
pub fn tw_ffi(attr: TokenStream, item: TokenStream) -> TokenStream {
match tw_ffi::tw_ffi(attr.into(), item.into()) {
Ok(item) => item.into(),
Err(e) => e.to_compile_error().into(),
}
}

Loading

0 comments on commit f140f3d

Please sign in to comment.