summaryrefslogtreecommitdiff
path: root/ops/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ops/lib.rs')
-rw-r--r--ops/lib.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/ops/lib.rs b/ops/lib.rs
index 971b0dfa0..598350167 100644
--- a/ops/lib.rs
+++ b/ops/lib.rs
@@ -386,7 +386,9 @@ fn codegen_arg(
let ident = quote::format_ident!("{name}");
let (pat, ty) = match arg {
syn::FnArg::Typed(pat) => {
- if is_optional_fast_callback_option(&pat.ty) {
+ if is_optional_fast_callback_option(&pat.ty)
+ || is_optional_wasm_memory(&pat.ty)
+ {
return quote! { let #ident = None; };
}
(&pat.pat, &pat.ty)
@@ -663,6 +665,10 @@ fn is_optional_fast_callback_option(ty: impl ToTokens) -> bool {
tokens(&ty).contains("Option < & mut FastApiCallbackOptions")
}
+fn is_optional_wasm_memory(ty: impl ToTokens) -> bool {
+ tokens(&ty).contains("Option < & mut [u8]")
+}
+
/// Detects if the type can be set using `rv.set_uint32` fast path
fn is_u32_rv(ty: impl ToTokens) -> bool {
["u32", "u8", "u16"].iter().any(|&s| tokens(&ty) == s) || is_resource_id(&ty)
@@ -743,6 +749,10 @@ mod tests {
if source.contains("// @test-attr:fast") {
attrs.must_be_fast = true;
}
+ if source.contains("// @test-attr:wasm") {
+ attrs.is_wasm = true;
+ attrs.must_be_fast = true;
+ }
let item = syn::parse_str(&source).expect("Failed to parse test file");
let op = Op::new(item, attrs);