diff options
author | Sam Liu <sam@ambushnetworks.com> | 2017-02-20 19:26:23 -0800 |
---|---|---|
committer | Sam Liu <sam@ambushnetworks.com> | 2017-02-20 23:13:47 -0800 |
commit | 4fc3e7e75d7eb7e61d4cbefd82d520a7d7320ef8 (patch) | |
tree | b5bc1674e21a7cba492bc7f5d157f1a5ca2c8741 /components/script/dom/crypto.rs | |
parent | ccc1df2dfe4f823419f57018c61cf53304979d11 (diff) | |
download | servo-4fc3e7e75d7eb7e61d4cbefd82d520a7d7320ef8.tar.gz servo-4fc3e7e75d7eb7e61d4cbefd82d520a7d7320ef8.zip |
Replace uses of spidermonkey-specific JS_GetArrayBufferViewType with ArrayBufferView impl's method get_array_type()
Diffstat (limited to 'components/script/dom/crypto.rs')
-rw-r--r-- | components/script/dom/crypto.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/components/script/dom/crypto.rs b/components/script/dom/crypto.rs index 6c7fce6c8d1..0067dd1c51a 100644 --- a/components/script/dom/crypto.rs +++ b/components/script/dom/crypto.rs @@ -11,7 +11,7 @@ use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::globalscope::GlobalScope; use js::jsapi::{JSContext, JSObject}; -use js::jsapi::{JS_GetArrayBufferViewType, Type}; +use js::jsapi::Type; use servo_rand::{ServoRng, Rng}; unsafe_no_jsmanaged_fields!(ServoRng); @@ -46,15 +46,15 @@ impl CryptoMethods for Crypto { -> Fallible<NonZero<*mut JSObject>> { assert!(!input.is_null()); typedarray!(in(_cx) let mut array_buffer_view: ArrayBufferView = input); - let mut data = match array_buffer_view.as_mut() { - Ok(x) => x.as_mut_slice(), + let (array_type, mut data) = match array_buffer_view.as_mut() { + Ok(x) => (x.get_array_type(), x.as_mut_slice()), Err(_) => { return Err(Error::Type("Argument to Crypto.getRandomValues is not an ArrayBufferView" .to_owned())); } }; - if !is_integer_buffer(input) { + if !is_integer_buffer(array_type) { return Err(Error::TypeMismatch); } @@ -68,9 +68,8 @@ impl CryptoMethods for Crypto { } } -#[allow(unsafe_code)] -fn is_integer_buffer(input: *mut JSObject) -> bool { - match unsafe { JS_GetArrayBufferViewType(input) } { +fn is_integer_buffer(array_type: Type) -> bool { + match array_type { Type::Uint8 | Type::Uint8Clamped | Type::Int8 | |