Merge pull request #941 from upsilon/fix-layoutsettings-setter
[mono.git] / mono / metadata / marshal.c
index 9aa3badf700549cec88283e8257d9b08ac26a258..74c8be3c5f1c0daab762f3aa6d2cf4eabe79b66f 100644 (file)
@@ -2606,7 +2606,7 @@ mono_marshal_method_from_wrapper (MonoMethod *wrapper)
                        return res;
        case MONO_WRAPPER_MANAGED_TO_NATIVE:
                info = mono_marshal_get_wrapper_info (wrapper);
-               if (info && (info->subtype == WRAPPER_SUBTYPE_NONE || info->subtype == WRAPPER_SUBTYPE_NATIVE_FUNC_AOT))
+               if (info && (info->subtype == WRAPPER_SUBTYPE_NONE || info->subtype == WRAPPER_SUBTYPE_NATIVE_FUNC_AOT || info->subtype == WRAPPER_SUBTYPE_PINVOKE))
                        return info->d.managed_to_native.method;
                else
                        return NULL;
@@ -4297,7 +4297,11 @@ mono_marshal_get_delegate_invoke (MonoMethod *method, MonoDelegate *del)
                invoke_sig = static_sig;
 
        if (static_method_with_first_arg_bound)
-               name = mono_signature_to_name (invoke_sig, "invoke_bound_");
+               name = mono_signature_to_name (invoke_sig, "invoke_bound");
+       else if (closed_over_null)
+               name = mono_signature_to_name (invoke_sig, "invoke_closed_over_null");
+       else if (callvirt)
+               name = mono_signature_to_name (invoke_sig, "invoke_callvirt");
        else
                name = mono_signature_to_name (sig, "invoke");
        if (ctx)
@@ -9040,7 +9044,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                                                        mb, csig, csig->param_count + 16);
        mono_mb_free (mb);
 
-       info = mono_wrapper_info_create (res, WRAPPER_SUBTYPE_NONE);
+       info = mono_wrapper_info_create (res, WRAPPER_SUBTYPE_PINVOKE);
        info->d.managed_to_native.method = method;
        mono_marshal_set_wrapper_info (res, info);
 
@@ -9656,8 +9660,8 @@ mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type)
        sig = mono_method_signature (method);
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_MANAGED_TO_MANAGED);
 
-#ifndef DISABLE_JIT
        param_count = sig->param_count + sig->hasthis;
+#ifndef DISABLE_JIT
        for (i = 0; i < param_count; i++)
                mono_mb_emit_ldarg (mb, i);
 
@@ -11800,7 +11804,9 @@ ves_icall_System_Runtime_InteropServices_Marshal_SizeOf (MonoReflectionType *rty
 
        layout = (klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK);
 
-       if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT) {
+       if (type->type == MONO_TYPE_PTR || type->type == MONO_TYPE_FNPTR) {
+               return sizeof (gpointer);
+       } else if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT) {
                gchar *msg;
                MonoException *exc;