Merge pull request #498 from Unroll-Me/master
[mono.git] / mcs / class / corlib / System.Reflection.Emit / EnumBuilder.cs
index 3073699abe4d89dddf8d6e254b05d2914aba9d7d..50a674473779299209f339f4915230de6f31272a 100644 (file)
@@ -31,6 +31,7 @@
 // (C) 2001 Ximian, Inc.  http://www.ximian.com
 //
 
+#if !FULL_AOT_RUNTIME
 using System;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -39,10 +40,8 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit {
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterface (typeof (_EnumBuilder))]
-#endif
        [ClassInterface (ClassInterfaceType.None)]
        public sealed class EnumBuilder : Type, _EnumBuilder {
                private TypeBuilder _tb;
@@ -55,7 +54,7 @@ namespace System.Reflection.Emit {
                                typeof(Enum), null, PackingSize.Unspecified, 0, null);
                        _underlyingType = underlyingType;
                        _underlyingField = _tb.DefineField ("value__", underlyingType,
-                               (FieldAttributes.SpecialName | FieldAttributes.Private));
+                               (FieldAttributes.SpecialName | FieldAttributes.Private | FieldAttributes.RTSpecialName));
                        setup_enum_type (_tb);
                }
 
@@ -64,6 +63,12 @@ namespace System.Reflection.Emit {
                        return _tb;
                }
 
+               internal override Type InternalResolve ()
+               {
+                       return _tb.InternalResolve (); 
+               }
+
+
                public override Assembly Assembly {
                        get {
                                return _tb.Assembly;
@@ -154,13 +159,21 @@ namespace System.Reflection.Emit {
                        return res;
                }
 
+#if NET_4_0
+               public override Type GetEnumUnderlyingType ()
+               {
+                       return _underlyingType;
+               }
+#endif
+
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern void setup_enum_type (Type t);
 
                public FieldBuilder DefineLiteral (string literalName, object literalValue)
                {
+                       Type fieldType = this;
                        FieldBuilder fieldBuilder = _tb.DefineField (literalName, 
-                               _underlyingType, (FieldAttributes.Literal | 
+                               fieldType, (FieldAttributes.Literal | 
                                (FieldAttributes.Static | FieldAttributes.Public)));
                        fieldBuilder.SetConstant (literalValue);
                        return fieldBuilder;
@@ -172,13 +185,14 @@ namespace System.Reflection.Emit {
                }
 
                protected override ConstructorInfo GetConstructorImpl (
-                       BindingFlags bindingAttr, Binder binder, CallingConventions cc,
+                       BindingFlags bindingAttr, Binder binder, CallingConventions callConvention,
                        Type[] types, ParameterModifier[] modifiers)
                {
-                       return _tb.GetConstructor (bindingAttr, binder, cc, types, 
+                       return _tb.GetConstructor (bindingAttr, binder, callConvention, types, 
                                modifiers);
                }
 
+               [ComVisible (true)]
                public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
                {
                        return _tb.GetConstructors (bindingAttr);
@@ -229,6 +243,7 @@ namespace System.Reflection.Emit {
                        return _tb.GetInterface (name, ignoreCase);
                }
 
+               [ComVisible (true)]
                public override InterfaceMapping GetInterfaceMap (Type interfaceType)
                {
                        return _tb.GetInterfaceMap (interfaceType);
@@ -340,47 +355,38 @@ namespace System.Reflection.Emit {
                        return _tb.IsDefined (attributeType, inherit);
                }
 
-               public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+               public override Type MakeArrayType ()
                {
-                       _tb.SetCustomAttribute (customBuilder);
+                       return  new ArrayType (this, 0);
                }
 
-#if NET_2_0
-               [ComVisible (true)]
-#endif
-               public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+               public override Type MakeArrayType (int rank)
                {
-                       SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+                       if (rank < 1)
+                               throw new IndexOutOfRangeException ();
+                       return new ArrayType (this, rank);
                }
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
-               [MonoTODO("Not implemented")]
-               public override Type[] GetGenericArguments ()
+               public override Type MakeByRefType ()
                {
-                       throw new NotImplementedException ();
+                       return new ByRefType (this);
                }
 
-               [MonoTODO("Not implemented")]
-               public override bool ContainsGenericParameters {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+               public override Type MakePointerType ()
+               {
+                       return new PointerType (this);
                }
 
-               [MonoTODO]
-               public override bool IsGenericParameter {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+               public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+               {
+                       _tb.SetCustomAttribute (customBuilder);
                }
 
-               [MonoTODO]
-               public override int GenericParameterPosition {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+               [ComVisible (true)]
+               public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+               {
+                       SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
                }
-#endif
 
                private Exception CreateNotSupportedException ()
                {
@@ -406,5 +412,12 @@ namespace System.Reflection.Emit {
                {
                        throw new NotImplementedException ();
                }
+
+               internal override bool IsUserType {
+                       get {
+                               return false;
+                       }
+               }
        }
 }
+#endif