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

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

Issue 615063003: Mojo cpp bindings: support Clone() for structs and arrays which don't contain handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 ec03b7f32fe930cfcf57c977685f712730633dda..7ae7a8321c774040b9f5668f3919a649bcff0688 100644
--- a/mojo/public/tools/bindings/pylib/mojom/generate/module.py
+++ b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
@@ -421,6 +421,25 @@ def IsMoveOnlyKind(kind):
return IsObjectKind(kind) or IsAnyHandleKind(kind)
+def IsCloneableKind(kind):
+ def ContainsHandles(kind, visited_kinds):
+ if kind in visited_kinds:
+ # No need to examine the kind again.
+ return False
+ visited_kinds.add(kind)
+ if IsAnyHandleKind(kind):
+ return True
+ if IsAnyArrayKind(kind):
+ return ContainsHandles(kind.kind, visited_kinds)
+ if IsStructKind(kind):
+ for field in kind.fields:
+ if ContainsHandles(field.kind, visited_kinds):
+ return True
+ return False
+
+ return not ContainsHandles(kind, set())
+
+
def HasCallbacks(interface):
for method in interface.methods:
if method.response_parameters != None:

Powered by Google App Engine
This is Rietveld 408576698