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 */
21 guint32 row_size; /* calculated later with column_sizes */
23 guint32 column_sizes [9];
24 guint32 *values; /* rows * columns */
29 * The followinbg structure must match the C# implementation in our corlib.
32 struct _MonoReflectionMethod {
36 MonoReflectionType *reftype;
39 struct _MonoDelegate {
41 MonoObject *target_type;
43 MonoString *method_name;
45 gpointer delegate_trampoline;
46 MonoReflectionMethod *method_info;
49 typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
50 struct _MonoMulticastDelegate {
51 MonoDelegate delegate;
52 MonoMulticastDelegate *prev;
58 MonoClassField *field;
59 } MonoReflectionField;
64 MonoProperty *property;
65 } MonoReflectionProperty;
71 } MonoReflectionEvent;
75 MonoReflectionType *ClassImpl;
76 MonoObject *DefaultValueImpl;
77 MonoObject *MemberImpl;
81 } MonoReflectionParameter;
85 MonoAssembly *assembly;
86 } MonoReflectionAssembly;
89 MonoReflectionType *utype;
95 MonoReflectionType *parent;
96 MonoReflectionType *ret;
102 MonoReflectionType *parent;
104 MonoReflectionMethod *get;
105 MonoReflectionMethod *set;
110 MonoReflectionType *parent;
112 MonoReflectionMethod *add_method;
113 MonoReflectionMethod *remove_method;
114 MonoReflectionMethod *raise_method;
119 MonoReflectionType *parent;
120 MonoReflectionType *type;
127 MonoString *name_space;
128 MonoReflectionType *etype;
129 MonoReflectionType *nested_in;
130 MonoReflectionAssembly *assembly;
132 MonoBoolean isprimitive;
138 } MonoReflectionILTokenInfo;
143 MonoObject *mbuilder;
148 MonoArray *ex_handlers;
149 gint32 num_token_fixups;
150 MonoArray *token_fixups;
151 } MonoReflectionILGen;
158 } MonoILExceptionInfo;
161 MonoReflectionType *extype;
165 gint32 filter_offset;
166 } MonoILExceptionBlock;
170 MonoReflectionType *type;
172 } MonoReflectionLocalBuilder;
181 MonoString *marshaltype;
182 MonoReflectionType *marshaltyperef;
183 } MonoReflectionMarshal;
190 MonoReflectionMarshal *marshal_info;
194 } MonoReflectionParamBuilder;
199 MonoReflectionILGen *ilgen;
200 MonoArray *parameters;
208 MonoBoolean init_locals;
209 } MonoReflectionCtorBuilder;
214 MonoReflectionType *rtype;
215 MonoArray *parameters;
221 MonoReflectionILGen *ilgen;
225 MonoReflectionMethod *override_method;
227 MonoString *dllentry;
231 MonoBoolean init_locals;
232 } MonoReflectionMethodBuilder;
237 MonoReflectionType *parent;
238 MonoReflectionType *ret;
239 MonoArray *parameters;
243 } MonoReflectionArrayMethod;
253 MonoAssembly assembly;
256 guint32 metadata_rva;
258 guint32 cli_header_offset;
262 guint32 imp_names_offset;
268 } sections [MONO_SECTION_MAX];
270 GHashTable *handleref;
271 MonoGHashTable *tokens;
272 MonoGHashTable *blob_cache;
273 GList *array_methods;
274 MonoGHashTable *token_fixups;
275 MonoGHashTable *method_to_table_idx;
276 MonoGHashTable *field_to_table_idx;
280 guint32 strong_name_size;
281 MonoDynamicStream pefile;
282 MonoDynamicStream sheap;
283 MonoDynamicStream code; /* used to store method headers and bytecode */
284 MonoDynamicStream resources; /* managed embedded resources */
285 MonoDynamicStream us;
286 MonoDynamicStream blob;
287 MonoDynamicStream tstream;
288 MonoDynamicStream guid;
289 MonoDynamicTable tables [64];
290 } MonoDynamicAssembly;
295 MonoString *filename;
297 } MonoReflectionResource;
300 MonoReflectionAssembly assembly;
301 MonoDynamicAssembly *dynamic_assembly;
302 MonoReflectionMethodBuilder *entry_point;
307 MonoArray *resources;
314 MonoBoolean delay_sign;
316 } MonoReflectionAssemblyBuilder;
321 MonoReflectionType *type;
323 MonoObject *def_value;
326 MonoReflectionType *typeb;
329 MonoReflectionMarshal *marshal_info;
330 MonoClassField *handle;
331 } MonoReflectionFieldBuilder;
337 MonoReflectionType *type;
338 MonoArray *parameters;
340 MonoObject *def_value;
341 MonoReflectionMethodBuilder *set_method;
342 MonoReflectionMethodBuilder *get_method;
344 } MonoReflectionPropertyBuilder;
349 MonoReflectionAssembly *assembly;
352 MonoString *scopename;
353 gboolean is_resource;
354 } MonoReflectionModule;
357 MonoReflectionModule module;
362 MonoReflectionAssemblyBuilder *assemblyb;
363 MonoArray *global_methods;
364 MonoArray *global_fields;
365 } MonoReflectionModuleBuilder;
368 MonoReflectionType type;
371 MonoReflectionType *parent;
372 MonoReflectionType *nesting_type;
373 MonoArray *interfaces;
376 MonoArray *properties;
383 MonoReflectionModuleBuilder *module;
386 } MonoReflectionTypeBuilder;
391 MonoString *codebase;
392 gint32 major, minor, build, revision;
393 /* FIXME: add missing stuff */
394 /* CultureInfo cultureinfo;
395 AssemblyNameFlags flags;
396 AssemblyHashAlgorithm hashalg;
397 StrongNameKeyPair keypair;
398 AssemblyVersionCompatibility versioncompat;*/
399 MonoObject *cultureInfo;
403 MonoArray *publicKey;
405 MonoObject *versioncompat;
406 } MonoReflectionAssemblyName;
411 MonoReflectionType *type;
412 MonoReflectionTypeBuilder *typeb;
414 MonoReflectionMethodBuilder *add_method;
415 MonoReflectionMethodBuilder *remove_method;
416 MonoReflectionMethodBuilder *raise_method;
417 MonoArray *other_methods;
420 } MonoReflectionEventBuilder;
424 MonoReflectionMethod *ctor;
426 } MonoReflectionCustomAttr;
428 typedef struct MonoTypeNameParse MonoTypeNameParse;
430 struct MonoTypeNameParse {
433 MonoAssemblyName assembly;
434 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
440 MonoReflectionModuleBuilder *module;
441 MonoArray *arguments;
443 MonoReflectionType *return_type;
445 guint32 unmanaged_call_conv;
446 } MonoReflectionSigHelper;
452 } MonoCustomAttrEntry;
457 MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
458 } MonoCustomAttrInfo;
461 RESOURCE_LOCATION_EMBEDDED = 1,
462 RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
463 RESOURCE_LOCATION_IN_MANIFEST = 4
468 MonoReflectionAssembly *assembly;
469 MonoString *filename;
471 } MonoManifestResourceInfo;
473 char* mono_type_get_name (MonoType *type);
474 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
475 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
476 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
478 void mono_image_create_pefile (MonoReflectionAssemblyBuilder *assembly);
479 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
480 guint32 mono_image_insert_string (MonoReflectionAssemblyBuilder *assembly, MonoString *str);
481 guint32 mono_image_create_token (MonoDynamicAssembly *assembly, MonoObject *obj);
482 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
484 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
485 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
486 MonoReflectionModule* mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
487 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
488 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
489 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
490 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
491 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
492 /* note: this one is slightly different: we keep the whole array of params in the cache */
493 MonoReflectionParameter** mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
495 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
496 MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
498 MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
499 MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
500 MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method);
501 MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass);
502 MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
503 MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
504 MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event);
505 MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field);
506 MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, guint32 param);
507 void mono_custom_attrs_free (MonoCustomAttrInfo *ainfo);
509 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
511 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
513 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
515 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
517 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
520 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
523 mono_image_build_metadata (MonoReflectionAssemblyBuilder *assemblyb);
525 #endif /* __METADATA_REFLECTION_H__ */