1 #ifndef __METADATA_REFLECTION_H__
2 #define __METADATA_REFLECTION_H__
4 #include <mono/metadata/image.h>
5 #include <mono/metadata/metadata.h>
6 #include <mono/metadata/class.h>
7 #include <mono/metadata/object.h>
8 #include <mono/utils/mono-hash.h>
13 guint32 alloc_size; /* malloced bytes */
15 guint32 offset; /* from start of metadata */
20 guint32 row_size; /* calculated later with column_sizes */
22 guint32 column_sizes [9];
23 guint32 *values; /* rows * columns */
28 * The followinbg structure must match the C# implementation in our corlib.
31 struct _MonoReflectionMethod {
35 MonoReflectionType *reftype;
38 struct _MonoDelegate {
40 MonoObject *target_type;
42 MonoString *method_name;
44 gpointer delegate_trampoline;
45 MonoReflectionMethod *method_info;
48 typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
49 struct _MonoMulticastDelegate {
50 MonoDelegate delegate;
51 MonoMulticastDelegate *prev;
57 MonoClassField *field;
58 } MonoReflectionField;
63 MonoProperty *property;
64 } MonoReflectionProperty;
70 } MonoReflectionEvent;
74 MonoReflectionType *ClassImpl;
75 MonoObject *DefaultValueImpl;
76 MonoObject *MemberImpl;
80 } MonoReflectionParameter;
84 MonoAssembly *assembly;
85 } MonoReflectionAssembly;
88 MonoReflectionType *utype;
94 MonoReflectionType *parent;
95 MonoReflectionType *ret;
101 MonoReflectionType *parent;
103 MonoReflectionMethod *get;
104 MonoReflectionMethod *set;
109 MonoReflectionType *parent;
111 MonoReflectionMethod *add_method;
112 MonoReflectionMethod *remove_method;
113 MonoReflectionMethod *raise_method;
118 MonoReflectionType *parent;
119 MonoReflectionType *type;
126 MonoString *name_space;
127 MonoReflectionType *etype;
128 MonoReflectionType *nested_in;
129 MonoReflectionAssembly *assembly;
131 MonoBoolean isprimitive;
137 } MonoReflectionILTokenInfo;
142 MonoObject *mbuilder;
147 MonoArray *ex_handlers;
148 gint32 num_token_fixups;
149 MonoArray *token_fixups;
150 } MonoReflectionILGen;
157 } MonoILExceptionInfo;
160 MonoReflectionType *extype;
164 gint32 filter_offset;
165 } MonoILExceptionBlock;
169 MonoReflectionType *type;
171 } MonoReflectionLocalBuilder;
178 } MonoReflectionMarshal;
185 MonoReflectionMarshal *marshal_info;
189 } MonoReflectionParamBuilder;
194 MonoReflectionILGen *ilgen;
195 MonoArray *parameters;
203 MonoBoolean init_locals;
204 } MonoReflectionCtorBuilder;
209 MonoReflectionType *rtype;
210 MonoArray *parameters;
216 MonoReflectionILGen *ilgen;
220 MonoReflectionMethod *override_method;
222 MonoString *dllentry;
226 MonoBoolean init_locals;
227 } MonoReflectionMethodBuilder;
232 MonoReflectionType *parent;
233 MonoReflectionType *ret;
234 MonoArray *parameters;
238 } MonoReflectionArrayMethod;
248 MonoAssembly assembly;
251 guint32 metadata_rva;
253 guint32 cli_header_offset;
257 guint32 imp_names_offset;
263 } sections [MONO_SECTION_MAX];
265 GHashTable *handleref;
266 GList *array_methods;
267 MonoGHashTable *token_fixups;
268 MonoDynamicStream pefile;
269 MonoDynamicStream sheap;
270 MonoDynamicStream code; /* used to store method headers and bytecode */
271 MonoDynamicStream resources; /* managed embedded resources */
272 MonoDynamicStream us;
273 MonoDynamicStream blob;
274 MonoDynamicStream tstream;
275 MonoDynamicStream guid;
276 MonoDynamicTable tables [64];
277 } MonoDynamicAssembly;
282 MonoString *filename;
284 } MonoReflectionResource;
287 MonoReflectionAssembly assembly;
288 MonoDynamicAssembly *dynamic_assembly;
289 MonoReflectionMethodBuilder *entry_point;
294 MonoArray *resources;
295 } MonoReflectionAssemblyBuilder;
300 MonoReflectionType *type;
302 MonoObject *def_value;
305 MonoReflectionType *typeb;
308 MonoReflectionMarshal *marshal_info;
309 } MonoReflectionFieldBuilder;
315 MonoReflectionType *type;
316 MonoArray *parameters;
318 MonoObject *def_value;
319 MonoReflectionMethodBuilder *set_method;
320 MonoReflectionMethodBuilder *get_method;
322 } MonoReflectionPropertyBuilder;
327 MonoReflectionAssembly *assembly;
330 MonoString *scopename;
331 } MonoReflectionModule;
334 MonoReflectionModule module;
339 MonoReflectionAssemblyBuilder *assemblyb;
340 } MonoReflectionModuleBuilder;
343 MonoReflectionType type;
346 MonoReflectionType *parent;
347 MonoReflectionType *nesting_type;
348 MonoArray *interfaces;
351 MonoArray *properties;
358 MonoReflectionModuleBuilder *module;
361 } MonoReflectionTypeBuilder;
366 MonoString *codebase;
367 gint32 major, minor, build, revision;
368 /* FIXME: add missing stuff */
369 /* CultureInfo cultureinfo;
370 AssemblyNameFlags flags;
371 AssemblyHashAlgorithm hashalg;
372 StrongNameKeyPair keypair;
373 AssemblyVersionCompatibility versioncompat;*/
374 MonoObject *cultureInfo;
378 MonoObject *versioncompat;
379 } MonoReflectionAssemblyName;
384 MonoReflectionType *type;
385 MonoReflectionTypeBuilder *typeb;
387 MonoReflectionMethodBuilder *add_method;
388 MonoReflectionMethodBuilder *remove_method;
389 MonoReflectionMethodBuilder *raise_method;
390 MonoArray *other_methods;
393 } MonoReflectionEventBuilder;
397 MonoReflectionMethod *ctor;
399 } MonoReflectionCustomAttr;
401 typedef struct MonoTypeNameParse MonoTypeNameParse;
403 struct MonoTypeNameParse {
406 MonoAssemblyName assembly;
407 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
413 MonoReflectionModuleBuilder *module;
414 MonoArray *arguments;
416 } MonoReflectionSigHelper;
420 char* mono_type_get_name (MonoType *type);
421 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
422 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
423 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
425 void mono_image_create_pefile (MonoReflectionAssemblyBuilder *assembly);
426 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
427 guint32 mono_image_insert_string (MonoReflectionAssemblyBuilder *assembly, MonoString *str);
428 guint32 mono_image_create_token (MonoDynamicAssembly *assembly, MonoObject *obj);
430 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
431 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
432 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
433 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
434 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
435 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
436 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
437 /* note: this one is slightly different: we keep the whole array of params in the cache */
438 MonoReflectionParameter** mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
440 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
441 MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
443 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
445 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
447 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
449 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
451 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
453 #endif /* __METADATA_REFLECTION_H__ */