Skip to content

Commit 2c59822

Browse files
authored
Fix all the warnings (#562)
* Add oom-with-hook feature to Cargo Signed-off-by: Greg Morenz <[email protected]> * Remove unused import Signed-off-by: Greg Morenz <[email protected]> * Fix abi of EncodedStringCallback Signed-off-by: Greg Morenz <[email protected]> * Resolve ambiguous imports Signed-off-by: Greg Morenz <[email protected]> --------- Signed-off-by: Greg Morenz <[email protected]>
1 parent 99518a4 commit 2c59822

File tree

6 files changed

+10
-4
lines changed

6 files changed

+10
-4
lines changed

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ debugmozjs = []
2727
profilemozjs = []
2828
jitspew = []
2929
crown = []
30+
oom_with_hook = []
3031

3132
[dependencies]
3233
libc.workspace = true

mozjs-sys/src/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use core::mem;
1111

1212
pub use generated::root::*;
1313

14-
pub type EncodedStringCallback = fn(*const core::ffi::c_char);
14+
pub type EncodedStringCallback = unsafe extern "C" fn(*const core::ffi::c_char);
1515

1616
// manual glue stuff
1717
unsafe impl Sync for ProxyTraps {}

mozjs-sys/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![allow(unused_extern_crates)]
66
#![cfg_attr(feature = "crown", feature(register_tool))]
77
#![cfg_attr(feature = "crown", register_tool(crown))]
8+
#![cfg_attr(feature = "oom_with_hook", feature(alloc_error_hook))]
89

910
// These extern crates are needed for linking
1011
extern crate encoding_c;

mozjs-sys/src/trace.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use std::sync::atomic::{
3232
AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicU16, AtomicU32,
3333
AtomicU64, AtomicU8, AtomicUsize,
3434
};
35-
use std::sync::Arc;
3635
use std::thread::JoinHandle;
3736
use std::time::{Duration, Instant, SystemTime};
3837

mozjs/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
//!
3232
3333
pub mod jsapi {
34+
// Resolve ambiguous imports
35+
pub use mozjs_sys::jsapi::js::detail;
36+
pub use mozjs_sys::jsapi::JS::{FrontendContext, MemoryUse};
37+
3438
pub use mozjs_sys::jsapi::glue::*;
3539
pub use mozjs_sys::jsapi::js::detail::*;
3640
pub use mozjs_sys::jsapi::js::*;

mozjs/tests/callback.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ unsafe extern "C" fn puts(context: *mut JSContext, argc: u32, vp: *mut Value) ->
6464
let arg = mozjs::rust::Handle::from_raw(args.get(0));
6565
let js = mozjs::rust::ToString(context, arg);
6666
rooted!(in(context) let message_root = js);
67-
EncodeStringToUTF8(context, message_root.handle().into(), |message| {
67+
unsafe extern "C" fn cb(message: *const core::ffi::c_char) {
6868
let message = CStr::from_ptr(message);
6969
let message = str::from_utf8(message.to_bytes()).unwrap();
7070
assert_eq!(message, "Test Iñtërnâtiônàlizætiøn ┬─┬ノ( º _ ºノ) ");
7171
println!("{}", message);
72-
});
72+
}
73+
EncodeStringToUTF8(context, message_root.handle().into(), cb);
7374

7475
args.rval().set(UndefinedValue());
7576
true

0 commit comments

Comments
 (0)