1 #ifndef __MONO_OBJECT_INTERNALS_H__
2 #define __MONO_OBJECT_INTERNALS_H__
4 #include <mono/metadata/object.h>
5 #include <mono/metadata/threads.h>
6 #include <mono/metadata/reflection.h>
7 #include <mono/metadata/mempool.h>
8 #include <mono/metadata/class-internals.h>
9 #include <mono/io-layer/io-layer.h>
10 #include "mono/utils/mono-compiler.h"
13 * We should find a better place for this stuff. We can't put it in mono-compiler.h,
14 * since that is included by libgc.
17 #define G_LIKELY(a) (a)
18 #define G_UNLIKELY(a) (a)
22 * glib defines this macro and uses it in the definition of G_LIKELY, and thus,
23 * g_assert (). The macro expands to a complex piece of code, preventing some
24 * gcc versions like 4.3.0 from handling the __builtin_expect construct properly,
25 * causing the generation of the unlikely branch into the middle of the code.
27 #ifdef _G_BOOLEAN_EXPR
28 #undef _G_BOOLEAN_EXPR
29 #define _G_BOOLEAN_EXPR(expr) (gsize)(expr)
34 #define mono_assert(expr) G_STMT_START{ \
38 char *msg = g_strdup_printf ("file %s: line %d (%s): " \
39 "assertion failed: (%s)", __FILE__, __LINE__, \
40 __PRETTY_FUNCTION__, #expr); \
41 ex = mono_get_exception_execution_engine (msg); \
43 mono_raise_exception (ex); \
46 #define mono_assert_not_reached() G_STMT_START{ \
48 char *msg = g_strdup_printf ("file %s: line %d (%s): " \
49 "should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__); \
50 ex = mono_get_exception_execution_engine (msg); \
52 mono_raise_exception (ex); \
55 #define mono_assert(expr) G_STMT_START{ \
59 char *msg = g_strdup_printf ("file %s: line %d: " \
60 "assertion failed: (%s)", __FILE__, __LINE__, \
62 ex = mono_get_exception_execution_engine (msg); \
64 mono_raise_exception (ex); \
67 #define mono_assert_not_reached() G_STMT_START{ \
69 char *msg = g_strdup_printf ("file %s: line %d): " \
70 "should not be reached", __FILE__, __LINE__); \
71 ex = mono_get_exception_execution_engine (msg); \
73 mono_raise_exception (ex); \
77 #define mono_assert(expr) g_assert(expr)
78 #define mono_assert_not_reached() g_assert_not_reached()
81 #define MONO_CHECK_ARG(arg, expr) G_STMT_START{ \
85 char *msg = g_strdup_printf ("assertion `%s' failed", \
87 if (arg) {} /* check if the name exists */ \
88 ex = mono_get_exception_argument (#arg, msg); \
90 mono_raise_exception (ex); \
93 #define MONO_CHECK_ARG_NULL(arg) G_STMT_START{ \
97 if (arg) {} /* check if the name exists */ \
98 ex = mono_get_exception_argument_null (#arg); \
99 mono_raise_exception (ex); \
102 /* 16 == default capacity */
103 #define mono_stringbuilder_capacity(sb) ((sb)->str ? ((sb)->str->length) : 16)
106 * Macros which cache the results of lookups locally.
107 * These should be used instead of the original versions, if the __GNUC__
108 * restriction is acceptable.
113 /* namespace and name should be a constant */
114 #define mono_class_from_name_cached(image,namespace,name) ({ \
115 static MonoClass *tmp_klass; \
117 tmp_klass = mono_class_from_name ((image), (namespace), (name)); \
118 g_assert (tmp_klass); \
121 /* name should be a compile-time constant */
122 #define mono_class_get_field_from_name_cached(klass,name) ({ \
123 static MonoClassField *tmp_field; \
125 tmp_field = mono_class_get_field_from_name ((klass), (name)); \
126 g_assert (tmp_field); \
129 /* eclass should be a run-time constant */
130 #define mono_array_class_get_cached(eclass,rank) ({ \
131 static MonoClass *tmp_klass; \
133 tmp_klass = mono_array_class_get ((eclass), (rank)); \
134 g_assert (tmp_klass); \
137 /* eclass should be a run-time constant */
138 #define mono_array_new_cached(domain, eclass, size) mono_array_new_specific (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size))
142 #define mono_class_from_name_cached(image,namespace,name) mono_class_from_name ((image), (namespace), (name))
143 #define mono_class_get_field_from_name_cached(klass,name) mono_class_get_field_from_name ((klass), (name))
144 #define mono_array_class_get_cached(eclass,rank) mono_array_class_get ((eclass), (rank))
145 #define mono_array_new_cached(domain, eclass, size) mono_array_new_specific (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size))
151 MonoObject *identity;
152 } MonoMarshalByRefObject;
154 /* This is a copy of System.AppDomain */
155 struct _MonoAppDomain {
156 MonoMarshalByRefObject mbr;
164 MonoString *cached_str;
176 } MonoArgumentHandle;
179 MonoMethodSignature *sig;
185 struct _MonoException {
187 /* Stores the IPs and the generic sharing infos
188 (vtable/MRGCTX) of the frames. */
189 MonoArray *trace_ips;
190 MonoObject *inner_ex;
192 MonoString *help_link;
193 MonoString *class_name;
194 MonoString *stack_trace;
195 MonoString *remote_stack_trace;
196 gint32 remote_stack_index;
204 } MonoSystemException;
207 MonoSystemException base;
208 MonoString *param_name;
209 } MonoArgumentException;
212 MonoSystemException base;
214 MonoString *type_name;
215 } MonoTypeLoadException;
219 MonoObject *async_state;
221 MonoObject *async_delegate;
223 MonoObject *object_data;
224 MonoBoolean sync_completed;
225 MonoBoolean completed;
226 MonoBoolean endinvoke_called;
227 MonoObject *async_callback;
228 MonoObject *execution_context;
229 MonoObject *original_context;
233 MonoMarshalByRefObject object;
235 MonoBoolean disposed;
238 /* This is a copy of System.Runtime.Remoting.Messaging.CallType */
241 CallType_BeginInvoke = 1,
242 CallType_EndInvoke = 2,
246 /* This corresponds to System.Type */
247 struct _MonoReflectionType {
253 MonoReflectionType type;
254 MonoObject *type_info;
255 } MonoReflectionMonoType;
259 MonoReflectionType *class_to_proxy;
261 MonoObject *unwrapped_server;
262 gint32 target_domain_id;
263 MonoString *target_uri;
264 MonoObject *object_identity;
266 MonoObject *stub_data;
270 MonoMarshalByRefObject object;
272 GHashTable* itf_hash;
276 MonoRealProxy real_proxy;
277 MonoComObject *com_object;
279 } MonoComInteropProxy;
284 MonoRemoteClass *remote_class;
285 MonoBoolean custom_type_info;
286 } MonoTransparentProxy;
290 MonoReflectionMethod *method;
293 MonoArray *arg_types;
297 MonoAsyncResult *async_result;
304 gint32 native_offset;
305 MonoReflectionMethod *method;
306 MonoString *filename;
309 MonoString *internal_method_name;
314 int lock_thread_id; /* to be used as the pre-shifted thread id in thin locks */
316 MonoArray *cached_culture_info;
318 MonoBoolean threadpool_thread;
322 MonoException *abort_exc;
323 int abort_state_handle;
324 guint64 tid; /* This is accessed as a gsize in the code (so it can hold a 64bit pointer on systems that need it), but needs to reserve 64 bits of space on all machines as it corresponds to a field in managed code */
327 gpointer *static_data;
330 MonoAppContext *current_appcontext;
332 MonoObject *start_obj;
333 GSList *appdomain_refs;
334 /* This is modified using atomic ops, so keep it a gint32 */
335 gint32 interruption_requested;
336 gpointer suspend_event;
337 gpointer suspended_event;
338 gpointer resume_event;
339 CRITICAL_SECTION *synch_cs;
340 guint8* serialized_culture_info;
341 guint32 serialized_culture_info_len;
342 guint8* serialized_ui_culture_info;
343 guint32 serialized_ui_culture_info_len;
344 MonoBoolean thread_dump_requested;
345 gpointer end_stack; /* This is only used when running in the debugger. */
346 MonoBoolean thread_interrupt_requested;
347 guint8 apartment_state;
348 gint32 critical_region_level;
349 guint32 small_id; /* A small, unique id, used for the hazard pointer table. */
350 MonoThreadManageCallback manage_callback;
351 MonoException *pending_exception;
352 MonoObject *ec_to_set;
354 * These fields are used to avoid having to increment corlib versions
355 * when a new field is added to the unmanaged MonoThread structure.
357 gpointer interrupt_on_stop;
366 MonoReflectionType *type;
368 } MonoSerializationEntry;
372 MonoObject *additional;
373 } MonoStreamingContext;
377 MonoBoolean readOnly;
378 MonoString *AMDesignator;
379 MonoString *PMDesignator;
380 MonoString *DateSeparator;
381 MonoString *TimeSeparator;
382 MonoString *ShortDatePattern;
383 MonoString *LongDatePattern;
384 MonoString *ShortTimePattern;
385 MonoString *LongTimePattern;
386 MonoString *MonthDayPattern;
387 MonoString *YearMonthPattern;
388 MonoString *FullDateTimePattern;
389 MonoString *RFC1123Pattern;
390 MonoString *SortableDateTimePattern;
391 MonoString *UniversalSortableDateTimePattern;
392 guint32 FirstDayOfWeek;
393 MonoObject *Calendar;
394 guint32 CalendarWeekRule;
395 MonoArray *AbbreviatedDayNames;
397 MonoArray *MonthNames;
398 MonoArray *AbbreviatedMonthNames;
399 MonoArray *ShortDatePatterns;
400 MonoArray *LongDatePatterns;
401 MonoArray *ShortTimePatterns;
402 MonoArray *LongTimePatterns;
403 MonoArray *MonthDayPatterns;
404 MonoArray *YearMonthPatterns;
405 MonoArray *shortDayNames;
406 } MonoDateTimeFormatInfo;
411 MonoBoolean readOnly;
412 MonoString *decimalFormats;
413 MonoString *currencyFormats;
414 MonoString *percentFormats;
415 MonoString *digitPattern;
416 MonoString *zeroPattern;
417 gint32 currencyDecimalDigits;
418 MonoString *currencyDecimalSeparator;
419 MonoString *currencyGroupSeparator;
420 MonoArray *currencyGroupSizes;
421 gint32 currencyNegativePattern;
422 gint32 currencyPositivePattern;
423 MonoString *currencySymbol;
424 MonoString *naNSymbol;
425 MonoString *negativeInfinitySymbol;
426 MonoString *negativeSign;
427 guint32 numberDecimalDigits;
428 MonoString *numberDecimalSeparator;
429 MonoString *numberGroupSeparator;
430 MonoArray *numberGroupSizes;
431 gint32 numberNegativePattern;
432 gint32 percentDecimalDigits;
433 MonoString *percentDecimalSeparator;
434 MonoString *percentGroupSeparator;
435 MonoArray *percentGroupSizes;
436 gint32 percentNegativePattern;
437 gint32 percentPositivePattern;
438 MonoString *percentSymbol;
439 MonoString *perMilleSymbol;
440 MonoString *positiveInfinitySymbol;
441 MonoString *positiveSign;
442 } MonoNumberFormatInfo;
447 MonoString *icu_name;
448 gpointer ICU_collator;
453 MonoBoolean is_read_only;
456 gint32 specific_lcid;
457 gint32 datetime_index;
459 MonoBoolean use_user_override;
460 MonoNumberFormatInfo *number_format;
461 MonoDateTimeFormatInfo *datetime_format;
462 MonoObject *textinfo;
464 MonoString *displayname;
465 MonoString *englishname;
466 MonoString *nativename;
467 MonoString *iso3lang;
468 MonoString *iso2lang;
469 MonoString *icu_name;
470 MonoString *win3lang;
471 MonoString *territory;
472 MonoCompareInfo *compareinfo;
473 const gint32 *calendar_data;
474 const void* text_info_data;
480 MonoString *iso2name;
481 MonoString *iso3name;
482 MonoString *win3name;
483 MonoString *english_name;
484 MonoString *currency_symbol;
485 MonoString *iso_currency_symbol;
486 MonoString *currency_english_name;
500 } MonoInterfaceTypeAttribute;
503 * Callbacks supplied by the runtime and called by the modules in metadata/
504 * This interface is easier to extend than adding a new function type +
505 * a new 'install' function for every callback.
508 gpointer (*create_ftnptr) (MonoDomain *domain, gpointer addr);
509 gpointer (*get_addr_from_ftnptr) (gpointer descr);
510 char* (*get_runtime_build_info) (void);
511 } MonoRuntimeCallbacks;
513 /* used to free a dynamic method */
514 typedef void (*MonoFreeMethodFunc) (MonoDomain *domain, MonoMethod *method);
516 /* Used to initialize the method pointers inside vtables */
517 typedef gboolean (*MonoInitVTableFunc) (MonoVTable *vtable);
519 void mono_set_pending_exception (MonoException *exc) MONO_INTERNAL;
521 /* remoting and async support */
524 mono_async_result_new (MonoDomain *domain, HANDLE handle,
525 MonoObject *state, gpointer data, MonoObject *object_data) MONO_INTERNAL;
528 mono_wait_handle_new (MonoDomain *domain, HANDLE handle) MONO_INTERNAL;
531 mono_wait_handle_get_handle (MonoWaitHandle *handle) MONO_INTERNAL;
534 mono_message_init (MonoDomain *domain, MonoMethodMessage *this_obj,
535 MonoReflectionMethod *method, MonoArray *out_args) MONO_INTERNAL;
538 mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg,
539 MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
542 mono_message_invoke (MonoObject *target, MonoMethodMessage *msg,
543 MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
546 mono_method_call_message_new (MonoMethod *method, gpointer *params, MonoMethod *invoke,
547 MonoDelegate **cb, MonoObject **state) MONO_INTERNAL;
550 mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args) MONO_INTERNAL;
553 mono_delegate_ctor_with_method (MonoObject *this, MonoObject *target, gpointer addr, MonoMethod *method) MONO_INTERNAL;
556 mono_delegate_ctor (MonoObject *this_obj, MonoObject *target, gpointer addr) MONO_INTERNAL;
559 mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *pass_size_in_words) MONO_INTERNAL;
562 mono_runtime_free_method (MonoDomain *domain, MonoMethod *method) MONO_INTERNAL;
564 /* runtime initialization functions */
565 typedef void (*MonoExceptionFunc) (MonoException *ex);
568 mono_install_handler (MonoExceptionFunc func) MONO_INTERNAL;
571 mono_install_runtime_invoke (MonoInvokeFunc func) MONO_INTERNAL;
574 mono_install_compile_method (MonoCompileFunc func) MONO_INTERNAL;
577 mono_install_free_method (MonoFreeMethodFunc func) MONO_INTERNAL;
580 mono_install_callbacks (MonoRuntimeCallbacks *cbs) MONO_INTERNAL;
582 MonoRuntimeCallbacks*
583 mono_get_runtime_callbacks (void) MONO_INTERNAL;
586 mono_type_initialization_init (void) MONO_INTERNAL;
589 mono_type_initialization_cleanup (void) MONO_INTERNAL;
592 mono_thread_get_tls_key (void) MONO_INTERNAL;
595 mono_thread_get_tls_offset (void) MONO_INTERNAL;
598 mono_domain_get_tls_key (void) MONO_INTERNAL;
601 mono_domain_get_tls_offset (void) MONO_INTERNAL;
603 /* Reflection and Reflection.Emit support */
606 * Handling System.Type objects:
608 * Fields defined as System.Type in managed code should be defined as MonoObject*
609 * in unmanaged structures, and the monotype_cast () function should be used for
610 * casting them to MonoReflectionType* to avoid crashes/security issues when
611 * encountering instances of user defined subclasses of System.Type.
614 #define IS_MONOTYPE(obj) (!(obj) || (((MonoObject*)(obj))->vtable->klass->image == mono_defaults.corlib && ((MonoReflectionType*)(obj))->type != NULL))
617 * Make sure the argument, which should be a System.Type is a System.MonoType object
618 * or equivalent, and not an instance of
619 * a user defined subclass of System.Type. This should be used in places were throwing
620 * an exception is safe.
622 #define CHECK_MONOTYPE(obj) do { \
623 if (!IS_MONOTYPE (obj)) \
624 mono_raise_exception (mono_get_exception_not_supported ("User defined subclasses of System.Type are not yet supported")); \
627 /* This should be used for accessing members of Type[] arrays */
628 #define mono_type_array_get(arr,index) monotype_cast (mono_array_get ((arr), gpointer, (index)))
631 * Cast an object to MonoReflectionType, making sure it is a System.MonoType or
634 static inline MonoReflectionType*
635 monotype_cast (MonoObject *obj)
637 g_assert (IS_MONOTYPE (obj));
639 return (MonoReflectionType*)obj;
643 * The following structure must match the C# implementation in our corlib.
646 struct _MonoReflectionMethod {
650 MonoReflectionType *reftype;
653 typedef struct _MonoReflectionGenericMethod MonoReflectionGenericMethod;
654 struct _MonoReflectionGenericMethod {
655 MonoReflectionMethod method;
658 struct _MonoDelegate {
660 /* The compiled code of the target method */
662 /* The invoke code */
663 gpointer invoke_impl;
666 gpointer delegate_trampoline;
668 * If non-NULL, this points to a memory location which stores the address of
669 * the compiled code of the method, or NULL if it is not yet compiled.
671 guint8 **method_code;
672 MonoReflectionMethod *method_info;
673 MonoReflectionMethod *original_method_info;
677 typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
678 struct _MonoMulticastDelegate {
679 MonoDelegate delegate;
680 MonoMulticastDelegate *prev;
683 struct _MonoReflectionField {
686 MonoClassField *field;
688 MonoReflectionType *type;
692 struct _MonoReflectionProperty {
695 MonoProperty *property;
698 /*This is System.EventInfo*/
699 struct _MonoReflectionEvent {
701 MonoObject *cached_add_event;
705 MonoReflectionEvent object;
708 } MonoReflectionMonoEvent;
712 MonoReflectionType *ClassImpl;
713 MonoObject *DefaultValueImpl;
714 MonoObject *MemberImpl;
715 MonoString *NameImpl;
718 MonoObject *MarshalAsImpl;
719 } MonoReflectionParameter;
721 struct _MonoReflectionMethodBody {
726 MonoBoolean init_locals;
727 guint32 local_var_sig_token;
731 struct _MonoReflectionAssembly {
733 MonoAssembly *assembly;
734 MonoObject *resolve_event_holder;
736 MonoObject *evidence; /* Evidence */
737 MonoObject *minimum; /* PermissionSet - for SecurityAction.RequestMinimum */
738 MonoObject *optional; /* PermissionSet - for SecurityAction.RequestOptional */
739 MonoObject *refuse; /* PermissionSet - for SecurityAction.RequestRefuse */
740 MonoObject *granted; /* PermissionSet - for the resolved assembly granted permissions */
741 MonoObject *denied; /* PermissionSet - for the resolved assembly denied permissions */
743 MonoBoolean from_byte_array;
748 MonoReflectionType *utype;
754 MonoReflectionType *parent;
755 MonoReflectionType *ret;
762 MonoReflectionType *parent;
764 MonoReflectionMethod *get;
765 MonoReflectionMethod *set;
770 MonoReflectionType *declaring_type;
771 MonoReflectionType *reflected_type;
773 MonoReflectionMethod *add_method;
774 MonoReflectionMethod *remove_method;
775 MonoReflectionMethod *raise_method;
777 MonoArray *other_methods;
782 MonoString *name_space;
783 MonoReflectionType *etype;
784 MonoReflectionType *nested_in;
785 MonoReflectionAssembly *assembly;
787 MonoBoolean isprimitive;
793 } MonoReflectionILTokenInfo;
802 MonoArray *ex_handlers;
803 gint32 num_token_fixups;
804 MonoArray *token_fixups;
805 } MonoReflectionILGen;
812 } MonoILExceptionInfo;
819 gint32 filter_offset;
820 } MonoILExceptionBlock;
824 MonoObject *catch_type;
825 gint32 filter_offset;
829 gint32 handler_offset;
830 gint32 handler_length;
831 } MonoReflectionExceptionHandlingClause;
835 MonoReflectionType *local_type;
836 MonoBoolean is_pinned;
838 } MonoReflectionLocalVariableInfo;
842 * Must have the same layout as MonoReflectionLocalVariableInfo, since
843 * LocalBuilder inherits from it under net 2.0.
847 MonoBoolean is_pinned;
850 } MonoReflectionLocalBuilder;
859 MonoString *marshaltype;
860 MonoObject *marshaltyperef;
862 MonoBoolean has_size;
863 } MonoReflectionMarshal;
870 MonoReflectionMarshal *marshal_info;
874 MonoObject *def_value;
875 } MonoReflectionParamBuilder;
880 MonoReflectionILGen *ilgen;
881 MonoArray *parameters;
889 MonoBoolean init_locals;
890 MonoArray *param_modreq;
891 MonoArray *param_modopt;
892 MonoArray *permissions;
893 } MonoReflectionCtorBuilder;
899 MonoArray *parameters;
905 MonoReflectionILGen *ilgen;
909 MonoReflectionMethod *override_method;
911 MonoString *dllentry;
916 MonoBoolean init_locals;
917 MonoGenericContainer *generic_container;
918 MonoArray *generic_params;
919 MonoArray *return_modreq;
920 MonoArray *return_modopt;
921 MonoArray *param_modreq;
922 MonoArray *param_modopt;
923 MonoArray *permissions;
924 } MonoReflectionMethodBuilder;
929 MonoReflectionType *parent;
930 MonoReflectionType *ret;
931 MonoArray *parameters;
935 } MonoReflectionArrayMethod;
940 MonoString *filename;
944 } MonoReflectionResource;
951 } MonoReflectionWin32Resource;
956 } MonoReflectionPermissionSet;
959 MonoReflectionAssembly assembly;
960 MonoDynamicAssembly *dynamic_assembly;
961 MonoReflectionMethod *entry_point;
966 MonoArray *resources;
967 MonoArray *public_key;
973 MonoBoolean delay_sign;
975 MonoArray *loaded_modules;
976 MonoArray *win32_resources;
978 MonoArray *permissions_minimum;
979 MonoArray *permissions_optional;
980 MonoArray *permissions_refused;
983 MonoBoolean corlib_internal;
984 MonoArray *type_forwarders;
985 MonoArray *pktoken; /* as hexadecimal byte[] */
986 } MonoReflectionAssemblyBuilder;
993 MonoObject *def_value;
996 MonoReflectionType *typeb;
999 MonoReflectionMarshal *marshal_info;
1000 MonoClassField *handle;
1003 } MonoReflectionFieldBuilder;
1010 MonoArray *parameters;
1012 MonoObject *def_value;
1013 MonoReflectionMethodBuilder *set_method;
1014 MonoReflectionMethodBuilder *get_method;
1016 } MonoReflectionPropertyBuilder;
1018 struct _MonoReflectionModule {
1021 MonoReflectionAssembly *assembly;
1024 MonoString *scopename;
1025 MonoBoolean is_resource;
1030 MonoReflectionModule module;
1031 MonoDynamicImage *dynamic_image;
1037 MonoReflectionAssemblyBuilder *assemblyb;
1038 MonoArray *global_methods;
1039 MonoArray *global_fields;
1041 MonoArray *resources;
1042 } MonoReflectionModuleBuilder;
1045 MonoReflectionType type;
1049 MonoReflectionType *nesting_type;
1050 MonoArray *interfaces;
1054 MonoArray *properties;
1059 MonoArray *subtypes;
1062 MonoReflectionModuleBuilder *module;
1064 gint32 packing_size;
1065 MonoGenericContainer *generic_container;
1066 MonoArray *generic_params;
1067 MonoArray *permissions;
1068 MonoReflectionType *created;
1069 } MonoReflectionTypeBuilder;
1072 MonoReflectionType type;
1073 MonoReflectionType *element_type;
1075 } MonoReflectionArrayType;
1078 MonoReflectionType type;
1079 MonoReflectionType *element_type;
1080 } MonoReflectionDerivedType;
1083 MonoReflectionType type;
1084 MonoReflectionTypeBuilder *tbuilder;
1085 MonoReflectionMethodBuilder *mbuilder;
1088 MonoReflectionType *base_type;
1089 MonoArray *iface_constraints;
1092 } MonoReflectionGenericParam;
1094 typedef struct _MonoReflectionGenericClass MonoReflectionGenericClass;
1095 struct _MonoReflectionGenericClass {
1096 MonoReflectionType type;
1097 /* From System.MonoType */
1098 MonoObject *type_info;
1099 MonoReflectionTypeBuilder *generic_type;
1100 MonoArray *type_arguments;
1101 guint32 initialized;
1107 MonoString *codebase;
1108 gint32 major, minor, build, revision;
1109 MonoObject *cultureInfo;
1112 MonoObject *keypair;
1113 MonoArray *publicKey;
1114 MonoArray *keyToken;
1115 guint32 versioncompat;
1116 MonoObject *version;
1117 guint32 processor_architecture;
1118 } MonoReflectionAssemblyName;
1123 MonoReflectionType *type;
1124 MonoReflectionTypeBuilder *typeb;
1126 MonoReflectionMethodBuilder *add_method;
1127 MonoReflectionMethodBuilder *remove_method;
1128 MonoReflectionMethodBuilder *raise_method;
1129 MonoArray *other_methods;
1132 } MonoReflectionEventBuilder;
1136 MonoReflectionMethod *ctor;
1138 } MonoReflectionCustomAttr;
1145 MonoString *entry_point;
1146 MonoBoolean exact_spelling;
1147 MonoBoolean preserve_sig;
1148 MonoBoolean set_last_error;
1149 MonoBoolean best_fit_mapping;
1150 MonoBoolean throw_on_unmappable;
1151 } MonoReflectionDllImportAttribute;
1157 MonoBoolean set_last_error;
1158 MonoBoolean best_fit_mapping;
1159 MonoBoolean throw_on_unmappable;
1160 } MonoReflectionUnmanagedFunctionPointerAttribute;
1165 } MonoReflectionGuidAttribute;
1169 MonoMethod *mhandle;
1171 MonoReflectionType *rtype;
1172 MonoArray *parameters;
1175 MonoReflectionModule *module;
1176 MonoBoolean skip_visibility;
1177 MonoBoolean init_locals;
1178 MonoReflectionILGen *ilgen;
1181 GSList *referenced_by;
1182 MonoReflectionType *owner;
1183 } MonoReflectionDynamicMethod;
1187 MonoReflectionModuleBuilder *module;
1188 MonoArray *arguments;
1190 MonoReflectionType *return_type;
1192 guint32 unmanaged_call_conv;
1195 } MonoReflectionSigHelper;
1199 MonoReflectionGenericClass *inst;
1200 MonoReflectionFieldBuilder *fb;
1201 } MonoReflectionFieldOnTypeBuilderInst;
1205 MonoReflectionGenericClass *inst;
1206 MonoReflectionCtorBuilder *cb;
1207 } MonoReflectionCtorOnTypeBuilderInst;
1211 MonoReflectionGenericClass *inst;
1212 MonoReflectionMethodBuilder *mb;
1213 MonoArray *method_args;
1214 MonoReflectionMethodBuilder *generic_method_definition;
1215 } MonoReflectionMethodOnTypeBuilderInst;
1219 MonoBoolean visible;
1220 } MonoReflectionComVisibleAttribute;
1223 RESOURCE_LOCATION_EMBEDDED = 1,
1224 RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
1225 RESOURCE_LOCATION_IN_MANIFEST = 4
1230 MonoReflectionAssembly *assembly;
1231 MonoString *filename;
1233 } MonoManifestResourceInfo;
1235 /* A boxed IntPtr */
1241 /* Keep in sync with System.GenericParameterAttributes */
1243 GENERIC_PARAMETER_ATTRIBUTE_NON_VARIANT = 0,
1244 GENERIC_PARAMETER_ATTRIBUTE_COVARIANT = 1,
1245 GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT = 2,
1246 GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK = 3,
1248 GENERIC_PARAMETER_ATTRIBUTE_NO_SPECIAL_CONSTRAINT = 0,
1249 GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT = 4,
1250 GENERIC_PARAMETER_ATTRIBUTE_VALUE_TYPE_CONSTRAINT = 8,
1251 GENERIC_PARAMETER_ATTRIBUTE_CONSTRUCTOR_CONSTRAINT = 16,
1252 GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINTS_MASK = 28
1253 } GenericParameterAttributes;
1255 void mono_image_create_pefile (MonoReflectionModuleBuilder *module, HANDLE file) MONO_INTERNAL;
1256 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly) MONO_INTERNAL;
1257 MonoReflectionModule * mono_image_load_module_dynamic (MonoReflectionAssemblyBuilder *assembly, MonoString *file_name) MONO_INTERNAL;
1258 guint32 mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str) MONO_INTERNAL;
1259 guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj, gboolean create_methodspec, gboolean register_token) MONO_INTERNAL;
1260 guint32 mono_image_create_method_token (MonoDynamicImage *assembly, MonoObject *obj, MonoArray *opt_param_types) MONO_INTERNAL;
1261 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module) MONO_INTERNAL;
1262 void mono_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj) MONO_INTERNAL;
1263 void mono_dynamic_image_free (MonoDynamicImage *image) MONO_INTERNAL;
1264 void mono_image_set_wrappers_type (MonoReflectionModuleBuilder *mb, MonoReflectionType *type) MONO_INTERNAL;
1266 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1268 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1270 void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1272 void mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1274 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1276 void mono_reflection_get_dynamic_overrides (MonoClass *klass, MonoMethod ***overrides, int *num_overrides) MONO_INTERNAL;
1278 void mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *m) MONO_INTERNAL;
1279 void mono_reflection_destroy_dynamic_method (MonoReflectionDynamicMethod *mb) MONO_INTERNAL;
1281 void mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam) MONO_INTERNAL;
1282 void mono_reflection_create_unmanaged_type (MonoReflectionType *type) MONO_INTERNAL;
1284 MonoArray* mono_param_get_objects_internal (MonoDomain *domain, MonoMethod *method, MonoClass *refclass) MONO_INTERNAL;
1287 mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic) MONO_INTERNAL;
1289 mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_argc, MonoType **types) MONO_INTERNAL;
1290 MonoReflectionMethod*
1291 mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *method, MonoArray *types) MONO_INTERNAL;
1293 mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, MonoArray *methods, MonoArray *ctors, MonoArray *fields, MonoArray *properties, MonoArray *events) MONO_INTERNAL;
1294 MonoReflectionEvent *
1295 mono_reflection_event_builder_get_event_info (MonoReflectionTypeBuilder *tb, MonoReflectionEventBuilder *eb) MONO_INTERNAL;
1297 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig) MONO_INTERNAL;
1299 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig) MONO_INTERNAL;
1301 MonoReflectionMarshal* mono_reflection_marshal_from_marshal_spec (MonoDomain *domain, MonoClass *klass, MonoMarshalSpec *spec) MONO_INTERNAL;
1304 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context) MONO_INTERNAL;
1307 mono_reflection_call_is_assignable_to (MonoClass *klass, MonoClass *oklass) MONO_INTERNAL;
1310 mono_reflection_is_valid_dynamic_token (MonoDynamicImage *image, guint32 token) MONO_INTERNAL;
1313 mono_reflection_type_get_handle (MonoReflectionType *ref) MONO_INTERNAL;
1316 mono_image_build_metadata (MonoReflectionModuleBuilder *module) MONO_INTERNAL;
1319 mono_get_constant_value_from_blob (MonoDomain* domain, MonoTypeEnum type, const char *blob, void *value) MONO_INTERNAL;
1322 mono_release_type_locks (MonoThread *thread) MONO_INTERNAL;
1325 mono_string_to_utf8_mp (MonoMemPool *mp, MonoString *s) MONO_INTERNAL;
1328 mono_string_to_utf8_image (MonoImage *image, MonoString *s) MONO_INTERNAL;
1332 mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array) MONO_INTERNAL;
1335 mono_array_full_copy (MonoArray *src, MonoArray *dest) MONO_INTERNAL;
1338 mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *real_proxy) MONO_INTERNAL;
1341 mono_upgrade_remote_class (MonoDomain *domain, MonoObject *tproxy, MonoClass *klass) MONO_INTERNAL;
1344 mono_create_ftnptr (MonoDomain *domain, gpointer addr) MONO_INTERNAL;
1347 mono_get_addr_from_ftnptr (gpointer descr) MONO_INTERNAL;
1350 mono_nullable_init (guint8 *buf, MonoObject *value, MonoClass *klass) MONO_INTERNAL;
1353 mono_nullable_box (guint8 *buf, MonoClass *klass) MONO_INTERNAL;
1355 #define MONO_IMT_SIZE 19
1359 gpointer target_code;
1362 typedef struct _MonoImtBuilderEntry {
1364 struct _MonoImtBuilderEntry *next;
1365 MonoImtItemValue value;
1367 guint8 has_target_code : 1;
1368 } MonoImtBuilderEntry;
1370 typedef struct _MonoIMTCheckItem MonoIMTCheckItem;
1372 struct _MonoIMTCheckItem {
1374 int check_target_idx;
1375 MonoImtItemValue value;
1377 guint8 *code_target;
1379 guint8 compare_done;
1381 guint8 short_branch;
1382 guint8 has_target_code;
1385 typedef gpointer (*MonoImtThunkBuilder) (MonoVTable *vtable, MonoDomain *domain,
1386 MonoIMTCheckItem **imt_entries, int count, gpointer fail_trunk);
1389 mono_install_imt_thunk_builder (MonoImtThunkBuilder func) MONO_INTERNAL;
1392 mono_install_imt_trampoline (gpointer tramp) MONO_INTERNAL;
1395 mono_install_vtable_trampoline (gpointer tramp) MONO_INTERNAL;
1398 mono_vtable_build_imt_slot (MonoVTable* vtable, int imt_slot) MONO_INTERNAL;
1401 mono_method_get_imt_slot (MonoMethod *method) MONO_INTERNAL;
1404 mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtable,
1405 gpointer *vtable_slot,
1406 MonoMethod *method, gpointer code) MONO_INTERNAL;
1409 mono_method_alloc_generic_virtual_thunk (MonoDomain *domain, int size) MONO_INTERNAL;
1412 MONO_UNHANDLED_POLICY_LEGACY,
1413 MONO_UNHANDLED_POLICY_CURRENT
1414 } MonoRuntimeUnhandledExceptionPolicy;
1416 MonoRuntimeUnhandledExceptionPolicy
1417 mono_runtime_unhandled_exception_policy_get (void) MONO_INTERNAL;
1419 mono_runtime_unhandled_exception_policy_set (MonoRuntimeUnhandledExceptionPolicy policy) MONO_INTERNAL;
1422 mono_class_try_get_vtable (MonoDomain *domain, MonoClass *class) MONO_INTERNAL;
1425 mono_runtime_class_init_full (MonoVTable *vtable, gboolean raise_exception) MONO_INTERNAL;
1428 mono_method_clear_object (MonoDomain *domain, MonoMethod *method) MONO_INTERNAL;
1431 mono_class_compute_gc_descriptor (MonoClass *class) MONO_INTERNAL;
1433 #endif /* __MONO_OBJECT_INTERNALS_H__ */