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 // |
11 // ...the getter is named 'myField' and the setter is named | 11 // ...the getter is named 'myField' and the setter is named |
12 // 'myField='. This allows us to assign unique names to getters and | 12 // 'myField='. This allows us to assign unique names to getters and |
13 // setters for the purposes of member lookup. | 13 // setters for the purposes of member lookup. |
14 | 14 |
15 library dart.mirrors; | 15 library dart.mirrors; |
16 | 16 |
17 import 'dart:async'; | 17 import 'dart:async'; |
18 import 'dart:isolate'; | 18 import 'dart:isolate'; |
19 import 'dart:uri'; | |
19 | 20 |
20 /** | 21 /** |
21 * A [MirrorSystem] is the main interface used to reflect on a set of | 22 * A [MirrorSystem] is the main interface used to reflect on a set of |
22 * associated libraries. | 23 * associated libraries. |
23 * | 24 * |
24 * At runtime each running isolate has a distinct [MirrorSystem]. | 25 * At runtime each running isolate has a distinct [MirrorSystem]. |
25 * | 26 * |
26 * It is also possible to have a [MirrorSystem] which represents a set | 27 * It is also possible to have a [MirrorSystem] which represents a set |
27 * of libraries which are not running -- perhaps at compile-time. In | 28 * of libraries which are not running -- perhaps at compile-time. In |
28 * this case, all available reflective functionality would be | 29 * this case, all available reflective functionality would be |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 * For the purposes of the mirrors library, these types are all | 168 * For the purposes of the mirrors library, these types are all |
168 * object-like, in that they support method invocation and field | 169 * object-like, in that they support method invocation and field |
169 * access. Real Dart objects are represented by the [InstanceMirror] | 170 * access. Real Dart objects are represented by the [InstanceMirror] |
170 * type. | 171 * type. |
171 * | 172 * |
172 * See [InstanceMirror], [ClassMirror], and [LibraryMirror]. | 173 * See [InstanceMirror], [ClassMirror], and [LibraryMirror]. |
173 */ | 174 */ |
174 abstract class ObjectMirror implements Mirror { | 175 abstract class ObjectMirror implements Mirror { |
175 /** | 176 /** |
176 * Invokes the named function and returns a mirror on the result. | 177 * Invokes the named function and returns a mirror on the result. |
177 * The arguments must be instances of [InstanceMirror], [num], | 178 * The arguments must be instances of [InstanceMirror], [num], |
178 * [String] or [bool]. | 179 * [String] or [bool]. |
179 */ | 180 */ |
180 /* TODO(turnidge): Properly document. | 181 /* TODO(turnidge): Properly document. |
181 * TODO(turnidge): Handle ambiguous names. | 182 * TODO(turnidge): Handle ambiguous names. |
182 * TODO(turnidge): Handle optional & named arguments. | 183 * TODO(turnidge): Handle optional & named arguments. |
183 */ | 184 */ |
184 Future<InstanceMirror> invokeAsync(String memberName, | 185 Future<InstanceMirror> invokeAsync(String memberName, |
185 List<Object> positionalArguments, | 186 List<Object> positionalArguments, |
186 [Map<String,Object> namedArguments]); | 187 [Map<String,Object> namedArguments]); |
187 | 188 |
188 /** | 189 /** |
189 * Invokes a getter and returns a mirror on the result. The getter | 190 * Invokes a getter and returns a mirror on the result. The getter |
190 * can be the implicit getter for a field or a user-defined getter | 191 * can be the implicit getter for a field or a user-defined getter |
191 * method. | 192 * method. |
192 */ | 193 */ |
193 /* TODO(turnidge): Handle ambiguous names.*/ | 194 /* TODO(turnidge): Handle ambiguous names.*/ |
194 Future<InstanceMirror> getFieldAsync(String fieldName); | 195 Future<InstanceMirror> getFieldAsync(String fieldName); |
195 | 196 |
196 /** | 197 /** |
197 * Invokes a setter and returns a mirror on the result. The setter | 198 * Invokes a setter and returns a mirror on the result. The setter |
198 * may be either the implicit setter for a non-final field or a | 199 * may be either the implicit setter for a non-final field or a |
199 * user-defined setter method. | 200 * user-defined setter method. |
200 * The argument must be an instance of either [InstanceMirror], [num], | 201 * The argument must be an instance of either [InstanceMirror], [num], |
201 * [String] or [bool]. | 202 * [String] or [bool]. |
202 */ | 203 */ |
203 /* TODO(turnidge): Handle ambiguous names.*/ | 204 /* TODO(turnidge): Handle ambiguous names.*/ |
204 Future<InstanceMirror> setFieldAsync(String fieldName, Object value); | 205 Future<InstanceMirror> setFieldAsync(String fieldName, Object value); |
205 } | 206 } |
206 | 207 |
207 /** | 208 /** |
208 * An [InstanceMirror] reflects an instance of a Dart language object. | 209 * An [InstanceMirror] reflects an instance of a Dart language object. |
209 */ | 210 */ |
210 abstract class InstanceMirror implements ObjectMirror { | 211 abstract class InstanceMirror implements ObjectMirror { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 | 253 |
253 /** | 254 /** |
254 * The source code for this closure, if available. Otherwise null. | 255 * The source code for this closure, if available. Otherwise null. |
255 * | 256 * |
256 * TODO(turnidge): Would this just be available in function? | 257 * TODO(turnidge): Would this just be available in function? |
257 */ | 258 */ |
258 String get source; | 259 String get source; |
259 | 260 |
260 /** | 261 /** |
261 * Executes the closure. | 262 * Executes the closure. |
262 * The arguments must be instances of [InstanceMirror], [num], | 263 * The arguments must be instances of [InstanceMirror], [num], |
263 * [String] or [bool]. | 264 * [String] or [bool]. |
264 */ | 265 */ |
265 Future<InstanceMirror> applyAsync(List<Object> positionalArguments, | 266 Future<InstanceMirror> applyAsync(List<Object> positionalArguments, |
266 [Map<String,Object> namedArguments]); | 267 [Map<String,Object> namedArguments]); |
267 | 268 |
268 /** | 269 /** |
269 * Looks up the value of a name in the scope of the closure. The | 270 * Looks up the value of a name in the scope of the closure. The |
270 * result is a mirror on that value. | 271 * result is a mirror on that value. |
271 */ | 272 */ |
272 Future<InstanceMirror> findInContext(String name); | 273 Future<InstanceMirror> findInContext(String name); |
273 } | 274 } |
274 | 275 |
275 /** | 276 /** |
276 * A [LibraryMirror] reflects a Dart language library, providing | 277 * A [LibraryMirror] reflects a Dart language library, providing |
277 * access to the variables, functions, and classes of the | 278 * access to the variables, functions, and classes of the |
278 * library. | 279 * library. |
279 */ | 280 */ |
280 abstract class LibraryMirror implements DeclarationMirror, ObjectMirror { | 281 abstract class LibraryMirror implements DeclarationMirror, ObjectMirror { |
281 /** | 282 /** |
283 * Deprecated: Use [uri] instead. | |
ahe
2013/04/15 13:24:48
Today is a great day to get rid of deprecated stuf
Johnni Winther
2013/04/17 09:40:33
Removed.
| |
284 * | |
282 * The url of the library. | 285 * The url of the library. |
283 * | 286 * |
284 * TODO(turnidge): Document where this url comes from. Will this | 287 * TODO(turnidge): Document where this url comes from. Will this |
285 * value be sensible? | 288 * value be sensible? |
286 */ | 289 */ |
287 String get url; | 290 String get url => uri.toString(); |
291 | |
292 /** | |
293 * The absolute uri of the library. | |
294 */ | |
295 Uri get uri; | |
288 | 296 |
289 /** | 297 /** |
290 * An immutable map from from names to mirrors for all members in | 298 * An immutable map from from names to mirrors for all members in |
291 * this library. | 299 * this library. |
292 * | 300 * |
293 * The members of a library are its top-level classes, | 301 * The members of a library are its top-level classes, |
294 * functions, variables, getters, and setters. | 302 * functions, variables, getters, and setters. |
295 */ | 303 */ |
296 Map<String, Mirror> get members; | 304 Map<String, Mirror> get members; |
297 | 305 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 * For most classes, they are their own original declaration. For | 434 * For most classes, they are their own original declaration. For |
427 * generic classes, however, there is a distinction between the | 435 * generic classes, however, there is a distinction between the |
428 * original class declaration, which has unbound type variables, and | 436 * original class declaration, which has unbound type variables, and |
429 * the instantiations of generic classes, which have bound type | 437 * the instantiations of generic classes, which have bound type |
430 * variables. | 438 * variables. |
431 */ | 439 */ |
432 ClassMirror get originalDeclaration; | 440 ClassMirror get originalDeclaration; |
433 | 441 |
434 /** | 442 /** |
435 * Invokes the named constructor and returns a mirror on the result. | 443 * Invokes the named constructor and returns a mirror on the result. |
436 * The arguments must be instances of [InstanceMirror], [num], | 444 * The arguments must be instances of [InstanceMirror], [num], |
437 */ | 445 */ |
438 /* TODO(turnidge): Properly document.*/ | 446 /* TODO(turnidge): Properly document.*/ |
439 Future<InstanceMirror> newInstanceAsync(String constructorName, | 447 Future<InstanceMirror> newInstanceAsync(String constructorName, |
440 List<Object> positionalArguments, | 448 List<Object> positionalArguments, |
441 [Map<String,Object> namedArguments]); | 449 [Map<String,Object> namedArguments]); |
442 | 450 |
443 /** | 451 /** |
444 * Does this mirror represent a class? | 452 * Does this mirror represent a class? |
445 * | 453 * |
446 * TODO(turnidge): This functions goes away after the | 454 * TODO(turnidge): This functions goes away after the |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 /** | 764 /** |
757 * Is [:true:] if this comment is a documentation comment. | 765 * Is [:true:] if this comment is a documentation comment. |
758 * | 766 * |
759 * That is, that the comment is either enclosed in [: /** ... */ :] or starts | 767 * That is, that the comment is either enclosed in [: /** ... */ :] or starts |
760 * with [: /// :]. | 768 * with [: /// :]. |
761 */ | 769 */ |
762 final bool isDocComment; | 770 final bool isDocComment; |
763 | 771 |
764 const Comment(this.text, this.trimmedText, this.isDocComment); | 772 const Comment(this.text, this.trimmedText, this.isDocComment); |
765 } | 773 } |
OLD | NEW |