diff options
author | benwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 10:31:40 +0000 |
---|---|---|
committer | benwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 10:31:40 +0000 |
commit | 1d678d0b08b8e89a69804c14a94449cae49398bd (patch) | |
tree | 45586e3cdc4057412ea298ba23c4772cfa9fbb9b /ppapi | |
parent | d95a190627401e8c3338b8e938c2408dd20bc4d2 (diff) | |
download | chromium_src-1d678d0b08b8e89a69804c14a94449cae49398bd.zip chromium_src-1d678d0b08b8e89a69804c14a94449cae49398bd.tar.gz chromium_src-1d678d0b08b8e89a69804c14a94449cae49398bd.tar.bz2 |
Support unions in extensions IDl dictionaries.
This change adds support for unions in extensions IDL dictionaries, such
as the following:
dictionary foo {
(long or DOMString) bar;
};
Unions are also supported in callback and function parameters.
NOTRY=true
BUG=339558
Review URL: https://codereview.chromium.org/181143002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256792 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rwxr-xr-x | ppapi/generators/idl_lexer.py | 3 | ||||
-rwxr-xr-x | ppapi/generators/idl_parser.py | 41 |
2 files changed, 41 insertions, 3 deletions
diff --git a/ppapi/generators/idl_lexer.py b/ppapi/generators/idl_lexer.py index 4120ac7..47d64a2 100755 --- a/ppapi/generators/idl_lexer.py +++ b/ppapi/generators/idl_lexer.py @@ -54,6 +54,7 @@ class IDLLexer(object): 'INTERFACE', 'STRUCT', 'TYPEDEF', + 'OR', # Extra WebIDL keywords 'CALLBACK', @@ -92,6 +93,8 @@ class IDLLexer(object): 'optional' : 'OPTIONAL', 'static' : 'STATIC', 'namespace' : 'NAMESPACE', + + 'or' : 'OR', } # 'literals' is a value expected by lex which specifies a list of valid diff --git a/ppapi/generators/idl_parser.py b/ppapi/generators/idl_parser.py index df33070..73b15ca 100755 --- a/ppapi/generators/idl_parser.py +++ b/ppapi/generators/idl_parser.py @@ -534,17 +534,17 @@ class IDLParser(IDLLexer): if self.parse_debug: DumpReduction('expression_unop', p) def p_expression_term(self, p): - "expression : '(' expression ')'" + """expression : '(' expression ')'""" p[0] = "%s%s%s" % (str(p[1]), str(p[2]), str(p[3])) if self.parse_debug: DumpReduction('expression_term', p) def p_expression_symbol(self, p): - "expression : SYMBOL" + """expression : SYMBOL""" p[0] = p[1] if self.parse_debug: DumpReduction('expression_symbol', p) def p_expression_integer(self, p): - "expression : integer" + """expression : integer""" p[0] = p[1] if self.parse_debug: DumpReduction('expression_integer', p) @@ -583,6 +583,27 @@ class IDLParser(IDLLexer): # them. p.set_lineno(0, p.lineno(1)) + +# +# Union +# +# A union allows multiple choices of types for a parameter or member. +# + + def p_union_option(self, p): + """union_option : modifiers SYMBOL arrays""" + typeref = self.BuildAttribute('TYPEREF', p[2]) + children = ListFromConcat(p[1], typeref, p[3]) + p[0] = self.BuildProduction('Option', p, 2, children) + + def p_union_list(self, p): + """union_list : union_option OR union_list + | union_option""" + if len(p) > 2: + p[0] = ListFromConcat(p[1], p[3]) + else: + p[0] = p[1] + # # Parameter List # @@ -606,6 +627,13 @@ class IDLParser(IDLLexer): p[0] = self.BuildNamed('Param', p, 5, children) if self.parse_debug: DumpReduction('param_item', p) + def p_param_item_union(self, p): + """param_item : modifiers optional '(' union_list ')' identifier""" + union = self.BuildAttribute('Union', True) + children = ListFromConcat(p[1], p[2], p[4], union) + p[0] = self.BuildNamed('Param', p, 6, children) + if self.parse_debug: DumpReduction('param_item', p) + def p_optional(self, p): """optional : OPTIONAL | """ @@ -738,6 +766,13 @@ class IDLParser(IDLLexer): p[0] = self.BuildNamed('Member', p, 5, children) if self.parse_debug: DumpReduction('attribute', p) + def p_member_attribute_union(self, p): + """member_attribute : modifiers '(' union_list ')' questionmark identifier""" + union = self.BuildAttribute('Union', True) + children = ListFromConcat(p[1], p[3], p[5], union) + p[0] = self.BuildNamed('Member', p, 6, children) + if self.parse_debug: DumpReduction('attribute', p) + def p_member_function(self, p): """member_function : modifiers static SYMBOL arrays SYMBOL param_list""" typeref = self.BuildAttribute('TYPEREF', p[3]) |