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;
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;
276 guint32 strong_name_size;
277 MonoDynamicStream pefile;
278 MonoDynamicStream sheap;
279 MonoDynamicStream code; /* used to store method headers and bytecode */
280 MonoDynamicStream resources; /* managed embedded resources */
281 MonoDynamicStream us;
282 MonoDynamicStream blob;
283 MonoDynamicStream tstream;
284 MonoDynamicStream guid;
285 MonoDynamicTable tables [64];
286 } MonoDynamicAssembly;
291 MonoString *filename;
293 } MonoReflectionResource;
296 MonoReflectionAssembly assembly;
297 MonoDynamicAssembly *dynamic_assembly;
298 MonoReflectionMethodBuilder *entry_point;
303 MonoArray *resources;
310 MonoBoolean delay_sign;
312 } MonoReflectionAssemblyBuilder;
317 MonoReflectionType *type;
319 MonoObject *def_value;
322 MonoReflectionType *typeb;
325 MonoReflectionMarshal *marshal_info;
326 MonoClassField *handle;
327 } MonoReflectionFieldBuilder;
333 MonoReflectionType *type;
334 MonoArray *parameters;
336 MonoObject *def_value;
337 MonoReflectionMethodBuilder *set_method;
338 MonoReflectionMethodBuilder *get_method;
340 } MonoReflectionPropertyBuilder;
345 MonoReflectionAssembly *assembly;
348 MonoString *scopename;
349 gboolean is_resource;
350 } MonoReflectionModule;
353 MonoReflectionModule module;
358 MonoReflectionAssemblyBuilder *assemblyb;
359 MonoArray *global_methods;
360 MonoArray *global_fields;
361 } MonoReflectionModuleBuilder;
364 MonoReflectionType type;
367 MonoReflectionType *parent;
368 MonoReflectionType *nesting_type;
369 MonoArray *interfaces;
372 MonoArray *properties;
379 MonoReflectionModuleBuilder *module;
382 } MonoReflectionTypeBuilder;
387 MonoString *codebase;
388 gint32 major, minor, build, revision;
389 /* FIXME: add missing stuff */
390 /* CultureInfo cultureinfo;
391 AssemblyNameFlags flags;
392 AssemblyHashAlgorithm hashalg;
393 StrongNameKeyPair keypair;
394 AssemblyVersionCompatibility versioncompat;*/
395 MonoObject *cultureInfo;
399 MonoArray *publicKey;
401 MonoObject *versioncompat;
402 } MonoReflectionAssemblyName;
407 MonoReflectionType *type;
408 MonoReflectionTypeBuilder *typeb;
410 MonoReflectionMethodBuilder *add_method;
411 MonoReflectionMethodBuilder *remove_method;
412 MonoReflectionMethodBuilder *raise_method;
413 MonoArray *other_methods;
416 } MonoReflectionEventBuilder;
420 MonoReflectionMethod *ctor;
422 } MonoReflectionCustomAttr;
424 typedef struct MonoTypeNameParse MonoTypeNameParse;
426 struct MonoTypeNameParse {
429 MonoAssemblyName assembly;
430 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
436 MonoReflectionModuleBuilder *module;
437 MonoArray *arguments;
439 MonoReflectionType *return_type;
441 guint32 unmanaged_call_conv;
442 } MonoReflectionSigHelper;
448 } MonoCustomAttrEntry;
453 MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
454 } MonoCustomAttrInfo;
457 RESOURCE_LOCATION_EMBEDDED = 1,
458 RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
459 RESOURCE_LOCATION_IN_MANIFEST = 4
464 MonoReflectionAssembly *assembly;
465 MonoString *filename;
467 } MonoManifestResourceInfo;
469 char* mono_type_get_name (MonoType *type);
470 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
471 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
472 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
474 void mono_image_create_pefile (MonoReflectionAssemblyBuilder *assembly);
475 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
476 guint32 mono_image_insert_string (MonoReflectionAssemblyBuilder *assembly, MonoString *str);
477 guint32 mono_image_create_token (MonoDynamicAssembly *assembly, MonoObject *obj);
478 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
480 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
481 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
482 MonoReflectionModule* mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
483 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
484 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
485 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
486 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
487 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
488 /* note: this one is slightly different: we keep the whole array of params in the cache */
489 MonoReflectionParameter** mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
491 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
492 MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
494 MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
495 MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
496 MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method);
497 MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass);
498 MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
499 MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
500 MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event);
501 MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field);
502 MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, guint32 param);
503 void mono_custom_attrs_free (MonoCustomAttrInfo *ainfo);
505 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
507 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
509 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
511 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
513 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
516 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
519 mono_image_build_metadata (MonoReflectionAssemblyBuilder *assemblyb);
521 #endif /* __METADATA_REFLECTION_H__ */