Wrap always_inline and noinline attributes in compiler checks and use MSVC equivalent.
[mono.git] / mcs / class / IKVM.Reflection / Emit / EnumBuilder.cs
1 /*
2   Copyright (C) 2010 Jeroen Frijters
3
4   This software is provided 'as-is', without any express or implied
5   warranty.  In no event will the authors be held liable for any damages
6   arising from the use of this software.
7
8   Permission is granted to anyone to use this software for any purpose,
9   including commercial applications, and to alter it and redistribute it
10   freely, subject to the following restrictions:
11
12   1. The origin of this software must not be misrepresented; you must not
13      claim that you wrote the original software. If you use this software
14      in a product, an acknowledgment in the product documentation would be
15      appreciated but is not required.
16   2. Altered source versions must be plainly marked as such, and must not be
17      misrepresented as being the original software.
18   3. This notice may not be removed or altered from any source distribution.
19
20   Jeroen Frijters
21   jeroen@frijters.net
22   
23 */
24 using System;
25 using System.Collections.Generic;
26 using System.Text;
27
28 namespace IKVM.Reflection.Emit
29 {
30         public sealed class EnumBuilder : Type
31         {
32                 private readonly TypeBuilder typeBuilder;
33                 private readonly FieldBuilder fieldBuilder;
34
35                 internal EnumBuilder(TypeBuilder typeBuilder, FieldBuilder fieldBuilder)
36                         : base(typeBuilder)
37                 {
38                         this.typeBuilder = typeBuilder;
39                         this.fieldBuilder = fieldBuilder;
40                 }
41
42                 public override string __Name
43                 {
44                         get { return typeBuilder.__Name; }
45                 }
46
47                 public override string __Namespace
48                 {
49                         get { return typeBuilder.__Namespace; }
50                 }
51
52                 public override string Name
53                 {
54                         get { return typeBuilder.Name; }
55                 }
56
57                 public override string FullName
58                 {
59                         get { return typeBuilder.FullName; }
60                 }
61
62                 public override Type BaseType
63                 {
64                         get { return typeBuilder.BaseType; }
65                 }
66
67                 public override TypeAttributes Attributes
68                 {
69                         get { return typeBuilder.Attributes; }
70                 }
71
72                 public override Module Module
73                 {
74                         get { return typeBuilder.Module; }
75                 }
76
77                 public FieldBuilder DefineLiteral(string literalName, object literalValue)
78                 {
79                         FieldBuilder fb = typeBuilder.DefineField(literalName, typeBuilder, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
80                         fb.SetConstant(literalValue);
81                         return fb;
82                 }
83
84                 public Type CreateType()
85                 {
86                         return typeBuilder.CreateType();
87                 }
88
89                 public TypeToken TypeToken
90                 {
91                         get { return typeBuilder.TypeToken; }
92                 }
93
94                 public FieldBuilder UnderlyingField
95                 {
96                         get { return fieldBuilder; }
97                 }
98
99                 public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
100                 {
101                         typeBuilder.SetCustomAttribute(con, binaryAttribute);
102                 }
103
104                 public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
105                 {
106                         typeBuilder.SetCustomAttribute(customBuilder);
107                 }
108
109                 public override Type GetEnumUnderlyingType()
110                 {
111                         return fieldBuilder.FieldType;
112                 }
113
114                 internal override bool IsBaked
115                 {
116                         get { return typeBuilder.IsBaked; }
117                 }
118         }
119 }