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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/parse/translate.py

Issue 376023002: Mojo: Mojom parser: Make |module| use an |identifier_wrapped|. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 5 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
Index: mojo/public/tools/bindings/pylib/mojom/parse/translate.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
index acc9433ed0e1a59b8bcf98899151c87f70c44d3f..e65015e454e523fe80c95f338e3e0c91bd9639e6 100644
--- a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
@@ -120,17 +120,6 @@ def _MapConstant(tree):
constant['value'] = tree[3]
return constant
-def _MapModule(tree, name):
- mojom = {}
- mojom['name'] = name
- mojom['namespace'] = tree[1]
- mojom['attributes'] = _AttributeListToDict(tree[2])
- mojom['structs'] = _MapTree(_MapStruct, tree[3], 'STRUCT')
- mojom['interfaces'] = _MapTree(_MapInterface, tree[3], 'INTERFACE')
- mojom['enums'] = _MapTree(_MapEnum, tree[3], 'ENUM')
- mojom['constants'] = _MapTree(_MapConstant, tree[3], 'CONST')
- return mojom
-
def _MapImport(tree):
import_item = {}
import_item['filename'] = tree[1]
@@ -142,7 +131,19 @@ class _MojomBuilder(object):
self.mojom = {}
def Build(self, tree, name):
- modules = [_MapModule(item, name) for item in tree if item[0] == 'MODULE']
+ def MapModule(tree, name):
+ assert tree[1] is None or tree[1][0] == 'IDENTIFIER'
+ mojom = {}
+ mojom['name'] = name
+ mojom['namespace'] = '' if not tree[1] else tree[1][1]
+ mojom['attributes'] = _AttributeListToDict(tree[2])
+ mojom['structs'] = _MapTree(_MapStruct, tree[3], 'STRUCT')
+ mojom['interfaces'] = _MapTree(_MapInterface, tree[3], 'INTERFACE')
+ mojom['enums'] = _MapTree(_MapEnum, tree[3], 'ENUM')
+ mojom['constants'] = _MapTree(_MapConstant, tree[3], 'CONST')
+ return mojom
+
+ modules = [MapModule(item, name) for item in tree if item[0] == 'MODULE']
if len(modules) != 1:
raise Exception('A mojom file must contain exactly 1 module.')
self.mojom = modules[0]

Powered by Google App Engine
This is Rietveld 408576698