bors-servo
e597cd9e1a
Auto merge of #20265 - Xanewok:fix-js-objects-in-unions, r=jdm
...
Fix JS object conversion in unions
<!-- Please describe your changes on the following line: -->
Requires safe `Heap::boxed` constructor from https://github.com/servo/rust-mozjs/pull/395 (more info on it is in the PR).
Since unions currently assume that their respective members root themselves and can be stored on heap, I modified the union member object conversion branch to convert to a `RootedTraceableBox<Heap<*mut JSObject>>` (which is the currently generated type for objects in said unions).
I did it only for Unions and not dictionaries, since some dictionaries had bare `*mut JSObject` members - is this a mistake and something that needs further fixing?
Does this need a test, e.g. passing a union with object to a function that returns said object, and comparing the results for equality?
r? @jdm
Generated code with this patch (for `StringOrObject`):
```rust
impl FromJSValConvertible for StringOrObject {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrObject>, ()> {
if value.get().is_object() {
match StringOrObject::TryConvertToObject(cx, value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrObject::Object(value))),
Ok(None) => (),
}
}
// (...)
}
}
impl StringOrObject {
// (...)
unsafe fn TryConvertToObject(cx: *mut JSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<Heap<*mut JSObject>>>, ()> {
Ok(Some(RootedTraceableBox::from_box(Heap::boxed(value.get().to_object()))))
}
}
```
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #17011 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20265 )
<!-- Reviewable:end -->
2018-03-14 12:04:23 -04:00
..
2018-03-13 22:47:36 +01:00
2018-01-26 01:18:57 +08:00
2018-01-22 17:41:25 +01:00
2017-10-18 22:20:37 +11:00
2018-03-13 22:47:37 +01:00
2017-08-23 21:38:44 +02:00
2017-10-16 17:16:20 +02:00
2017-10-18 09:15:55 +02:00
2018-01-26 01:18:54 +08:00
2017-10-16 17:16:20 +02:00
2017-11-09 16:56:39 +01:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-02-24 01:50:51 +01:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2018-02-26 19:07:04 +08:00
2018-02-07 09:21:24 +01:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-06-16 17:55:25 -04:00
2018-01-29 20:27:54 -05:00
2018-01-22 17:41:25 +01:00
2018-02-22 13:21:41 +03:00
2017-10-17 11:24:57 -07:00
2017-10-18 22:20:37 +11:00
2017-10-18 22:20:37 +11:00
2017-10-18 22:20:37 +11:00
2017-10-18 22:20:37 +11:00
2017-10-18 22:20:37 +11:00
2017-10-30 23:36:06 +01:00
2017-10-18 22:20:37 +11:00
2017-09-26 09:49:10 +02:00
2018-01-22 17:41:25 +01:00
2018-02-27 19:29:07 +01:00
2017-10-18 22:20:37 +11:00
2017-10-18 22:20:37 +11:00
2017-10-17 11:24:57 -07:00
2017-10-30 23:36:06 +01:00
2017-10-18 22:20:37 +11:00
2018-01-25 11:25:23 +01:00
2017-10-18 22:20:37 +11:00
2017-10-30 23:36:06 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-03-06 07:24:24 -08:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-18 22:20:37 +11:00
2018-02-09 09:32:56 +05:30
2017-10-16 17:16:20 +02:00
2017-12-08 14:32:28 +01:00
2018-02-09 09:32:56 +05:30
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-03-14 15:10:05 +01:00
2017-10-18 22:20:37 +11:00
2017-10-18 22:20:37 +11:00
2017-11-17 15:59:59 -08:00
2018-01-25 11:25:23 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-01-10 20:54:35 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-01-22 17:41:25 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-02-22 21:34:53 +05:30
2017-10-16 17:16:20 +02:00
2017-11-15 19:28:03 +08:00
2018-01-30 14:12:37 -06:00
2018-02-13 09:40:06 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-17 11:24:57 -07:00
2017-10-17 11:24:57 -07:00
2017-10-16 17:16:20 +02:00
2017-10-30 23:36:06 +01:00
2017-10-27 12:53:11 +02:00
2018-01-26 02:11:02 +08:00
2017-10-16 17:16:20 +02:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-02-20 13:50:53 +01:00
2017-10-16 17:16:20 +02:00
2017-10-30 23:36:06 +01:00
2017-10-17 11:24:57 -07:00
2017-10-16 17:16:20 +02:00
2018-02-23 01:55:21 +05:30
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-17 11:24:57 -07:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-02-26 07:38:41 +05:30
2017-10-24 17:02:18 -05:00
2018-02-23 02:37:11 +05:30
2017-10-16 17:16:20 +02:00
2017-12-09 20:26:48 +01:00
2017-10-16 17:16:20 +02:00
2018-02-25 00:02:33 +05:30
2017-10-16 17:16:20 +02:00
2018-01-19 15:06:52 +01:00
2017-11-09 16:56:39 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-10-30 23:36:06 +01:00
2017-10-30 23:36:06 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-01-29 20:27:54 -05:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-11-09 16:56:39 +01:00
2017-10-30 23:36:06 +01:00
2017-10-17 11:24:57 -07:00
2017-10-16 17:16:20 +02:00
2017-11-30 16:18:57 +00:00
2017-10-16 17:16:20 +02:00
2018-02-28 17:07:49 -08:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-17 11:24:57 -07:00
2018-02-23 02:37:11 +05:30
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-01-22 17:41:26 +01:00
2017-10-16 17:16:20 +02:00
2017-10-30 23:36:06 +01:00
2017-10-16 17:16:20 +02:00
2017-11-09 16:56:39 +01:00
2017-10-16 17:16:20 +02:00
2018-01-23 10:41:42 +01:00
2018-01-23 10:41:42 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-09-26 09:49:10 +02:00
2017-10-16 17:16:20 +02:00
2018-02-11 08:02:39 +01:00
2017-10-18 09:15:55 +02:00
2018-02-16 21:52:29 +05:30
2017-10-16 17:16:20 +02:00
2017-11-09 16:56:39 +01:00
2017-10-16 17:16:20 +02:00
2017-08-23 17:16:30 +02:00
2018-02-13 09:12:00 +01:00
2017-10-19 22:01:30 +08:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-12-08 14:32:28 +01:00
2017-10-17 11:24:57 -07:00
2018-01-10 20:54:35 +01:00
2018-01-15 09:42:31 +01:00
2017-10-16 17:16:20 +02:00
2017-09-06 13:33:30 +02:00
2017-09-06 13:33:30 +02:00
2018-01-22 17:41:25 +01:00
2017-10-16 17:16:20 +02:00
2017-12-07 07:26:39 +01:00
2017-12-14 16:48:19 -06:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-09-26 09:49:10 +02:00
2017-10-16 17:16:20 +02:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-01-10 20:54:35 +01:00
2017-10-18 22:20:37 +11:00
2017-12-06 21:11:39 +01:00
2017-10-18 22:20:37 +11:00
2017-11-16 13:36:22 +08:00
2017-10-18 22:20:37 +11:00
2018-01-22 17:41:25 +01:00
2017-10-16 17:16:20 +02:00
2017-11-09 16:56:39 +01:00
2017-10-30 23:36:06 +01:00
2017-10-16 17:16:20 +02:00
2017-10-17 11:24:57 -07:00
2017-10-16 17:16:20 +02:00
2017-10-17 11:24:57 -07:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-05-03 12:57:49 -05:00
2017-05-03 12:57:49 -05:00
2017-10-16 17:16:20 +02:00
2017-11-06 13:00:14 -05:00
2018-03-13 22:47:37 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-03-13 17:38:33 +01:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2018-02-16 11:24:12 +01:00
2017-11-09 16:56:39 +01:00
2018-01-22 17:41:25 +01:00
2017-10-17 11:24:57 -07:00
2017-10-17 11:24:57 -07:00
2017-10-17 11:24:57 -07:00
2017-10-16 17:16:20 +02:00
2017-10-21 15:13:04 -05:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-18 22:20:37 +11:00
2017-10-31 19:08:26 +01:00
2017-03-13 21:57:50 +08:00
2016-11-23 22:46:57 -08:00
2017-10-30 23:36:06 +01:00
2017-11-06 17:08:14 +01:00
2017-10-16 17:16:20 +02:00
2017-10-27 12:53:11 +02:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2018-01-22 17:41:25 +01:00
2017-10-18 22:20:37 +11:00
2018-01-22 17:41:25 +01:00
2018-01-22 17:41:25 +01:00
2018-01-22 17:41:25 +01:00
2018-03-06 15:28:10 +02:00
2017-10-16 17:16:20 +02:00
2017-10-18 22:20:37 +11:00
2017-10-16 17:16:20 +02:00
2017-10-18 22:20:37 +11:00
2017-02-24 01:50:51 +01:00
2018-03-12 14:23:20 +01:00
2017-10-18 22:20:37 +11:00
2018-03-09 23:27:29 +01:00
2018-03-12 14:23:20 +01:00
2017-10-16 17:16:20 +02:00
2018-02-07 09:21:24 +01:00
2017-10-16 17:16:20 +02:00
2018-01-10 20:54:35 +01:00
2018-03-09 23:27:29 +01:00
2018-02-26 07:38:41 +05:30
2018-02-22 21:34:53 +05:30
2017-11-01 20:45:22 +00:00
2017-10-16 17:16:20 +02:00
2017-10-16 17:16:20 +02:00
2017-10-30 23:36:06 +01:00
2017-10-18 22:20:37 +11:00
2018-02-09 09:32:56 +05:30
2018-02-13 09:40:06 +01:00
2017-09-01 11:54:09 +02:00
2017-10-16 17:16:20 +02:00