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 "fmt" | 8 "fmt" |
9 "mojo/public/go/bindings" | 9 "mojo/public/go/bindings" |
10 "mojom/mojom_parser/generated/mojom_files" | 10 "mojom/mojom_parser/generated/mojom_files" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 saveEmitLineAndColumnNumbers := emitLineAndColumnNumbers | 45 saveEmitLineAndColumnNumbers := emitLineAndColumnNumbers |
46 emitLineAndColumnNumbers = emitLineAndColumnNumbersParam | 46 emitLineAndColumnNumbers = emitLineAndColumnNumbersParam |
47 saveEmitSerializedRuntimeTypeInfo := emitSerializedRuntimeTypeInfo | 47 saveEmitSerializedRuntimeTypeInfo := emitSerializedRuntimeTypeInfo |
48 emitSerializedRuntimeTypeInfo = emitSerializedRuntimeTypeInfoParam | 48 emitSerializedRuntimeTypeInfo = emitSerializedRuntimeTypeInfoParam |
49 | 49 |
50 fileGraph := translateDescriptor(d) | 50 fileGraph := translateDescriptor(d) |
51 if debug { | 51 if debug { |
52 debugString = myfmt.Sprintf("%#v", fileGraph) | 52 debugString = myfmt.Sprintf("%#v", fileGraph) |
53 } | 53 } |
54 encoder := bindings.NewEncoder() | 54 encoder := bindings.NewEncoder() |
| 55 encoder.SetDeterministic(true) |
55 fileGraph.Encode(encoder) | 56 fileGraph.Encode(encoder) |
56 bytes, _, err = encoder.Data() | 57 bytes, _, err = encoder.Data() |
57 | 58 |
58 emitLineAndColumnNumbers = saveEmitLineAndColumnNumbers | 59 emitLineAndColumnNumbers = saveEmitLineAndColumnNumbers |
59 emitSerializedRuntimeTypeInfo = saveEmitSerializedRuntimeTypeInfo | 60 emitSerializedRuntimeTypeInfo = saveEmitSerializedRuntimeTypeInfo |
60 return | 61 return |
61 } | 62 } |
62 | 63 |
63 // translateDescriptor translates from a mojom.MojomDescriptor (the pure Go | 64 // translateDescriptor translates from a mojom.MojomDescriptor (the pure Go |
64 // representation used by the parser) to a mojom_files.MojomFileGraph (the | 65 // representation used by the parser) to a mojom_files.MojomFileGraph (the |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 201 } |
201 } | 202 } |
202 | 203 |
203 // TODO(rudominer) Do we need the EmbeddedEnums and EmbeddedConstants | 204 // TODO(rudominer) Do we need the EmbeddedEnums and EmbeddedConstants |
204 // fields in KeysByType. It seems these fields are not currently being | 205 // fields in KeysByType. It seems these fields are not currently being |
205 // used in mojom_translator.py. | 206 // used in mojom_translator.py. |
206 | 207 |
207 // SerializedRuntimeTypeInfo | 208 // SerializedRuntimeTypeInfo |
208 if emitSerializedRuntimeTypeInfo { | 209 if emitSerializedRuntimeTypeInfo { |
209 encoder := bindings.NewEncoder() | 210 encoder := bindings.NewEncoder() |
| 211 encoder.SetDeterministic(true) |
210 typeInfo.Encode(encoder) | 212 typeInfo.Encode(encoder) |
211 bytes, _, err := encoder.Data() | 213 bytes, _, err := encoder.Data() |
212 if err != nil { | 214 if err != nil { |
213 panic(fmt.Sprintf("Error while serializing runtimeTypeIn
fo: %s", err.Error())) | 215 panic(fmt.Sprintf("Error while serializing runtimeTypeIn
fo: %s", err.Error())) |
214 } | 216 } |
215 file.SerializedRuntimeTypeInfo = &bytes | 217 file.SerializedRuntimeTypeInfo = &bytes |
216 } | 218 } |
217 | 219 |
218 return | 220 return |
219 } | 221 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 | 673 |
672 // stringPointer is a convenience function for creating a pointer to a string wh
ose value | 674 // stringPointer is a convenience function for creating a pointer to a string wh
ose value |
673 // is the specified string. It may be used in situations where the compiler will | 675 // is the specified string. It may be used in situations where the compiler will |
674 // not allow you to take the address of a string value directly, such as the | 676 // not allow you to take the address of a string value directly, such as the |
675 // return value of a function. It is necessary to create pointers to strings bec
ause | 677 // return value of a function. It is necessary to create pointers to strings bec
ause |
676 // that is how the Mojom type |string?| (i.e. nullable string) is represented in | 678 // that is how the Mojom type |string?| (i.e. nullable string) is represented in |
677 // in the Mojom Go bindings. | 679 // in the Mojom Go bindings. |
678 func stringPointer(s string) *string { | 680 func stringPointer(s string) *string { |
679 return &s | 681 return &s |
680 } | 682 } |
OLD | NEW |