mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Use the conversion traits from js.
This commit is contained in:
parent
acb24e80b8
commit
6d2ae85c1f
15 changed files with 285 additions and 647 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
use dom::bindings::codegen::PrototypeList;
|
||||
use dom::bindings::codegen::PrototypeList::MAX_PROTO_CHAIN_LENGTH;
|
||||
use dom::bindings::conversions::{DOM_OBJECT_SLOT, is_dom_class, jsstring_to_str};
|
||||
use dom::bindings::conversions::{DOM_OBJECT_SLOT, is_dom_class};
|
||||
use dom::bindings::conversions::{private_from_proto_check, root_from_handleobject};
|
||||
use dom::bindings::error::throw_invalid_this;
|
||||
use dom::bindings::inheritance::TopTypeId;
|
||||
|
@ -50,6 +50,7 @@ use std::default::Default;
|
|||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::str::jsstring_to_str;
|
||||
|
||||
/// Proxy handler for a WindowProxy.
|
||||
#[allow(raw_pointer_derive)]
|
||||
|
@ -441,11 +442,11 @@ pub fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Option<u32>
|
|||
/// Find the index of a string given by `v` in `values`.
|
||||
/// Returns `Err(())` on JSAPI failure (there is a pending exception), and
|
||||
/// `Ok(None)` if there was no matching string.
|
||||
pub fn find_enum_string_index(cx: *mut JSContext,
|
||||
v: HandleValue,
|
||||
values: &[&'static str])
|
||||
-> Result<Option<usize>, ()> {
|
||||
let jsstr = unsafe { ToString(cx, v) };
|
||||
pub unsafe fn find_enum_string_index(cx: *mut JSContext,
|
||||
v: HandleValue,
|
||||
values: &[&'static str])
|
||||
-> Result<Option<usize>, ()> {
|
||||
let jsstr = ToString(cx, v);
|
||||
if jsstr.is_null() {
|
||||
return Err(());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue