Skip to content

Commit c0ce4a8

Browse files
authored
Added Constructor for mozilla::Range (#433)
* Added Constructor for mozilla::Range * Fixed Imports in jsimpls
1 parent 3b5690c commit c0ce4a8

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

mozjs-sys/src/jsimpls.rs

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use crate::jsapi::glue::JS_ForOfIteratorInit;
66
use crate::jsapi::glue::JS_ForOfIteratorNext;
77
use crate::jsapi::jsid;
8+
use crate::jsapi::mozilla;
89
use crate::jsapi::JSAutoRealm;
910
use crate::jsapi::JSContext;
1011
use crate::jsapi::JSErrNum;
@@ -22,7 +23,7 @@ use crate::jsgc::RootKind;
2223
use crate::jsid::VoidId;
2324
use crate::jsval::UndefinedValue;
2425

25-
use crate::jsapi::JS::{ObjectOpResult, ObjectOpResult_SpecialCodes};
26+
use std::marker::PhantomData;
2627
use std::ops::Deref;
2728
use std::ops::DerefMut;
2829
use std::os::raw::c_void;
@@ -87,7 +88,7 @@ impl<T> JS::Handle<T> {
8788
pub unsafe fn from_marked_location(ptr: *const T) -> JS::Handle<T> {
8889
JS::Handle {
8990
ptr: ptr as *mut T,
90-
_phantom_0: ::std::marker::PhantomData,
91+
_phantom_0: PhantomData,
9192
}
9293
}
9394
}
@@ -96,7 +97,7 @@ impl<T> JS::MutableHandle<T> {
9697
pub unsafe fn from_marked_location(ptr: *mut T) -> JS::MutableHandle<T> {
9798
JS::MutableHandle {
9899
ptr,
99-
_phantom_0: ::std::marker::PhantomData,
100+
_phantom_0: PhantomData,
100101
}
101102
}
102103

@@ -379,9 +380,9 @@ impl JSNativeWrapper {
379380
impl<T> JS::Rooted<T> {
380381
pub fn new_unrooted() -> JS::Rooted<T> {
381382
JS::Rooted {
382-
stack: ::std::ptr::null_mut(),
383-
prev: ::std::ptr::null_mut(),
384-
ptr: unsafe { ::std::mem::zeroed() },
383+
stack: ptr::null_mut(),
384+
prev: ptr::null_mut(),
385+
ptr: unsafe { std::mem::zeroed() },
385386
}
386387
}
387388

@@ -523,10 +524,10 @@ impl JS::ObjectOpResult {
523524
}
524525
}
525526

526-
impl Default for ObjectOpResult {
527-
fn default() -> ObjectOpResult {
528-
ObjectOpResult {
529-
code_: ObjectOpResult_SpecialCodes::Uninitialized as usize,
527+
impl Default for JS::ObjectOpResult {
528+
fn default() -> JS::ObjectOpResult {
529+
JS::ObjectOpResult {
530+
code_: JS::ObjectOpResult_SpecialCodes::Uninitialized as usize,
530531
}
531532
}
532533
}
@@ -544,3 +545,27 @@ impl JS::ForOfIterator {
544545
JS_ForOfIteratorNext(self, val, done)
545546
}
546547
}
548+
549+
impl<T> mozilla::Range<T> {
550+
pub fn new(start: &mut T, end: &mut T) -> mozilla::Range<T> {
551+
mozilla::Range {
552+
mStart: mozilla::RangedPtr {
553+
mPtr: start,
554+
#[cfg(feature = "debugmozjs")]
555+
mRangeStart: start,
556+
#[cfg(feature = "debugmozjs")]
557+
mRangeEnd: end,
558+
_phantom_0: PhantomData,
559+
},
560+
mEnd: mozilla::RangedPtr {
561+
mPtr: end,
562+
#[cfg(feature = "debugmozjs")]
563+
mRangeStart: start,
564+
#[cfg(feature = "debugmozjs")]
565+
mRangeEnd: end,
566+
_phantom_0: PhantomData,
567+
},
568+
_phantom_0: PhantomData,
569+
}
570+
}
571+
}

0 commit comments

Comments
 (0)