register_icall (cominterop_get_interface, "cominterop_get_interface", "ptr object ptr int32", FALSE);
register_icall (mono_string_to_bstr, "mono_string_to_bstr", "ptr obj", FALSE);
- register_icall (mono_string_from_bstr, "mono_string_from_bstr", "obj ptr", FALSE);
+ register_icall (mono_string_from_bstr_icall, "mono_string_from_bstr_icall", "obj ptr", FALSE);
register_icall (mono_free_bstr, "mono_free_bstr", "void ptr", FALSE);
register_icall (cominterop_type_from_handle, "cominterop_type_from_handle", "object ptr", FALSE);
* Constructor does not need to be called. Will be called later.
*/
MonoVTable *vtable = mono_class_vtable_full (domain, klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
obj = mono_object_new_alloc_specific_checked (vtable, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
return obj;
}
#ifdef HOST_WIN32
/* All ccw objects are free threaded */
static int
-cominterop_ccw_getfreethreadedmarshaler (MonoCCW* ccw, MonoObject* object, gpointer* ppv)
+cominterop_ccw_getfreethreadedmarshaler (MonoCCW* ccw, MonoObject* object, gpointer* ppv, MonoError *error)
{
+ mono_error_init (error);
#ifdef HOST_WIN32
- MonoError error;
if (!ccw->free_marshaler) {
int ret = 0;
gpointer tunk;
- tunk = cominterop_get_ccw_checked (object, mono_class_get_iunknown_class (), &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ tunk = cominterop_get_ccw_checked (object, mono_class_get_iunknown_class (), error);
+ return_val_if_nok (error, MONO_E_NOINTERFACE);
ret = CoCreateFreeThreadedMarshaler (tunk, (LPUNKNOWN*)&ccw->free_marshaler);
}
#ifdef HOST_WIN32
/* handle IMarshal special */
if (0 == memcmp (riid, &MONO_IID_IMarshal, sizeof (IID))) {
- return cominterop_ccw_getfreethreadedmarshaler (ccw, object, ppv);
+ int res = cominterop_ccw_getfreethreadedmarshaler (ccw, object, ppv, &error);
+ mono_error_assert_ok (&error);
+ return res;
}
#endif
klass_iter = klass;
mono_string_from_bstr (gpointer bstr)
{
MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (bstr, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+MonoString *
+mono_string_from_bstr_icall (gpointer bstr)
+{
+ MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (bstr, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+MonoString *
+mono_string_from_bstr_checked (gpointer bstr, MonoError *error)
+{
MonoString * res = NULL;
+ mono_error_init (error);
+
if (!bstr)
return NULL;
#ifdef HOST_WIN32
- res = mono_string_new_utf16_checked (mono_domain_get (), bstr, SysStringLen (bstr), &error);
+ res = mono_string_new_utf16_checked (mono_domain_get (), bstr, SysStringLen (bstr), error);
#else
if (com_provider == MONO_COM_DEFAULT) {
- res = mono_string_new_utf16_checked (mono_domain_get (), (const mono_unichar2 *)bstr, *((guint32 *)bstr - 1) / sizeof(gunichar2), &error);
+ res = mono_string_new_utf16_checked (mono_domain_get (), (const mono_unichar2 *)bstr, *((guint32 *)bstr - 1) / sizeof(gunichar2), error);
} else if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {
MonoString* str = NULL;
glong written = 0;
gunichar2* utf16 = NULL;
utf16 = g_ucs4_to_utf16 ((const gunichar *)bstr, sys_string_len_ms (bstr), NULL, &written, NULL);
- str = mono_string_new_utf16_checked (mono_domain_get (), utf16, written, &error);
+ str = mono_string_new_utf16_checked (mono_domain_get (), utf16, written, error);
g_free (utf16);
res = str;
} else {
}
#endif
- mono_error_raise_exception (&error); /* FIXME don't raise here */
return res;
}
emit an exception in the generated IL.
*/
register_icall (mono_string_to_bstr, "mono_string_to_bstr", "ptr obj", FALSE);
- register_icall (mono_string_from_bstr, "mono_string_from_bstr", "obj ptr", FALSE);
+ register_icall (mono_string_from_bstr_icall, "mono_string_from_bstr_icall", "obj ptr", FALSE);
register_icall (mono_free_bstr, "mono_free_bstr", "void ptr", FALSE);
}
#endif
}
+
MonoString *
mono_string_from_bstr (gpointer bstr)
{
- MonoString *res = NULL;
MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (bstr, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+MonoString *
+mono_string_from_bstr_icall (gpointer bstr)
+{
+ MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (bstr, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+MonoString *
+mono_string_from_bstr_checked (gpointer bstr, MonoError *error)
+{
+ MonoString *res = NULL;
+ mono_error_init (error);
if (!bstr)
return NULL;
#ifdef HOST_WIN32
- res = mono_string_new_utf16_checked (mono_domain_get (), bstr, SysStringLen (bstr), &error);
+ res = mono_string_new_utf16_checked (mono_domain_get (), bstr, SysStringLen (bstr), error);
#else
- res = mono_string_new_utf16_checked (mono_domain_get (), bstr, *((guint32 *)bstr - 1) / sizeof(gunichar2), &error);
+ res = mono_string_new_utf16_checked (mono_domain_get (), bstr, *((guint32 *)bstr - 1) / sizeof(gunichar2), error);
#endif
- mono_error_raise_exception (&error); /* FIXME don't raise here */
return res;
}
MonoString *
ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (gpointer ptr)
{
- return mono_string_from_bstr(ptr);
+ MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (ptr, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
gpointer