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

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

Issue 2163793002: C bindings: Implement _Validate(), and some pre-requisites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address comments Created 4 years, 4 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 } 441 }
442 442
443 func getPaddingAfter(fields []mojom_types.StructField, i int, fileGraph *mojom_f iles.MojomFileGraph) uint32 { 443 func getPaddingAfter(fields []mojom_types.StructField, i int, fileGraph *mojom_f iles.MojomFileGraph) uint32 {
444 // Must be a power of 2 for the remaining computation to work 444 // Must be a power of 2 for the remaining computation to work
445 const kAlignment uint32 = 8 445 const kAlignment uint32 = 8
446 446
447 // Calculate the remaining padding for the last field 447 // Calculate the remaining padding for the last field
448 if i == len(fields)-1 { 448 if i == len(fields)-1 {
449 // m = (field offset + field size) % kAlignment 449 // m = (field offset + field size) % kAlignment
450 » » m := (fields[i].Offset + mojomTypeSize(fields[i].Type, fileGraph )) & (kAlignment - 1) 450 » » m := (fields[i].Offset + mojomTypeByteSize(fields[i].Type, fileG raph)) & (kAlignment - 1)
451 if m != 0 { 451 if m != 0 {
452 return kAlignment - m 452 return kAlignment - m
453 } 453 }
454 return 0 454 return 0
455 } 455 }
456 456
457 // (next element's offset) 457 // (next element's offset)
458 // - (current element's offset + current element's size) 458 // - (current element's offset + current element's size)
459 » diff := int64(fields[i+1].Offset) - (int64(fields[i].Offset) + int64(moj omTypeSize(fields[i].Type, fileGraph))) 459 » diff := int64(fields[i+1].Offset) - (int64(fields[i].Offset) + int64(moj omTypeByteSize(fields[i].Type, fileGraph)))
460 if diff <= 0 { 460 if diff <= 0 {
461 return 0 461 return 0
462 } 462 }
463 return uint32(diff) 463 return uint32(diff)
464 } 464 }
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