OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 package templates | 5 package templates |
6 | 6 |
7 // These declarations go in the header file so that we can avoid some | 7 // These declarations go in the header file so that we can avoid some |
8 // circular-dependencies. We call these "public" to say that other types can | 8 // circular-dependencies. We call these "public" to say that other types can |
9 // refer to them. | 9 // refer to them. |
10 const GenerateTypeTableDeclarations = ` | 10 const GenerateTypeTableDeclarations = ` |
11 {{define "GenerateTypeTableDeclarations"}} | 11 {{define "GenerateTypeTableDeclarations"}} |
| 12 // Union type table declarations. |
12 {{range $union := .PublicUnionNames -}} | 13 {{range $union := .PublicUnionNames -}} |
13 extern struct MojomPointerTableUnionEntry {{$union}}[]; | 14 extern struct MojomTypeDescriptorUnion {{$union}}; |
14 {{end}} | 15 {{end -}} |
15 | 16 |
| 17 // Struct type table declarations. |
16 {{range $struct := .PublicStructNames -}} | 18 {{range $struct := .PublicStructNames -}} |
17 extern struct MojomPointerTableStructEntry {{$struct}}[]; | 19 extern struct MojomTypeDescriptorStruct {{$struct}}; |
18 {{end -}} | 20 {{end -}} |
19 {{end}} | 21 {{end}} |
20 ` | 22 ` |
21 | 23 |
22 const GenerateTypeTableDefinitions = ` | 24 const GenerateTypeTableDefinitions = ` |
23 {{define "GenerateTypeTableDefinitions"}} | 25 {{define "GenerateTypeTableDefinitions"}} |
24 // Declarations for array type entries. | 26 // Declarations for array type entries. |
25 {{range $array := .Arrays -}} | 27 {{range $array := .Arrays -}} |
26 static struct MojomPointerTableArrayEntry {{$array.Name}}; | 28 static struct MojomTypeDescriptorArray {{$array.Name}}; |
27 {{end -}} | 29 {{end -}} |
28 | 30 |
29 // Declarations for struct type tables. | 31 // Declarations for struct type tables. |
30 {{range $struct := .Structs -}} | 32 {{range $struct := .Structs -}} |
31 struct MojomPointerTableStructEntry {{$struct.Name}}[]; | 33 struct MojomTypeDescriptorStruct {{$struct.Name}}; |
32 {{end -}} | 34 {{end -}} |
33 | 35 |
34 // Declarations for union type tables. | 36 // Declarations for union type tables. |
35 {{range $union := .Unions -}} | 37 {{range $union := .Unions -}} |
36 struct MojomPointerTableUnionEntry {{$union.Name}}[]; | 38 struct MojomTypeDescriptorUnion {{$union.Name}}; |
37 {{end -}} | 39 {{end -}} |
38 | 40 |
39 // Array type entry definitions. | 41 // Array type entry definitions. |
40 {{range $array := .Arrays -}} | 42 {{range $array := .Arrays -}} |
41 static struct MojomPointerTableArrayEntry {{$array.Name}} = { | 43 static struct MojomTypeDescriptorArray {{$array.Name}} = { |
42 {{$array.ElemTable}}, {{$array.NumElements}}, | 44 {{$array.ElemType}}, {{$array.ElemTable}}, |
43 {{$array.ElemType}}, {{$array.Nullable}}, | 45 {{$array.NumElements}}, {{$array.Nullable}}, |
44 }; | 46 }; |
45 {{end -}} | 47 {{end -}} |
46 | 48 |
47 // Struct type table definitions. | 49 // Struct type table definitions. |
48 {{range $struct := .Structs -}} | 50 {{range $struct := .Structs -}} |
49 struct MojomPointerTableStructEntry {{$struct.Name}}[] = { | 51 struct MojomTypeDescriptorStructEntry {{$struct.Name}}_Entries[] = { |
50 {{- range $entry := $struct.Entries}} | 52 {{- range $entry := $struct.Entries}} |
51 { | 53 { |
52 {{$entry.ElemTable}}, {{$entry.Offset}}, {{$entry.MinVersion}}, | 54 {{$entry.ElemType}}, {{$entry.ElemTable}}, |
53 {{$entry.ElemType}}, {{$entry.Nullable}}, {{$entry.KeepGoing}}, | 55 {{$entry.Offset}}, {{$entry.MinVersion}}, |
| 56 {{$entry.Nullable}}, |
54 }, | 57 }, |
55 {{end -}} | 58 {{end -}} |
56 }; | 59 }; |
| 60 struct MojomTypeDescriptorStruct {{$struct.Name}} = { |
| 61 {{len $struct.Entries}}ul, {{$struct.Name}}_Entries, |
| 62 }; |
57 {{end -}} | 63 {{end -}} |
58 | 64 |
59 // Union type table definitions. | 65 // Union type table definitions. |
60 {{range $union := .Unions -}} | 66 {{range $union := .Unions -}} |
61 struct MojomPointerTableUnionEntry {{$union.Name}}[] = { | 67 struct MojomTypeDescriptorUnionEntry {{$union.Name}}_Entries[] = { |
62 {{- range $entry := $union.Entries}} | 68 {{- range $entry := $union.Entries}} |
63 { | 69 { |
64 {{$entry.ElemTable}}, {{$entry.Tag}}, {{$entry.ElemType}}, | 70 {{$entry.ElemType}}, {{$entry.ElemTable}}, |
65 {{$entry.Nullable}}, {{$entry.KeepGoing}}, | 71 {{$entry.Tag}}, {{$entry.Nullable}}, |
66 }, | 72 }, |
67 {{end -}} | 73 {{end -}} |
68 }; | 74 }; |
| 75 struct MojomTypeDescriptorUnion {{$union.Name}} = { |
| 76 {{len $union.Entries}}ul, {{$union.Name}}_Entries, |
| 77 }; |
69 {{end}} | 78 {{end}} |
70 | 79 |
71 {{end}} | 80 {{end}} |
72 ` | 81 ` |
OLD | NEW |