Author: jbevain
Date: 2007-01-02 14:50:48 -0500 (Tue, 02 Jan 2007)
New Revision: 70383

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/blob.h
   trunk/mono/mono/metadata/reflection.c
Log:
2007-01-02  Jb Evain  <[EMAIL PROTECTED]>

        * blob.h: add a MONO_TYPE_ENUM definition
        * reflection.c (load_cattr_value, create_custom_attr, 
create_custom_attr_data):
        fix the encoding of arrays of enums in custom attributes.

        Fixes #79666.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-01-02 19:33:48 UTC (rev 70382)
+++ trunk/mono/mono/metadata/ChangeLog  2007-01-02 19:50:48 UTC (rev 70383)
@@ -1,3 +1,11 @@
+2007-01-02  Jb Evain  <[EMAIL PROTECTED]>
+
+       * blob.h: add a MONO_TYPE_ENUM definition
+       * reflection.c (load_cattr_value, create_custom_attr, 
create_custom_attr_data):
+       fix the encoding of arrays of enums in custom attributes.
+
+       Fixes #79666.
+
 2007-01-01  Miguel de Icaza  <[EMAIL PROTECTED]>
 
        * marshal.c (mono_string_to_byvalwstr): Fix this routine.   The

Modified: trunk/mono/mono/metadata/blob.h
===================================================================
--- trunk/mono/mono/metadata/blob.h     2007-01-02 19:33:48 UTC (rev 70382)
+++ trunk/mono/mono/metadata/blob.h     2007-01-02 19:50:48 UTC (rev 70383)
@@ -44,7 +44,9 @@
 
        MONO_TYPE_MODIFIER   = 0x40,       /* Or with the following types */
        MONO_TYPE_SENTINEL   = 0x41,       /* Sentinel for varargs method 
signature */
-       MONO_TYPE_PINNED     = 0x45       /* Local var that points to pinned 
object */
+       MONO_TYPE_PINNED     = 0x45,       /* Local var that points to pinned 
object */
+
+       MONO_TYPE_ENUM       = 0x55        /* an enumeration */
 } MonoTypeEnum;
 
 typedef enum {

Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c       2007-01-02 19:33:48 UTC (rev 
70382)
+++ trunk/mono/mono/metadata/reflection.c       2007-01-02 19:50:48 UTC (rev 
70383)
@@ -6767,6 +6767,8 @@
                }
                arr = mono_array_new (mono_domain_get(), tklass, alen);
                basetype = tklass->byval_arg.type;
+               if (basetype == MONO_TYPE_VALUETYPE && tklass->enumtype)
+                       basetype = tklass->enum_basetype->type;
                switch (basetype)
                {
                        case MONO_TYPE_U1:
@@ -6813,7 +6815,7 @@
                                }
                                break;
                        default:
-                               g_error("Type 0x%02x not handled in custom attr 
array decoding",t->data.type->type);
+                               g_error ("Type 0x%02x not handled in custom 
attr array decoding", basetype);
                }
                *end=p;
                return arr;
@@ -6983,14 +6985,12 @@
        named += 2;
        for (j = 0; j < num_named; j++) {
                gint name_len;
-               gboolean is_boxed = FALSE;
                char *name, named_type, data_type;
                named_type = *named++;
                data_type = *named++; /* type of data */
-               if (data_type == 0x51)
-                       is_boxed = TRUE;
-
-               if (data_type == 0x55) {
+               if (data_type == MONO_TYPE_SZARRAY)
+                       data_type = *named++;
+               if (data_type == MONO_TYPE_ENUM) {
                        gint type_len;
                        char *type_name;
                        type_len = mono_metadata_decode_blob_size (named, 
&named);
@@ -7000,10 +7000,6 @@
                        named += type_len;
                        /* FIXME: lookup the type and check type consistency */
                        g_free (type_name);
-               } else if (data_type == MONO_TYPE_SZARRAY && (named_type == 
0x54 || named_type == 0x53)) {
-                       /* this seems to be the type of the element of the 
array */
-                       /* g_print ("skipping 0x%02x after prop\n", *named); */
-                       named++;
                }
                name_len = mono_metadata_decode_blob_size (named, &named);
                name = g_malloc (name_len + 1);
@@ -7098,7 +7094,9 @@
                char *name, named_type, data_type;
                named_type = *named++;
                data_type = *named++; /* type of data */
-               if (data_type == 0x55) {
+               if (data_type == MONO_TYPE_SZARRAY)
+                       data_type = *named++;
+               if (data_type == MONO_TYPE_ENUM) {
                        gint type_len;
                        char *type_name;
                        type_len = mono_metadata_decode_blob_size (named, 
&named);
@@ -7108,10 +7106,6 @@
                        named += type_len;
                        /* FIXME: lookup the type and check type consistency */
                        g_free (type_name);
-               } else if (data_type == MONO_TYPE_SZARRAY && (named_type == 
0x54 || named_type == 0x53)) {
-                       /* this seems to be the type of the element of the 
array */
-                       /* g_print ("skipping 0x%02x after prop\n", *named); */
-                       named++;
                }
                name_len = mono_metadata_decode_blob_size (named, &named);
                name = g_malloc (name_len + 1);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to