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

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

Issue 2820783002: Add associated interfaces & bindings. (Closed)
Patch Set: Remove changes to vibration-iframe-expected.txt because it was removed in master. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/pylib/mojom/generate/module.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/module.py b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
index 3a5f188e75e46490b172759ad264a8e24beef749..ef49f0dfb2dde4ba98747bc59a9d54534953d94b 100644
--- a/mojo/public/tools/bindings/pylib/mojom/generate/module.py
+++ b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
@@ -847,6 +847,37 @@ def PassesAssociatedKinds(interface):
return True
return False
yzshen1 2017/04/19 21:11:34 I understand some files don't respect this, but we
wangjimmy 2017/04/20 15:36:44 Done.
+# Finds out whether a method passes associated interfaces and associated
+# interface requests.
+def MethodPassesAssociatedKinds(method):
+ def _ContainsAssociatedKinds(kind, visited_kinds):
+ if kind in visited_kinds:
+ # No need to examine the kind again.
+ return False
+ visited_kinds.add(kind)
+ if IsAssociatedKind(kind):
+ return True
+ if IsArrayKind(kind):
+ return _ContainsAssociatedKinds(kind.kind, visited_kinds)
+ if IsStructKind(kind) or IsUnionKind(kind):
+ for field in kind.fields:
+ if _ContainsAssociatedKinds(field.kind, visited_kinds):
+ return True
+ if IsMapKind(kind):
+ # No need to examine the key kind, only primitive kinds and non-nullable
+ # string are allowed to be key kinds.
+ return _ContainsAssociatedKinds(kind.value_kind, visited_kinds)
+ return False
+
+ visited_kinds = set()
+ for param in method.parameters:
+ if _ContainsAssociatedKinds(param.kind, visited_kinds):
+ return True
+ if method.response_parameters != None:
+ for param in method.response_parameters:
+ if _ContainsAssociatedKinds(param.kind, visited_kinds):
+ return True
+ return False
def HasSyncMethods(interface):
for method in interface.methods:

Powered by Google App Engine
This is Rietveld 408576698