| 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 const GenerateStructDeclarations = ` | 7 const GenerateStructDeclarations = ` |
| 8 {{- /* . (dot) refers to the Go type |cgen.StructTemplate| */ -}} | 8 {{- /* . (dot) refers to the Go type |cgen.StructTemplate| */ -}} |
| 9 {{define "GenerateStructDeclarations" -}} | 9 {{define "GenerateStructDeclarations" -}} |
| 10 {{- $struct := . -}} | 10 {{- $struct := . -}} |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 struct {{$struct.Name}}* {{$struct.Name}}_New(struct MojomBuffer* in_buffer); | 31 struct {{$struct.Name}}* {{$struct.Name}}_New(struct MojomBuffer* in_buffer); |
| 32 | 32 |
| 33 void {{$struct.Name}}_Init( | 33 void {{$struct.Name}}_Init( |
| 34 struct {{$struct.Name}}* in_data); | 34 struct {{$struct.Name}}* in_data); |
| 35 | 35 |
| 36 void {{$struct.Name}}_CloseAllHandles( | 36 void {{$struct.Name}}_CloseAllHandles( |
| 37 struct {{$struct.Name}}* in_data); | 37 struct {{$struct.Name}}* in_data); |
| 38 | 38 |
| 39 struct {{$struct.Name}}* {{$struct.Name}}_DeepCopy( | 39 struct {{$struct.Name}}* {{$struct.Name}}_DeepCopy( |
| 40 struct MojomBuffer* in_buffer, | 40 struct MojomBuffer* in_buffer, |
| 41 struct {{$struct.Name}}* in_data); | 41 struct {{$struct.Name}}* in_struct); |
| 42 | 42 |
| 43 size_t {{$struct.Name}}_ComputeSerializedSize( | 43 size_t {{$struct.Name}}_ComputeSerializedSize( |
| 44 const struct {{$struct.Name}}* in_data); | 44 const struct {{$struct.Name}}* in_data); |
| 45 | 45 |
| 46 void {{$struct.Name}}_EncodePointersAndHandles( | 46 void {{$struct.Name}}_EncodePointersAndHandles( |
| 47 struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size, | 47 struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size, |
| 48 struct MojomHandleBuffer* inout_handle_buffer); | 48 struct MojomHandleBuffer* inout_handle_buffer); |
| 49 | 49 |
| 50 void {{$struct.Name}}_DecodePointersAndHandles( | 50 void {{$struct.Name}}_DecodePointersAndHandles( |
| 51 struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size, | 51 struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size, |
| 52 MojoHandle inout_handles[], uint32_t in_num_handles); | 52 MojoHandle inout_handles[], uint32_t in_num_handles); |
| 53 | 53 |
| 54 MojomValidationResult {{$struct.Name}}_Validate( | 54 MojomValidationResult {{$struct.Name}}_Validate( |
| 55 const struct {{$struct.Name}}* in_struct, uint32_t in_struct_size, | 55 const struct {{$struct.Name}}* in_struct, uint32_t in_struct_size, |
| 56 uint32_t in_num_handles); | 56 uint32_t in_num_handles); |
| 57 | 57 |
| 58 {{end}} | 58 {{end}} |
| 59 ` | 59 ` |
| 60 | 60 |
| 61 // TODO(vardhan): Move other struct constant definitions in here. | 61 // TODO(vardhan): Move other struct constant definitions in here. |
| 62 const GenerateStructDefinitions = ` | 62 const GenerateStructDefinitions = ` |
| 63 {{- /* . (dot) refers to the Go type |cgen.StructTemplate| */ -}} | 63 {{- /* . (dot) refers to the Go type |cgen.StructTemplate| */ -}} |
| 64 {{define "GenerateStructDefinitions" -}} | 64 {{define "GenerateStructDefinitions" -}} |
| 65 {{- $struct := . -}} | 65 {{- $struct := . -}} |
| 66 | 66 |
| 67 {{range $const := $struct.Constants -}} | 67 {{range $const := $struct.Constants -}} |
| 68 const {{$const.Type}} {{$const.Name}} = {{$const.Value}}; | 68 const {{$const.Type}} {{$const.Name}} = {{$const.Value}}; |
| 69 {{end -}} | 69 {{end -}} |
| 70 | 70 |
| 71 struct {{$struct.Name}}* {{$struct.Name}}_DeepCopy( |
| 72 struct MojomBuffer* in_buffer, |
| 73 struct {{$struct.Name}}* in_struct) { |
| 74 struct {{$struct.Name}}* out_struct = NULL; |
| 75 if (!MojomStruct_DeepCopy( |
| 76 in_buffer, &{{$struct.Name}}__TypeDesc, |
| 77 (struct MojomStructHeader*)in_struct, |
| 78 (struct MojomStructHeader**)&out_struct)) { |
| 79 return NULL; |
| 80 } |
| 81 return out_struct; |
| 82 } |
| 83 |
| 71 size_t {{$struct.Name}}_ComputeSerializedSize( | 84 size_t {{$struct.Name}}_ComputeSerializedSize( |
| 72 const struct {{$struct.Name}}* in_data) { | 85 const struct {{$struct.Name}}* in_data) { |
| 73 return MojomStruct_ComputeSerializedSize( | 86 return MojomStruct_ComputeSerializedSize( |
| 74 &{{$struct.Name}}__TypeDesc, | 87 &{{$struct.Name}}__TypeDesc, |
| 75 (const struct MojomStructHeader*)in_data); | 88 (const struct MojomStructHeader*)in_data); |
| 76 } | 89 } |
| 77 | 90 |
| 78 void {{$struct.Name}}_EncodePointersAndHandles( | 91 void {{$struct.Name}}_EncodePointersAndHandles( |
| 79 struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size, | 92 struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size, |
| 80 struct MojomHandleBuffer* inout_handle_buffer) { | 93 struct MojomHandleBuffer* inout_handle_buffer) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 101 .next_pointer = (char*)in_struct + in_struct->header_.num_bytes, | 114 .next_pointer = (char*)in_struct + in_struct->header_.num_bytes, |
| 102 }; | 115 }; |
| 103 return MojomStruct_Validate( | 116 return MojomStruct_Validate( |
| 104 &{{$struct.Name}}__TypeDesc, | 117 &{{$struct.Name}}__TypeDesc, |
| 105 (struct MojomStructHeader*)in_struct, in_struct_size, in_num_handles, | 118 (struct MojomStructHeader*)in_struct, in_struct_size, in_num_handles, |
| 106 &context); | 119 &context); |
| 107 } | 120 } |
| 108 | 121 |
| 109 {{end}} | 122 {{end}} |
| 110 ` | 123 ` |
| OLD | NEW |