[sgen] Fix warning
[mono.git] / mono / metadata / icall.c
index 2d891f3fbfc0fc1342dcd6ccc2f8b0ee7ab571fc..7e7d4e0953e77b7a9fabadefe2cdaa8f54a9476c 100644 (file)
@@ -1924,28 +1924,30 @@ typedef enum {
 } PInfo;
 
 ICALL_EXPORT void
-ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info, PInfo req_info)
+ves_icall_get_property_info (const MonoReflectionProperty *property, MonoPropertyInfo *info, PInfo req_info)
 {
        MonoDomain *domain = mono_object_domain (property); 
+       const MonoProperty *pproperty = property->property;
 
        if ((req_info & PInfo_ReflectedType) != 0)
                MONO_STRUCT_SETREF (info, parent, mono_type_get_object (domain, &property->klass->byval_arg));
        if ((req_info & PInfo_DeclaringType) != 0)
-               MONO_STRUCT_SETREF (info, declaring_type, mono_type_get_object (domain, &property->property->parent->byval_arg));
+               MONO_STRUCT_SETREF (info, declaring_type, mono_type_get_object (domain, &pproperty->parent->byval_arg));
 
        if ((req_info & PInfo_Name) != 0)
-               MONO_STRUCT_SETREF (info, name, mono_string_new (domain, property->property->name));
+               MONO_STRUCT_SETREF (info, name, mono_string_new (domain, pproperty->name));
 
        if ((req_info & PInfo_Attributes) != 0)
-               info->attrs = property->property->attrs;
+               info->attrs = pproperty->attrs;
 
        if ((req_info & PInfo_GetMethod) != 0)
-               MONO_STRUCT_SETREF (info, get, property->property->get ?
-                                                       mono_method_get_object (domain, property->property->get, property->klass): NULL);
-       
+               MONO_STRUCT_SETREF (info, get, pproperty->get &&
+                                                       (((pproperty->get->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) || pproperty->get->klass == property->klass) ?
+                                                       mono_method_get_object (domain, pproperty->get, property->klass): NULL);
        if ((req_info & PInfo_SetMethod) != 0)
-               MONO_STRUCT_SETREF (info, set, property->property->set ?
-                                                       mono_method_get_object (domain, property->property->set, property->klass): NULL);
+               MONO_STRUCT_SETREF (info, set, pproperty->set &&
+                                                       (((pproperty->set->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) || pproperty->set->klass == property->klass) ?
+                                                       mono_method_get_object (domain, pproperty->set, property->klass): NULL);
        /* 
         * There may be other methods defined for properties, though, it seems they are not exposed 
         * in the reflection API 
@@ -3220,7 +3222,7 @@ ves_icall_Type_GetFields_internal (MonoReflectionType *type, MonoString *name, g
        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_ptr_array_init (tmp_array, 2, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection fields list");
        
 handle_parent: 
        if (klass->exception_type != MONO_EXCEPTION_NONE) {
@@ -3476,7 +3478,7 @@ ves_icall_Type_GetConstructors_internal (MonoReflectionType *type, guint32 bflag
        gpointer iter = NULL;
        MonoPtrArray tmp_array;
        
-       mono_ptr_array_init (tmp_array, 4); /*FIXME, guestimating*/
+       mono_ptr_array_init (tmp_array, 4, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection constructors list"); /*FIXME, guestimating*/
 
        domain = ((MonoObject *)type)->vtable->domain;
        if (type->type->byref)
@@ -3584,7 +3586,7 @@ ves_icall_Type_GetPropertiesByName (MonoReflectionType *type, MonoString *name,
        GHashTable *properties = NULL;
        MonoPtrArray tmp_array;
 
-       mono_ptr_array_init (tmp_array, 8); /*This the average for ASP.NET types*/
+       mono_ptr_array_init (tmp_array, 8, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection properties list"); /*This the average for ASP.NET types*/
 
        if (!System_Reflection_PropertyInfo)
                System_Reflection_PropertyInfo = mono_class_from_name (
@@ -3718,7 +3720,7 @@ ves_icall_Type_GetEvents_internal (MonoReflectionType *type, MonoString *name, g
        GHashTable *events = NULL;
        MonoPtrArray tmp_array;
 
-       mono_ptr_array_init (tmp_array, 4);
+       mono_ptr_array_init (tmp_array, 4, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection events list");
 
        if (!System_Reflection_EventInfo)
                System_Reflection_EventInfo = mono_class_from_name (
@@ -3851,7 +3853,7 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint
        if (klass->generic_class)
                klass = klass->generic_class->container_class;
 
-       mono_ptr_array_init (tmp_array, 1);
+       mono_ptr_array_init (tmp_array, 1, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection nested types list");
        iter = NULL;
        while ((nested = mono_class_get_nested_types (klass, &iter))) {
                match = 0;
@@ -5614,6 +5616,12 @@ ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegate *delegate)
        return ret;
 }
 
+ICALL_EXPORT MonoReflectionMethod*
+ves_icall_System_Delegate_GetVirtualMethod_internal (MonoDelegate *delegate)
+{
+       return mono_method_get_object (mono_domain_get (), mono_object_get_virtual_method (delegate->target, delegate->method), mono_object_class (delegate->target));
+}
+
 /* System.Buffer */
 
 static inline gint32 
@@ -5681,6 +5689,13 @@ ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, Mo
 {
        guint8 *src_buf, *dest_buf;
 
+       if (count < 0) {
+               mono_set_pending_exception (mono_get_exception_argument ("count", "is negative"));
+               return FALSE;
+       }
+
+       g_assert (count >= 0);
+
        /* This is called directly from the class libraries without going through the managed wrapper */
        MONO_CHECK_ARG_NULL (src, FALSE);
        MONO_CHECK_ARG_NULL (dest, FALSE);