Skip to content

Commit

Permalink
move op to ops_builtin_v8.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosc90 committed Oct 16, 2022
1 parent 713e2f4 commit d5e8c42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions core/01_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
eventLoopHasMoreWork: () => ops.op_event_loop_has_more_work(),
setPromiseRejectCallback: (fn) => ops.op_set_promise_reject_callback(fn),
byteLength: (str) => ops.op_str_byte_length(str),
arrayBufferWasDetached: (ab) => ops.op_arraybuffer_was_detached(ab)
});

ObjectAssign(globalThis.__bootstrap, { core });
Expand Down
10 changes: 10 additions & 0 deletions core/ops_builtin_v8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub(crate) fn init_builtins_v8() -> Vec<OpDecl> {
op_store_pending_promise_exception::decl(),
op_remove_pending_promise_exception::decl(),
op_has_pending_promise_exception::decl(),
op_arraybuffer_was_detached::decl(),
]
}

Expand Down Expand Up @@ -887,3 +888,12 @@ fn op_has_pending_promise_exception<'a>(
.pending_promise_exceptions
.contains_key(&promise_global)
}

#[op(v8)]
fn op_arraybuffer_was_detached<'a>(
_scope: &mut v8::HandleScope<'a>,
input: serde_v8::Value<'a>,
) -> Result<bool, Error> {
let ab = v8::Local::<v8::ArrayBuffer>::try_from(input.v8_value)?;
Ok(ab.was_detached())
}
10 changes: 0 additions & 10 deletions ext/web/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ pub fn init<P: TimersPermission + 'static>(
op_timer_handle::decl(),
op_cancel_handle::decl(),
op_sleep::decl(),
op_arraybuffer_was_detached::decl(),
])
.state(move |state| {
state.put(blob_store.clone());
Expand Down Expand Up @@ -338,15 +337,6 @@ fn op_encoding_encode_into(
Ok(())
}

#[op(v8)]
fn op_arraybuffer_was_detached<'a>(
_scope: &mut v8::HandleScope<'a>,
input: serde_v8::Value<'a>,
) -> Result<bool, AnyError> {
let ab = v8::Local::<v8::ArrayBuffer>::try_from(input.v8_value)?;
Ok(ab.was_detached())
}

/// Creates a [`CancelHandle`] resource that can be used to cancel invocations of certain ops.
#[op]
pub fn op_cancel_handle(state: &mut OpState) -> ResourceId {
Expand Down

0 comments on commit d5e8c42

Please sign in to comment.