| 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 // Write getters. | 538 // Write getters. |
| 539 cls.fields.asMap().forEach((index, field) { | 539 cls.fields.asMap().forEach((index, field) { |
| 540 String fieldName = field.name; | 540 String fieldName = field.name; |
| 541 idlModel.FieldType type = field.type; | 541 idlModel.FieldType type = field.type; |
| 542 String typeName = type.typeName; | 542 String typeName = type.typeName; |
| 543 // Prepare "readCode" + "def" | 543 // Prepare "readCode" + "def" |
| 544 String readCode; | 544 String readCode; |
| 545 String def = defaultValue(type, false); | 545 String def = defaultValue(type, false); |
| 546 if (type.isList) { | 546 if (type.isList) { |
| 547 if (typeName == 'int') { | 547 if (typeName == 'int') { |
| 548 String itemCode = 'const fb.Uint32Reader()'; | 548 readCode = 'const fb.Uint32ListReader()'; |
| 549 readCode = 'const fb.ListReader<int>($itemCode)'; | |
| 550 } else if (typeName == 'double') { | 549 } else if (typeName == 'double') { |
| 551 readCode = 'const fb.Float64ListReader()'; | 550 readCode = 'const fb.Float64ListReader()'; |
| 552 } else if (typeName == 'String') { | 551 } else if (typeName == 'String') { |
| 553 String itemCode = 'const fb.StringReader()'; | 552 String itemCode = 'const fb.StringReader()'; |
| 554 readCode = 'const fb.ListReader<String>($itemCode)'; | 553 readCode = 'const fb.ListReader<String>($itemCode)'; |
| 555 } else if (_idl.classes.containsKey(typeName)) { | 554 } else if (_idl.classes.containsKey(typeName)) { |
| 556 String itemCode = 'const _${typeName}Reader()'; | 555 String itemCode = 'const _${typeName}Reader()'; |
| 557 readCode = 'const fb.ListReader<${idlPrefix(typeName)}>($itemCode)'; | 556 readCode = 'const fb.ListReader<${idlPrefix(typeName)}>($itemCode)'; |
| 558 } else { | 557 } else { |
| 559 assert(_idl.enums.containsKey(typeName)); | 558 assert(_idl.enums.containsKey(typeName)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 return token.lexeme.split('\n').map((String line) { | 646 return token.lexeme.split('\n').map((String line) { |
| 648 if (line.startsWith(indent)) { | 647 if (line.startsWith(indent)) { |
| 649 line = line.substring(indent.length); | 648 line = line.substring(indent.length); |
| 650 } | 649 } |
| 651 return line; | 650 return line; |
| 652 }).join('\n'); | 651 }).join('\n'); |
| 653 } | 652 } |
| 654 return null; | 653 return null; |
| 655 } | 654 } |
| 656 } | 655 } |
| OLD | NEW |