Merge pull request #1635 from alexrp/core-clr-properties
[mono.git] / mono / metadata / icall.c
index 759c6cec29b721c67b1c178b285a5c74d494fec2..a7a725a8d32c35459d1a1124050853c295e09720 100644 (file)
@@ -38,6 +38,7 @@
 #include <mono/metadata/threads.h>
 #include <mono/metadata/threads-types.h>
 #include <mono/metadata/threadpool.h>
+#include <mono/metadata/threadpool-microsoft.h>
 #include <mono/metadata/monitor.h>
 #include <mono/metadata/reflection.h>
 #include <mono/metadata/assembly.h>
@@ -292,6 +293,8 @@ ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32
                        INVALID_CAST;
                }
                break;
+       default:
+               break;
        }
 
        if (!ec->valuetype) {
@@ -1468,40 +1471,6 @@ handle_enum:
        return 0;
 }
 
-ICALL_EXPORT guint32
-ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, MonoBoolean check_interfaces)
-{
-       MonoDomain *domain; 
-       MonoClass *klass;
-       MonoClass *klassc;
-
-       g_assert (type != NULL);
-       
-       domain = ((MonoObject *)type)->vtable->domain;
-
-       if (!c) /* FIXME: dont know what do do here */
-               return 0;
-
-       klass = mono_class_from_mono_type (type->type);
-       klassc = mono_class_from_mono_type (c->type);
-
-       /* Interface check requires a more complex setup so we
-        * only do for them. Otherwise we simply avoid mono_class_init.
-        */
-       if (check_interfaces) {
-               mono_class_init_or_throw (klass);
-               mono_class_init_or_throw (klassc);
-       } else if (!klass->supertypes || !klassc->supertypes) {
-               mono_class_setup_supertypes (klass);
-               mono_class_setup_supertypes (klassc);
-       }
-
-       if (type->type->byref)
-               return klassc == mono_defaults.object_class;
-
-       return mono_class_is_subclass_of (klass, klassc, check_interfaces);
-}
-
 static gboolean
 mono_type_is_primitive (MonoType *type)
 {
@@ -1522,14 +1491,11 @@ mono_type_get_underlying_type_ignore_byref (MonoType *type)
 ICALL_EXPORT guint32
 ves_icall_type_is_assignable_from (MonoReflectionType *type, MonoReflectionType *c)
 {
-       MonoDomain *domain; 
        MonoClass *klass;
        MonoClass *klassc;
 
        g_assert (type != NULL);
        
-       domain = ((MonoObject *)type)->vtable->domain;
-
        klass = mono_class_from_mono_type (type->type);
        klassc = mono_class_from_mono_type (c->type);
 
@@ -2946,17 +2912,16 @@ read_enum_value (const char *mem, int type)
                return *(gint8*)mem;
        case MONO_TYPE_CHAR:
        case MONO_TYPE_U2:
-               return *(guint16*)mem;
+               return read16 (mem);
        case MONO_TYPE_I2:
-               return *(gint16*)mem;
+               return (gint16) read16 (mem);
        case MONO_TYPE_U4:
-               return *(guint32*)mem;
+               return read32 (mem);
        case MONO_TYPE_I4:
-               return *(gint32*)mem;
+               return (gint32) read32 (mem);
        case MONO_TYPE_U8:
-               return *(guint64*)mem;
        case MONO_TYPE_I8:
-               return *(gint64*)mem;
+               return read64 (mem);
        default:
                g_assert_not_reached ();
        }
@@ -3113,6 +3078,8 @@ ves_icall_System_Enum_compare_value_to (MonoObject *this, MonoObject *other)
                        COMPARE_ENUM_VALUES (guint64);
                case MONO_TYPE_I8:
                        COMPARE_ENUM_VALUES (gint64);
+               default:
+                       break;
        }
 #undef COMPARE_ENUM_VALUES
        /* indicates that the enum was of an unsupported unerlying type */
@@ -3157,7 +3124,7 @@ ves_icall_System_Enum_GetEnumValuesAndNames (MonoReflectionType *type, MonoArray
 {
        MonoDomain *domain = mono_object_domain (type); 
        MonoClass *enumc = mono_class_from_mono_type (type->type);
-       guint j = 0, nvalues, crow;
+       guint j = 0, nvalues;
        gpointer iter;
        MonoClassField *field;
        int base_type;
@@ -3177,11 +3144,9 @@ ves_icall_System_Enum_GetEnumValuesAndNames (MonoReflectionType *type, MonoArray
        *names = mono_array_new (domain, mono_defaults.string_class, nvalues);
        *values = mono_array_new (domain, mono_defaults.uint64_class, nvalues);
 
-       crow = -1;
        iter = NULL;
        while ((field = mono_class_get_fields (enumc, &iter))) {
                const char *p;
-               int len;
                MonoTypeEnum def_type;
 
                if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
@@ -3193,7 +3158,7 @@ ves_icall_System_Enum_GetEnumValuesAndNames (MonoReflectionType *type, MonoArray
                mono_array_setref (*names, j, mono_string_new (domain, mono_field_get_name (field)));
 
                p = mono_class_get_field_default_value (field, &def_type);
-               len = mono_metadata_decode_blob_size (p, &p);
+               /* len = */ mono_metadata_decode_blob_size (p, &p);
 
                field_value = read_enum_value (p, base_type);
                mono_array_set (*values, guint64, j, field_value);
@@ -3337,7 +3302,7 @@ mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bfla
        MonoClass *startklass;
        MonoMethod *method;
        gpointer iter;
-       int len, match, nslots;
+       int match, nslots;
        /*FIXME, use MonoBitSet*/
        guint32 method_slots_default [8];
        guint32 *method_slots = NULL;
@@ -3347,7 +3312,6 @@ mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bfla
        startklass = klass;
        *ex = NULL;
 
-       len = 0;
        if (name != NULL)
                compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp;
 
@@ -4695,6 +4659,20 @@ vell_icall_MonoType_get_core_clr_security_level (MonoReflectionType *this)
        return mono_security_core_clr_class_level (klass);
 }
 
+ICALL_EXPORT int
+ves_icall_MonoField_get_core_clr_security_level (MonoReflectionField *this)
+{
+       MonoClassField *field = this->field;
+       return mono_security_core_clr_field_level (field, TRUE);
+}
+
+ICALL_EXPORT int
+ves_icall_MonoMethod_get_core_clr_security_level (MonoReflectionMethod *this)
+{
+       MonoMethod *method = this->method;
+       return mono_security_core_clr_method_level (method, TRUE);
+}
+
 static void
 fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute, gboolean by_default_version, gboolean default_publickey, gboolean default_token)
 {
@@ -5797,9 +5775,6 @@ ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray
                                }
                                transitioned++;
                        } else {
-                               time_t te;
-                               te = mktime (&tt);
-                               
                                mono_array_setref ((*names), 0, mono_string_new (domain, tzone));
                                mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
                                if (gmtoff_ds == 0) {