Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: mojom/generators/c/cgen/header.go

Issue 2072903002: C bindings pt3: Type table definitions and barebones files to get generated code to compile. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: elem_table -> elem_descriptor Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/mojom_tool/bin/mac64/generators/c.sha1 ('k') | mojom/generators/c/cgen/type_table.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698