Tue Aug 27 16:57:18 CEST 2002 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Tue, 27 Aug 2002 14:59:42 +0000 (14:59 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Tue, 27 Aug 2002 14:59:42 +0000 (14:59 -0000)
* TypeBuilder.cs: remove duplicate code and fix
named field reading in custom attr.

svn path=/trunk/mcs/; revision=7089

mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs

index f621817916885addd9923e6b868e097a5d733b89..ef35e4451d825a581c2fb0cd093b87d41f46388a 100644 (file)
@@ -1,3 +1,9 @@
+
+Tue Aug 27 16:57:18 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+       * TypeBuilder.cs: remove duplicate code and fix
+       named field reading in custom attr.
+
 2002-08-24  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * TypeBuilder.cs: UnspecifiedTypeSize is 0.
index bc809b3b075fd85f13120eb1c8066adccfca8c70..be52f786da50a0aead8849e51988516094deee4e 100644 (file)
@@ -586,29 +586,6 @@ namespace System.Reflection.Emit {
                
                public override RuntimeTypeHandle TypeHandle { get { return _impl; } }
 
-               private static int decode_len (byte[] data, int pos, out int rpos) {
-                       int len = 0;
-                       if ((data [pos] & 0x80) == 0) {
-                               len = (int)(data [pos++] & 0x7f);
-                       } else if ((data [pos] & 0x40) == 0) {
-                               len = ((data [pos] & 0x3f) << 8) + data [pos + 1];
-                               pos += 2;
-                       } else {
-                               len = ((data [pos] & 0x1f) << 24) + (data [pos + 1] << 16) + (data [pos + 2] << 8) + data [pos + 3];
-                               pos += 4;
-                       }
-                       rpos = pos;
-                       return len;
-               }
-
-               private static string string_from_bytes (byte[] data, int pos, int len) {
-                       char[] chars = new char [len];
-                       // FIXME: use a utf8 decoder here
-                       for (int i = 0; i < len; ++i)
-                               chars [i] = (char)data [pos + i];
-                       return new String (chars);
-               }
-
                public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
                        string attrname = customBuilder.Ctor.ReflectedType.FullName;
                        if (attrname == "System.Runtime.InteropServices.StructLayoutAttribute") {
@@ -638,9 +615,10 @@ namespace System.Reflection.Emit {
                                int nnamed = (int)data [pos++];
                                nnamed |= ((int)data [pos++]) << 8;
                                for (int i = 0; i < nnamed; ++i) {
+                                       byte named_type = data [pos++];
                                        byte type = data [pos++];
-                                       int len = decode_len (data, pos, out pos);
-                                       string named_name = string_from_bytes (data, pos, len);
+                                       int len = CustomAttributeBuilder.decode_len (data, pos, out pos);
+                                       string named_name = CustomAttributeBuilder.string_from_bytes (data, pos, len);
                                        pos += len;
                                        /* all the fields are integers in StructLayout */
                                        int value = (int)data [pos++];