| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * This file contains code to generate serialization/deserialization logic for | 6 * This file contains code to generate serialization/deserialization logic for |
| 7 * summaries based on an "IDL" description of the summary format (written in | 7 * summaries based on an "IDL" description of the summary format (written in |
| 8 * stylized Dart). | 8 * stylized Dart). |
| 9 * | 9 * |
| 10 * For each class in the "IDL" input, two corresponding classes are generated: | 10 * For each class in the "IDL" input, two corresponding classes are generated: |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 out('$typeStr _$fieldName;'); | 310 out('$typeStr _$fieldName;'); |
| 311 } | 311 } |
| 312 // Generate getters and setters. | 312 // Generate getters and setters. |
| 313 for (idlModel.FieldDeclaration field in cls.fields) { | 313 for (idlModel.FieldDeclaration field in cls.fields) { |
| 314 String fieldName = field.name; | 314 String fieldName = field.name; |
| 315 String typeStr = encodedType(field.type); | 315 String typeStr = encodedType(field.type); |
| 316 String def = defaultValue(field.type); | 316 String def = defaultValue(field.type); |
| 317 String defSuffix = def == null ? '' : ' ?? $def'; | 317 String defSuffix = def == null ? '' : ' ?? $def'; |
| 318 out(); | 318 out(); |
| 319 out('@override'); | 319 out('@override'); |
| 320 out('${dartType(field.type)} get $fieldName => _$fieldName$defSuffix;'); | 320 out('$typeStr get $fieldName => _$fieldName$defSuffix;'); |
| 321 out(); | 321 out(); |
| 322 outDoc(field.documentation); | 322 outDoc(field.documentation); |
| 323 constructorParams.add('$typeStr $fieldName'); | 323 constructorParams.add('$typeStr $fieldName'); |
| 324 out('void set $fieldName($typeStr _value) {'); | 324 out('void set $fieldName($typeStr _value) {'); |
| 325 indent(() { | 325 indent(() { |
| 326 String stateFieldName = '_' + fieldName; | 326 String stateFieldName = '_' + fieldName; |
| 327 out('assert(!_finished);'); | 327 out('assert(!_finished);'); |
| 328 out('$stateFieldName = _value;'); | 328 out('$stateFieldName = _value;'); |
| 329 }); | 329 }); |
| 330 out('}'); | 330 out('}'); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 return token.lexeme.split('\n').map((String line) { | 620 return token.lexeme.split('\n').map((String line) { |
| 621 if (line.startsWith(indent)) { | 621 if (line.startsWith(indent)) { |
| 622 line = line.substring(indent.length); | 622 line = line.substring(indent.length); |
| 623 } | 623 } |
| 624 return line; | 624 return line; |
| 625 }).join('\n'); | 625 }).join('\n'); |
| 626 } | 626 } |
| 627 return null; | 627 return null; |
| 628 } | 628 } |
| 629 } | 629 } |
| OLD | NEW |