Commit d8988a18 authored by Viet-Trung Luu's avatar Viet-Trung Luu

Mojo: Make the mojom bindings generator not exponential in the import depth.

We don't need to do deep copies -- shallow copies will do. However, for
structs and such, we need to carefully work around the shared_definition
nonsense.

R=jamesr@chromium.org
BUG=406156

Review URL: https://codereview.chromium.org/535333002

Cr-Commit-Position: refs/heads/master@{#293352}
parent 87fdd0ac
......@@ -134,7 +134,12 @@ def KindFromData(kinds, data, scope):
def KindFromImport(original_kind, imported_from):
"""Used with 'import module' - clones the kind imported from the given
module's namespace. Only used with Structs, Interfaces and Enums."""
kind = copy.deepcopy(original_kind)
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
......@@ -155,7 +160,9 @@ def ImportFromData(module, data):
# Ditto for values.
for value in import_module.values.itervalues():
if value.imported_from is None:
value = copy.deepcopy(value)
# 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
module.values[value.GetSpec()] = value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment