mirror of
https://github.com/servo/servo.git
synced 2025-09-23 05:10:09 +01:00
Compile WebIDL return type "object" to NonZero<*mut JSObject>
This commit is contained in:
parent
3e32948a39
commit
6e1523f4ae
11 changed files with 74 additions and 48 deletions
|
@ -2,6 +2,7 @@
|
|||
* 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::{Error, Fallible};
|
||||
|
@ -70,7 +71,7 @@ impl TextEncoderMethods for TextEncoder {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encode
|
||||
fn Encode(&self, cx: *mut JSContext, input: USVString) -> *mut JSObject {
|
||||
fn Encode(&self, cx: *mut JSContext, input: USVString) -> NonZero<*mut JSObject> {
|
||||
unsafe {
|
||||
let encoded = self.encoder.encode(&input.0, EncoderTrap::Strict).unwrap();
|
||||
let length = encoded.len() as u32;
|
||||
|
@ -80,7 +81,7 @@ impl TextEncoderMethods for TextEncoder {
|
|||
let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object.get(), &mut is_shared, ptr::null());
|
||||
assert!(!is_shared);
|
||||
ptr::copy_nonoverlapping(encoded.as_ptr(), js_object_data, length as usize);
|
||||
js_object.get()
|
||||
NonZero::new(js_object.get())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue