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

Unified Diff: mojo/public/bindings/pylib/generate/mojom_data.py

Issue 159983003: Fix a bug with mojom imports where 2 imports with the same namespace would (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | « mojo/public/bindings/pylib/generate/mojom.py ('k') | mojo/public/bindings/tests/sample_import.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/pylib/generate/mojom_data.py
diff --git a/mojo/public/bindings/pylib/generate/mojom_data.py b/mojo/public/bindings/pylib/generate/mojom_data.py
index 01847c1b05ed5475c6e965230ffc32a30974f8b2..4972b689447b19796d1cc6a6450cae5169e1c658 100644
--- a/mojo/public/bindings/pylib/generate/mojom_data.py
+++ b/mojo/public/bindings/pylib/generate/mojom_data.py
@@ -54,12 +54,19 @@ def KindFromData(kinds, data):
kinds[data] = kind
return kind
-def ImportFromData(data):
+def ImportFromData(module, data):
import_module = data['module']
import_item = {}
import_item['module_name'] = import_module.name
import_item['namespace'] = import_module.namespace
+
+ # Copy the struct kinds from our imports into the current module.
+ for kind in import_module.kinds.itervalues():
+ # TODO(mpcomplete): Handle enums
+ if isinstance(kind, mojom.Struct) and kind.imported_from is None:
+ kind = mojom.Struct.CreateFromImport(kind, import_item)
+ module.kinds[kind.spec] = kind
return import_item
def StructToData(struct):
@@ -182,25 +189,19 @@ def ModuleFromData(data):
module.kinds = {}
for kind in mojom.PRIMITIVES:
module.kinds[kind.spec] = kind
- # Copy the struct kinds from our imports into the current module.
- for import_data in data['imports']:
- import_module = import_data['module']
- for kind in import_module.kinds.itervalues():
- # TODO(mpcomplete): Handle enums
- if isinstance(kind, mojom.Struct):
- kind = mojom.Struct.CreateFromImport(
- kind, import_module.namespace)
- module.kinds[kind.spec] = kind
module.name = data['name']
module.namespace = data['namespace']
+ # Imports must come first, because they add to module.kinds which is used
+ # by by the others.
module.imports = map(
- lambda import_data: ImportFromData(import_data), data['imports'])
+ lambda import_data: ImportFromData(module, import_data),
+ data['imports'])
module.structs = map(
lambda struct: StructFromData(module, struct), data['structs'])
module.interfaces = map(
- lambda interface:
- InterfaceFromData(module, interface), data['interfaces'])
+ lambda interface: InterfaceFromData(module, interface),
+ data['interfaces'])
if data.has_key('enums'):
module.enums = map(
lambda enum: EnumFromData(module.kinds, enum), data['enums'])
« no previous file with comments | « mojo/public/bindings/pylib/generate/mojom.py ('k') | mojo/public/bindings/tests/sample_import.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698