| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 serialization | 5 package serialization |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "compress/gzip" | 9 "compress/gzip" |
| 10 "encoding/base64" | 10 "encoding/base64" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| 318 func translateStructField(f *mojom.StructField) (field mojom_types.StructField)
{ | 318 func translateStructField(f *mojom.StructField) (field mojom_types.StructField)
{ |
| 319 field.DeclData = translateDeclarationData(&f.DeclarationData) | 319 field.DeclData = translateDeclarationData(&f.DeclarationData) |
| 320 field.Type = translateTypeRef(f.FieldType) | 320 field.Type = translateTypeRef(f.FieldType) |
| 321 if f.DefaultValue != nil { | 321 if f.DefaultValue != nil { |
| 322 field.DefaultValue = translateDefaultFieldValue(f.DefaultValue) | 322 field.DefaultValue = translateDefaultFieldValue(f.DefaultValue) |
| 323 } | 323 } |
| 324 if emitComputedPackingData { | 324 if emitComputedPackingData { |
| 325 » » // TODO(rudominer) Check the allowed size of offsets. The type u
sed in | 325 » » field.Offset = f.Offset() |
| 326 » » // mojom_types.mojom might need to be changed. | |
| 327 » » field.Offset = int32(f.Offset()) | |
| 328 field.Bit = int8(f.Bit()) | 326 field.Bit = int8(f.Bit()) |
| 329 field.MinVersion = f.MinVersion() | 327 field.MinVersion = f.MinVersion() |
| 330 } | 328 } |
| 331 return | 329 return |
| 332 } | 330 } |
| 333 | 331 |
| 334 func translateDefaultFieldValue(v mojom.ValueRef) mojom_types.DefaultFieldValue
{ | 332 func translateDefaultFieldValue(v mojom.ValueRef) mojom_types.DefaultFieldValue
{ |
| 335 switch v := v.(type) { | 333 switch v := v.(type) { |
| 336 case mojom.LiteralValue: | 334 case mojom.LiteralValue: |
| 337 if v.IsDefault() { | 335 if v.IsDefault() { |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 | 745 |
| 748 // stringPointer is a convenience function for creating a pointer to a string wh
ose value | 746 // stringPointer is a convenience function for creating a pointer to a string wh
ose value |
| 749 // is the specified string. It may be used in situations where the compiler will | 747 // is the specified string. It may be used in situations where the compiler will |
| 750 // not allow you to take the address of a string value directly, such as the | 748 // not allow you to take the address of a string value directly, such as the |
| 751 // return value of a function. It is necessary to create pointers to strings bec
ause | 749 // return value of a function. It is necessary to create pointers to strings bec
ause |
| 752 // that is how the Mojom type |string?| (i.e. nullable string) is represented in | 750 // that is how the Mojom type |string?| (i.e. nullable string) is represented in |
| 753 // in the Mojom Go bindings. | 751 // in the Mojom Go bindings. |
| 754 func stringPointer(s string) *string { | 752 func stringPointer(s string) *string { |
| 755 return &s | 753 return &s |
| 756 } | 754 } |
| OLD | NEW |