static CRITICAL_SECTION cominterop_mutex;
/* STDCALL on windows, CDECL everywhere else to work with XPCOM and MainWin COM */
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
#define STDCALL __stdcall
#else
#define STDCALL
guint32 ref_count;
guint32 gc_handle;
GHashTable* vtable_hash;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
gpointer free_marshaler;
#endif
} MonoCCW;
res->param_count = param_count;
// STDCALL on windows, CDECL everywhere else to work with XPCOM and MainWin COM
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
res->call_convention = MONO_CALL_STDCALL;
#else
res->call_convention = MONO_CALL_C;
static MonoClass*
cominterop_get_method_interface (MonoMethod* method)
{
+ MonoError error;
MonoClass *ic = method->klass;
/* if method is on a class, we need to look up interface method exists on */
if (!MONO_CLASS_IS_INTERFACE(method->klass)) {
- GPtrArray *ifaces = mono_class_get_implemented_interfaces (method->klass);
+ GPtrArray *ifaces = mono_class_get_implemented_interfaces (method->klass, &error);
+ g_assert (mono_error_ok (&error));
if (ifaces) {
int i;
+ mono_class_setup_vtable (method->klass);
for (i = 0; i < ifaces->len; ++i) {
- int offset;
+ int j, offset;
+ gboolean found = FALSE;
ic = g_ptr_array_index (ifaces, i);
offset = mono_class_interface_offset (method->klass, ic);
- if (method->slot >= offset && method->slot < offset + ic->method.count)
+ for (j = 0; j < ic->method.count; ++j) {
+ if (method->klass->vtable [j + offset] == method) {
+ found = TRUE;
+ break;
+ }
+ }
+ if (found)
break;
ic = NULL;
}
}
}
- g_assert (ic);
+ if (!ic)
+ g_assert (ic);
g_assert (MONO_CLASS_IS_INTERFACE (ic));
return ic;
/* if method is on a class, we need to look up interface method exists on */
if (!MONO_CLASS_IS_INTERFACE(ic)) {
int offset = 0;
+ int i = 0;
ic = cominterop_get_method_interface (method);
offset = mono_class_interface_offset (method->klass, ic);
g_assert(offset >= 0);
- slot -= offset;
+ for(i = 0; i < ic->method.count; ++i) {
+ if (method->klass->vtable [i + offset] == method)
+ {
+ slot = ic->methods[i]->slot;
+ break;
+ }
+ }
}
g_assert (ic);
cominterop_com_visible (MonoClass* klass)
{
static MonoClass *ComVisibleAttribute = NULL;
+ MonoError error;
MonoCustomAttrInfo *cinfo;
GPtrArray *ifaces;
MonoBoolean visible = 0;
return TRUE;
}
- ifaces = mono_class_get_implemented_interfaces (klass);
+ ifaces = mono_class_get_implemented_interfaces (klass, &error);
+ g_assert (mono_error_ok (&error));
if (ifaces) {
int i;
for (i = 0; i < ifaces->len; ++i) {
if (!method->klass->methods)
mono_class_setup_methods (method->klass);
+ g_assert (!method->klass->exception_type); /*FIXME do proper error handling*/
sig = mono_method_signature (method);
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_COMINTEROP);
/* csig = mono_metadata_signature_dup (sig); */
/* STDCALL on windows, CDECL everywhere else to work with XPCOM and MainWin COM */
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
csig->call_convention = MONO_CALL_STDCALL;
#else
csig->call_convention = MONO_CALL_C;
if (!ccw) {
ccw = g_new0 (MonoCCW, 1);
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
ccw->free_marshaler = 0;
#endif
ccw->vtable_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
/* allow gc of object */
guint32 oldhandle = ccw->gc_handle;
g_assert (oldhandle);
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
if (ccw->free_marshaler)
ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (ccw->free_marshaler);
#endif
return ref_count;
}
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
static const IID MONO_IID_IMarshal = {0x3, 0x0, 0x0, {0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x46}};
#endif
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
/* All ccw objects are free threaded */
static int
cominterop_ccw_getfreethreadedmarshaler (MonoCCW* ccw, MonoObject* object, gpointer* ppv)
{
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
if (!ccw->free_marshaler) {
int ret = 0;
gpointer tunk;
static int STDCALL
cominterop_ccw_queryinterface (MonoCCWInterface* ccwe, guint8* riid, gpointer* ppv)
{
+ MonoError error;
GPtrArray *ifaces;
MonoClass *itf = NULL;
int i;
return MONO_S_OK;
}
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
/* handle IMarshal special */
if (0 == memcmp (riid, &MONO_IID_IMarshal, sizeof (IID))) {
return cominterop_ccw_getfreethreadedmarshaler (ccw, object, ppv);
#endif
klass_iter = klass;
while (klass_iter && klass_iter != mono_defaults.object_class) {
- ifaces = mono_class_get_implemented_interfaces (klass_iter);
+ ifaces = mono_class_get_implemented_interfaces (klass_iter, &error);
+ g_assert (mono_error_ok (&error));
if (ifaces) {
for (i = 0; i < ifaces->len; ++i) {
MonoClass *ic = NULL;
{
if (!string_obj)
return NULL;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
return SysAllocStringLen (mono_string_chars (string_obj), mono_string_length (string_obj));
#else
if (com_provider == MONO_COM_DEFAULT) {
{
if (!bstr)
return NULL;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
return mono_string_new_utf16 (mono_domain_get (), bstr, SysStringLen (bstr));
#else
if (com_provider == MONO_COM_DEFAULT) {
{
if (!bstr)
return;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
SysFreeString ((BSTR)bstr);
#else
if (com_provider == MONO_COM_DEFAULT) {
guint32 mono_marshal_safearray_get_dim (gpointer safearray)
{
guint32 result=0;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
result = SafeArrayGetDim (safearray);
#else
if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {
int mono_marshal_safe_array_get_lbound (gpointer psa, guint nDim, glong* plLbound)
{
int result=MONO_S_OK;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
result = SafeArrayGetLBound (psa, nDim, plLbound);
#else
if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {
int mono_marshal_safe_array_get_ubound (gpointer psa, guint nDim, glong* plUbound)
{
int result=MONO_S_OK;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
result = SafeArrayGetUBound (psa, nDim, plUbound);
#else
if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {
int i;
gboolean bounded = FALSE;
-#ifndef PLATFORM_WIN32
+#ifndef HOST_WIN32
// If not on windows, check that the MS provider is used as it is
// required for SAFEARRAY support.
// If SAFEARRAYs are not supported, returning FALSE from this
gpointer mono_marshal_safearray_get_value (gpointer safearray, gpointer indices)
{
gpointer result;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
int hr = SafeArrayPtrOfIndex (safearray, indices, &result);
if (hr < 0) {
cominterop_raise_hr_exception (hr);
void mono_marshal_safearray_end (gpointer safearray, gpointer indices)
{
g_free(indices);
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
SafeArrayDestroy (safearray);
#else
if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {