Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // For the purposes of the mirrors library, we adopt a naming | 5 // For the purposes of the mirrors library, we adopt a naming |
| 6 // convention with respect to getters and setters. Specifically, for | 6 // convention with respect to getters and setters. Specifically, for |
| 7 // some variable or field... | 7 // some variable or field... |
| 8 // | 8 // |
| 9 // var myField; | 9 // var myField; |
| 10 // | 10 // |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 | 105 |
| 106 /** | 106 /** |
| 107 * Creates a [MirrorSystem] for the isolate which is listening on | 107 * Creates a [MirrorSystem] for the isolate which is listening on |
| 108 * the [SendPort]. | 108 * the [SendPort]. |
| 109 */ | 109 */ |
| 110 external Future<MirrorSystem> mirrorSystemOf(SendPort port); | 110 external Future<MirrorSystem> mirrorSystemOf(SendPort port); |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * Returns an [InstanceMirror] for some Dart language object. | 113 * Returns an [InstanceMirror] for some Dart language object. |
| 114 * | 114 * |
| 115 * This only works if this mirror system is associated with the | 115 * This only works with objects local to the current isolate. |
| 116 * current running isolate. | |
| 117 */ | 116 */ |
| 118 external InstanceMirror reflect(Object reflectee); | 117 external InstanceMirror reflect(Object reflectee); |
| 119 | 118 |
| 120 /** | 119 /** |
| 121 * Returns a [ClassMirror] for the class represented by a Dart | 120 * Returns a [ClassMirror] for the class represented by a Dart |
| 122 * Type object. | 121 * Type object. |
| 123 * | 122 * |
| 124 * This only works with objects local to the current isolate. | 123 * This only works with objects local to the current isolate. |
| 125 */ | 124 */ |
| 126 external ClassMirror reflectClass(Type key); | 125 external ClassMirror reflectClass(Type key); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 */ | 217 */ |
| 219 bool get isTopLevel; | 218 bool get isTopLevel; |
| 220 | 219 |
| 221 /** | 220 /** |
| 222 * The source location of this Dart language entity. | 221 * The source location of this Dart language entity. |
| 223 */ | 222 */ |
| 224 SourceLocation get location; | 223 SourceLocation get location; |
| 225 | 224 |
| 226 /** | 225 /** |
| 227 * A list of the metadata associated with this declaration. | 226 * A list of the metadata associated with this declaration. |
| 227 * | |
| 228 * Let D be the declaration this mirror reflects. | |
| 229 * If D is decorated with annotations A1, ..., An | |
|
ahe
2013/06/11 08:48:10
Add * around the greek.
gbracha
2013/06/12 21:21:18
Done.
| |
| 230 * where n > 0, then for each annotation Ai associated | |
| 231 * with D, 1 <= i <= n, let ci be the constant object | |
| 232 * specified by Ai. Then this method returns a list whose | |
| 233 * members are instance mirrors on c1, ..., cn. | |
| 234 * If no annotations are associated with D, then | |
| 235 * an empty list is returned. | |
| 228 */ | 236 */ |
| 229 List<InstanceMirror> get metadata; | 237 List<InstanceMirror> get metadata; |
| 230 } | 238 } |
| 231 | 239 |
| 232 /** | 240 /** |
| 233 * An [ObjectMirror] is a common superinterface of [InstanceMirror], | 241 * An [ObjectMirror] is a common superinterface of [InstanceMirror], |
| 234 * [ClassMirror], and [LibraryMirror] that represents their shared | 242 * [ClassMirror], and [LibraryMirror] that represents their shared |
| 235 * functionality. | 243 * functionality. |
| 236 * | 244 * |
| 237 * For the purposes of the mirrors library, these types are all | 245 * For the purposes of the mirrors library, these types are all |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 * *o.f = a* | 310 * *o.f = a* |
| 303 * in a scope that has access to the private members | 311 * in a scope that has access to the private members |
| 304 * of *o* (if *o* is a class or library) or the private members of the | 312 * of *o* (if *o* is a class or library) or the private members of the |
| 305 * class of *o* (otherwise). | 313 * class of *o* (otherwise). |
| 306 * If the invocation returns a result *r*, this method returns | 314 * If the invocation returns a result *r*, this method returns |
| 307 * the result of calling [reflect]([value]). | 315 * the result of calling [reflect]([value]). |
| 308 * If the invocation throws an exception *e* (that it does not catch) | 316 * If the invocation throws an exception *e* (that it does not catch) |
| 309 * the the result is a [MirrorError] wrapping *e*. | 317 * the the result is a [MirrorError] wrapping *e*. |
| 310 */ | 318 */ |
| 311 /* TODO(turnidge): Handle ambiguous names.*/ | 319 /* TODO(turnidge): Handle ambiguous names.*/ |
| 312 InstanceMirror setField(Symbol fieldName, Object arg); | 320 InstanceMirror setField(Symbol fieldName, Object value); |
| 313 | 321 |
| 314 /** | 322 /** |
| 315 * Invokes the named function and returns a mirror on the result. | 323 * Invokes the named function and returns a mirror on the result. |
| 316 * The arguments must be instances of [InstanceMirror], or of | 324 * The arguments must be instances of [InstanceMirror], or of |
| 317 * a type that is serializable across isolates (currently [num], | 325 * a type that is serializable across isolates (currently [num], |
| 318 * [String], or [bool]). | 326 * [String], or [bool]). |
| 319 * | 327 * |
| 320 * Let *o* be the object reflected by this mirror, let | 328 * Let *o* be the object reflected by this mirror, let |
| 321 * *f* be the simple name of the member denoted by [memberName], | 329 * *f* be the simple name of the member denoted by [memberName], |
| 322 * let *a1, ..., an* be the elements of [positionalArguments] | 330 * let *a1, ..., an* be the elements of [positionalArguments] |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 338 * If the invocation returns a result *r*, *k* will be completed | 346 * If the invocation returns a result *r*, *k* will be completed |
| 339 * with the result of calling [reflect](*r*). | 347 * with the result of calling [reflect](*r*). |
| 340 * If the invocation throws an exception *e* (that it does not catch) | 348 * If the invocation throws an exception *e* (that it does not catch) |
| 341 * then *k* is completed with a [MirrorError] wrapping *e*. | 349 * then *k* is completed with a [MirrorError] wrapping *e*. |
| 342 */ | 350 */ |
| 343 /* | 351 /* |
| 344 * TODO(turnidge): Handle ambiguous names. | 352 * TODO(turnidge): Handle ambiguous names. |
| 345 * TODO(turnidge): Handle optional & named arguments. | 353 * TODO(turnidge): Handle optional & named arguments. |
| 346 */ | 354 */ |
| 347 Future<InstanceMirror> invokeAsync(Symbol memberName, | 355 Future<InstanceMirror> invokeAsync(Symbol memberName, |
| 348 List<Object> positionalArguments, | 356 List positionalArguments, |
| 349 [Map<Symbol, Object> namedArguments]); | 357 [Map<Symbol, dynamic> namedArguments]); |
| 350 | 358 |
| 351 /** | 359 /** |
| 352 * Invokes a getter and returns a mirror on the result. The getter | 360 * Invokes a getter and returns a mirror on the result. The getter |
| 353 * can be the implicit getter for a field or a user-defined getter | 361 * can be the implicit getter for a field or a user-defined getter |
| 354 * method. | 362 * method. |
| 355 * | 363 * |
| 356 * Let *o* be the object reflected by this mirror, let | 364 * Let *o* be the object reflected by this mirror, let |
| 357 * *f* be the simple name of the getter denoted by [fieldName], | 365 * *f* be the simple name of the getter denoted by [fieldName], |
| 358 * Then this method will perform the getter invocation | 366 * Then this method will perform the getter invocation |
| 359 * *o.f* | 367 * *o.f* |
| 360 * in a scope that has access to the private members | 368 * in a scope that has access to the private members |
| 361 * of *o* (if *o* is a class or library) or the private members of the | 369 * of *o* (if *o* is a class or library) or the private members of the |
| 362 * class of *o*(otherwise). | 370 * class of *o*(otherwise). |
| 363 * The method returns a future *k*. | 371 * The method returns a future *k*. |
| 364 * If the invocation returns a result *r*, *k* will be completed | 372 * If the invocation returns a result *r*, *k* will be completed |
| 365 * with the result of calling [reflect](*r*). | 373 * with the result of calling [reflect](*r*). |
| 366 * If the invocation throws an exception *e* (that it does not catch) | 374 * If the invocation throws an exception *e* (that it does not catch) |
| 367 * then *k* is completed with a [MirrorError] wrapping *e*. | 375 * then *k* is completed with a [MirrorError] wrapping *e*. |
| 368 */ | 376 */ |
| 369 /* TODO(turnidge): Handle ambiguous names.*/ | 377 /* TODO(turnidge): Handle ambiguous names.*/ |
| 370 Future<InstanceMirror> getFieldAsync(Symbol fieldName); | 378 Future<InstanceMirror> getFieldAsync(Symbol fieldName); |
| 371 | 379 |
| 372 /** | 380 /** |
| 373 * Invokes a setter and returns a mirror on the result. The setter | 381 * Invokes a setter and returns a mirror on the result. The setter |
| 374 * may be either the implicit setter for a non-final field or a | 382 * may be either the implicit setter for a non-final field or a |
| 375 * user-defined setter method. | 383 * user-defined setter method. |
| 376 * The argument must be an instance of [InstanceMirror], or of | 384 * The second argument must be an instance of [InstanceMirror], or of |
| 377 * a type that is serializable across isolates (currently [num], | 385 * a type that is serializable across isolates (currently [num], |
| 378 * [String], or [bool]). | 386 * [String], or [bool]). |
| 379 * | 387 * |
| 380 * Let *o* be the object reflected by this mirror, let | 388 * Let *o* be the object reflected by this mirror, let |
| 381 * *f* be the simple name of the getter denoted by [fieldName], | 389 * *f* be the simple name of the getter denoted by [fieldName], |
| 382 * and let a be the object bound to [value]. If *a* is an instance of | 390 * and let a be the object bound to [value]. If *a* is an instance of |
| 383 * [InstanceMirror] let *p* be the object | 391 * [InstanceMirror] let *p* be the object |
| 384 * reflected by *a*, otherwise let *p =a*. | 392 * reflected by *a*, otherwise let *p =a*. |
| 385 * If *p* is not an instance of [InstanceMirror], *p* must be | 393 * If *p* is not an instance of [InstanceMirror], *p* must be |
| 386 * serializable across isolates or an exception is thrown. | 394 * serializable across isolates or an exception is thrown. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 * let *k1, ..., km* be the identifiers denoted by the elements of | 482 * let *k1, ..., km* be the identifiers denoted by the elements of |
| 475 * [namedArguments.keys] | 483 * [namedArguments.keys] |
| 476 * and let *v1, ..., vm* be the elements of [namedArguments.values]. | 484 * and let *v1, ..., vm* be the elements of [namedArguments.values]. |
| 477 * Then this method will perform the method invocation | 485 * Then this method will perform the method invocation |
| 478 * *f(a1, ..., an, k1: v1, ..., km: vm)* | 486 * *f(a1, ..., an, k1: v1, ..., km: vm)* |
| 479 * If the invocation returns a result *r*, this method returns | 487 * If the invocation returns a result *r*, this method returns |
| 480 * the result of calling [reflect](*r*). | 488 * the result of calling [reflect](*r*). |
| 481 * If the invocation throws an exception *e* (that it does not catch) | 489 * If the invocation throws an exception *e* (that it does not catch) |
| 482 * the the result is a [MirrorError] wrapping *e*. | 490 * the the result is a [MirrorError] wrapping *e*. |
| 483 */ | 491 */ |
| 484 InstanceMirror apply(List<Object> positionalArguments, | 492 InstanceMirror apply(List positionalArguments, |
| 485 [Map<Symbol,Object> namedArguments]); | 493 [Map<Symbol,dynamic> namedArguments]); |
|
ahe
2013/06/11 08:48:10
Add space after comma.
gbracha
2013/06/12 21:21:18
Done.
| |
| 486 | 494 |
| 487 /** | 495 /** |
| 488 * Executes the closure and returns a mirror on the result. | 496 * Executes the closure and returns a mirror on the result. |
| 489 * | 497 * |
| 490 * Let *f* be the closure reflected by this mirror, | 498 * Let *f* be the closure reflected by this mirror, |
| 491 * let *a1, ..., an* be the elements of [positionalArguments] | 499 * let *a1, ..., an* be the elements of [positionalArguments] |
| 492 * let *k1, ..., km* be the identifiers denoted by the elements of | 500 * let *k1, ..., km* be the identifiers denoted by the elements of |
| 493 * [namedArguments.keys] | 501 * [namedArguments.keys] |
| 494 * and let *v1, ..., vm* be the elements of [namedArguments.values]. | 502 * and let *v1, ..., vm* be the elements of [namedArguments.values]. |
| 495 * For each *ai*, if *ai* is an instance of [InstanceMirror], let *pi* | 503 * For each *ai*, if *ai* is an instance of [InstanceMirror], let *pi* |
| 496 * be the object reflected by *ai*; otherwise let *pi = ai, i in 1 ...n*. | 504 * be the object reflected by *ai*; otherwise let *pi = ai, i in 1 ...n*. |
| 497 * Likewise, for each *vj*, if *vj* is an instance of [InstanceMirror], let | 505 * Likewise, for each *vj*, if *vj* is an instance of [InstanceMirror], let |
| 498 * *qj* | 506 * *qj* |
| 499 * be the object reflected by *vj*; otherwise let *qj = vj, j in 1 ...m*. | 507 * be the object reflected by *vj*; otherwise let *qj = vj, j in 1 ...m*. |
| 500 * If any of the *pi, qj* is not an instance of [InstanceMirror] and | 508 * If any of the *pi, qj* is not an instance of [InstanceMirror] and |
| 501 * is not serializable across isolates, an exception is thrown. | 509 * is not serializable across isolates, an exception is thrown. |
| 502 * Then this method will perform the function invocation | 510 * Then this method will perform the function invocation |
| 503 * *f(p1, ..., pn, k1: q1, ..., km: qm)* | 511 * *f(p1, ..., pn, k1: q1, ..., km: qm)* |
| 504 * The method returns a future *k*. | 512 * The method returns a future *k*. |
| 505 * If the invocation returns a result *r*, *k* will be completed | 513 * If the invocation returns a result *r*, *k* will be completed |
| 506 * with the result of calling [reflect](*r*). | 514 * with the result of calling [reflect](*r*). |
| 507 * If the invocation throws an exception *e* (that it does not catch) | 515 * If the invocation throws an exception *e* (that it does not catch) |
| 508 * then *k* is completed with a [MirrorError] wrapping *e*. | 516 * then *k* is completed with a [MirrorError] wrapping *e*. |
| 509 * | 517 * |
| 510 * The arguments must be instances of [InstanceMirror], or of | 518 * The arguments must be instances of [InstanceMirror], or of |
| 511 * a type that is serializable across isolates (currently [num], | 519 * a type that is serializable across isolates (currently [num], |
| 512 * [String], or [bool]). | 520 * [String], or [bool]). |
| 513 */ | 521 */ |
| 514 Future<InstanceMirror> applyAsync(List<Object> positionalArguments, | 522 Future<InstanceMirror> applyAsync(List positionalArguments, |
| 515 [Map<Symbol, Object> namedArguments]); | 523 [Map<Symbol, dynamic> namedArguments]); |
| 516 | 524 |
| 517 /** | 525 /** |
| 518 * Looks up the value of a name in the scope of the closure. The | 526 * Looks up the value of a name in the scope of the closure. The |
| 519 * result is a mirror on that value. | 527 * result is a mirror on that value. |
| 520 * | 528 * |
| 521 * Let *s* be the contents of the string used to construct the symbol [name]. | 529 * Let *s* be the contents of the string used to construct the symbol [name]. |
| 522 * | 530 * |
| 523 * If the expression *s* occurs within the source code of the reflectee, | 531 * If the expression *s* occurs within the source code of the reflectee, |
| 524 * and that any such occurrence refers to a declaration outside the reflectee, | 532 * and that any such occurrence refers to a declaration outside the reflectee, |
| 525 * then let *v* be the result of evaluating the expression *s* at such | 533 * then let *v* be the result of evaluating the expression *s* at such |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 * in a scope that has access to the private members | 755 * in a scope that has access to the private members |
| 748 * of *c*. | 756 * of *c*. |
| 749 * In either case: | 757 * In either case: |
| 750 * The method returns a future *k*. | 758 * The method returns a future *k*. |
| 751 * If the invocation returns a result *r*, *k* will be completed | 759 * If the invocation returns a result *r*, *k* will be completed |
| 752 * with the result of calling [reflect](*r*). | 760 * with the result of calling [reflect](*r*). |
| 753 * If the invocation throws an exception *e* (that it does not catch) | 761 * If the invocation throws an exception *e* (that it does not catch) |
| 754 * then *k* is completed with a [MirrorError] wrapping *e*. | 762 * then *k* is completed with a [MirrorError] wrapping *e*. |
| 755 */ | 763 */ |
| 756 Future<InstanceMirror> newInstanceAsync(Symbol constructorName, | 764 Future<InstanceMirror> newInstanceAsync(Symbol constructorName, |
| 757 List<Object> positionalArguments, | 765 List positionalArguments, |
| 758 [Map<Symbol, Object> namedArguments]); | 766 [Map<Symbol, dynamic> namedArguments]) ; |
| 759 | 767 |
| 760 /** | 768 /** |
| 761 * Does this mirror represent a class? | 769 * Does this mirror represent a class? |
| 762 * | 770 * |
| 763 * TODO(turnidge): This functions goes away after the | 771 * TODO(turnidge): This functions goes away after the |
| 764 * class/interface changes. | 772 * class/interface changes. |
| 765 */ | 773 */ |
| 766 bool get isClass; | 774 bool get isClass; |
| 767 | 775 |
| 768 /** | 776 /** |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1071 /** | 1079 /** |
| 1072 * Is [:true:] if this comment is a documentation comment. | 1080 * Is [:true:] if this comment is a documentation comment. |
| 1073 * | 1081 * |
| 1074 * That is, that the comment is either enclosed in [: /** ... */ :] or starts | 1082 * That is, that the comment is either enclosed in [: /** ... */ :] or starts |
| 1075 * with [: /// :]. | 1083 * with [: /// :]. |
| 1076 */ | 1084 */ |
| 1077 final bool isDocComment; | 1085 final bool isDocComment; |
| 1078 | 1086 |
| 1079 const Comment(this.text, this.trimmedText, this.isDocComment); | 1087 const Comment(this.text, this.trimmedText, this.isDocComment); |
| 1080 } | 1088 } |
| OLD | NEW |