Another .net 4 update
[mono.git] / mono / metadata / cominterop.c
index 6d9fe24c3c1ddb829b7cc7dbf74e1329b46cfdab..c43283055f0d0a6bcdd63a2fd25dd653e0e64781 100644 (file)
@@ -801,7 +801,7 @@ cominterop_get_native_wrapper_adjusted (MonoMethod *method)
                                mspecs[mspec_index] = g_new0 (MonoMarshalSpec, 1);
                                mspecs[mspec_index]->native = MONO_NATIVE_INTERFACE;
                        }
-                       else if (sig_native->params[i]->type == MONO_NATIVE_BOOLEAN) {
+                       else if (sig_native->params[i]->type == MONO_TYPE_BOOLEAN) {
                                mspecs[mspec_index] = g_new0 (MonoMarshalSpec, 1);
                                mspecs[mspec_index]->native = MONO_NATIVE_VARIANTBOOL;
                        }
@@ -824,7 +824,7 @@ cominterop_get_native_wrapper_adjusted (MonoMethod *method)
                                mspecs[0] = g_new0 (MonoMarshalSpec, 1);
                                mspecs[0]->native = MONO_NATIVE_INTERFACE;
                        }
-                       else if (sig->ret->type == MONO_NATIVE_BOOLEAN) {
+                       else if (sig->ret->type == MONO_TYPE_BOOLEAN) {
                                mspecs[0] = g_new0 (MonoMarshalSpec, 1);
                                mspecs[0]->native = MONO_NATIVE_VARIANTBOOL;
                        }
@@ -1525,6 +1525,9 @@ ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (MonoObject* object, Mon
        g_assert (type->type);
        klass = mono_type_get_class (type->type);
        g_assert (klass);
+       if (!mono_class_init (klass))
+               mono_raise_exception (mono_class_get_exception_for_failure (klass));
+
        itf = cominterop_get_ccw (object, klass);
        g_assert (itf);
        return itf;
@@ -1680,7 +1683,11 @@ gpointer
 ves_icall_System_ComObject_GetInterfaceInternal (MonoComObject* obj, MonoReflectionType* type, MonoBoolean throw_exception)
 {
 #ifndef DISABLE_COM
-       return cominterop_get_interface (obj, mono_type_get_class (type->type), (gboolean)throw_exception);
+       MonoClass *class = mono_type_get_class (type->type);
+       if (!mono_class_init (class))
+               mono_raise_exception (mono_class_get_exception_for_failure (class));
+
+       return cominterop_get_interface (obj, class, (gboolean)throw_exception);
 #else
        g_assert_not_reached ();
 #endif
@@ -1969,7 +1976,7 @@ cominterop_get_ccw (MonoObject* object, MonoClass* itf)
                                                mspecs[mspec_index] = g_new0 (MonoMarshalSpec, 1);
                                                mspecs[mspec_index]->native = MONO_NATIVE_INTERFACE;
                                        }
-                                       else if (sig_adjusted->params[param_index]->type == MONO_NATIVE_BOOLEAN) {
+                                       else if (sig_adjusted->params[param_index]->type == MONO_TYPE_BOOLEAN) {
                                                mspecs[mspec_index] = g_new0 (MonoMarshalSpec, 1);
                                                mspecs[mspec_index]->native = MONO_NATIVE_VARIANTBOOL;
                                        }
@@ -2000,7 +2007,7 @@ cominterop_get_ccw (MonoObject* object, MonoClass* itf)
                                                mspecs[0] = g_new0 (MonoMarshalSpec, 1);
                                                mspecs[0]->native = MONO_NATIVE_INTERFACE;
                                        }
-                                       else if (sig_adjusted->params[sig_adjusted->param_count-1]->type == MONO_NATIVE_BOOLEAN) {
+                                       else if (sig_adjusted->params[sig_adjusted->param_count-1]->type == MONO_TYPE_BOOLEAN) {
                                                mspecs[0] = g_new0 (MonoMarshalSpec, 1);
                                                mspecs[0]->native = MONO_NATIVE_VARIANTBOOL;
                                        }
@@ -2015,7 +2022,7 @@ cominterop_get_ccw (MonoObject* object, MonoClass* itf)
 
                        cominterop_setup_marshal_context (&m, adjust_method);
                        m.mb = mb;
-                       mono_marshal_emit_managed_wrapper (mb, sig_adjusted, mspecs, &m, adjust_method, NULL);
+                       mono_marshal_emit_managed_wrapper (mb, sig_adjusted, mspecs, &m, adjust_method, 0);
                        mono_loader_lock ();
                        mono_cominterop_lock ();
                        wrapper_method = mono_mb_create_method (mb, m.csig, m.csig->param_count + 16);
@@ -2692,7 +2699,7 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
 
                        if (t->byref) {
                                mono_mb_emit_ldarg (mb, argnum);
-                               mono_mb_emit_byte (mb, CEE_LDIND_I);
+                               mono_mb_emit_byte (mb, CEE_LDIND_REF);
                        } else
                                mono_mb_emit_ldarg (mb, argnum);
 
@@ -2707,7 +2714,7 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
 
                        label2 = mono_mb_emit_short_branch (mb, CEE_BRTRUE_S);
 
-                       index_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+                       index_var = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
                        mono_mb_emit_byte (mb, CEE_LDC_I4_0);
                        mono_mb_emit_stloc (mb, index_var);
 
@@ -2719,7 +2726,7 @@ mono_cominterop_emit_marshal_safearray (EmitMarshalContext *m, int argnum, MonoT
 
                        if (t->byref) {
                                mono_mb_emit_ldarg (mb, argnum);
-                               mono_mb_emit_byte (mb, CEE_LDIND_I);
+                               mono_mb_emit_byte (mb, CEE_LDIND_REF);
                        } else
                                mono_mb_emit_ldarg (mb, argnum);