Chromium Code Reviews| 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 'package:html5lib/dom.dart' as dom; | 9 import 'package:html5lib/dom.dart' as dom; |
| 10 | 10 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 } | 247 } |
| 248 for (TypeEnumValue value in type.values) { | 248 for (TypeEnumValue value in type.values) { |
| 249 docComment(toHtmlVisitor.collectHtml(() { | 249 docComment(toHtmlVisitor.collectHtml(() { |
| 250 toHtmlVisitor.translateHtml(value.html); | 250 toHtmlVisitor.translateHtml(value.html); |
| 251 })); | 251 })); |
| 252 String valueString = literalString(value.value); | 252 String valueString = literalString(value.value); |
| 253 writeln( | 253 writeln( |
| 254 'static const ${value.value} = const $className._($valueString);'); | 254 'static const ${value.value} = const $className._($valueString);'); |
| 255 writeln(); | 255 writeln(); |
| 256 } | 256 } |
| 257 | |
| 258 writeln('/**'); | |
| 259 writeln(' * A list containing all of the services that are defined.'); | |
|
Paul Berry
2015/01/20 17:28:11
This looks like it will run on all enums, not just
Brian Wilkerson
2015/01/20 17:46:35
Done.
| |
| 260 writeln(' */'); | |
| 261 write('static const List<'); | |
| 262 write(className); | |
| 263 write('> VALUES = const <'); | |
| 264 write(className); | |
| 265 write('>['); | |
| 266 bool first = true; | |
| 267 for (TypeEnumValue value in type.values) { | |
| 268 if (first) { | |
| 269 first = false; | |
| 270 } else { | |
| 271 write(', '); | |
| 272 } | |
| 273 write(value.value); | |
| 274 } | |
| 275 writeln('];'); | |
| 276 writeln(); | |
| 277 | |
| 257 writeln('final String name;'); | 278 writeln('final String name;'); |
| 258 writeln(); | 279 writeln(); |
| 259 writeln('const $className._(this.name);'); | 280 writeln('const $className._(this.name);'); |
| 260 writeln(); | 281 writeln(); |
| 261 emitEnumClassConstructor(className, type); | 282 emitEnumClassConstructor(className, type); |
| 262 writeln(); | 283 writeln(); |
| 263 emitEnumFromJsonConstructor(className, type, impliedType); | 284 emitEnumFromJsonConstructor(className, type, impliedType); |
| 264 writeln(); | 285 writeln(); |
| 265 if (emitSpecialConstructors(className)) { | 286 if (emitSpecialConstructors(className)) { |
| 266 writeln(); | 287 writeln(); |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1173 | 1194 |
| 1174 @override | 1195 @override |
| 1175 String get asClosure => '($type value) => ${callback('value')}'; | 1196 String get asClosure => '($type value) => ${callback('value')}'; |
| 1176 | 1197 |
| 1177 @override | 1198 @override |
| 1178 bool get isIdentity => false; | 1199 bool get isIdentity => false; |
| 1179 | 1200 |
| 1180 @override | 1201 @override |
| 1181 String asSnippet(String value) => callback(value); | 1202 String asSnippet(String value) => callback(value); |
| 1182 } | 1203 } |
| OLD | NEW |