Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Implement host hooks and job queues APIs #2529

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove HostHooks implementation for ()
jedel1043 committed Jan 18, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a5acf793839f8d9110d324a7bc5e31ad716e81e1
8 changes: 7 additions & 1 deletion boa_engine/src/context/hooks.rs
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ pub trait HostHooks {
// 1. Return the JobCallback Record { [[Callback]]: callback, [[HostDefined]]: empty }.
JobCallback::new(callback, ())
}

/// [`HostCallJobCallback ( jobCallback, V, argumentsList )`][spec]
///
/// # Requirements
@@ -87,6 +88,7 @@ pub trait HostHooks {
) {
// The default implementation of HostPromiseRejectionTracker is to return unused.
}

/// [`HostEnsureCanCompileStrings ( calleeRealm )`][spec]
///
/// # Requirements
@@ -102,6 +104,7 @@ pub trait HostHooks {
// The default implementation of HostEnsureCanCompileStrings is to return NormalCompletion(unused).
Ok(())
}

/// [`HostHasSourceTextAvailable ( func )`][spec]
///
/// # Requirements
@@ -121,4 +124,7 @@ pub trait HostHooks {
}

/// Default implementation of [`HostHooks`], which doesn't carry any state.
impl HostHooks for () {}
#[derive(Debug, Clone, Copy)]
pub(crate) struct DefaultHooks;

impl HostHooks for DefaultHooks {}
3 changes: 2 additions & 1 deletion boa_engine/src/context/mod.rs
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

mod hooks;
pub mod intrinsics;
use hooks::DefaultHooks;
pub use hooks::HostHooks;

#[cfg(feature = "intl")]
@@ -612,7 +613,7 @@ impl<'icu, 'hooks, 'queue> ContextBuilder<'icu, 'hooks, 'queue> {
#[cfg(feature = "fuzz")]
instructions_remaining: self.instructions_remaining,
kept_alive: Vec::new(),
host_hooks: self.host_hooks.unwrap_or(&()),
host_hooks: self.host_hooks.unwrap_or(&DefaultHooks),
job_queue: self.job_queue.unwrap_or(&IdleJobQueue),
};