mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
refactor: rewrite ext/io, ext/webstorage ops to op2 (#20461)
This commit is contained in:
parent
82c2864065
commit
f32acb945e
3 changed files with 20 additions and 17 deletions
|
@ -365,7 +365,7 @@ async fn inspector_break_on_first_line() {
|
||||||
.await;
|
.await;
|
||||||
tester
|
tester
|
||||||
.assert_received_messages(
|
.assert_received_messages(
|
||||||
&[r#"{"id":4,"result":{"result":{"type":"undefined"}}}"#],
|
&[r#"{"id":4,"result":{"result":{"type":"object","subtype":"null","value":null}}}"#],
|
||||||
&[],
|
&[],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op2;
|
||||||
use deno_core::unsync::spawn_blocking;
|
use deno_core::unsync::spawn_blocking;
|
||||||
use deno_core::AsyncMutFuture;
|
use deno_core::AsyncMutFuture;
|
||||||
use deno_core::AsyncRefCell;
|
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
|
// override op_print to use the stdout and stderr in the resource table
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
pub fn op_print(
|
pub fn op_print(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
msg: &str,
|
#[string] msg: &str,
|
||||||
is_err: bool,
|
is_err: bool,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let rid = if is_err { 2 } else { 1 };
|
let rid = if is_err { 2 } else { 1 };
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::fmt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op2;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use rusqlite::params;
|
use rusqlite::params;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
|
@ -102,7 +102,7 @@ fn get_webstorage(
|
||||||
Ok(conn)
|
Ok(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
pub fn op_webstorage_length(
|
pub fn op_webstorage_length(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
|
@ -115,10 +115,11 @@ pub fn op_webstorage_length(
|
||||||
Ok(length)
|
Ok(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[string]
|
||||||
pub fn op_webstorage_key(
|
pub fn op_webstorage_key(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
index: u32,
|
#[smi] index: u32,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
) -> Result<Option<String>, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
let conn = get_webstorage(state, persistent)?;
|
let conn = get_webstorage(state, persistent)?;
|
||||||
|
@ -147,11 +148,11 @@ fn size_check(input: usize) -> Result<(), AnyError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
pub fn op_webstorage_set(
|
pub fn op_webstorage_set(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
key: &str,
|
#[string] key: &str,
|
||||||
value: &str,
|
#[string] value: &str,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let conn = get_webstorage(state, persistent)?;
|
let conn = get_webstorage(state, persistent)?;
|
||||||
|
@ -171,10 +172,11 @@ pub fn op_webstorage_set(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[string]
|
||||||
pub fn op_webstorage_get(
|
pub fn op_webstorage_get(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
key_name: String,
|
#[string] key_name: String,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
) -> Result<Option<String>, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
let conn = get_webstorage(state, persistent)?;
|
let conn = get_webstorage(state, persistent)?;
|
||||||
|
@ -187,10 +189,10 @@ pub fn op_webstorage_get(
|
||||||
Ok(val)
|
Ok(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
pub fn op_webstorage_remove(
|
pub fn op_webstorage_remove(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
key_name: &str,
|
#[string] key_name: &str,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let conn = get_webstorage(state, persistent)?;
|
let conn = get_webstorage(state, persistent)?;
|
||||||
|
@ -201,7 +203,7 @@ pub fn op_webstorage_remove(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
pub fn op_webstorage_clear(
|
pub fn op_webstorage_clear(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
|
@ -214,7 +216,8 @@ pub fn op_webstorage_clear(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
pub fn op_webstorage_iterate_keys(
|
pub fn op_webstorage_iterate_keys(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
|
|
Loading…
Reference in a new issue