[threadpool] Added dynamic concurrent queue implementation
[mono.git] / mcs / class / IKVM.Reflection / ConstructorInfo.cs
1 /*
2   Copyright (C) 2009 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
27 namespace IKVM.Reflection
28 {
29         public abstract class ConstructorInfo : MethodBase
30         {
31                 // prevent external subclasses
32                 internal ConstructorInfo()
33                 {
34                 }
35
36                 public static readonly string ConstructorName = ".ctor";
37                 public static readonly string TypeConstructorName = ".cctor";
38
39                 internal abstract MethodInfo GetMethodInfo();
40
41                 internal override MethodBase BindTypeParameters(Type type)
42                 {
43                         return new ConstructorInfoImpl((MethodInfo)GetMethodInfo().BindTypeParameters(type));
44                 }
45
46                 public sealed override MemberTypes MemberType
47                 {
48                         get { return MemberTypes.Constructor; }
49                 }
50
51                 public override bool ContainsGenericParameters
52                 {
53                         get { return GetMethodInfo().ContainsGenericParameters; }
54                 }
55
56                 public sealed override ParameterInfo[] GetParameters()
57                 {
58                         ParameterInfo[] parameters = GetMethodInfo().GetParameters();
59                         for (int i = 0; i < parameters.Length; i++)
60                         {
61                                 parameters[i] = new ParameterInfoWrapper(this, parameters[i]);
62                         }
63                         return parameters;
64                 }
65
66                 private sealed class ParameterInfoWrapper : ParameterInfo
67                 {
68                         private readonly ConstructorInfo ctor;
69                         private readonly ParameterInfo forward;
70
71                         internal ParameterInfoWrapper(ConstructorInfo ctor, ParameterInfo forward)
72                         {
73                                 this.ctor = ctor;
74                                 this.forward = forward;
75                         }
76
77                         public override string Name
78                         {
79                                 get { return forward.Name; }
80                         }
81
82                         public override Type ParameterType
83                         {
84                                 get { return forward.ParameterType; }
85                         }
86
87                         public override ParameterAttributes Attributes
88                         {
89                                 get { return forward.Attributes; }
90                         }
91
92                         public override int Position
93                         {
94                                 get { return forward.Position; }
95                         }
96
97                         public override object RawDefaultValue
98                         {
99                                 get { return forward.RawDefaultValue; }
100                         }
101
102                         public override Type[] GetOptionalCustomModifiers()
103                         {
104                                 return forward.GetOptionalCustomModifiers();
105                         }
106
107                         public override Type[] GetRequiredCustomModifiers()
108                         {
109                                 return forward.GetRequiredCustomModifiers();
110                         }
111
112                         public override MemberInfo Member
113                         {
114                                 get { return ctor; }
115                         }
116
117                         public override int MetadataToken
118                         {
119                                 get { return forward.MetadataToken; }
120                         }
121
122                         internal override Module Module
123                         {
124                                 get { return ctor.Module; }
125                         }
126
127                         internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
128                         {
129                                 return forward.GetCustomAttributesData(attributeType);
130                         }
131                 }
132         }
133
134         sealed class ConstructorInfoImpl : ConstructorInfo
135         {
136                 private readonly MethodInfo method;
137
138                 internal ConstructorInfoImpl(MethodInfo method)
139                 {
140                         this.method = method;
141                 }
142
143                 public override bool Equals(object obj)
144                 {
145                         ConstructorInfoImpl other = obj as ConstructorInfoImpl;
146                         return other != null && other.method.Equals(method);
147                 }
148
149                 public override int GetHashCode()
150                 {
151                         return method.GetHashCode();
152                 }
153
154                 public override MethodBody GetMethodBody()
155                 {
156                         return method.GetMethodBody();
157                 }
158
159                 public override CallingConventions CallingConvention
160                 {
161                         get { return method.CallingConvention; }
162                 }
163
164                 public override MethodAttributes Attributes
165                 {
166                         get { return method.Attributes; }
167                 }
168
169                 public override MethodImplAttributes GetMethodImplementationFlags()
170                 {
171                         return method.GetMethodImplementationFlags();
172                 }
173
174                 internal override int ParameterCount
175                 {
176                         get { return method.ParameterCount; }
177                 }
178
179                 public override Type DeclaringType
180                 {
181                         get { return method.DeclaringType; }
182                 }
183
184                 public override string Name
185                 {
186                         get { return method.Name; }
187                 }
188
189                 public override string ToString()
190                 {
191                         return method.ToString();
192                 }
193
194                 public override Module Module
195                 {
196                         get { return method.Module; }
197                 }
198
199                 public override int MetadataToken
200                 {
201                         get { return method.MetadataToken; }
202                 }
203
204                 public override bool __IsMissing
205                 {
206                         get { return method.__IsMissing; }
207                 }
208
209                 internal override MethodInfo GetMethodInfo()
210                 {
211                         return method;
212                 }
213
214                 internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
215                 {
216                         return method.GetCustomAttributesData(attributeType);
217                 }
218
219                 internal override MethodInfo GetMethodOnTypeDefinition()
220                 {
221                         return method.GetMethodOnTypeDefinition();
222                 }
223
224                 internal override MethodSignature MethodSignature
225                 {
226                         get { return method.MethodSignature; }
227                 }
228
229                 internal override int ImportTo(Emit.ModuleBuilder module)
230                 {
231                         return method.ImportTo(module);
232                 }
233         }
234 }