1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

feat(ops): custom arity (#13949)

Also cleanup & drop ignored wildcard op-args
This commit is contained in:
Aaron O'Mullan 2022-03-14 23:38:53 +01:00 committed by GitHub
parent 9f494dc405
commit 88d0f01948
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 99 additions and 498 deletions

View file

@ -244,7 +244,7 @@ jobs:
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: 7-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}
key: 8-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}
# In main branch, always creates fresh cache
- name: Cache build output (main)
@ -260,7 +260,7 @@ jobs:
!./target/*/*.zip
!./target/*/*.tar.gz
key: |
7-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }}
8-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }}
# Restore cache from the latest 'main' branch build.
- name: Cache build output (PR)
@ -276,7 +276,7 @@ jobs:
!./target/*/*.tar.gz
key: never_saved
restore-keys: |
7-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-
8-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-
# Don't save cache after building PRs or branches other than 'main'.
- name: Skip save cache (PR)

View file

@ -22,22 +22,18 @@ fn setup() -> Vec<Extension> {
}
#[op]
fn op_nop(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
fn op_nop(_: &mut OpState) -> Result<(), AnyError> {
Ok(())
}
#[op]
fn op_pi_json(_: &mut OpState, _: (), _: ()) -> Result<i64, AnyError> {
fn op_pi_json(_: &mut OpState) -> Result<i64, AnyError> {
Ok(314159)
}
// this is a function since async closures aren't stable
#[op]
async fn op_pi_async(
_: Rc<RefCell<OpState>>,
_: (),
_: (),
) -> Result<i64, AnyError> {
async fn op_pi_async(_: Rc<RefCell<OpState>>) -> Result<i64, AnyError> {
Ok(314159)
}

View file

@ -192,7 +192,6 @@ fn create_compiler_snapshot(
fn op_build_info(
state: &mut OpState,
_args: Value,
_: (),
) -> Result<Value, AnyError> {
let build_specifier = "asset:///bootstrap.ts";
let build_libs = state.borrow::<Vec<&str>>();
@ -203,31 +202,19 @@ fn create_compiler_snapshot(
}
#[op]
fn op_cwd(
_state: &mut OpState,
_args: Value,
_: (),
) -> Result<Value, AnyError> {
fn op_cwd(_state: &mut OpState, _args: Value) -> Result<Value, AnyError> {
Ok(json!("cache:///"))
}
#[op]
fn op_exists(
_state: &mut OpState,
_args: Value,
_: (),
) -> Result<Value, AnyError> {
fn op_exists(_state: &mut OpState, _args: Value) -> Result<Value, AnyError> {
Ok(json!(false))
}
#[op]
// using the same op that is used in `tsc.rs` for loading modules and reading
// files, but a slightly different implementation at build time.
fn op_load(
state: &mut OpState,
args: LoadArgs,
_: (),
) -> Result<Value, AnyError> {
fn op_load(state: &mut OpState, args: LoadArgs) -> Result<Value, AnyError> {
let op_crate_libs = state.borrow::<HashMap<&str, &str>>();
let path_dts = state.borrow::<PathBuf>();
let re_asset =

View file

@ -2515,7 +2515,6 @@ struct SourceSnapshotArgs {
fn op_dispose(
state: &mut OpState,
args: SourceSnapshotArgs,
_: (),
) -> Result<bool, AnyError> {
let state = state.borrow_mut::<State>();
let mark = state.performance.mark("op_dispose", Some(&args));
@ -2535,7 +2534,6 @@ struct SpecifierArgs {
fn op_exists(
state: &mut OpState,
args: SpecifierArgs,
_: (),
) -> Result<bool, AnyError> {
let state = state.borrow_mut::<State>();
// we don't measure the performance of op_exists anymore because as of TS 4.5
@ -2569,7 +2567,6 @@ struct GetChangeRangeArgs {
fn op_get_change_range(
state: &mut OpState,
args: GetChangeRangeArgs,
_: (),
) -> Result<Value, AnyError> {
let state = state.borrow_mut::<State>();
let mark = state.performance.mark("op_get_change_range", Some(&args));
@ -2616,7 +2613,6 @@ fn op_get_change_range(
fn op_get_length(
state: &mut OpState,
args: SourceSnapshotArgs,
_: (),
) -> Result<usize, AnyError> {
let state = state.borrow_mut::<State>();
let mark = state.performance.mark("op_get_length", Some(&args));
@ -2650,7 +2646,6 @@ struct GetTextArgs {
fn op_get_text(
state: &mut OpState,
args: GetTextArgs,
_: (),
) -> Result<String, AnyError> {
let state = state.borrow_mut::<State>();
let mark = state.performance.mark("op_get_text", Some(&args));
@ -2670,11 +2665,7 @@ fn op_get_text(
}
#[op]
fn op_is_cancelled(
state: &mut OpState,
_: (),
_: (),
) -> Result<bool, AnyError> {
fn op_is_cancelled(state: &mut OpState) -> Result<bool, AnyError> {
let state = state.borrow_mut::<State>();
Ok(state.token.is_cancelled())
}
@ -2683,7 +2674,6 @@ fn op_is_cancelled(
fn op_load(
state: &mut OpState,
args: SpecifierArgs,
_: (),
) -> Result<Option<String>, AnyError> {
let state = state.borrow_mut::<State>();
let mark = state.performance.mark("op_load", Some(&args));
@ -2697,7 +2687,6 @@ fn op_load(
fn op_resolve(
state: &mut OpState,
args: ResolveArgs,
_: (),
) -> Result<Vec<Option<(String, String)>>, AnyError> {
let state = state.borrow_mut::<State>();
let mark = state.performance.mark("op_resolve", Some(&args));
@ -2731,11 +2720,7 @@ fn op_resolve(
}
#[op]
fn op_respond(
state: &mut OpState,
args: Response,
_: (),
) -> Result<bool, AnyError> {
fn op_respond(state: &mut OpState, args: Response) -> Result<bool, AnyError> {
let state = state.borrow_mut::<State>();
state.response = Some(args);
Ok(true)
@ -2745,7 +2730,6 @@ fn op_respond(
fn op_script_names(
state: &mut OpState,
_args: Value,
_: (),
) -> Result<Vec<ModuleSpecifier>, AnyError> {
let state = state.borrow_mut::<State>();
Ok(
@ -2769,7 +2753,6 @@ struct ScriptVersionArgs {
fn op_script_version(
state: &mut OpState,
args: ScriptVersionArgs,
_: (),
) -> Result<Option<String>, AnyError> {
let state = state.borrow_mut::<State>();
// this op is very "noisy" and measuring its performance is not useful, so we
@ -3881,7 +3864,6 @@ mod tests {
SpecifierArgs {
specifier: "/error/unknown:something/index.d.ts".to_string(),
},
(),
);
assert!(actual.is_ok());
let actual = actual.unwrap();

View file

@ -35,7 +35,6 @@ struct PermissionsHolder(Uuid, Permissions);
pub fn op_pledge_test_permissions(
state: &mut OpState,
args: ChildPermissionsArg,
_: (),
) -> Result<Uuid, AnyError> {
let token = Uuid::new_v4();
let parent_permissions = state.borrow_mut::<Permissions>();
@ -54,7 +53,6 @@ pub fn op_pledge_test_permissions(
pub fn op_restore_test_permissions(
state: &mut OpState,
token: Uuid,
_: (),
) -> Result<(), AnyError> {
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
if token != permissions_holder.0 {
@ -70,11 +68,7 @@ pub fn op_restore_test_permissions(
}
#[op]
fn op_get_bench_origin(
state: &mut OpState,
_: (),
_: (),
) -> Result<String, AnyError> {
fn op_get_bench_origin(state: &mut OpState) -> Result<String, AnyError> {
Ok(state.borrow::<ModuleSpecifier>().to_string())
}
@ -82,7 +76,6 @@ fn op_get_bench_origin(
fn op_dispatch_bench_event(
state: &mut OpState,
event: BenchEvent,
_: (),
) -> Result<(), AnyError> {
let sender = state.borrow::<UnboundedSender<BenchEvent>>().clone();
sender.send(event).ok();
@ -91,7 +84,7 @@ fn op_dispatch_bench_event(
}
#[op]
fn op_bench_now(state: &mut OpState, _: (), _: ()) -> Result<u64, AnyError> {
fn op_bench_now(state: &mut OpState) -> Result<u64, AnyError> {
let ns = state.borrow::<time::Instant>().elapsed().as_nanos();
let ns_u64 = u64::try_from(ns)?;
Ok(ns_u64)

View file

@ -46,7 +46,6 @@ struct AppliedSourceMap {
fn op_apply_source_map(
state: &mut OpState,
args: ApplySourceMap,
_: (),
) -> Result<AppliedSourceMap, AnyError> {
let mut mappings_map: CachedMaps = HashMap::new();
let ps = state.borrow::<ProcState>().clone();
@ -71,7 +70,6 @@ fn op_apply_source_map(
fn op_format_diagnostic(
_state: &mut OpState,
args: Value,
_: (),
) -> Result<Value, AnyError> {
let diagnostic: Diagnostics = serde_json::from_value(args)?;
Ok(json!(diagnostic.to_string()))
@ -81,7 +79,6 @@ fn op_format_diagnostic(
fn op_format_file_name(
_state: &mut OpState,
file_name: String,
_: (),
) -> Result<String, AnyError> {
Ok(format_file_name(&file_name))
}

View file

@ -144,7 +144,6 @@ fn to_maybe_jsx_import_source_module(
async fn op_emit(
state: Rc<RefCell<OpState>>,
args: EmitArgs,
_: (),
) -> Result<EmitResult, AnyError> {
deno_runtime::ops::check_unstable2(&state, "Deno.emit");
let root_specifier = args.root_specifier;

View file

@ -33,7 +33,6 @@ struct PermissionsHolder(Uuid, Permissions);
pub fn op_pledge_test_permissions(
state: &mut OpState,
args: ChildPermissionsArg,
_: (),
) -> Result<Uuid, AnyError> {
let token = Uuid::new_v4();
let parent_permissions = state.borrow_mut::<Permissions>();
@ -52,7 +51,6 @@ pub fn op_pledge_test_permissions(
pub fn op_restore_test_permissions(
state: &mut OpState,
token: Uuid,
_: (),
) -> Result<(), AnyError> {
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
if token != permissions_holder.0 {
@ -68,11 +66,7 @@ pub fn op_restore_test_permissions(
}
#[op]
fn op_get_test_origin(
state: &mut OpState,
_: (),
_: (),
) -> Result<String, AnyError> {
fn op_get_test_origin(state: &mut OpState) -> Result<String, AnyError> {
Ok(state.borrow::<ModuleSpecifier>().to_string())
}
@ -80,7 +74,6 @@ fn op_get_test_origin(
fn op_dispatch_test_event(
state: &mut OpState,
event: TestEvent,
_: (),
) -> Result<(), AnyError> {
let sender = state.borrow::<UnboundedSender<TestEvent>>().clone();
sender.send(event).ok();

View file

@ -307,11 +307,7 @@ struct CreateHashArgs {
}
#[op]
fn op_create_hash(
s: &mut OpState,
args: Value,
_: (),
) -> Result<Value, AnyError> {
fn op_create_hash(s: &mut OpState, args: Value) -> Result<Value, AnyError> {
let state = s.borrow_mut::<State>();
let v: CreateHashArgs = serde_json::from_value(args)
.context("Invalid request from JavaScript for \"op_create_hash\".")?;
@ -322,7 +318,7 @@ fn op_create_hash(
}
#[op]
fn op_cwd(s: &mut OpState, _args: Value, _: ()) -> Result<String, AnyError> {
fn op_cwd(s: &mut OpState, _args: Value) -> Result<String, AnyError> {
let state = s.borrow_mut::<State>();
if let Some(config_specifier) = &state.maybe_config_specifier {
let cwd = config_specifier.join("./")?;
@ -347,11 +343,7 @@ struct EmitArgs {
}
#[op]
fn op_emit(
state: &mut OpState,
args: EmitArgs,
_: (),
) -> Result<Value, AnyError> {
fn op_emit(state: &mut OpState, args: EmitArgs) -> Result<Value, AnyError> {
let state = state.borrow_mut::<State>();
match args.file_name.as_ref() {
"deno:///.tsbuildinfo" => state.maybe_tsbuildinfo = Some(args.data),
@ -406,11 +398,7 @@ struct ExistsArgs {
}
#[op]
fn op_exists(
state: &mut OpState,
args: ExistsArgs,
_: (),
) -> Result<bool, AnyError> {
fn op_exists(state: &mut OpState, args: ExistsArgs) -> Result<bool, AnyError> {
let state = state.borrow_mut::<State>();
let graph_data = state.graph_data.read();
if let Ok(specifier) = normalize_specifier(&args.specifier) {
@ -452,7 +440,7 @@ fn as_ts_script_kind(media_type: &MediaType) -> i32 {
}
#[op]
fn op_load(state: &mut OpState, args: Value, _: ()) -> Result<Value, AnyError> {
fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
let state = state.borrow_mut::<State>();
let v: LoadArgs = serde_json::from_value(args)
.context("Invalid request from JavaScript for \"op_load\".")?;
@ -521,7 +509,6 @@ pub struct ResolveArgs {
fn op_resolve(
state: &mut OpState,
args: ResolveArgs,
_: (),
) -> Result<Value, AnyError> {
let state = state.borrow_mut::<State>();
let mut resolved: Vec<(String, String)> = Vec::new();
@ -629,11 +616,7 @@ struct RespondArgs {
}
#[op]
fn op_respond(
state: &mut OpState,
args: Value,
_: (),
) -> Result<Value, AnyError> {
fn op_respond(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
let state = state.borrow_mut::<State>();
let v: RespondArgs = serde_json::from_value(args)
.context("Error converting the result for \"op_respond\".")?;
@ -881,7 +864,6 @@ mod tests {
let actual = op_create_hash::call(
&mut state,
json!({ "data": "some sort of content" }),
(),
)
.expect("could not invoke op");
assert_eq!(
@ -934,7 +916,6 @@ mod tests {
file_name: "cache:///some/file.js".to_string(),
maybe_specifiers: Some(vec!["file:///some/file.ts".to_string()]),
},
(),
)
.expect("should have invoked op");
assert_eq!(actual, json!(true));
@ -966,7 +947,6 @@ mod tests {
vec!["file:///some/file.ts?q=.json".to_string()],
),
},
(),
)
.expect("should have invoked op");
assert_eq!(actual, json!(true));
@ -996,7 +976,6 @@ mod tests {
file_name: "deno:///.tsbuildinfo".to_string(),
maybe_specifiers: None,
},
(),
)
.expect("should have invoked op");
assert_eq!(actual, json!(true));
@ -1019,7 +998,6 @@ mod tests {
let actual = op_load::call(
&mut state,
json!({ "specifier": "https://deno.land/x/mod.ts"}),
(),
)
.expect("should have invoked op");
assert_eq!(
@ -1051,7 +1029,6 @@ mod tests {
let value = op_load::call(
&mut state,
json!({ "specifier": "asset:///lib.dom.d.ts" }),
(),
)
.expect("should have invoked op");
let actual: LoadResponse =
@ -1070,12 +1047,9 @@ mod tests {
Some("some content".to_string()),
)
.await;
let actual = op_load::call(
&mut state,
json!({ "specifier": "deno:///.tsbuildinfo"}),
(),
)
.expect("should have invoked op");
let actual =
op_load::call(&mut state, json!({ "specifier": "deno:///.tsbuildinfo"}))
.expect("should have invoked op");
assert_eq!(
actual,
json!({
@ -1092,7 +1066,6 @@ mod tests {
let actual = op_load::call(
&mut state,
json!({ "specifier": "https://deno.land/x/mod.ts"}),
(),
)
.expect("should have invoked op");
assert_eq!(
@ -1119,7 +1092,6 @@ mod tests {
base: "https://deno.land/x/a.ts".to_string(),
specifiers: vec!["./b.ts".to_string()],
},
(),
)
.expect("should have invoked op");
assert_eq!(actual, json!([["https://deno.land/x/b.ts", ".ts"]]));
@ -1139,7 +1111,6 @@ mod tests {
base: "https://deno.land/x/a.ts".to_string(),
specifiers: vec!["./bad.ts".to_string()],
},
(),
)
.expect("should have not errored");
assert_eq!(
@ -1163,7 +1134,6 @@ mod tests {
],
"stats": [["a", 12]]
}),
(),
)
.expect("should have invoked op");
assert_eq!(actual, json!(true));

View file

@ -17,7 +17,6 @@ use deno_core::*;
fn op_sum(
_state: &mut OpState,
nums: Vec<f64>,
_: (),
) -> Result<f64, deno_core::error::AnyError> {
// Sum inputs
let sum = nums.iter().fold(0.0, |a, v| a + v);

View file

@ -135,7 +135,7 @@ fn create_js_runtime() -> JsRuntime {
}
#[op]
fn op_listen(state: &mut OpState, _: (), _: ()) -> Result<ResourceId, Error> {
fn op_listen(state: &mut OpState) -> Result<ResourceId, Error> {
log::debug!("listen");
let addr = "127.0.0.1:4544".parse::<SocketAddr>().unwrap();
let std_listener = std::net::TcpListener::bind(&addr)?;
@ -149,7 +149,6 @@ fn op_listen(state: &mut OpState, _: (), _: ()) -> Result<ResourceId, Error> {
async fn op_accept(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<ResourceId, Error> {
log::debug!("accept rid={}", rid);

View file

@ -62,7 +62,7 @@ fn main() {
}
#[op]
fn op_schedule_task(state: &mut OpState, i: u8, _: ()) -> Result<(), Error> {
fn op_schedule_task(state: &mut OpState, i: u8) -> Result<(), Error> {
let tx = state.borrow_mut::<mpsc::UnboundedSender<Task>>();
tx.unbounded_send(Box::new(move || println!("Hello, world! x{}", i)))
.expect("unbounded_send failed");

View file

@ -1406,7 +1406,7 @@ import "/a.js";
static DISPATCH_COUNT: AtomicUsize = AtomicUsize::new(0);
#[op]
fn op_test(_: &mut OpState, control: u8, _: ()) -> Result<u8, AnyError> {
fn op_test(_: &mut OpState, control: u8) -> Result<u8, AnyError> {
DISPATCH_COUNT.fetch_add(1, Ordering::Relaxed);
assert_eq!(control, 42);
Ok(43)

View file

@ -40,7 +40,7 @@ pub(crate) fn init_builtins() -> Extension {
}
#[op]
pub fn void_op_sync(_: &mut OpState, _: (), _: ()) -> Result<(), Error> {
pub fn void_op_sync(_: &mut OpState) -> Result<(), Error> {
Ok(())
}
@ -57,8 +57,6 @@ pub async fn void_op_async(
#[op]
pub fn op_resources(
state: &mut OpState,
_: (),
_: (),
) -> Result<Vec<(ResourceId, String)>, Error> {
let serialized_resources = state
.resource_table
@ -69,16 +67,12 @@ pub fn op_resources(
}
#[op]
pub fn op_void_sync(_state: &mut OpState, _: (), _: ()) -> Result<(), Error> {
pub fn op_void_sync(_state: &mut OpState) -> Result<(), Error> {
Ok(())
}
#[op]
pub async fn op_void_async(
_state: Rc<RefCell<OpState>>,
_: (),
_: (),
) -> Result<(), Error> {
pub async fn op_void_async(_state: Rc<RefCell<OpState>>) -> Result<(), Error> {
Ok(())
}
@ -87,7 +81,6 @@ pub async fn op_void_async(
pub fn op_close(
state: &mut OpState,
rid: Option<ResourceId>,
_: (),
) -> Result<(), Error> {
// TODO(@AaronO): drop Option after improving type-strictness balance in
// serde_v8
@ -102,7 +95,6 @@ pub fn op_close(
pub fn op_try_close(
state: &mut OpState,
rid: Option<ResourceId>,
_: (),
) -> Result<(), Error> {
// TODO(@AaronO): drop Option after improving type-strictness balance in
// serde_v8.
@ -114,8 +106,6 @@ pub fn op_try_close(
#[op]
pub fn op_metrics(
state: &mut OpState,
_: (),
_: (),
) -> Result<(OpMetrics, Vec<OpMetrics>), Error> {
let aggregate = state.tracker.aggregate();
let per_op = state.tracker.per_op();
@ -229,7 +219,6 @@ async fn op_write(
async fn op_shutdown(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<(), Error> {
let resource = state.borrow().resource_table.get_any(rid)?;
resource.shutdown().await

View file

@ -2062,7 +2062,7 @@ pub mod tests {
#[test]
fn test_error_builder() {
#[op]
fn op_err(_: &mut OpState, _: (), _: ()) -> Result<(), Error> {
fn op_err(_: &mut OpState) -> Result<(), Error> {
Err(custom_error("DOMExceptionOperationError", "abc"))
}
@ -2468,8 +2468,6 @@ assertEquals(1, notify_return_value);
#[op]
async fn op_async_borrow(
op_state: Rc<RefCell<OpState>>,
_: (),
_: (),
) -> Result<(), Error> {
let n = {
let op_state = op_state.borrow();
@ -2511,8 +2509,6 @@ assertEquals(1, notify_return_value);
#[op]
async fn op_async_sleep(
_op_state: Rc<RefCell<OpState>>,
_: (),
_: (),
) -> Result<(), Error> {
// Future must be Poll::Pending on first call
tokio::time::sleep(std::time::Duration::from_millis(1)).await;
@ -2588,13 +2584,13 @@ assertEquals(1, notify_return_value);
static NEXT_TICK: AtomicUsize = AtomicUsize::new(0);
#[op]
fn op_macrotask(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
fn op_macrotask(_: &mut OpState) -> Result<(), AnyError> {
MACROTASK.fetch_add(1, Ordering::Relaxed);
Ok(())
}
#[op]
fn op_next_tick(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
fn op_next_tick(_: &mut OpState) -> Result<(), AnyError> {
NEXT_TICK.fetch_add(1, Ordering::Relaxed);
Ok(())
}
@ -2725,21 +2721,13 @@ assertEquals(1, notify_return_value);
static UNCAUGHT_EXCEPTION: AtomicUsize = AtomicUsize::new(0);
#[op]
fn op_promise_reject(
_: &mut OpState,
_: (),
_: (),
) -> Result<(), AnyError> {
fn op_promise_reject(_: &mut OpState) -> Result<(), AnyError> {
PROMISE_REJECT.fetch_add(1, Ordering::Relaxed);
Ok(())
}
#[op]
fn op_uncaught_exception(
_: &mut OpState,
_: (),
_: (),
) -> Result<(), AnyError> {
fn op_uncaught_exception(_: &mut OpState) -> Result<(), AnyError> {
UNCAUGHT_EXCEPTION.fetch_add(1, Ordering::Relaxed);
Ok(())
}

View file

@ -45,8 +45,6 @@ struct Unstable(bool); // --unstable
#[op]
pub fn op_broadcast_subscribe<BC>(
state: &mut OpState,
_: (),
_: (),
) -> Result<ResourceId, AnyError>
where
BC: BroadcastChannel + 'static,
@ -97,7 +95,6 @@ where
pub async fn op_broadcast_recv<BC>(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<Option<Message>, AnyError>
where
BC: BroadcastChannel + 'static,

View file

@ -46,7 +46,6 @@ pub enum GenerateKeyOptions {
pub async fn op_crypto_generate_key(
_state: Rc<RefCell<OpState>>,
opts: GenerateKeyOptions,
_: (),
) -> Result<ZeroCopyBuf, AnyError> {
let fun = || match opts {
GenerateKeyOptions::Rsa {

View file

@ -115,7 +115,6 @@ pub fn init(maybe_seed: Option<u64>) -> Extension {
pub fn op_crypto_get_random_values(
state: &mut OpState,
mut zero_copy: ZeroCopyBuf,
_: (),
) -> Result<(), AnyError> {
if zero_copy.len() > 65536 {
return Err(
@ -791,11 +790,7 @@ impl<'a> TryFrom<rsa::pkcs8::der::asn1::Any<'a>>
}
#[op]
pub fn op_crypto_random_uuid(
state: &mut OpState,
_: (),
_: (),
) -> Result<String, AnyError> {
pub fn op_crypto_random_uuid(state: &mut OpState) -> Result<String, AnyError> {
let maybe_seeded_rng = state.try_borrow_mut::<StdRng>();
let uuid = if let Some(seeded_rng) = maybe_seeded_rng {
let mut bytes = [0u8; 16];

View file

@ -369,7 +369,6 @@ pub struct FetchResponse {
pub async fn op_fetch_send(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<FetchResponse, AnyError> {
let request = state
.borrow_mut()
@ -528,7 +527,6 @@ pub struct CreateHttpClientOptions {
pub fn op_fetch_custom_client<FP>(
state: &mut OpState,
args: CreateHttpClientOptions,
_: (),
) -> Result<ResourceId, AnyError>
where
FP: FetchPermissions + 'static,

View file

@ -465,7 +465,6 @@ pub(crate) fn format_error(e: dlopen::Error, path: String) -> String {
fn op_ffi_load<FP>(
state: &mut deno_core::OpState,
args: FfiLoadArgs,
_: (),
) -> Result<ResourceId, AnyError>
where
FP: FfiPermissions + 'static,
@ -652,7 +651,6 @@ fn ffi_call(args: FfiCallArgs, symbol: &Symbol) -> Result<Value, AnyError> {
fn op_ffi_call_ptr(
_state: &mut deno_core::OpState,
args: FfiCallPtrArgs,
_: (),
) -> Result<Value, AnyError> {
let symbol = args.get_symbol();
ffi_call(args.into(), &symbol)
@ -662,7 +660,6 @@ fn op_ffi_call_ptr(
async fn op_ffi_call_ptr_nonblocking(
_state: Rc<RefCell<deno_core::OpState>>,
args: FfiCallPtrArgs,
_: (),
) -> Result<Value, AnyError> {
let symbol = args.get_symbol();
tokio::task::spawn_blocking(move || ffi_call(args.into(), &symbol))
@ -682,7 +679,6 @@ struct FfiGetArgs {
fn op_ffi_get_static(
state: &mut deno_core::OpState,
args: FfiGetArgs,
_: (),
) -> Result<Value, AnyError> {
let resource = state
.resource_table
@ -740,7 +736,6 @@ fn op_ffi_get_static(
fn op_ffi_call(
state: &mut deno_core::OpState,
args: FfiCallArgs,
_: (),
) -> Result<Value, AnyError> {
let resource = state
.resource_table
@ -759,7 +754,6 @@ fn op_ffi_call(
async fn op_ffi_call_nonblocking(
state: Rc<RefCell<deno_core::OpState>>,
args: FfiCallArgs,
_: (),
) -> Result<Value, AnyError> {
let resource = state
.borrow()
@ -780,7 +774,6 @@ async fn op_ffi_call_nonblocking(
fn op_ffi_ptr_of<FP>(
state: &mut deno_core::OpState,
buf: ZeroCopyBuf,
_: (),
) -> Result<U32x2, AnyError>
where
FP: FfiPermissions + 'static,
@ -795,7 +788,6 @@ where
fn op_ffi_buf_copy_into<FP>(
state: &mut deno_core::OpState,
(src, mut dst, len): (U32x2, ZeroCopyBuf, usize),
_: (),
) -> Result<(), AnyError>
where
FP: FfiPermissions + 'static,
@ -818,7 +810,6 @@ where
fn op_ffi_cstr_read<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<String, AnyError>
where
FP: FfiPermissions + 'static,
@ -834,7 +825,6 @@ where
fn op_ffi_read_u8<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<u8, AnyError>
where
FP: FfiPermissions + 'static,
@ -849,7 +839,6 @@ where
fn op_ffi_read_i8<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<i8, AnyError>
where
FP: FfiPermissions + 'static,
@ -864,7 +853,6 @@ where
fn op_ffi_read_u16<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<u16, AnyError>
where
FP: FfiPermissions + 'static,
@ -879,7 +867,6 @@ where
fn op_ffi_read_i16<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<i16, AnyError>
where
FP: FfiPermissions + 'static,
@ -894,7 +881,6 @@ where
fn op_ffi_read_u32<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<u32, AnyError>
where
FP: FfiPermissions + 'static,
@ -909,7 +895,6 @@ where
fn op_ffi_read_i32<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<i32, AnyError>
where
FP: FfiPermissions + 'static,
@ -924,7 +909,6 @@ where
fn op_ffi_read_u64<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<U32x2, AnyError>
where
FP: FfiPermissions + 'static,
@ -941,7 +925,6 @@ where
fn op_ffi_read_f32<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<f32, AnyError>
where
FP: FfiPermissions + 'static,
@ -956,7 +939,6 @@ where
fn op_ffi_read_f64<FP>(
state: &mut deno_core::OpState,
ptr: U32x2,
_: (),
) -> Result<f64, AnyError>
where
FP: FfiPermissions + 'static,

View file

@ -369,7 +369,6 @@ struct NextRequestResponse(
async fn op_http_accept(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<Option<NextRequestResponse>, AnyError> {
let conn = state.borrow().resource_table.get::<HttpConnResource>(rid)?;
@ -738,7 +737,6 @@ async fn op_http_write(
async fn op_http_shutdown(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<(), AnyError> {
let stream = state
.borrow()
@ -802,7 +800,6 @@ async fn op_http_read(
fn op_http_websocket_accept_header(
_: &mut OpState,
key: String,
_: (),
) -> Result<String, AnyError> {
let digest = ring::digest::digest(
&ring::digest::SHA1_FOR_LEGACY_USE_ONLY,
@ -815,7 +812,6 @@ fn op_http_websocket_accept_header(
async fn op_http_upgrade_websocket(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<ResourceId, AnyError> {
let stream = state
.borrow_mut()

View file

@ -162,7 +162,6 @@ async fn accept_tcp(
async fn op_net_accept(
state: Rc<RefCell<OpState>>,
args: AcceptArgs,
_: (),
) -> Result<OpConn, AnyError> {
match args.transport.as_str() {
"tcp" => accept_tcp(state, args, ()).await,
@ -306,7 +305,6 @@ pub struct ConnectArgs {
pub async fn op_net_connect<NP>(
state: Rc<RefCell<OpState>>,
args: ConnectArgs,
_: (),
) -> Result<OpConn, AnyError>
where
NP: NetPermissions + 'static,
@ -482,7 +480,6 @@ fn listen_udp(
fn op_net_listen<NP>(
state: &mut OpState,
args: ListenArgs,
_: (),
) -> Result<OpConn, AnyError>
where
NP: NetPermissions + 'static,
@ -622,7 +619,6 @@ pub struct NameServer {
pub async fn op_dns_resolve<NP>(
state: Rc<RefCell<OpState>>,
args: ResolveAddrArgs,
_: (),
) -> Result<Vec<DnsReturnRecord>, AnyError>
where
NP: NetPermissions + 'static,
@ -942,7 +938,7 @@ mod tests {
};
let connect_fut =
op_net_connect::call::<TestPermission>(conn_state, connect_args, ());
op_net_connect::call::<TestPermission>(conn_state, connect_args);
let conn = connect_fut.await.unwrap();
let rid = conn.rid;

View file

@ -769,7 +769,6 @@ pub struct StartTlsArgs {
pub async fn op_tls_start<NP>(
state: Rc<RefCell<OpState>>,
args: StartTlsArgs,
_: (),
) -> Result<OpConn, AnyError>
where
NP: NetPermissions + 'static,
@ -862,7 +861,6 @@ where
pub async fn op_tls_connect<NP>(
state: Rc<RefCell<OpState>>,
args: ConnectTlsArgs,
_: (),
) -> Result<OpConn, AnyError>
where
NP: NetPermissions + 'static,
@ -1022,7 +1020,6 @@ pub struct ListenTlsArgs {
pub fn op_tls_listen<NP>(
state: &mut OpState,
args: ListenTlsArgs,
_: (),
) -> Result<OpConn, AnyError>
where
NP: NetPermissions + 'static,
@ -1119,7 +1116,6 @@ where
pub async fn op_tls_accept(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<OpConn, AnyError> {
let resource = state
.borrow()
@ -1171,7 +1167,6 @@ pub async fn op_tls_accept(
pub async fn op_tls_handshake(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<TlsHandshakeInfo, AnyError> {
let resource = state
.borrow()

View file

@ -184,7 +184,6 @@ pub fn op_url_parse_search_params(
pub fn op_url_stringify_search_params(
_state: &mut deno_core::OpState,
args: Vec<(String, String)>,
_: (),
) -> Result<String, AnyError> {
let search = form_urlencoded::Serializer::new(String::new())
.extend_pairs(args)

View file

@ -163,7 +163,6 @@ impl BlobPart for SlicedBlobPart {
pub fn op_blob_create_part(
state: &mut deno_core::OpState,
data: ZeroCopyBuf,
_: (),
) -> Result<Uuid, AnyError> {
let blob_store = state.borrow::<BlobStore>();
let part = InMemoryBlobPart(data.to_vec());
@ -208,7 +207,6 @@ pub fn op_blob_slice_part(
pub async fn op_blob_read_part(
state: Rc<RefCell<deno_core::OpState>>,
id: Uuid,
_: (),
) -> Result<ZeroCopyBuf, AnyError> {
let part = {
let state = state.borrow();
@ -224,7 +222,6 @@ pub async fn op_blob_read_part(
pub fn op_blob_remove_part(
state: &mut deno_core::OpState,
id: Uuid,
_: (),
) -> Result<(), AnyError> {
let blob_store = state.borrow::<BlobStore>();
blob_store.remove_part(&id);
@ -261,7 +258,6 @@ pub fn op_blob_create_object_url(
pub fn op_blob_revoke_object_url(
state: &mut deno_core::OpState,
url: String,
_: (),
) -> Result<(), AnyError> {
let url = Url::parse(&url)?;
let blob_store = state.borrow::<BlobStore>();
@ -285,7 +281,6 @@ pub struct ReturnBlobPart {
pub fn op_blob_from_object_url(
state: &mut deno_core::OpState,
url: String,
_: (),
) -> Result<Option<ReturnBlob>, AnyError> {
let url = Url::parse(&url)?;
if url.scheme() != "blob" {

View file

@ -93,7 +93,6 @@ pub fn op_compression_write(
pub fn op_compression_finish(
state: &mut OpState,
rid: ResourceId,
_: (),
) -> Result<ZeroCopyBuf, AnyError> {
let resource = state.resource_table.take::<CompressionResource>(rid)?;
let resource = Rc::try_unwrap(resource).unwrap();

View file

@ -123,7 +123,6 @@ pub fn init<P: TimersPermission + 'static>(
fn op_base64_decode(
_: &mut OpState,
input: String,
_: (),
) -> Result<ZeroCopyBuf, AnyError> {
let mut input = input.into_bytes();
input.retain(|c| !c.is_ascii_whitespace());
@ -134,7 +133,6 @@ fn op_base64_decode(
fn op_base64_atob(
_: &mut OpState,
s: ByteString,
_: (),
) -> Result<ByteString, AnyError> {
let mut s = s.0;
s.retain(|c| !c.is_ascii_whitespace());
@ -188,17 +186,12 @@ fn b64_decode(input: &[u8]) -> Result<Vec<u8>, AnyError> {
fn op_base64_encode(
_: &mut OpState,
s: ZeroCopyBuf,
_: (),
) -> Result<String, AnyError> {
Ok(b64_encode(&s))
}
#[op]
fn op_base64_btoa(
_: &mut OpState,
s: ByteString,
_: (),
) -> Result<String, AnyError> {
fn op_base64_btoa(_: &mut OpState, s: ByteString) -> Result<String, AnyError> {
Ok(b64_encode(&s))
}
@ -220,7 +213,6 @@ struct DecoderOptions {
fn op_encoding_normalize_label(
_state: &mut OpState,
label: String,
_: (),
) -> Result<String, AnyError> {
let encoding = Encoding::for_label_no_replacement(label.as_bytes())
.ok_or_else(|| {
@ -236,7 +228,6 @@ fn op_encoding_normalize_label(
fn op_encoding_new_decoder(
state: &mut OpState,
options: DecoderOptions,
_: (),
) -> Result<ResourceId, AnyError> {
let DecoderOptions {
label,

View file

@ -109,8 +109,6 @@ impl Resource for MessagePortResource {
#[op]
pub fn op_message_port_create_entangled(
state: &mut OpState,
_: (),
_: (),
) -> Result<(ResourceId, ResourceId), AnyError> {
let (port1, port2) = create_entangled_message_port();
@ -211,7 +209,6 @@ pub fn op_message_port_post_message(
pub async fn op_message_port_recv_message(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<Option<JsMessageData>, AnyError> {
let resource = {
let state = state.borrow();

View file

@ -28,11 +28,7 @@ pub type StartTime = Instant;
// If the High precision flag is not set, the
// nanoseconds are rounded on 2ms.
#[op]
pub fn op_now<TP>(
state: &mut OpState,
_argument: (),
_: (),
) -> Result<f64, AnyError>
pub fn op_now<TP>(state: &mut OpState, _argument: ()) -> Result<f64, AnyError>
where
TP: TimersPermission + 'static,
{
@ -68,11 +64,7 @@ impl Resource for TimerHandle {
/// Creates a [`TimerHandle`] resource that can be used to cancel invocations of
/// [`op_sleep`].
#[op]
pub fn op_timer_handle(
state: &mut OpState,
_: (),
_: (),
) -> Result<ResourceId, AnyError> {
pub fn op_timer_handle(state: &mut OpState) -> Result<ResourceId, AnyError> {
let rid = state
.resource_table
.add(TimerHandle(CancelHandle::new_rc()));
@ -98,7 +90,6 @@ pub async fn op_sleep(
pub fn op_sleep_sync<TP>(
state: &mut OpState,
millis: u64,
_: (),
) -> Result<(), AnyError>
where
TP: TimersPermission + 'static,

View file

@ -182,7 +182,6 @@ pub struct CreateBindGroupLayoutArgs {
pub fn op_webgpu_create_bind_group_layout(
state: &mut OpState,
args: CreateBindGroupLayoutArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@ -226,7 +225,6 @@ pub struct CreatePipelineLayoutArgs {
pub fn op_webgpu_create_pipeline_layout(
state: &mut OpState,
args: CreatePipelineLayoutArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@ -278,7 +276,6 @@ pub struct CreateBindGroupArgs {
pub fn op_webgpu_create_bind_group(
state: &mut OpState,
args: CreateBindGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state

View file

@ -46,7 +46,6 @@ pub struct CreateBufferArgs {
pub fn op_webgpu_create_buffer(
state: &mut OpState,
args: CreateBufferArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@ -83,7 +82,6 @@ pub struct BufferGetMapAsyncArgs {
pub async fn op_webgpu_buffer_get_map_async(
state: Rc<RefCell<OpState>>,
args: BufferGetMapAsyncArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let (sender, receiver) = oneshot::channel::<Result<(), AnyError>>();

View file

@ -44,7 +44,6 @@ pub struct CreateRenderBundleEncoderArgs {
pub fn op_webgpu_create_render_bundle_encoder(
state: &mut OpState,
args: CreateRenderBundleEncoderArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let device_resource = state
.resource_table
@ -105,7 +104,6 @@ pub struct RenderBundleEncoderFinishArgs {
pub fn op_webgpu_render_bundle_encoder_finish(
state: &mut OpState,
args: RenderBundleEncoderFinishArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_bundle_encoder_resource =
state
@ -142,7 +140,6 @@ pub struct RenderBundleEncoderSetBindGroupArgs {
pub fn op_webgpu_render_bundle_encoder_set_bind_group(
state: &mut OpState,
args: RenderBundleEncoderSetBindGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let bind_group_resource =
state
@ -197,7 +194,6 @@ pub struct RenderBundleEncoderPushDebugGroupArgs {
pub fn op_webgpu_render_bundle_encoder_push_debug_group(
state: &mut OpState,
args: RenderBundleEncoderPushDebugGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_bundle_encoder_resource =
state
@ -227,7 +223,6 @@ pub struct RenderBundleEncoderPopDebugGroupArgs {
pub fn op_webgpu_render_bundle_encoder_pop_debug_group(
state: &mut OpState,
args: RenderBundleEncoderPopDebugGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_bundle_encoder_resource =
state
@ -252,7 +247,6 @@ pub struct RenderBundleEncoderInsertDebugMarkerArgs {
pub fn op_webgpu_render_bundle_encoder_insert_debug_marker(
state: &mut OpState,
args: RenderBundleEncoderInsertDebugMarkerArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_bundle_encoder_resource =
state
@ -283,7 +277,6 @@ pub struct RenderBundleEncoderSetPipelineArgs {
pub fn op_webgpu_render_bundle_encoder_set_pipeline(
state: &mut OpState,
args: RenderBundleEncoderSetPipelineArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pipeline_resource =
state
@ -316,7 +309,6 @@ pub struct RenderBundleEncoderSetIndexBufferArgs {
pub fn op_webgpu_render_bundle_encoder_set_index_buffer(
state: &mut OpState,
args: RenderBundleEncoderSetIndexBufferArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let buffer_resource = state
.resource_table
@ -353,7 +345,6 @@ pub struct RenderBundleEncoderSetVertexBufferArgs {
pub fn op_webgpu_render_bundle_encoder_set_vertex_buffer(
state: &mut OpState,
args: RenderBundleEncoderSetVertexBufferArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let buffer_resource = state
.resource_table
@ -388,7 +379,6 @@ pub struct RenderBundleEncoderDrawArgs {
pub fn op_webgpu_render_bundle_encoder_draw(
state: &mut OpState,
args: RenderBundleEncoderDrawArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_bundle_encoder_resource =
state
@ -421,7 +411,6 @@ pub struct RenderBundleEncoderDrawIndexedArgs {
pub fn op_webgpu_render_bundle_encoder_draw_indexed(
state: &mut OpState,
args: RenderBundleEncoderDrawIndexedArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_bundle_encoder_resource =
state
@ -452,7 +441,6 @@ pub struct RenderBundleEncoderDrawIndirectArgs {
pub fn op_webgpu_render_bundle_encoder_draw_indirect(
state: &mut OpState,
args: RenderBundleEncoderDrawIndirectArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let buffer_resource = state
.resource_table

View file

@ -41,7 +41,6 @@ pub struct CreateCommandEncoderArgs {
pub fn op_webgpu_create_command_encoder(
state: &mut OpState,
args: CreateCommandEncoderArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@ -102,7 +101,6 @@ pub struct CommandEncoderBeginRenderPassArgs {
pub fn op_webgpu_command_encoder_begin_render_pass(
state: &mut OpState,
args: CommandEncoderBeginRenderPassArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let command_encoder_resource = state
.resource_table
@ -221,7 +219,6 @@ pub struct CommandEncoderBeginComputePassArgs {
pub fn op_webgpu_command_encoder_begin_compute_pass(
state: &mut OpState,
args: CommandEncoderBeginComputePassArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let command_encoder_resource = state
.resource_table
@ -260,7 +257,6 @@ pub struct CommandEncoderCopyBufferToBufferArgs {
pub fn op_webgpu_command_encoder_copy_buffer_to_buffer(
state: &mut OpState,
args: CommandEncoderCopyBufferToBufferArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -319,7 +315,6 @@ pub struct CommandEncoderCopyBufferToTextureArgs {
pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
state: &mut OpState,
args: CommandEncoderCopyBufferToTextureArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -370,7 +365,6 @@ pub struct CommandEncoderCopyTextureToBufferArgs {
pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
state: &mut OpState,
args: CommandEncoderCopyTextureToBufferArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -425,7 +419,6 @@ pub struct CommandEncoderCopyTextureToTextureArgs {
pub fn op_webgpu_command_encoder_copy_texture_to_texture(
state: &mut OpState,
args: CommandEncoderCopyTextureToTextureArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -474,7 +467,6 @@ pub struct CommandEncoderClearBufferArgs {
pub fn op_webgpu_command_encoder_clear_buffer(
state: &mut OpState,
args: CommandEncoderClearBufferArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -504,7 +496,6 @@ pub struct CommandEncoderPushDebugGroupArgs {
pub fn op_webgpu_command_encoder_push_debug_group(
state: &mut OpState,
args: CommandEncoderPushDebugGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -526,7 +517,6 @@ pub struct CommandEncoderPopDebugGroupArgs {
pub fn op_webgpu_command_encoder_pop_debug_group(
state: &mut OpState,
args: CommandEncoderPopDebugGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -548,7 +538,6 @@ pub struct CommandEncoderInsertDebugMarkerArgs {
pub fn op_webgpu_command_encoder_insert_debug_marker(
state: &mut OpState,
args: CommandEncoderInsertDebugMarkerArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -574,7 +563,6 @@ pub struct CommandEncoderWriteTimestampArgs {
pub fn op_webgpu_command_encoder_write_timestamp(
state: &mut OpState,
args: CommandEncoderWriteTimestampArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -607,7 +595,6 @@ pub struct CommandEncoderResolveQuerySetArgs {
pub fn op_webgpu_command_encoder_resolve_query_set(
state: &mut OpState,
args: CommandEncoderResolveQuerySetArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
@ -642,7 +629,6 @@ pub struct CommandEncoderFinishArgs {
pub fn op_webgpu_command_encoder_finish(
state: &mut OpState,
args: CommandEncoderFinishArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let command_encoder_resource = state
.resource_table

View file

@ -31,7 +31,6 @@ pub struct ComputePassSetPipelineArgs {
pub fn op_webgpu_compute_pass_set_pipeline(
state: &mut OpState,
args: ComputePassSetPipelineArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let compute_pipeline_resource =
state
@ -62,7 +61,6 @@ pub struct ComputePassDispatchArgs {
pub fn op_webgpu_compute_pass_dispatch(
state: &mut OpState,
args: ComputePassDispatchArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let compute_pass_resource = state
.resource_table
@ -90,7 +88,6 @@ pub struct ComputePassDispatchIndirectArgs {
pub fn op_webgpu_compute_pass_dispatch_indirect(
state: &mut OpState,
args: ComputePassDispatchIndirectArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let buffer_resource = state
.resource_table
@ -120,7 +117,6 @@ pub struct ComputePassBeginPipelineStatisticsQueryArgs {
pub fn op_webgpu_compute_pass_begin_pipeline_statistics_query(
state: &mut OpState,
args: ComputePassBeginPipelineStatisticsQueryArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let compute_pass_resource = state
.resource_table
@ -148,7 +144,6 @@ pub struct ComputePassEndPipelineStatisticsQueryArgs {
pub fn op_webgpu_compute_pass_end_pipeline_statistics_query(
state: &mut OpState,
args: ComputePassEndPipelineStatisticsQueryArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let compute_pass_resource = state
.resource_table
@ -173,7 +168,6 @@ pub struct ComputePassWriteTimestampArgs {
pub fn op_webgpu_compute_pass_write_timestamp(
state: &mut OpState,
args: ComputePassWriteTimestampArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let compute_pass_resource = state
.resource_table
@ -202,7 +196,6 @@ pub struct ComputePassEndPassArgs {
pub fn op_webgpu_compute_pass_end_pass(
state: &mut OpState,
args: ComputePassEndPassArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let command_encoder_resource = state
.resource_table
@ -237,7 +230,6 @@ pub struct ComputePassSetBindGroupArgs {
pub fn op_webgpu_compute_pass_set_bind_group(
state: &mut OpState,
args: ComputePassSetBindGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let bind_group_resource =
state
@ -291,7 +283,6 @@ pub struct ComputePassPushDebugGroupArgs {
pub fn op_webgpu_compute_pass_push_debug_group(
state: &mut OpState,
args: ComputePassPushDebugGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let compute_pass_resource = state
.resource_table
@ -321,7 +312,6 @@ pub struct ComputePassPopDebugGroupArgs {
pub fn op_webgpu_compute_pass_pop_debug_group(
state: &mut OpState,
args: ComputePassPopDebugGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let compute_pass_resource = state
.resource_table
@ -345,7 +335,6 @@ pub struct ComputePassInsertDebugMarkerArgs {
pub fn op_webgpu_compute_pass_insert_debug_marker(
state: &mut OpState,
args: ComputePassInsertDebugMarkerArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let compute_pass_resource = state
.resource_table

View file

@ -245,7 +245,6 @@ pub struct GpuAdapterDevice {
pub async fn op_webgpu_request_adapter(
state: Rc<RefCell<OpState>>,
args: RequestAdapterArgs,
_: (),
) -> Result<GpuAdapterDeviceOrErr, AnyError> {
let mut state = state.borrow_mut();
check_unstable(&state, "navigator.gpu.requestAdapter");
@ -444,7 +443,6 @@ impl From<GpuRequiredFeatures> for wgpu_types::Features {
pub async fn op_webgpu_request_device(
state: Rc<RefCell<OpState>>,
args: RequestDeviceArgs,
_: (),
) -> Result<GpuAdapterDevice, AnyError> {
let mut state = state.borrow_mut();
let adapter_resource = state
@ -545,7 +543,6 @@ impl From<GpuQueryType> for wgpu_types::QueryType {
pub fn op_webgpu_create_query_set(
state: &mut OpState,
args: CreateQuerySetArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let device_resource =
state.resource_table.get::<WebGpuDevice>(args.device_rid)?;

View file

@ -62,7 +62,6 @@ pub struct CreateComputePipelineArgs {
pub fn op_webgpu_create_compute_pipeline(
state: &mut OpState,
args: CreateComputePipelineArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@ -132,7 +131,6 @@ pub struct PipelineLayout {
pub fn op_webgpu_compute_pipeline_get_bind_group_layout(
state: &mut OpState,
args: ComputePipelineGetBindGroupLayoutArgs,
_: (),
) -> Result<PipelineLayout, AnyError> {
let instance = state.borrow::<super::Instance>();
let compute_pipeline_resource = state
@ -310,7 +308,6 @@ pub struct CreateRenderPipelineArgs {
pub fn op_webgpu_create_render_pipeline(
state: &mut OpState,
args: CreateRenderPipelineArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@ -412,7 +409,6 @@ pub struct RenderPipelineGetBindGroupLayoutArgs {
pub fn op_webgpu_render_pipeline_get_bind_group_layout(
state: &mut OpState,
args: RenderPipelineGetBindGroupLayoutArgs,
_: (),
) -> Result<PipelineLayout, AnyError> {
let instance = state.borrow::<super::Instance>();
let render_pipeline_resource = state

View file

@ -24,7 +24,6 @@ pub struct QueueSubmitArgs {
pub fn op_webgpu_queue_submit(
state: &mut OpState,
args: QueueSubmitArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let queue_resource =

View file

@ -37,7 +37,6 @@ pub struct RenderPassSetViewportArgs {
pub fn op_webgpu_render_pass_set_viewport(
state: &mut OpState,
args: RenderPassSetViewportArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -70,7 +69,6 @@ pub struct RenderPassSetScissorRectArgs {
pub fn op_webgpu_render_pass_set_scissor_rect(
state: &mut OpState,
args: RenderPassSetScissorRectArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -98,7 +96,6 @@ pub struct RenderPassSetBlendConstantArgs {
pub fn op_webgpu_render_pass_set_blend_constant(
state: &mut OpState,
args: RenderPassSetBlendConstantArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -123,7 +120,6 @@ pub struct RenderPassSetStencilReferenceArgs {
pub fn op_webgpu_render_pass_set_stencil_reference(
state: &mut OpState,
args: RenderPassSetStencilReferenceArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -149,7 +145,6 @@ pub struct RenderPassBeginPipelineStatisticsQueryArgs {
pub fn op_webgpu_render_pass_begin_pipeline_statistics_query(
state: &mut OpState,
args: RenderPassBeginPipelineStatisticsQueryArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -177,7 +172,6 @@ pub struct RenderPassEndPipelineStatisticsQueryArgs {
pub fn op_webgpu_render_pass_end_pipeline_statistics_query(
state: &mut OpState,
args: RenderPassEndPipelineStatisticsQueryArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -202,7 +196,6 @@ pub struct RenderPassWriteTimestampArgs {
pub fn op_webgpu_render_pass_write_timestamp(
state: &mut OpState,
args: RenderPassWriteTimestampArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -231,7 +224,6 @@ pub struct RenderPassExecuteBundlesArgs {
pub fn op_webgpu_render_pass_execute_bundles(
state: &mut OpState,
args: RenderPassExecuteBundlesArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let mut render_bundle_ids = vec![];
@ -271,7 +263,6 @@ pub struct RenderPassEndPassArgs {
pub fn op_webgpu_render_pass_end_pass(
state: &mut OpState,
args: RenderPassEndPassArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let command_encoder_resource = state
.resource_table
@ -303,7 +294,6 @@ pub struct RenderPassSetBindGroupArgs {
pub fn op_webgpu_render_pass_set_bind_group(
state: &mut OpState,
args: RenderPassSetBindGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let bind_group_resource =
state
@ -357,7 +347,6 @@ pub struct RenderPassPushDebugGroupArgs {
pub fn op_webgpu_render_pass_push_debug_group(
state: &mut OpState,
args: RenderPassPushDebugGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -387,7 +376,6 @@ pub struct RenderPassPopDebugGroupArgs {
pub fn op_webgpu_render_pass_pop_debug_group(
state: &mut OpState,
args: RenderPassPopDebugGroupArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -411,7 +399,6 @@ pub struct RenderPassInsertDebugMarkerArgs {
pub fn op_webgpu_render_pass_insert_debug_marker(
state: &mut OpState,
args: RenderPassInsertDebugMarkerArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -442,7 +429,6 @@ pub struct RenderPassSetPipelineArgs {
pub fn op_webgpu_render_pass_set_pipeline(
state: &mut OpState,
args: RenderPassSetPipelineArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pipeline_resource =
state
@ -474,7 +460,6 @@ pub struct RenderPassSetIndexBufferArgs {
pub fn op_webgpu_render_pass_set_index_buffer(
state: &mut OpState,
args: RenderPassSetIndexBufferArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let buffer_resource = state
.resource_table
@ -516,7 +501,6 @@ pub struct RenderPassSetVertexBufferArgs {
pub fn op_webgpu_render_pass_set_vertex_buffer(
state: &mut OpState,
args: RenderPassSetVertexBufferArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let buffer_resource = state
.resource_table
@ -559,7 +543,6 @@ pub struct RenderPassDrawArgs {
pub fn op_webgpu_render_pass_draw(
state: &mut OpState,
args: RenderPassDrawArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -591,7 +574,6 @@ pub struct RenderPassDrawIndexedArgs {
pub fn op_webgpu_render_pass_draw_indexed(
state: &mut OpState,
args: RenderPassDrawIndexedArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
.resource_table
@ -621,7 +603,6 @@ pub struct RenderPassDrawIndirectArgs {
pub fn op_webgpu_render_pass_draw_indirect(
state: &mut OpState,
args: RenderPassDrawIndirectArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let buffer_resource = state
.resource_table
@ -651,7 +632,6 @@ pub struct RenderPassDrawIndexedIndirectArgs {
pub fn op_webgpu_render_pass_draw_indexed_indirect(
state: &mut OpState,
args: RenderPassDrawIndexedIndirectArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let buffer_resource = state
.resource_table

View file

@ -37,7 +37,6 @@ pub struct CreateSamplerArgs {
pub fn op_webgpu_create_sampler(
state: &mut OpState,
args: CreateSamplerArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state

View file

@ -29,7 +29,6 @@ pub struct CreateShaderModuleArgs {
pub fn op_webgpu_create_shader_module(
state: &mut OpState,
args: CreateShaderModuleArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state

View file

@ -39,7 +39,6 @@ pub struct CreateTextureArgs {
pub fn op_webgpu_create_texture(
state: &mut OpState,
args: CreateTextureArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@ -82,7 +81,6 @@ pub struct CreateTextureViewArgs {
pub fn op_webgpu_create_texture_view(
state: &mut OpState,
args: CreateTextureViewArgs,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let texture_resource = state

View file

@ -234,7 +234,6 @@ pub struct CreateResponse {
pub async fn op_ws_create<WP>(
state: Rc<RefCell<OpState>>,
args: CreateArgs,
_: (),
) -> Result<CreateResponse, AnyError>
where
WP: WebSocketPermissions + 'static,
@ -413,7 +412,6 @@ pub struct CloseArgs {
pub async fn op_ws_close(
state: Rc<RefCell<OpState>>,
args: CloseArgs,
_: (),
) -> Result<(), AnyError> {
let rid = args.rid;
let msg = Message::Close(args.code.map(|c| CloseFrame {
@ -448,7 +446,6 @@ pub enum NextEventResponse {
pub async fn op_ws_next_event(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<NextEventResponse, AnyError> {
let resource = state
.borrow_mut()

View file

@ -104,7 +104,6 @@ fn get_webstorage(
pub fn op_webstorage_length(
state: &mut OpState,
persistent: bool,
_: (),
) -> Result<u32, AnyError> {
let conn = get_webstorage(state, persistent)?;
@ -201,7 +200,6 @@ pub fn op_webstorage_remove(
pub fn op_webstorage_clear(
state: &mut OpState,
persistent: bool,
_: (),
) -> Result<(), AnyError> {
let conn = get_webstorage(state, persistent)?;
@ -215,7 +213,6 @@ pub fn op_webstorage_clear(
pub fn op_webstorage_iterate_keys(
state: &mut OpState,
persistent: bool,
_: (),
) -> Result<Vec<String>, AnyError> {
let conn = get_webstorage(state, persistent)?;

View file

@ -91,8 +91,7 @@ pub fn op(_attr: TokenStream, item: TokenStream) -> TokenStream {
/// Generate the body of a v8 func for an async op
fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
let a = codegen_arg(core, &f.sig.inputs[1], "a", 2);
let b = codegen_arg(core, &f.sig.inputs[2], "b", 3);
let (arg_decls, args_tail) = codegen_args(core, f, 1, 2);
let type_params = &f.sig.generics.params;
quote! {
@ -115,8 +114,7 @@ fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
}
};
#a
#b
#arg_decls
// SAFETY: Unchecked cast to external since #core guarantees args.data() is a v8 External.
let state_refcell_raw = unsafe {
@ -138,7 +136,7 @@ fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
};
#core::_ops::queue_async_op(scope, async move {
let result = Self::call::<#type_params>(state, a, b).await;
let result = Self::call::<#type_params>(state, #args_tail).await;
(promise_id, op_id, #core::_ops::to_op_result(get_class, result))
});
}
@ -146,8 +144,7 @@ fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
/// Generate the body of a v8 func for a sync op
fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
let a = codegen_arg(core, &f.sig.inputs[1], "a", 1);
let b = codegen_arg(core, &f.sig.inputs[2], "b", 2);
let (arg_decls, args_tail) = codegen_args(core, f, 1, 1);
let ret = codegen_sync_ret(core, &f.sig.output);
let type_params = &f.sig.generics.params;
@ -157,8 +154,7 @@ fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
#core::v8::Local::<#core::v8::Integer>::cast(args.get(0)).value()
} as usize;
#a
#b
#arg_decls
// SAFETY: Unchecked cast to external since #core guarantees args.data() is a v8 External.
let state_refcell_raw = unsafe {
@ -169,7 +165,7 @@ fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
let state = unsafe { &*(state_refcell_raw as *const std::cell::RefCell<#core::OpState>) };
let op_state = &mut state.borrow_mut();
let result = Self::call::<#type_params>(op_state, a, b);
let result = Self::call::<#type_params>(op_state, #args_tail);
op_state.tracker.track_sync(op_id);
@ -177,11 +173,34 @@ fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
}
}
fn codegen_args(
core: &TokenStream2,
f: &syn::ItemFn,
rust_i0: usize, // Index of first generic arg in rust
v8_i0: usize, // Index of first generic arg in v8/js
) -> (TokenStream2, TokenStream2) {
let inputs = &f.sig.inputs.iter().skip(rust_i0).enumerate();
let ident_seq: TokenStream2 = inputs
.clone()
.map(|(i, _)| format!("arg_{i}"))
.collect::<Vec<_>>()
.join(", ")
.parse()
.unwrap();
let decls: TokenStream2 = inputs
.clone()
.map(|(i, arg)| {
codegen_arg(core, arg, format!("arg_{i}").as_ref(), v8_i0 + i)
})
.collect();
(decls, ident_seq)
}
fn codegen_arg(
core: &TokenStream2,
arg: &syn::FnArg,
name: &str,
idx: i32,
idx: usize,
) -> TokenStream2 {
let ident = quote::format_ident!("{name}");
let pat = match arg {
@ -194,7 +213,7 @@ fn codegen_arg(
}
// Otherwise deserialize it via serde_v8
quote! {
let #ident = args.get(#idx);
let #ident = args.get(#idx as i32);
let #ident = match #core::serde_v8::from_v8(scope, #ident) {
Ok(v) => v,
Err(err) => {

View file

@ -161,7 +161,6 @@ fn open_helper(
fn op_open_sync(
state: &mut OpState,
args: OpenArgs,
_: (),
) -> Result<ResourceId, AnyError> {
let (path, open_options) = open_helper(state, args)?;
let std_file = open_options.open(&path).map_err(|err| {
@ -177,7 +176,6 @@ fn op_open_sync(
async fn op_open_async(
state: Rc<RefCell<OpState>>,
args: OpenArgs,
_: (),
) -> Result<ResourceId, AnyError> {
let (path, open_options) = open_helper(&mut state.borrow_mut(), args)?;
let tokio_file = tokio::fs::OpenOptions::from(open_options)
@ -217,11 +215,7 @@ fn seek_helper(args: SeekArgs) -> Result<(u32, SeekFrom), AnyError> {
}
#[op]
fn op_seek_sync(
state: &mut OpState,
args: SeekArgs,
_: (),
) -> Result<u64, AnyError> {
fn op_seek_sync(state: &mut OpState, args: SeekArgs) -> Result<u64, AnyError> {
let (rid, seek_from) = seek_helper(args)?;
let pos = StdFileResource::with(state, rid, |r| match r {
Ok(std_file) => std_file.seek(seek_from).map_err(AnyError::from),
@ -236,7 +230,6 @@ fn op_seek_sync(
async fn op_seek_async(
state: Rc<RefCell<OpState>>,
args: SeekArgs,
_: (),
) -> Result<u64, AnyError> {
let (rid, seek_from) = seek_helper(args)?;
@ -261,7 +254,6 @@ async fn op_seek_async(
fn op_fdatasync_sync(
state: &mut OpState,
rid: ResourceId,
_: (),
) -> Result<(), AnyError> {
StdFileResource::with(state, rid, |r| match r {
Ok(std_file) => std_file.sync_data().map_err(AnyError::from),
@ -274,7 +266,6 @@ fn op_fdatasync_sync(
async fn op_fdatasync_async(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<(), AnyError> {
let resource = state
.borrow_mut()
@ -294,11 +285,7 @@ async fn op_fdatasync_async(
}
#[op]
fn op_fsync_sync(
state: &mut OpState,
rid: ResourceId,
_: (),
) -> Result<(), AnyError> {
fn op_fsync_sync(state: &mut OpState, rid: ResourceId) -> Result<(), AnyError> {
StdFileResource::with(state, rid, |r| match r {
Ok(std_file) => std_file.sync_all().map_err(AnyError::from),
Err(_) => Err(type_error("cannot sync this type of resource".to_string())),
@ -310,7 +297,6 @@ fn op_fsync_sync(
async fn op_fsync_async(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<(), AnyError> {
let resource = state
.borrow_mut()
@ -333,7 +319,6 @@ async fn op_fsync_async(
fn op_fstat_sync(
state: &mut OpState,
rid: ResourceId,
_: (),
) -> Result<FsStat, AnyError> {
let metadata = StdFileResource::with(state, rid, |r| match r {
Ok(std_file) => std_file.metadata().map_err(AnyError::from),
@ -346,7 +331,6 @@ fn op_fstat_sync(
async fn op_fstat_async(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<FsStat, AnyError> {
let resource = state
.borrow_mut()
@ -432,7 +416,6 @@ async fn op_flock_async(
fn op_funlock_sync(
state: &mut OpState,
rid: ResourceId,
_: (),
) -> Result<(), AnyError> {
use fs3::FileExt;
super::check_unstable(state, "Deno.funlockSync");
@ -450,7 +433,6 @@ fn op_funlock_sync(
async fn op_funlock_async(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<(), AnyError> {
use fs3::FileExt;
super::check_unstable2(&state, "Deno.funlock");
@ -484,11 +466,7 @@ async fn op_funlock_async(
}
#[op]
fn op_umask(
state: &mut OpState,
mask: Option<u32>,
_: (),
) -> Result<u32, AnyError> {
fn op_umask(state: &mut OpState, mask: Option<u32>) -> Result<u32, AnyError> {
super::check_unstable(state, "Deno.umask");
// TODO implement umask for Windows
// see https://github.com/nodejs/node/blob/master/src/node_process_methods.cc
@ -517,11 +495,7 @@ fn op_umask(
}
#[op]
fn op_chdir(
state: &mut OpState,
directory: String,
_: (),
) -> Result<(), AnyError> {
fn op_chdir(state: &mut OpState, directory: String) -> Result<(), AnyError> {
let d = PathBuf::from(&directory);
state.borrow_mut::<Permissions>().read.check(&d)?;
set_current_dir(&d).map_err(|err| {
@ -539,11 +513,7 @@ pub struct MkdirArgs {
}
#[op]
fn op_mkdir_sync(
state: &mut OpState,
args: MkdirArgs,
_: (),
) -> Result<(), AnyError> {
fn op_mkdir_sync(state: &mut OpState, args: MkdirArgs) -> Result<(), AnyError> {
let path = Path::new(&args.path).to_path_buf();
let mode = args.mode.unwrap_or(0o777) & 0o777;
state.borrow_mut::<Permissions>().write.check(&path)?;
@ -565,7 +535,6 @@ fn op_mkdir_sync(
async fn op_mkdir_async(
state: Rc<RefCell<OpState>>,
args: MkdirArgs,
_: (),
) -> Result<(), AnyError> {
let path = Path::new(&args.path).to_path_buf();
let mode = args.mode.unwrap_or(0o777) & 0o777;
@ -601,11 +570,7 @@ pub struct ChmodArgs {
}
#[op]
fn op_chmod_sync(
state: &mut OpState,
args: ChmodArgs,
_: (),
) -> Result<(), AnyError> {
fn op_chmod_sync(state: &mut OpState, args: ChmodArgs) -> Result<(), AnyError> {
let path = Path::new(&args.path).to_path_buf();
let mode = args.mode & 0o777;
let err_mapper = |err: Error| {
@ -634,7 +599,6 @@ fn op_chmod_sync(
async fn op_chmod_async(
state: Rc<RefCell<OpState>>,
args: ChmodArgs,
_: (),
) -> Result<(), AnyError> {
let path = Path::new(&args.path).to_path_buf();
let mode = args.mode & 0o777;
@ -677,11 +641,7 @@ pub struct ChownArgs {
}
#[op]
fn op_chown_sync(
state: &mut OpState,
args: ChownArgs,
_: (),
) -> Result<(), AnyError> {
fn op_chown_sync(state: &mut OpState, args: ChownArgs) -> Result<(), AnyError> {
let path = Path::new(&args.path).to_path_buf();
state.borrow_mut::<Permissions>().write.check(&path)?;
debug!(
@ -715,7 +675,6 @@ fn op_chown_sync(
async fn op_chown_async(
state: Rc<RefCell<OpState>>,
args: ChownArgs,
_: (),
) -> Result<(), AnyError> {
let path = Path::new(&args.path).to_path_buf();
@ -764,7 +723,6 @@ pub struct RemoveArgs {
fn op_remove_sync(
state: &mut OpState,
args: RemoveArgs,
_: (),
) -> Result<(), AnyError> {
let path = PathBuf::from(&args.path);
let recursive = args.recursive;
@ -810,7 +768,6 @@ fn op_remove_sync(
async fn op_remove_async(
state: Rc<RefCell<OpState>>,
args: RemoveArgs,
_: (),
) -> Result<(), AnyError> {
let path = PathBuf::from(&args.path);
let recursive = args.recursive;
@ -869,7 +826,6 @@ pub struct CopyFileArgs {
fn op_copy_file_sync(
state: &mut OpState,
args: CopyFileArgs,
_: (),
) -> Result<(), AnyError> {
let from = PathBuf::from(&args.from);
let to = PathBuf::from(&args.to);
@ -908,7 +864,6 @@ fn op_copy_file_sync(
async fn op_copy_file_async(
state: Rc<RefCell<OpState>>,
args: CopyFileArgs,
_: (),
) -> Result<(), AnyError> {
let from = PathBuf::from(&args.from);
let to = PathBuf::from(&args.to);
@ -1037,7 +992,6 @@ pub struct StatArgs {
fn op_stat_sync(
state: &mut OpState,
args: StatArgs,
_: (),
) -> Result<FsStat, AnyError> {
let path = PathBuf::from(&args.path);
let lstat = args.lstat;
@ -1058,7 +1012,6 @@ fn op_stat_sync(
async fn op_stat_async(
state: Rc<RefCell<OpState>>,
args: StatArgs,
_: (),
) -> Result<FsStat, AnyError> {
let path = PathBuf::from(&args.path);
let lstat = args.lstat;
@ -1088,7 +1041,6 @@ async fn op_stat_async(
fn op_realpath_sync(
state: &mut OpState,
path: String,
_: (),
) -> Result<String, AnyError> {
let path = PathBuf::from(&path);
@ -1110,7 +1062,6 @@ fn op_realpath_sync(
async fn op_realpath_async(
state: Rc<RefCell<OpState>>,
path: String,
_: (),
) -> Result<String, AnyError> {
let path = PathBuf::from(&path);
@ -1148,7 +1099,6 @@ pub struct DirEntry {
fn op_read_dir_sync(
state: &mut OpState,
path: String,
_: (),
) -> Result<Vec<DirEntry>, AnyError> {
let path = PathBuf::from(&path);
@ -1189,7 +1139,6 @@ fn op_read_dir_sync(
async fn op_read_dir_async(
state: Rc<RefCell<OpState>>,
path: String,
_: (),
) -> Result<Vec<DirEntry>, AnyError> {
let path = PathBuf::from(&path);
{
@ -1242,7 +1191,6 @@ pub struct RenameArgs {
fn op_rename_sync(
state: &mut OpState,
args: RenameArgs,
_: (),
) -> Result<(), AnyError> {
let oldpath = PathBuf::from(&args.oldpath);
let newpath = PathBuf::from(&args.newpath);
@ -1271,7 +1219,6 @@ fn op_rename_sync(
async fn op_rename_async(
state: Rc<RefCell<OpState>>,
args: RenameArgs,
_: (),
) -> Result<(), AnyError> {
let oldpath = PathBuf::from(&args.oldpath);
let newpath = PathBuf::from(&args.newpath);
@ -1314,11 +1261,7 @@ pub struct LinkArgs {
}
#[op]
fn op_link_sync(
state: &mut OpState,
args: LinkArgs,
_: (),
) -> Result<(), AnyError> {
fn op_link_sync(state: &mut OpState, args: LinkArgs) -> Result<(), AnyError> {
let oldpath = PathBuf::from(&args.oldpath);
let newpath = PathBuf::from(&args.newpath);
@ -1348,7 +1291,6 @@ fn op_link_sync(
async fn op_link_async(
state: Rc<RefCell<OpState>>,
args: LinkArgs,
_: (),
) -> Result<(), AnyError> {
let oldpath = PathBuf::from(&args.oldpath);
let newpath = PathBuf::from(&args.newpath);
@ -1402,7 +1344,6 @@ pub struct SymlinkOptions {
fn op_symlink_sync(
state: &mut OpState,
args: SymlinkArgs,
_: (),
) -> Result<(), AnyError> {
let oldpath = PathBuf::from(&args.oldpath);
let newpath = PathBuf::from(&args.newpath);
@ -1464,7 +1405,6 @@ fn op_symlink_sync(
async fn op_symlink_async(
state: Rc<RefCell<OpState>>,
args: SymlinkArgs,
_: (),
) -> Result<(), AnyError> {
let oldpath = PathBuf::from(&args.oldpath);
let newpath = PathBuf::from(&args.newpath);
@ -1529,7 +1469,6 @@ async fn op_symlink_async(
fn op_read_link_sync(
state: &mut OpState,
path: String,
_: (),
) -> Result<String, AnyError> {
let path = PathBuf::from(&path);
@ -1553,7 +1492,6 @@ fn op_read_link_sync(
async fn op_read_link_async(
state: Rc<RefCell<OpState>>,
path: String,
_: (),
) -> Result<String, AnyError> {
let path = PathBuf::from(&path);
{
@ -1589,7 +1527,6 @@ pub struct FtruncateArgs {
fn op_ftruncate_sync(
state: &mut OpState,
args: FtruncateArgs,
_: (),
) -> Result<(), AnyError> {
let rid = args.rid;
let len = args.len as u64;
@ -1604,7 +1541,6 @@ fn op_ftruncate_sync(
async fn op_ftruncate_async(
state: Rc<RefCell<OpState>>,
args: FtruncateArgs,
_: (),
) -> Result<(), AnyError> {
let rid = args.rid;
let len = args.len as u64;
@ -1637,7 +1573,6 @@ pub struct TruncateArgs {
fn op_truncate_sync(
state: &mut OpState,
args: TruncateArgs,
_: (),
) -> Result<(), AnyError> {
let path = PathBuf::from(&args.path);
let len = args.len;
@ -1663,7 +1598,6 @@ fn op_truncate_sync(
async fn op_truncate_async(
state: Rc<RefCell<OpState>>,
args: TruncateArgs,
_: (),
) -> Result<(), AnyError> {
let path = PathBuf::from(&args.path);
let len = args.len;
@ -1747,7 +1681,6 @@ pub struct MakeTempArgs {
fn op_make_temp_dir_sync(
state: &mut OpState,
args: MakeTempArgs,
_: (),
) -> Result<String, AnyError> {
let dir = args.dir.map(|s| PathBuf::from(&s));
let prefix = args.prefix.map(String::from);
@ -1777,7 +1710,6 @@ fn op_make_temp_dir_sync(
async fn op_make_temp_dir_async(
state: Rc<RefCell<OpState>>,
args: MakeTempArgs,
_: (),
) -> Result<String, AnyError> {
let dir = args.dir.map(|s| PathBuf::from(&s));
let prefix = args.prefix.map(String::from);
@ -1812,7 +1744,6 @@ async fn op_make_temp_dir_async(
fn op_make_temp_file_sync(
state: &mut OpState,
args: MakeTempArgs,
_: (),
) -> Result<String, AnyError> {
let dir = args.dir.map(|s| PathBuf::from(&s));
let prefix = args.prefix.map(String::from);
@ -1842,7 +1773,6 @@ fn op_make_temp_file_sync(
async fn op_make_temp_file_async(
state: Rc<RefCell<OpState>>,
args: MakeTempArgs,
_: (),
) -> Result<String, AnyError> {
let dir = args.dir.map(|s| PathBuf::from(&s));
let prefix = args.prefix.map(String::from);
@ -1885,7 +1815,6 @@ pub struct FutimeArgs {
fn op_futime_sync(
state: &mut OpState,
args: FutimeArgs,
_: (),
) -> Result<(), AnyError> {
super::check_unstable(state, "Deno.futimeSync");
let rid = args.rid;
@ -1909,7 +1838,6 @@ fn op_futime_sync(
async fn op_futime_async(
state: Rc<RefCell<OpState>>,
args: FutimeArgs,
_: (),
) -> Result<(), AnyError> {
super::check_unstable2(&state, "Deno.futime");
let rid = args.rid;
@ -1955,11 +1883,7 @@ pub struct UtimeArgs {
}
#[op]
fn op_utime_sync(
state: &mut OpState,
args: UtimeArgs,
_: (),
) -> Result<(), AnyError> {
fn op_utime_sync(state: &mut OpState, args: UtimeArgs) -> Result<(), AnyError> {
super::check_unstable(state, "Deno.utime");
let path = PathBuf::from(&args.path);
@ -1977,7 +1901,6 @@ fn op_utime_sync(
async fn op_utime_async(
state: Rc<RefCell<OpState>>,
args: UtimeArgs,
_: (),
) -> Result<(), AnyError> {
super::check_unstable(&state.borrow(), "Deno.utime");
@ -2002,7 +1925,7 @@ async fn op_utime_async(
}
#[op]
fn op_cwd(state: &mut OpState, _: (), _: ()) -> Result<String, AnyError> {
fn op_cwd(state: &mut OpState) -> Result<String, AnyError> {
let path = current_dir()?;
state
.borrow_mut::<Permissions>()

View file

@ -98,7 +98,6 @@ pub struct OpenArgs {
fn op_fs_events_open(
state: &mut OpState,
args: OpenArgs,
_: (),
) -> Result<ResourceId, AnyError> {
let (sender, receiver) = mpsc::channel::<Result<FsEvent, AnyError>>(16);
let sender = Mutex::new(sender);
@ -133,7 +132,6 @@ fn op_fs_events_open(
async fn op_fs_events_poll(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<Option<FsEvent>, AnyError> {
let resource = state.borrow().resource_table.get::<FsEventsResource>(rid)?;
let mut receiver = RcRef::map(&resource, |r| &r.receiver).borrow_mut().await;

View file

@ -20,7 +20,6 @@ pub fn init() -> Extension {
fn op_http_start(
state: &mut OpState,
tcp_stream_rid: ResourceId,
_: (),
) -> Result<ResourceId, AnyError> {
if let Ok(resource_rc) = state
.resource_table

View file

@ -40,7 +40,7 @@ pub fn init(maybe_exit_code: Option<Arc<AtomicI32>>) -> Extension {
}
#[op]
fn op_exec_path(state: &mut OpState, _: (), _: ()) -> Result<String, AnyError> {
fn op_exec_path(state: &mut OpState) -> Result<String, AnyError> {
let current_exe = env::current_exe().unwrap();
state
.borrow_mut::<Permissions>()
@ -71,11 +71,7 @@ fn op_set_env(
}
#[op]
fn op_env(
state: &mut OpState,
_: (),
_: (),
) -> Result<HashMap<String, String>, AnyError> {
fn op_env(state: &mut OpState) -> Result<HashMap<String, String>, AnyError> {
state.borrow_mut::<Permissions>().env.check_all()?;
Ok(env::vars().collect())
}
@ -84,7 +80,6 @@ fn op_env(
fn op_get_env(
state: &mut OpState,
key: String,
_: (),
) -> Result<Option<String>, AnyError> {
state.borrow_mut::<Permissions>().env.check(&key)?;
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
@ -98,11 +93,7 @@ fn op_get_env(
}
#[op]
fn op_delete_env(
state: &mut OpState,
key: String,
_: (),
) -> Result<(), AnyError> {
fn op_delete_env(state: &mut OpState, key: String) -> Result<(), AnyError> {
state.borrow_mut::<Permissions>().env.check(&key)?;
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
return Err(type_error("Key contains invalid characters."));
@ -112,27 +103,19 @@ fn op_delete_env(
}
#[op]
fn op_set_exit_code(
state: &mut OpState,
code: i32,
_: (),
) -> Result<(), AnyError> {
fn op_set_exit_code(state: &mut OpState, code: i32) -> Result<(), AnyError> {
state.borrow_mut::<Arc<AtomicI32>>().store(code, Relaxed);
Ok(())
}
#[op]
fn op_exit(state: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
fn op_exit(state: &mut OpState) -> Result<(), AnyError> {
let code = state.borrow::<Arc<AtomicI32>>().load(Relaxed);
std::process::exit(code)
}
#[op]
fn op_loadavg(
state: &mut OpState,
_: (),
_: (),
) -> Result<(f64, f64, f64), AnyError> {
fn op_loadavg(state: &mut OpState) -> Result<(f64, f64, f64), AnyError> {
super::check_unstable(state, "Deno.loadavg");
state.borrow_mut::<Permissions>().env.check_all()?;
match sys_info::loadavg() {
@ -142,7 +125,7 @@ fn op_loadavg(
}
#[op]
fn op_hostname(state: &mut OpState, _: (), _: ()) -> Result<String, AnyError> {
fn op_hostname(state: &mut OpState) -> Result<String, AnyError> {
super::check_unstable(state, "Deno.hostname");
state.borrow_mut::<Permissions>().env.check_all()?;
let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_string());
@ -150,11 +133,7 @@ fn op_hostname(state: &mut OpState, _: (), _: ()) -> Result<String, AnyError> {
}
#[op]
fn op_os_release(
state: &mut OpState,
_: (),
_: (),
) -> Result<String, AnyError> {
fn op_os_release(state: &mut OpState) -> Result<String, AnyError> {
super::check_unstable(state, "Deno.osRelease");
state.borrow_mut::<Permissions>().env.check_all()?;
let release = sys_info::os_release().unwrap_or_else(|_| "".to_string());
@ -164,8 +143,6 @@ fn op_os_release(
#[op]
fn op_network_interfaces(
state: &mut OpState,
_: (),
_: (),
) -> Result<Vec<NetworkInterface>, AnyError> {
super::check_unstable(state, "Deno.networkInterfaces");
state.borrow_mut::<Permissions>().env.check_all()?;
@ -232,8 +209,6 @@ struct MemInfo {
#[op]
fn op_system_memory_info(
state: &mut OpState,
_: (),
_: (),
) -> Result<Option<MemInfo>, AnyError> {
super::check_unstable(state, "Deno.systemMemoryInfo");
state.borrow_mut::<Permissions>().env.check_all()?;
@ -253,11 +228,7 @@ fn op_system_memory_info(
#[cfg(not(windows))]
#[op]
fn op_getuid(
state: &mut OpState,
_: (),
_: (),
) -> Result<Option<u32>, AnyError> {
fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
super::check_unstable(state, "Deno.getUid");
state.borrow_mut::<Permissions>().env.check_all()?;
unsafe { Ok(Some(libc::getuid())) }
@ -265,11 +236,7 @@ fn op_getuid(
#[cfg(windows)]
#[op]
fn op_getuid(
state: &mut OpState,
_: (),
_: (),
) -> Result<Option<u32>, AnyError> {
fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
super::check_unstable(state, "Deno.getUid");
state.borrow_mut::<Permissions>().env.check_all()?;
Ok(None)

View file

@ -34,7 +34,6 @@ pub struct PermissionArgs {
pub fn op_query_permission(
state: &mut OpState,
args: PermissionArgs,
_: (),
) -> Result<String, AnyError> {
let permissions = state.borrow::<Permissions>();
let path = args.path.as_deref();
@ -66,7 +65,6 @@ pub fn op_query_permission(
pub fn op_revoke_permission(
state: &mut OpState,
args: PermissionArgs,
_: (),
) -> Result<String, AnyError> {
let permissions = state.borrow_mut::<Permissions>();
let path = args.path.as_deref();
@ -98,7 +96,6 @@ pub fn op_revoke_permission(
pub fn op_request_permission(
state: &mut OpState,
args: PermissionArgs,
_: (),
) -> Result<String, AnyError> {
let permissions = state.borrow_mut::<Permissions>();
let path = args.path.as_deref();

View file

@ -99,11 +99,7 @@ struct RunInfo {
}
#[op]
fn op_run(
state: &mut OpState,
run_args: RunArgs,
_: (),
) -> Result<RunInfo, AnyError> {
fn op_run(state: &mut OpState, run_args: RunArgs) -> Result<RunInfo, AnyError> {
let args = run_args.cmd;
state.borrow_mut::<Permissions>().run.check(&args[0])?;
let env = run_args.env;
@ -227,7 +223,6 @@ struct ProcessStatus {
async fn op_run_status(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<ProcessStatus, AnyError> {
let resource = state
.borrow_mut()

View file

@ -19,11 +19,7 @@ pub fn init(main_module: ModuleSpecifier) -> Extension {
}
#[op]
fn op_main_module(
state: &mut OpState,
_: (),
_: (),
) -> Result<String, AnyError> {
fn op_main_module(state: &mut OpState) -> Result<String, AnyError> {
let main = state.borrow::<ModuleSpecifier>().to_string();
let main_url = deno_core::resolve_url_or_path(&main)?;
if main_url.scheme() == "file" {

View file

@ -178,7 +178,6 @@ pub fn signal_str_to_int(s: &str) -> Result<libc::c_int, AnyError> {
fn op_signal_bind(
state: &mut OpState,
sig: String,
_: (),
) -> Result<ResourceId, AnyError> {
let signo = signal_str_to_int(&sig)?;
if signal_hook_registry::FORBIDDEN.contains(&signo) {
@ -200,7 +199,6 @@ fn op_signal_bind(
async fn op_signal_poll(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
) -> Result<bool, AnyError> {
let resource = state
.borrow_mut()
@ -220,7 +218,6 @@ async fn op_signal_poll(
pub fn op_signal_unbind(
state: &mut OpState,
rid: ResourceId,
_: (),
) -> Result<(), AnyError> {
state.resource_table.close(rid)?;
Ok(())
@ -228,30 +225,18 @@ pub fn op_signal_unbind(
#[cfg(not(unix))]
#[op]
pub fn op_signal_bind(
_state: &mut OpState,
_: (),
_: (),
) -> Result<(), AnyError> {
pub fn op_signal_bind(_state: &mut OpState) -> Result<(), AnyError> {
Err(generic_error("not implemented"))
}
#[cfg(not(unix))]
#[op]
fn op_signal_unbind(
_state: &mut OpState,
_: (),
_: (),
) -> Result<(), AnyError> {
fn op_signal_unbind(_state: &mut OpState) -> Result<(), AnyError> {
Err(generic_error("not implemented"))
}
#[cfg(not(unix))]
#[op]
async fn op_signal_poll(
_state: Rc<RefCell<OpState>>,
_: (),
_: (),
) -> Result<(), AnyError> {
async fn op_signal_poll(_state: Rc<RefCell<OpState>>) -> Result<(), AnyError> {
Err(generic_error("not implemented"))
}

View file

@ -68,11 +68,7 @@ pub struct SetRawArgs {
}
#[op]
fn op_set_raw(
state: &mut OpState,
args: SetRawArgs,
_: (),
) -> Result<(), AnyError> {
fn op_set_raw(state: &mut OpState, args: SetRawArgs) -> Result<(), AnyError> {
super::check_unstable(state, "Deno.setRaw");
let rid = args.rid;
@ -213,11 +209,7 @@ fn op_set_raw(
}
#[op]
fn op_isatty(
state: &mut OpState,
rid: ResourceId,
_: (),
) -> Result<bool, AnyError> {
fn op_isatty(state: &mut OpState, rid: ResourceId) -> Result<bool, AnyError> {
let isatty: bool = StdFileResource::with(state, rid, move |r| match r {
Ok(std_file) => {
#[cfg(windows)]
@ -251,7 +243,6 @@ struct ConsoleSize {
fn op_console_size(
state: &mut OpState,
rid: ResourceId,
_: (),
) -> Result<ConsoleSize, AnyError> {
super::check_unstable(state, "Deno.consoleSize");

View file

@ -33,7 +33,6 @@ pub fn init() -> Extension {
fn op_worker_post_message(
state: &mut OpState,
data: JsMessageData,
_: (),
) -> Result<(), AnyError> {
let handle = state.borrow::<WebWorkerInternalHandle>().clone();
handle.port.send(state, data)?;
@ -43,8 +42,6 @@ fn op_worker_post_message(
#[op]
async fn op_worker_recv_message(
state: Rc<RefCell<OpState>>,
_: (),
_: (),
) -> Result<Option<JsMessageData>, AnyError> {
let handle = {
let state = state.borrow();
@ -58,7 +55,7 @@ async fn op_worker_recv_message(
}
#[op]
fn op_worker_close(state: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
fn op_worker_close(state: &mut OpState) -> Result<(), AnyError> {
// Notify parent that we're finished
let mut handle = state.borrow_mut::<WebWorkerInternalHandle>().clone();
@ -67,11 +64,7 @@ fn op_worker_close(state: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
}
#[op]
fn op_worker_get_type(
state: &mut OpState,
_: (),
_: (),
) -> Result<WebWorkerType, AnyError> {
fn op_worker_get_type(state: &mut OpState) -> Result<WebWorkerType, AnyError> {
let handle = state.borrow::<WebWorkerInternalHandle>().clone();
Ok(handle.worker_type)
}

View file

@ -148,7 +148,6 @@ pub struct CreateWorkerArgs {
fn op_create_worker(
state: &mut OpState,
args: CreateWorkerArgs,
_: (),
) -> Result<WorkerId, AnyError> {
let specifier = args.specifier.clone();
let maybe_source_code = if args.has_source_code {
@ -265,7 +264,6 @@ fn op_create_worker(
fn op_host_terminate_worker(
state: &mut OpState,
id: WorkerId,
_: (),
) -> Result<(), AnyError> {
if let Some(worker_thread) = state.borrow_mut::<WorkersTable>().remove(&id) {
worker_thread.terminate();
@ -320,7 +318,6 @@ fn close_channel(
async fn op_host_recv_ctrl(
state: Rc<RefCell<OpState>>,
id: WorkerId,
_: (),
) -> Result<WorkerControlEvent, AnyError> {
let worker_handle = {
let state = state.borrow();
@ -352,7 +349,6 @@ async fn op_host_recv_ctrl(
async fn op_host_recv_message(
state: Rc<RefCell<OpState>>,
id: WorkerId,
_: (),
) -> Result<Option<JsMessageData>, AnyError> {
let worker_handle = {
let s = state.borrow();