Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: ppapi/generators/idl_parser.py

Issue 9359040: WIP IDL-IPC2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Checkpoint before going back to returning ListValue via ExtensionMsg_Response. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/generators/idl_lexer.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/generators/idl_parser.py
diff --git a/ppapi/generators/idl_parser.py b/ppapi/generators/idl_parser.py
index 45f10210a70a1b220599c67382dd46550900157a..f600cb26d22bc01e229c091b3a108408fea0ec0a 100755
--- a/ppapi/generators/idl_parser.py
+++ b/ppapi/generators/idl_parser.py
@@ -213,23 +213,48 @@ class IDLParser(IDLLexer):
# present. The extended attributes and the top_list become siblings which
# in turn are children of the file object created from the results of top.
def p_top(self, p):
- """top : COMMENT COMMENT ext_attr_block top_list"""
+ """top : COMMENT COMMENT ext_attr_block top_list
+ | namespace"""
+ if len(p) == 2:
+ p[0] = ListFromConcat(p[1])
+ else:
+ copyright_comment = self.BuildComment('Copyright', p, 1)
+ filedoc_comment = self.BuildComment('Comment', p, 2)
+ p[0] = ListFromConcat(copyright_comment, filedoc_comment, p[3], p[4])
+ if self.parse_debug: DumpReduction('top', p)
+
+ def p_namespace(self, p):
+ """namespace : modifiers NAMESPACE namespace_name '{' top_list '}' ';'"""
+ children = ListFromConcat(p[1], p[5])
+ p[0] = self.BuildNamed('Namespace', p, 3, children)
- Copyright = self.BuildComment('Copyright', p, 1)
- Filedoc = self.BuildComment('Comment', p, 2)
+ # We allow namespace names of the form foo.bar.baz.
+ def p_namespace_name(self, p):
+ """namespace_name : SYMBOL
+ | SYMBOL '.' namespace_name"""
+ p[0] = "".join(p[1:])
+
+ def p_dictionary_block(self, p):
+ """dictionary_block : modifiers DICTIONARY SYMBOL '{' struct_list '}' ';'"""
+ p[0] = self.BuildNamed('Dictionary', p, 3, ListFromConcat(p[5]))
- p[0] = ListFromConcat(Copyright, Filedoc, p[3], p[4])
- if self.parse_debug: DumpReduction('top', p)
+
+ def p_callback_decl(self, p):
+ """callback_decl : modifiers CALLBACK SYMBOL '=' SYMBOL param_list ';'"""
+ children = ListFromConcat(p[1], p[6])
+ p[0] = self.BuildNamed('Callback', p, 3, children)
# Build a list of top level items.
def p_top_list(self, p):
- """top_list : describe_block top_list
+ """top_list : dictionary_block top_list
+ | describe_block top_list
| enum_block top_list
| inline top_list
| interface_block top_list
| label_block top_list
| struct_block top_list
| typedef_decl top_list
+ | callback_decl top_list
| """
if len(p) > 2:
p[0] = ListFromConcat(p[1], p[2])
@@ -499,12 +524,19 @@ class IDLParser(IDLLexer):
if self.parse_debug: DumpReduction('param_list', p)
def p_param_item(self, p):
- """param_item : modifiers SYMBOL arrays SYMBOL"""
- typeref = self.BuildAttribute('TYPEREF', p[2])
- children = ListFromConcat(p[1],typeref, p[3])
- p[0] = self.BuildNamed('Param', p, 4, children)
+ """param_item : modifiers optional SYMBOL arrays SYMBOL"""
+ typeref = self.BuildAttribute('TYPEREF', p[3])
+ children = ListFromConcat(p[1],p[2], typeref, p[4])
+ p[0] = self.BuildNamed('Param', p, 5, children)
if self.parse_debug: DumpReduction('param_item', p)
+ def p_optional(self, p):
+ """optional : OPTIONAL
+ | """
+ if len(p) == 2:
+ p[0] = self.BuildAttribute('OPTIONAL', True)
+
+
def p_param_cont(self, p):
"""param_cont : ',' param_item param_cont
| """
@@ -520,7 +552,7 @@ class IDLParser(IDLLexer):
#
# Typedef
#
-# A typedef creates a new referencable type. The tyepdef can specify an array
+# A typedef creates a new referencable type. The typedef can specify an array
# definition as well as a function declaration.
#
def p_typedef_data(self, p):
@@ -615,26 +647,31 @@ class IDLParser(IDLLexer):
# A member attribute or function of a struct or interface.
#
def p_member_attribute(self, p):
- """member_attribute : modifiers SYMBOL SYMBOL """
+ """member_attribute : modifiers SYMBOL arrays questionmark SYMBOL"""
typeref = self.BuildAttribute('TYPEREF', p[2])
- children = ListFromConcat(p[1], typeref)
- p[0] = self.BuildNamed('Member', p, 3, children)
- if self.parse_debug: DumpReduction('attribute', p)
-
- def p_member_attribute_array(self, p):
- """member_attribute : modifiers SYMBOL arrays SYMBOL """
- typeref = self.BuildAttribute('TYPEREF', p[2])
- children = ListFromConcat(p[1], typeref, p[3])
- p[0] = self.BuildNamed('Member', p, 4, children)
+ children = ListFromConcat(p[1], typeref, p[3], p[4])
+ p[0] = self.BuildNamed('Member', p, 5, children)
if self.parse_debug: DumpReduction('attribute', p)
def p_member_function(self, p):
- """member_function : modifiers SYMBOL SYMBOL param_list"""
- typeref = self.BuildAttribute('TYPEREF', p[2])
- children = ListFromConcat(p[1], typeref, p[4])
- p[0] = self.BuildNamed('Member', p, 3, children)
+ """member_function : modifiers static SYMBOL SYMBOL param_list"""
+ typeref = self.BuildAttribute('TYPEREF', p[3])
+ children = ListFromConcat(p[1], p[2], typeref, p[5])
+ p[0] = self.BuildNamed('Member', p, 4, children)
if self.parse_debug: DumpReduction('function', p)
+ def p_static(self, p):
+ """static : STATIC
+ | """
+ if len(p) == 2:
+ p[0] = self.BuildAttribute('STATIC', True)
+
+ def p_questionmark(self, p):
+ """questionmark : '?'
+ | """
+ if len(p) == 2:
+ p[0] = self.BuildAttribute('OPTIONAL', True)
+
#
# Interface
#
« no previous file with comments | « ppapi/generators/idl_lexer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698