From 68851d6f371ce353d4313a17a4d0461f03061814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 23 Sep 2023 21:33:31 +0200 Subject: refactor: rewrite ops to op2 macro (#20628) Co-authored-by: Matt Mastracci --- ext/http/http_next.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'ext/http') diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs index c6e3ac384..08d3f54b1 100644 --- a/ext/http/http_next.rs +++ b/ext/http/http_next.rs @@ -25,7 +25,6 @@ use deno_core::error::AnyError; use deno_core::futures::TryFutureExt; use deno_core::op; use deno_core::op2; -use deno_core::serde_v8; use deno_core::serde_v8::from_v8; use deno_core::unsync::spawn; use deno_core::unsync::JoinHandle; @@ -229,11 +228,11 @@ pub fn op_http_set_promise_complete(#[smi] slab_id: SlabId, status: u16) { http.complete(); } -#[op(v8)] +#[op2] pub fn op_http_get_request_method_and_url<'scope, HTTP>( scope: &mut v8::HandleScope<'scope>, - slab_id: SlabId, -) -> serde_v8::Value<'scope> + #[smi] slab_id: SlabId, +) -> v8::Local<'scope, v8::Array> where HTTP: HttpPropertyExtractor, { @@ -290,10 +289,7 @@ where }; let vec = [method, authority, path, peer_address, port]; - let array = v8::Array::new_with_elements(scope, vec.as_slice()); - let array_value: v8::Local = array.into(); - - array_value.into() + v8::Array::new_with_elements(scope, vec.as_slice()) } #[op2] @@ -307,11 +303,11 @@ pub fn op_http_get_request_header( value.map(|value| value.as_bytes().into()) } -#[op(v8)] +#[op2] pub fn op_http_get_request_headers<'scope>( scope: &mut v8::HandleScope<'scope>, - slab_id: SlabId, -) -> serde_v8::Value<'scope> { + #[smi] slab_id: SlabId, +) -> v8::Local<'scope, v8::Array> { let http = slab_get(slab_id); let headers = &http.request_parts().headers; // Two slots for each header key/value pair @@ -372,16 +368,14 @@ pub fn op_http_get_request_headers<'scope>( ); } - let array = v8::Array::new_with_elements(scope, vec.as_slice()); - let array_value: v8::Local = array.into(); - - array_value.into() + v8::Array::new_with_elements(scope, vec.as_slice()) } -#[op(fast)] +#[op2(fast)] +#[smi] pub fn op_http_read_request_body( state: Rc>, - slab_id: SlabId, + #[smi] slab_id: SlabId, ) -> ResourceId { let mut http = slab_get(slab_id); let rid = if let Some(incoming) = http.take_body() { -- cgit v1.2.3