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 cgen | 5 package cgen |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "log" | 9 "log" |
10 "path/filepath" | 10 "path/filepath" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 default: | 182 default: |
183 log.Fatal("Shouldn't be here. Unknown value type for:", value) | 183 log.Fatal("Shouldn't be here. Unknown value type for:", value) |
184 } | 184 } |
185 | 185 |
186 return "" | 186 return "" |
187 } | 187 } |
188 | 188 |
189 func NewConstantTemplate(fileGraph *mojom_files.MojomFileGraph, mojomConstant mo
jom_types.DeclaredConstant) ConstantTemplate { | 189 func NewConstantTemplate(fileGraph *mojom_files.MojomFileGraph, mojomConstant mo
jom_types.DeclaredConstant) ConstantTemplate { |
190 var type_text string | 190 var type_text string |
191 switch mojomConstant.Type.(type) { | 191 switch mojomConstant.Type.(type) { |
192 » // We can't type string constants as a 'union MojomStringPtr' since it | 192 » // We can't type string constants as a 'union MojomStringHeaderPtr' sinc
e it |
193 // involves some setup and prevents immediate consumption. const char* s
hould | 193 // involves some setup and prevents immediate consumption. const char* s
hould |
194 // suffice. | 194 // suffice. |
195 case *mojom_types.TypeStringType: | 195 case *mojom_types.TypeStringType: |
196 type_text = "char*" | 196 type_text = "char*" |
197 default: | 197 default: |
198 type_text = mojomToCType(mojomConstant.Type, fileGraph) | 198 type_text = mojomToCType(mojomConstant.Type, fileGraph) |
199 } | 199 } |
200 name := mojomToCName(*mojomConstant.DeclData.FullIdentifier) | 200 name := mojomToCName(*mojomConstant.DeclData.FullIdentifier) |
201 if isReservedKeyword(name) { | 201 if isReservedKeyword(name) { |
202 log.Fatalf("Generated name %s is a reserved C keyword", name) | 202 log.Fatalf("Generated name %s is a reserved C keyword", name) |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 if m != 0 { | 452 if m != 0 { |
453 return kAlignment - int(m) | 453 return kAlignment - int(m) |
454 } | 454 } |
455 return 0 | 455 return 0 |
456 } | 456 } |
457 | 457 |
458 // (next element's offset) | 458 // (next element's offset) |
459 // - (current element's offset + current element's size) | 459 // - (current element's offset + current element's size) |
460 return intmax(int(fields[i+1].Offset)-(int(fields[i].Offset)+mojomTypeSi
ze(fields[i].Type, fileGraph)), 0) | 460 return intmax(int(fields[i+1].Offset)-(int(fields[i].Offset)+mojomTypeSi
ze(fields[i].Type, fileGraph)), 0) |
461 } | 461 } |
OLD | NEW |