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

Support variadic interface arguments (fixes #8159) #8197

Merged
merged 5 commits into from Nov 11, 2015

Conversation

@nox
Copy link
Member

nox commented Oct 25, 2015

Review on Reviewable

@highfive
Copy link

highfive commented Oct 25, 2015

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
@nox
Copy link
Member Author

nox commented Oct 25, 2015

unsafe extern fn passVariadicInterface(cx: *mut JSContext, _obj: HandleObject, this: *const TestBinding, args: *const JSJitMethodCallArgs) -> bool {
    let this = &*this;
    let args = &*args;
    let argc = args._base.argc_;
    let mut arg0 = RootedVec::new();
    *arg0 = Vec::with_capacity((argc - 0) as usize);
    for variadicArg in 0..argc {
        let slot: *const Blob = if args.get(variadicArg).get().is_object() {
            match native_from_handlevalue(args.get(variadicArg)) {
                Ok(val) => val,
                Err(()) => {
                    throw_type_error(cx, "value does not implement interface Blob.");
                    return false;
                }
            }
        } else {
            throw_type_error(cx, "Value is not an object.");
            return false;
        };
        arg0.push(JS::from_ref(&*slot));
    }
    let result: () = this.PassVariadicInterface(arg0.r());

    (result).to_jsval(cx, args.rval());
    return true;
}
@nox nox force-pushed the nox:variadic-interface-argument branch from 502d542 to 88bf688 Oct 25, 2015
@nox
Copy link
Member Author

nox commented Oct 25, 2015

@Ms2ger
Copy link
Contributor

Ms2ger commented Oct 26, 2015

Not sure I'm a big fan of the branching

@nox
Copy link
Member Author

nox commented Oct 26, 2015

I have no idea what your remark is about, @Ms2ger.

@jdm
Copy link
Member

jdm commented Oct 27, 2015

@bors-servo: r+
This looks ok to me and is necessary for #8225. I'll double back and do a thorough post-merge review.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 27, 2015

📌 Commit 88bf688 has been approved by jdm

@jdm
Copy link
Member

jdm commented Oct 27, 2015

@bors-servo: r-
The pressure's off. I'll review this properly.

@jdm jdm self-assigned this Oct 27, 2015
@bors-servo
Copy link
Contributor

bors-servo commented Oct 28, 2015

The latest upstream changes (presumably #8241) made this pull request unmergeable. Please resolve the merge conflicts.

@jdm
Copy link
Member

jdm commented Nov 11, 2015

Generally looks good! I'd just like to make sure that we're thinking through the changes to the types carefully.
-S-awaiting-review +S-needs-code-changes


Reviewed 10 of 10 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, 7 of 7 files at r5.
Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


components/script/dom/bindings/codegen/CodegenRust.py, line 761 [r4] (raw file):
memberType appears to be unused now. We should remove it if that's the case.


components/script/dom/bindings/codegen/CodegenRust.py, line 1209 [r4] (raw file):
We lost this check; is that a problem? For example, could that end up causing underflow in the earlier subtraction?


components/script/dom/bindings/codegen/CodegenRust.py, line 108 [r5] (raw file):
"Returns a string of the Rust expression..."


components/script/dom/bindings/codegen/CodegenRust.py, line 764 [r5] (raw file):
I guess this else block is why we continue rooting members of dictionaries after this change. I'm concerned that this is both non-obvious and confusing.


components/script/dom/bindings/codegen/Configuration.py, line 166 [r5] (raw file):
I'm slightly concerned that this could make us no longer root dictionary members or something? What's the effect of modifying this and the next line?


components/script/dom/bindings/conversions.rs, line 756 [r5] (raw file):
Let's not make this public if it doesn't need to be. The fewer things expose unsafe pointers the better.


Comments from the review on Reviewable.io

nox added 4 commits Oct 25, 2015
Functions returning `Root<T>` are prefixed by "root_" and the ones returning
`*const T` by "native_".

Functions taking `*mut JSObject` are now suffixed by "_from_object" and the ones
taking `&T` by "_from_reflector".
Use global_root_from_reflector() instead.
@nox nox force-pushed the nox:variadic-interface-argument branch from 88bf688 to c765924 Nov 11, 2015
@nox
Copy link
Member Author

nox commented Nov 11, 2015

-S-needs-rebase +S-awaiting-answer


Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


components/script/dom/bindings/codegen/CodegenRust.py, line 761 [r4] (raw file):
Done.


components/script/dom/bindings/codegen/CodegenRust.py, line 1209 [r4] (raw file):
The number of arguments can never be less than the offset where variadic arguments start, when that code is executed. No underflow can thus happen.


components/script/dom/bindings/codegen/CodegenRust.py, line 108 [r5] (raw file):
Done.


components/script/dom/bindings/codegen/CodegenRust.py, line 764 [r5] (raw file):
So what do you want me to do?


components/script/dom/bindings/codegen/Configuration.py, line 166 [r5] (raw file):
None apart from letting me distinguish variadic interface arguments from variadic union arguments, etc. Dictionary members stay rooted AFAIK. What codegen result do you want me to paste to convince you?


components/script/dom/bindings/conversions.rs, line 756 [r5] (raw file):
Done.


Comments from the review on Reviewable.io

@jdm
Copy link
Member

jdm commented Nov 11, 2015

-S-awaiting-review -S-awaiting-answer +S-needs-code-changes


Reviewed 14 of 14 files at r6.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


components/script/dom/bindings/codegen/CodegenRust.py, line 764 [r5] (raw file):
I think my confusion stems from two parts:

  • there's no block that explicitly deals with isMember != "Variadic"
  • we rely on returnType being Root for things that are not conceptually return types
    I would be happy with an elif for the first point that uses returnType but has a comment explaining our reasoning.

Comments from the review on Reviewable.io

We use a RootedVec value in codegen, of which we use the `r()` method to
pass `&[&T]` to the interface methods.
@nox nox force-pushed the nox:variadic-interface-argument branch from c765924 to acb13dc Nov 11, 2015
@jdm
Copy link
Member

jdm commented Nov 11, 2015

@bors-servo: r+


Reviewed 1 of 1 files at r7.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from the review on Reviewable.io

@bors-servo
Copy link
Contributor

bors-servo commented Nov 11, 2015

📌 Commit acb13dc has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 11, 2015

Testing commit acb13dc with merge f03a826...

bors-servo added a commit that referenced this pull request Nov 11, 2015
Support variadic interface arguments (fixes #8159)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8197)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 11, 2015

@bors-servo bors-servo merged commit acb13dc into servo:master Nov 11, 2015
2 of 3 checks passed
2 of 3 checks passed
code-review/reviewable Review in progress: all files reviewed, 1 unresolved discussion
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
nox added a commit to nox/servo that referenced this pull request Nov 12, 2015
bors-servo added a commit that referenced this pull request Nov 12, 2015
Properly handle variadic arguments preceded by default values

I broke that in #8197.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8498)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Nov 12, 2015
Properly handle variadic arguments preceded by default values

I broke that in #8197.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8498)
<!-- Reviewable:end -->
@nox nox deleted the nox:variadic-interface-argument branch Nov 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.