Set svn:eol-style=native, delete svn:executable.
[mono.git] / mcs / class / corlib / System.Reflection.Emit / TypeBuilder.cs
index b129a0419204f34ffa309af3a08543eab58abb6a..2c8b519b4dbe6f92392f5e85a6ea418f40350598 100644 (file)
@@ -271,6 +271,8 @@ namespace System.Reflection.Emit {
                                                                       CallingConventions callConvention, Type[] types,
                                                                       ParameterModifier[] modifiers)
                {
+                       check_created ();
+                       
                        if (ctors == null)
                                return null;
 
@@ -623,7 +625,8 @@ namespace System.Reflection.Emit {
                
                public Type CreateType() {
                        /* handle nesting_type */
-                       check_not_created ();
+                       if (created != null)
+                               return created;
 
                        // Fire TypeResolve events for fields whose type is an unfinished
                        // value type.
@@ -1143,14 +1146,16 @@ 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 named_type = data [pos++];
+                                       pos ++;
                                        byte type = data [pos++];
                                        int len;
                                        string named_name;
 
                                        if (type == 0x55) {
                                                len = CustomAttributeBuilder.decode_len (data, pos, out pos);
-                                               string named_typename = CustomAttributeBuilder.string_from_bytes (data, pos, len);
+                                               //string named_typename = 
+                                               CustomAttributeBuilder.string_from_bytes (data, pos, len);
                                                pos += len;
                                                // FIXME: Check that 'named_type' and 'named_typename' match, etc.
                                                //        See related code/FIXME in mono/mono/metadata/reflection.c
@@ -1169,11 +1174,14 @@ namespace System.Reflection.Emit {
                                                switch ((CharSet)value) {
                                                case CharSet.None:
                                                case CharSet.Ansi:
+                                                       attrs &= ~(TypeAttributes.UnicodeClass | TypeAttributes.AutoClass);
                                                        break;
                                                case CharSet.Unicode:
+                                                       attrs &= ~TypeAttributes.AutoClass;
                                                        attrs |= TypeAttributes.UnicodeClass;
                                                        break;
                                                case CharSet.Auto:
+                                                       attrs &= ~TypeAttributes.UnicodeClass;
                                                        attrs |= TypeAttributes.AutoClass;
                                                        break;
                                                default:
@@ -1333,6 +1341,27 @@ namespace System.Reflection.Emit {
                        return base.IsSubclassOf (c);
                }
 
+               [MonoTODO ("arrays")]
+               internal bool IsAssignableTo (Type c)
+               {
+                       if (c == this)
+                               return true;
+
+                       if (c.IsInterface) {
+                               if (interfaces == null)
+                                       return false;
+                               foreach (Type t in interfaces)
+                                       if (c.IsAssignableFrom (t))
+                                               return true;
+                               return false;
+                       }
+
+                       if (parent == null)
+                               return c == typeof (object);
+                       else
+                               return c.IsAssignableFrom (parent);
+               }
+
 #if NET_2_0 || BOOTSTRAP_NET_2_0
                public bool IsCreated () {
                        return is_created;
@@ -1382,7 +1411,7 @@ namespace System.Reflection.Emit {
                        }
                }
 
-               public GenericTypeParameterBuilder[] DefineGenericParameters (string[] names)
+               public GenericTypeParameterBuilder[] DefineGenericParameters (params string[] names)
                {
                        setup_generic_class ();