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

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

Issue 2864753002: Mojo code generator: simplify how imported types and values are handled. (Closed)
Patch Set: . Created 3 years, 7 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/tools/bindings/pylib/mojom/generate/module.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/pylib/mojom/generate/translate.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/translate.py b/mojo/public/tools/bindings/pylib/mojom/generate/translate.py
index ffad7447a93b485a95a82cf7c63498013e7edefc..bd5f3267d7016747a2cb164ef0ca60f13675bf20 100644
--- a/mojo/public/tools/bindings/pylib/mojom/generate/translate.py
+++ b/mojo/public/tools/bindings/pylib/mojom/generate/translate.py
@@ -222,41 +222,19 @@ def _Kind(kinds, spec, scope):
kinds[spec] = kind
return kind
-def _KindFromImport(original_kind, imported_from):
- """Used with 'import module' - clones the kind imported from the given
- module's namespace. Only used with Structs, Unions, Interfaces and Enums."""
- kind = copy.copy(original_kind)
- # |shared_definition| is used to store various properties (see
- # |AddSharedProperty()| in module.py), including |imported_from|. We don't
- # want the copy to share these with the original, so copy it if necessary.
- if hasattr(original_kind, 'shared_definition'):
- kind.shared_definition = copy.copy(original_kind.shared_definition)
- kind.imported_from = imported_from
- return kind
-
def _Import(module, import_module):
- import_item = {}
- import_item['module_name'] = import_module.name
- import_item['namespace'] = import_module.namespace
- import_item['module'] = import_module
-
# Copy the struct kinds from our imports into the current module.
importable_kinds = (mojom.Struct, mojom.Union, mojom.Enum, mojom.Interface)
for kind in import_module.kinds.itervalues():
if (isinstance(kind, importable_kinds) and
- kind.imported_from is None):
- kind = _KindFromImport(kind, import_item)
+ kind.module.path == import_module.path):
module.kinds[kind.spec] = kind
# Ditto for values.
for value in import_module.values.itervalues():
- if value.imported_from is None:
- # Values don't have shared definitions (since they're not nullable), so no
- # need to do anything special.
- value = copy.copy(value)
- value.imported_from = import_item
+ if value.module.path == import_module.path:
module.values[value.GetSpec()] = value
- return import_item
+ return import_module
def _Struct(module, parsed_struct):
"""
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/generate/module.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698