Skip to content

Commit

Permalink
update quickjs-ng to 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrieshiemstra committed Sep 16, 2024
1 parent 22a7bb4 commit bc3e747
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quickjs_runtime"
version = "0.14.0"
version = "0.14.1"
authors = ["Andries Hiemstra <[email protected]>"]
edition = "2021"
description = "Wrapper API and utils for the QuickJS JavaScript engine with support for Promise, Modules, Async/await"
Expand Down Expand Up @@ -31,7 +31,7 @@ backtrace = "0.3.67"

#libquickjs-sys = {package="hirofa-quickjs-sys", git='https://github.com/HiRoFa/quickjs-sys'}
#libquickjs-sys = {package="hirofa-quickjs-sys", path='../quickjs-sys', default-features=false}
libquickjs-sys = {package="hirofa-quickjs-sys", version="0.4.0", default-features=false}
libquickjs-sys = {package="hirofa-quickjs-sys", version="0.5.0", default-features=false}
lazy_static = "1.4.0"
log = "0.4"
num_cpus = "1"
Expand Down
8 changes: 8 additions & 0 deletions src/quickjs_utils/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,17 @@ where
let atom = enum_ref.get_atom_raw(index) as q::JSAtom;
let prop_name = atoms::to_str(context, &atom)?;

#[cfg(feature = "bellard")]
let raw_value = q::JS_GetPropertyInternal(
context,
*obj_ref.borrow_value(),
atom,
*obj_ref.borrow_value(),
0,
);
#[cfg(feature = "quickjs-ng")]
let raw_value = q::JS_GetProperty(context, *obj_ref.borrow_value(), atom);

let prop_val_ref = QuickJsValueAdapter::new(
context,
raw_value,
Expand Down Expand Up @@ -511,13 +515,17 @@ where
let atom = enum_ref.get_atom_raw(index) as q::JSAtom;
let prop_name = atoms::to_str(context, &atom)?;

#[cfg(feature = "bellard")]
let raw_value = q::JS_GetPropertyInternal(
context,
*obj_ref.borrow_value(),
atom,
*obj_ref.borrow_value(),
0,
);
#[cfg(feature = "quickjs-ng")]
let raw_value = q::JS_GetProperty(context, *obj_ref.borrow_value(), atom);

let prop_val_ref = QuickJsValueAdapter::new(
context,
raw_value,
Expand Down
5 changes: 5 additions & 0 deletions src/quickjs_utils/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ pub fn to_f64(value_ref: &QuickJsValueAdapter) -> Result<f64, JsError> {
}

pub fn from_f64(f: f64) -> QuickJsValueAdapter {
#[cfg(feature = "bellard")]
let raw = unsafe { q::JS_NewFloat64(ptr::null_mut(), f) };

#[cfg(feature = "quickjs-ng")]
let raw = unsafe { q::JS_NewNumber(ptr::null_mut(), f) };

QuickJsValueAdapter::new_no_context(raw, "primitives::from_f64")
}

Expand Down

0 comments on commit bc3e747

Please sign in to comment.