[runtime] Use MonoError for mono_type_get_object
[mono.git] / mono / metadata / cominterop.c
index 9c4c8e60d371401b4c8b96845db4122bd7ca7d3c..162e7436406f30b3e0e3e46cb618c3a2e1031d19 100644 (file)
@@ -35,6 +35,8 @@
 #include "mono/utils/mono-counters.h"
 #include "mono/utils/strenc.h"
 #include "mono/utils/atomic.h"
+#include "mono/utils/mono-error.h"
+#include "mono/utils/mono-error-internals.h"
 #include <string.h>
 #include <errno.h>
 
@@ -520,11 +522,17 @@ cominterop_get_hresult_for_exception (MonoException* exc)
 static MonoReflectionType *
 cominterop_type_from_handle (MonoType *handle)
 {
+       MonoError error;
+       MonoReflectionType *ret;
        MonoDomain *domain = mono_domain_get (); 
        MonoClass *klass = mono_class_from_mono_type (handle);
 
        mono_class_init (klass);
-       return mono_type_get_object (domain, handle);
+
+       ret = mono_type_get_object_checked (domain, handle, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
+
+       return ret;
 }
 
 void
@@ -1600,6 +1608,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal
 MonoObject *
 ves_icall_System_ComObject_CreateRCW (MonoReflectionType *type)
 {
+       MonoError error;
        MonoClass *klass;
        MonoDomain *domain;
        MonoObject *obj;
@@ -1607,13 +1616,15 @@ ves_icall_System_ComObject_CreateRCW (MonoReflectionType *type)
        domain = mono_object_domain (type);
        klass = mono_class_from_mono_type (type->type);
 
-       /* call mono_object_new_alloc_specific instead of mono_object_new
+       /* call mono_object_new_alloc_specific_checked instead of mono_object_new
         * because we want to actually create object. mono_object_new checks
         * to see if type is import and creates transparent proxy. this method
         * is called by the corresponding real proxy to create the real RCW.
         * Constructor does not need to be called. Will be called later.
        */
-       obj = mono_object_new_alloc_specific (mono_class_vtable_full (domain, klass, TRUE));
+       obj = mono_object_new_alloc_specific_checked (mono_class_vtable_full (domain, klass, TRUE), &error);
+       mono_error_raise_exception (&error);
+
        return obj;
 }
 
@@ -2991,6 +3002,7 @@ int mono_marshal_safe_array_get_ubound (gpointer psa, guint nDim, glong* plUboun
 static gboolean
 mono_marshal_safearray_begin (gpointer safearray, MonoArray **result, gpointer *indices, gpointer empty, gpointer parameter, gboolean allocateNewArray)
 {
+       MonoError error;
        int dim;
        uintptr_t *sizes;
        intptr_t *bounds;
@@ -3049,7 +3061,8 @@ mono_marshal_safearray_begin (gpointer safearray, MonoArray **result, gpointer *
 
                        if (allocateNewArray) {
                                aklass = mono_bounded_array_class_get (mono_defaults.object_class, dim, bounded);
-                               *result = mono_array_new_full (mono_domain_get (), aklass, sizes, bounds);
+                               *result = mono_array_new_full_checked (mono_domain_get (), aklass, sizes, bounds, &error);
+                               mono_error_raise_exception (&error); /* FIXME don't raise here */
                        } else {
                                *result = (MonoArray *)parameter;
                        }