Variadic constructor generated from IDL doesn't allow no arguments. |
|||
Issue description
When I have an IDL like:
[Constructor(double... args)]
interface FooBar { };
the generated bindings seems to forbid passing no arguments into the constructor:
if (UNLIKELY(info.Length() < 1)) {
exceptionState.ThrowTypeError(...);
return;
}
My understanding is that we should be able to construct FooBar with no arguments. Is there something I'm missing?
Spec: https://www.w3.org/TR/WebIDL-1/#dfn-variadic
,
Oct 23 2017
By the way, is this present in some spec you're trying to implement (i.e. is it blocking your work or is it something it'd be good to implement at some point)?
,
Oct 23 2017
Hi, yes it's required for a spec I'm currently implementing [1]. Specifically, we're required to throw a SyntaxError on empty arguments [2], but the generated code throws a TypeError. [1] https://drafts.css-houdini.org/css-typed-om-1/#complex-numeric [2] https://drafts.css-houdini.org/css-typed-om-1/#dom-cssmathsum-cssmathsum
,
Oct 24 2017
peria@, would you mind if I take this over? I've got a CL that should be up for review soon.
,
Oct 24 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/05c6a56ccb00db1504d23d91728edc77037dee47 commit 05c6a56ccb00db1504d23d91728edc77037dee47 Author: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Date: Tue Oct 24 13:04:59 2017 bindings: Do not require variadic arguments to be passed to constructors When an IDL interface had a single constructor (i.e. we are not dealing with overloads) and it had a variadic argument, we were wrongly throwing a TypeError if it was not passed. Per https://heycam.github.io/webidl/#idl-operations: "The final argument of a variadic operation is also considered to be an optional argument. Declaring an argument to be optional indicates that the argument value can be omitted when the operation is invoked." Do what we already do for regular methods and discard variadic arguments along with explicitly optional ones when counting the number of required arguments a constructor has. Bug: 776278 Change-Id: Iba039b8d394297247348f0cb4730da1749986ae5 Reviewed-on: https://chromium-review.googlesource.com/735143 Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Yuki Shiino <yukishiino@chromium.org> Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com> Cr-Commit-Position: refs/heads/master@{#511124} [modify] https://crrev.com/05c6a56ccb00db1504d23d91728edc77037dee47/third_party/WebKit/Source/bindings/scripts/v8_interface.py [add] https://crrev.com/05c6a56ccb00db1504d23d91728edc77037dee47/third_party/WebKit/Source/bindings/tests/idls/core/TestVariadicConstructorArguments.idl [add] https://crrev.com/05c6a56ccb00db1504d23d91728edc77037dee47/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.cpp [add] https://crrev.com/05c6a56ccb00db1504d23d91728edc77037dee47/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.h
,
Oct 24 2017
This should be fixed now, do let us know if there are any bugs left preventing you from implementing the spec.
,
Oct 24 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e6d900fb6ed08dbd3a048899f38962ee75f4d8d0 commit e6d900fb6ed08dbd3a048899f38962ee75f4d8d0 Author: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Date: Tue Oct 24 13:45:53 2017 bindings: Format TestVariadicConstructorArguments.idl Put the "Constructor" bit in a separate line to follow what we normally do in other IDL files. TBR=peria@chromium.org Bug: 776278 Change-Id: I140f95c6ca693b5ab1cbc5cca45ef7d05684e857 No-Try: True Reviewed-on: https://chromium-review.googlesource.com/735720 Reviewed-by: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com> Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com> Cr-Commit-Position: refs/heads/master@{#511134} [modify] https://crrev.com/e6d900fb6ed08dbd3a048899f38962ee75f4d8d0/third_party/WebKit/Source/bindings/tests/idls/core/TestVariadicConstructorArguments.idl
,
Oct 26 2017
Thank you for getting to this quickly! |
|||
►
Sign in to add a comment |
|||
Comment 1 by peria@chromium.org
, Oct 20 2017Status: Available (was: Untriaged)