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

Side by Side Diff: runtime/lib/mirrors.cc

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 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_debugger_api.h" 6 #include "include/dart_debugger_api.h"
7 #include "platform/json.h" 7 #include "platform/json.h"
8 #include "vm/bootstrap_natives.h" 8 #include "vm/bootstrap_natives.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 Dart_Handle arg = Dart_ListGetAt(arg_list, i); 191 Dart_Handle arg = Dart_ListGetAt(arg_list, i);
192 Dart_Handle unwrapped_arg = UnwrapArg(arg); 192 Dart_Handle unwrapped_arg = UnwrapArg(arg);
193 if (Dart_IsError(unwrapped_arg)) { 193 if (Dart_IsError(unwrapped_arg)) {
194 return unwrapped_arg; 194 return unwrapped_arg;
195 } 195 }
196 arg_array->Add(unwrapped_arg); 196 arg_array->Add(unwrapped_arg);
197 } 197 }
198 return Dart_True(); 198 return Dart_True();
199 } 199 }
200 200
201 /*
202 static Dart_Handle UnwrapLocalArg(Dart_Handle arg) {
203 if (Dart_IsError(arg)) {
204 return arg;
205 }
206 // unwrap the object?
207 return arg;
208 }
209
210
211 static Dart_Handle UnwrapLocalArgList(Dart_Handle arg_list,
212 GrowableArray<Dart_Handle>* arg_array) {
213 intptr_t len = 0;
214 Dart_Handle result = Dart_ListLength(arg_list, &len);
215 if (Dart_IsError(result)) {
216 return result;
217 }
218 for (intptr_t i = 0; i < len; i++) {
219 Dart_Handle arg = Dart_ListGetAt(arg_list, i);
220 Dart_Handle unwrapped_arg = UnwrapLocalArg(arg);
221 if (Dart_IsError(unwrapped_arg)) {
222 return unwrapped_arg;
223 }
224 arg_array->Add(unwrapped_arg);
225 }
226 return Dart_True();
227 }*/
228
229
201 230
202 static Dart_Handle CreateLazyMirror(Dart_Handle target); 231 static Dart_Handle CreateLazyMirror(Dart_Handle target);
203 232
204 233
205 static Dart_Handle CreateParameterMirrorList(Dart_Handle func) { 234 static Dart_Handle CreateParameterMirrorList(Dart_Handle func) {
206 int64_t fixed_param_count; 235 int64_t fixed_param_count;
207 int64_t opt_param_count; 236 int64_t opt_param_count;
208 Dart_Handle result = Dart_FunctionParameterCounts(func, 237 Dart_Handle result = Dart_FunctionParameterCounts(func,
209 &fixed_param_count, 238 &fixed_param_count,
210 &opt_param_count); 239 &opt_param_count);
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 Dart_PropagateError(CreateMirroredError(result)); 1217 Dart_PropagateError(CreateMirroredError(result));
1189 } 1218 }
1190 1219
1191 Dart_Handle wrapped_result = CreateInstanceMirror(result); 1220 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1192 if (Dart_IsError(wrapped_result)) { 1221 if (Dart_IsError(wrapped_result)) {
1193 Dart_PropagateError(wrapped_result); 1222 Dart_PropagateError(wrapped_result);
1194 } 1223 }
1195 Dart_SetReturnValue(args, wrapped_result); 1224 Dart_SetReturnValue(args, wrapped_result);
1196 Dart_ExitScope(); 1225 Dart_ExitScope();
1197 } 1226 }
1227 /*
1228 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_invokeSync)(
1229 Dart_NativeArguments args) {
1230 Dart_EnterScope();
1231 Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
1232 Dart_Handle member = Dart_GetNativeArgument(args, 1);
1233
1234 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2);
1235
1236 Dart_Handle reflectee = UnwrapMirror(mirror);
1237 GrowableArray<Dart_Handle> invoke_args;
1238 Dart_Handle result = UnwrapLocalArgList(wrapped_invoke_args, &invoke_args);
1239 if (Dart_IsError(result)) {
1240 Dart_PropagateError(result);
1241 }
1242 result =
1243 Dart_Invoke(reflectee, member, invoke_args.length(), invoke_args.data());
1244 if (Dart_IsError(result)) {
1245 // Instead of propagating the error from an invoke directly, we
1246 // provide reflective access to the error.
1247 Dart_PropagateError(CreateMirroredError(result));
1248 }
1249
1250 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1251 if (Dart_IsError(wrapped_result)) {
1252 Dart_PropagateError(wrapped_result);
1253 }
1254 Dart_SetReturnValue(args, wrapped_result);
1255 Dart_ExitScope();
1256 }
1198 1257
1199 1258
1259
1260 void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_setFieldSync)(
1261 Dart_NativeArguments args) {
1262 Dart_EnterScope();
1263 Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
1264 Dart_Handle fieldName = Dart_GetNativeArgument(args, 1);
1265
1266 Dart_Handle wrapped_arg = Dart_GetNativeArgument(args, 2);
1267
1268 Dart_Handle reflectee = UnwrapMirror(mirror);
1269 Dart_Handle set_arg = UnwrapLocalArg(wrapped_arg);
1270 if (Dart_IsError(set_arg)) {
1271 Dart_PropagateError(set_arg);
1272 }
1273 Dart_Handle result = Dart_SetField(reflectee, fieldName, set_arg);
1274 if (Dart_IsError(result)) {
1275 // Instead of propagating the error from a SetField directly, we
1276 // provide reflective access to the error.
1277 Dart_PropagateError(CreateMirroredError(result));
1278 }
1279
1280 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1281 if (Dart_IsError(wrapped_result)) {
1282 Dart_PropagateError(wrapped_result);
1283 }
1284 Dart_SetReturnValue(args, wrapped_result);
1285 Dart_ExitScope();
1286 }
1287
1288
1289 void NATIVE_ENTRY_FUNCTION(LocalClosureMirrorImpl_applySync)(
1290 Dart_NativeArguments args) {
1291 Dart_EnterScope();
1292 Dart_Handle mirror = Dart_GetNativeArgument(args, 0);
1293
1294 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 1);
1295
1296 Dart_Handle reflectee = UnwrapMirror(mirror);
1297 GrowableArray<Dart_Handle> invoke_args;
1298 Dart_Handle result = UnwrapLocalArgList(wrapped_invoke_args, &invoke_args);
1299 if (Dart_IsError(result)) {
1300 Dart_PropagateError(result);
1301 }
1302 result =
1303 Dart_InvokeClosure(reflectee, invoke_args.length(), invoke_args.data());
1304 if (Dart_IsError(result)) {
1305 // Instead of propagating the error from an apply directly, we
1306 // provide reflective access to the error.
1307 Dart_PropagateError(CreateMirroredError(result));
1308 }
1309
1310 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1311 if (Dart_IsError(wrapped_result)) {
1312 Dart_PropagateError(wrapped_result);
1313 }
1314 Dart_SetReturnValue(args, wrapped_result);
1315 Dart_ExitScope();
1316 }
1317
1318
1319 void NATIVE_ENTRY_FUNCTION(LocalClassMirrorImpl_invokeConstructorSync)(
1320 Dart_NativeArguments args) {
1321 Dart_EnterScope();
1322 Dart_Handle klass_mirror = Dart_GetNativeArgument(args, 0);
1323 Dart_Handle constructor_name = Dart_GetNativeArgument(args, 1);
1324
1325 Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2);
1326
1327 Dart_Handle klass = UnwrapMirror(klass_mirror);
1328 GrowableArray<Dart_Handle> invoke_args;
1329 Dart_Handle result = UnwrapLocalArgList(wrapped_invoke_args, &invoke_args);
1330 if (Dart_IsError(result)) {
1331 Dart_PropagateError(result);
1332 }
1333 result = Dart_New(klass,
1334 constructor_name,
1335 invoke_args.length(),
1336 invoke_args.data());
1337 if (Dart_IsError(result)) {
1338 // Instead of propagating the error from an invoke directly, we
1339 // provide reflective access to the error.
1340 Dart_PropagateError(CreateMirroredError(result));
1341 }
1342
1343 Dart_Handle wrapped_result = CreateInstanceMirror(result);
1344 if (Dart_IsError(wrapped_result)) {
1345 Dart_PropagateError(wrapped_result);
1346 }
1347 Dart_SetReturnValue(args, wrapped_result);
1348 Dart_ExitScope();
1349 }
1350 */
1351
1200 void HandleMirrorsMessage(Isolate* isolate, 1352 void HandleMirrorsMessage(Isolate* isolate,
1201 Dart_Port reply_port, 1353 Dart_Port reply_port,
1202 const Instance& message) { 1354 const Instance& message) {
1203 UNIMPLEMENTED(); 1355 UNIMPLEMENTED();
1204 } 1356 }
1205 1357
1206 } // namespace dart 1358 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698