Skip to content
Merged
Changes from all commits
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
45 changes: 35 additions & 10 deletions mozjs-sys/src/jsimpls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::jsapi::glue::JS_ForOfIteratorInit;
use crate::jsapi::glue::JS_ForOfIteratorNext;
use crate::jsapi::jsid;
use crate::jsapi::mozilla;
use crate::jsapi::JSAutoRealm;
use crate::jsapi::JSContext;
use crate::jsapi::JSErrNum;
Expand All @@ -22,7 +23,7 @@ use crate::jsgc::RootKind;
use crate::jsid::VoidId;
use crate::jsval::UndefinedValue;

use crate::jsapi::JS::{ObjectOpResult, ObjectOpResult_SpecialCodes};
use std::marker::PhantomData;
use std::ops::Deref;
use std::ops::DerefMut;
use std::os::raw::c_void;
Expand Down Expand Up @@ -87,7 +88,7 @@ impl<T> JS::Handle<T> {
pub unsafe fn from_marked_location(ptr: *const T) -> JS::Handle<T> {
JS::Handle {
ptr: ptr as *mut T,
_phantom_0: ::std::marker::PhantomData,
_phantom_0: PhantomData,
}
}
}
Expand All @@ -96,7 +97,7 @@ impl<T> JS::MutableHandle<T> {
pub unsafe fn from_marked_location(ptr: *mut T) -> JS::MutableHandle<T> {
JS::MutableHandle {
ptr,
_phantom_0: ::std::marker::PhantomData,
_phantom_0: PhantomData,
}
}

Expand Down Expand Up @@ -379,9 +380,9 @@ impl JSNativeWrapper {
impl<T> JS::Rooted<T> {
pub fn new_unrooted() -> JS::Rooted<T> {
JS::Rooted {
stack: ::std::ptr::null_mut(),
prev: ::std::ptr::null_mut(),
ptr: unsafe { ::std::mem::zeroed() },
stack: ptr::null_mut(),
prev: ptr::null_mut(),
ptr: unsafe { std::mem::zeroed() },
}
}

Expand Down Expand Up @@ -523,10 +524,10 @@ impl JS::ObjectOpResult {
}
}

impl Default for ObjectOpResult {
fn default() -> ObjectOpResult {
ObjectOpResult {
code_: ObjectOpResult_SpecialCodes::Uninitialized as usize,
impl Default for JS::ObjectOpResult {
fn default() -> JS::ObjectOpResult {
JS::ObjectOpResult {
code_: JS::ObjectOpResult_SpecialCodes::Uninitialized as usize,
}
}
}
Expand All @@ -544,3 +545,27 @@ impl JS::ForOfIterator {
JS_ForOfIteratorNext(self, val, done)
}
}

impl<T> mozilla::Range<T> {
pub fn new(start: &mut T, end: &mut T) -> mozilla::Range<T> {
mozilla::Range {
mStart: mozilla::RangedPtr {
mPtr: start,
#[cfg(feature = "debugmozjs")]
mRangeStart: start,
#[cfg(feature = "debugmozjs")]
mRangeEnd: end,
_phantom_0: PhantomData,
},
mEnd: mozilla::RangedPtr {
mPtr: end,
#[cfg(feature = "debugmozjs")]
mRangeStart: start,
#[cfg(feature = "debugmozjs")]
mRangeEnd: end,
_phantom_0: PhantomData,
},
_phantom_0: PhantomData,
}
}
}