daf50bbc95e13a982040599db9d6a8485aa548f6
[mono.git] / mcs / class / corlib / System.Reflection.Emit / GenericTypeParameterBuilder.cs
1 //
2 // System.Reflection.Emit.GenericTypeParameterBuilder
3 //
4 // Martin Baulig (martin@ximian.com)
5 //
6 // (C) 2004 Novell, Inc.
7 //
8
9 using System.Reflection;
10 using System.Reflection.Emit;
11 using System.Collections;
12 using System.Runtime.CompilerServices;
13 using System.Globalization;
14 using System.Runtime.Serialization;
15
16 #if NET_1_2
17 namespace System.Reflection.Emit
18 {
19         public sealed class GenericTypeParameterBuilder : Type
20         {
21         #region Sync with reflection.h
22                 private TypeBuilder tbuilder;
23                 private MethodBuilder mbuilder;
24                 private string name;
25                 private int index;
26                 private Type base_type;
27                 private Type[] iface_constraints;
28         #endregion
29
30                 public void SetBaseTypeConstraint (Type base_type_constraint)
31                 {
32                         this.base_type = base_type_constraint;
33                 }
34
35                 public void SetInterfaceConstraints (Type[] iface_constraints)
36                 {
37                         this.iface_constraints = iface_constraints;
38                 }
39
40                 internal GenericTypeParameterBuilder (TypeBuilder tbuilder,
41                                                       MethodBuilder mbuilder,
42                                                       string name, int index)
43                 {
44                         this.tbuilder = tbuilder;
45                         this.mbuilder = mbuilder;
46                         this.name = name;
47                         this.index = index;
48
49                         initialize ();
50                 }
51
52                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
53                 private extern void initialize ();
54
55                 public override bool IsSubclassOf (Type c)
56                 {
57                         if (BaseType == null)
58                                 return false;
59                         else
60                                 return BaseType == c || BaseType.IsSubclassOf (c);
61                 }
62
63                 protected override TypeAttributes GetAttributeFlagsImpl ()
64                 {
65                         return TypeAttributes.Class;
66                 }
67
68                 protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
69                                                                        Binder binder,
70                                                                        CallingConventions callConvention,
71                                                                        Type[] types,
72                                                                        ParameterModifier[] modifiers)
73                 {
74                         throw not_supported ();
75                 }
76
77                 public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
78                 {
79                         throw not_supported ();
80                 }
81
82                 public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
83                 {
84                         throw not_supported ();
85                 }
86
87                 public override EventInfo[] GetEvents (BindingFlags bindingAttr)
88                 {
89                         throw not_supported ();
90                 }
91
92                 public override FieldInfo GetField (string name, BindingFlags bindingAttr)
93                 {
94                         throw not_supported ();
95                 }
96
97                 public override FieldInfo[] GetFields (BindingFlags bindingAttr)
98                 {
99                         throw not_supported ();
100                 }
101                 
102                 public override Type GetInterface (string name, bool ignoreCase)
103                 {
104                         throw not_supported ();
105                 }
106
107                 public override Type[] GetInterfaces ()
108                 {
109                         throw not_supported ();
110                 }
111                 
112                 public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
113                 {
114                         throw not_supported ();
115                 }
116
117                 public override MethodInfo [] GetMethods (BindingFlags bindingAttr)
118                 {
119                         throw not_supported ();
120                 }
121
122                 protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr,
123                                                              Binder binder,
124                                                              CallingConventions callConvention,
125                                                              Type[] types, ParameterModifier[] modifiers)
126                 {
127                         throw not_supported ();
128                 }
129
130                 public override Type GetNestedType (string name, BindingFlags bindingAttr)
131                 {
132                         throw not_supported ();
133                 }
134
135                 public override Type[] GetNestedTypes (BindingFlags bindingAttr)
136                 {
137                         throw not_supported ();
138                 }
139
140                 public override PropertyInfo [] GetProperties (BindingFlags bindingAttr)
141                 {
142                         throw not_supported ();
143                 }
144
145                 protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr,
146                                                                  Binder binder, Type returnType,
147                                                                  Type[] types,
148                                                                  ParameterModifier[] modifiers)
149                 {
150                         throw not_supported ();
151                 }
152
153                 protected override bool HasElementTypeImpl ()
154                 {
155                         return false;
156                 }
157
158                 protected override bool IsArrayImpl ()
159                 {
160                         return false;
161                 }
162
163                 protected override bool IsByRefImpl ()
164                 {
165                         return false;
166                 }
167
168                 protected override bool IsCOMObjectImpl ()
169                 {
170                         return false;
171                 }
172
173                 protected override bool IsPointerImpl ()
174                 {
175                         return false;
176                 }
177
178                 protected override bool IsPrimitiveImpl ()
179                 {
180                         return false;
181                 }
182
183                 protected override bool IsValueTypeImpl ()
184                 {
185 #warning "FIXME"
186                         return false;
187                         return base_type != null ? base_type.IsValueType : false;
188                 }
189                 
190                 public override object InvokeMember (string name, BindingFlags invokeAttr,
191                                                      Binder binder, object target, object[] args,
192                                                      ParameterModifier[] modifiers,
193                                                      CultureInfo culture, string[] namedParameters)
194                 {
195                         throw not_supported ();
196                 }
197
198                 public override Type GetElementType ()
199                 {
200                         throw not_supported ();
201                 }
202
203                 public override Type UnderlyingSystemType {
204                         get {
205                                 return null;
206                         }
207                 }
208
209                 public override Assembly Assembly {
210                         get { return tbuilder.Assembly; }
211                 }
212
213                 public override string AssemblyQualifiedName {
214                         get { return null; }
215                 }
216
217                 public override Type BaseType {
218                         get { return base_type; }
219                 }
220
221                 public override string FullName {
222                         get { return null; }
223                 }
224
225                 public override Guid GUID {
226                         get { return Guid.Empty; }
227                 }
228
229                 public override bool IsDefined (Type attributeType, bool inherit)
230                 {
231                         throw not_supported ();
232                 }
233
234                 public override object[] GetCustomAttributes (bool inherit)
235                 {
236                         throw not_supported ();
237                 }
238
239                 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
240                 {
241                         throw not_supported ();
242                 }
243
244                 public override MemberTypes MemberType {
245                         get { return MemberTypes.TypeInfo; }
246                 }
247
248                 public override string Name {
249                         get { return name; }
250                 }
251
252                 public override string Namespace {
253                         get { return null; }
254                 }
255
256                 public override Module Module {
257                         get { return tbuilder.Module; }
258                 }
259
260                 public override Type DeclaringType {
261                         get { return mbuilder != null ? null : tbuilder; }
262                 }
263
264                 public override Type ReflectedType {
265                         get {
266                                 return DeclaringType;
267                         }
268                 }
269
270                 public override RuntimeTypeHandle TypeHandle {
271                         get { throw not_supported (); }
272                 }
273
274                 public override int GetArrayRank ()
275                 {
276                         throw not_supported ();
277                 }
278
279                 public override Type GetGenericTypeDefinition ()
280                 {
281                         throw not_supported ();
282                 }
283
284                 public override bool HasGenericArguments {
285                         get { return false; }
286                 }
287
288                 public override bool ContainsGenericParameters {
289                         get { return false; }
290                 }
291
292                 public override bool IsGenericParameter {
293                         get { return true; }
294                 }
295
296                 public override int GenericParameterPosition {
297                         get { return index; }
298                 }
299
300                 public override MethodInfo DeclaringMethod {
301                         get { return mbuilder; }
302                 }
303
304                 private Exception not_supported ()
305                 {
306                         return new NotSupportedException ();
307                 }
308
309                 public override string ToString ()
310                 {
311                         return name;
312                 }
313         }
314 }
315 #endif