mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
feat(ops): custom arity (#13949)
Also cleanup & drop ignored wildcard op-args
This commit is contained in:
parent
9f494dc405
commit
88d0f01948
55 changed files with 99 additions and 498 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -244,7 +244,7 @@ jobs:
|
||||||
~/.cargo/registry/index
|
~/.cargo/registry/index
|
||||||
~/.cargo/registry/cache
|
~/.cargo/registry/cache
|
||||||
~/.cargo/git/db
|
~/.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
|
# In main branch, always creates fresh cache
|
||||||
- name: Cache build output (main)
|
- name: Cache build output (main)
|
||||||
|
@ -260,7 +260,7 @@ jobs:
|
||||||
!./target/*/*.zip
|
!./target/*/*.zip
|
||||||
!./target/*/*.tar.gz
|
!./target/*/*.tar.gz
|
||||||
key: |
|
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.
|
# Restore cache from the latest 'main' branch build.
|
||||||
- name: Cache build output (PR)
|
- name: Cache build output (PR)
|
||||||
|
@ -276,7 +276,7 @@ jobs:
|
||||||
!./target/*/*.tar.gz
|
!./target/*/*.tar.gz
|
||||||
key: never_saved
|
key: never_saved
|
||||||
restore-keys: |
|
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'.
|
# Don't save cache after building PRs or branches other than 'main'.
|
||||||
- name: Skip save cache (PR)
|
- name: Skip save cache (PR)
|
||||||
|
|
|
@ -22,22 +22,18 @@ fn setup() -> Vec<Extension> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_nop(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
|
fn op_nop(_: &mut OpState) -> Result<(), AnyError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_pi_json(_: &mut OpState, _: (), _: ()) -> Result<i64, AnyError> {
|
fn op_pi_json(_: &mut OpState) -> Result<i64, AnyError> {
|
||||||
Ok(314159)
|
Ok(314159)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is a function since async closures aren't stable
|
// this is a function since async closures aren't stable
|
||||||
#[op]
|
#[op]
|
||||||
async fn op_pi_async(
|
async fn op_pi_async(_: Rc<RefCell<OpState>>) -> Result<i64, AnyError> {
|
||||||
_: Rc<RefCell<OpState>>,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<i64, AnyError> {
|
|
||||||
Ok(314159)
|
Ok(314159)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
cli/build.rs
19
cli/build.rs
|
@ -192,7 +192,6 @@ fn create_compiler_snapshot(
|
||||||
fn op_build_info(
|
fn op_build_info(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_args: Value,
|
_args: Value,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let build_specifier = "asset:///bootstrap.ts";
|
let build_specifier = "asset:///bootstrap.ts";
|
||||||
let build_libs = state.borrow::<Vec<&str>>();
|
let build_libs = state.borrow::<Vec<&str>>();
|
||||||
|
@ -203,31 +202,19 @@ fn create_compiler_snapshot(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_cwd(
|
fn op_cwd(_state: &mut OpState, _args: Value) -> Result<Value, AnyError> {
|
||||||
_state: &mut OpState,
|
|
||||||
_args: Value,
|
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
|
||||||
Ok(json!("cache:///"))
|
Ok(json!("cache:///"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_exists(
|
fn op_exists(_state: &mut OpState, _args: Value) -> Result<Value, AnyError> {
|
||||||
_state: &mut OpState,
|
|
||||||
_args: Value,
|
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
|
||||||
Ok(json!(false))
|
Ok(json!(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
// using the same op that is used in `tsc.rs` for loading modules and reading
|
// using the same op that is used in `tsc.rs` for loading modules and reading
|
||||||
// files, but a slightly different implementation at build time.
|
// files, but a slightly different implementation at build time.
|
||||||
fn op_load(
|
fn op_load(state: &mut OpState, args: LoadArgs) -> Result<Value, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: LoadArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
|
||||||
let op_crate_libs = state.borrow::<HashMap<&str, &str>>();
|
let op_crate_libs = state.borrow::<HashMap<&str, &str>>();
|
||||||
let path_dts = state.borrow::<PathBuf>();
|
let path_dts = state.borrow::<PathBuf>();
|
||||||
let re_asset =
|
let re_asset =
|
||||||
|
|
|
@ -2515,7 +2515,6 @@ struct SourceSnapshotArgs {
|
||||||
fn op_dispose(
|
fn op_dispose(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: SourceSnapshotArgs,
|
args: SourceSnapshotArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<bool, AnyError> {
|
) -> Result<bool, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mark = state.performance.mark("op_dispose", Some(&args));
|
let mark = state.performance.mark("op_dispose", Some(&args));
|
||||||
|
@ -2535,7 +2534,6 @@ struct SpecifierArgs {
|
||||||
fn op_exists(
|
fn op_exists(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: SpecifierArgs,
|
args: SpecifierArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<bool, AnyError> {
|
) -> Result<bool, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
// we don't measure the performance of op_exists anymore because as of TS 4.5
|
// 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(
|
fn op_get_change_range(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: GetChangeRangeArgs,
|
args: GetChangeRangeArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mark = state.performance.mark("op_get_change_range", Some(&args));
|
let mark = state.performance.mark("op_get_change_range", Some(&args));
|
||||||
|
@ -2616,7 +2613,6 @@ fn op_get_change_range(
|
||||||
fn op_get_length(
|
fn op_get_length(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: SourceSnapshotArgs,
|
args: SourceSnapshotArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<usize, AnyError> {
|
) -> Result<usize, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mark = state.performance.mark("op_get_length", Some(&args));
|
let mark = state.performance.mark("op_get_length", Some(&args));
|
||||||
|
@ -2650,7 +2646,6 @@ struct GetTextArgs {
|
||||||
fn op_get_text(
|
fn op_get_text(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: GetTextArgs,
|
args: GetTextArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mark = state.performance.mark("op_get_text", Some(&args));
|
let mark = state.performance.mark("op_get_text", Some(&args));
|
||||||
|
@ -2670,11 +2665,7 @@ fn op_get_text(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_is_cancelled(
|
fn op_is_cancelled(state: &mut OpState) -> Result<bool, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<bool, AnyError> {
|
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
Ok(state.token.is_cancelled())
|
Ok(state.token.is_cancelled())
|
||||||
}
|
}
|
||||||
|
@ -2683,7 +2674,6 @@ fn op_is_cancelled(
|
||||||
fn op_load(
|
fn op_load(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: SpecifierArgs,
|
args: SpecifierArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<String>, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mark = state.performance.mark("op_load", Some(&args));
|
let mark = state.performance.mark("op_load", Some(&args));
|
||||||
|
@ -2697,7 +2687,6 @@ fn op_load(
|
||||||
fn op_resolve(
|
fn op_resolve(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ResolveArgs,
|
args: ResolveArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Vec<Option<(String, String)>>, AnyError> {
|
) -> Result<Vec<Option<(String, String)>>, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mark = state.performance.mark("op_resolve", Some(&args));
|
let mark = state.performance.mark("op_resolve", Some(&args));
|
||||||
|
@ -2731,11 +2720,7 @@ fn op_resolve(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_respond(
|
fn op_respond(state: &mut OpState, args: Response) -> Result<bool, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: Response,
|
|
||||||
_: (),
|
|
||||||
) -> Result<bool, AnyError> {
|
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
state.response = Some(args);
|
state.response = Some(args);
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
@ -2745,7 +2730,6 @@ fn op_respond(
|
||||||
fn op_script_names(
|
fn op_script_names(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_args: Value,
|
_args: Value,
|
||||||
_: (),
|
|
||||||
) -> Result<Vec<ModuleSpecifier>, AnyError> {
|
) -> Result<Vec<ModuleSpecifier>, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
Ok(
|
Ok(
|
||||||
|
@ -2769,7 +2753,6 @@ struct ScriptVersionArgs {
|
||||||
fn op_script_version(
|
fn op_script_version(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ScriptVersionArgs,
|
args: ScriptVersionArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<String>, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
// this op is very "noisy" and measuring its performance is not useful, so we
|
// this op is very "noisy" and measuring its performance is not useful, so we
|
||||||
|
@ -3881,7 +3864,6 @@ mod tests {
|
||||||
SpecifierArgs {
|
SpecifierArgs {
|
||||||
specifier: "/error/unknown:something/index.d.ts".to_string(),
|
specifier: "/error/unknown:something/index.d.ts".to_string(),
|
||||||
},
|
},
|
||||||
(),
|
|
||||||
);
|
);
|
||||||
assert!(actual.is_ok());
|
assert!(actual.is_ok());
|
||||||
let actual = actual.unwrap();
|
let actual = actual.unwrap();
|
||||||
|
|
|
@ -35,7 +35,6 @@ struct PermissionsHolder(Uuid, Permissions);
|
||||||
pub fn op_pledge_test_permissions(
|
pub fn op_pledge_test_permissions(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ChildPermissionsArg,
|
args: ChildPermissionsArg,
|
||||||
_: (),
|
|
||||||
) -> Result<Uuid, AnyError> {
|
) -> Result<Uuid, AnyError> {
|
||||||
let token = Uuid::new_v4();
|
let token = Uuid::new_v4();
|
||||||
let parent_permissions = state.borrow_mut::<Permissions>();
|
let parent_permissions = state.borrow_mut::<Permissions>();
|
||||||
|
@ -54,7 +53,6 @@ pub fn op_pledge_test_permissions(
|
||||||
pub fn op_restore_test_permissions(
|
pub fn op_restore_test_permissions(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
token: Uuid,
|
token: Uuid,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
|
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
|
||||||
if token != permissions_holder.0 {
|
if token != permissions_holder.0 {
|
||||||
|
@ -70,11 +68,7 @@ pub fn op_restore_test_permissions(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_get_bench_origin(
|
fn op_get_bench_origin(state: &mut OpState) -> Result<String, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
|
||||||
Ok(state.borrow::<ModuleSpecifier>().to_string())
|
Ok(state.borrow::<ModuleSpecifier>().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +76,6 @@ fn op_get_bench_origin(
|
||||||
fn op_dispatch_bench_event(
|
fn op_dispatch_bench_event(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
event: BenchEvent,
|
event: BenchEvent,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let sender = state.borrow::<UnboundedSender<BenchEvent>>().clone();
|
let sender = state.borrow::<UnboundedSender<BenchEvent>>().clone();
|
||||||
sender.send(event).ok();
|
sender.send(event).ok();
|
||||||
|
@ -91,7 +84,7 @@ fn op_dispatch_bench_event(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[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 = state.borrow::<time::Instant>().elapsed().as_nanos();
|
||||||
let ns_u64 = u64::try_from(ns)?;
|
let ns_u64 = u64::try_from(ns)?;
|
||||||
Ok(ns_u64)
|
Ok(ns_u64)
|
||||||
|
|
|
@ -46,7 +46,6 @@ struct AppliedSourceMap {
|
||||||
fn op_apply_source_map(
|
fn op_apply_source_map(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ApplySourceMap,
|
args: ApplySourceMap,
|
||||||
_: (),
|
|
||||||
) -> Result<AppliedSourceMap, AnyError> {
|
) -> Result<AppliedSourceMap, AnyError> {
|
||||||
let mut mappings_map: CachedMaps = HashMap::new();
|
let mut mappings_map: CachedMaps = HashMap::new();
|
||||||
let ps = state.borrow::<ProcState>().clone();
|
let ps = state.borrow::<ProcState>().clone();
|
||||||
|
@ -71,7 +70,6 @@ fn op_apply_source_map(
|
||||||
fn op_format_diagnostic(
|
fn op_format_diagnostic(
|
||||||
_state: &mut OpState,
|
_state: &mut OpState,
|
||||||
args: Value,
|
args: Value,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let diagnostic: Diagnostics = serde_json::from_value(args)?;
|
let diagnostic: Diagnostics = serde_json::from_value(args)?;
|
||||||
Ok(json!(diagnostic.to_string()))
|
Ok(json!(diagnostic.to_string()))
|
||||||
|
@ -81,7 +79,6 @@ fn op_format_diagnostic(
|
||||||
fn op_format_file_name(
|
fn op_format_file_name(
|
||||||
_state: &mut OpState,
|
_state: &mut OpState,
|
||||||
file_name: String,
|
file_name: String,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
Ok(format_file_name(&file_name))
|
Ok(format_file_name(&file_name))
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,6 @@ fn to_maybe_jsx_import_source_module(
|
||||||
async fn op_emit(
|
async fn op_emit(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: EmitArgs,
|
args: EmitArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<EmitResult, AnyError> {
|
) -> Result<EmitResult, AnyError> {
|
||||||
deno_runtime::ops::check_unstable2(&state, "Deno.emit");
|
deno_runtime::ops::check_unstable2(&state, "Deno.emit");
|
||||||
let root_specifier = args.root_specifier;
|
let root_specifier = args.root_specifier;
|
||||||
|
|
|
@ -33,7 +33,6 @@ struct PermissionsHolder(Uuid, Permissions);
|
||||||
pub fn op_pledge_test_permissions(
|
pub fn op_pledge_test_permissions(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ChildPermissionsArg,
|
args: ChildPermissionsArg,
|
||||||
_: (),
|
|
||||||
) -> Result<Uuid, AnyError> {
|
) -> Result<Uuid, AnyError> {
|
||||||
let token = Uuid::new_v4();
|
let token = Uuid::new_v4();
|
||||||
let parent_permissions = state.borrow_mut::<Permissions>();
|
let parent_permissions = state.borrow_mut::<Permissions>();
|
||||||
|
@ -52,7 +51,6 @@ pub fn op_pledge_test_permissions(
|
||||||
pub fn op_restore_test_permissions(
|
pub fn op_restore_test_permissions(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
token: Uuid,
|
token: Uuid,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
|
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
|
||||||
if token != permissions_holder.0 {
|
if token != permissions_holder.0 {
|
||||||
|
@ -68,11 +66,7 @@ pub fn op_restore_test_permissions(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_get_test_origin(
|
fn op_get_test_origin(state: &mut OpState) -> Result<String, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
|
||||||
Ok(state.borrow::<ModuleSpecifier>().to_string())
|
Ok(state.borrow::<ModuleSpecifier>().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +74,6 @@ fn op_get_test_origin(
|
||||||
fn op_dispatch_test_event(
|
fn op_dispatch_test_event(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
event: TestEvent,
|
event: TestEvent,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let sender = state.borrow::<UnboundedSender<TestEvent>>().clone();
|
let sender = state.borrow::<UnboundedSender<TestEvent>>().clone();
|
||||||
sender.send(event).ok();
|
sender.send(event).ok();
|
||||||
|
|
46
cli/tsc.rs
46
cli/tsc.rs
|
@ -307,11 +307,7 @@ struct CreateHashArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_create_hash(
|
fn op_create_hash(s: &mut OpState, args: Value) -> Result<Value, AnyError> {
|
||||||
s: &mut OpState,
|
|
||||||
args: Value,
|
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
|
||||||
let state = s.borrow_mut::<State>();
|
let state = s.borrow_mut::<State>();
|
||||||
let v: CreateHashArgs = serde_json::from_value(args)
|
let v: CreateHashArgs = serde_json::from_value(args)
|
||||||
.context("Invalid request from JavaScript for \"op_create_hash\".")?;
|
.context("Invalid request from JavaScript for \"op_create_hash\".")?;
|
||||||
|
@ -322,7 +318,7 @@ fn op_create_hash(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[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>();
|
let state = s.borrow_mut::<State>();
|
||||||
if let Some(config_specifier) = &state.maybe_config_specifier {
|
if let Some(config_specifier) = &state.maybe_config_specifier {
|
||||||
let cwd = config_specifier.join("./")?;
|
let cwd = config_specifier.join("./")?;
|
||||||
|
@ -347,11 +343,7 @@ struct EmitArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_emit(
|
fn op_emit(state: &mut OpState, args: EmitArgs) -> Result<Value, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: EmitArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
match args.file_name.as_ref() {
|
match args.file_name.as_ref() {
|
||||||
"deno:///.tsbuildinfo" => state.maybe_tsbuildinfo = Some(args.data),
|
"deno:///.tsbuildinfo" => state.maybe_tsbuildinfo = Some(args.data),
|
||||||
|
@ -406,11 +398,7 @@ struct ExistsArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_exists(
|
fn op_exists(state: &mut OpState, args: ExistsArgs) -> Result<bool, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: ExistsArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<bool, AnyError> {
|
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let graph_data = state.graph_data.read();
|
let graph_data = state.graph_data.read();
|
||||||
if let Ok(specifier) = normalize_specifier(&args.specifier) {
|
if let Ok(specifier) = normalize_specifier(&args.specifier) {
|
||||||
|
@ -452,7 +440,7 @@ fn as_ts_script_kind(media_type: &MediaType) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[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 state = state.borrow_mut::<State>();
|
||||||
let v: LoadArgs = serde_json::from_value(args)
|
let v: LoadArgs = serde_json::from_value(args)
|
||||||
.context("Invalid request from JavaScript for \"op_load\".")?;
|
.context("Invalid request from JavaScript for \"op_load\".")?;
|
||||||
|
@ -521,7 +509,6 @@ pub struct ResolveArgs {
|
||||||
fn op_resolve(
|
fn op_resolve(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ResolveArgs,
|
args: ResolveArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mut resolved: Vec<(String, String)> = Vec::new();
|
let mut resolved: Vec<(String, String)> = Vec::new();
|
||||||
|
@ -629,11 +616,7 @@ struct RespondArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_respond(
|
fn op_respond(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: Value,
|
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let v: RespondArgs = serde_json::from_value(args)
|
let v: RespondArgs = serde_json::from_value(args)
|
||||||
.context("Error converting the result for \"op_respond\".")?;
|
.context("Error converting the result for \"op_respond\".")?;
|
||||||
|
@ -881,7 +864,6 @@ mod tests {
|
||||||
let actual = op_create_hash::call(
|
let actual = op_create_hash::call(
|
||||||
&mut state,
|
&mut state,
|
||||||
json!({ "data": "some sort of content" }),
|
json!({ "data": "some sort of content" }),
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("could not invoke op");
|
.expect("could not invoke op");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -934,7 +916,6 @@ mod tests {
|
||||||
file_name: "cache:///some/file.js".to_string(),
|
file_name: "cache:///some/file.js".to_string(),
|
||||||
maybe_specifiers: Some(vec!["file:///some/file.ts".to_string()]),
|
maybe_specifiers: Some(vec!["file:///some/file.ts".to_string()]),
|
||||||
},
|
},
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
assert_eq!(actual, json!(true));
|
assert_eq!(actual, json!(true));
|
||||||
|
@ -966,7 +947,6 @@ mod tests {
|
||||||
vec!["file:///some/file.ts?q=.json".to_string()],
|
vec!["file:///some/file.ts?q=.json".to_string()],
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
assert_eq!(actual, json!(true));
|
assert_eq!(actual, json!(true));
|
||||||
|
@ -996,7 +976,6 @@ mod tests {
|
||||||
file_name: "deno:///.tsbuildinfo".to_string(),
|
file_name: "deno:///.tsbuildinfo".to_string(),
|
||||||
maybe_specifiers: None,
|
maybe_specifiers: None,
|
||||||
},
|
},
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
assert_eq!(actual, json!(true));
|
assert_eq!(actual, json!(true));
|
||||||
|
@ -1019,7 +998,6 @@ mod tests {
|
||||||
let actual = op_load::call(
|
let actual = op_load::call(
|
||||||
&mut state,
|
&mut state,
|
||||||
json!({ "specifier": "https://deno.land/x/mod.ts"}),
|
json!({ "specifier": "https://deno.land/x/mod.ts"}),
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1051,7 +1029,6 @@ mod tests {
|
||||||
let value = op_load::call(
|
let value = op_load::call(
|
||||||
&mut state,
|
&mut state,
|
||||||
json!({ "specifier": "asset:///lib.dom.d.ts" }),
|
json!({ "specifier": "asset:///lib.dom.d.ts" }),
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
let actual: LoadResponse =
|
let actual: LoadResponse =
|
||||||
|
@ -1070,11 +1047,8 @@ mod tests {
|
||||||
Some("some content".to_string()),
|
Some("some content".to_string()),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
let actual = op_load::call(
|
let actual =
|
||||||
&mut state,
|
op_load::call(&mut state, json!({ "specifier": "deno:///.tsbuildinfo"}))
|
||||||
json!({ "specifier": "deno:///.tsbuildinfo"}),
|
|
||||||
(),
|
|
||||||
)
|
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual,
|
actual,
|
||||||
|
@ -1092,7 +1066,6 @@ mod tests {
|
||||||
let actual = op_load::call(
|
let actual = op_load::call(
|
||||||
&mut state,
|
&mut state,
|
||||||
json!({ "specifier": "https://deno.land/x/mod.ts"}),
|
json!({ "specifier": "https://deno.land/x/mod.ts"}),
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1119,7 +1092,6 @@ mod tests {
|
||||||
base: "https://deno.land/x/a.ts".to_string(),
|
base: "https://deno.land/x/a.ts".to_string(),
|
||||||
specifiers: vec!["./b.ts".to_string()],
|
specifiers: vec!["./b.ts".to_string()],
|
||||||
},
|
},
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
assert_eq!(actual, json!([["https://deno.land/x/b.ts", ".ts"]]));
|
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(),
|
base: "https://deno.land/x/a.ts".to_string(),
|
||||||
specifiers: vec!["./bad.ts".to_string()],
|
specifiers: vec!["./bad.ts".to_string()],
|
||||||
},
|
},
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have not errored");
|
.expect("should have not errored");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1163,7 +1134,6 @@ mod tests {
|
||||||
],
|
],
|
||||||
"stats": [["a", 12]]
|
"stats": [["a", 12]]
|
||||||
}),
|
}),
|
||||||
(),
|
|
||||||
)
|
)
|
||||||
.expect("should have invoked op");
|
.expect("should have invoked op");
|
||||||
assert_eq!(actual, json!(true));
|
assert_eq!(actual, json!(true));
|
||||||
|
|
|
@ -17,7 +17,6 @@ use deno_core::*;
|
||||||
fn op_sum(
|
fn op_sum(
|
||||||
_state: &mut OpState,
|
_state: &mut OpState,
|
||||||
nums: Vec<f64>,
|
nums: Vec<f64>,
|
||||||
_: (),
|
|
||||||
) -> Result<f64, deno_core::error::AnyError> {
|
) -> Result<f64, deno_core::error::AnyError> {
|
||||||
// Sum inputs
|
// Sum inputs
|
||||||
let sum = nums.iter().fold(0.0, |a, v| a + v);
|
let sum = nums.iter().fold(0.0, |a, v| a + v);
|
||||||
|
|
|
@ -135,7 +135,7 @@ fn create_js_runtime() -> JsRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_listen(state: &mut OpState, _: (), _: ()) -> Result<ResourceId, Error> {
|
fn op_listen(state: &mut OpState) -> Result<ResourceId, Error> {
|
||||||
log::debug!("listen");
|
log::debug!("listen");
|
||||||
let addr = "127.0.0.1:4544".parse::<SocketAddr>().unwrap();
|
let addr = "127.0.0.1:4544".parse::<SocketAddr>().unwrap();
|
||||||
let std_listener = std::net::TcpListener::bind(&addr)?;
|
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(
|
async fn op_accept(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, Error> {
|
) -> Result<ResourceId, Error> {
|
||||||
log::debug!("accept rid={}", rid);
|
log::debug!("accept rid={}", rid);
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[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>>();
|
let tx = state.borrow_mut::<mpsc::UnboundedSender<Task>>();
|
||||||
tx.unbounded_send(Box::new(move || println!("Hello, world! x{}", i)))
|
tx.unbounded_send(Box::new(move || println!("Hello, world! x{}", i)))
|
||||||
.expect("unbounded_send failed");
|
.expect("unbounded_send failed");
|
||||||
|
|
|
@ -1406,7 +1406,7 @@ import "/a.js";
|
||||||
static DISPATCH_COUNT: AtomicUsize = AtomicUsize::new(0);
|
static DISPATCH_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
#[op]
|
#[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);
|
DISPATCH_COUNT.fetch_add(1, Ordering::Relaxed);
|
||||||
assert_eq!(control, 42);
|
assert_eq!(control, 42);
|
||||||
Ok(43)
|
Ok(43)
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub(crate) fn init_builtins() -> Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
pub fn void_op_sync(_: &mut OpState, _: (), _: ()) -> Result<(), Error> {
|
pub fn void_op_sync(_: &mut OpState) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,6 @@ pub async fn void_op_async(
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_resources(
|
pub fn op_resources(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<Vec<(ResourceId, String)>, Error> {
|
) -> Result<Vec<(ResourceId, String)>, Error> {
|
||||||
let serialized_resources = state
|
let serialized_resources = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -69,16 +67,12 @@ pub fn op_resources(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_void_sync(_state: &mut OpState, _: (), _: ()) -> Result<(), Error> {
|
pub fn op_void_sync(_state: &mut OpState) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
pub async fn op_void_async(
|
pub async fn op_void_async(_state: Rc<RefCell<OpState>>) -> Result<(), Error> {
|
||||||
_state: Rc<RefCell<OpState>>,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), Error> {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +81,6 @@ pub async fn op_void_async(
|
||||||
pub fn op_close(
|
pub fn op_close(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: Option<ResourceId>,
|
rid: Option<ResourceId>,
|
||||||
_: (),
|
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// TODO(@AaronO): drop Option after improving type-strictness balance in
|
// TODO(@AaronO): drop Option after improving type-strictness balance in
|
||||||
// serde_v8
|
// serde_v8
|
||||||
|
@ -102,7 +95,6 @@ pub fn op_close(
|
||||||
pub fn op_try_close(
|
pub fn op_try_close(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: Option<ResourceId>,
|
rid: Option<ResourceId>,
|
||||||
_: (),
|
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// TODO(@AaronO): drop Option after improving type-strictness balance in
|
// TODO(@AaronO): drop Option after improving type-strictness balance in
|
||||||
// serde_v8.
|
// serde_v8.
|
||||||
|
@ -114,8 +106,6 @@ pub fn op_try_close(
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_metrics(
|
pub fn op_metrics(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(OpMetrics, Vec<OpMetrics>), Error> {
|
) -> Result<(OpMetrics, Vec<OpMetrics>), Error> {
|
||||||
let aggregate = state.tracker.aggregate();
|
let aggregate = state.tracker.aggregate();
|
||||||
let per_op = state.tracker.per_op();
|
let per_op = state.tracker.per_op();
|
||||||
|
@ -229,7 +219,6 @@ async fn op_write(
|
||||||
async fn op_shutdown(
|
async fn op_shutdown(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let resource = state.borrow().resource_table.get_any(rid)?;
|
let resource = state.borrow().resource_table.get_any(rid)?;
|
||||||
resource.shutdown().await
|
resource.shutdown().await
|
||||||
|
|
|
@ -2062,7 +2062,7 @@ pub mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_error_builder() {
|
fn test_error_builder() {
|
||||||
#[op]
|
#[op]
|
||||||
fn op_err(_: &mut OpState, _: (), _: ()) -> Result<(), Error> {
|
fn op_err(_: &mut OpState) -> Result<(), Error> {
|
||||||
Err(custom_error("DOMExceptionOperationError", "abc"))
|
Err(custom_error("DOMExceptionOperationError", "abc"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2468,8 +2468,6 @@ assertEquals(1, notify_return_value);
|
||||||
#[op]
|
#[op]
|
||||||
async fn op_async_borrow(
|
async fn op_async_borrow(
|
||||||
op_state: Rc<RefCell<OpState>>,
|
op_state: Rc<RefCell<OpState>>,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let n = {
|
let n = {
|
||||||
let op_state = op_state.borrow();
|
let op_state = op_state.borrow();
|
||||||
|
@ -2511,8 +2509,6 @@ assertEquals(1, notify_return_value);
|
||||||
#[op]
|
#[op]
|
||||||
async fn op_async_sleep(
|
async fn op_async_sleep(
|
||||||
_op_state: Rc<RefCell<OpState>>,
|
_op_state: Rc<RefCell<OpState>>,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// Future must be Poll::Pending on first call
|
// Future must be Poll::Pending on first call
|
||||||
tokio::time::sleep(std::time::Duration::from_millis(1)).await;
|
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);
|
static NEXT_TICK: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_macrotask(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
|
fn op_macrotask(_: &mut OpState) -> Result<(), AnyError> {
|
||||||
MACROTASK.fetch_add(1, Ordering::Relaxed);
|
MACROTASK.fetch_add(1, Ordering::Relaxed);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_next_tick(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
|
fn op_next_tick(_: &mut OpState) -> Result<(), AnyError> {
|
||||||
NEXT_TICK.fetch_add(1, Ordering::Relaxed);
|
NEXT_TICK.fetch_add(1, Ordering::Relaxed);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -2725,21 +2721,13 @@ assertEquals(1, notify_return_value);
|
||||||
static UNCAUGHT_EXCEPTION: AtomicUsize = AtomicUsize::new(0);
|
static UNCAUGHT_EXCEPTION: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_promise_reject(
|
fn op_promise_reject(_: &mut OpState) -> Result<(), AnyError> {
|
||||||
_: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
PROMISE_REJECT.fetch_add(1, Ordering::Relaxed);
|
PROMISE_REJECT.fetch_add(1, Ordering::Relaxed);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_uncaught_exception(
|
fn op_uncaught_exception(_: &mut OpState) -> Result<(), AnyError> {
|
||||||
_: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
UNCAUGHT_EXCEPTION.fetch_add(1, Ordering::Relaxed);
|
UNCAUGHT_EXCEPTION.fetch_add(1, Ordering::Relaxed);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,6 @@ struct Unstable(bool); // --unstable
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_broadcast_subscribe<BC>(
|
pub fn op_broadcast_subscribe<BC>(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError>
|
) -> Result<ResourceId, AnyError>
|
||||||
where
|
where
|
||||||
BC: BroadcastChannel + 'static,
|
BC: BroadcastChannel + 'static,
|
||||||
|
@ -97,7 +95,6 @@ where
|
||||||
pub async fn op_broadcast_recv<BC>(
|
pub async fn op_broadcast_recv<BC>(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<Message>, AnyError>
|
) -> Result<Option<Message>, AnyError>
|
||||||
where
|
where
|
||||||
BC: BroadcastChannel + 'static,
|
BC: BroadcastChannel + 'static,
|
||||||
|
|
|
@ -46,7 +46,6 @@ pub enum GenerateKeyOptions {
|
||||||
pub async fn op_crypto_generate_key(
|
pub async fn op_crypto_generate_key(
|
||||||
_state: Rc<RefCell<OpState>>,
|
_state: Rc<RefCell<OpState>>,
|
||||||
opts: GenerateKeyOptions,
|
opts: GenerateKeyOptions,
|
||||||
_: (),
|
|
||||||
) -> Result<ZeroCopyBuf, AnyError> {
|
) -> Result<ZeroCopyBuf, AnyError> {
|
||||||
let fun = || match opts {
|
let fun = || match opts {
|
||||||
GenerateKeyOptions::Rsa {
|
GenerateKeyOptions::Rsa {
|
||||||
|
|
|
@ -115,7 +115,6 @@ pub fn init(maybe_seed: Option<u64>) -> Extension {
|
||||||
pub fn op_crypto_get_random_values(
|
pub fn op_crypto_get_random_values(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
mut zero_copy: ZeroCopyBuf,
|
mut zero_copy: ZeroCopyBuf,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
if zero_copy.len() > 65536 {
|
if zero_copy.len() > 65536 {
|
||||||
return Err(
|
return Err(
|
||||||
|
@ -791,11 +790,7 @@ impl<'a> TryFrom<rsa::pkcs8::der::asn1::Any<'a>>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_crypto_random_uuid(
|
pub fn op_crypto_random_uuid(state: &mut OpState) -> Result<String, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
|
||||||
let maybe_seeded_rng = state.try_borrow_mut::<StdRng>();
|
let maybe_seeded_rng = state.try_borrow_mut::<StdRng>();
|
||||||
let uuid = if let Some(seeded_rng) = maybe_seeded_rng {
|
let uuid = if let Some(seeded_rng) = maybe_seeded_rng {
|
||||||
let mut bytes = [0u8; 16];
|
let mut bytes = [0u8; 16];
|
||||||
|
|
|
@ -369,7 +369,6 @@ pub struct FetchResponse {
|
||||||
pub async fn op_fetch_send(
|
pub async fn op_fetch_send(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<FetchResponse, AnyError> {
|
) -> Result<FetchResponse, AnyError> {
|
||||||
let request = state
|
let request = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -528,7 +527,6 @@ pub struct CreateHttpClientOptions {
|
||||||
pub fn op_fetch_custom_client<FP>(
|
pub fn op_fetch_custom_client<FP>(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateHttpClientOptions,
|
args: CreateHttpClientOptions,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError>
|
) -> Result<ResourceId, AnyError>
|
||||||
where
|
where
|
||||||
FP: FetchPermissions + 'static,
|
FP: FetchPermissions + 'static,
|
||||||
|
|
|
@ -465,7 +465,6 @@ pub(crate) fn format_error(e: dlopen::Error, path: String) -> String {
|
||||||
fn op_ffi_load<FP>(
|
fn op_ffi_load<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
args: FfiLoadArgs,
|
args: FfiLoadArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError>
|
) -> Result<ResourceId, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -652,7 +651,6 @@ fn ffi_call(args: FfiCallArgs, symbol: &Symbol) -> Result<Value, AnyError> {
|
||||||
fn op_ffi_call_ptr(
|
fn op_ffi_call_ptr(
|
||||||
_state: &mut deno_core::OpState,
|
_state: &mut deno_core::OpState,
|
||||||
args: FfiCallPtrArgs,
|
args: FfiCallPtrArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let symbol = args.get_symbol();
|
let symbol = args.get_symbol();
|
||||||
ffi_call(args.into(), &symbol)
|
ffi_call(args.into(), &symbol)
|
||||||
|
@ -662,7 +660,6 @@ fn op_ffi_call_ptr(
|
||||||
async fn op_ffi_call_ptr_nonblocking(
|
async fn op_ffi_call_ptr_nonblocking(
|
||||||
_state: Rc<RefCell<deno_core::OpState>>,
|
_state: Rc<RefCell<deno_core::OpState>>,
|
||||||
args: FfiCallPtrArgs,
|
args: FfiCallPtrArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let symbol = args.get_symbol();
|
let symbol = args.get_symbol();
|
||||||
tokio::task::spawn_blocking(move || ffi_call(args.into(), &symbol))
|
tokio::task::spawn_blocking(move || ffi_call(args.into(), &symbol))
|
||||||
|
@ -682,7 +679,6 @@ struct FfiGetArgs {
|
||||||
fn op_ffi_get_static(
|
fn op_ffi_get_static(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
args: FfiGetArgs,
|
args: FfiGetArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -740,7 +736,6 @@ fn op_ffi_get_static(
|
||||||
fn op_ffi_call(
|
fn op_ffi_call(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
args: FfiCallArgs,
|
args: FfiCallArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -759,7 +754,6 @@ fn op_ffi_call(
|
||||||
async fn op_ffi_call_nonblocking(
|
async fn op_ffi_call_nonblocking(
|
||||||
state: Rc<RefCell<deno_core::OpState>>,
|
state: Rc<RefCell<deno_core::OpState>>,
|
||||||
args: FfiCallArgs,
|
args: FfiCallArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
|
@ -780,7 +774,6 @@ async fn op_ffi_call_nonblocking(
|
||||||
fn op_ffi_ptr_of<FP>(
|
fn op_ffi_ptr_of<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
buf: ZeroCopyBuf,
|
buf: ZeroCopyBuf,
|
||||||
_: (),
|
|
||||||
) -> Result<U32x2, AnyError>
|
) -> Result<U32x2, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -795,7 +788,6 @@ where
|
||||||
fn op_ffi_buf_copy_into<FP>(
|
fn op_ffi_buf_copy_into<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
(src, mut dst, len): (U32x2, ZeroCopyBuf, usize),
|
(src, mut dst, len): (U32x2, ZeroCopyBuf, usize),
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError>
|
) -> Result<(), AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -818,7 +810,6 @@ where
|
||||||
fn op_ffi_cstr_read<FP>(
|
fn op_ffi_cstr_read<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError>
|
) -> Result<String, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -834,7 +825,6 @@ where
|
||||||
fn op_ffi_read_u8<FP>(
|
fn op_ffi_read_u8<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<u8, AnyError>
|
) -> Result<u8, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -849,7 +839,6 @@ where
|
||||||
fn op_ffi_read_i8<FP>(
|
fn op_ffi_read_i8<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<i8, AnyError>
|
) -> Result<i8, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -864,7 +853,6 @@ where
|
||||||
fn op_ffi_read_u16<FP>(
|
fn op_ffi_read_u16<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<u16, AnyError>
|
) -> Result<u16, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -879,7 +867,6 @@ where
|
||||||
fn op_ffi_read_i16<FP>(
|
fn op_ffi_read_i16<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<i16, AnyError>
|
) -> Result<i16, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -894,7 +881,6 @@ where
|
||||||
fn op_ffi_read_u32<FP>(
|
fn op_ffi_read_u32<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<u32, AnyError>
|
) -> Result<u32, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -909,7 +895,6 @@ where
|
||||||
fn op_ffi_read_i32<FP>(
|
fn op_ffi_read_i32<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<i32, AnyError>
|
) -> Result<i32, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -924,7 +909,6 @@ where
|
||||||
fn op_ffi_read_u64<FP>(
|
fn op_ffi_read_u64<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<U32x2, AnyError>
|
) -> Result<U32x2, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -941,7 +925,6 @@ where
|
||||||
fn op_ffi_read_f32<FP>(
|
fn op_ffi_read_f32<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<f32, AnyError>
|
) -> Result<f32, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
@ -956,7 +939,6 @@ where
|
||||||
fn op_ffi_read_f64<FP>(
|
fn op_ffi_read_f64<FP>(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
ptr: U32x2,
|
ptr: U32x2,
|
||||||
_: (),
|
|
||||||
) -> Result<f64, AnyError>
|
) -> Result<f64, AnyError>
|
||||||
where
|
where
|
||||||
FP: FfiPermissions + 'static,
|
FP: FfiPermissions + 'static,
|
||||||
|
|
|
@ -369,7 +369,6 @@ struct NextRequestResponse(
|
||||||
async fn op_http_accept(
|
async fn op_http_accept(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<NextRequestResponse>, AnyError> {
|
) -> Result<Option<NextRequestResponse>, AnyError> {
|
||||||
let conn = state.borrow().resource_table.get::<HttpConnResource>(rid)?;
|
let conn = state.borrow().resource_table.get::<HttpConnResource>(rid)?;
|
||||||
|
|
||||||
|
@ -738,7 +737,6 @@ async fn op_http_write(
|
||||||
async fn op_http_shutdown(
|
async fn op_http_shutdown(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let stream = state
|
let stream = state
|
||||||
.borrow()
|
.borrow()
|
||||||
|
@ -802,7 +800,6 @@ async fn op_http_read(
|
||||||
fn op_http_websocket_accept_header(
|
fn op_http_websocket_accept_header(
|
||||||
_: &mut OpState,
|
_: &mut OpState,
|
||||||
key: String,
|
key: String,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let digest = ring::digest::digest(
|
let digest = ring::digest::digest(
|
||||||
&ring::digest::SHA1_FOR_LEGACY_USE_ONLY,
|
&ring::digest::SHA1_FOR_LEGACY_USE_ONLY,
|
||||||
|
@ -815,7 +812,6 @@ fn op_http_websocket_accept_header(
|
||||||
async fn op_http_upgrade_websocket(
|
async fn op_http_upgrade_websocket(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, AnyError> {
|
||||||
let stream = state
|
let stream = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
|
@ -162,7 +162,6 @@ async fn accept_tcp(
|
||||||
async fn op_net_accept(
|
async fn op_net_accept(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: AcceptArgs,
|
args: AcceptArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<OpConn, AnyError> {
|
) -> Result<OpConn, AnyError> {
|
||||||
match args.transport.as_str() {
|
match args.transport.as_str() {
|
||||||
"tcp" => accept_tcp(state, args, ()).await,
|
"tcp" => accept_tcp(state, args, ()).await,
|
||||||
|
@ -306,7 +305,6 @@ pub struct ConnectArgs {
|
||||||
pub async fn op_net_connect<NP>(
|
pub async fn op_net_connect<NP>(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: ConnectArgs,
|
args: ConnectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<OpConn, AnyError>
|
) -> Result<OpConn, AnyError>
|
||||||
where
|
where
|
||||||
NP: NetPermissions + 'static,
|
NP: NetPermissions + 'static,
|
||||||
|
@ -482,7 +480,6 @@ fn listen_udp(
|
||||||
fn op_net_listen<NP>(
|
fn op_net_listen<NP>(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ListenArgs,
|
args: ListenArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<OpConn, AnyError>
|
) -> Result<OpConn, AnyError>
|
||||||
where
|
where
|
||||||
NP: NetPermissions + 'static,
|
NP: NetPermissions + 'static,
|
||||||
|
@ -622,7 +619,6 @@ pub struct NameServer {
|
||||||
pub async fn op_dns_resolve<NP>(
|
pub async fn op_dns_resolve<NP>(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: ResolveAddrArgs,
|
args: ResolveAddrArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<Vec<DnsReturnRecord>, AnyError>
|
) -> Result<Vec<DnsReturnRecord>, AnyError>
|
||||||
where
|
where
|
||||||
NP: NetPermissions + 'static,
|
NP: NetPermissions + 'static,
|
||||||
|
@ -942,7 +938,7 @@ mod tests {
|
||||||
};
|
};
|
||||||
|
|
||||||
let connect_fut =
|
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 conn = connect_fut.await.unwrap();
|
||||||
|
|
||||||
let rid = conn.rid;
|
let rid = conn.rid;
|
||||||
|
|
|
@ -769,7 +769,6 @@ pub struct StartTlsArgs {
|
||||||
pub async fn op_tls_start<NP>(
|
pub async fn op_tls_start<NP>(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: StartTlsArgs,
|
args: StartTlsArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<OpConn, AnyError>
|
) -> Result<OpConn, AnyError>
|
||||||
where
|
where
|
||||||
NP: NetPermissions + 'static,
|
NP: NetPermissions + 'static,
|
||||||
|
@ -862,7 +861,6 @@ where
|
||||||
pub async fn op_tls_connect<NP>(
|
pub async fn op_tls_connect<NP>(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: ConnectTlsArgs,
|
args: ConnectTlsArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<OpConn, AnyError>
|
) -> Result<OpConn, AnyError>
|
||||||
where
|
where
|
||||||
NP: NetPermissions + 'static,
|
NP: NetPermissions + 'static,
|
||||||
|
@ -1022,7 +1020,6 @@ pub struct ListenTlsArgs {
|
||||||
pub fn op_tls_listen<NP>(
|
pub fn op_tls_listen<NP>(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ListenTlsArgs,
|
args: ListenTlsArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<OpConn, AnyError>
|
) -> Result<OpConn, AnyError>
|
||||||
where
|
where
|
||||||
NP: NetPermissions + 'static,
|
NP: NetPermissions + 'static,
|
||||||
|
@ -1119,7 +1116,6 @@ where
|
||||||
pub async fn op_tls_accept(
|
pub async fn op_tls_accept(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<OpConn, AnyError> {
|
) -> Result<OpConn, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
|
@ -1171,7 +1167,6 @@ pub async fn op_tls_accept(
|
||||||
pub async fn op_tls_handshake(
|
pub async fn op_tls_handshake(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<TlsHandshakeInfo, AnyError> {
|
) -> Result<TlsHandshakeInfo, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
|
|
|
@ -184,7 +184,6 @@ pub fn op_url_parse_search_params(
|
||||||
pub fn op_url_stringify_search_params(
|
pub fn op_url_stringify_search_params(
|
||||||
_state: &mut deno_core::OpState,
|
_state: &mut deno_core::OpState,
|
||||||
args: Vec<(String, String)>,
|
args: Vec<(String, String)>,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let search = form_urlencoded::Serializer::new(String::new())
|
let search = form_urlencoded::Serializer::new(String::new())
|
||||||
.extend_pairs(args)
|
.extend_pairs(args)
|
||||||
|
|
|
@ -163,7 +163,6 @@ impl BlobPart for SlicedBlobPart {
|
||||||
pub fn op_blob_create_part(
|
pub fn op_blob_create_part(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
data: ZeroCopyBuf,
|
data: ZeroCopyBuf,
|
||||||
_: (),
|
|
||||||
) -> Result<Uuid, AnyError> {
|
) -> Result<Uuid, AnyError> {
|
||||||
let blob_store = state.borrow::<BlobStore>();
|
let blob_store = state.borrow::<BlobStore>();
|
||||||
let part = InMemoryBlobPart(data.to_vec());
|
let part = InMemoryBlobPart(data.to_vec());
|
||||||
|
@ -208,7 +207,6 @@ pub fn op_blob_slice_part(
|
||||||
pub async fn op_blob_read_part(
|
pub async fn op_blob_read_part(
|
||||||
state: Rc<RefCell<deno_core::OpState>>,
|
state: Rc<RefCell<deno_core::OpState>>,
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
_: (),
|
|
||||||
) -> Result<ZeroCopyBuf, AnyError> {
|
) -> Result<ZeroCopyBuf, AnyError> {
|
||||||
let part = {
|
let part = {
|
||||||
let state = state.borrow();
|
let state = state.borrow();
|
||||||
|
@ -224,7 +222,6 @@ pub async fn op_blob_read_part(
|
||||||
pub fn op_blob_remove_part(
|
pub fn op_blob_remove_part(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let blob_store = state.borrow::<BlobStore>();
|
let blob_store = state.borrow::<BlobStore>();
|
||||||
blob_store.remove_part(&id);
|
blob_store.remove_part(&id);
|
||||||
|
@ -261,7 +258,6 @@ pub fn op_blob_create_object_url(
|
||||||
pub fn op_blob_revoke_object_url(
|
pub fn op_blob_revoke_object_url(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
url: String,
|
url: String,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let url = Url::parse(&url)?;
|
let url = Url::parse(&url)?;
|
||||||
let blob_store = state.borrow::<BlobStore>();
|
let blob_store = state.borrow::<BlobStore>();
|
||||||
|
@ -285,7 +281,6 @@ pub struct ReturnBlobPart {
|
||||||
pub fn op_blob_from_object_url(
|
pub fn op_blob_from_object_url(
|
||||||
state: &mut deno_core::OpState,
|
state: &mut deno_core::OpState,
|
||||||
url: String,
|
url: String,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<ReturnBlob>, AnyError> {
|
) -> Result<Option<ReturnBlob>, AnyError> {
|
||||||
let url = Url::parse(&url)?;
|
let url = Url::parse(&url)?;
|
||||||
if url.scheme() != "blob" {
|
if url.scheme() != "blob" {
|
||||||
|
|
|
@ -93,7 +93,6 @@ pub fn op_compression_write(
|
||||||
pub fn op_compression_finish(
|
pub fn op_compression_finish(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<ZeroCopyBuf, AnyError> {
|
) -> Result<ZeroCopyBuf, AnyError> {
|
||||||
let resource = state.resource_table.take::<CompressionResource>(rid)?;
|
let resource = state.resource_table.take::<CompressionResource>(rid)?;
|
||||||
let resource = Rc::try_unwrap(resource).unwrap();
|
let resource = Rc::try_unwrap(resource).unwrap();
|
||||||
|
|
|
@ -123,7 +123,6 @@ pub fn init<P: TimersPermission + 'static>(
|
||||||
fn op_base64_decode(
|
fn op_base64_decode(
|
||||||
_: &mut OpState,
|
_: &mut OpState,
|
||||||
input: String,
|
input: String,
|
||||||
_: (),
|
|
||||||
) -> Result<ZeroCopyBuf, AnyError> {
|
) -> Result<ZeroCopyBuf, AnyError> {
|
||||||
let mut input = input.into_bytes();
|
let mut input = input.into_bytes();
|
||||||
input.retain(|c| !c.is_ascii_whitespace());
|
input.retain(|c| !c.is_ascii_whitespace());
|
||||||
|
@ -134,7 +133,6 @@ fn op_base64_decode(
|
||||||
fn op_base64_atob(
|
fn op_base64_atob(
|
||||||
_: &mut OpState,
|
_: &mut OpState,
|
||||||
s: ByteString,
|
s: ByteString,
|
||||||
_: (),
|
|
||||||
) -> Result<ByteString, AnyError> {
|
) -> Result<ByteString, AnyError> {
|
||||||
let mut s = s.0;
|
let mut s = s.0;
|
||||||
s.retain(|c| !c.is_ascii_whitespace());
|
s.retain(|c| !c.is_ascii_whitespace());
|
||||||
|
@ -188,17 +186,12 @@ fn b64_decode(input: &[u8]) -> Result<Vec<u8>, AnyError> {
|
||||||
fn op_base64_encode(
|
fn op_base64_encode(
|
||||||
_: &mut OpState,
|
_: &mut OpState,
|
||||||
s: ZeroCopyBuf,
|
s: ZeroCopyBuf,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
Ok(b64_encode(&s))
|
Ok(b64_encode(&s))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_base64_btoa(
|
fn op_base64_btoa(_: &mut OpState, s: ByteString) -> Result<String, AnyError> {
|
||||||
_: &mut OpState,
|
|
||||||
s: ByteString,
|
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
|
||||||
Ok(b64_encode(&s))
|
Ok(b64_encode(&s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +213,6 @@ struct DecoderOptions {
|
||||||
fn op_encoding_normalize_label(
|
fn op_encoding_normalize_label(
|
||||||
_state: &mut OpState,
|
_state: &mut OpState,
|
||||||
label: String,
|
label: String,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let encoding = Encoding::for_label_no_replacement(label.as_bytes())
|
let encoding = Encoding::for_label_no_replacement(label.as_bytes())
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
|
@ -236,7 +228,6 @@ fn op_encoding_normalize_label(
|
||||||
fn op_encoding_new_decoder(
|
fn op_encoding_new_decoder(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
options: DecoderOptions,
|
options: DecoderOptions,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, AnyError> {
|
||||||
let DecoderOptions {
|
let DecoderOptions {
|
||||||
label,
|
label,
|
||||||
|
|
|
@ -109,8 +109,6 @@ impl Resource for MessagePortResource {
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_message_port_create_entangled(
|
pub fn op_message_port_create_entangled(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(ResourceId, ResourceId), AnyError> {
|
) -> Result<(ResourceId, ResourceId), AnyError> {
|
||||||
let (port1, port2) = create_entangled_message_port();
|
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(
|
pub async fn op_message_port_recv_message(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<JsMessageData>, AnyError> {
|
) -> Result<Option<JsMessageData>, AnyError> {
|
||||||
let resource = {
|
let resource = {
|
||||||
let state = state.borrow();
|
let state = state.borrow();
|
||||||
|
|
|
@ -28,11 +28,7 @@ pub type StartTime = Instant;
|
||||||
// If the High precision flag is not set, the
|
// If the High precision flag is not set, the
|
||||||
// nanoseconds are rounded on 2ms.
|
// nanoseconds are rounded on 2ms.
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_now<TP>(
|
pub fn op_now<TP>(state: &mut OpState, _argument: ()) -> Result<f64, AnyError>
|
||||||
state: &mut OpState,
|
|
||||||
_argument: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<f64, AnyError>
|
|
||||||
where
|
where
|
||||||
TP: TimersPermission + 'static,
|
TP: TimersPermission + 'static,
|
||||||
{
|
{
|
||||||
|
@ -68,11 +64,7 @@ impl Resource for TimerHandle {
|
||||||
/// Creates a [`TimerHandle`] resource that can be used to cancel invocations of
|
/// Creates a [`TimerHandle`] resource that can be used to cancel invocations of
|
||||||
/// [`op_sleep`].
|
/// [`op_sleep`].
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_timer_handle(
|
pub fn op_timer_handle(state: &mut OpState) -> Result<ResourceId, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
|
||||||
let rid = state
|
let rid = state
|
||||||
.resource_table
|
.resource_table
|
||||||
.add(TimerHandle(CancelHandle::new_rc()));
|
.add(TimerHandle(CancelHandle::new_rc()));
|
||||||
|
@ -98,7 +90,6 @@ pub async fn op_sleep(
|
||||||
pub fn op_sleep_sync<TP>(
|
pub fn op_sleep_sync<TP>(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
millis: u64,
|
millis: u64,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError>
|
) -> Result<(), AnyError>
|
||||||
where
|
where
|
||||||
TP: TimersPermission + 'static,
|
TP: TimersPermission + 'static,
|
||||||
|
|
|
@ -182,7 +182,6 @@ pub struct CreateBindGroupLayoutArgs {
|
||||||
pub fn op_webgpu_create_bind_group_layout(
|
pub fn op_webgpu_create_bind_group_layout(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateBindGroupLayoutArgs,
|
args: CreateBindGroupLayoutArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -226,7 +225,6 @@ pub struct CreatePipelineLayoutArgs {
|
||||||
pub fn op_webgpu_create_pipeline_layout(
|
pub fn op_webgpu_create_pipeline_layout(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreatePipelineLayoutArgs,
|
args: CreatePipelineLayoutArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -278,7 +276,6 @@ pub struct CreateBindGroupArgs {
|
||||||
pub fn op_webgpu_create_bind_group(
|
pub fn op_webgpu_create_bind_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateBindGroupArgs,
|
args: CreateBindGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
|
|
@ -46,7 +46,6 @@ pub struct CreateBufferArgs {
|
||||||
pub fn op_webgpu_create_buffer(
|
pub fn op_webgpu_create_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateBufferArgs,
|
args: CreateBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -83,7 +82,6 @@ pub struct BufferGetMapAsyncArgs {
|
||||||
pub async fn op_webgpu_buffer_get_map_async(
|
pub async fn op_webgpu_buffer_get_map_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: BufferGetMapAsyncArgs,
|
args: BufferGetMapAsyncArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let (sender, receiver) = oneshot::channel::<Result<(), AnyError>>();
|
let (sender, receiver) = oneshot::channel::<Result<(), AnyError>>();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ pub struct CreateRenderBundleEncoderArgs {
|
||||||
pub fn op_webgpu_create_render_bundle_encoder(
|
pub fn op_webgpu_create_render_bundle_encoder(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateRenderBundleEncoderArgs,
|
args: CreateRenderBundleEncoderArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -105,7 +104,6 @@ pub struct RenderBundleEncoderFinishArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_finish(
|
pub fn op_webgpu_render_bundle_encoder_finish(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderFinishArgs,
|
args: RenderBundleEncoderFinishArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource =
|
let render_bundle_encoder_resource =
|
||||||
state
|
state
|
||||||
|
@ -142,7 +140,6 @@ pub struct RenderBundleEncoderSetBindGroupArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_set_bind_group(
|
pub fn op_webgpu_render_bundle_encoder_set_bind_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderSetBindGroupArgs,
|
args: RenderBundleEncoderSetBindGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let bind_group_resource =
|
let bind_group_resource =
|
||||||
state
|
state
|
||||||
|
@ -197,7 +194,6 @@ pub struct RenderBundleEncoderPushDebugGroupArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_push_debug_group(
|
pub fn op_webgpu_render_bundle_encoder_push_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderPushDebugGroupArgs,
|
args: RenderBundleEncoderPushDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource =
|
let render_bundle_encoder_resource =
|
||||||
state
|
state
|
||||||
|
@ -227,7 +223,6 @@ pub struct RenderBundleEncoderPopDebugGroupArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_pop_debug_group(
|
pub fn op_webgpu_render_bundle_encoder_pop_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderPopDebugGroupArgs,
|
args: RenderBundleEncoderPopDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource =
|
let render_bundle_encoder_resource =
|
||||||
state
|
state
|
||||||
|
@ -252,7 +247,6 @@ pub struct RenderBundleEncoderInsertDebugMarkerArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_insert_debug_marker(
|
pub fn op_webgpu_render_bundle_encoder_insert_debug_marker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderInsertDebugMarkerArgs,
|
args: RenderBundleEncoderInsertDebugMarkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource =
|
let render_bundle_encoder_resource =
|
||||||
state
|
state
|
||||||
|
@ -283,7 +277,6 @@ pub struct RenderBundleEncoderSetPipelineArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_set_pipeline(
|
pub fn op_webgpu_render_bundle_encoder_set_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderSetPipelineArgs,
|
args: RenderBundleEncoderSetPipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pipeline_resource =
|
let render_pipeline_resource =
|
||||||
state
|
state
|
||||||
|
@ -316,7 +309,6 @@ pub struct RenderBundleEncoderSetIndexBufferArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_set_index_buffer(
|
pub fn op_webgpu_render_bundle_encoder_set_index_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderSetIndexBufferArgs,
|
args: RenderBundleEncoderSetIndexBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -353,7 +345,6 @@ pub struct RenderBundleEncoderSetVertexBufferArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_set_vertex_buffer(
|
pub fn op_webgpu_render_bundle_encoder_set_vertex_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderSetVertexBufferArgs,
|
args: RenderBundleEncoderSetVertexBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -388,7 +379,6 @@ pub struct RenderBundleEncoderDrawArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_draw(
|
pub fn op_webgpu_render_bundle_encoder_draw(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderDrawArgs,
|
args: RenderBundleEncoderDrawArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource =
|
let render_bundle_encoder_resource =
|
||||||
state
|
state
|
||||||
|
@ -421,7 +411,6 @@ pub struct RenderBundleEncoderDrawIndexedArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_draw_indexed(
|
pub fn op_webgpu_render_bundle_encoder_draw_indexed(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderDrawIndexedArgs,
|
args: RenderBundleEncoderDrawIndexedArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_bundle_encoder_resource =
|
let render_bundle_encoder_resource =
|
||||||
state
|
state
|
||||||
|
@ -452,7 +441,6 @@ pub struct RenderBundleEncoderDrawIndirectArgs {
|
||||||
pub fn op_webgpu_render_bundle_encoder_draw_indirect(
|
pub fn op_webgpu_render_bundle_encoder_draw_indirect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderBundleEncoderDrawIndirectArgs,
|
args: RenderBundleEncoderDrawIndirectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
|
|
@ -41,7 +41,6 @@ pub struct CreateCommandEncoderArgs {
|
||||||
pub fn op_webgpu_create_command_encoder(
|
pub fn op_webgpu_create_command_encoder(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateCommandEncoderArgs,
|
args: CreateCommandEncoderArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -102,7 +101,6 @@ pub struct CommandEncoderBeginRenderPassArgs {
|
||||||
pub fn op_webgpu_command_encoder_begin_render_pass(
|
pub fn op_webgpu_command_encoder_begin_render_pass(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderBeginRenderPassArgs,
|
args: CommandEncoderBeginRenderPassArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -221,7 +219,6 @@ pub struct CommandEncoderBeginComputePassArgs {
|
||||||
pub fn op_webgpu_command_encoder_begin_compute_pass(
|
pub fn op_webgpu_command_encoder_begin_compute_pass(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderBeginComputePassArgs,
|
args: CommandEncoderBeginComputePassArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -260,7 +257,6 @@ pub struct CommandEncoderCopyBufferToBufferArgs {
|
||||||
pub fn op_webgpu_command_encoder_copy_buffer_to_buffer(
|
pub fn op_webgpu_command_encoder_copy_buffer_to_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderCopyBufferToBufferArgs,
|
args: CommandEncoderCopyBufferToBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -319,7 +315,6 @@ pub struct CommandEncoderCopyBufferToTextureArgs {
|
||||||
pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
|
pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderCopyBufferToTextureArgs,
|
args: CommandEncoderCopyBufferToTextureArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -370,7 +365,6 @@ pub struct CommandEncoderCopyTextureToBufferArgs {
|
||||||
pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
|
pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderCopyTextureToBufferArgs,
|
args: CommandEncoderCopyTextureToBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -425,7 +419,6 @@ pub struct CommandEncoderCopyTextureToTextureArgs {
|
||||||
pub fn op_webgpu_command_encoder_copy_texture_to_texture(
|
pub fn op_webgpu_command_encoder_copy_texture_to_texture(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderCopyTextureToTextureArgs,
|
args: CommandEncoderCopyTextureToTextureArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -474,7 +467,6 @@ pub struct CommandEncoderClearBufferArgs {
|
||||||
pub fn op_webgpu_command_encoder_clear_buffer(
|
pub fn op_webgpu_command_encoder_clear_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderClearBufferArgs,
|
args: CommandEncoderClearBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -504,7 +496,6 @@ pub struct CommandEncoderPushDebugGroupArgs {
|
||||||
pub fn op_webgpu_command_encoder_push_debug_group(
|
pub fn op_webgpu_command_encoder_push_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderPushDebugGroupArgs,
|
args: CommandEncoderPushDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -526,7 +517,6 @@ pub struct CommandEncoderPopDebugGroupArgs {
|
||||||
pub fn op_webgpu_command_encoder_pop_debug_group(
|
pub fn op_webgpu_command_encoder_pop_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderPopDebugGroupArgs,
|
args: CommandEncoderPopDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -548,7 +538,6 @@ pub struct CommandEncoderInsertDebugMarkerArgs {
|
||||||
pub fn op_webgpu_command_encoder_insert_debug_marker(
|
pub fn op_webgpu_command_encoder_insert_debug_marker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderInsertDebugMarkerArgs,
|
args: CommandEncoderInsertDebugMarkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -574,7 +563,6 @@ pub struct CommandEncoderWriteTimestampArgs {
|
||||||
pub fn op_webgpu_command_encoder_write_timestamp(
|
pub fn op_webgpu_command_encoder_write_timestamp(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderWriteTimestampArgs,
|
args: CommandEncoderWriteTimestampArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -607,7 +595,6 @@ pub struct CommandEncoderResolveQuerySetArgs {
|
||||||
pub fn op_webgpu_command_encoder_resolve_query_set(
|
pub fn op_webgpu_command_encoder_resolve_query_set(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderResolveQuerySetArgs,
|
args: CommandEncoderResolveQuerySetArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
|
@ -642,7 +629,6 @@ pub struct CommandEncoderFinishArgs {
|
||||||
pub fn op_webgpu_command_encoder_finish(
|
pub fn op_webgpu_command_encoder_finish(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CommandEncoderFinishArgs,
|
args: CommandEncoderFinishArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
|
|
@ -31,7 +31,6 @@ pub struct ComputePassSetPipelineArgs {
|
||||||
pub fn op_webgpu_compute_pass_set_pipeline(
|
pub fn op_webgpu_compute_pass_set_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassSetPipelineArgs,
|
args: ComputePassSetPipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pipeline_resource =
|
let compute_pipeline_resource =
|
||||||
state
|
state
|
||||||
|
@ -62,7 +61,6 @@ pub struct ComputePassDispatchArgs {
|
||||||
pub fn op_webgpu_compute_pass_dispatch(
|
pub fn op_webgpu_compute_pass_dispatch(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassDispatchArgs,
|
args: ComputePassDispatchArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -90,7 +88,6 @@ pub struct ComputePassDispatchIndirectArgs {
|
||||||
pub fn op_webgpu_compute_pass_dispatch_indirect(
|
pub fn op_webgpu_compute_pass_dispatch_indirect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassDispatchIndirectArgs,
|
args: ComputePassDispatchIndirectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -120,7 +117,6 @@ pub struct ComputePassBeginPipelineStatisticsQueryArgs {
|
||||||
pub fn op_webgpu_compute_pass_begin_pipeline_statistics_query(
|
pub fn op_webgpu_compute_pass_begin_pipeline_statistics_query(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassBeginPipelineStatisticsQueryArgs,
|
args: ComputePassBeginPipelineStatisticsQueryArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -148,7 +144,6 @@ pub struct ComputePassEndPipelineStatisticsQueryArgs {
|
||||||
pub fn op_webgpu_compute_pass_end_pipeline_statistics_query(
|
pub fn op_webgpu_compute_pass_end_pipeline_statistics_query(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassEndPipelineStatisticsQueryArgs,
|
args: ComputePassEndPipelineStatisticsQueryArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -173,7 +168,6 @@ pub struct ComputePassWriteTimestampArgs {
|
||||||
pub fn op_webgpu_compute_pass_write_timestamp(
|
pub fn op_webgpu_compute_pass_write_timestamp(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassWriteTimestampArgs,
|
args: ComputePassWriteTimestampArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -202,7 +196,6 @@ pub struct ComputePassEndPassArgs {
|
||||||
pub fn op_webgpu_compute_pass_end_pass(
|
pub fn op_webgpu_compute_pass_end_pass(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassEndPassArgs,
|
args: ComputePassEndPassArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -237,7 +230,6 @@ pub struct ComputePassSetBindGroupArgs {
|
||||||
pub fn op_webgpu_compute_pass_set_bind_group(
|
pub fn op_webgpu_compute_pass_set_bind_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassSetBindGroupArgs,
|
args: ComputePassSetBindGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let bind_group_resource =
|
let bind_group_resource =
|
||||||
state
|
state
|
||||||
|
@ -291,7 +283,6 @@ pub struct ComputePassPushDebugGroupArgs {
|
||||||
pub fn op_webgpu_compute_pass_push_debug_group(
|
pub fn op_webgpu_compute_pass_push_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassPushDebugGroupArgs,
|
args: ComputePassPushDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -321,7 +312,6 @@ pub struct ComputePassPopDebugGroupArgs {
|
||||||
pub fn op_webgpu_compute_pass_pop_debug_group(
|
pub fn op_webgpu_compute_pass_pop_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassPopDebugGroupArgs,
|
args: ComputePassPopDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -345,7 +335,6 @@ pub struct ComputePassInsertDebugMarkerArgs {
|
||||||
pub fn op_webgpu_compute_pass_insert_debug_marker(
|
pub fn op_webgpu_compute_pass_insert_debug_marker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePassInsertDebugMarkerArgs,
|
args: ComputePassInsertDebugMarkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let compute_pass_resource = state
|
let compute_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
|
|
@ -245,7 +245,6 @@ pub struct GpuAdapterDevice {
|
||||||
pub async fn op_webgpu_request_adapter(
|
pub async fn op_webgpu_request_adapter(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: RequestAdapterArgs,
|
args: RequestAdapterArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<GpuAdapterDeviceOrErr, AnyError> {
|
) -> Result<GpuAdapterDeviceOrErr, AnyError> {
|
||||||
let mut state = state.borrow_mut();
|
let mut state = state.borrow_mut();
|
||||||
check_unstable(&state, "navigator.gpu.requestAdapter");
|
check_unstable(&state, "navigator.gpu.requestAdapter");
|
||||||
|
@ -444,7 +443,6 @@ impl From<GpuRequiredFeatures> for wgpu_types::Features {
|
||||||
pub async fn op_webgpu_request_device(
|
pub async fn op_webgpu_request_device(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: RequestDeviceArgs,
|
args: RequestDeviceArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<GpuAdapterDevice, AnyError> {
|
) -> Result<GpuAdapterDevice, AnyError> {
|
||||||
let mut state = state.borrow_mut();
|
let mut state = state.borrow_mut();
|
||||||
let adapter_resource = state
|
let adapter_resource = state
|
||||||
|
@ -545,7 +543,6 @@ impl From<GpuQueryType> for wgpu_types::QueryType {
|
||||||
pub fn op_webgpu_create_query_set(
|
pub fn op_webgpu_create_query_set(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateQuerySetArgs,
|
args: CreateQuerySetArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let device_resource =
|
let device_resource =
|
||||||
state.resource_table.get::<WebGpuDevice>(args.device_rid)?;
|
state.resource_table.get::<WebGpuDevice>(args.device_rid)?;
|
||||||
|
|
|
@ -62,7 +62,6 @@ pub struct CreateComputePipelineArgs {
|
||||||
pub fn op_webgpu_create_compute_pipeline(
|
pub fn op_webgpu_create_compute_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateComputePipelineArgs,
|
args: CreateComputePipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -132,7 +131,6 @@ pub struct PipelineLayout {
|
||||||
pub fn op_webgpu_compute_pipeline_get_bind_group_layout(
|
pub fn op_webgpu_compute_pipeline_get_bind_group_layout(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ComputePipelineGetBindGroupLayoutArgs,
|
args: ComputePipelineGetBindGroupLayoutArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<PipelineLayout, AnyError> {
|
) -> Result<PipelineLayout, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let compute_pipeline_resource = state
|
let compute_pipeline_resource = state
|
||||||
|
@ -310,7 +308,6 @@ pub struct CreateRenderPipelineArgs {
|
||||||
pub fn op_webgpu_create_render_pipeline(
|
pub fn op_webgpu_create_render_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateRenderPipelineArgs,
|
args: CreateRenderPipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -412,7 +409,6 @@ pub struct RenderPipelineGetBindGroupLayoutArgs {
|
||||||
pub fn op_webgpu_render_pipeline_get_bind_group_layout(
|
pub fn op_webgpu_render_pipeline_get_bind_group_layout(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPipelineGetBindGroupLayoutArgs,
|
args: RenderPipelineGetBindGroupLayoutArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<PipelineLayout, AnyError> {
|
) -> Result<PipelineLayout, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let render_pipeline_resource = state
|
let render_pipeline_resource = state
|
||||||
|
|
|
@ -24,7 +24,6 @@ pub struct QueueSubmitArgs {
|
||||||
pub fn op_webgpu_queue_submit(
|
pub fn op_webgpu_queue_submit(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: QueueSubmitArgs,
|
args: QueueSubmitArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let queue_resource =
|
let queue_resource =
|
||||||
|
|
|
@ -37,7 +37,6 @@ pub struct RenderPassSetViewportArgs {
|
||||||
pub fn op_webgpu_render_pass_set_viewport(
|
pub fn op_webgpu_render_pass_set_viewport(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetViewportArgs,
|
args: RenderPassSetViewportArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -70,7 +69,6 @@ pub struct RenderPassSetScissorRectArgs {
|
||||||
pub fn op_webgpu_render_pass_set_scissor_rect(
|
pub fn op_webgpu_render_pass_set_scissor_rect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetScissorRectArgs,
|
args: RenderPassSetScissorRectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -98,7 +96,6 @@ pub struct RenderPassSetBlendConstantArgs {
|
||||||
pub fn op_webgpu_render_pass_set_blend_constant(
|
pub fn op_webgpu_render_pass_set_blend_constant(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetBlendConstantArgs,
|
args: RenderPassSetBlendConstantArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -123,7 +120,6 @@ pub struct RenderPassSetStencilReferenceArgs {
|
||||||
pub fn op_webgpu_render_pass_set_stencil_reference(
|
pub fn op_webgpu_render_pass_set_stencil_reference(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetStencilReferenceArgs,
|
args: RenderPassSetStencilReferenceArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -149,7 +145,6 @@ pub struct RenderPassBeginPipelineStatisticsQueryArgs {
|
||||||
pub fn op_webgpu_render_pass_begin_pipeline_statistics_query(
|
pub fn op_webgpu_render_pass_begin_pipeline_statistics_query(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassBeginPipelineStatisticsQueryArgs,
|
args: RenderPassBeginPipelineStatisticsQueryArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -177,7 +172,6 @@ pub struct RenderPassEndPipelineStatisticsQueryArgs {
|
||||||
pub fn op_webgpu_render_pass_end_pipeline_statistics_query(
|
pub fn op_webgpu_render_pass_end_pipeline_statistics_query(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassEndPipelineStatisticsQueryArgs,
|
args: RenderPassEndPipelineStatisticsQueryArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -202,7 +196,6 @@ pub struct RenderPassWriteTimestampArgs {
|
||||||
pub fn op_webgpu_render_pass_write_timestamp(
|
pub fn op_webgpu_render_pass_write_timestamp(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassWriteTimestampArgs,
|
args: RenderPassWriteTimestampArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -231,7 +224,6 @@ pub struct RenderPassExecuteBundlesArgs {
|
||||||
pub fn op_webgpu_render_pass_execute_bundles(
|
pub fn op_webgpu_render_pass_execute_bundles(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassExecuteBundlesArgs,
|
args: RenderPassExecuteBundlesArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let mut render_bundle_ids = vec![];
|
let mut render_bundle_ids = vec![];
|
||||||
|
|
||||||
|
@ -271,7 +263,6 @@ pub struct RenderPassEndPassArgs {
|
||||||
pub fn op_webgpu_render_pass_end_pass(
|
pub fn op_webgpu_render_pass_end_pass(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassEndPassArgs,
|
args: RenderPassEndPassArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let command_encoder_resource = state
|
let command_encoder_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -303,7 +294,6 @@ pub struct RenderPassSetBindGroupArgs {
|
||||||
pub fn op_webgpu_render_pass_set_bind_group(
|
pub fn op_webgpu_render_pass_set_bind_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetBindGroupArgs,
|
args: RenderPassSetBindGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let bind_group_resource =
|
let bind_group_resource =
|
||||||
state
|
state
|
||||||
|
@ -357,7 +347,6 @@ pub struct RenderPassPushDebugGroupArgs {
|
||||||
pub fn op_webgpu_render_pass_push_debug_group(
|
pub fn op_webgpu_render_pass_push_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassPushDebugGroupArgs,
|
args: RenderPassPushDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -387,7 +376,6 @@ pub struct RenderPassPopDebugGroupArgs {
|
||||||
pub fn op_webgpu_render_pass_pop_debug_group(
|
pub fn op_webgpu_render_pass_pop_debug_group(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassPopDebugGroupArgs,
|
args: RenderPassPopDebugGroupArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -411,7 +399,6 @@ pub struct RenderPassInsertDebugMarkerArgs {
|
||||||
pub fn op_webgpu_render_pass_insert_debug_marker(
|
pub fn op_webgpu_render_pass_insert_debug_marker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassInsertDebugMarkerArgs,
|
args: RenderPassInsertDebugMarkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -442,7 +429,6 @@ pub struct RenderPassSetPipelineArgs {
|
||||||
pub fn op_webgpu_render_pass_set_pipeline(
|
pub fn op_webgpu_render_pass_set_pipeline(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetPipelineArgs,
|
args: RenderPassSetPipelineArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pipeline_resource =
|
let render_pipeline_resource =
|
||||||
state
|
state
|
||||||
|
@ -474,7 +460,6 @@ pub struct RenderPassSetIndexBufferArgs {
|
||||||
pub fn op_webgpu_render_pass_set_index_buffer(
|
pub fn op_webgpu_render_pass_set_index_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetIndexBufferArgs,
|
args: RenderPassSetIndexBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -516,7 +501,6 @@ pub struct RenderPassSetVertexBufferArgs {
|
||||||
pub fn op_webgpu_render_pass_set_vertex_buffer(
|
pub fn op_webgpu_render_pass_set_vertex_buffer(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassSetVertexBufferArgs,
|
args: RenderPassSetVertexBufferArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -559,7 +543,6 @@ pub struct RenderPassDrawArgs {
|
||||||
pub fn op_webgpu_render_pass_draw(
|
pub fn op_webgpu_render_pass_draw(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassDrawArgs,
|
args: RenderPassDrawArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -591,7 +574,6 @@ pub struct RenderPassDrawIndexedArgs {
|
||||||
pub fn op_webgpu_render_pass_draw_indexed(
|
pub fn op_webgpu_render_pass_draw_indexed(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassDrawIndexedArgs,
|
args: RenderPassDrawIndexedArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let render_pass_resource = state
|
let render_pass_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -621,7 +603,6 @@ pub struct RenderPassDrawIndirectArgs {
|
||||||
pub fn op_webgpu_render_pass_draw_indirect(
|
pub fn op_webgpu_render_pass_draw_indirect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassDrawIndirectArgs,
|
args: RenderPassDrawIndirectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -651,7 +632,6 @@ pub struct RenderPassDrawIndexedIndirectArgs {
|
||||||
pub fn op_webgpu_render_pass_draw_indexed_indirect(
|
pub fn op_webgpu_render_pass_draw_indexed_indirect(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenderPassDrawIndexedIndirectArgs,
|
args: RenderPassDrawIndexedIndirectArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let buffer_resource = state
|
let buffer_resource = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
|
|
@ -37,7 +37,6 @@ pub struct CreateSamplerArgs {
|
||||||
pub fn op_webgpu_create_sampler(
|
pub fn op_webgpu_create_sampler(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateSamplerArgs,
|
args: CreateSamplerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
|
|
@ -29,7 +29,6 @@ pub struct CreateShaderModuleArgs {
|
||||||
pub fn op_webgpu_create_shader_module(
|
pub fn op_webgpu_create_shader_module(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateShaderModuleArgs,
|
args: CreateShaderModuleArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
|
|
@ -39,7 +39,6 @@ pub struct CreateTextureArgs {
|
||||||
pub fn op_webgpu_create_texture(
|
pub fn op_webgpu_create_texture(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateTextureArgs,
|
args: CreateTextureArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let device_resource = state
|
let device_resource = state
|
||||||
|
@ -82,7 +81,6 @@ pub struct CreateTextureViewArgs {
|
||||||
pub fn op_webgpu_create_texture_view(
|
pub fn op_webgpu_create_texture_view(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateTextureViewArgs,
|
args: CreateTextureViewArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WebGpuResult, AnyError> {
|
) -> Result<WebGpuResult, AnyError> {
|
||||||
let instance = state.borrow::<super::Instance>();
|
let instance = state.borrow::<super::Instance>();
|
||||||
let texture_resource = state
|
let texture_resource = state
|
||||||
|
|
|
@ -234,7 +234,6 @@ pub struct CreateResponse {
|
||||||
pub async fn op_ws_create<WP>(
|
pub async fn op_ws_create<WP>(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: CreateArgs,
|
args: CreateArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<CreateResponse, AnyError>
|
) -> Result<CreateResponse, AnyError>
|
||||||
where
|
where
|
||||||
WP: WebSocketPermissions + 'static,
|
WP: WebSocketPermissions + 'static,
|
||||||
|
@ -413,7 +412,6 @@ pub struct CloseArgs {
|
||||||
pub async fn op_ws_close(
|
pub async fn op_ws_close(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: CloseArgs,
|
args: CloseArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let rid = args.rid;
|
let rid = args.rid;
|
||||||
let msg = Message::Close(args.code.map(|c| CloseFrame {
|
let msg = Message::Close(args.code.map(|c| CloseFrame {
|
||||||
|
@ -448,7 +446,6 @@ pub enum NextEventResponse {
|
||||||
pub async fn op_ws_next_event(
|
pub async fn op_ws_next_event(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<NextEventResponse, AnyError> {
|
) -> Result<NextEventResponse, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
|
@ -104,7 +104,6 @@ fn get_webstorage(
|
||||||
pub fn op_webstorage_length(
|
pub fn op_webstorage_length(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
_: (),
|
|
||||||
) -> Result<u32, AnyError> {
|
) -> Result<u32, AnyError> {
|
||||||
let conn = get_webstorage(state, persistent)?;
|
let conn = get_webstorage(state, persistent)?;
|
||||||
|
|
||||||
|
@ -201,7 +200,6 @@ pub fn op_webstorage_remove(
|
||||||
pub fn op_webstorage_clear(
|
pub fn op_webstorage_clear(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let conn = get_webstorage(state, persistent)?;
|
let conn = get_webstorage(state, persistent)?;
|
||||||
|
|
||||||
|
@ -215,7 +213,6 @@ pub fn op_webstorage_clear(
|
||||||
pub fn op_webstorage_iterate_keys(
|
pub fn op_webstorage_iterate_keys(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
persistent: bool,
|
persistent: bool,
|
||||||
_: (),
|
|
||||||
) -> Result<Vec<String>, AnyError> {
|
) -> Result<Vec<String>, AnyError> {
|
||||||
let conn = get_webstorage(state, persistent)?;
|
let conn = get_webstorage(state, persistent)?;
|
||||||
|
|
||||||
|
|
43
ops/lib.rs
43
ops/lib.rs
|
@ -91,8 +91,7 @@ pub fn op(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
/// Generate the body of a v8 func for an async op
|
/// Generate the body of a v8 func for an async op
|
||||||
fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
|
fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
|
||||||
let a = codegen_arg(core, &f.sig.inputs[1], "a", 2);
|
let (arg_decls, args_tail) = codegen_args(core, f, 1, 2);
|
||||||
let b = codegen_arg(core, &f.sig.inputs[2], "b", 3);
|
|
||||||
let type_params = &f.sig.generics.params;
|
let type_params = &f.sig.generics.params;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -115,8 +114,7 @@ fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#a
|
#arg_decls
|
||||||
#b
|
|
||||||
|
|
||||||
// SAFETY: Unchecked cast to external since #core guarantees args.data() is a v8 External.
|
// SAFETY: Unchecked cast to external since #core guarantees args.data() is a v8 External.
|
||||||
let state_refcell_raw = unsafe {
|
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 {
|
#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))
|
(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
|
/// Generate the body of a v8 func for a sync op
|
||||||
fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
|
fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 {
|
||||||
let a = codegen_arg(core, &f.sig.inputs[1], "a", 1);
|
let (arg_decls, args_tail) = codegen_args(core, f, 1, 1);
|
||||||
let b = codegen_arg(core, &f.sig.inputs[2], "b", 2);
|
|
||||||
let ret = codegen_sync_ret(core, &f.sig.output);
|
let ret = codegen_sync_ret(core, &f.sig.output);
|
||||||
let type_params = &f.sig.generics.params;
|
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()
|
#core::v8::Local::<#core::v8::Integer>::cast(args.get(0)).value()
|
||||||
} as usize;
|
} as usize;
|
||||||
|
|
||||||
#a
|
#arg_decls
|
||||||
#b
|
|
||||||
|
|
||||||
// SAFETY: Unchecked cast to external since #core guarantees args.data() is a v8 External.
|
// SAFETY: Unchecked cast to external since #core guarantees args.data() is a v8 External.
|
||||||
let state_refcell_raw = unsafe {
|
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 state = unsafe { &*(state_refcell_raw as *const std::cell::RefCell<#core::OpState>) };
|
||||||
|
|
||||||
let op_state = &mut state.borrow_mut();
|
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);
|
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(
|
fn codegen_arg(
|
||||||
core: &TokenStream2,
|
core: &TokenStream2,
|
||||||
arg: &syn::FnArg,
|
arg: &syn::FnArg,
|
||||||
name: &str,
|
name: &str,
|
||||||
idx: i32,
|
idx: usize,
|
||||||
) -> TokenStream2 {
|
) -> TokenStream2 {
|
||||||
let ident = quote::format_ident!("{name}");
|
let ident = quote::format_ident!("{name}");
|
||||||
let pat = match arg {
|
let pat = match arg {
|
||||||
|
@ -194,7 +213,7 @@ fn codegen_arg(
|
||||||
}
|
}
|
||||||
// Otherwise deserialize it via serde_v8
|
// Otherwise deserialize it via serde_v8
|
||||||
quote! {
|
quote! {
|
||||||
let #ident = args.get(#idx);
|
let #ident = args.get(#idx as i32);
|
||||||
let #ident = match #core::serde_v8::from_v8(scope, #ident) {
|
let #ident = match #core::serde_v8::from_v8(scope, #ident) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
@ -161,7 +161,6 @@ fn open_helper(
|
||||||
fn op_open_sync(
|
fn op_open_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: OpenArgs,
|
args: OpenArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, AnyError> {
|
||||||
let (path, open_options) = open_helper(state, args)?;
|
let (path, open_options) = open_helper(state, args)?;
|
||||||
let std_file = open_options.open(&path).map_err(|err| {
|
let std_file = open_options.open(&path).map_err(|err| {
|
||||||
|
@ -177,7 +176,6 @@ fn op_open_sync(
|
||||||
async fn op_open_async(
|
async fn op_open_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: OpenArgs,
|
args: OpenArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, AnyError> {
|
||||||
let (path, open_options) = open_helper(&mut state.borrow_mut(), args)?;
|
let (path, open_options) = open_helper(&mut state.borrow_mut(), args)?;
|
||||||
let tokio_file = tokio::fs::OpenOptions::from(open_options)
|
let tokio_file = tokio::fs::OpenOptions::from(open_options)
|
||||||
|
@ -217,11 +215,7 @@ fn seek_helper(args: SeekArgs) -> Result<(u32, SeekFrom), AnyError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_seek_sync(
|
fn op_seek_sync(state: &mut OpState, args: SeekArgs) -> Result<u64, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: SeekArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<u64, AnyError> {
|
|
||||||
let (rid, seek_from) = seek_helper(args)?;
|
let (rid, seek_from) = seek_helper(args)?;
|
||||||
let pos = StdFileResource::with(state, rid, |r| match r {
|
let pos = StdFileResource::with(state, rid, |r| match r {
|
||||||
Ok(std_file) => std_file.seek(seek_from).map_err(AnyError::from),
|
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(
|
async fn op_seek_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: SeekArgs,
|
args: SeekArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<u64, AnyError> {
|
) -> Result<u64, AnyError> {
|
||||||
let (rid, seek_from) = seek_helper(args)?;
|
let (rid, seek_from) = seek_helper(args)?;
|
||||||
|
|
||||||
|
@ -261,7 +254,6 @@ async fn op_seek_async(
|
||||||
fn op_fdatasync_sync(
|
fn op_fdatasync_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
StdFileResource::with(state, rid, |r| match r {
|
StdFileResource::with(state, rid, |r| match r {
|
||||||
Ok(std_file) => std_file.sync_data().map_err(AnyError::from),
|
Ok(std_file) => std_file.sync_data().map_err(AnyError::from),
|
||||||
|
@ -274,7 +266,6 @@ fn op_fdatasync_sync(
|
||||||
async fn op_fdatasync_async(
|
async fn op_fdatasync_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -294,11 +285,7 @@ async fn op_fdatasync_async(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_fsync_sync(
|
fn op_fsync_sync(state: &mut OpState, rid: ResourceId) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
rid: ResourceId,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
StdFileResource::with(state, rid, |r| match r {
|
StdFileResource::with(state, rid, |r| match r {
|
||||||
Ok(std_file) => std_file.sync_all().map_err(AnyError::from),
|
Ok(std_file) => std_file.sync_all().map_err(AnyError::from),
|
||||||
Err(_) => Err(type_error("cannot sync this type of resource".to_string())),
|
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(
|
async fn op_fsync_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -333,7 +319,6 @@ async fn op_fsync_async(
|
||||||
fn op_fstat_sync(
|
fn op_fstat_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<FsStat, AnyError> {
|
) -> Result<FsStat, AnyError> {
|
||||||
let metadata = StdFileResource::with(state, rid, |r| match r {
|
let metadata = StdFileResource::with(state, rid, |r| match r {
|
||||||
Ok(std_file) => std_file.metadata().map_err(AnyError::from),
|
Ok(std_file) => std_file.metadata().map_err(AnyError::from),
|
||||||
|
@ -346,7 +331,6 @@ fn op_fstat_sync(
|
||||||
async fn op_fstat_async(
|
async fn op_fstat_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<FsStat, AnyError> {
|
) -> Result<FsStat, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -432,7 +416,6 @@ async fn op_flock_async(
|
||||||
fn op_funlock_sync(
|
fn op_funlock_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
use fs3::FileExt;
|
use fs3::FileExt;
|
||||||
super::check_unstable(state, "Deno.funlockSync");
|
super::check_unstable(state, "Deno.funlockSync");
|
||||||
|
@ -450,7 +433,6 @@ fn op_funlock_sync(
|
||||||
async fn op_funlock_async(
|
async fn op_funlock_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
use fs3::FileExt;
|
use fs3::FileExt;
|
||||||
super::check_unstable2(&state, "Deno.funlock");
|
super::check_unstable2(&state, "Deno.funlock");
|
||||||
|
@ -484,11 +466,7 @@ async fn op_funlock_async(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_umask(
|
fn op_umask(state: &mut OpState, mask: Option<u32>) -> Result<u32, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
mask: Option<u32>,
|
|
||||||
_: (),
|
|
||||||
) -> Result<u32, AnyError> {
|
|
||||||
super::check_unstable(state, "Deno.umask");
|
super::check_unstable(state, "Deno.umask");
|
||||||
// TODO implement umask for Windows
|
// TODO implement umask for Windows
|
||||||
// see https://github.com/nodejs/node/blob/master/src/node_process_methods.cc
|
// see https://github.com/nodejs/node/blob/master/src/node_process_methods.cc
|
||||||
|
@ -517,11 +495,7 @@ fn op_umask(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_chdir(
|
fn op_chdir(state: &mut OpState, directory: String) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
directory: String,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
let d = PathBuf::from(&directory);
|
let d = PathBuf::from(&directory);
|
||||||
state.borrow_mut::<Permissions>().read.check(&d)?;
|
state.borrow_mut::<Permissions>().read.check(&d)?;
|
||||||
set_current_dir(&d).map_err(|err| {
|
set_current_dir(&d).map_err(|err| {
|
||||||
|
@ -539,11 +513,7 @@ pub struct MkdirArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_mkdir_sync(
|
fn op_mkdir_sync(state: &mut OpState, args: MkdirArgs) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: MkdirArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
let path = Path::new(&args.path).to_path_buf();
|
let path = Path::new(&args.path).to_path_buf();
|
||||||
let mode = args.mode.unwrap_or(0o777) & 0o777;
|
let mode = args.mode.unwrap_or(0o777) & 0o777;
|
||||||
state.borrow_mut::<Permissions>().write.check(&path)?;
|
state.borrow_mut::<Permissions>().write.check(&path)?;
|
||||||
|
@ -565,7 +535,6 @@ fn op_mkdir_sync(
|
||||||
async fn op_mkdir_async(
|
async fn op_mkdir_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: MkdirArgs,
|
args: MkdirArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let path = Path::new(&args.path).to_path_buf();
|
let path = Path::new(&args.path).to_path_buf();
|
||||||
let mode = args.mode.unwrap_or(0o777) & 0o777;
|
let mode = args.mode.unwrap_or(0o777) & 0o777;
|
||||||
|
@ -601,11 +570,7 @@ pub struct ChmodArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_chmod_sync(
|
fn op_chmod_sync(state: &mut OpState, args: ChmodArgs) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: ChmodArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
let path = Path::new(&args.path).to_path_buf();
|
let path = Path::new(&args.path).to_path_buf();
|
||||||
let mode = args.mode & 0o777;
|
let mode = args.mode & 0o777;
|
||||||
let err_mapper = |err: Error| {
|
let err_mapper = |err: Error| {
|
||||||
|
@ -634,7 +599,6 @@ fn op_chmod_sync(
|
||||||
async fn op_chmod_async(
|
async fn op_chmod_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: ChmodArgs,
|
args: ChmodArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let path = Path::new(&args.path).to_path_buf();
|
let path = Path::new(&args.path).to_path_buf();
|
||||||
let mode = args.mode & 0o777;
|
let mode = args.mode & 0o777;
|
||||||
|
@ -677,11 +641,7 @@ pub struct ChownArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_chown_sync(
|
fn op_chown_sync(state: &mut OpState, args: ChownArgs) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: ChownArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
let path = Path::new(&args.path).to_path_buf();
|
let path = Path::new(&args.path).to_path_buf();
|
||||||
state.borrow_mut::<Permissions>().write.check(&path)?;
|
state.borrow_mut::<Permissions>().write.check(&path)?;
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -715,7 +675,6 @@ fn op_chown_sync(
|
||||||
async fn op_chown_async(
|
async fn op_chown_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: ChownArgs,
|
args: ChownArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let path = Path::new(&args.path).to_path_buf();
|
let path = Path::new(&args.path).to_path_buf();
|
||||||
|
|
||||||
|
@ -764,7 +723,6 @@ pub struct RemoveArgs {
|
||||||
fn op_remove_sync(
|
fn op_remove_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RemoveArgs,
|
args: RemoveArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let path = PathBuf::from(&args.path);
|
let path = PathBuf::from(&args.path);
|
||||||
let recursive = args.recursive;
|
let recursive = args.recursive;
|
||||||
|
@ -810,7 +768,6 @@ fn op_remove_sync(
|
||||||
async fn op_remove_async(
|
async fn op_remove_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: RemoveArgs,
|
args: RemoveArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let path = PathBuf::from(&args.path);
|
let path = PathBuf::from(&args.path);
|
||||||
let recursive = args.recursive;
|
let recursive = args.recursive;
|
||||||
|
@ -869,7 +826,6 @@ pub struct CopyFileArgs {
|
||||||
fn op_copy_file_sync(
|
fn op_copy_file_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CopyFileArgs,
|
args: CopyFileArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let from = PathBuf::from(&args.from);
|
let from = PathBuf::from(&args.from);
|
||||||
let to = PathBuf::from(&args.to);
|
let to = PathBuf::from(&args.to);
|
||||||
|
@ -908,7 +864,6 @@ fn op_copy_file_sync(
|
||||||
async fn op_copy_file_async(
|
async fn op_copy_file_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: CopyFileArgs,
|
args: CopyFileArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let from = PathBuf::from(&args.from);
|
let from = PathBuf::from(&args.from);
|
||||||
let to = PathBuf::from(&args.to);
|
let to = PathBuf::from(&args.to);
|
||||||
|
@ -1037,7 +992,6 @@ pub struct StatArgs {
|
||||||
fn op_stat_sync(
|
fn op_stat_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: StatArgs,
|
args: StatArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<FsStat, AnyError> {
|
) -> Result<FsStat, AnyError> {
|
||||||
let path = PathBuf::from(&args.path);
|
let path = PathBuf::from(&args.path);
|
||||||
let lstat = args.lstat;
|
let lstat = args.lstat;
|
||||||
|
@ -1058,7 +1012,6 @@ fn op_stat_sync(
|
||||||
async fn op_stat_async(
|
async fn op_stat_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: StatArgs,
|
args: StatArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<FsStat, AnyError> {
|
) -> Result<FsStat, AnyError> {
|
||||||
let path = PathBuf::from(&args.path);
|
let path = PathBuf::from(&args.path);
|
||||||
let lstat = args.lstat;
|
let lstat = args.lstat;
|
||||||
|
@ -1088,7 +1041,6 @@ async fn op_stat_async(
|
||||||
fn op_realpath_sync(
|
fn op_realpath_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
path: String,
|
path: String,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let path = PathBuf::from(&path);
|
let path = PathBuf::from(&path);
|
||||||
|
|
||||||
|
@ -1110,7 +1062,6 @@ fn op_realpath_sync(
|
||||||
async fn op_realpath_async(
|
async fn op_realpath_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
path: String,
|
path: String,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let path = PathBuf::from(&path);
|
let path = PathBuf::from(&path);
|
||||||
|
|
||||||
|
@ -1148,7 +1099,6 @@ pub struct DirEntry {
|
||||||
fn op_read_dir_sync(
|
fn op_read_dir_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
path: String,
|
path: String,
|
||||||
_: (),
|
|
||||||
) -> Result<Vec<DirEntry>, AnyError> {
|
) -> Result<Vec<DirEntry>, AnyError> {
|
||||||
let path = PathBuf::from(&path);
|
let path = PathBuf::from(&path);
|
||||||
|
|
||||||
|
@ -1189,7 +1139,6 @@ fn op_read_dir_sync(
|
||||||
async fn op_read_dir_async(
|
async fn op_read_dir_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
path: String,
|
path: String,
|
||||||
_: (),
|
|
||||||
) -> Result<Vec<DirEntry>, AnyError> {
|
) -> Result<Vec<DirEntry>, AnyError> {
|
||||||
let path = PathBuf::from(&path);
|
let path = PathBuf::from(&path);
|
||||||
{
|
{
|
||||||
|
@ -1242,7 +1191,6 @@ pub struct RenameArgs {
|
||||||
fn op_rename_sync(
|
fn op_rename_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: RenameArgs,
|
args: RenameArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let oldpath = PathBuf::from(&args.oldpath);
|
let oldpath = PathBuf::from(&args.oldpath);
|
||||||
let newpath = PathBuf::from(&args.newpath);
|
let newpath = PathBuf::from(&args.newpath);
|
||||||
|
@ -1271,7 +1219,6 @@ fn op_rename_sync(
|
||||||
async fn op_rename_async(
|
async fn op_rename_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: RenameArgs,
|
args: RenameArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let oldpath = PathBuf::from(&args.oldpath);
|
let oldpath = PathBuf::from(&args.oldpath);
|
||||||
let newpath = PathBuf::from(&args.newpath);
|
let newpath = PathBuf::from(&args.newpath);
|
||||||
|
@ -1314,11 +1261,7 @@ pub struct LinkArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_link_sync(
|
fn op_link_sync(state: &mut OpState, args: LinkArgs) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: LinkArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
let oldpath = PathBuf::from(&args.oldpath);
|
let oldpath = PathBuf::from(&args.oldpath);
|
||||||
let newpath = PathBuf::from(&args.newpath);
|
let newpath = PathBuf::from(&args.newpath);
|
||||||
|
|
||||||
|
@ -1348,7 +1291,6 @@ fn op_link_sync(
|
||||||
async fn op_link_async(
|
async fn op_link_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: LinkArgs,
|
args: LinkArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let oldpath = PathBuf::from(&args.oldpath);
|
let oldpath = PathBuf::from(&args.oldpath);
|
||||||
let newpath = PathBuf::from(&args.newpath);
|
let newpath = PathBuf::from(&args.newpath);
|
||||||
|
@ -1402,7 +1344,6 @@ pub struct SymlinkOptions {
|
||||||
fn op_symlink_sync(
|
fn op_symlink_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: SymlinkArgs,
|
args: SymlinkArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let oldpath = PathBuf::from(&args.oldpath);
|
let oldpath = PathBuf::from(&args.oldpath);
|
||||||
let newpath = PathBuf::from(&args.newpath);
|
let newpath = PathBuf::from(&args.newpath);
|
||||||
|
@ -1464,7 +1405,6 @@ fn op_symlink_sync(
|
||||||
async fn op_symlink_async(
|
async fn op_symlink_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: SymlinkArgs,
|
args: SymlinkArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let oldpath = PathBuf::from(&args.oldpath);
|
let oldpath = PathBuf::from(&args.oldpath);
|
||||||
let newpath = PathBuf::from(&args.newpath);
|
let newpath = PathBuf::from(&args.newpath);
|
||||||
|
@ -1529,7 +1469,6 @@ async fn op_symlink_async(
|
||||||
fn op_read_link_sync(
|
fn op_read_link_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
path: String,
|
path: String,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let path = PathBuf::from(&path);
|
let path = PathBuf::from(&path);
|
||||||
|
|
||||||
|
@ -1553,7 +1492,6 @@ fn op_read_link_sync(
|
||||||
async fn op_read_link_async(
|
async fn op_read_link_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
path: String,
|
path: String,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let path = PathBuf::from(&path);
|
let path = PathBuf::from(&path);
|
||||||
{
|
{
|
||||||
|
@ -1589,7 +1527,6 @@ pub struct FtruncateArgs {
|
||||||
fn op_ftruncate_sync(
|
fn op_ftruncate_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: FtruncateArgs,
|
args: FtruncateArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let rid = args.rid;
|
let rid = args.rid;
|
||||||
let len = args.len as u64;
|
let len = args.len as u64;
|
||||||
|
@ -1604,7 +1541,6 @@ fn op_ftruncate_sync(
|
||||||
async fn op_ftruncate_async(
|
async fn op_ftruncate_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: FtruncateArgs,
|
args: FtruncateArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let rid = args.rid;
|
let rid = args.rid;
|
||||||
let len = args.len as u64;
|
let len = args.len as u64;
|
||||||
|
@ -1637,7 +1573,6 @@ pub struct TruncateArgs {
|
||||||
fn op_truncate_sync(
|
fn op_truncate_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: TruncateArgs,
|
args: TruncateArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let path = PathBuf::from(&args.path);
|
let path = PathBuf::from(&args.path);
|
||||||
let len = args.len;
|
let len = args.len;
|
||||||
|
@ -1663,7 +1598,6 @@ fn op_truncate_sync(
|
||||||
async fn op_truncate_async(
|
async fn op_truncate_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: TruncateArgs,
|
args: TruncateArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let path = PathBuf::from(&args.path);
|
let path = PathBuf::from(&args.path);
|
||||||
let len = args.len;
|
let len = args.len;
|
||||||
|
@ -1747,7 +1681,6 @@ pub struct MakeTempArgs {
|
||||||
fn op_make_temp_dir_sync(
|
fn op_make_temp_dir_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: MakeTempArgs,
|
args: MakeTempArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let dir = args.dir.map(|s| PathBuf::from(&s));
|
let dir = args.dir.map(|s| PathBuf::from(&s));
|
||||||
let prefix = args.prefix.map(String::from);
|
let prefix = args.prefix.map(String::from);
|
||||||
|
@ -1777,7 +1710,6 @@ fn op_make_temp_dir_sync(
|
||||||
async fn op_make_temp_dir_async(
|
async fn op_make_temp_dir_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: MakeTempArgs,
|
args: MakeTempArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let dir = args.dir.map(|s| PathBuf::from(&s));
|
let dir = args.dir.map(|s| PathBuf::from(&s));
|
||||||
let prefix = args.prefix.map(String::from);
|
let prefix = args.prefix.map(String::from);
|
||||||
|
@ -1812,7 +1744,6 @@ async fn op_make_temp_dir_async(
|
||||||
fn op_make_temp_file_sync(
|
fn op_make_temp_file_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: MakeTempArgs,
|
args: MakeTempArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let dir = args.dir.map(|s| PathBuf::from(&s));
|
let dir = args.dir.map(|s| PathBuf::from(&s));
|
||||||
let prefix = args.prefix.map(String::from);
|
let prefix = args.prefix.map(String::from);
|
||||||
|
@ -1842,7 +1773,6 @@ fn op_make_temp_file_sync(
|
||||||
async fn op_make_temp_file_async(
|
async fn op_make_temp_file_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: MakeTempArgs,
|
args: MakeTempArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let dir = args.dir.map(|s| PathBuf::from(&s));
|
let dir = args.dir.map(|s| PathBuf::from(&s));
|
||||||
let prefix = args.prefix.map(String::from);
|
let prefix = args.prefix.map(String::from);
|
||||||
|
@ -1885,7 +1815,6 @@ pub struct FutimeArgs {
|
||||||
fn op_futime_sync(
|
fn op_futime_sync(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: FutimeArgs,
|
args: FutimeArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
super::check_unstable(state, "Deno.futimeSync");
|
super::check_unstable(state, "Deno.futimeSync");
|
||||||
let rid = args.rid;
|
let rid = args.rid;
|
||||||
|
@ -1909,7 +1838,6 @@ fn op_futime_sync(
|
||||||
async fn op_futime_async(
|
async fn op_futime_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: FutimeArgs,
|
args: FutimeArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
super::check_unstable2(&state, "Deno.futime");
|
super::check_unstable2(&state, "Deno.futime");
|
||||||
let rid = args.rid;
|
let rid = args.rid;
|
||||||
|
@ -1955,11 +1883,7 @@ pub struct UtimeArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_utime_sync(
|
fn op_utime_sync(state: &mut OpState, args: UtimeArgs) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: UtimeArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
super::check_unstable(state, "Deno.utime");
|
super::check_unstable(state, "Deno.utime");
|
||||||
|
|
||||||
let path = PathBuf::from(&args.path);
|
let path = PathBuf::from(&args.path);
|
||||||
|
@ -1977,7 +1901,6 @@ fn op_utime_sync(
|
||||||
async fn op_utime_async(
|
async fn op_utime_async(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
args: UtimeArgs,
|
args: UtimeArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
super::check_unstable(&state.borrow(), "Deno.utime");
|
super::check_unstable(&state.borrow(), "Deno.utime");
|
||||||
|
|
||||||
|
@ -2002,7 +1925,7 @@ async fn op_utime_async(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_cwd(state: &mut OpState, _: (), _: ()) -> Result<String, AnyError> {
|
fn op_cwd(state: &mut OpState) -> Result<String, AnyError> {
|
||||||
let path = current_dir()?;
|
let path = current_dir()?;
|
||||||
state
|
state
|
||||||
.borrow_mut::<Permissions>()
|
.borrow_mut::<Permissions>()
|
||||||
|
|
|
@ -98,7 +98,6 @@ pub struct OpenArgs {
|
||||||
fn op_fs_events_open(
|
fn op_fs_events_open(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: OpenArgs,
|
args: OpenArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, AnyError> {
|
||||||
let (sender, receiver) = mpsc::channel::<Result<FsEvent, AnyError>>(16);
|
let (sender, receiver) = mpsc::channel::<Result<FsEvent, AnyError>>(16);
|
||||||
let sender = Mutex::new(sender);
|
let sender = Mutex::new(sender);
|
||||||
|
@ -133,7 +132,6 @@ fn op_fs_events_open(
|
||||||
async fn op_fs_events_poll(
|
async fn op_fs_events_poll(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<FsEvent>, AnyError> {
|
) -> Result<Option<FsEvent>, AnyError> {
|
||||||
let resource = state.borrow().resource_table.get::<FsEventsResource>(rid)?;
|
let resource = state.borrow().resource_table.get::<FsEventsResource>(rid)?;
|
||||||
let mut receiver = RcRef::map(&resource, |r| &r.receiver).borrow_mut().await;
|
let mut receiver = RcRef::map(&resource, |r| &r.receiver).borrow_mut().await;
|
||||||
|
|
|
@ -20,7 +20,6 @@ pub fn init() -> Extension {
|
||||||
fn op_http_start(
|
fn op_http_start(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
tcp_stream_rid: ResourceId,
|
tcp_stream_rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, AnyError> {
|
||||||
if let Ok(resource_rc) = state
|
if let Ok(resource_rc) = state
|
||||||
.resource_table
|
.resource_table
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub fn init(maybe_exit_code: Option<Arc<AtomicI32>>) -> Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[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();
|
let current_exe = env::current_exe().unwrap();
|
||||||
state
|
state
|
||||||
.borrow_mut::<Permissions>()
|
.borrow_mut::<Permissions>()
|
||||||
|
@ -71,11 +71,7 @@ fn op_set_env(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_env(
|
fn op_env(state: &mut OpState) -> Result<HashMap<String, String>, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<HashMap<String, String>, AnyError> {
|
|
||||||
state.borrow_mut::<Permissions>().env.check_all()?;
|
state.borrow_mut::<Permissions>().env.check_all()?;
|
||||||
Ok(env::vars().collect())
|
Ok(env::vars().collect())
|
||||||
}
|
}
|
||||||
|
@ -84,7 +80,6 @@ fn op_env(
|
||||||
fn op_get_env(
|
fn op_get_env(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
key: String,
|
key: String,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<String>, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
state.borrow_mut::<Permissions>().env.check(&key)?;
|
state.borrow_mut::<Permissions>().env.check(&key)?;
|
||||||
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
|
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
|
||||||
|
@ -98,11 +93,7 @@ fn op_get_env(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_delete_env(
|
fn op_delete_env(state: &mut OpState, key: String) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
key: String,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
state.borrow_mut::<Permissions>().env.check(&key)?;
|
state.borrow_mut::<Permissions>().env.check(&key)?;
|
||||||
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
|
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
|
||||||
return Err(type_error("Key contains invalid characters."));
|
return Err(type_error("Key contains invalid characters."));
|
||||||
|
@ -112,27 +103,19 @@ fn op_delete_env(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_set_exit_code(
|
fn op_set_exit_code(state: &mut OpState, code: i32) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
code: i32,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
state.borrow_mut::<Arc<AtomicI32>>().store(code, Relaxed);
|
state.borrow_mut::<Arc<AtomicI32>>().store(code, Relaxed);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[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);
|
let code = state.borrow::<Arc<AtomicI32>>().load(Relaxed);
|
||||||
std::process::exit(code)
|
std::process::exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_loadavg(
|
fn op_loadavg(state: &mut OpState) -> Result<(f64, f64, f64), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(f64, f64, f64), AnyError> {
|
|
||||||
super::check_unstable(state, "Deno.loadavg");
|
super::check_unstable(state, "Deno.loadavg");
|
||||||
state.borrow_mut::<Permissions>().env.check_all()?;
|
state.borrow_mut::<Permissions>().env.check_all()?;
|
||||||
match sys_info::loadavg() {
|
match sys_info::loadavg() {
|
||||||
|
@ -142,7 +125,7 @@ fn op_loadavg(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[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");
|
super::check_unstable(state, "Deno.hostname");
|
||||||
state.borrow_mut::<Permissions>().env.check_all()?;
|
state.borrow_mut::<Permissions>().env.check_all()?;
|
||||||
let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_string());
|
let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_string());
|
||||||
|
@ -150,11 +133,7 @@ fn op_hostname(state: &mut OpState, _: (), _: ()) -> Result<String, AnyError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_os_release(
|
fn op_os_release(state: &mut OpState) -> Result<String, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
|
||||||
super::check_unstable(state, "Deno.osRelease");
|
super::check_unstable(state, "Deno.osRelease");
|
||||||
state.borrow_mut::<Permissions>().env.check_all()?;
|
state.borrow_mut::<Permissions>().env.check_all()?;
|
||||||
let release = sys_info::os_release().unwrap_or_else(|_| "".to_string());
|
let release = sys_info::os_release().unwrap_or_else(|_| "".to_string());
|
||||||
|
@ -164,8 +143,6 @@ fn op_os_release(
|
||||||
#[op]
|
#[op]
|
||||||
fn op_network_interfaces(
|
fn op_network_interfaces(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<Vec<NetworkInterface>, AnyError> {
|
) -> Result<Vec<NetworkInterface>, AnyError> {
|
||||||
super::check_unstable(state, "Deno.networkInterfaces");
|
super::check_unstable(state, "Deno.networkInterfaces");
|
||||||
state.borrow_mut::<Permissions>().env.check_all()?;
|
state.borrow_mut::<Permissions>().env.check_all()?;
|
||||||
|
@ -232,8 +209,6 @@ struct MemInfo {
|
||||||
#[op]
|
#[op]
|
||||||
fn op_system_memory_info(
|
fn op_system_memory_info(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<Option<MemInfo>, AnyError> {
|
) -> Result<Option<MemInfo>, AnyError> {
|
||||||
super::check_unstable(state, "Deno.systemMemoryInfo");
|
super::check_unstable(state, "Deno.systemMemoryInfo");
|
||||||
state.borrow_mut::<Permissions>().env.check_all()?;
|
state.borrow_mut::<Permissions>().env.check_all()?;
|
||||||
|
@ -253,11 +228,7 @@ fn op_system_memory_info(
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
#[op]
|
#[op]
|
||||||
fn op_getuid(
|
fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<Option<u32>, AnyError> {
|
|
||||||
super::check_unstable(state, "Deno.getUid");
|
super::check_unstable(state, "Deno.getUid");
|
||||||
state.borrow_mut::<Permissions>().env.check_all()?;
|
state.borrow_mut::<Permissions>().env.check_all()?;
|
||||||
unsafe { Ok(Some(libc::getuid())) }
|
unsafe { Ok(Some(libc::getuid())) }
|
||||||
|
@ -265,11 +236,7 @@ fn op_getuid(
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[op]
|
#[op]
|
||||||
fn op_getuid(
|
fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<Option<u32>, AnyError> {
|
|
||||||
super::check_unstable(state, "Deno.getUid");
|
super::check_unstable(state, "Deno.getUid");
|
||||||
state.borrow_mut::<Permissions>().env.check_all()?;
|
state.borrow_mut::<Permissions>().env.check_all()?;
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|
|
@ -34,7 +34,6 @@ pub struct PermissionArgs {
|
||||||
pub fn op_query_permission(
|
pub fn op_query_permission(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: PermissionArgs,
|
args: PermissionArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let permissions = state.borrow::<Permissions>();
|
let permissions = state.borrow::<Permissions>();
|
||||||
let path = args.path.as_deref();
|
let path = args.path.as_deref();
|
||||||
|
@ -66,7 +65,6 @@ pub fn op_query_permission(
|
||||||
pub fn op_revoke_permission(
|
pub fn op_revoke_permission(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: PermissionArgs,
|
args: PermissionArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let permissions = state.borrow_mut::<Permissions>();
|
let permissions = state.borrow_mut::<Permissions>();
|
||||||
let path = args.path.as_deref();
|
let path = args.path.as_deref();
|
||||||
|
@ -98,7 +96,6 @@ pub fn op_revoke_permission(
|
||||||
pub fn op_request_permission(
|
pub fn op_request_permission(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: PermissionArgs,
|
args: PermissionArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let permissions = state.borrow_mut::<Permissions>();
|
let permissions = state.borrow_mut::<Permissions>();
|
||||||
let path = args.path.as_deref();
|
let path = args.path.as_deref();
|
||||||
|
|
|
@ -99,11 +99,7 @@ struct RunInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_run(
|
fn op_run(state: &mut OpState, run_args: RunArgs) -> Result<RunInfo, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
run_args: RunArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<RunInfo, AnyError> {
|
|
||||||
let args = run_args.cmd;
|
let args = run_args.cmd;
|
||||||
state.borrow_mut::<Permissions>().run.check(&args[0])?;
|
state.borrow_mut::<Permissions>().run.check(&args[0])?;
|
||||||
let env = run_args.env;
|
let env = run_args.env;
|
||||||
|
@ -227,7 +223,6 @@ struct ProcessStatus {
|
||||||
async fn op_run_status(
|
async fn op_run_status(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<ProcessStatus, AnyError> {
|
) -> Result<ProcessStatus, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
|
@ -19,11 +19,7 @@ pub fn init(main_module: ModuleSpecifier) -> Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_main_module(
|
fn op_main_module(state: &mut OpState) -> Result<String, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<String, AnyError> {
|
|
||||||
let main = state.borrow::<ModuleSpecifier>().to_string();
|
let main = state.borrow::<ModuleSpecifier>().to_string();
|
||||||
let main_url = deno_core::resolve_url_or_path(&main)?;
|
let main_url = deno_core::resolve_url_or_path(&main)?;
|
||||||
if main_url.scheme() == "file" {
|
if main_url.scheme() == "file" {
|
||||||
|
|
|
@ -178,7 +178,6 @@ pub fn signal_str_to_int(s: &str) -> Result<libc::c_int, AnyError> {
|
||||||
fn op_signal_bind(
|
fn op_signal_bind(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
sig: String,
|
sig: String,
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, AnyError> {
|
||||||
let signo = signal_str_to_int(&sig)?;
|
let signo = signal_str_to_int(&sig)?;
|
||||||
if signal_hook_registry::FORBIDDEN.contains(&signo) {
|
if signal_hook_registry::FORBIDDEN.contains(&signo) {
|
||||||
|
@ -200,7 +199,6 @@ fn op_signal_bind(
|
||||||
async fn op_signal_poll(
|
async fn op_signal_poll(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<bool, AnyError> {
|
) -> Result<bool, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -220,7 +218,6 @@ async fn op_signal_poll(
|
||||||
pub fn op_signal_unbind(
|
pub fn op_signal_unbind(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
state.resource_table.close(rid)?;
|
state.resource_table.close(rid)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -228,30 +225,18 @@ pub fn op_signal_unbind(
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_signal_bind(
|
pub fn op_signal_bind(_state: &mut OpState) -> Result<(), AnyError> {
|
||||||
_state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
Err(generic_error("not implemented"))
|
Err(generic_error("not implemented"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
#[op]
|
#[op]
|
||||||
fn op_signal_unbind(
|
fn op_signal_unbind(_state: &mut OpState) -> Result<(), AnyError> {
|
||||||
_state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
Err(generic_error("not implemented"))
|
Err(generic_error("not implemented"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
#[op]
|
#[op]
|
||||||
async fn op_signal_poll(
|
async fn op_signal_poll(_state: Rc<RefCell<OpState>>) -> Result<(), AnyError> {
|
||||||
_state: Rc<RefCell<OpState>>,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
Err(generic_error("not implemented"))
|
Err(generic_error("not implemented"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,11 +68,7 @@ pub struct SetRawArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_set_raw(
|
fn op_set_raw(state: &mut OpState, args: SetRawArgs) -> Result<(), AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
args: SetRawArgs,
|
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
|
||||||
super::check_unstable(state, "Deno.setRaw");
|
super::check_unstable(state, "Deno.setRaw");
|
||||||
|
|
||||||
let rid = args.rid;
|
let rid = args.rid;
|
||||||
|
@ -213,11 +209,7 @@ fn op_set_raw(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_isatty(
|
fn op_isatty(state: &mut OpState, rid: ResourceId) -> Result<bool, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
rid: ResourceId,
|
|
||||||
_: (),
|
|
||||||
) -> Result<bool, AnyError> {
|
|
||||||
let isatty: bool = StdFileResource::with(state, rid, move |r| match r {
|
let isatty: bool = StdFileResource::with(state, rid, move |r| match r {
|
||||||
Ok(std_file) => {
|
Ok(std_file) => {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
@ -251,7 +243,6 @@ struct ConsoleSize {
|
||||||
fn op_console_size(
|
fn op_console_size(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
|
||||||
) -> Result<ConsoleSize, AnyError> {
|
) -> Result<ConsoleSize, AnyError> {
|
||||||
super::check_unstable(state, "Deno.consoleSize");
|
super::check_unstable(state, "Deno.consoleSize");
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ pub fn init() -> Extension {
|
||||||
fn op_worker_post_message(
|
fn op_worker_post_message(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
data: JsMessageData,
|
data: JsMessageData,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let handle = state.borrow::<WebWorkerInternalHandle>().clone();
|
let handle = state.borrow::<WebWorkerInternalHandle>().clone();
|
||||||
handle.port.send(state, data)?;
|
handle.port.send(state, data)?;
|
||||||
|
@ -43,8 +42,6 @@ fn op_worker_post_message(
|
||||||
#[op]
|
#[op]
|
||||||
async fn op_worker_recv_message(
|
async fn op_worker_recv_message(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<Option<JsMessageData>, AnyError> {
|
) -> Result<Option<JsMessageData>, AnyError> {
|
||||||
let handle = {
|
let handle = {
|
||||||
let state = state.borrow();
|
let state = state.borrow();
|
||||||
|
@ -58,7 +55,7 @@ async fn op_worker_recv_message(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[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
|
// Notify parent that we're finished
|
||||||
let mut handle = state.borrow_mut::<WebWorkerInternalHandle>().clone();
|
let mut handle = state.borrow_mut::<WebWorkerInternalHandle>().clone();
|
||||||
|
|
||||||
|
@ -67,11 +64,7 @@ fn op_worker_close(state: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_worker_get_type(
|
fn op_worker_get_type(state: &mut OpState) -> Result<WebWorkerType, AnyError> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<WebWorkerType, AnyError> {
|
|
||||||
let handle = state.borrow::<WebWorkerInternalHandle>().clone();
|
let handle = state.borrow::<WebWorkerInternalHandle>().clone();
|
||||||
Ok(handle.worker_type)
|
Ok(handle.worker_type)
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,6 @@ pub struct CreateWorkerArgs {
|
||||||
fn op_create_worker(
|
fn op_create_worker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: CreateWorkerArgs,
|
args: CreateWorkerArgs,
|
||||||
_: (),
|
|
||||||
) -> Result<WorkerId, AnyError> {
|
) -> Result<WorkerId, AnyError> {
|
||||||
let specifier = args.specifier.clone();
|
let specifier = args.specifier.clone();
|
||||||
let maybe_source_code = if args.has_source_code {
|
let maybe_source_code = if args.has_source_code {
|
||||||
|
@ -265,7 +264,6 @@ fn op_create_worker(
|
||||||
fn op_host_terminate_worker(
|
fn op_host_terminate_worker(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
id: WorkerId,
|
id: WorkerId,
|
||||||
_: (),
|
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
if let Some(worker_thread) = state.borrow_mut::<WorkersTable>().remove(&id) {
|
if let Some(worker_thread) = state.borrow_mut::<WorkersTable>().remove(&id) {
|
||||||
worker_thread.terminate();
|
worker_thread.terminate();
|
||||||
|
@ -320,7 +318,6 @@ fn close_channel(
|
||||||
async fn op_host_recv_ctrl(
|
async fn op_host_recv_ctrl(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
id: WorkerId,
|
id: WorkerId,
|
||||||
_: (),
|
|
||||||
) -> Result<WorkerControlEvent, AnyError> {
|
) -> Result<WorkerControlEvent, AnyError> {
|
||||||
let worker_handle = {
|
let worker_handle = {
|
||||||
let state = state.borrow();
|
let state = state.borrow();
|
||||||
|
@ -352,7 +349,6 @@ async fn op_host_recv_ctrl(
|
||||||
async fn op_host_recv_message(
|
async fn op_host_recv_message(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
id: WorkerId,
|
id: WorkerId,
|
||||||
_: (),
|
|
||||||
) -> Result<Option<JsMessageData>, AnyError> {
|
) -> Result<Option<JsMessageData>, AnyError> {
|
||||||
let worker_handle = {
|
let worker_handle = {
|
||||||
let s = state.borrow();
|
let s = state.borrow();
|
||||||
|
|
Loading…
Reference in a new issue