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

Impl macro rework #1314

Merged
merged 3 commits into from
Sep 9, 2024
Merged

Impl macro rework #1314

merged 3 commits into from
Sep 9, 2024

Conversation

coolreader18
Copy link
Collaborator

Description of Changes

Please describe your change, mention any related tickets, and so on here.

Expected complexity level and risk

2

@cloutiertyler cloutiertyler added Do not merge Do not merge PRs with this label without coordinating further release-1.0 labels Jun 3, 2024
@coolreader18 coolreader18 force-pushed the noa/macro-rework branch 2 times, most recently from 41c4d18 to 972a7f8 Compare June 7, 2024 18:41
@coolreader18 coolreader18 marked this pull request as ready for review June 7, 2024 20:24
Comment on lines 820 to 949
macro_rules! special_reducer {
($(#[$attr:meta])* $name:ident = $reducer_name:literal) => {
#[proc_macro_attribute]
pub fn $name(args: StdTokenStream, item: StdTokenStream) -> StdTokenStream {
cvt_attr(args, item, quote!(), |args, original_function: ItemFn| {
syn::parse2::<Nothing>(args)?;
gen_reducer(original_function, $reducer_name, ReducerExtra::None)
})
}
};
}

if std::env::var("PROC_MACRO_DEBUG").is_ok() {
{
#![allow(clippy::disallowed_macros)]
println!("{}", output);
}
}
special_reducer!(
// TODO: doc
init = "__init__"
);

Ok(output)
}
special_reducer!(
// TODO: doc
connect = "__identity_connected__"
);

fn spacetimedb_special_reducer(name: &str, item: TokenStream) -> syn::Result<TokenStream> {
let original_function = syn::parse2::<ItemFn>(item)?;
gen_reducer(original_function, name, ReducerExtra::None)
}
special_reducer!(
// TODO: doc
disconnect = "__identity_disconnected__"
);

special_reducer!(
// TODO: doc
update = "__update__"
);
Copy link
Contributor

Choose a reason for hiding this comment

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

I found myself jumping back and forth between fn reducer and these, so please move these definitions after fn reducer. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have a follow up PR that reorganizes the module structure - that'll make it much less confusing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Happy to review that PR :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@coolreader18 coolreader18 force-pushed the noa/macro-rework branch 2 times, most recently from 2de1f2f to 7606ffa Compare June 12, 2024 19:03
Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

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

You have some doc test failures so you probably need an , ignore and then a tweak for the smoketests. Otherwise this looks very good!

@coolreader18 coolreader18 enabled auto-merge July 3, 2024 20:21
@coolreader18 coolreader18 disabled auto-merge July 3, 2024 20:21
@coolreader18 coolreader18 force-pushed the noa/macro-rework branch 2 times, most recently from c0aee9c to e7ddac4 Compare July 3, 2024 20:42
@Centril Centril force-pushed the noa/macro-rework branch 3 times, most recently from 30bdb2c to a7876e2 Compare July 4, 2024 15:17
@@ -225,7 +225,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)

public void Insert() {{
var bytes = SpacetimeDB.Runtime.Insert(tableId.Value, this);
// bytes should contain modified value now with autoinc fields updated
// bytes should contain modified value now with auto_inc fields updated
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a search-replace change? Probably shouldn't be necessary here and in the snapshots.

@coolreader18 coolreader18 force-pushed the noa/macro-rework branch 2 times, most recently from dd4123d to 2f53410 Compare September 9, 2024 19:50
@coolreader18 coolreader18 added this pull request to the merge queue Sep 9, 2024
Merged via the queue into master with commit 8daab8e Sep 9, 2024
7 checks passed
@coolreader18 coolreader18 deleted the noa/macro-rework branch September 10, 2024 15:45
@bfops bfops added the api-break A PR that makes an API breaking change label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-break A PR that makes an API breaking change Do not merge Do not merge PRs with this label without coordinating further release-0.12
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants