| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 55 const struct {{$struct.Name}}* in_struct, uint32_t in_struct_size, |
| 56 uint32_t in_num_handles); |
| 57 |
| 54 {{end}} | 58 {{end}} |
| 55 ` | 59 ` |
| 56 | 60 |
| 57 // TODO(vardhan): Move other struct constant definitions in here. | 61 // TODO(vardhan): Move other struct constant definitions in here. |
| 58 const GenerateStructDefinitions = ` | 62 const GenerateStructDefinitions = ` |
| 59 {{- /* . (dot) refers to the Go type |cgen.StructTemplate| */ -}} | 63 {{- /* . (dot) refers to the Go type |cgen.StructTemplate| */ -}} |
| 60 {{define "GenerateStructDefinitions" -}} | 64 {{define "GenerateStructDefinitions" -}} |
| 61 {{- $struct := . -}} | 65 {{- $struct := . -}} |
| 62 | 66 |
| 63 {{range $const := $struct.Constants -}} | 67 {{range $const := $struct.Constants -}} |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 | 86 |
| 83 void {{$struct.Name}}_DecodePointersAndHandles( | 87 void {{$struct.Name}}_DecodePointersAndHandles( |
| 84 struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size, | 88 struct {{$struct.Name}}* inout_struct, uint32_t in_struct_size, |
| 85 MojoHandle inout_handles[], uint32_t in_num_handles) { | 89 MojoHandle inout_handles[], uint32_t in_num_handles) { |
| 86 MojomStruct_DecodePointersAndHandles( | 90 MojomStruct_DecodePointersAndHandles( |
| 87 &{{$struct.Name}}__TypeDesc, | 91 &{{$struct.Name}}__TypeDesc, |
| 88 (struct MojomStructHeader*)inout_struct, in_struct_size, | 92 (struct MojomStructHeader*)inout_struct, in_struct_size, |
| 89 inout_handles, in_num_handles); | 93 inout_handles, in_num_handles); |
| 90 } | 94 } |
| 91 | 95 |
| 96 MojomValidationResult {{$struct.Name}}_Validate( |
| 97 const struct {{$struct.Name}}* in_struct, uint32_t in_struct_size, |
| 98 uint32_t in_num_handles) { |
| 99 struct MojomValidationContext context = { |
| 100 .next_handle_index = 0, |
| 101 .next_pointer = (char*)in_struct + in_struct->header_.num_bytes, |
| 102 }; |
| 103 return MojomStruct_Validate( |
| 104 &{{$struct.Name}}__TypeDesc, |
| 105 (struct MojomStructHeader*)in_struct, in_struct_size, in_num_handles, |
| 106 &context); |
| 107 } |
| 108 |
| 92 {{end}} | 109 {{end}} |
| 93 ` | 110 ` |
| OLD | NEW |