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

Unified Diff: mojo/public/bindings/parse/mojo_translate.py

Issue 99623010: Add support for enums within structs and interfaces to mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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 | « mojo/public/bindings/parse/mojo_parser.py ('k') | mojo/public/bindings/sample/sample_service.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/parse/mojo_translate.py
diff --git a/mojo/public/bindings/parse/mojo_translate.py b/mojo/public/bindings/parse/mojo_translate.py
index 333653243370bf6b4bb9754a286ecb1d8870b22f..98dc6c0ffa862dca4bbdfeb5b6aacff2b3050ed3 100755
--- a/mojo/public/bindings/parse/mojo_translate.py
+++ b/mojo/public/bindings/parse/mojo_translate.py
@@ -77,6 +77,7 @@ def MapMethods(methods):
'ordinal': MapOrdinal(method[3])})
return out
+
def MapEnumFields(fields):
out = []
for field in fields:
@@ -85,24 +86,36 @@ def MapEnumFields(fields):
'value': field[2]})
return out
+
+def MapEnums(enums):
+ out = []
+ for enum in enums:
+ if enum[0] == 'ENUM':
+ out.append({'name': enum[1],
+ 'fields': MapEnumFields(enum[2])})
+ return out
+
+
class MojomBuilder():
def __init__(self):
self.mojom = {}
- def AddStruct(self, name, attributes, fields):
+ def AddStruct(self, name, attributes, body):
struct = {}
struct['name'] = name
# TODO(darin): Add support for |attributes|
#struct['attributes'] = MapAttributes(attributes)
- struct['fields'] = MapFields(fields)
+ struct['fields'] = MapFields(body)
+ struct['enums'] = MapEnums(body)
self.mojom['structs'].append(struct)
- def AddInterface(self, name, attributes, methods):
+ def AddInterface(self, name, attributes, body):
interface = {}
interface['name'] = name
interface['peer'] = GetAttribute(attributes, 'Peer')
- interface['methods'] = MapMethods(methods)
+ interface['methods'] = MapMethods(body)
+ interface['enums'] = MapEnums(body)
self.mojom['interfaces'].append(interface)
def AddEnum(self, name, fields):
@@ -121,9 +134,9 @@ class MojomBuilder():
self.mojom['enums'] = []
for item in contents:
if item[0] == 'STRUCT':
- self.AddStruct(name=item[1], attributes=item[2], fields=item[3])
+ self.AddStruct(name=item[1], attributes=item[2], body=item[3])
elif item[0] == 'INTERFACE':
- self.AddInterface(name=item[1], attributes=item[2], methods=item[3])
+ self.AddInterface(name=item[1], attributes=item[2], body=item[3])
elif item[0] == 'ENUM':
self.AddEnum(name=item[1], fields=item[2])
« no previous file with comments | « mojo/public/bindings/parse/mojo_parser.py ('k') | mojo/public/bindings/sample/sample_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698