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