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 MonoObject *resolve_event_holder;
90 } MonoReflectionAssembly;
93 MonoReflectionType *utype;
99 MonoReflectionType *parent;
100 MonoReflectionType *ret;
107 MonoReflectionType *parent;
109 MonoReflectionMethod *get;
110 MonoReflectionMethod *set;
115 MonoReflectionType *declaring_type;
116 MonoReflectionType *reflected_type;
118 MonoReflectionMethod *add_method;
119 MonoReflectionMethod *remove_method;
120 MonoReflectionMethod *raise_method;
126 MonoString *name_space;
127 MonoReflectionType *etype;
128 MonoReflectionType *nested_in;
129 MonoReflectionAssembly *assembly;
131 MonoBoolean isprimitive;
137 } MonoReflectionILTokenInfo;
146 MonoArray *ex_handlers;
147 gint32 num_token_fixups;
148 MonoArray *token_fixups;
149 } MonoReflectionILGen;
156 } MonoILExceptionInfo;
159 MonoReflectionType *extype;
163 gint32 filter_offset;
164 } MonoILExceptionBlock;
168 MonoReflectionType *type;
170 MonoBoolean is_pinned;
171 } MonoReflectionLocalBuilder;
180 MonoString *marshaltype;
181 MonoReflectionType *marshaltyperef;
182 } MonoReflectionMarshal;
189 MonoReflectionMarshal *marshal_info;
193 } MonoReflectionParamBuilder;
198 MonoReflectionILGen *ilgen;
199 MonoArray *parameters;
207 MonoBoolean init_locals;
208 MonoArray *param_modreq;
209 MonoArray *param_modopt;
210 MonoArray *permissions;
211 } MonoReflectionCtorBuilder;
216 MonoReflectionType *rtype;
217 MonoArray *parameters;
223 MonoReflectionILGen *ilgen;
227 MonoReflectionMethod *override_method;
229 MonoString *dllentry;
233 MonoBoolean init_locals;
234 MonoArray *generic_params;
235 MonoArray *return_modreq;
236 MonoArray *return_modopt;
237 MonoArray *param_modreq;
238 MonoArray *param_modopt;
239 MonoArray *permissions;
240 } MonoReflectionMethodBuilder;
245 MonoReflectionType *parent;
246 MonoReflectionType *ret;
247 MonoArray *parameters;
251 } MonoReflectionArrayMethod;
261 MonoAssembly assembly;
265 guint32 strong_name_size;
266 } MonoDynamicAssembly;
272 guint32 metadata_rva;
274 guint32 cli_header_offset;
278 guint32 imp_names_offset;
284 } sections [MONO_SECTION_MAX];
285 GHashTable *typespec;
287 GHashTable *handleref;
288 MonoGHashTable *tokens;
289 MonoGHashTable *blob_cache;
290 GList *array_methods;
291 MonoGHashTable *token_fixups;
292 MonoGHashTable *method_to_table_idx;
293 MonoGHashTable *field_to_table_idx;
294 MonoGHashTable *method_aux_hash;
298 guint32 strong_name_size;
300 guint32 win32_res_size;
301 MonoDynamicStream pefile;
302 MonoDynamicStream sheap;
303 MonoDynamicStream code; /* used to store method headers and bytecode */
304 MonoDynamicStream resources; /* managed embedded resources */
305 MonoDynamicStream us;
306 MonoDynamicStream blob;
307 MonoDynamicStream tstream;
308 MonoDynamicStream guid;
309 MonoDynamicTable tables [64];
315 MonoString *filename;
318 } MonoReflectionResource;
325 } MonoReflectionWin32Resource;
330 } MonoReflectionPermissionSet;
333 MonoReflectionAssembly assembly;
334 MonoDynamicAssembly *dynamic_assembly;
335 MonoReflectionMethod *entry_point;
340 MonoArray *resources;
341 MonoArray *public_key;
347 MonoBoolean delay_sign;
349 MonoArray *loaded_modules;
350 MonoArray *win32_resources;
351 } MonoReflectionAssemblyBuilder;
356 MonoReflectionType *type;
358 MonoObject *def_value;
361 MonoReflectionType *typeb;
364 MonoReflectionMarshal *marshal_info;
365 MonoClassField *handle;
368 } MonoReflectionFieldBuilder;
374 MonoReflectionType *type;
375 MonoArray *parameters;
377 MonoObject *def_value;
378 MonoReflectionMethodBuilder *set_method;
379 MonoReflectionMethodBuilder *get_method;
381 } MonoReflectionPropertyBuilder;
386 MonoReflectionAssembly *assembly;
389 MonoString *scopename;
390 MonoBoolean is_resource;
391 } MonoReflectionModule;
394 MonoReflectionModule module;
395 MonoDynamicImage *dynamic_image;
401 MonoReflectionAssemblyBuilder *assemblyb;
402 MonoArray *global_methods;
403 MonoArray *global_fields;
405 MonoArray *resources;
406 } MonoReflectionModuleBuilder;
409 MonoReflectionType type;
412 MonoReflectionType *parent;
413 MonoReflectionType *nesting_type;
414 MonoArray *interfaces;
418 MonoArray *properties;
426 MonoReflectionModuleBuilder *module;
429 MonoArray *generic_params;
430 MonoArray *permissions;
431 } MonoReflectionTypeBuilder;
434 MonoReflectionType type;
435 MonoReflectionTypeBuilder *tbuilder;
436 MonoReflectionMethodBuilder *mbuilder;
439 MonoReflectionType *base_type;
440 MonoArray *iface_constraints;
441 MonoBoolean has_ctor_constraint;
442 MonoBoolean has_reference_type;
443 MonoBoolean has_value_type;
444 } MonoReflectionGenericParam;
446 typedef struct _MonoReflectionGenericInst MonoReflectionGenericInst;
447 struct _MonoReflectionGenericInst {
448 MonoReflectionType type;
449 MonoReflectionType *generic_type;
456 MonoString *codebase;
457 gint32 major, minor, build, revision;
458 /* FIXME: add missing stuff */
459 /* CultureInfo cultureinfo;
460 AssemblyNameFlags flags;
461 AssemblyHashAlgorithm hashalg;
462 StrongNameKeyPair keypair;
463 AssemblyVersionCompatibility versioncompat;*/
464 MonoObject *cultureInfo;
468 MonoArray *publicKey;
470 MonoObject *versioncompat;
471 } MonoReflectionAssemblyName;
476 MonoReflectionType *type;
477 MonoReflectionTypeBuilder *typeb;
479 MonoReflectionMethodBuilder *add_method;
480 MonoReflectionMethodBuilder *remove_method;
481 MonoReflectionMethodBuilder *raise_method;
482 MonoArray *other_methods;
485 } MonoReflectionEventBuilder;
489 MonoReflectionMethod *ctor;
491 } MonoReflectionCustomAttr;
497 MonoReflectionType *rtype;
498 MonoArray *parameters;
501 MonoReflectionModule *module;
502 MonoBoolean skip_visibility;
503 MonoBoolean init_locals;
504 MonoReflectionILGen *ilgen;
507 } MonoReflectionDynamicMethod;
509 typedef struct MonoTypeNameParse MonoTypeNameParse;
511 struct MonoTypeNameParse {
514 MonoAssemblyName assembly;
515 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
521 MonoReflectionModuleBuilder *module;
522 MonoArray *arguments;
524 MonoReflectionType *return_type;
526 guint32 unmanaged_call_conv;
527 } MonoReflectionSigHelper;
533 } MonoCustomAttrEntry;
538 MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
539 } MonoCustomAttrInfo;
542 * Information which isn't in the MonoMethod structure is stored here for
547 MonoMarshalSpec **param_marshall;
548 MonoCustomAttrInfo **param_cattr;
549 } MonoReflectionMethodAux;
552 RESOURCE_LOCATION_EMBEDDED = 1,
553 RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
554 RESOURCE_LOCATION_IN_MANIFEST = 4
559 MonoReflectionAssembly *assembly;
560 MonoString *filename;
562 } MonoManifestResourceInfo;
564 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
565 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
566 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
568 void mono_image_create_pefile (MonoReflectionModuleBuilder *module);
569 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
570 MonoReflectionModule * mono_image_load_module (MonoReflectionAssemblyBuilder *assembly, MonoString *file_name);
571 guint32 mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str);
572 guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj);
573 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
575 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
576 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
577 MonoReflectionModule* mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
578 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
579 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
580 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
581 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
582 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
583 /* note: this one is slightly different: we keep the whole array of params in the cache */
584 MonoArray* mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
586 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
587 MonoArray* mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
589 MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
590 MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
591 MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method);
592 MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass);
593 MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
594 MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
595 MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event);
596 MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field);
597 MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, guint32 param);
598 void mono_custom_attrs_free (MonoCustomAttrInfo *ainfo);
600 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
602 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
604 void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb);
606 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
608 void mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *m);
610 void mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam);
613 mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_argc, MonoType **types);
614 MonoReflectionMethod*
615 mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *method, MonoArray *types);
617 mono_reflection_generic_inst_initialize (MonoReflectionGenericInst *type, MonoArray *methods, MonoArray *ctors, MonoArray *fields, MonoArray *properties, MonoArray *events);
618 MonoReflectionEvent *
619 mono_reflection_event_builder_get_event_info (MonoReflectionTypeBuilder *tb, MonoReflectionEventBuilder *eb);
622 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
624 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
627 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
630 mono_image_build_metadata (MonoReflectionModuleBuilder *module);
632 #endif /* __METADATA_REFLECTION_H__ */