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

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

Issue 1824263002: Mojom backend: Stop re-computing version info and field packing data. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 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/generate/generator.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/generator.py b/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
index fec88718b52049928b77913129f30529cfccfc6b..1d57528d3582852a19ce12238bfe5b283ed4a015 100644
--- a/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
+++ b/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
@@ -88,15 +88,20 @@ class Generator(object):
def _AddStructComputedData(self, exported, struct):
"""Adds computed data to the given struct. The data is computed once and
used repeatedly in the generation process."""
- struct.packed = pack.PackedStruct(struct)
- struct.bytes = pack.GetByteLayout(struct.packed)
- struct.versions = pack.GetVersionInfo(struct.packed)
+ if not hasattr(struct, 'packed') or struct.packed is None:
+ struct.packed = pack.PackedStruct(struct)
+ struct.bytes = pack.GetByteLayout(struct.packed)
struct.exported = exported
return struct
def _AddInterfaceComputedData(self, interface):
"""Adds computed data to the given interface. The data is computed once and
used repeatedly in the generation process."""
+ # Here we set the interface's |version| attribute to be the maximum value
+ # of the |min_version| attributes of all methods in the interface and all
+ # parameters in those methods.
+ # TODO(rudominer) Consider adding this value to the intermediate
+ # representation.
interface.version = 0
for method in interface.methods:
if method.min_version is not None:
@@ -116,19 +121,9 @@ class Generator(object):
return interface
def _GetStructFromMethod(self, method):
- """Converts a method's parameters into the fields of a struct."""
- params_class = "%s_%s_Params" % (method.interface.name, method.name)
- struct = mojom.Struct(params_class, module=method.interface.module)
- for param in method.parameters:
- struct.AddField(param.name, param.kind, param.ordinal,
- attributes=param.attributes)
- return self._AddStructComputedData(False, struct)
+ """Returns a method's parameters as a struct."""
+ return self._AddStructComputedData(False, method.param_struct)
def _GetResponseStructFromMethod(self, method):
- """Converts a method's response_parameters into the fields of a struct."""
- params_class = "%s_%s_ResponseParams" % (method.interface.name, method.name)
- struct = mojom.Struct(params_class, module=method.interface.module)
- for param in method.response_parameters:
- struct.AddField(param.name, param.kind, param.ordinal,
- attributes=param.attributes)
- return self._AddStructComputedData(False, struct)
+ """Returns a method's response_parameters as a struct."""
+ return self._AddStructComputedData(False, method.response_param_struct)
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_go_generator.py ('k') | mojo/public/tools/bindings/pylib/mojom/generate/module.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698