Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upError in generated binding for variadic argument of type that needs rooting #8159
Comments
|
This is probably because |
|
I would rather make it pass |
|
I guess a |
|
Sounds like making the proper thing ( |
|
Especially because I think the |
|
So I managed to get the code to compile: 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 arg0: _ = if 0 < argc {
let mut vector = RootedVec::new();
*vector = 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;
};
vector.push(JS::from_ref(&*slot));
}
vector
} else {
RootedVec::new()
};
let result: () = this.PassVariadicInterface(arg0.r());
(result).to_jsval(cx, args.rval());
return true;
}But I'm pretty sure this will fail at runtime when the RootedVec is dropped. Will write a test. |
|
Yes, this panics. |
We use a RootedVec value in codegen, of which we use the `r()` method to pass `&[&T]` to the interface methods.
We use a RootedVec value in codegen, of which we use the `r()` method to pass `&[&T]` to the interface methods.
We use a RootedVec value in codegen, of which we use the `r()` method to pass `&[&T]` to the interface methods.
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 -->
The following WebIDL (where
Touchis as defined in #7204):causes this compile error:
The generated trait method signature is:
and the generated binding is: