Tue Jan 22 22:54:18 CET 2002 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System / MonoType.cs
1 // System.MonoType
2 //
3 // Sean MacIsaac (macisaac@ximian.com)
4 //
5 // (C) 2001 Ximian, Inc.
6
7 using System.Reflection;
8 using System.Runtime.CompilerServices;
9 using System.Globalization;
10
11 namespace System
12 {
13         internal struct MonoTypeInfo {
14                 public string name;
15                 public string name_space;
16                 public Type parent;
17                 public Type etype;
18                 public Type[] interfaces;
19                 public Assembly assembly;
20                 public TypeAttributes attrs;
21                 public int rank;
22         }
23
24         internal class MonoType : Type
25         {
26
27                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
28                 private static extern void type_from_obj (MonoType type, Object obj);
29                 
30                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
31                 private static extern void get_type_info (RuntimeTypeHandle type, out MonoTypeInfo info);
32
33                 internal MonoType (Object obj) {
34                         type_from_obj (this, obj);
35                 }
36
37                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
38                 private static extern TypeAttributes get_attributes (Type type);
39         
40                 protected override TypeAttributes GetAttributeFlagsImpl () {
41                         return get_attributes (this);
42                 }
43
44                 protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
45                         throw new NotImplementedException ();
46                 }
47
48                 public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr) {
49                         throw new NotImplementedException ();
50                 }
51
52                 public override EventInfo GetEvent (string name, BindingFlags bindingAttr) {
53                         throw new NotImplementedException ();
54                 }
55
56                 public override EventInfo[] GetEvents (BindingFlags bindingAttr) {
57                         throw new NotImplementedException ();
58                 }
59
60                 public override FieldInfo GetField( string name, BindingFlags bindingAttr) {
61                         //FIXME
62                         return null;
63                 }
64
65                 public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
66                         //FIXME
67                         return null;
68                 }
69
70                 public override Type GetInterface (string name, bool ignoreCase) {
71                         throw new NotImplementedException ();
72                 }
73
74                 public override Type[] GetInterfaces()
75                 {
76                         MonoTypeInfo info;
77                         get_type_info (_impl, out info);
78                         return info.interfaces;
79                 }
80                 
81                 public override MemberInfo[] GetMembers( BindingFlags bindingAttr) {
82                         // FIXME
83                         throw new NotImplementedException ();
84                 }
85
86                 public override MethodInfo[] GetMethods (BindingFlags bindingAttr) {
87                         MemberInfo[] m = FindMembers (MemberTypes.Method, bindingAttr, null, null);
88                         MethodInfo[] res = new MethodInfo [m.Length];
89                         int i;
90                         for (i = 0; i < m.Length; ++i)
91                                 res [i] = (MethodInfo) m [i];
92                         return res;
93                 }
94
95                 protected override MethodInfo GetMethodImpl( string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
96                         // FIXME
97                         return null;
98                 }
99                 
100                 public override Type GetNestedType( string name, BindingFlags bindingAttr) {
101                         // FIXME
102                         return null;
103                 }
104
105                 public override Type[] GetNestedTypes (BindingFlags bindingAttr) {
106                         // FIXME
107                         return null;
108                 }
109
110                 public override PropertyInfo[] GetProperties( BindingFlags bindingAttr) {
111                         // FIXME
112                         return null;
113                 }
114                 
115                 protected override PropertyInfo GetPropertyImpl( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) {
116                         // FIXME
117                         return null;
118                 }
119
120                 protected override bool HasElementTypeImpl () {
121                         return IsArrayImpl() || IsByRefImpl() || IsPointerImpl ();
122                 }
123
124                 protected override bool IsArrayImpl () {
125                         return type_is_subtype_of (this, typeof (System.Array));
126                 }
127                 protected override bool IsByRefImpl () {
128                         // FIXME
129                         return false;
130                 }
131                 protected override bool IsCOMObjectImpl () {
132                         return false;
133                 }
134                 protected override bool IsPointerImpl () {
135                         // FIXME
136                         return false;
137                 }
138                 protected override bool IsPrimitiveImpl () {
139                         // FIXME
140                         return false;
141                 }
142                 protected override bool IsValueTypeImpl () {
143                         // test this one
144                         return (Attributes & TypeAttributes.ClassSemanticsMask) == TypeAttributes.ValueType;
145                 }
146                 
147                 public override object InvokeMember( string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) {
148                         // FIXME
149                         return null;
150                 }
151
152                 public override Type GetElementType()
153                 {
154                         MonoTypeInfo info;
155                         get_type_info (_impl, out info);
156                         return info.etype;
157                 }
158
159                 public override Type UnderlyingSystemType {
160                         get {
161                                 MonoTypeInfo info;
162                                 get_type_info (_impl, out info);
163                                 return info.etype;
164                         }
165                 }
166
167                 public override Assembly Assembly {
168                         get {
169                                 MonoTypeInfo info;
170                                 get_type_info (_impl, out info);
171                                 return info.assembly;
172                         }
173                 }
174
175                 public override string AssemblyQualifiedName {
176                         get {
177                                 return assQualifiedName ();
178                         }
179                 }
180
181                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
182                 private extern string assQualifiedName();
183
184                 public override Type BaseType {
185                         get {
186                                 MonoTypeInfo info;
187                                 get_type_info (_impl, out info);
188                                 return info.parent;
189                         }
190                 }
191
192                 public override string FullName {
193                         get {
194                                 string str = assQualifiedName ();
195                                 return str.Split(',')[0];
196                         }
197                 }
198
199                 public override Guid GUID {
200                         get {return Guid.Empty;}
201                 }
202
203                 public override bool IsDefined (Type attributeType, bool inherit)
204                 {
205                         return false;
206                 }
207
208                 public override object[] GetCustomAttributes (bool inherit)
209                 {
210                         return null;
211                 }
212
213                 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
214                 {
215                         return null;
216                 }
217
218                 public override MemberTypes MemberType {
219                         get {
220                                 return MemberTypes.All;
221                         }
222                 }
223
224                 public override string Name {
225                         get {
226                                 MonoTypeInfo info;
227                                 get_type_info (_impl, out info);
228                                 return info.name;
229                         }
230                 }
231
232                 public override string Namespace {
233                         get {
234                                 MonoTypeInfo info;
235                                 get_type_info (_impl, out info);
236                                 return info.name_space;
237                         }
238                 }
239
240                 public override Module Module {
241                         get {
242                                 return null;
243                         }
244                 }
245
246                 public override Type ReflectedType {
247                         get {
248                                 return null;
249                         }
250                 }
251
252                 public override RuntimeTypeHandle TypeHandle {
253                         get {
254                                 return _impl;
255                         }
256                 }
257
258                 public override int GetArrayRank () {
259                         MonoTypeInfo info;
260                         get_type_info (_impl, out info);
261                         return info.rank;
262                 }
263         }
264 }