Skip to content

Commit

Permalink
Fix Context::base
Browse files Browse the repository at this point in the history
  • Loading branch information
DelSkayn committed Nov 18, 2024
1 parent 51618b1 commit bab3ebc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/context/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl AsyncContext {
/// If additional functions are required use [`AsyncContext::custom`],
/// [`AsyncContext::builder`] or [`AsyncContext::full`].
pub async fn base(runtime: &AsyncRuntime) -> Result<Self> {
Self::custom::<intrinsic::Base>(runtime).await
Self::custom::<intrinsic::None>(runtime).await
}

/// Creates a context with only the required intrinsics registered.
Expand Down
12 changes: 9 additions & 3 deletions core/src/context/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Context {
/// If additional functions are required use [`Context::custom`],
/// [`Context::builder`] or [`Context::full`].
pub fn base(runtime: &Runtime) -> Result<Self> {
Self::custom::<intrinsic::Base>(runtime)
Self::custom::<intrinsic::None>(runtime)
}

/// Creates a context with only the required intrinsics registered.
Expand All @@ -51,7 +51,7 @@ impl Context {
let ctx = NonNull::new(unsafe { qjs::JS_NewContextRaw(guard.rt.as_ptr()) })
.ok_or_else(|| Error::Allocation)?;
// rquickjs assumes the base objects exist, so we allways need to add this.
unsafe { intrinsic::Base::add_intrinsic(ctx) };
unsafe { qjs::JS_AddIntrinsicBaseObjects(ctx.as_ptr()) };
unsafe { I::add_intrinsic(ctx) };
let res = Inner {
ctx,
Expand Down Expand Up @@ -154,7 +154,7 @@ mod test {
use crate::*;

#[test]
fn base() {
fn basic() {
test_with(|ctx| {
let val: Value = ctx.eval(r#"1+1"#).unwrap();

Expand All @@ -179,6 +179,12 @@ mod test {
});
}

#[test]
fn base() {
let rt = Runtime::new().unwrap();
let _ = Context::base(&rt).unwrap();
}

#[test]
fn module() {
test_with(|ctx| {
Expand Down
5 changes: 0 additions & 5 deletions core/src/context/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ pub mod intrinsic {

intrinsic_impls! {
@builtin:
/// Add base objects support
BaseObjects JS_AddIntrinsicBaseObjects,
/// Add Date object support
Date JS_AddIntrinsicDate,
/// Add evaluation support
Expand All @@ -81,9 +79,6 @@ pub mod intrinsic {
WeakRef JS_AddIntrinsicWeakRef,
}

/// An alias for [`BaseObjects`]
pub type Base = BaseObjects;

/// Add none intrinsics
pub type None = ();

Expand Down

0 comments on commit bab3ebc

Please sign in to comment.