| 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 // The dart:mirrors library provides reflective access for Dart program. | |
| 6 // | |
| 7 // For the purposes of the mirrors library, we adopt a naming | |
| 8 // convention with respect to getters and setters. Specifically, for | |
| 9 // some variable or field... | |
| 10 // | |
| 11 // var myField; | |
| 12 // | |
| 13 // ...the getter is named 'myField' and the setter is named | |
| 14 // 'myField='. This allows us to assign unique names to getters and | |
| 15 // setters for the purposes of member lookup. | |
| 16 | |
| 17 // #library("mirrors"); | |
| 18 | |
| 19 /** | 5 /** |
| 20 * A [MirrorSystem] is the main interface used to reflect on a set of | 6 * A [MirrorSystem] is the main interface used to reflect on a set of |
| 21 * associated libraries. | 7 * associated libraries. |
| 22 * | 8 * |
| 23 * At runtime each running isolate has a distinct [MirrorSystem]. | 9 * At runtime each running isolate has a distinct [MirrorSystem]. |
| 24 * | 10 * |
| 25 * It is also possible to have a [MirrorSystem] which represents a set | 11 * It is also possible to have a [MirrorSystem] which represents a set |
| 26 * of libraries which are not running -- perhaps at compile-time. In | 12 * of libraries which are not running -- perhaps at compile-time. In |
| 27 * this case, all available reflective functionality would be | 13 * this case, all available reflective functionality would be |
| 28 * supported, but runtime functionality (such as invoking a function | 14 * supported, but runtime functionality (such as invoking a function |
| (...skipping 19 matching lines...) Expand all Loading... |
| 48 | 34 |
| 49 /** | 35 /** |
| 50 * A mirror on the [:void:] type. | 36 * A mirror on the [:void:] type. |
| 51 */ | 37 */ |
| 52 TypeMirror get voidType; | 38 TypeMirror get voidType; |
| 53 } | 39 } |
| 54 | 40 |
| 55 /** | 41 /** |
| 56 * Returns a [MirrorSystem] for the current isolate. | 42 * Returns a [MirrorSystem] for the current isolate. |
| 57 */ | 43 */ |
| 58 MirrorSystem currentMirrorSystem() { | 44 external MirrorSystem currentMirrorSystem(); |
| 59 return _Mirrors.currentMirrorSystem(); | |
| 60 } | |
| 61 | 45 |
| 62 /** | 46 /** |
| 63 * Creates a [MirrorSystem] for the isolate which is listening on | 47 * Creates a [MirrorSystem] for the isolate which is listening on |
| 64 * the [SendPort]. | 48 * the [SendPort]. |
| 65 */ | 49 */ |
| 66 Future<MirrorSystem> mirrorSystemOf(SendPort port) { | 50 external Future<MirrorSystem> mirrorSystemOf(SendPort port); |
| 67 return _Mirrors.mirrorSystemOf(port); | |
| 68 } | |
| 69 | 51 |
| 70 /** | 52 /** |
| 71 * Returns an [InstanceMirror] for some Dart language object. | 53 * Returns an [InstanceMirror] for some Dart language object. |
| 72 * | 54 * |
| 73 * This only works if this mirror system is associated with the | 55 * This only works if this mirror system is associated with the |
| 74 * current running isolate. | 56 * current running isolate. |
| 75 */ | 57 */ |
| 76 InstanceMirror reflect(Object reflectee) { | 58 external InstanceMirror reflect(Object reflectee); |
| 77 return _Mirrors.reflect(reflectee); | |
| 78 } | |
| 79 | 59 |
| 80 /** | 60 /** |
| 81 * A [Mirror] reflects some Dart language entity. | 61 * A [Mirror] reflects some Dart language entity. |
| 82 * | 62 * |
| 83 * Every [Mirror] originates from some [MirrorSystem]. | 63 * Every [Mirror] originates from some [MirrorSystem]. |
| 84 */ | 64 */ |
| 85 abstract class Mirror { | 65 abstract class Mirror { |
| 86 /** | 66 /** |
| 87 * The [MirrorSystem] that contains this mirror. | 67 * The [MirrorSystem] that contains this mirror. |
| 88 */ | 68 */ |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 | 716 |
| 737 /** | 717 /** |
| 738 * A [MirrorException] is used to indicate errors within the mirrors | 718 * A [MirrorException] is used to indicate errors within the mirrors |
| 739 * framework. | 719 * framework. |
| 740 */ | 720 */ |
| 741 class MirrorException implements Exception { | 721 class MirrorException implements Exception { |
| 742 const MirrorException(String this._message); | 722 const MirrorException(String this._message); |
| 743 String toString() => "MirrorException: '$_message'"; | 723 String toString() => "MirrorException: '$_message'"; |
| 744 final String _message; | 724 final String _message; |
| 745 } | 725 } |
| OLD | NEW |