mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Replace NonZero<*mut JSObject> with a wrapper to enable local trait impls.
This commit is contained in:
parent
115d859551
commit
e2fafd2dfc
22 changed files with 108 additions and 69 deletions
|
@ -2,16 +2,16 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use core::nonzero::NonZero;
|
||||
use dom::bindings::codegen::Bindings::TextEncoderBinding;
|
||||
use dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::nonnull::NonNullJSObjectPtr;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::bindings::str::{DOMString, USVString};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{JSContext, JSObject};
|
||||
use js::jsapi::JSContext;
|
||||
use js::typedarray::{Uint8Array, CreateWith};
|
||||
use std::ptr;
|
||||
|
||||
|
@ -47,12 +47,12 @@ impl TextEncoderMethods for TextEncoder {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encode
|
||||
unsafe fn Encode(&self, cx: *mut JSContext, input: USVString) -> NonZero<*mut JSObject> {
|
||||
unsafe fn Encode(&self, cx: *mut JSContext, input: USVString) -> NonNullJSObjectPtr {
|
||||
let encoded = input.0.as_bytes();
|
||||
|
||||
rooted!(in(cx) let mut js_object = ptr::null_mut());
|
||||
assert!(Uint8Array::create(cx, CreateWith::Slice(&encoded), js_object.handle_mut()).is_ok());
|
||||
|
||||
NonZero::new_unchecked(js_object.get())
|
||||
NonNullJSObjectPtr::new_unchecked(js_object.get())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue