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

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

Issue 1847683004: Mojom compiler backend: Stop re-computing interface version numbers and consume method declaration o (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebasing. Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Code shared by the various language-specific code generators.""" 5 """Code shared by the various language-specific code generators."""
6 6
7 from functools import partial 7 from functools import partial
8 from itertools import chain 8 from itertools import chain
9 import os.path 9 import os.path
10 import re 10 import re
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 used repeatedly in the generation process.""" 162 used repeatedly in the generation process."""
163 if not hasattr(struct, 'packed') or struct.packed is None: 163 if not hasattr(struct, 'packed') or struct.packed is None:
164 struct.packed = pack.PackedStruct(struct) 164 struct.packed = pack.PackedStruct(struct)
165 struct.bytes = pack.GetByteLayout(struct.packed) 165 struct.bytes = pack.GetByteLayout(struct.packed)
166 struct.exported = exported 166 struct.exported = exported
167 return struct 167 return struct
168 168
169 def _AddInterfaceComputedData(self, interface): 169 def _AddInterfaceComputedData(self, interface):
170 """Adds computed data to the given interface. The data is computed once and 170 """Adds computed data to the given interface. The data is computed once and
171 used repeatedly in the generation process.""" 171 used repeatedly in the generation process."""
172 # Here we set the interface's |version| attribute to be the maximum value
173 # of the |min_version| attributes of all methods in the interface and all
174 # parameters in those methods.
175 # TODO(rudominer) Consider adding this value to the intermediate
176 # representation.
177 interface.version = 0
178 for method in interface.methods: 172 for method in interface.methods:
179 if method.min_version is not None:
180 interface.version = max(interface.version, method.min_version)
181
182 method.param_struct = self._GetStructFromMethod(method) 173 method.param_struct = self._GetStructFromMethod(method)
183 interface.version = max(interface.version,
184 method.param_struct.versions[-1].version)
185
186 if method.response_parameters is not None: 174 if method.response_parameters is not None:
187 method.response_param_struct = self._GetResponseStructFromMethod(method) 175 method.response_param_struct = self._GetResponseStructFromMethod(method)
188 interface.version = max(
189 interface.version,
190 method.response_param_struct.versions[-1].version)
191 else: 176 else:
192 method.response_param_struct = None 177 method.response_param_struct = None
193 return interface 178 return interface
194 179
195 def _GetStructFromMethod(self, method): 180 def _GetStructFromMethod(self, method):
196 """Returns a method's parameters as a struct.""" 181 """Returns a method's parameters as a struct."""
197 return self._AddStructComputedData(False, method.param_struct) 182 return self._AddStructComputedData(False, method.param_struct)
198 183
199 def _GetResponseStructFromMethod(self, method): 184 def _GetResponseStructFromMethod(self, method):
200 """Returns a method's response_parameters as a struct.""" 185 """Returns a method's response_parameters as a struct."""
201 return self._AddStructComputedData(False, method.response_param_struct) 186 return self._AddStructComputedData(False, method.response_param_struct)
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698