LibreOffice Module cli_ure (master) 1
PolymorphicType.cs
Go to the documentation of this file.
1/*
2 * This file is part of the LibreOffice project.
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 */
18
19using System;
20using System.Collections;
21using System.Reflection;
22using System.Globalization;
23
24namespace uno {
25
26
27
84public class PolymorphicType: Type
85{
86 private Type m_base;
87 private string m_type_name;
88
89 private static Hashtable m_ht_types = Hashtable.Synchronized(new Hashtable(256));
90
106 public static PolymorphicType GetType(Type type, string name)
107 {
108 if (name == null || type == null)
109 throw new ArgumentNullException(
110 "cli-uno: uno.PolymorphicType.GetType was called with a null argument");
111 //check if the type is either an array of structs or a polymorphic struct.
112 if (type.IsArray)
113 {
115 while ((elementType = elementType.GetElementType()).IsArray);
116 //unfortunately we cannot check if it is a real polymorphic struct here.
117 if ( ! elementType.IsClass)
118 return null;
119
120
121 }
122 else if (Attribute.GetCustomAttribute(type, typeof(uno.TypeParametersAttribute))
123 == null)
124 {
125 return null;
126 }
127
128 lock (m_ht_types.SyncRoot)
129 {
131 if (t == null)
132 {
133 t = new PolymorphicType(type, name);
134 m_ht_types.Add(name, t);
135 }
136 return t;
137 }
138 }
139
140 private PolymorphicType(Type type, string name)
141 {
143 m_base = type;
144 }
145
146 public string PolymorphicName
147 {
148 get
149 {
150 return m_type_name;
151 }
152 }
153
155 {
156 get
157 {
158 return m_base;
159 }
160 }
161
162
163 //implementations of abstract methods and properties from base class
164 public override string Name
165 {
166 get
167 {
168 return m_base.Name;
169 }
170 }
171
172 public override Assembly Assembly
173 {
174 get
175 {
176 return m_base.Assembly;
177 }
178 }
179
180 public override string AssemblyQualifiedName
181 {
182 get
183 {
184 return m_base.AssemblyQualifiedName;
185 }
186 }
187
188 public override Type BaseType
189 {
190 get
191 {
192 return m_base.BaseType;
193 }
194 }
195
196 public override string FullName
197 {
198 get
199 {
200 return m_base.FullName;
201 }
202 }
203
204 public override Guid GUID
205 {
206 get
207 {
208 return m_base.GUID;
209 }
210 }
211
212 public override Module Module
213 {
214 get
215 {
216 return m_base.Module;
217 }
218 }
219
220 public override string Namespace
221 {
222 get
223 {
224 return m_base.Namespace;
225 }
226 }
227
228 public override RuntimeTypeHandle TypeHandle
229 {
230 get
231 {
232 return m_base.TypeHandle;
233 }
234 }
235
237 {
238 get
239 {
240 return m_base.UnderlyingSystemType;
241 }
242 }
243
244 public override Type DeclaringType
245 {
246 get
247 {
248 return m_base.DeclaringType;
249 }
250 }
251
252 public override object[] GetCustomAttributes(
253 bool inherit)
254 {
255 return m_base.GetCustomAttributes(inherit);
256 }
257
258 public override object[] GetCustomAttributes(
259 Type attributeType,
260 bool inherit)
261 {
262 return m_base.GetCustomAttributes(attributeType, inherit);
263 }
264
265 public override bool IsDefined(
266 Type attributeType,
267 bool inherit)
268 {
269 return IsDefined(attributeType, inherit);
270 }
271
272 protected override TypeAttributes GetAttributeFlagsImpl()
273 {
274 return m_base.Attributes;
275 }
276
277 protected override ConstructorInfo GetConstructorImpl(
278 BindingFlags bindingAttr,
279 Binder binder,
280 CallingConventions callConvention,
281 Type[] types,
282 ParameterModifier[] modifiers)
283 {
284 return m_base.GetConstructor(
285 bindingAttr, binder, callConvention, types, modifiers);
286 }
287
288 public override ConstructorInfo[] GetConstructors(
289 BindingFlags bindingAttr)
290 {
291 return m_base.GetConstructors(bindingAttr);
292 }
293
294 public override Type GetElementType()
295 {
296 return m_base.GetElementType();
297 }
298
299 public override EventInfo GetEvent(
300 string name,
301 BindingFlags bindingAttr)
302 {
303 return m_base.GetEvent(name, bindingAttr);
304 }
305
306 public override EventInfo[] GetEvents(
307 BindingFlags bindingAttr)
308 {
309 return m_base.GetEvents(bindingAttr);
310 }
311
312 public override FieldInfo GetField(
313 string name,
314 BindingFlags bindingAttr)
315 {
316 return m_base.GetField(name, bindingAttr);
317 }
318
319 public override FieldInfo[] GetFields(
320 BindingFlags bindingAttr)
321 {
322 return m_base.GetFields(bindingAttr);
323 }
324
325 public override Type GetInterface(
326 string name, bool ignoreCase)
327 {
328 return m_base.GetInterface(name, ignoreCase);
329 }
330
331 public override Type[] GetInterfaces()
332 {
333 return m_base.GetInterfaces();
334 }
335
336 public override MemberInfo[] GetMembers(
337 BindingFlags bindingAttr)
338 {
339 return m_base.GetMembers(bindingAttr);
340 }
341
342 protected override MethodInfo GetMethodImpl(
343 string name,
344 BindingFlags bindingAttr,
345 Binder binder,
346 CallingConventions callConvention,
347 Type[] types,
348 ParameterModifier[] modifiers)
349 {
350 return m_base.GetMethod(
351 name, bindingAttr, binder, callConvention, types, modifiers);
352 }
353
354 public override MethodInfo[] GetMethods(
355 BindingFlags bindingAttr)
356 {
357 return m_base.GetMethods(bindingAttr);
358 }
359
360 public override Type GetNestedType(
361 string name, BindingFlags bindingAttr)
362 {
363 return m_base.GetNestedType(name, bindingAttr);
364 }
365
366 public override Type[] GetNestedTypes(
367 BindingFlags bindingAttr)
368 {
369 return m_base.GetNestedTypes(bindingAttr);
370 }
371
372 public override PropertyInfo[] GetProperties(
373 BindingFlags bindingAttr)
374 {
375 return m_base.GetProperties(bindingAttr);
376 }
377
378 protected override PropertyInfo GetPropertyImpl(
379 string name,
380 BindingFlags bindingAttr,
381 Binder binder,
382 Type returnType,
383 Type[] types,
384 ParameterModifier[] modifiers)
385 {
386 return m_base.GetProperty(
387 name, bindingAttr, binder, returnType, types, modifiers);
388 }
389
390 protected override bool HasElementTypeImpl()
391 {
392 return m_base.HasElementType;
393 }
394
395 public override object InvokeMember(
396 string name,
397 BindingFlags invokeAttr,
398 Binder binder,
399 object target,
400 object[] args,
401 ParameterModifier[] modifiers,
402 CultureInfo culture,
403 string[] namedParameters)
404 {
405 return m_base.InvokeMember(
406 name, invokeAttr, binder, target, args, modifiers, culture, namedParameters);
407 }
408
409 protected override bool IsArrayImpl()
410 {
411 return m_base.IsArray;
412 }
413
414 protected override bool IsByRefImpl()
415 {
416 return m_base.IsByRef;
417 }
418
419 protected override bool IsCOMObjectImpl()
420 {
421 return m_base.IsCOMObject;
422 }
423
424 protected override bool IsPointerImpl()
425 {
426 return m_base.IsPointer;
427 }
428
429 protected override bool IsPrimitiveImpl()
430 {
431 return m_base.IsPrimitive;
432 }
433}
434}
std::unordered_map< std::string, LinkedList > Hashtable
XPropertyListType t
represents a polymorphic type.
override bool IsArrayImpl()
override object[] GetCustomAttributes(Type attributeType, bool inherit)
override bool IsDefined(Type attributeType, bool inherit)
override FieldInfo[] GetFields(BindingFlags bindingAttr)
override TypeAttributes GetAttributeFlagsImpl()
override Type UnderlyingSystemType
override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
override Type GetNestedType(string name, BindingFlags bindingAttr)
override bool IsPrimitiveImpl()
PolymorphicType(Type type, string name)
override Type BaseType
override EventInfo[] GetEvents(BindingFlags bindingAttr)
override bool IsByRefImpl()
override EventInfo GetEvent(string name, BindingFlags bindingAttr)
override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
override Type[] GetNestedTypes(BindingFlags bindingAttr)
override Type DeclaringType
override RuntimeTypeHandle TypeHandle
override MethodInfo[] GetMethods(BindingFlags bindingAttr)
override bool HasElementTypeImpl()
override Type GetElementType()
override FieldInfo GetField(string name, BindingFlags bindingAttr)
override string FullName
override Type[] GetInterfaces()
override string Namespace
override MemberInfo[] GetMembers(BindingFlags bindingAttr)
override Type GetInterface(string name, bool ignoreCase)
static Hashtable m_ht_types
override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
override bool IsCOMObjectImpl()
override object[] GetCustomAttributes(bool inherit)
override bool IsPointerImpl()
override string AssemblyQualifiedName
override string Name
static PolymorphicType GetType(Type type, string name)
provides a unique instance of this class.
override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
override Assembly Assembly
override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
is used to mark a UNO entity to have type parameters.
const char * name
std::shared_ptr< osl::Mutex > const & lock()
Type elementType(Type type)
args
ResultType type