summaryrefslogtreecommitdiff
path: root/cli/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/state.rs')
-rw-r--r--cli/state.rs29
1 files changed, 12 insertions, 17 deletions
diff --git a/cli/state.rs b/cli/state.rs
index 2ea75ace6..9f225e522 100644
--- a/cli/state.rs
+++ b/cli/state.rs
@@ -58,17 +58,6 @@ pub struct State {
}
impl State {
- pub fn stateful_json_op<D>(
- self: &Rc<Self>,
- dispatcher: D,
- ) -> impl Fn(&mut deno_core::CoreIsolateState, &mut [ZeroCopyBuf]) -> Op
- where
- D: Fn(&Rc<State>, Value, &mut [ZeroCopyBuf]) -> Result<JsonOp, ErrBox>,
- {
- use crate::ops::json_op;
- self.core_op(json_op(self.stateful_op(dispatcher)))
- }
-
pub fn stateful_json_op_sync<D>(
self: &Rc<Self>,
resource_table: &Rc<RefCell<ResourceTable>>,
@@ -85,7 +74,8 @@ impl State {
let state = self.clone();
let resource_table = resource_table.clone();
- move |isolate_state: &mut CoreIsolateState, bufs: &mut [ZeroCopyBuf]| {
+ let f = move |isolate_state: &mut CoreIsolateState,
+ bufs: &mut [ZeroCopyBuf]| {
let get_error_class_fn = isolate_state.get_error_class_fn;
// The first buffer should contain JSON encoded op arguments; parse them.
@@ -108,7 +98,8 @@ impl State {
// Convert to Op.
Op::Sync(serialize_result(None, result, get_error_class_fn))
- }
+ };
+ self.core_op(f)
}
pub fn stateful_json_op_async<D, F>(
@@ -124,7 +115,8 @@ impl State {
let state = self.clone();
let resource_table = resource_table.clone();
- move |isolate_state: &mut CoreIsolateState, bufs: &mut [ZeroCopyBuf]| {
+ let f = move |isolate_state: &mut CoreIsolateState,
+ bufs: &mut [ZeroCopyBuf]| {
let get_error_class_fn = isolate_state.get_error_class_fn;
// The first buffer should contain JSON encoded op arguments; parse them.
@@ -163,9 +155,12 @@ impl State {
}
.boxed_local(),
)
- }
+ };
+ self.core_op(f)
}
+ // TODO(bartlomieju): remove me - still used by `op_open_plugin` which
+ // needs access to isolate_state
pub fn stateful_json_op2<D>(
self: &Rc<Self>,
dispatcher: D,
@@ -185,7 +180,7 @@ impl State {
/// Wrap core `OpDispatcher` to collect metrics.
// TODO(ry) this should be private. Is called by stateful_json_op or
// stateful_minimal_op
- pub fn core_op<D>(
+ pub(crate) fn core_op<D>(
self: &Rc<Self>,
dispatcher: D,
) -> impl Fn(&mut deno_core::CoreIsolateState, &mut [ZeroCopyBuf]) -> Op
@@ -324,7 +319,7 @@ impl State {
///
/// This is intentionally a non-recoverable check so that people cannot probe
/// for unstable APIs from stable programs.
- pub fn check_unstable(self: &Rc<Self>, api_name: &str) {
+ pub fn check_unstable(&self, api_name: &str) {
// TODO(ry) Maybe use IsolateHandle::terminate_execution here to provide a
// stack trace in JS.
if !self.global_state.flags.unstable {