Repository navigation
Add WebIDL sequence return values - #8412
Conversation
|
r? @jdm |
There was a problem hiding this comment.
Not 100% sure about if this is correct, I tested it and it worked though.
|
-S-awaiting-review +S-needs-code-changes Reviewed 2 of 2 files at r1, 2 of 2 files at r2, 4 of 4 files at r3. components/script/dom/bindings/conversions.rs, line 817 [r1] (raw file): let mut js_objects = RootedVec::new();
for obj in &self {
let mut val = RootedValue::new(cx, UndefinedValue());
obj.to_jsval(cx, val.handle_mut());
js_objects.push(val.handle().get());
}This will ensure that each converted value is stored in a rooted vector, so subsequent conversions will not risk GCing them. components/script/dom/bindings/conversions.rs, line 827 [r1] (raw file): components/script/dom/bindings/conversions.rs, line 814 [r3] (raw file): Comments from the review on Reviewable.io |
|
Review status: all files reviewed at latest revision, 3 unresolved discussions. components/script/dom/bindings/conversions.rs, line 817 [r1] (raw file): let js_objects: Vec<RootedValue> = self.iter().map(|obj| {
let mut val = RootedValue::new(cx, UndefinedValue());
obj.to_jsval(cx, val.handle_mut());
val
}).collect();
let values: Vec<JSVal> = js_objects.iter()
.map(|obj| obj.handle().get())
.collect(); I think this is correct (even though I'm not too happy with the double vector, but I guess we should keep the components/script/dom/bindings/conversions.rs, line 814 [r3] (raw file): Comments from the review on Reviewable.io |
|
Review status: 6 of 7 files reviewed at latest revision, 3 unresolved discussions. components/script/dom/bindings/conversions.rs, line 817 [r1] (raw file): components/script/dom/bindings/conversions.rs, line 827 [r1] (raw file): Comments from the review on Reviewable.io |
52e8021 to
b19267a
Compare
|
Review status: 6 of 7 files reviewed at latest revision, 3 unresolved discussions. components/script/dom/bindings/conversions.rs, line 817 [r1] (raw file): May yo review it to see if there might be any issue with GC, or if this can be done in a more performant way? :) TL;DR; here is the relevant code: let mut js_objects = RootedVec::new();
for obj in self.iter() {
let mut heap = Heap::default();
let mut val = RootedValue::new(cx, UndefinedValue());
obj.to_jsval(cx, val.handle_mut());
heap.set(val.handle().get());
js_objects.push(heap);
}
let values: Vec<JSVal> = js_objects.iter()
.map(|heap| heap.handle().get())
.collect();Comments from the review on Reviewable.io |
|
I wonder if we should have a |
|
-S-awaiting-review +S-needs-code-changes +S-awaiting-answer Reviewed 1 of 1 files at r4. components/script/dom/bindings/conversions.rs, line 820 [r4] (raw file): let mut val = RootedValue::new(cx, UndefinedValue());
obj.to_jsval(cx, val.handle_mut());
js_objects.push(Heap::default());
js_objects.iter_mut().last().unwrap().set(val.handle().get());components/script/dom/bindings/conversions.rs, line 825 [r4] (raw file): components/script/dom/bindings/conversions.rs, line 836 [r4] (raw file): Comments from the review on Reviewable.io |
|
☔ The latest upstream changes (presumably #8197) made this pull request unmergeable. Please resolve the merge conflicts. |
b19267a to
105f2e9
Compare
105f2e9 to
1f00c14
Compare
|
Review status: 4 of 7 files reviewed at latest revision, 3 unresolved discussions. components/script/dom/bindings/conversions.rs, line 820 [r4] (raw file): This also solves the double vector issue, and the components/script/dom/bindings/conversions.rs, line 825 [r4] (raw file): components/script/dom/bindings/conversions.rs, line 836 [r4] (raw file): Comments from the review on Reviewable.io |
1f00c14 to
71fdb60
Compare
|
Great; only nits remaining! Reviewed 3 of 3 files at r5. components/script/dom/bindings/conversions.rs, line 820 [r4] (raw file): components/script/dom/bindings/conversions.rs, line 43 [r5] (raw file): components/script/dom/bindings/conversions.rs, line 820 [r5] (raw file): components/script/dom/bindings/conversions.rs, line 822 [r5] (raw file): Comments from the review on Reviewable.io |
|
Reviewed 1 of 1 files at r6. Comments from the review on Reviewable.io |
This commits changes the creation of the array to use the length, and sets the elements later. Reference implementation: https://github.com/mozilla/gecko-dev/blob/07ed19e582faf40f5f72567169db62452f6c6dc9/js/xpconnect/public/nsTArrayHelpers.h#L16
71fdb60 to
e33330d
Compare
|
Review status: 6 of 7 files reviewed at latest revision, 2 unresolved discussions. components/script/dom/bindings/conversions.rs, line 820 [r5] (raw file): components/script/dom/bindings/conversions.rs, line 822 [r5] (raw file): Comments from the review on Reviewable.io |
|
@bors-servo: r+ Reviewed 1 of 1 files at r7. Comments from the review on Reviewable.io |
|
📌 Commit e33330d has been approved by |
Add WebIDL sequence return values And use it for `WebGLRenderingContext::getSupportedExtensions`. Part of #544 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8412) <!-- Reviewable:end -->
|
💔 Test failed - linux-rel |
|
⚡ Previous build results for android, gonk, linux-dev, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt are reusable. Rebuilding only linux-rel... |
|
☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt |
And use it for
WebGLRenderingContext::getSupportedExtensions.Part of #544