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 GHashTable *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 } MonoReflectionModule;
352 MonoReflectionModule module;
357 MonoReflectionAssemblyBuilder *assemblyb;
358 MonoArray *global_methods;
359 MonoArray *global_fields;
360 } MonoReflectionModuleBuilder;
363 MonoReflectionType type;
366 MonoReflectionType *parent;
367 MonoReflectionType *nesting_type;
368 MonoArray *interfaces;
371 MonoArray *properties;
378 MonoReflectionModuleBuilder *module;
381 } MonoReflectionTypeBuilder;
386 MonoString *codebase;
387 gint32 major, minor, build, revision;
388 /* FIXME: add missing stuff */
389 /* CultureInfo cultureinfo;
390 AssemblyNameFlags flags;
391 AssemblyHashAlgorithm hashalg;
392 StrongNameKeyPair keypair;
393 AssemblyVersionCompatibility versioncompat;*/
394 MonoObject *cultureInfo;
398 MonoArray *publicKey;
400 MonoObject *versioncompat;
401 } MonoReflectionAssemblyName;
406 MonoReflectionType *type;
407 MonoReflectionTypeBuilder *typeb;
409 MonoReflectionMethodBuilder *add_method;
410 MonoReflectionMethodBuilder *remove_method;
411 MonoReflectionMethodBuilder *raise_method;
412 MonoArray *other_methods;
415 } MonoReflectionEventBuilder;
419 MonoReflectionMethod *ctor;
421 } MonoReflectionCustomAttr;
423 typedef struct MonoTypeNameParse MonoTypeNameParse;
425 struct MonoTypeNameParse {
428 MonoAssemblyName assembly;
429 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
435 MonoReflectionModuleBuilder *module;
436 MonoArray *arguments;
438 MonoReflectionType *return_type;
440 guint32 unmanaged_call_conv;
441 } MonoReflectionSigHelper;
447 } MonoCustomAttrEntry;
452 MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
453 } MonoCustomAttrInfo;
456 char* mono_type_get_name (MonoType *type);
457 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
458 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
459 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
461 void mono_image_create_pefile (MonoReflectionAssemblyBuilder *assembly);
462 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
463 guint32 mono_image_insert_string (MonoReflectionAssemblyBuilder *assembly, MonoString *str);
464 guint32 mono_image_create_token (MonoDynamicAssembly *assembly, MonoObject *obj);
465 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
467 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
468 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
469 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
470 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
471 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
472 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
473 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
474 /* note: this one is slightly different: we keep the whole array of params in the cache */
475 MonoReflectionParameter** mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
477 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
478 MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
480 MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
481 MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
482 MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method);
483 MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass);
484 MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
485 MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
486 MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event);
487 MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field);
488 MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, guint32 param);
490 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
492 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
494 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
496 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
498 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
501 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
504 mono_image_build_metadata (MonoReflectionAssemblyBuilder *assemblyb);
506 #endif /* __METADATA_REFLECTION_H__ */