| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 ']') | 425 ']') |
| 426 if IsNullableKind(key_kind): | 426 if IsNullableKind(key_kind): |
| 427 raise Exception("Nullable kinds cannot be keys in maps.") | 427 raise Exception("Nullable kinds cannot be keys in maps.") |
| 428 if IsStructKind(key_kind): | 428 if IsStructKind(key_kind): |
| 429 # TODO(erg): It would sometimes be nice if we could key on struct | 429 # TODO(erg): It would sometimes be nice if we could key on struct |
| 430 # values. However, what happens if the struct has a handle in it? Or | 430 # values. However, what happens if the struct has a handle in it? Or |
| 431 # non-copyable data like an array? | 431 # non-copyable data like an array? |
| 432 raise Exception("Structs cannot be keys in maps.") | 432 raise Exception("Structs cannot be keys in maps.") |
| 433 if IsAnyHandleKind(key_kind): | 433 if IsAnyHandleKind(key_kind): |
| 434 raise Exception("Handles cannot be keys in maps.") | 434 raise Exception("Handles cannot be keys in maps.") |
| 435 if IsInterfaceKind(key_kind): | 435 if IsAnyInterfaceKind(key_kind): |
| 436 raise Exception("Interfaces cannot be keys in maps.") | 436 raise Exception("Interfaces cannot be keys in maps.") |
| 437 if IsArrayKind(key_kind): | 437 if IsArrayKind(key_kind): |
| 438 raise Exception("Arrays cannot be keys in maps.") | 438 raise Exception("Arrays cannot be keys in maps.") |
| 439 else: | 439 else: |
| 440 ReferenceKind.__init__(self) | 440 ReferenceKind.__init__(self) |
| 441 | 441 |
| 442 self.key_kind = key_kind | 442 self.key_kind = key_kind |
| 443 self.value_kind = value_kind | 443 self.value_kind = value_kind |
| 444 | 444 |
| 445 def Repr(self, as_ref=True): | 445 def Repr(self, as_ref=True): |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 764 |
| 765 def IsObjectKind(kind): | 765 def IsObjectKind(kind): |
| 766 return IsPointerKind(kind) or IsUnionKind(kind) | 766 return IsPointerKind(kind) or IsUnionKind(kind) |
| 767 | 767 |
| 768 | 768 |
| 769 def IsPointerKind(kind): | 769 def IsPointerKind(kind): |
| 770 return (IsStructKind(kind) or IsArrayKind(kind) or IsStringKind(kind) or | 770 return (IsStructKind(kind) or IsArrayKind(kind) or IsStringKind(kind) or |
| 771 IsMapKind(kind)) | 771 IsMapKind(kind)) |
| 772 | 772 |
| 773 | 773 |
| 774 # Please note that interface is not considered as handle kind, since it is an | 774 # Please note that it doesn't include any interface kind. |
| 775 # aggregate type consisting of a handle and a version number. | |
| 776 def IsAnyHandleKind(kind): | 775 def IsAnyHandleKind(kind): |
| 777 return (IsGenericHandleKind(kind) or | 776 return (IsGenericHandleKind(kind) or |
| 778 IsDataPipeConsumerKind(kind) or | 777 IsDataPipeConsumerKind(kind) or |
| 779 IsDataPipeProducerKind(kind) or | 778 IsDataPipeProducerKind(kind) or |
| 780 IsMessagePipeKind(kind) or | 779 IsMessagePipeKind(kind) or |
| 781 IsSharedBufferKind(kind) or | 780 IsSharedBufferKind(kind)) |
| 782 IsInterfaceRequestKind(kind)) | 781 |
| 782 |
| 783 def IsAnyInterfaceKind(kind): |
| 784 return (IsInterfaceKind(kind) or IsInterfaceRequestKind(kind) or |
| 785 IsAssociatedKind(kind)) |
| 783 | 786 |
| 784 | 787 |
| 785 def IsAnyHandleOrInterfaceKind(kind): | 788 def IsAnyHandleOrInterfaceKind(kind): |
| 786 return (IsAnyHandleKind(kind) or IsInterfaceKind(kind) or | 789 return IsAnyHandleKind(kind) or IsAnyInterfaceKind(kind) |
| 787 IsAssociatedKind(kind)) | |
| 788 | 790 |
| 789 | 791 |
| 790 def IsAssociatedKind(kind): | 792 def IsAssociatedKind(kind): |
| 791 return (IsAssociatedInterfaceKind(kind) or | 793 return (IsAssociatedInterfaceKind(kind) or |
| 792 IsAssociatedInterfaceRequestKind(kind)) | 794 IsAssociatedInterfaceRequestKind(kind)) |
| 793 | 795 |
| 794 | 796 |
| 795 def HasCallbacks(interface): | 797 def HasCallbacks(interface): |
| 796 for method in interface.methods: | 798 for method in interface.methods: |
| 797 if method.response_parameters != None: | 799 if method.response_parameters != None: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 if _ContainsAssociatedKinds(param.kind, visited_kinds): | 833 if _ContainsAssociatedKinds(param.kind, visited_kinds): |
| 832 return True | 834 return True |
| 833 return False | 835 return False |
| 834 | 836 |
| 835 | 837 |
| 836 def HasSyncMethods(interface): | 838 def HasSyncMethods(interface): |
| 837 for method in interface.methods: | 839 for method in interface.methods: |
| 838 if method.sync: | 840 if method.sync: |
| 839 return True | 841 return True |
| 840 return False | 842 return False |
| OLD | NEW |