OLD | NEW |
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 # This module's classes provide an interface to mojo modules. Modules are | 5 # This module's classes provide an interface to mojo modules. Modules are |
6 # collections of interfaces and structs to be used by mojo ipc clients and | 6 # collections of interfaces and structs to be used by mojo ipc clients and |
7 # servers. | 7 # servers. |
8 # | 8 # |
9 # A simple interface would be created this way: | 9 # A simple interface would be created this way: |
10 # module = mojom.generate.module.Module('Foo') | 10 # module = mojom.generate.module.Module('Foo') |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 def IsAnyHandleKind(kind): | 414 def IsAnyHandleKind(kind): |
415 return (IsNonInterfaceHandleKind(kind) or | 415 return (IsNonInterfaceHandleKind(kind) or |
416 IsInterfaceKind(kind) or | 416 IsInterfaceKind(kind) or |
417 IsInterfaceRequestKind(kind)) | 417 IsInterfaceRequestKind(kind)) |
418 | 418 |
419 | 419 |
420 def IsMoveOnlyKind(kind): | 420 def IsMoveOnlyKind(kind): |
421 return IsObjectKind(kind) or IsAnyHandleKind(kind) | 421 return IsObjectKind(kind) or IsAnyHandleKind(kind) |
422 | 422 |
423 | 423 |
| 424 def IsCloneableKind(kind): |
| 425 def ContainsHandles(kind, visited_kinds): |
| 426 if kind in visited_kinds: |
| 427 # No need to examine the kind again. |
| 428 return False |
| 429 visited_kinds.add(kind) |
| 430 if IsAnyHandleKind(kind): |
| 431 return True |
| 432 if IsAnyArrayKind(kind): |
| 433 return ContainsHandles(kind.kind, visited_kinds) |
| 434 if IsStructKind(kind): |
| 435 for field in kind.fields: |
| 436 if ContainsHandles(field.kind, visited_kinds): |
| 437 return True |
| 438 return False |
| 439 |
| 440 return not ContainsHandles(kind, set()) |
| 441 |
| 442 |
424 def HasCallbacks(interface): | 443 def HasCallbacks(interface): |
425 for method in interface.methods: | 444 for method in interface.methods: |
426 if method.response_parameters != None: | 445 if method.response_parameters != None: |
427 return True | 446 return True |
428 return False | 447 return False |
429 | 448 |
OLD | NEW |