diff options
author | bashi <bashi@chromium.org> | 2015-01-21 06:41:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-21 14:43:14 +0000 |
commit | df59d8f077f7541b54a3b84df22ef026b642e717 (patch) | |
tree | 92ea6192623cf95bf5f649d1edbdd018bc3048bc | |
parent | 8910d20fdabea7c0e44aea273daf2474962ec0fd (diff) | |
download | chromium_src-df59d8f077f7541b54a3b84df22ef026b642e717.zip chromium_src-df59d8f077f7541b54a3b84df22ef026b642e717.tar.gz chromium_src-df59d8f077f7541b54a3b84df22ef026b642e717.tar.bz2 |
IDL: Support empty sequence default value
The spec[1] says that we can use '[]' to specify a default value
which represents an empty sequence value. Note that this CL just
makes idl_parser recognize an empty sequence value. Actual work
should be done by clients (e.g. Blink's code generator).
[1] http://heycam.github.io/webidl/#dfn-optional-argument-default-value
BUG=450385
TEST=tools/idl_parser/run_tests.py
Review URL: https://codereview.chromium.org/865453002
Cr-Commit-Position: refs/heads/master@{#312380}
-rwxr-xr-x | tools/idl_parser/idl_parser.py | 8 | ||||
-rw-r--r-- | tools/idl_parser/test_parser/interface_web.idl | 17 |
2 files changed, 23 insertions, 2 deletions
diff --git a/tools/idl_parser/idl_parser.py b/tools/idl_parser/idl_parser.py index af0bd05..0fa9b61 100755 --- a/tools/idl_parser/idl_parser.py +++ b/tools/idl_parser/idl_parser.py @@ -324,8 +324,12 @@ class IDLParser(object): # [17] def p_DefaultValue(self, p): """DefaultValue : ConstValue - | string""" - if type(p[1]) == str: + | string + | '[' ']'""" + if len(p) == 3: + p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'sequence'), + self.BuildAttribute('VALUE', '[]')) + elif type(p[1]) == str: p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'DOMString'), self.BuildAttribute('NAME', p[1])) else: diff --git a/tools/idl_parser/test_parser/interface_web.idl b/tools/idl_parser/test_parser/interface_web.idl index e42075b..cff2cd0 100644 --- a/tools/idl_parser/test_parser/interface_web.idl +++ b/tools/idl_parser/test_parser/interface_web.idl @@ -75,6 +75,23 @@ interface MyIFaceBig { }; /* TREE + *Interface(MyIfaceEmptySequenceDefalutValue) + * Operation(foo) + * Arguments() + * Argument(arg) + * Type() + * Sequence() + * Type() + * PrimitiveType(DOMString) + * Default() + * Type() + * PrimitiveType(void) + */ +interface MyIfaceEmptySequenceDefalutValue { + void foo(optional sequence<DOMString> arg = []); +}; + +/* TREE *Interface(MyIFaceBig2) * Const(nullValue) * PrimitiveType(DOMString) |