diff options
Diffstat (limited to 'ops/lib.rs')
-rw-r--r-- | ops/lib.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ops/lib.rs b/ops/lib.rs index 26fcb2a78..7fa800b14 100644 --- a/ops/lib.rs +++ b/ops/lib.rs @@ -193,7 +193,8 @@ fn codegen_v8_async( .inputs .iter() .map_while(|a| { - (if is_v8 { scope_arg(a) } else { None }).or_else(|| opstate_arg(a)) + (if is_v8 { scope_arg(a) } else { None }) + .or_else(|| rc_refcell_opstate_arg(a)) }) .collect::<Vec<_>>(); let rust_i0 = special_args.len(); @@ -291,6 +292,16 @@ fn opstate_arg(arg: &FnArg) -> Option<TokenStream2> { } } +fn rc_refcell_opstate_arg(arg: &FnArg) -> Option<TokenStream2> { + match arg { + arg if is_rc_refcell_opstate(arg) => Some(quote! { ctx.state.clone(), }), + arg if is_mut_ref_opstate(arg) => Some( + quote! { compile_error!("mutable opstate is not supported in async ops"), }, + ), + _ => None, + } +} + /// Generate the body of a v8 func for a sync op fn codegen_v8_sync( core: &TokenStream2, |