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;
106 MonoReflectionType *parent;
108 MonoReflectionMethod *get;
109 MonoReflectionMethod *set;
114 MonoReflectionType *parent;
116 MonoReflectionMethod *add_method;
117 MonoReflectionMethod *remove_method;
118 MonoReflectionMethod *raise_method;
124 MonoString *name_space;
125 MonoReflectionType *etype;
126 MonoReflectionType *nested_in;
127 MonoReflectionAssembly *assembly;
129 MonoBoolean isprimitive;
135 } MonoReflectionILTokenInfo;
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 MonoArray *param_modreq;
206 MonoArray *param_modopt;
207 } MonoReflectionCtorBuilder;
212 MonoReflectionType *rtype;
213 MonoArray *parameters;
219 MonoReflectionILGen *ilgen;
223 MonoReflectionMethod *override_method;
225 MonoString *dllentry;
229 MonoBoolean init_locals;
230 MonoArray *generic_params;
231 MonoArray *return_modreq;
232 MonoArray *return_modopt;
233 MonoArray *param_modreq;
234 MonoArray *param_modopt;
235 } MonoReflectionMethodBuilder;
240 MonoReflectionType *parent;
241 MonoReflectionType *ret;
242 MonoArray *parameters;
246 } MonoReflectionArrayMethod;
249 * Information which isn't in the MonoMethod structure is stored here for
254 MonoMarshalSpec **param_marshall;
255 } MonoReflectionMethodAux;
265 MonoAssembly assembly;
269 guint32 strong_name_size;
270 } MonoDynamicAssembly;
276 guint32 metadata_rva;
278 guint32 cli_header_offset;
282 guint32 imp_names_offset;
288 } sections [MONO_SECTION_MAX];
290 GHashTable *handleref;
291 MonoGHashTable *tokens;
292 MonoGHashTable *blob_cache;
293 GList *array_methods;
294 MonoGHashTable *token_fixups;
295 MonoGHashTable *method_to_table_idx;
296 MonoGHashTable *field_to_table_idx;
297 MonoGHashTable *method_aux_hash;
301 guint32 strong_name_size;
302 MonoDynamicStream pefile;
303 MonoDynamicStream sheap;
304 MonoDynamicStream code; /* used to store method headers and bytecode */
305 MonoDynamicStream resources; /* managed embedded resources */
306 MonoDynamicStream us;
307 MonoDynamicStream blob;
308 MonoDynamicStream tstream;
309 MonoDynamicStream guid;
310 MonoDynamicTable tables [64];
316 MonoString *filename;
318 } MonoReflectionResource;
321 MonoReflectionAssembly assembly;
322 MonoDynamicAssembly *dynamic_assembly;
323 MonoReflectionMethodBuilder *entry_point;
328 MonoArray *resources;
329 MonoArray *public_key;
335 MonoBoolean delay_sign;
337 gpointer main_module;
338 } MonoReflectionAssemblyBuilder;
343 MonoReflectionType *type;
345 MonoObject *def_value;
348 MonoReflectionType *typeb;
351 MonoReflectionMarshal *marshal_info;
352 MonoClassField *handle;
355 } MonoReflectionFieldBuilder;
361 MonoReflectionType *type;
362 MonoArray *parameters;
364 MonoObject *def_value;
365 MonoReflectionMethodBuilder *set_method;
366 MonoReflectionMethodBuilder *get_method;
368 } MonoReflectionPropertyBuilder;
373 MonoReflectionAssembly *assembly;
376 MonoString *scopename;
377 MonoBoolean is_resource;
378 } MonoReflectionModule;
381 MonoReflectionModule module;
382 MonoDynamicImage *dynamic_image;
387 MonoReflectionAssemblyBuilder *assemblyb;
388 MonoArray *global_methods;
389 MonoArray *global_fields;
391 } MonoReflectionModuleBuilder;
394 MonoReflectionType type;
397 MonoReflectionType *parent;
398 MonoReflectionType *nesting_type;
399 MonoArray *interfaces;
402 MonoArray *properties;
409 MonoReflectionModuleBuilder *module;
412 MonoArray *generic_params;
413 } MonoReflectionTypeBuilder;
417 MonoGenericParam *param;
418 MonoReflectionType *type;
421 MonoArray *constraints;
422 } MonoReflectionGenericParam;
424 typedef struct _MonoReflectionGenericInst MonoReflectionGenericInst;
425 struct _MonoReflectionGenericInst {
426 MonoReflectionType type;
428 MonoReflectionGenericInst *parent;
429 MonoReflectionType *generic_type;
430 MonoArray *interfaces;
437 MonoReflectionMethod rmethod;
438 MonoReflectionMethod *declaring;
439 MonoReflectionGenericInst *declaring_type;
440 MonoReflectionGenericInst *reflected_type;
441 MonoGenericInst *ginst;
442 } MonoReflectionInflatedMethod;
445 MonoReflectionField rfield;
446 MonoClassField *declaring;
447 MonoReflectionGenericInst *declaring_type;
448 MonoReflectionGenericInst *reflected_type;
449 } MonoReflectionInflatedField;
454 MonoString *codebase;
455 gint32 major, minor, build, revision;
456 /* FIXME: add missing stuff */
457 /* CultureInfo cultureinfo;
458 AssemblyNameFlags flags;
459 AssemblyHashAlgorithm hashalg;
460 StrongNameKeyPair keypair;
461 AssemblyVersionCompatibility versioncompat;*/
462 MonoObject *cultureInfo;
466 MonoArray *publicKey;
468 MonoObject *versioncompat;
469 } MonoReflectionAssemblyName;
474 MonoReflectionType *type;
475 MonoReflectionTypeBuilder *typeb;
477 MonoReflectionMethodBuilder *add_method;
478 MonoReflectionMethodBuilder *remove_method;
479 MonoReflectionMethodBuilder *raise_method;
480 MonoArray *other_methods;
483 } MonoReflectionEventBuilder;
487 MonoReflectionMethod *ctor;
489 } MonoReflectionCustomAttr;
495 MonoReflectionType *rtype;
496 MonoArray *parameters;
499 MonoReflectionModule *module;
500 MonoBoolean skip_visibility;
501 MonoBoolean init_locals;
502 MonoReflectionILGen *ilgen;
505 } MonoReflectionDynamicMethod;
507 typedef struct MonoTypeNameParse MonoTypeNameParse;
509 struct MonoTypeNameParse {
512 MonoAssemblyName assembly;
513 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
519 MonoReflectionModuleBuilder *module;
520 MonoArray *arguments;
522 MonoReflectionType *return_type;
524 guint32 unmanaged_call_conv;
525 } MonoReflectionSigHelper;
531 } MonoCustomAttrEntry;
536 MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
537 } MonoCustomAttrInfo;
540 RESOURCE_LOCATION_EMBEDDED = 1,
541 RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
542 RESOURCE_LOCATION_IN_MANIFEST = 4
547 MonoReflectionAssembly *assembly;
548 MonoString *filename;
550 } MonoManifestResourceInfo;
552 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
553 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
554 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
556 void mono_image_create_pefile (MonoReflectionModuleBuilder *module);
557 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
558 guint32 mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str);
559 guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj);
560 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
562 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
563 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
564 MonoReflectionModule* mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
565 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
566 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
567 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
568 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
569 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
570 /* note: this one is slightly different: we keep the whole array of params in the cache */
571 MonoArray* mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
573 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
574 MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
576 MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
577 MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
578 MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method);
579 MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass);
580 MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
581 MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
582 MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event);
583 MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field);
584 MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, guint32 param);
585 void mono_custom_attrs_free (MonoCustomAttrInfo *ainfo);
587 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
589 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
591 void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb);
593 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
595 void mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *m);
597 MonoReflectionType *mono_reflection_define_generic_parameter (MonoReflectionTypeBuilder *tb, MonoReflectionMethodBuilder *mb, guint32 index, MonoReflectionGenericParam *gparam);
599 MonoReflectionGenericInst*
600 mono_reflection_bind_generic_parameters (MonoReflectionType *type, MonoArray *types);
601 MonoReflectionInflatedMethod*
602 mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *method, MonoArray *types);
603 MonoReflectionInflatedMethod*
604 mono_reflection_inflate_method_or_ctor (MonoReflectionGenericInst *declaring_type, MonoReflectionGenericInst *reflected_type, MonoObject *obj);
605 MonoReflectionInflatedField*
606 mono_reflection_inflate_field (MonoReflectionGenericInst *declaring_type, MonoReflectionGenericInst *reflected_type, MonoObject *obj);
608 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
610 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
613 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
616 mono_image_build_metadata (MonoReflectionModuleBuilder *module);
618 #endif /* __METADATA_REFLECTION_H__ */