Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 13967003: EAKING CHANGE: Rename InstanceMIrror.invoke, .getField, .setField to invokeAsync, getFieldAsync, se… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // VM-specific implementation of the dart:mirrors library. 5 // VM-specific implementation of the dart:mirrors library.
6 6
7 // These values are allowed to be passed directly over the wire. 7 // These values are allowed to be passed directly over the wire.
8 bool _isSimpleValue(var value) { 8 bool _isSimpleValue(var value) {
9 return (value == null || value is num || value is String || value is bool); 9 return (value == null || value is num || value is String || value is bool);
10 } 10 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 final bool isCurrent = true; 111 final bool isCurrent = true;
112 112
113 var _rootLibrary; 113 var _rootLibrary;
114 LibraryMirror get rootLibrary { 114 LibraryMirror get rootLibrary {
115 if (_rootLibrary is _LazyLibraryMirror) { 115 if (_rootLibrary is _LazyLibraryMirror) {
116 _rootLibrary = _rootLibrary.resolve(mirrors); 116 _rootLibrary = _rootLibrary.resolve(mirrors);
117 } 117 }
118 return _rootLibrary; 118 return _rootLibrary;
119 } 119 }
120 120
121 String toString() => "IsolateMirror on '$debugName'"; 121 String toString() => "IsolateMirror on '$debugName'";
Ivan Posva 2013/04/10 00:30:10 Line ends in white space.
122 } 122 }
123 123
124 // A VMReference is used to hold a reference to a VM-internal object, 124 // A VMReference is used to hold a reference to a VM-internal object,
125 // which can include things like libraries, classes, etc. 125 // which can include things like libraries, classes, etc.
126 class VMReference extends NativeFieldWrapperClass1 { 126 class VMReference extends NativeFieldWrapperClass1 {
127 } 127 }
128 128
129 abstract class _LocalVMObjectMirrorImpl extends _LocalMirrorImpl { 129 abstract class _LocalVMObjectMirrorImpl extends _LocalMirrorImpl {
130 _LocalVMObjectMirrorImpl(this._reference) {} 130 _LocalVMObjectMirrorImpl(this._reference) {}
131 131
132 // For now, all VMObjects hold a VMReference. We could consider 132 // For now, all VMObjects hold a VMReference. We could consider
133 // storing the Object reference itself here if the object is a Dart 133 // storing the Object reference itself here if the object is a Dart
134 // language objects (except for objects of type VMReference, of 134 // language objects (except for objects of type VMReference, of
135 // course). 135 // course).
136 VMReference _reference; 136 VMReference _reference;
137 } 137 }
138 138
139 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl 139 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl
140 implements ObjectMirror { 140 implements ObjectMirror {
141 _LocalObjectMirrorImpl(ref) : super(ref) {} 141 _LocalObjectMirrorImpl(ref) : super(ref) {}
142 142
143 Future<InstanceMirror> invoke(String memberName, 143 /* TODO: uncomment and correct
144 InstanceMirror invoke(String memberName,
145 List positionalArguments,
146 [Map<String,dynamic> namedArguments]) {
147 if (namedArguments != null) {
148 throw new UnimplementedError(
149 'named argument support is not implemented');
150 }
151 return _invoke(this, memberName, positionalArguments)); // needs to be disti nct for sync calls
152 }
153
154
155
156 InstanceMirror getField(String fieldName)
157 {
158 » return _getField(this, fieldName); // needs to be distinct for sync call s
Ivan Posva 2013/04/10 00:30:10 Please replace tab with spaces eventually.
159 }
160
161 InstanceMirror setField(String fieldName, Object arg)
162 {
163 return (_setField(this, fieldName, arg); // needs to be distinct for sync ca lls
164 }
165
166
167 */
168
169 Future<InstanceMirror> invokeAsync(String memberName,
144 List positionalArguments, 170 List positionalArguments,
Ivan Posva 2013/04/10 00:30:10 Indentation.
145 [Map<String,dynamic> namedArguments]) { 171 [Map<String,dynamic> namedArguments]) {
146 if (namedArguments != null) { 172 if (namedArguments != null) {
147 throw new UnimplementedError( 173 throw new UnimplementedError(
148 'named argument support is not implemented'); 174 'named argument support is not implemented');
149 } 175 }
150 // Walk the arguments and make sure they are legal. 176 // Walk the arguments and make sure they are legal.
151 for (int i = 0; i < positionalArguments.length; i++) { 177 for (int i = 0; i < positionalArguments.length; i++) {
152 var arg = positionalArguments[i]; 178 var arg = positionalArguments[i];
153 _validateArgument(i, arg); 179 _validateArgument(i, arg);
154 } 180 }
155 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); 181 Completer<InstanceMirror> completer = new Completer<InstanceMirror>();
156 try { 182 try {
157 completer.complete( 183 completer.complete(
158 _invoke(this, memberName, positionalArguments)); 184 _invoke(this, memberName, positionalArguments));
159 } catch (exception, s) { 185 } catch (exception, s) {
160 completer.completeError(exception, s); 186 completer.completeError(exception, s);
161 } 187 }
162 return completer.future; 188 return completer.future;
163 } 189 }
164 190
165 Future<InstanceMirror> getField(String fieldName) 191 Future<InstanceMirror> getFieldAsync(String fieldName)
166 { 192 {
167 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); 193 Completer<InstanceMirror> completer = new Completer<InstanceMirror>();
168 try { 194 try {
169 completer.complete(_getField(this, fieldName)); 195 completer.complete(_getField(this, fieldName));
170 } catch (exception, s) { 196 } catch (exception, s) {
171 completer.completeError(exception, s); 197 completer.completeError(exception, s);
172 } 198 }
173 return completer.future; 199 return completer.future;
174 } 200 }
175 201
176 Future<InstanceMirror> setField(String fieldName, Object arg) 202 Future<InstanceMirror> setFieldAsync(String fieldName, Object arg)
177 { 203 {
178 _validateArgument(0, arg); 204 _validateArgument(0, arg);
179 205
180 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); 206 Completer<InstanceMirror> completer = new Completer<InstanceMirror>();
181 try { 207 try {
182 completer.complete(_setField(this, fieldName, arg)); 208 completer.complete(_setField(this, fieldName, arg));
183 } catch (exception, s) { 209 } catch (exception, s) {
184 completer.completeError(exception, s); 210 completer.completeError(exception, s);
185 } 211 }
186 return completer.future; 212 return completer.future;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 reflectee, 324 reflectee,
299 this.function) : super(ref, type, reflectee) {} 325 this.function) : super(ref, type, reflectee) {}
300 326
301 final MethodMirror function; 327 final MethodMirror function;
302 328
303 String get source { 329 String get source {
304 throw new UnimplementedError( 330 throw new UnimplementedError(
305 'ClosureMirror.source is not implemented'); 331 'ClosureMirror.source is not implemented');
306 } 332 }
307 333
308 Future<InstanceMirror> apply(List<Object> positionalArguments, 334 Future<InstanceMirror> applyAsync(List<Object> positionalArguments,
309 [Map<String,Object> namedArguments]) { 335 [Map<String,Object> namedArguments]) {
Ivan Posva 2013/04/10 00:30:10 Indentation.
310 if (namedArguments != null) { 336 if (namedArguments != null) {
311 throw new UnimplementedError( 337 throw new UnimplementedError(
312 'named argument support is not implemented'); 338 'named argument support is not implemented');
313 } 339 }
314 // Walk the arguments and make sure they are legal. 340 // Walk the arguments and make sure they are legal.
315 for (int i = 0; i < positionalArguments.length; i++) { 341 for (int i = 0; i < positionalArguments.length; i++) {
316 var arg = positionalArguments[i]; 342 var arg = positionalArguments[i];
317 _LocalObjectMirrorImpl._validateArgument(i, arg); 343 _LocalObjectMirrorImpl._validateArgument(i, arg);
318 } 344 }
319 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); 345 Completer<InstanceMirror> completer = new Completer<InstanceMirror>();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 'ClassMirror.isOriginalDeclaration is not implemented'); 520 'ClassMirror.isOriginalDeclaration is not implemented');
495 } 521 }
496 522
497 ClassMirror get genericDeclaration { 523 ClassMirror get genericDeclaration {
498 throw new UnimplementedError( 524 throw new UnimplementedError(
499 'ClassMirror.originalDeclaration is not implemented'); 525 'ClassMirror.originalDeclaration is not implemented');
500 } 526 }
501 527
502 String toString() => "ClassMirror on '$simpleName'"; 528 String toString() => "ClassMirror on '$simpleName'";
503 529
504 Future<InstanceMirror> newInstance(String constructorName, 530 Future<InstanceMirror> newInstanceAsync(String constructorName,
505 List positionalArguments, 531 List positionalArguments,
Ivan Posva 2013/04/10 00:30:10 Indentation.
506 [Map<String,dynamic> namedArguments]) { 532 [Map<String,dynamic> namedArguments]) {
507 if (namedArguments != null) { 533 if (namedArguments != null) {
508 throw new UnimplementedError( 534 throw new UnimplementedError(
509 'named argument support is not implemented'); 535 'named argument support is not implemented');
510 } 536 }
511 // Walk the arguments and make sure they are legal. 537 // Walk the arguments and make sure they are legal.
512 for (int i = 0; i < positionalArguments.length; i++) { 538 for (int i = 0; i < positionalArguments.length; i++) {
513 var arg = positionalArguments[i]; 539 var arg = positionalArguments[i];
514 _LocalObjectMirrorImpl._validateArgument(i, arg); 540 _LocalObjectMirrorImpl._validateArgument(i, arg);
515 } 541 }
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 } 989 }
964 990
965 // Creates a new local InstanceMirror 991 // Creates a new local InstanceMirror
966 static InstanceMirror makeLocalInstanceMirror(Object reflectee) 992 static InstanceMirror makeLocalInstanceMirror(Object reflectee)
967 native 'Mirrors_makeLocalInstanceMirror'; 993 native 'Mirrors_makeLocalInstanceMirror';
968 994
969 // Creates a new local mirror for some Object. 995 // Creates a new local mirror for some Object.
970 static InstanceMirror reflect(Object reflectee) { 996 static InstanceMirror reflect(Object reflectee) {
971 return makeLocalInstanceMirror(reflectee); 997 return makeLocalInstanceMirror(reflectee);
972 } 998 }
999
1000 static ClassMirror reflectClass(Type reflectee) {
1001 throw new UnimplementedError('reflectClass is not implemented');
1002 }
1003
1004
973 } 1005 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698