-
Notifications
You must be signed in to change notification settings - Fork 177
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
Impl macro rework #1314
Conversation
41c4d18
to
972a7f8
Compare
crates/bindings-macro/src/lib.rs
Outdated
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__" | ||
); |
There was a problem hiding this comment.
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
. :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d678b83
to
9fa81ef
Compare
2de1f2f
to
7606ffa
Compare
There was a problem hiding this 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!
7606ffa
to
b8d3e77
Compare
c0aee9c
to
e7ddac4
Compare
30bdb2c
to
a7876e2
Compare
@@ -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 |
There was a problem hiding this comment.
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.
a7876e2
to
bfb0832
Compare
dd4123d
to
2f53410
Compare
2f53410
to
72a0243
Compare
72a0243
to
4071a5b
Compare
Description of Changes
Please describe your change, mention any related tickets, and so on here.
Expected complexity level and risk
2