1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

refactor: rewrite ext/io, ext/webstorage ops to op2 (#20461)

This commit is contained in:
Bartek Iwańczuk 2023-09-12 12:42:05 +02:00 committed by GitHub
parent 82c2864065
commit f32acb945e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 17 deletions

View file

@ -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;

View file

@ -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 };

View file

@ -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,