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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 def IsAssociatedKind(kind): | 784 def IsAssociatedKind(kind): |
785 return (IsAssociatedInterfaceKind(kind) or | 785 return (IsAssociatedInterfaceKind(kind) or |
786 IsAssociatedInterfaceRequestKind(kind)) | 786 IsAssociatedInterfaceRequestKind(kind)) |
787 | 787 |
788 | 788 |
789 def IsMoveOnlyKind(kind): | 789 def IsMoveOnlyKind(kind): |
790 return (not IsStringKind(kind) and IsObjectKind(kind)) or \ | 790 return (not IsStringKind(kind) and IsObjectKind(kind)) or \ |
791 IsAnyHandleKind(kind) or IsInterfaceKind(kind) or IsAssociatedKind(kind) | 791 IsAnyHandleKind(kind) or IsInterfaceKind(kind) or IsAssociatedKind(kind) |
792 | 792 |
793 | 793 |
794 def IsCloneableKind(kind, filter): | |
795 def _IsCloneable(kind, visited_kinds): | |
796 if kind in visited_kinds: | |
797 # No need to examine the kind again. | |
798 return True | |
799 visited_kinds.add(kind) | |
800 if IsAnyHandleKind(kind) or IsInterfaceKind(kind) or IsAssociatedKind(kind): | |
801 return False | |
802 if IsArrayKind(kind): | |
803 return _IsCloneable(kind.kind, visited_kinds) | |
804 if IsStructKind(kind) or IsUnionKind(kind): | |
805 if IsStructKind(kind) and filter(kind): | |
806 return False | |
807 for field in kind.fields: | |
808 if not _IsCloneable(field.kind, visited_kinds): | |
809 return False | |
810 if IsMapKind(kind): | |
811 # No need to examine the key kind, only primitive kinds and non-nullable | |
812 # string are allowed to be key kinds. | |
813 return _IsCloneable(kind.value_kind, visited_kinds) | |
814 return True | |
815 | |
816 return _IsCloneable(kind, set()) | |
817 | |
818 | |
819 def HasCallbacks(interface): | 794 def HasCallbacks(interface): |
820 for method in interface.methods: | 795 for method in interface.methods: |
821 if method.response_parameters != None: | 796 if method.response_parameters != None: |
822 return True | 797 return True |
823 return False | 798 return False |
824 | 799 |
825 | 800 |
826 # Finds out whether an interface passes associated interfaces and associated | 801 # Finds out whether an interface passes associated interfaces and associated |
827 # interface requests. | 802 # interface requests. |
828 def PassesAssociatedKinds(interface): | 803 def PassesAssociatedKinds(interface): |
(...skipping 26 matching lines...) Expand all Loading... |
855 if _ContainsAssociatedKinds(param.kind, visited_kinds): | 830 if _ContainsAssociatedKinds(param.kind, visited_kinds): |
856 return True | 831 return True |
857 return False | 832 return False |
858 | 833 |
859 | 834 |
860 def HasSyncMethods(interface): | 835 def HasSyncMethods(interface): |
861 for method in interface.methods: | 836 for method in interface.methods: |
862 if method.sync: | 837 if method.sync: |
863 return True | 838 return True |
864 return False | 839 return False |
OLD | NEW |