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') |
11 # interface = module.AddInterface('Bar') | 11 # interface = module.AddInterface('Bar') |
12 # method = interface.AddMethod('Tat', 0) | 12 # method = interface.AddMethod('Tat', 0) |
13 # method.AddParameter('baz', 0, mojom.INT32) | 13 # method.AddParameter('baz', 0, mojom.INT32) |
14 | 14 |
15 | 15 |
16 class Kind(object): | 16 class Kind(object): |
17 def __init__(self, spec=None): | 17 def __init__(self, spec=None): |
18 self.spec = spec | 18 self.spec = spec |
19 self.parent_kind = None | 19 self.parent_kind = None |
20 | 20 |
21 | 21 |
22 class ReferenceKind(Kind): | 22 class ReferenceKind(Kind): |
23 """ReferenceKind represents pointer types and handle types. | 23 """ReferenceKind represents pointer types and handle types. |
24 A type is nullable means that NULL (for pointer types) or invalid handle | 24 A type is nullable if null (for pointer types) or invalid handle (for handle |
25 (for handle types) is a legal value for the type. | 25 types) is a legal value for the type. |
26 """ | 26 """ |
27 | 27 |
28 def __init__(self, spec=None, is_nullable=False): | 28 def __init__(self, spec=None, is_nullable=False): |
29 assert spec is None or is_nullable == spec.startswith('?') | 29 assert spec is None or is_nullable == spec.startswith('?') |
30 Kind.__init__(self, spec) | 30 Kind.__init__(self, spec) |
31 self.is_nullable = is_nullable | 31 self.is_nullable = is_nullable |
32 self.shared_definition = {} | 32 self.shared_definition = {} |
33 | 33 |
34 def MakeNullableKind(self): | 34 def MakeNullableKind(self): |
35 assert not self.is_nullable | 35 assert not self.is_nullable |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 def IsMoveOnlyKind(kind): | 420 def IsMoveOnlyKind(kind): |
421 return IsObjectKind(kind) or IsAnyHandleKind(kind) | 421 return IsObjectKind(kind) or IsAnyHandleKind(kind) |
422 | 422 |
423 | 423 |
424 def HasCallbacks(interface): | 424 def HasCallbacks(interface): |
425 for method in interface.methods: | 425 for method in interface.methods: |
426 if method.response_parameters != None: | 426 if method.response_parameters != None: |
427 return True | 427 return True |
428 return False | 428 return False |
429 | 429 |
OLD | NEW |