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
+254
−54
Merged
Implement the MozMap type. #13332
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6023560
Improve jsid_to_str's name and documentation.
Ms2ger d1d2074
Improve handling of ConversionResult::Failure in unions.
Ms2ger e942f50
Handle unsupported types better in getUnionTypeTemplateVars.
Ms2ger b2fc80a
Rename innerSequenceType to innerContainerType.
Ms2ger 9371889
Use innerContainerType in getConversionConfigForType.
Ms2ger 9a9ca45
Introduce wrapInNativeContainerType.
Ms2ger 2d83e5a
Implement the MozMap type.
Ms2ger File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
| @@ -44,6 +44,7 @@ pub use js::conversions::ConversionBehavior; | ||
| use js::conversions::latin1_to_string; | ||
| use js::error::throw_type_error; | ||
| use js::glue::{GetProxyPrivate, IsWrapper}; | ||
| use js::glue::{RUST_JSID_IS_INT, RUST_JSID_TO_INT}; | ||
| use js::glue::{RUST_JSID_IS_STRING, RUST_JSID_TO_STRING, UnwrapObject}; | ||
| use js::jsapi::{HandleId, HandleObject, HandleValue, JSClass, JSContext}; | ||
| use js::jsapi::{JSObject, JSString, JS_GetArrayBufferViewType, JS_GetClass}; | ||
| @@ -115,15 +116,36 @@ 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. | ||
Ms2ger
Author
Contributor
|
||
| /// | ||
| /// # Panics | ||
| /// | ||
| /// Panics if `id` is not string-valued. | ||
| pub fn string_jsid_to_string(cx: *mut JSContext, id: HandleId) -> DOMString { | ||
|
||
| unsafe { | ||
| assert!(RUST_JSID_IS_STRING(id)); | ||
| jsstring_to_str(cx, RUST_JSID_TO_STRING(id)) | ||
| } | ||
| } | ||
|
|
||
| /// Convert `id` to a `DOMString`. Returns `None` if `id` is not a string or | ||
| /// integer. | ||
| /// | ||
| /// Handling of invalid UTF-16 in strings depends on the relevant option. | ||
|
||
| pub unsafe fn jsid_to_string(cx: *mut JSContext, id: HandleId) -> Option<DOMString> { | ||
| if RUST_JSID_IS_STRING(id) { | ||
| return Some(jsstring_to_str(cx, RUST_JSID_TO_STRING(id))); | ||
| } | ||
|
|
||
| if RUST_JSID_IS_INT(id) { | ||
| return Some(RUST_JSID_TO_INT(id).to_string().into()); | ||
| } | ||
|
|
||
| None | ||
| } | ||
|
|
||
| // http://heycam.github.io/webidl/#es-USVString | ||
| impl ToJSValConvertible for USVString { | ||
| unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { | ||
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
"relevant option"? Is this a copy-paste error?