Skip to content

Commit

Permalink
Added Constructor for mozilla::Range (#433)
Browse files Browse the repository at this point in the history
* Added Constructor for mozilla::Range

* Fixed Imports in jsimpls
  • Loading branch information
Redfire75369 authored Dec 2, 2023
1 parent 3b5690c commit c0ce4a8
Showing 1 changed file with 35 additions and 10 deletions.
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,
}
}
}

0 comments on commit c0ce4a8

Please sign in to comment.