Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/generate/module.py

Issue 2820783002: Add associated interfaces & bindings. (Closed)
Patch Set: Change Router.prototype.accept. Add a TODO for endpoint client not attached. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 def HasCallbacks(interface): 810 def HasCallbacks(interface):
811 for method in interface.methods: 811 for method in interface.methods:
812 if method.response_parameters != None: 812 if method.response_parameters != None:
813 return True 813 return True
814 return False 814 return False
815 815
816 816
817 # Finds out whether an interface passes associated interfaces and associated 817 # Finds out whether an interface passes associated interfaces and associated
818 # interface requests. 818 # interface requests.
819 def PassesAssociatedKinds(interface): 819 def PassesAssociatedKinds(interface):
820 def _ContainsAssociatedKinds(kind, visited_kinds): 820 visited_kinds = set()
821 for method in interface.methods:
822 if MethodPassesAssociatedKinds(method, visited_kinds):
823 return True
824 return False
825
826
827 # Finds out whether a method passes associated interfaces and associated
828 # interface requests.
829 def MethodPassesAssociatedKinds(method, visited_kinds=None):
830 def _ContainsAssociatedKinds(kind):
821 if kind in visited_kinds: 831 if kind in visited_kinds:
822 # No need to examine the kind again. 832 # No need to examine the kind again.
823 return False 833 return False
824 visited_kinds.add(kind) 834 visited_kinds.add(kind)
825 if IsAssociatedKind(kind): 835 if IsAssociatedKind(kind):
826 return True 836 return True
827 if IsArrayKind(kind): 837 if IsArrayKind(kind):
828 return _ContainsAssociatedKinds(kind.kind, visited_kinds) 838 return _ContainsAssociatedKinds(kind.kind)
829 if IsStructKind(kind) or IsUnionKind(kind): 839 if IsStructKind(kind) or IsUnionKind(kind):
830 for field in kind.fields: 840 for field in kind.fields:
831 if _ContainsAssociatedKinds(field.kind, visited_kinds): 841 if _ContainsAssociatedKinds(field.kind):
832 return True 842 return True
833 if IsMapKind(kind): 843 if IsMapKind(kind):
834 # No need to examine the key kind, only primitive kinds and non-nullable 844 # No need to examine the key kind, only primitive kinds and non-nullable
835 # string are allowed to be key kinds. 845 # string are allowed to be key kinds.
836 return _ContainsAssociatedKinds(kind.value_kind, visited_kinds) 846 return _ContainsAssociatedKinds(kind.value_kind)
837 return False 847 return False
838 848
839 visited_kinds = set() 849 if visited_kinds is None:
840 for method in interface.methods: 850 visited_kinds = set()
841 for param in method.parameters: 851
842 if _ContainsAssociatedKinds(param.kind, visited_kinds): 852 for param in method.parameters:
853 if _ContainsAssociatedKinds(param.kind):
854 return True
855 if method.response_parameters != None:
856 for param in method.response_parameters:
857 if _ContainsAssociatedKinds(param.kind):
843 return True 858 return True
844 if method.response_parameters != None:
845 for param in method.response_parameters:
846 if _ContainsAssociatedKinds(param.kind, visited_kinds):
847 return True
848 return False 859 return False
849 860
850 861
851 def HasSyncMethods(interface): 862 def HasSyncMethods(interface):
852 for method in interface.methods: 863 for method in interface.methods:
853 if method.sync: 864 if method.sync:
854 return True 865 return True
855 return False 866 return False
856 867
857 868
(...skipping 24 matching lines...) Expand all
882 return True 893 return True
883 elif IsAnyInterfaceKind(kind): 894 elif IsAnyInterfaceKind(kind):
884 return True 895 return True
885 elif IsArrayKind(kind): 896 elif IsArrayKind(kind):
886 return Check(kind.kind) 897 return Check(kind.kind)
887 elif IsMapKind(kind): 898 elif IsMapKind(kind):
888 return Check(kind.key_kind) or Check(kind.value_kind) 899 return Check(kind.key_kind) or Check(kind.value_kind)
889 else: 900 else:
890 return False 901 return False
891 return Check(kind) 902 return Check(kind)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698