Skip to content

Commit 87e07ef

Browse files
committedOct 14, 2024
implement procedural derive macro for IsPlutusData
1 parent 9274576 commit 87e07ef

File tree

7 files changed

+820
-0
lines changed

7 files changed

+820
-0
lines changed
 

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ result
22
.direnv
33
.pre-commit-config.yaml
44
.DS_Store
5+
target

‎flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
./hercules-ci.nix
2424

2525
./plutus-ledger-api/build.nix
26+
./is-plutus-data-derive/build.nix
2627
];
2728
debug = true;
2829
systems = [ "x86_64-linux" "x86_64-darwin" ];

‎is-plutus-data-derive/Cargo.lock

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎is-plutus-data-derive/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "is-plutus-data-derive"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
proc-macro2 = "1.0.87"
8+
quote = "1.0.37"
9+
syn = { version = "2.0.79", features = ["full", "extra-traits"]}
10+
thiserror = "1.0.64"
11+
12+
[lib]
13+
proc-macro = true

‎is-plutus-data-derive/build.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ inputs, ... }: {
2+
perSystem = { config, system, ... }:
3+
let
4+
rustFlake =
5+
inputs.flake-lang.lib.${system}.rustFlake {
6+
src = ./.;
7+
version = "0";
8+
crateName = "is-plutus-data-derive";
9+
devShellHook = config.settings.shell.hook;
10+
cargoNextestExtraArgs = "--all-features";
11+
generateDocs = false;
12+
};
13+
14+
in
15+
{
16+
inherit (rustFlake) packages checks devShells;
17+
};
18+
}

‎is-plutus-data-derive/src/derive_impl.rs

Lines changed: 706 additions & 0 deletions
Large diffs are not rendered by default.

‎is-plutus-data-derive/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use quote::ToTokens;
2+
use syn::{parse_macro_input, DeriveInput};
3+
4+
pub(crate) mod derive_impl;
5+
6+
#[proc_macro_derive(IsPlutusData, attributes(plutus_data_derive_strategy))]
7+
pub fn derive_is_plutus_data(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
8+
let input = parse_macro_input!(input as DeriveInput);
9+
derive_impl::get_is_plutus_data_instance(input)
10+
.unwrap()
11+
.into_token_stream()
12+
.into()
13+
}

0 commit comments

Comments
 (0)
Please sign in to comment.