| 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 def IsAssociatedKind(kind): | 600 def IsAssociatedKind(kind): |
| 601 return (IsAssociatedInterfaceKind(kind) or | 601 return (IsAssociatedInterfaceKind(kind) or |
| 602 IsAssociatedInterfaceRequestKind(kind)) | 602 IsAssociatedInterfaceRequestKind(kind)) |
| 603 | 603 |
| 604 | 604 |
| 605 def IsMoveOnlyKind(kind): | 605 def IsMoveOnlyKind(kind): |
| 606 return (not IsStringKind(kind) and IsObjectKind(kind)) or \ | 606 return (not IsStringKind(kind) and IsObjectKind(kind)) or \ |
| 607 IsAnyHandleKind(kind) or IsInterfaceKind(kind) or IsAssociatedKind(kind) | 607 IsAnyHandleKind(kind) or IsInterfaceKind(kind) or IsAssociatedKind(kind) |
| 608 | 608 |
| 609 | 609 |
| 610 def IsCloneableKind(kind): | 610 def IsCloneableKind(kind, filter): |
| 611 def _IsCloneable(kind, visited_kinds): | 611 def _IsCloneable(kind, visited_kinds): |
| 612 if kind in visited_kinds: | 612 if kind in visited_kinds: |
| 613 # No need to examine the kind again. | 613 # No need to examine the kind again. |
| 614 return True | 614 return True |
| 615 visited_kinds.add(kind) | 615 visited_kinds.add(kind) |
| 616 if IsAnyHandleKind(kind) or IsInterfaceKind(kind) or IsAssociatedKind(kind): | 616 if IsAnyHandleKind(kind) or IsInterfaceKind(kind) or IsAssociatedKind(kind): |
| 617 return False | 617 return False |
| 618 if IsArrayKind(kind): | 618 if IsArrayKind(kind): |
| 619 return _IsCloneable(kind.kind, visited_kinds) | 619 return _IsCloneable(kind.kind, visited_kinds) |
| 620 if IsStructKind(kind) or IsUnionKind(kind): | 620 if IsStructKind(kind) or IsUnionKind(kind): |
| 621 if IsStructKind(kind) and kind.native_only: | 621 if IsStructKind(kind) and (kind.native_only or filter(kind)): |
| 622 return False | 622 return False |
| 623 for field in kind.fields: | 623 for field in kind.fields: |
| 624 if not _IsCloneable(field.kind, visited_kinds): | 624 if not _IsCloneable(field.kind, visited_kinds): |
| 625 return False | 625 return False |
| 626 if IsMapKind(kind): | 626 if IsMapKind(kind): |
| 627 # No need to examine the key kind, only primitive kinds and non-nullable | 627 # No need to examine the key kind, only primitive kinds and non-nullable |
| 628 # string are allowed to be key kinds. | 628 # string are allowed to be key kinds. |
| 629 return _IsCloneable(kind.value_kind, visited_kinds) | 629 return _IsCloneable(kind.value_kind, visited_kinds) |
| 630 return True | 630 return True |
| 631 | 631 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 if _ContainsAssociatedKinds(param.kind, visited_kinds): | 671 if _ContainsAssociatedKinds(param.kind, visited_kinds): |
| 672 return True | 672 return True |
| 673 return False | 673 return False |
| 674 | 674 |
| 675 | 675 |
| 676 def HasSyncMethods(interface): | 676 def HasSyncMethods(interface): |
| 677 for method in interface.methods: | 677 for method in interface.methods: |
| 678 if method.sync: | 678 if method.sync: |
| 679 return True | 679 return True |
| 680 return False | 680 return False |
| OLD | NEW |