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;
60 MonoReflectionType *type;
62 } MonoReflectionField;
67 MonoProperty *property;
68 } MonoReflectionProperty;
74 } MonoReflectionEvent;
78 MonoReflectionType *ClassImpl;
79 MonoObject *DefaultValueImpl;
80 MonoObject *MemberImpl;
84 } MonoReflectionParameter;
88 MonoAssembly *assembly;
89 } MonoReflectionAssembly;
92 MonoReflectionType *utype;
98 MonoReflectionType *parent;
99 MonoReflectionType *ret;
105 MonoReflectionType *parent;
107 MonoReflectionMethod *get;
108 MonoReflectionMethod *set;
113 MonoReflectionType *parent;
115 MonoReflectionMethod *add_method;
116 MonoReflectionMethod *remove_method;
117 MonoReflectionMethod *raise_method;
123 MonoString *name_space;
124 MonoReflectionType *etype;
125 MonoReflectionType *nested_in;
126 MonoReflectionAssembly *assembly;
128 MonoBoolean isprimitive;
134 } MonoReflectionILTokenInfo;
139 MonoObject *mbuilder;
144 MonoArray *ex_handlers;
145 gint32 num_token_fixups;
146 MonoArray *token_fixups;
147 } MonoReflectionILGen;
154 } MonoILExceptionInfo;
157 MonoReflectionType *extype;
161 gint32 filter_offset;
162 } MonoILExceptionBlock;
166 MonoReflectionType *type;
168 } MonoReflectionLocalBuilder;
177 MonoString *marshaltype;
178 MonoReflectionType *marshaltyperef;
179 } MonoReflectionMarshal;
186 MonoReflectionMarshal *marshal_info;
190 } MonoReflectionParamBuilder;
195 MonoReflectionILGen *ilgen;
196 MonoArray *parameters;
204 MonoBoolean init_locals;
205 } MonoReflectionCtorBuilder;
210 MonoReflectionType *rtype;
211 MonoArray *parameters;
217 MonoReflectionILGen *ilgen;
221 MonoReflectionMethod *override_method;
223 MonoString *dllentry;
227 MonoBoolean init_locals;
228 } MonoReflectionMethodBuilder;
233 MonoReflectionType *parent;
234 MonoReflectionType *ret;
235 MonoArray *parameters;
239 } MonoReflectionArrayMethod;
249 MonoAssembly assembly;
252 guint32 metadata_rva;
254 guint32 cli_header_offset;
258 guint32 imp_names_offset;
264 } sections [MONO_SECTION_MAX];
266 GHashTable *handleref;
267 MonoGHashTable *tokens;
268 MonoGHashTable *blob_cache;
269 GList *array_methods;
270 MonoGHashTable *token_fixups;
271 MonoGHashTable *method_to_table_idx;
272 MonoGHashTable *field_to_table_idx;
273 MonoGHashTable *param_marshalling;
277 guint32 strong_name_size;
278 MonoDynamicStream pefile;
279 MonoDynamicStream sheap;
280 MonoDynamicStream code; /* used to store method headers and bytecode */
281 MonoDynamicStream resources; /* managed embedded resources */
282 MonoDynamicStream us;
283 MonoDynamicStream blob;
284 MonoDynamicStream tstream;
285 MonoDynamicStream guid;
286 MonoDynamicTable tables [64];
287 } MonoDynamicAssembly;
292 MonoString *filename;
294 } MonoReflectionResource;
297 MonoReflectionAssembly assembly;
298 MonoDynamicAssembly *dynamic_assembly;
299 MonoReflectionMethodBuilder *entry_point;
304 MonoArray *resources;
311 MonoBoolean delay_sign;
313 } MonoReflectionAssemblyBuilder;
318 MonoReflectionType *type;
320 MonoObject *def_value;
323 MonoReflectionType *typeb;
326 MonoReflectionMarshal *marshal_info;
327 MonoClassField *handle;
328 } MonoReflectionFieldBuilder;
334 MonoReflectionType *type;
335 MonoArray *parameters;
337 MonoObject *def_value;
338 MonoReflectionMethodBuilder *set_method;
339 MonoReflectionMethodBuilder *get_method;
341 } MonoReflectionPropertyBuilder;
346 MonoReflectionAssembly *assembly;
349 MonoString *scopename;
350 MonoBoolean is_resource;
351 } MonoReflectionModule;
354 MonoReflectionModule module;
359 MonoReflectionAssemblyBuilder *assemblyb;
360 MonoArray *global_methods;
361 MonoArray *global_fields;
362 } MonoReflectionModuleBuilder;
365 MonoReflectionType type;
368 MonoReflectionType *parent;
369 MonoReflectionType *nesting_type;
370 MonoArray *interfaces;
373 MonoArray *properties;
380 MonoReflectionModuleBuilder *module;
383 MonoArray *generic_params;
384 } MonoReflectionTypeBuilder;
388 MonoGenericParam *param;
389 MonoReflectionType *type;
392 MonoArray *constraints;
393 } MonoReflectionGenericParam;
398 MonoString *codebase;
399 gint32 major, minor, build, revision;
400 /* FIXME: add missing stuff */
401 /* CultureInfo cultureinfo;
402 AssemblyNameFlags flags;
403 AssemblyHashAlgorithm hashalg;
404 StrongNameKeyPair keypair;
405 AssemblyVersionCompatibility versioncompat;*/
406 MonoObject *cultureInfo;
410 MonoArray *publicKey;
412 MonoObject *versioncompat;
413 } MonoReflectionAssemblyName;
418 MonoReflectionType *type;
419 MonoReflectionTypeBuilder *typeb;
421 MonoReflectionMethodBuilder *add_method;
422 MonoReflectionMethodBuilder *remove_method;
423 MonoReflectionMethodBuilder *raise_method;
424 MonoArray *other_methods;
427 } MonoReflectionEventBuilder;
431 MonoReflectionMethod *ctor;
433 } MonoReflectionCustomAttr;
435 typedef struct MonoTypeNameParse MonoTypeNameParse;
437 struct MonoTypeNameParse {
440 MonoAssemblyName assembly;
441 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
447 MonoReflectionModuleBuilder *module;
448 MonoArray *arguments;
450 MonoReflectionType *return_type;
452 guint32 unmanaged_call_conv;
453 } MonoReflectionSigHelper;
459 } MonoCustomAttrEntry;
464 MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
465 } MonoCustomAttrInfo;
468 RESOURCE_LOCATION_EMBEDDED = 1,
469 RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
470 RESOURCE_LOCATION_IN_MANIFEST = 4
475 MonoReflectionAssembly *assembly;
476 MonoString *filename;
478 } MonoManifestResourceInfo;
480 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
481 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
482 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
484 void mono_image_create_pefile (MonoReflectionAssemblyBuilder *assembly);
485 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
486 guint32 mono_image_insert_string (MonoReflectionAssemblyBuilder *assembly, MonoString *str);
487 guint32 mono_image_create_token (MonoDynamicAssembly *assembly, MonoObject *obj);
488 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
490 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
491 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
492 MonoReflectionModule* mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
493 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
494 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
495 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
496 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
497 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
498 /* note: this one is slightly different: we keep the whole array of params in the cache */
499 MonoArray* mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
501 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
502 MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
504 MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
505 MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
506 MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method);
507 MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass);
508 MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
509 MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
510 MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event);
511 MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field);
512 MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, guint32 param);
513 void mono_custom_attrs_free (MonoCustomAttrInfo *ainfo);
515 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
517 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
519 void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb);
521 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
523 MonoReflectionType* mono_reflection_define_generic_parameter (MonoReflectionTypeBuilder *tb, MonoReflectionGenericParam *gparam);
525 mono_reflection_bind_generic_parameters (MonoReflectionType *type, MonoArray *types);
527 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
529 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
532 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
535 mono_image_build_metadata (MonoReflectionAssemblyBuilder *assemblyb);
537 #endif /* __METADATA_REFLECTION_H__ */