Skip to content

Commit

Permalink
macro refactor (#66)
Browse files Browse the repository at this point in the history
* macro refactor with support for generics and various attributes, including derives

* misstype

* fixed tests that used the macro

* fixed build for stable, added diagnostics feature in case it is someone on nightly wants it enabled

* feat: attrs in macro by origin way

* chore: update documents

* feat: add unit test

* chore: fmt

---------

Co-authored-by: Vitalii Lukyanov <[email protected]>
Co-authored-by: ShootingStarDragons <[email protected]>
  • Loading branch information
3 people authored Sep 27, 2024
1 parent b604b8a commit 7545129
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 121 deletions.
91 changes: 91 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion iced_examples/counter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ enum WindowDirection {
Bottom,
}

#[to_layer_message(derives = "Debug Clone")]
#[to_layer_message]
#[derive(Debug, Clone)]
enum Message {
IncrementPressed,
DecrementPressed,
Expand Down
3 changes: 2 additions & 1 deletion iced_examples/counter_muti/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ enum WindowDirection {
Bottom(Id),
}

#[to_layer_message(multi, info_name = "WindowInfo", derives = "Debug Clone")]
#[to_layer_message(multi, info_name = "WindowInfo")]
#[derive(Debug, Clone)]
enum Message {
IncrementPressed,
DecrementPressed,
Expand Down
4 changes: 3 additions & 1 deletion iced_layershell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ enum WindowDirection {

// Because new iced delete the custom command, so now we make a macro crate to generate
// the Command
#[to_layer_message(derives = "Debug Clone")]
#[to_layer_message]
#[derive(Debug, Clone)]
#[doc = "Some docs"]
enum Message {
IncrementPressed,
DecrementPressed,
Expand Down
12 changes: 11 additions & 1 deletion iced_layershell_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ readme.workspace = true
[lib]
proc-macro = true

[features]
default = []
# Only nightly
diagnostics = ["darling/diagnostics"]

[dependencies]
darling = { version = "0.20.10", features = ["suggestions"] }
manyhow = { version = "0.11.4", features = ["darling"] }
proc-macro2 = "1.0.86"
quote = "1.0.37"
syn = { version = "2.0.77", features = ["full"]}
syn = { version = "2.0.77", features = ["full"] }

[dev-dependencies]
iced_layershell.workspace = true
Loading

0 comments on commit 7545129

Please sign in to comment.