summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-09-12 12:42:05 +0200
committerGitHub <noreply@github.com>2023-09-12 12:42:05 +0200
commitf32acb945e4f96b540c61705eb0d786fc4389d60 (patch)
treec5a286d5ded60971fc38638a205efbb3074f78f2
parent82c28640658df400e5bed2e208912247b1e83d0f (diff)
refactor: rewrite ext/io, ext/webstorage ops to op2 (#20461)
-rw-r--r--cli/tests/integration/inspector_tests.rs2
-rw-r--r--ext/io/lib.rs6
-rw-r--r--ext/webstorage/lib.rs29
3 files changed, 20 insertions, 17 deletions
diff --git a/cli/tests/integration/inspector_tests.rs b/cli/tests/integration/inspector_tests.rs
index 526efbdf2..e593c3b29 100644
--- a/cli/tests/integration/inspector_tests.rs
+++ b/cli/tests/integration/inspector_tests.rs
@@ -365,7 +365,7 @@ async fn inspector_break_on_first_line() {
.await;
tester
.assert_received_messages(
- &[r#"{"id":4,"result":{"result":{"type":"undefined"}}}"#],
+ &[r#"{"id":4,"result":{"result":{"type":"object","subtype":"null","value":null}}}"#],
&[],
)
.await;
diff --git a/ext/io/lib.rs b/ext/io/lib.rs
index 3d6ac0f37..eb26c495a 100644
--- a/ext/io/lib.rs
+++ b/ext/io/lib.rs
@@ -1,7 +1,7 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::error::AnyError;
-use deno_core::op;
+use deno_core::op2;
use deno_core::unsync::spawn_blocking;
use deno_core::AsyncMutFuture;
use deno_core::AsyncRefCell;
@@ -733,10 +733,10 @@ impl crate::fs::File for StdFileResourceInner {
}
// override op_print to use the stdout and stderr in the resource table
-#[op]
+#[op2(fast)]
pub fn op_print(
state: &mut OpState,
- msg: &str,
+ #[string] msg: &str,
is_err: bool,
) -> Result<(), AnyError> {
let rid = if is_err { 2 } else { 1 };
diff --git a/ext/webstorage/lib.rs b/ext/webstorage/lib.rs
index 10be072e8..5712dd38f 100644
--- a/ext/webstorage/lib.rs
+++ b/ext/webstorage/lib.rs
@@ -6,7 +6,7 @@ use std::fmt;
use std::path::PathBuf;
use deno_core::error::AnyError;
-use deno_core::op;
+use deno_core::op2;
use deno_core::OpState;
use rusqlite::params;
use rusqlite::Connection;
@@ -102,7 +102,7 @@ fn get_webstorage(
Ok(conn)
}
-#[op]
+#[op2(fast)]
pub fn op_webstorage_length(
state: &mut OpState,
persistent: bool,
@@ -115,10 +115,11 @@ pub fn op_webstorage_length(
Ok(length)
}
-#[op]
+#[op2]
+#[string]
pub fn op_webstorage_key(
state: &mut OpState,
- index: u32,
+ #[smi] index: u32,
persistent: bool,
) -> Result<Option<String>, AnyError> {
let conn = get_webstorage(state, persistent)?;
@@ -147,11 +148,11 @@ fn size_check(input: usize) -> Result<(), AnyError> {
Ok(())
}
-#[op]
+#[op2(fast)]
pub fn op_webstorage_set(
state: &mut OpState,
- key: &str,
- value: &str,
+ #[string] key: &str,
+ #[string] value: &str,
persistent: bool,
) -> Result<(), AnyError> {
let conn = get_webstorage(state, persistent)?;
@@ -171,10 +172,11 @@ pub fn op_webstorage_set(
Ok(())
}
-#[op]
+#[op2]
+#[string]
pub fn op_webstorage_get(
state: &mut OpState,
- key_name: String,
+ #[string] key_name: String,
persistent: bool,
) -> Result<Option<String>, AnyError> {
let conn = get_webstorage(state, persistent)?;
@@ -187,10 +189,10 @@ pub fn op_webstorage_get(
Ok(val)
}
-#[op]
+#[op2(fast)]
pub fn op_webstorage_remove(
state: &mut OpState,
- key_name: &str,
+ #[string] key_name: &str,
persistent: bool,
) -> Result<(), AnyError> {
let conn = get_webstorage(state, persistent)?;
@@ -201,7 +203,7 @@ pub fn op_webstorage_remove(
Ok(())
}
-#[op]
+#[op2(fast)]
pub fn op_webstorage_clear(
state: &mut OpState,
persistent: bool,
@@ -214,7 +216,8 @@ pub fn op_webstorage_clear(
Ok(())
}
-#[op]
+#[op2]
+#[serde]
pub fn op_webstorage_iterate_keys(
state: &mut OpState,
persistent: bool,