Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the MozMap type. #13332

Merged
merged 7 commits into from Sep 21, 2016
Next

Improve jsid_to_str's name and documentation.

  • Loading branch information
Ms2ger committed Sep 21, 2016
commit 6023560863b4d08d68e1f637ba110c7023a9f18c
@@ -4658,7 +4658,7 @@ def __init__(self, descriptor, name):
def define(self):
# Our first argument is the id we're getting.
argName = self.arguments[0].identifier.name
return ("let %s = jsid_to_str(cx, id);\n"
return ("let %s = string_jsid_to_string(cx, id);\n"
"let this = UnwrapProxy(proxy);\n"
"let this = &*this;\n" % argName +
CGProxySpecialOperation.define(self))
@@ -5528,13 +5528,13 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'dom::bindings::conversions::StringificationBehavior',
'dom::bindings::conversions::ToJSValConvertible',
'dom::bindings::conversions::is_array_like',
'dom::bindings::conversions::jsid_to_str',
'dom::bindings::conversions::native_from_handlevalue',
'dom::bindings::conversions::native_from_object',
'dom::bindings::conversions::private_from_object',
'dom::bindings::conversions::root_from_handleobject',
'dom::bindings::conversions::root_from_handlevalue',
'dom::bindings::conversions::root_from_object',
'dom::bindings::conversions::string_jsid_to_string',
'dom::bindings::codegen::PrototypeList',
'dom::bindings::codegen::RegisterBindings',
'dom::bindings::codegen::UnionTypes',
@@ -115,9 +115,14 @@ impl <T: Reflectable + IDLInterface> FromJSValConvertible for Root<T> {
}
}

/// Convert the given `jsid` to a `DOMString`. Fails if the `jsid` is not a
/// string, or if the string does not contain valid UTF-16.
pub fn jsid_to_str(cx: *mut JSContext, id: HandleId) -> DOMString {
/// Convert `id` to a `DOMString`, assuming it is string-valued.
///
/// Handling of invalid UTF-16 in strings depends on the relevant option.

This comment has been minimized.

@jdm

jdm Sep 20, 2016

Member

"relevant option"? Is this a copy-paste error?

This comment has been minimized.

@Ms2ger

Ms2ger Sep 21, 2016

Author Contributor

Refers to opts::get().replace_surrogates; not sure if it would be better to mention -Z replace-surrogates explicitly.

///
/// # Panics
///
/// Panics if `id` is not string-valued.
pub fn string_jsid_to_string(cx: *mut JSContext, id: HandleId) -> DOMString {

This comment has been minimized.

@nox

nox Sep 20, 2016

Member

Could you make it unsafe while at it?

unsafe {
assert!(RUST_JSID_IS_STRING(id));
jsstring_to_str(cx, RUST_JSID_TO_STRING(id))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.