2005-04-16 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Sat, 16 Apr 2005 15:54:50 +0000 (15:54 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 16 Apr 2005 15:54:50 +0000 (15:54 -0000)
* reflection.c reflection.h: Fix handling of parameter defaults in dynamic
methods. Also fixes handling of parameter attributes. Fixes #74609.

svn path=/trunk/mono/; revision=43094

mono/metadata/ChangeLog
mono/metadata/reflection.c
mono/metadata/reflection.h

index ad84a50cd3f3c03568a95e6809378fde422378b8..32739b00b3a01f918bdda17b97ba77874b3fb7e6 100644 (file)
@@ -1,3 +1,10 @@
+2005-04-16  Zoltan Varga  <vargaz@freemail.hu>
+
+       * reflection.c reflection.h: Fix handling of parameter defaults in dynamic
+       methods. Also fixes handling of parameter attributes. Fixes #74609.
+
+       * mono-debug.c (mono_debug_close_image): Fix warning.
+
 2005-04-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * socket-io.h: replaced old unused field with new 'blocking'.
index 667ed0a41ed9c99ef2d875f9418e5408e55b447d..276e372b4a5a9043ae59517a26d586b36bf5c5c0 100644 (file)
@@ -5757,8 +5757,10 @@ get_default_param_value_blobs (MonoMethod *method, char **blobs, guint32 *types)
 
        if (klass->image->dynamic) {
                MonoReflectionMethodAux *aux = g_hash_table_lookup (((MonoDynamicImage*)method->klass->image)->method_aux_hash, method);
-               if (aux && aux->param_defaults)
+               if (aux && aux->param_defaults) {
                        memcpy (blobs, &(aux->param_defaults [1]), methodsig->param_count * sizeof (char*));
+                       memcpy (types, &(aux->param_default_types [1]), methodsig->param_count * sizeof (guint32));
+               }
                return;
        }
 
@@ -7868,8 +7870,11 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
                for (i = 0; i <= m->signature->param_count; ++i) {
                        MonoReflectionParamBuilder *pb;
                        if ((pb = mono_array_get (rmb->pinfo, MonoReflectionParamBuilder*, i))) {
-                               if (i > 0)
+                               if ((i > 0) && (pb->attrs)) {
+                                       /* Make a copy since it might point to a shared type structure */
+                                       m->signature->params [i - 1] = g_memdup (m->signature->params [i - 1], sizeof (MonoType) + ((m->signature->params [i - 1]->num_mods - MONO_ZERO_LEN_ARRAY) * sizeof (MonoCustomMod)));
                                        m->signature->params [i - 1]->attrs = pb->attrs;
+                               }
 
                                if (pb->def_value) {
                                        MonoDynamicImage *assembly;
@@ -7877,8 +7882,10 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
                                        char *p;
                                        const char *p2;
 
-                                       if (!method_aux->param_defaults)
+                                       if (!method_aux->param_defaults) {
                                                method_aux->param_defaults = g_new0 (guint8*, m->signature->param_count + 1);
+                                               method_aux->param_default_types = g_new0 (guint32, m->signature->param_count + 1);
+                                       }
                                        assembly = (MonoDynamicImage*)klass->image;
                                        idx = encode_constant (assembly, pb->def_value, &def_type);
                                        /* Copy the data from the blob since it might get realloc-ed */
@@ -7886,6 +7893,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
                                        len = mono_metadata_decode_blob_size (p, &p2);
                                        len += p2 - p;
                                        method_aux->param_defaults [i] = g_malloc (len);
+                                       method_aux->param_default_types [i] = def_type;
                                        memcpy ((gpointer)method_aux->param_defaults [i], p, len);
                                }
 
index 150d261cf83044ac9a4cec2b75f90d28607403da..bd6a2d894d299fc67eae9208d449066b58d2919c 100644 (file)
@@ -35,6 +35,7 @@ typedef struct {
        MonoMarshalSpec **param_marshall;
        MonoCustomAttrInfo **param_cattr;
        guint8** param_defaults;
+       guint32 *param_default_types;
        char *dllentry, *dll;
 } MonoReflectionMethodAux;