X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Ficall.c;h=165cdd39d8fb39480187deee89e1c49e3ea89892;hb=35671f29a75557cce71204311539475fcc145ddb;hp=636d7eab796547ce4fb7d2f79a42a5193f7cad71;hpb=d43ea3ac56e86e4bb683037c7d895b4c30eeb253;p=mono.git diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 636d7eab796..165cdd39d8f 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -1529,6 +1529,33 @@ ves_icall_System_Type_internal_from_handle (MonoType *handle) return ret; } +ICALL_EXPORT MonoType* +ves_icall_Mono_RuntimeClassHandle_GetTypeFromClass (MonoClass *klass) +{ + return mono_class_get_type (klass); +} + +ICALL_EXPORT void +ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree (GPtrArray *ptr_array) +{ + g_ptr_array_free (ptr_array, TRUE); +} + +ICALL_EXPORT void +ves_icall_Mono_SafeStringMarshal_GFree (void *c_str) +{ + g_free (c_str); +} + +ICALL_EXPORT char* +ves_icall_Mono_SafeStringMarshal_StringToUtf8 (MonoString *s) +{ + MonoError error; + char *res = mono_string_to_utf8_checked (s, &error); + mono_error_set_pending_exception (&error); + return res; +} + /* System.TypeCode */ typedef enum { TYPECODE_EMPTY, @@ -1753,7 +1780,6 @@ ves_icall_System_Reflection_FieldInfo_internal_from_handle_type (MonoClassField MonoError error; gboolean found = FALSE; MonoClass *klass; - MonoClass *k; g_assert (handle); @@ -1762,13 +1788,7 @@ ves_icall_System_Reflection_FieldInfo_internal_from_handle_type (MonoClassField } else { klass = mono_class_from_mono_type (type); - /* Check that the field belongs to the class */ - for (k = klass; k; k = k->parent) { - if (k == handle->parent) { - found = TRUE; - break; - } - } + found = klass == handle->parent || mono_class_has_parent (klass, handle->parent); if (!found) /* The managed code will throw the exception */ @@ -1780,6 +1800,55 @@ ves_icall_System_Reflection_FieldInfo_internal_from_handle_type (MonoClassField return result; } +ICALL_EXPORT MonoReflectionEvent* +ves_icall_System_Reflection_EventInfo_internal_from_handle_type (MonoEvent *handle, MonoType *type) +{ + MonoError error; + MonoClass *klass; + + g_assert (handle); + + if (!type) { + klass = handle->parent; + } else { + klass = mono_class_from_mono_type (type); + + gboolean found = klass == handle->parent || mono_class_has_parent (klass, handle->parent); + if (!found) + /* Managed code will throw an exception */ + return NULL; + } + + MonoReflectionEvent *result = mono_event_get_object_checked (mono_domain_get (), klass, handle, &error); + mono_error_set_pending_exception (&error); + return result; +} + + +ICALL_EXPORT MonoReflectionProperty* +ves_icall_System_Reflection_PropertyInfo_internal_from_handle_type (MonoProperty *handle, MonoType *type) +{ + MonoError error; + MonoClass *klass; + + g_assert (handle); + + if (!type) { + klass = handle->parent; + } else { + klass = mono_class_from_mono_type (type); + + gboolean found = klass == handle->parent || mono_class_has_parent (klass, handle->parent); + if (!found) + /* Managed code will throw an exception */ + return NULL; + } + + MonoReflectionProperty *result = mono_property_get_object_checked (mono_domain_get (), klass, handle, &error); + mono_error_set_pending_exception (&error); + return result; +} + ICALL_EXPORT MonoArray* ves_icall_System_Reflection_FieldInfo_GetTypeModifiers (MonoReflectionField *field, MonoBoolean optional) { @@ -2875,45 +2944,10 @@ ves_icall_RuntimeType_GetGenericParameterPosition (MonoReflectionType *type) return -1; } -ICALL_EXPORT GenericParameterAttributes -ves_icall_RuntimeType_GetGenericParameterAttributes (MonoReflectionType *type) -{ - g_assert (IS_MONOTYPE (type)); - g_assert (is_generic_parameter (type->type)); - return (GenericParameterAttributes)mono_generic_param_info (type->type->data.generic_param)->flags; -} - -ICALL_EXPORT MonoArray * -ves_icall_RuntimeType_GetGenericParameterConstraints (MonoReflectionType *type) +ICALL_EXPORT MonoGenericParamInfo * +ves_icall_RuntimeTypeHandle_GetGenericParameterInfo (MonoReflectionType *type) { - MonoError error; - MonoReflectionType *rt; - MonoGenericParamInfo *param_info; - MonoDomain *domain; - MonoClass **ptr; - MonoArray *res; - int i, count; - - g_assert (IS_MONOTYPE (type)); - - domain = mono_object_domain (type); - param_info = mono_generic_param_info (type->type->data.generic_param); - for (count = 0, ptr = param_info->constraints; ptr && *ptr; ptr++, count++) - ; - - res = mono_array_new_checked (domain, mono_defaults.runtimetype_class, count, &error); - if (mono_error_set_pending_exception (&error)) - return NULL; - for (i = 0; i < count; i++) { - rt = mono_type_get_object_checked (domain, ¶m_info->constraints [i]->byval_arg, &error); - if (mono_error_set_pending_exception (&error)) - return NULL; - - mono_array_setref (res, i, rt); - } - - - return res; + return mono_generic_param_info (type->type->data.generic_param); } ICALL_EXPORT MonoBoolean @@ -3770,38 +3804,32 @@ enum { BFLAGS_OptionalParamBinding = 0x40000 }; -ICALL_EXPORT MonoArray* -ves_icall_RuntimeType_GetFields_internal (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoReflectionType *reftype) +ICALL_EXPORT GPtrArray* +ves_icall_RuntimeType_GetFields_native (MonoReflectionType *type, char *utf8_name, guint32 bflags) { MonoError error; - MonoDomain *domain; - MonoClass *startklass, *klass, *refklass; - MonoArray *res; - MonoObject *member; - int i, match; + MonoClass *startklass, *klass; + int match; gpointer iter; - char *utf8_name = NULL; int (*compare_func) (const char *s1, const char *s2) = NULL; MonoClassField *field; - MonoPtrArray tmp_array; - domain = ((MonoObject *)type)->vtable->domain; if (type->type->byref) { - MonoArray *result = mono_array_new_checked (domain, mono_defaults.field_info_class, 0, &error); - mono_error_set_pending_exception (&error); - return result; + return g_ptr_array_new (); } + mono_error_init (&error); + + compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp; + klass = startklass = mono_class_from_mono_type (type->type); - refklass = mono_class_from_mono_type (reftype->type); - mono_ptr_array_init (tmp_array, 2, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection fields list"); + GPtrArray *ptr_array = g_ptr_array_sized_new (16); handle_parent: if (mono_class_has_failure (klass)) { - mono_ptr_array_destroy (tmp_array); - mono_set_pending_exception (mono_class_get_exception_for_failure (klass)); - return NULL; + mono_error_set_for_class_failure (&error, klass); + goto fail; } iter = NULL; @@ -3833,41 +3861,18 @@ handle_parent: if (!match) continue; - if (name != NULL) { - if (utf8_name == NULL) { - utf8_name = mono_string_to_utf8_checked (name, &error); - if (!is_ok (&error)) - goto fail; - compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp; - } - - if (compare_func (mono_field_get_name (field), utf8_name)) + if (utf8_name != NULL && compare_func (mono_field_get_name (field), utf8_name)) continue; - } - member = (MonoObject*)mono_field_get_object_checked (domain, refklass, field, &error); - if (!mono_error_ok (&error)) - goto fail; - mono_ptr_array_append (tmp_array, member); + g_ptr_array_add (ptr_array, field); } if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)) goto handle_parent; - res = mono_array_new_cached (domain, mono_defaults.field_info_class, mono_ptr_array_size (tmp_array), &error); - if (!is_ok (&error)) - goto fail; - - for (i = 0; i < mono_ptr_array_size (tmp_array); ++i) - mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i)); + return ptr_array; - mono_ptr_array_destroy (tmp_array); - - if (utf8_name != NULL) - g_free (utf8_name); - - return res; fail: - mono_ptr_array_destroy (tmp_array); + g_ptr_array_free (ptr_array, TRUE); mono_error_set_pending_exception (&error); return NULL; } @@ -3888,7 +3893,7 @@ method_nonpublic (MonoMethod* method, gboolean start_klass) } GPtrArray* -mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoException **ex) +mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError *error) { GPtrArray *array; MonoClass *startklass; @@ -3902,7 +3907,7 @@ mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bfla array = g_ptr_array_new (); startklass = klass; - *ex = NULL; + mono_error_init (error); if (name != NULL) compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp; @@ -3991,117 +3996,54 @@ loader_error: g_free (method_slots); g_ptr_array_free (array, TRUE); - if (mono_class_has_failure (klass)) { - *ex = mono_class_get_exception_for_failure (klass); - } else { - *ex = mono_get_exception_execution_engine ("Unknown error"); - } + g_assert (mono_class_has_failure (klass)); + mono_error_set_for_class_failure (error, klass); return NULL; } -ICALL_EXPORT MonoArray* -ves_icall_RuntimeType_GetMethodsByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype) +ICALL_EXPORT GPtrArray* +ves_icall_RuntimeType_GetMethodsByName_native (MonoReflectionType *type, const char *mname, guint32 bflags, MonoBoolean ignore_case) { - static MonoClass *MethodInfo_array; MonoError error; - MonoDomain *domain; - MonoArray *res; - MonoVTable *array_vtable; - MonoException *ex = NULL; - const char *mname = NULL; GPtrArray *method_array; - MonoClass *klass, *refklass; - int i; - - mono_error_init (&error); - - if (!MethodInfo_array) { - MonoClass *klass = mono_array_class_get (mono_defaults.method_info_class, 1); - mono_memory_barrier (); - MethodInfo_array = klass; - } + MonoClass *klass; klass = mono_class_from_mono_type (type->type); - refklass = mono_class_from_mono_type (reftype->type); - domain = ((MonoObject *)type)->vtable->domain; - array_vtable = mono_class_vtable_full (domain, MethodInfo_array, &error); - if (!is_ok (&error)) { - mono_error_set_pending_exception (&error); - return NULL; - } if (type->type->byref) { - res = mono_array_new_specific_checked (array_vtable, 0, &error); - mono_error_set_pending_exception (&error); - - return res; + return g_ptr_array_new (); } - if (name) { - mname = mono_string_to_utf8_checked (name, &error); - if (mono_error_set_pending_exception (&error)) - return NULL; - } - - method_array = mono_class_get_methods_by_name (klass, mname, bflags, ignore_case, FALSE, &ex); - g_free ((char*)mname); - if (ex) { - mono_set_pending_exception (ex); - return NULL; - } - - res = mono_array_new_specific_checked (array_vtable, method_array->len, &error); - if (!mono_error_ok (&error)) { - mono_error_set_pending_exception (&error); - return NULL; - } - - for (i = 0; i < method_array->len; ++i) { - MonoMethod *method = (MonoMethod *)g_ptr_array_index (method_array, i); - MonoReflectionMethod *rm = mono_method_get_object_checked (domain, method, refklass, &error); - if (!mono_error_ok (&error)) - goto failure; - mono_array_setref (res, i, rm); - } - -failure: - g_ptr_array_free (method_array, TRUE); - if (!mono_error_ok (&error)) - mono_set_pending_exception (mono_error_convert_to_exception (&error)); - return res; + method_array = mono_class_get_methods_by_name (klass, mname, bflags, ignore_case, FALSE, &error); + mono_error_set_pending_exception (&error); + return method_array; } -ICALL_EXPORT MonoArray* -ves_icall_RuntimeType_GetConstructors_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype) +ICALL_EXPORT GPtrArray* +ves_icall_RuntimeType_GetConstructors_native (MonoReflectionType *type, guint32 bflags) { - MonoDomain *domain; - MonoClass *startklass, *klass, *refklass; - MonoArray *res = NULL; + MonoClass *startklass, *klass; MonoMethod *method; - MonoObject *member; - int i, match; + int match; gpointer iter = NULL; - MonoPtrArray tmp_array; + GPtrArray *res_array; MonoError error; - domain = ((MonoObject *)type)->vtable->domain; if (type->type->byref) { - res = mono_array_new_cached (domain, mono_defaults.method_info_class, 0, &error); - mono_error_set_pending_exception (&error); - return res; + return g_ptr_array_new (); } - mono_ptr_array_init (tmp_array, 4, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection constructors list"); /*FIXME, guestimating*/ - - klass = startklass = mono_class_from_mono_type (type->type); - refklass = mono_class_from_mono_type (reftype->type); mono_class_setup_methods (klass); if (mono_class_has_failure (klass)) { - mono_set_pending_exception (mono_class_get_exception_for_failure (klass)); - goto leave; + mono_error_init (&error); + mono_error_set_for_class_failure (&error, klass); + mono_error_set_pending_exception (&error); + return NULL; } + res_array = g_ptr_array_sized_new (4); /* FIXME, guestimating */ + iter = NULL; while ((method = mono_class_get_methods (klass, &iter))) { match = 0; @@ -4128,24 +4070,10 @@ ves_icall_RuntimeType_GetConstructors_internal (MonoReflectionType *type, guint3 if (!match) continue; - member = (MonoObject*)mono_method_get_object_checked (domain, method, refklass, &error); - if (mono_error_set_pending_exception (&error)) - goto leave; - - mono_ptr_array_append (tmp_array, member); + g_ptr_array_add (res_array, method); } - res = mono_array_new_cached (domain, mono_class_get_constructor_info_class (), mono_ptr_array_size (tmp_array), &error); - if (mono_error_set_pending_exception (&error)) - goto leave; - - for (i = 0; i < mono_ptr_array_size (tmp_array); ++i) - mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i)); - -leave: - mono_ptr_array_destroy (tmp_array); - - return res; + return res_array; } static guint @@ -4157,12 +4085,17 @@ property_hash (gconstpointer data) } static gboolean -method_declaring_signatures_equal (MonoMethod *method1, MonoMethod *method2) +property_accessor_override (MonoMethod *method1, MonoMethod *method2) { - if (method1->is_inflated) - method1 = ((MonoMethodInflated*) method1)->declaring; - if (method2->is_inflated) - method2 = ((MonoMethodInflated*) method2)->declaring; + if (method1->slot != -1 && method1->slot == method2->slot) + return TRUE; + + if (mono_class_get_generic_type_definition (method1->klass) == mono_class_get_generic_type_definition (method2->klass)) { + if (method1->is_inflated) + method1 = ((MonoMethodInflated*) method1)->declaring; + if (method2->is_inflated) + method2 = ((MonoMethodInflated*) method2)->declaring; + } return mono_metadata_signature_equal (mono_method_signature (method1), mono_method_signature (method2)); } @@ -4188,10 +4121,10 @@ property_equal (MonoProperty *prop1, MonoProperty *prop2) the indexer came from method 1 or from method 2, and we shouldn't conflate them. (Bugzilla 36283) */ - if (prop1->get && prop2->get && !method_declaring_signatures_equal (prop1->get, prop2->get)) + if (prop1->get && prop2->get && !property_accessor_override (prop1->get, prop2->get)) return FALSE; - if (prop1->set && prop2->set && !method_declaring_signatures_equal (prop1->set, prop2->set)) + if (prop1->set && prop2->set && !property_accessor_override (prop1->set, prop2->set)) return FALSE; return TRUE; @@ -4206,49 +4139,40 @@ property_accessor_nonpublic (MonoMethod* accessor, gboolean start_klass) return method_nonpublic (accessor, start_klass); } -ICALL_EXPORT MonoArray* -ves_icall_RuntimeType_GetPropertiesByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype) +ICALL_EXPORT GPtrArray* +ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionType *type, gchar *propname, guint32 bflags, MonoBoolean ignore_case) { MonoError error; - MonoDomain *domain; MonoClass *startklass, *klass; - MonoArray *res; MonoMethod *method; MonoProperty *prop; - int i, match; + int match; guint32 flags; - gchar *propname = NULL; int (*compare_func) (const char *s1, const char *s2) = NULL; gpointer iter; GHashTable *properties = NULL; - MonoPtrArray tmp_array; + GPtrArray *res_array; - mono_error_init (&error); - - domain = ((MonoObject *)type)->vtable->domain; if (type->type->byref) { - res = mono_array_new_cached (domain, mono_class_get_property_info_class (), 0, &error); - mono_error_set_pending_exception (&error); - return res; + return g_ptr_array_new (); } - mono_ptr_array_init (tmp_array, 8, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection properties list"); /*This the average for ASP.NET types*/ - + mono_error_init (&error); + klass = startklass = mono_class_from_mono_type (type->type); - if (name != NULL) { - propname = mono_string_to_utf8_checked (name, &error); - if (mono_error_set_pending_exception (&error)) - return NULL; - compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp; - } + compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp; + + res_array = g_ptr_array_sized_new (8); /*This the average for ASP.NET types*/ properties = g_hash_table_new (property_hash, (GEqualFunc)property_equal); handle_parent: mono_class_setup_methods (klass); mono_class_setup_vtable (klass); - if (mono_class_has_failure (klass)) + if (mono_class_has_failure (klass)) { + mono_error_set_for_class_failure (&error, klass); goto loader_error; + } iter = NULL; while ((prop = mono_class_get_properties (klass, &iter))) { @@ -4286,49 +4210,28 @@ handle_parent: continue; match = 0; - if (name != NULL) { - if (compare_func (propname, prop->name)) - continue; - } + if (propname != NULL && compare_func (propname, prop->name)) + continue; if (g_hash_table_lookup (properties, prop)) continue; - MonoReflectionProperty *pr = mono_property_get_object_checked (domain, startklass, prop, &error); - if (!pr) - goto failure; - mono_ptr_array_append (tmp_array, pr); + g_ptr_array_add (res_array, prop); g_hash_table_insert (properties, prop, prop); } - if ((!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))) + if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)) goto handle_parent; g_hash_table_destroy (properties); - g_free (propname); - - res = mono_array_new_cached (domain, mono_class_get_property_info_class (), mono_ptr_array_size (tmp_array), &error); - if (!is_ok (&error)) - goto failure; - for (i = 0; i < mono_ptr_array_size (tmp_array); ++i) - mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i)); - - mono_ptr_array_destroy (tmp_array); - - return res; + return res_array; loader_error: - if (mono_class_has_failure (klass)) - mono_error_set_for_class_failure (&error, klass); - -failure: if (properties) g_hash_table_destroy (properties); - if (name) - g_free (propname); - mono_ptr_array_destroy (tmp_array); + g_ptr_array_free (res_array, TRUE); mono_error_set_pending_exception (&error); @@ -4350,32 +4253,28 @@ event_equal (MonoEvent *event1, MonoEvent *event2) return g_str_equal (event1->name, event2->name); } -ICALL_EXPORT MonoArray* -ves_icall_RuntimeType_GetEvents_internal (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoReflectionType *reftype) +ICALL_EXPORT GPtrArray* +ves_icall_RuntimeType_GetEvents_native (MonoReflectionType *type, char *utf8_name, guint32 bflags) { MonoError error; - MonoDomain *domain; MonoClass *startklass, *klass; - MonoArray *res; MonoMethod *method; MonoEvent *event; - int i, match; + int match; gpointer iter; - char *utf8_name = NULL; int (*compare_func) (const char *s1, const char *s2) = NULL; GHashTable *events = NULL; - MonoPtrArray tmp_array; + GPtrArray *res_array; - mono_error_init (&error); - - domain = mono_object_domain (type); if (type->type->byref) { - res = mono_array_new_cached (domain, mono_class_get_event_info_class (), 0, &error); - mono_error_set_pending_exception (&error); - return res; + return g_ptr_array_new (); } - mono_ptr_array_init (tmp_array, 4, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection events list"); + mono_error_init (&error); + + compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp; + + res_array = g_ptr_array_sized_new (4); klass = startklass = mono_class_from_mono_type (type->type); @@ -4383,8 +4282,10 @@ ves_icall_RuntimeType_GetEvents_internal (MonoReflectionType *type, MonoString * handle_parent: mono_class_setup_methods (klass); mono_class_setup_vtable (klass); - if (mono_class_has_failure (klass)) - goto loader_error; + if (mono_class_has_failure (klass)) { + mono_error_set_for_class_failure (&error, klass); + goto failure; + } iter = NULL; while ((event = mono_class_get_events (klass, &iter))) { @@ -4425,26 +4326,13 @@ handle_parent: if (!match) continue; - if (name != NULL) { - if (utf8_name == NULL) { - utf8_name = mono_string_to_utf8_checked (name, &error); - if (!is_ok (&error)) - goto failure; - compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp; - } - - if (compare_func (event->name, utf8_name)) - continue; - } + if (utf8_name != NULL && compare_func (event->name, utf8_name)) + continue; if (g_hash_table_lookup (events, event)) continue; - MonoReflectionEvent *ev_obj; - ev_obj = mono_event_get_object_checked (domain, startklass, event, &error); - if (!ev_obj) - goto failure; - mono_ptr_array_append (tmp_array, ev_obj); + g_ptr_array_add (res_array, event); g_hash_table_insert (events, event, event); } @@ -4453,59 +4341,31 @@ handle_parent: g_hash_table_destroy (events); - res = mono_array_new_cached (domain, mono_class_get_event_info_class (), mono_ptr_array_size (tmp_array), &error); - if (!is_ok (&error)) - goto failure; - - for (i = 0; i < mono_ptr_array_size (tmp_array); ++i) - mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i)); - - mono_ptr_array_destroy (tmp_array); - - if (utf8_name != NULL) - g_free (utf8_name); - - return res; - -loader_error: - if (mono_class_has_failure (klass)) - mono_error_set_for_class_failure (&error, klass); + return res_array; failure: - if (events != NULL) g_hash_table_destroy (events); - if (utf8_name != NULL) - g_free (utf8_name); - mono_ptr_array_destroy (tmp_array); + g_ptr_array_free (res_array, TRUE); mono_error_set_pending_exception (&error); return NULL; } -ICALL_EXPORT MonoArray* -ves_icall_RuntimeType_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint32 bflags) +ICALL_EXPORT GPtrArray * +ves_icall_RuntimeType_GetNestedTypes_native (MonoReflectionType *type, char *str, guint32 bflags) { - MonoError error; - MonoReflectionType *rt; - MonoDomain *domain; MonoClass *klass; - MonoArray *res = NULL; - int i, match; + int match; MonoClass *nested; gpointer iter; - char *str = NULL; - MonoPtrArray tmp_array; - - mono_error_init (&error); + GPtrArray *res_array; - domain = ((MonoObject *)type)->vtable->domain; if (type->type->byref) { - MonoArray *result = mono_array_new_cached (domain, mono_defaults.runtimetype_class, 0, &error); - mono_error_set_pending_exception (&error); - return result; + return g_ptr_array_new (); } + klass = mono_class_from_mono_type (type->type); /* @@ -4520,7 +4380,8 @@ ves_icall_RuntimeType_GetNestedTypes (MonoReflectionType *type, MonoString *name if (klass->generic_class) klass = klass->generic_class->container_class; - mono_ptr_array_init (tmp_array, 1, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection nested types list"); + res_array = g_ptr_array_new (); + iter = NULL; while ((nested = mono_class_get_nested_types (klass, &iter))) { match = 0; @@ -4534,39 +4395,13 @@ ves_icall_RuntimeType_GetNestedTypes (MonoReflectionType *type, MonoString *name if (!match) continue; - if (name != NULL) { - if (str == NULL) { - str = mono_string_to_utf8_checked (name, &error); - if (!is_ok (&error)) - goto leave; - mono_identifier_unescape_type_name_chars (str); - } - - if (strcmp (nested->name, str)) + if (str != NULL && strcmp (nested->name, str)) continue; - } - - rt = mono_type_get_object_checked (domain, &nested->byval_arg, &error); - if (!is_ok (&error)) - goto leave; - mono_ptr_array_append (tmp_array, (MonoObject*) rt); + g_ptr_array_add (res_array, &nested->byval_arg); } - res = mono_array_new_cached (domain, mono_defaults.runtimetype_class, mono_ptr_array_size (tmp_array), &error); - if (!is_ok (&error)) - goto leave; - - for (i = 0; i < mono_ptr_array_size (tmp_array); ++i) - mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i)); - -leave: - mono_ptr_array_destroy (tmp_array); - - g_free (str); - - mono_error_set_pending_exception (&error); - return res; + return res_array; } ICALL_EXPORT MonoReflectionType* @@ -4888,6 +4723,27 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAss return result; } +ICALL_EXPORT MonoString* +ves_icall_System_Reflection_Assembly_GetAotId () +{ + int i; + guint8 aotid_sum = 0; + MonoDomain* domain = mono_domain_get (); + + if (!domain->entry_assembly || !domain->entry_assembly->image) + return NULL; + + guint8 (*aotid)[16] = &domain->entry_assembly->image->aotid; + + for (i = 0; i < 16; ++i) + aotid_sum |= (*aotid)[i]; + + if (aotid_sum == 0) + return NULL; + + return mono_string_new (domain, mono_guid_to_string((guint8*) aotid)); +} + static MonoObject* create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, guint32 revision, MonoError *error) { @@ -5126,7 +4982,7 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflec mono_metadata_decode_row (table, i - 1, file_cols, MONO_FILE_SIZE); val = mono_metadata_string_heap (assembly->assembly->image, file_cols [MONO_FILE_NAME]); MONO_OBJECT_SETREF (info, filename, mono_string_new (mono_object_domain (assembly), val)); - if (file_cols [MONO_FILE_FLAGS] && FILE_CONTAINS_NO_METADATA) + if (file_cols [MONO_FILE_FLAGS] & FILE_CONTAINS_NO_METADATA) info->location = 0; else info->location = RESOURCE_LOCATION_EMBEDDED; @@ -5269,7 +5125,7 @@ ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly for (i = 0; i < file_count; ++i, ++j) { mono_metadata_decode_row (table, i, cols, MONO_FILE_SIZE); - if (cols [MONO_FILE_FLAGS] && FILE_CONTAINS_NO_METADATA) { + if (cols [MONO_FILE_FLAGS] & FILE_CONTAINS_NO_METADATA) { MonoReflectionModule *rm = mono_module_file_get_object_checked (domain, image, i, &error); if (mono_error_set_pending_exception (&error)) return NULL; @@ -5352,21 +5208,24 @@ mono_method_get_equivalent_method (MonoMethod *method, MonoClass *klass) } ICALL_EXPORT MonoReflectionMethod* -ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternalType (MonoMethod *method, MonoType *type) +ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternalType_native (MonoMethod *method, MonoType *type, MonoBoolean generic_check) { MonoReflectionMethod *res = NULL; MonoError error; MonoClass *klass; - if (type) { + if (type && generic_check) { klass = mono_class_from_mono_type (type); - if (mono_class_get_generic_type_definition (method->klass) != mono_class_get_generic_type_definition (klass)) + if (mono_class_get_generic_type_definition (method->klass) != mono_class_get_generic_type_definition (klass)) return NULL; + if (method->klass != klass) { method = mono_method_get_equivalent_method (method, klass); if (!method) return NULL; } - } else + } else if (type) + klass = mono_class_from_mono_type (type); + else klass = method->klass; res = mono_method_get_object_checked (mono_domain_get (), method, klass, &error); mono_error_set_pending_exception (&error); @@ -7331,16 +7190,6 @@ ves_icall_System_Runtime_Versioning_VersioningHelper_GetRuntimeId (void) return 9; } -ICALL_EXPORT void -ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this_obj, - MonoReflectionMethod *method, - MonoArray *out_args) -{ - MonoError error; - mono_message_init (mono_object_domain (this_obj), this_obj, method, out_args, &error); - mono_error_set_pending_exception (&error); -} - #ifndef DISABLE_REMOTING ICALL_EXPORT MonoBoolean ves_icall_IsTransparentProxy (MonoObject *proxy)