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

Unified Diff: tools/idl_parser/idl_parser.py

Issue 1031593003: IDL: Add support for serializer definitions (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years, 9 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 | « no previous file | tools/idl_parser/test_parser/interface_web.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/idl_parser/idl_parser.py
diff --git a/tools/idl_parser/idl_parser.py b/tools/idl_parser/idl_parser.py
index bdd6dc74cd6da14fbc69da4d80ba1a96d52a4831..27b19142908eadacdc5b6e2198c1394a389b2a31 100755
--- a/tools/idl_parser/idl_parser.py
+++ b/tools/idl_parser/idl_parser.py
@@ -273,6 +273,7 @@ class IDLParser(object):
def p_InterfaceMember(self, p):
"""InterfaceMember : Const
| Operation
+ | Serializer
| Stringifier
| StaticMember
| Iterable
@@ -467,7 +468,74 @@ class IDLParser(object):
p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'float'),
self.BuildAttribute('VALUE', val))
- # [30-34] NOT IMPLEMENTED (Serializer)
+ # [30]
+ def p_Serializer(self, p):
+ """Serializer : SERIALIZER SerializerRest"""
+ p[0] = self.BuildProduction('Serializer', p, 1, p[2])
+
+ # [31]
+ # TODO(jl): This adds ReturnType and ';', missing from the spec's grammar.
+ # https://www.w3.org/Bugs/Public/show_bug.cgi?id=20361
+ def p_SerializerRest(self, p):
+ """SerializerRest : ReturnType OperationRest
+ | '=' SerializationPattern ';'
+ | ';'"""
+ if len(p) == 3:
+ p[2].AddChildren(p[1])
+ p[0] = p[2]
+ elif len(p) == 4:
+ p[0] = p[2]
+
+ # [32]
+ def p_SerializationPattern(self, p):
+ """SerializationPattern : '{' SerializationPatternMap '}'
+ | '[' SerializationPatternList ']'
+ | identifier"""
+ if len(p) > 2:
+ p[0] = p[2]
+ else:
+ p[0] = self.BuildAttribute('ATTRIBUTE', p[1])
+
+ # [33]
+ # TODO(jl): This adds the "ATTRIBUTE" and "INHERIT ',' ATTRIBUTE" variants,
+ # missing from the spec's grammar.
+ # https://www.w3.org/Bugs/Public/show_bug.cgi?id=20361
+ def p_SerializationPatternMap(self, p):
+ """SerializationPatternMap : GETTER
+ | ATTRIBUTE
+ | INHERIT ',' ATTRIBUTE
+ | INHERIT Identifiers
+ | identifier Identifiers
+ |"""
+ p[0] = self.BuildProduction('Map', p, 0)
+ if len(p) == 4:
+ p[0].AddChildren(self.BuildTrue('INHERIT'))
+ p[0].AddChildren(self.BuildTrue('ATTRIBUTE'))
+ elif len(p) > 1:
+ if p[1] == 'getter':
+ p[0].AddChildren(self.BuildTrue('GETTER'))
+ elif p[1] == 'attribute':
+ p[0].AddChildren(self.BuildTrue('ATTRIBUTE'))
+ else:
+ if p[1] == 'inherit':
+ p[0].AddChildren(self.BuildTrue('INHERIT'))
+ attributes = p[2]
+ else:
+ attributes = ListFromConcat(p[1], p[2])
+ p[0].AddChildren(self.BuildAttribute('ATTRIBUTES', attributes))
+
+ # [34]
+ def p_SerializationPatternList(self, p):
+ """SerializationPatternList : GETTER
+ | identifier Identifiers
+ |"""
+ p[0] = self.BuildProduction('List', p, 0)
+ if len(p) > 1:
+ if p[1] == 'getter':
+ p[0].AddChildren(self.BuildTrue('GETTER'))
+ else:
+ attributes = ListFromConcat(p[1], p[2])
+ p[0].AddChildren(self.BuildAttribute('ATTRIBUTES', attributes))
# [35]
def p_Stringifier(self, p):
« no previous file with comments | « no previous file | tools/idl_parser/test_parser/interface_web.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698