Skip to content

Commit

Permalink
use str to_jsval() now
Browse files Browse the repository at this point in the history
xmlhttprequest.rs, CodegenRust.py
replace into_string().to_jsval() to to_jsval()

conversions.rs
DOMString to_jsval() use as_slice().tojsval() now
  • Loading branch information
yodalee committed Dec 31, 2014
1 parent 6f569de commit bb087c2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -2781,7 +2781,7 @@ def __init__(self, enum):
impl ToJSValConvertible for super::%s {
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
strings[*self as uint].into_string().to_jsval(cx)
strings[*self as uint].to_jsval(cx)
}
}
""" % (",\n ".join(['"%s"' % val for val in enum.values()]), enum.identifier.name)
Expand Down
9 changes: 1 addition & 8 deletions components/script/dom/bindings/conversions.rs
Expand Up @@ -247,14 +247,7 @@ impl ToJSValConvertible for str {

impl ToJSValConvertible for DOMString {
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
unsafe {
let string_utf16: Vec<u16> = self.as_slice().utf16_units().collect();
let jsstr = JS_NewUCStringCopyN(cx, string_utf16.as_ptr(), string_utf16.len() as libc::size_t);
if jsstr.is_null() {
panic!("JS_NewUCStringCopyN failed");
}
StringValue(&*jsstr)
}
self.as_slice().to_jsval(cx)
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/xmlhttprequest.rs
Expand Up @@ -695,7 +695,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
if ready_state == XMLHttpRequestState::XHRDone || ready_state == XMLHttpRequestState::Loading {
self.text_response().to_jsval(cx)
} else {
"".into_string().to_jsval(cx)
"".to_jsval(cx)
}
},
_ if self.ready_state.get() != XMLHttpRequestState::XHRDone => NullValue(),
Expand Down

9 comments on commit bb087c2

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at yodalee@bb087c2

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging yodalee/servo/issue4484-ToJSValConvertible-for-str = bb087c2 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yodalee/servo/issue4484-ToJSValConvertible-for-str = bb087c2 merged ok, testing candidate = aaf099c

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at yodalee@bb087c2

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging yodalee/servo/issue4484-ToJSValConvertible-for-str = bb087c2 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yodalee/servo/issue4484-ToJSValConvertible-for-str = bb087c2 merged ok, testing candidate = fda38cf

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = fda38cf

Please sign in to comment.