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

Unified Diff: third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_python_generator.py

Issue 890843003: Revert of Update mojo sdk to rev 8af2ccff2eee4bfca1043015abee30482a030b30 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
Index: third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_python_generator.py
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_python_generator.py b/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_python_generator.py
index d4d4ed7e5d723eabd5f6528d9f714d43b6033dcb..f8a70579ad0054948246ef51e07283ecc4014cf9 100644
--- a/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_python_generator.py
+++ b/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_python_generator.py
@@ -191,6 +191,14 @@
assert len(byte.packed_fields) == 1
return GetFieldDescriptor(byte.packed_fields[0])
+def GetResponseStructFromMethod(method):
+ return generator.GetDataHeader(
+ False, generator.GetResponseStructFromMethod(method))
+
+def GetStructFromMethod(method):
+ return generator.GetDataHeader(
+ False, generator.GetStructFromMethod(method))
+
def ComputeStaticValues(module):
in_progress = set()
computed = set()
@@ -279,8 +287,8 @@
'field_group': GetFieldGroup,
'fully_qualified_name': GetFullyQualifiedName,
'name': GetNameForElement,
- 'response_struct_from_method': generator.GetResponseStructFromMethod,
- 'struct_from_method': generator.GetStructFromMethod,
+ 'response_struct_from_method': GetResponseStructFromMethod,
+ 'struct_from_method': GetStructFromMethod,
}
@UseJinja('python_templates/module.py.tmpl', filters=python_filters)
@@ -288,7 +296,7 @@
return {
'enums': self.module.enums,
'imports': self.GetImports(),
- 'interfaces': self.module.interfaces,
+ 'interfaces': self.GetQualifiedInterfaces(),
'module': ComputeStaticValues(self.module),
'namespace': self.module.namespace,
'structs': self.GetStructs(),
@@ -303,6 +311,26 @@
for each in self.module.imports:
each['python_module'] = MojomToPythonImport(each['module_name'])
return self.module.imports
+
+ def GetQualifiedInterfaces(self):
+ """
+ Returns the list of interfaces of the module. Each interface that has a
+ client will have a reference to the representation of the client interface
+ in the 'qualified_client' field.
+ """
+ interfaces = self.module.interfaces
+ all_interfaces = [] + interfaces
+ for each in self.GetImports():
+ all_interfaces += [data.KindFromImport(x, each) for x in
+ each['module'].interfaces];
+ interfaces_by_name = dict((x.name, x) for x in all_interfaces)
+ for interface in interfaces:
+ if interface.client:
+ assert interface.client in interfaces_by_name, (
+ 'Unable to find interface %s declared as client of %s.' %
+ (interface.client, interface.name))
+ interface.qualified_client = interfaces_by_name[interface.client]
+ return sorted(interfaces, key=lambda i: (bool(i.client), i.name))
def GetJinjaParameters(self):
return {

Powered by Google App Engine
This is Rietveld 408576698