| 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 for method in interface.methods: | 840 for method in interface.methods: |
| 841 for param in method.parameters: | 841 for param in method.parameters: |
| 842 if _ContainsAssociatedKinds(param.kind, visited_kinds): | 842 if _ContainsAssociatedKinds(param.kind, visited_kinds): |
| 843 return True | 843 return True |
| 844 if method.response_parameters != None: | 844 if method.response_parameters != None: |
| 845 for param in method.response_parameters: | 845 for param in method.response_parameters: |
| 846 if _ContainsAssociatedKinds(param.kind, visited_kinds): | 846 if _ContainsAssociatedKinds(param.kind, visited_kinds): |
| 847 return True | 847 return True |
| 848 return False | 848 return False |
| 849 | 849 |
| 850 # Finds out whether a method passes associated interfaces and associated |
| 851 # interface requests. |
| 852 def MethodPassesAssociatedKinds(method): |
| 853 def _ContainsAssociatedKinds(kind, visited_kinds): |
| 854 if kind in visited_kinds: |
| 855 # No need to examine the kind again. |
| 856 return False |
| 857 visited_kinds.add(kind) |
| 858 if IsAssociatedKind(kind): |
| 859 return True |
| 860 if IsArrayKind(kind): |
| 861 return _ContainsAssociatedKinds(kind.kind, visited_kinds) |
| 862 if IsStructKind(kind) or IsUnionKind(kind): |
| 863 for field in kind.fields: |
| 864 if _ContainsAssociatedKinds(field.kind, visited_kinds): |
| 865 return True |
| 866 if IsMapKind(kind): |
| 867 # No need to examine the key kind, only primitive kinds and non-nullable |
| 868 # string are allowed to be key kinds. |
| 869 return _ContainsAssociatedKinds(kind.value_kind, visited_kinds) |
| 870 return False |
| 871 |
| 872 visited_kinds = set() |
| 873 for param in method.parameters: |
| 874 if _ContainsAssociatedKinds(param.kind, visited_kinds): |
| 875 return True |
| 876 if method.response_parameters != None: |
| 877 for param in method.response_parameters: |
| 878 if _ContainsAssociatedKinds(param.kind, visited_kinds): |
| 879 return True |
| 880 return False |
| 850 | 881 |
| 851 def HasSyncMethods(interface): | 882 def HasSyncMethods(interface): |
| 852 for method in interface.methods: | 883 for method in interface.methods: |
| 853 if method.sync: | 884 if method.sync: |
| 854 return True | 885 return True |
| 855 return False | 886 return False |
| 856 | 887 |
| 857 | 888 |
| 858 def ContainsHandlesOrInterfaces(kind): | 889 def ContainsHandlesOrInterfaces(kind): |
| 859 """Check if the kind contains any handles. | 890 """Check if the kind contains any handles. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 882 return True | 913 return True |
| 883 elif IsAnyInterfaceKind(kind): | 914 elif IsAnyInterfaceKind(kind): |
| 884 return True | 915 return True |
| 885 elif IsArrayKind(kind): | 916 elif IsArrayKind(kind): |
| 886 return Check(kind.kind) | 917 return Check(kind.kind) |
| 887 elif IsMapKind(kind): | 918 elif IsMapKind(kind): |
| 888 return Check(kind.key_kind) or Check(kind.value_kind) | 919 return Check(kind.key_kind) or Check(kind.value_kind) |
| 889 else: | 920 else: |
| 890 return False | 921 return False |
| 891 return Check(kind) | 922 return Check(kind) |
| OLD | NEW |