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 */
20 guint32 row_size; /* calculated later with column_sizes */
22 guint32 column_sizes [9];
23 guint32 *values; /* rows * columns */
28 * The followinbg structure must match the C# implementation in our corlib.
31 struct _MonoReflectionMethod {
35 MonoReflectionType *reftype;
38 struct _MonoDelegate {
40 MonoObject *target_type;
42 MonoString *method_name;
44 gpointer delegate_trampoline;
45 MonoReflectionMethod *method_info;
48 typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
49 struct _MonoMulticastDelegate {
50 MonoDelegate delegate;
51 MonoMulticastDelegate *prev;
57 MonoClassField *field;
58 } MonoReflectionField;
63 MonoProperty *property;
64 } MonoReflectionProperty;
70 } MonoReflectionEvent;
74 MonoReflectionType *ClassImpl;
75 MonoObject *DefaultValueImpl;
76 MonoObject *MemberImpl;
80 } MonoReflectionParameter;
84 MonoAssembly *assembly;
85 } MonoReflectionAssembly;
88 MonoReflectionType *utype;
94 MonoReflectionType *parent;
95 MonoReflectionType *ret;
101 MonoReflectionType *parent;
103 MonoReflectionMethod *get;
104 MonoReflectionMethod *set;
109 MonoReflectionType *parent;
111 MonoReflectionMethod *add_method;
112 MonoReflectionMethod *remove_method;
113 MonoReflectionMethod *raise_method;
118 MonoReflectionType *parent;
119 MonoReflectionType *type;
126 MonoString *name_space;
127 MonoReflectionType *etype;
128 MonoReflectionType *nested_in;
129 MonoReflectionAssembly *assembly;
131 MonoBoolean isprimitive;
137 } MonoReflectionILTokenInfo;
142 MonoObject *mbuilder;
147 MonoArray *ex_handlers;
148 gint32 num_token_fixups;
149 MonoArray *token_fixups;
150 } MonoReflectionILGen;
157 } MonoILExceptionInfo;
160 MonoReflectionType *extype;
164 gint32 filter_offset;
165 } MonoILExceptionBlock;
169 MonoReflectionType *type;
171 } MonoReflectionLocalBuilder;
178 } MonoReflectionMarshal;
185 MonoReflectionMarshal *marshal_info;
189 } MonoReflectionParamBuilder;
194 MonoReflectionILGen *ilgen;
195 MonoArray *parameters;
203 MonoBoolean init_locals;
204 } MonoReflectionCtorBuilder;
209 MonoReflectionType *rtype;
210 MonoArray *parameters;
216 MonoReflectionILGen *ilgen;
220 MonoReflectionMethod *override_method;
222 MonoString *dllentry;
226 MonoBoolean init_locals;
227 } MonoReflectionMethodBuilder;
232 MonoReflectionType *parent;
233 MonoReflectionType *ret;
234 MonoArray *parameters;
238 } MonoReflectionArrayMethod;
248 MonoAssembly assembly;
251 guint32 metadata_rva;
253 guint32 cli_header_offset;
257 guint32 imp_names_offset;
263 } sections [MONO_SECTION_MAX];
265 GHashTable *handleref;
266 MonoGHashTable *tokens;
267 GHashTable *blob_cache;
268 GList *array_methods;
269 MonoGHashTable *token_fixups;
270 MonoGHashTable *method_to_table_idx;
271 MonoGHashTable *field_to_table_idx;
273 guint32 strong_name_size;
274 MonoDynamicStream pefile;
275 MonoDynamicStream sheap;
276 MonoDynamicStream code; /* used to store method headers and bytecode */
277 MonoDynamicStream resources; /* managed embedded resources */
278 MonoDynamicStream us;
279 MonoDynamicStream blob;
280 MonoDynamicStream tstream;
281 MonoDynamicStream guid;
282 MonoDynamicTable tables [64];
283 } MonoDynamicAssembly;
288 MonoString *filename;
290 } MonoReflectionResource;
293 MonoReflectionAssembly assembly;
294 MonoDynamicAssembly *dynamic_assembly;
295 MonoReflectionMethodBuilder *entry_point;
300 MonoArray *resources;
307 MonoBoolean delay_sign;
308 } MonoReflectionAssemblyBuilder;
313 MonoReflectionType *type;
315 MonoObject *def_value;
318 MonoReflectionType *typeb;
321 MonoReflectionMarshal *marshal_info;
322 MonoClassField *handle;
323 } MonoReflectionFieldBuilder;
329 MonoReflectionType *type;
330 MonoArray *parameters;
332 MonoObject *def_value;
333 MonoReflectionMethodBuilder *set_method;
334 MonoReflectionMethodBuilder *get_method;
336 } MonoReflectionPropertyBuilder;
341 MonoReflectionAssembly *assembly;
344 MonoString *scopename;
345 } MonoReflectionModule;
348 MonoReflectionModule module;
353 MonoReflectionAssemblyBuilder *assemblyb;
354 MonoArray *global_methods;
355 MonoArray *global_fields;
356 } MonoReflectionModuleBuilder;
359 MonoReflectionType type;
362 MonoReflectionType *parent;
363 MonoReflectionType *nesting_type;
364 MonoArray *interfaces;
367 MonoArray *properties;
374 MonoReflectionModuleBuilder *module;
377 } MonoReflectionTypeBuilder;
382 MonoString *codebase;
383 gint32 major, minor, build, revision;
384 /* FIXME: add missing stuff */
385 /* CultureInfo cultureinfo;
386 AssemblyNameFlags flags;
387 AssemblyHashAlgorithm hashalg;
388 StrongNameKeyPair keypair;
389 AssemblyVersionCompatibility versioncompat;*/
390 MonoObject *cultureInfo;
394 MonoArray *publicKey;
396 MonoObject *versioncompat;
397 } MonoReflectionAssemblyName;
402 MonoReflectionType *type;
403 MonoReflectionTypeBuilder *typeb;
405 MonoReflectionMethodBuilder *add_method;
406 MonoReflectionMethodBuilder *remove_method;
407 MonoReflectionMethodBuilder *raise_method;
408 MonoArray *other_methods;
411 } MonoReflectionEventBuilder;
415 MonoReflectionMethod *ctor;
417 } MonoReflectionCustomAttr;
419 typedef struct MonoTypeNameParse MonoTypeNameParse;
421 struct MonoTypeNameParse {
424 MonoAssemblyName assembly;
425 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
431 MonoReflectionModuleBuilder *module;
432 MonoArray *arguments;
434 MonoReflectionType *return_type;
436 guint32 unmanaged_call_conv;
437 } MonoReflectionSigHelper;
441 char* mono_type_get_name (MonoType *type);
442 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
443 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
444 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
446 void mono_image_create_pefile (MonoReflectionAssemblyBuilder *assembly);
447 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
448 guint32 mono_image_insert_string (MonoReflectionAssemblyBuilder *assembly, MonoString *str);
449 guint32 mono_image_create_token (MonoDynamicAssembly *assembly, MonoObject *obj);
450 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
452 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
453 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
454 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
455 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
456 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
457 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
458 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
459 /* note: this one is slightly different: we keep the whole array of params in the cache */
460 MonoReflectionParameter** mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
462 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
463 MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
465 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
467 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
469 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
471 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
473 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
476 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
479 mono_image_build_metadata (MonoReflectionAssemblyBuilder *assemblyb);
481 #endif /* __METADATA_REFLECTION_H__ */