Index: runtime/lib/mirrors.cc |
=================================================================== |
--- runtime/lib/mirrors.cc (revision 21161) |
+++ runtime/lib/mirrors.cc (working copy) |
@@ -198,7 +198,36 @@ |
return Dart_True(); |
} |
+ /* |
+static Dart_Handle UnwrapLocalArg(Dart_Handle arg) { |
+ if (Dart_IsError(arg)) { |
+ return arg; |
+ } |
+ // unwrap the object? |
+ return arg; |
+} |
+ |
+static Dart_Handle UnwrapLocalArgList(Dart_Handle arg_list, |
+ GrowableArray<Dart_Handle>* arg_array) { |
+ intptr_t len = 0; |
+ Dart_Handle result = Dart_ListLength(arg_list, &len); |
+ if (Dart_IsError(result)) { |
+ return result; |
+ } |
+ for (intptr_t i = 0; i < len; i++) { |
+ Dart_Handle arg = Dart_ListGetAt(arg_list, i); |
+ Dart_Handle unwrapped_arg = UnwrapLocalArg(arg); |
+ if (Dart_IsError(unwrapped_arg)) { |
+ return unwrapped_arg; |
+ } |
+ arg_array->Add(unwrapped_arg); |
+ } |
+ return Dart_True(); |
+ }*/ |
+ |
+ |
+ |
static Dart_Handle CreateLazyMirror(Dart_Handle target); |
@@ -1195,8 +1224,131 @@ |
Dart_SetReturnValue(args, wrapped_result); |
Dart_ExitScope(); |
} |
+ /* |
+void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_invokeSync)( |
+ Dart_NativeArguments args) { |
+ Dart_EnterScope(); |
+ Dart_Handle mirror = Dart_GetNativeArgument(args, 0); |
+ Dart_Handle member = Dart_GetNativeArgument(args, 1); |
+ Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2); |
+ Dart_Handle reflectee = UnwrapMirror(mirror); |
+ GrowableArray<Dart_Handle> invoke_args; |
+ Dart_Handle result = UnwrapLocalArgList(wrapped_invoke_args, &invoke_args); |
+ if (Dart_IsError(result)) { |
+ Dart_PropagateError(result); |
+ } |
+ result = |
+ Dart_Invoke(reflectee, member, invoke_args.length(), invoke_args.data()); |
+ if (Dart_IsError(result)) { |
+ // Instead of propagating the error from an invoke directly, we |
+ // provide reflective access to the error. |
+ Dart_PropagateError(CreateMirroredError(result)); |
+ } |
+ |
+ Dart_Handle wrapped_result = CreateInstanceMirror(result); |
+ if (Dart_IsError(wrapped_result)) { |
+ Dart_PropagateError(wrapped_result); |
+ } |
+ Dart_SetReturnValue(args, wrapped_result); |
+ Dart_ExitScope(); |
+} |
+ |
+ |
+ |
+void NATIVE_ENTRY_FUNCTION(LocalObjectMirrorImpl_setFieldSync)( |
+ Dart_NativeArguments args) { |
+ Dart_EnterScope(); |
+ Dart_Handle mirror = Dart_GetNativeArgument(args, 0); |
+ Dart_Handle fieldName = Dart_GetNativeArgument(args, 1); |
+ |
+ Dart_Handle wrapped_arg = Dart_GetNativeArgument(args, 2); |
+ |
+ Dart_Handle reflectee = UnwrapMirror(mirror); |
+ Dart_Handle set_arg = UnwrapLocalArg(wrapped_arg); |
+ if (Dart_IsError(set_arg)) { |
+ Dart_PropagateError(set_arg); |
+ } |
+ Dart_Handle result = Dart_SetField(reflectee, fieldName, set_arg); |
+ if (Dart_IsError(result)) { |
+ // Instead of propagating the error from a SetField directly, we |
+ // provide reflective access to the error. |
+ Dart_PropagateError(CreateMirroredError(result)); |
+ } |
+ |
+ Dart_Handle wrapped_result = CreateInstanceMirror(result); |
+ if (Dart_IsError(wrapped_result)) { |
+ Dart_PropagateError(wrapped_result); |
+ } |
+ Dart_SetReturnValue(args, wrapped_result); |
+ Dart_ExitScope(); |
+} |
+ |
+ |
+void NATIVE_ENTRY_FUNCTION(LocalClosureMirrorImpl_applySync)( |
+ Dart_NativeArguments args) { |
+ Dart_EnterScope(); |
+ Dart_Handle mirror = Dart_GetNativeArgument(args, 0); |
+ |
+ Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 1); |
+ |
+ Dart_Handle reflectee = UnwrapMirror(mirror); |
+ GrowableArray<Dart_Handle> invoke_args; |
+ Dart_Handle result = UnwrapLocalArgList(wrapped_invoke_args, &invoke_args); |
+ if (Dart_IsError(result)) { |
+ Dart_PropagateError(result); |
+ } |
+ result = |
+ Dart_InvokeClosure(reflectee, invoke_args.length(), invoke_args.data()); |
+ if (Dart_IsError(result)) { |
+ // Instead of propagating the error from an apply directly, we |
+ // provide reflective access to the error. |
+ Dart_PropagateError(CreateMirroredError(result)); |
+ } |
+ |
+ Dart_Handle wrapped_result = CreateInstanceMirror(result); |
+ if (Dart_IsError(wrapped_result)) { |
+ Dart_PropagateError(wrapped_result); |
+ } |
+ Dart_SetReturnValue(args, wrapped_result); |
+ Dart_ExitScope(); |
+} |
+ |
+ |
+void NATIVE_ENTRY_FUNCTION(LocalClassMirrorImpl_invokeConstructorSync)( |
+ Dart_NativeArguments args) { |
+ Dart_EnterScope(); |
+ Dart_Handle klass_mirror = Dart_GetNativeArgument(args, 0); |
+ Dart_Handle constructor_name = Dart_GetNativeArgument(args, 1); |
+ |
+ Dart_Handle wrapped_invoke_args = Dart_GetNativeArgument(args, 2); |
+ |
+ Dart_Handle klass = UnwrapMirror(klass_mirror); |
+ GrowableArray<Dart_Handle> invoke_args; |
+ Dart_Handle result = UnwrapLocalArgList(wrapped_invoke_args, &invoke_args); |
+ if (Dart_IsError(result)) { |
+ Dart_PropagateError(result); |
+ } |
+ result = Dart_New(klass, |
+ constructor_name, |
+ invoke_args.length(), |
+ invoke_args.data()); |
+ if (Dart_IsError(result)) { |
+ // Instead of propagating the error from an invoke directly, we |
+ // provide reflective access to the error. |
+ Dart_PropagateError(CreateMirroredError(result)); |
+ } |
+ |
+ Dart_Handle wrapped_result = CreateInstanceMirror(result); |
+ if (Dart_IsError(wrapped_result)) { |
+ Dart_PropagateError(wrapped_result); |
+ } |
+ Dart_SetReturnValue(args, wrapped_result); |
+ Dart_ExitScope(); |
+} |
+ */ |
+ |
void HandleMirrorsMessage(Isolate* isolate, |
Dart_Port reply_port, |
const Instance& message) { |