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 # mojom's classes provide an interface to mojo modules. Modules are collections | 5 # mojom's classes provide an interface to mojo modules. Modules are collections |
6 # of interfaces and structs to be used by mojo ipc clients and servers. | 6 # of interfaces and structs to be used by mojo ipc clients and servers. |
7 # | 7 # |
8 # A simple interface would be created this way: | 8 # A simple interface would be created this way: |
9 # module = mojom.Module('Foo') | 9 # module = mojom.Module('Foo') |
10 # interface = module.AddInterface('Bar') | 10 # interface = module.AddInterface('Bar') |
11 # method = interface.AddMethod('Tat', 0) | 11 # method = interface.AddMethod('Tat', 0) |
12 # method.AddParameter('baz', 0, mojom.INT32) | 12 # method.AddParameter('baz', 0, mojom.INT32) |
13 # | 13 # |
14 | 14 |
15 class Kind(object): | 15 class Kind(object): |
16 def __init__(self, spec = None): | 16 def __init__(self, spec = None): |
17 self.spec = spec | 17 self.spec = spec |
18 self.parent_kind = None | 18 self.parent_kind = None |
19 | 19 |
20 # Initialize the set of primitive types. These can be accessed by clients. | 20 # Initialize the set of primitive types. These can be accessed by clients. |
21 BOOL = Kind('b') | 21 BOOL = Kind('b') |
22 INT8 = Kind('i8') | 22 INT8 = Kind('i8') |
23 INT16 = Kind('i16') | 23 INT16 = Kind('i16') |
24 INT32 = Kind('i32') | 24 INT32 = Kind('i32') |
25 INT64 = Kind('i64') | 25 INT64 = Kind('i64') |
26 UINT8 = Kind('u8') | 26 UINT8 = Kind('u8') |
27 UINT16 = Kind('u16') | 27 UINT16 = Kind('u16') |
28 UINT32 = Kind('u32') | 28 UINT32 = Kind('u32') |
29 UINT64 = Kind('u64') | 29 UINT64 = Kind('u64') |
30 FLOAT = Kind('f') | 30 FLOAT = Kind('f') |
31 DOUBLE = Kind('d') | 31 DOUBLE = Kind('d') |
32 STRING = Kind('s') | 32 STRING = Kind('s') |
33 HANDLE = Kind('h') | 33 HANDLE = Kind('h') |
34 DCPIPE = Kind('h:d:c') | 34 DCPIPE = Kind('h:d:c') |
35 DPPIPE = Kind('h:d:p') | 35 DPPIPE = Kind('h:d:p') |
36 MSGPIPE = Kind('h:m') | 36 MSGPIPE = Kind('h:m') |
| 37 SHAREDBUFFER = Kind('h:s') |
37 | 38 |
38 | 39 |
39 # Collection of all Primitive types | 40 # Collection of all Primitive types |
40 PRIMITIVES = ( | 41 PRIMITIVES = ( |
41 BOOL, | 42 BOOL, |
42 INT8, | 43 INT8, |
43 INT16, | 44 INT16, |
44 INT32, | 45 INT32, |
45 INT64, | 46 INT64, |
46 UINT8, | 47 UINT8, |
47 UINT16, | 48 UINT16, |
48 UINT32, | 49 UINT32, |
49 UINT64, | 50 UINT64, |
50 FLOAT, | 51 FLOAT, |
51 DOUBLE, | 52 DOUBLE, |
52 STRING, | 53 STRING, |
53 HANDLE, | 54 HANDLE, |
54 DCPIPE, | 55 DCPIPE, |
55 DPPIPE, | 56 DPPIPE, |
56 MSGPIPE | 57 MSGPIPE, |
| 58 SHAREDBUFFER |
57 ) | 59 ) |
58 | 60 |
59 | 61 |
60 class Constant(object): | 62 class Constant(object): |
61 def __init__(self, module, enum, field): | 63 def __init__(self, module, enum, field): |
62 self.namespace = module.namespace | 64 self.namespace = module.namespace |
63 self.parent_kind = enum.parent_kind | 65 self.parent_kind = enum.parent_kind |
64 self.name = [enum.name, field.name] | 66 self.name = [enum.name, field.name] |
65 self.imported_from = None | 67 self.imported_from = None |
66 | 68 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 179 |
178 def AddInterface(self, name): | 180 def AddInterface(self, name): |
179 interface = Interface(name); | 181 interface = Interface(name); |
180 self.interfaces.append(interface) | 182 self.interfaces.append(interface) |
181 return interface; | 183 return interface; |
182 | 184 |
183 def AddStruct(self, name): | 185 def AddStruct(self, name): |
184 struct = Struct(name) | 186 struct = Struct(name) |
185 self.structs.append(struct) | 187 self.structs.append(struct) |
186 return struct; | 188 return struct; |
OLD | NEW |