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

Side by Side Diff: mojo/public/python/mojo_bindings/interface_reflection.py

Issue 1508613003: Require an explicit ServiceName annotation for interfaces in Python. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """ 5 """
6 The metaclasses used by the mojo python bindings for interfaces. 6 The metaclasses used by the mojo python bindings for interfaces.
7 7
8 It is splitted from mojo_bindings.reflection because it uses some generated code 8 It is splitted from mojo_bindings.reflection because it uses some generated code
9 that would create a cyclic dependency. 9 that would create a cyclic dependency.
10 """ 10 """
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return type.__new__(mcs, name, bases, dictionary) 60 return type.__new__(mcs, name, bases, dictionary)
61 61
62 descriptor = dictionary.pop('DESCRIPTOR', {}) 62 descriptor = dictionary.pop('DESCRIPTOR', {})
63 63
64 methods = [_MethodDescriptor(x) for x in descriptor.get('methods', [])] 64 methods = [_MethodDescriptor(x) for x in descriptor.get('methods', [])]
65 for method in methods: 65 for method in methods:
66 dictionary[method.name] = _NotImplemented 66 dictionary[method.name] = _NotImplemented
67 fully_qualified_name = descriptor['fully_qualified_name'] 67 fully_qualified_name = descriptor['fully_qualified_name']
68 68
69 interface_manager = InterfaceManager( 69 interface_manager = InterfaceManager(
70 fully_qualified_name, descriptor['version'], methods) 70 name, descriptor['version'], methods)
71 dictionary.update({ 71 dictionary.update({
72 'service_name' = fully_qualified_name,
72 'manager': None, 73 'manager': None,
73 '_interface_manager': interface_manager, 74 '_interface_manager': interface_manager,
74 }) 75 })
75 76
76 interface_class = type.__new__(mcs, name, bases, dictionary) 77 interface_class = type.__new__(mcs, name, bases, dictionary)
77 interface_manager.interface_class = interface_class 78 interface_manager.interface_class = interface_class
78 return interface_class 79 return interface_class
79 80
80 @property 81 @property
81 def manager(cls): 82 def manager(cls):
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 payload = message.payload 458 payload = message.payload
458 query = ( 459 query = (
459 interface_control_messages_mojom.RunOrClosePipeMessageParams.Deserialize( 460 interface_control_messages_mojom.RunOrClosePipeMessageParams.Deserialize(
460 serialization.RootDeserializationContext(payload.data, 461 serialization.RootDeserializationContext(payload.data,
461 payload.handles))) 462 payload.handles)))
462 return query.require_version.version <= manager.interface_manager.version 463 return query.require_version.version <= manager.interface_manager.version
463 464
464 465
465 def _NotImplemented(*_1, **_2): 466 def _NotImplemented(*_1, **_2):
466 raise NotImplementedError() 467 raise NotImplementedError()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698