| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library codegen.protocol; | 5 library codegen.protocol; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'api.dart'; | 9 import 'api.dart'; |
| 10 import 'codegen_tools.dart'; | 10 import 'codegen_tools.dart'; |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 keyCode = toJsonCode(resolvedType.keyType); | 469 keyCode = toJsonCode(resolvedType.keyType); |
| 470 } else { | 470 } else { |
| 471 keyCode = new ToJsonIdentity(dartType(resolvedType.keyType)); | 471 keyCode = new ToJsonIdentity(dartType(resolvedType.keyType)); |
| 472 } | 472 } |
| 473 ToJsonCode valueCode = toJsonCode(resolvedType.valueType); | 473 ToJsonCode valueCode = toJsonCode(resolvedType.valueType); |
| 474 if (keyCode.isIdentity && valueCode.isIdentity) { | 474 if (keyCode.isIdentity && valueCode.isIdentity) { |
| 475 return new ToJsonIdentity(dartType(resolvedType)); | 475 return new ToJsonIdentity(dartType(resolvedType)); |
| 476 } else { | 476 } else { |
| 477 return new ToJsonSnippet(dartType(type), (String value) { | 477 return new ToJsonSnippet(dartType(type), (String value) { |
| 478 StringBuffer result = new StringBuffer(); | 478 StringBuffer result = new StringBuffer(); |
| 479 result.write('_mapMap($value'); | 479 result.write('mapMap($value'); |
| 480 if (!keyCode.isIdentity) { | 480 if (!keyCode.isIdentity) { |
| 481 result.write(', keyCallback: ${keyCode.asClosure}'); | 481 result.write(', keyCallback: ${keyCode.asClosure}'); |
| 482 } | 482 } |
| 483 if (!valueCode.isIdentity) { | 483 if (!valueCode.isIdentity) { |
| 484 result.write(', valueCallback: ${valueCode.asClosure}'); | 484 result.write(', valueCallback: ${valueCode.asClosure}'); |
| 485 } | 485 } |
| 486 result.write(')'); | 486 result.write(')'); |
| 487 return result.toString(); | 487 return result.toString(); |
| 488 }); | 488 }); |
| 489 } | 489 } |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi()); | 828 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi()); |
| 829 return visitor.collectCode(visitor.visitApi); | 829 return visitor.collectCode(visitor.visitApi); |
| 830 }); | 830 }); |
| 831 | 831 |
| 832 /** | 832 /** |
| 833 * Translate spec_input.html into protocol_matchers.dart. | 833 * Translate spec_input.html into protocol_matchers.dart. |
| 834 */ | 834 */ |
| 835 main() { | 835 main() { |
| 836 target.generate(); | 836 target.generate(); |
| 837 } | 837 } |
| OLD | NEW |