X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Ficall.c;h=e58903aa88ae32ce21eab684712b7c40e4b61aa6;hb=c06516cde05a33e4e1af37f5e5823e7fc965c3d4;hp=ca649adcf0509edd510afb5eb0008d3eccaf72af;hpb=e4816c5c39ba39514bc57f87a22da3c749f83893;p=mono.git diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index ca649adcf05..e58903aa88a 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -8,6 +8,7 @@ * * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com) * Copyright 2004-2009 Novell, Inc (http://www.novell.com) + * Copyright 2011-2012 Xamarin Inc (http://www.xamarin.com). */ #include @@ -90,7 +91,7 @@ extern MonoString* ves_icall_System_Environment_GetOSVersionString (void) MONO_INTERNAL; -static MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void); +ICALL_EXPORT MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void); static MonoArray* type_array_from_modifiers (MonoImage *image, MonoType *type, int optional); @@ -111,7 +112,7 @@ mono_class_init_or_throw (MonoClass *klass) /* * We expect a pointer to a char, not a string */ -static gboolean +ICALL_EXPORT gboolean mono_double_ParseImpl (char *ptr, double *result) { gchar *endptr = NULL; @@ -137,7 +138,7 @@ mono_double_ParseImpl (char *ptr, double *result) return TRUE; } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos) { MonoClass *ac; @@ -159,7 +160,7 @@ ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos) return *ea; } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs) { MonoClass *ac, *ic; @@ -202,7 +203,7 @@ ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs) return ves_icall_System_Array_GetValueImpl (this, pos); } -static void +ICALL_EXPORT void ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 pos) { MonoClass *ac, *vc, *ec; @@ -234,7 +235,7 @@ ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 } if (!value) { - memset (ea, 0, esize); + mono_gc_bzero (ea, esize); return; } @@ -297,7 +298,7 @@ ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 if (ec->has_references) mono_value_copy (ea, (char*)value + sizeof (MonoObject), ec); else - memcpy (ea, (char *)value + sizeof (MonoObject), esize); + mono_gc_memmove (ea, (char *)value + sizeof (MonoObject), esize); return; } @@ -480,7 +481,7 @@ ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 #undef ASSIGN_REAL } -static void +ICALL_EXPORT void ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value, MonoArray *idxs) { @@ -521,7 +522,7 @@ ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value, ves_icall_System_Array_SetValueImpl (this, value, pos); } -static MonoArray * +ICALL_EXPORT MonoArray * ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds) { MonoClass *aklass, *klass; @@ -557,7 +558,7 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray * for (i = 0; i < aklass->rank; ++i) { sizes [i] = mono_array_get (lengths, guint32, i); if (bounds) - sizes [i + aklass->rank] = mono_array_get (bounds, guint32, i); + sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i); else sizes [i + aklass->rank] = 0; } @@ -567,7 +568,7 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray * return array; } -static MonoArray * +ICALL_EXPORT MonoArray * ves_icall_System_Array_CreateInstanceImpl64 (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds) { MonoClass *aklass, *klass; @@ -614,7 +615,7 @@ ves_icall_System_Array_CreateInstanceImpl64 (MonoReflectionType *type, MonoArray return array; } -static gint32 +ICALL_EXPORT gint32 ves_icall_System_Array_GetRank (MonoObject *this) { MONO_ARCH_SAVE_REGS; @@ -622,7 +623,7 @@ ves_icall_System_Array_GetRank (MonoObject *this) return this->vtable->klass->rank; } -static gint32 +ICALL_EXPORT gint32 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension) { gint32 rank = ((MonoObject *)this)->vtable->klass->rank; @@ -645,7 +646,7 @@ ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension) return length; } -static gint64 +ICALL_EXPORT gint64 ves_icall_System_Array_GetLongLength (MonoArray *this, gint32 dimension) { gint32 rank = ((MonoObject *)this)->vtable->klass->rank; @@ -661,7 +662,7 @@ ves_icall_System_Array_GetLongLength (MonoArray *this, gint32 dimension) return this->bounds [dimension].length; } -static gint32 +ICALL_EXPORT gint32 ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension) { gint32 rank = ((MonoObject *)this)->vtable->klass->rank; @@ -677,14 +678,14 @@ ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension) return this->bounds [dimension].lower_bound; } -static void +ICALL_EXPORT void ves_icall_System_Array_ClearInternal (MonoArray *arr, int idx, int length) { int sz = mono_array_element_size (mono_object_class (arr)); - memset (mono_array_addr_with_size (arr, sz, idx), 0, length * sz); + mono_gc_bzero (mono_array_addr_with_size (arr, sz, idx), length * sz); } -static gboolean +ICALL_EXPORT gboolean ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length) { int element_size; @@ -772,7 +773,7 @@ ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* d mono_value_copy_array (dest, dest_idx, source_addr, length); } else { dest_addr = mono_array_addr_with_size (dest, element_size, dest_idx); - memmove (dest_addr, source_addr, element_size * length); + mono_gc_memmove (dest_addr, source_addr, element_size * length); } } else { mono_array_memcpy_refs (dest, dest_idx, source, source_idx, length); @@ -781,7 +782,7 @@ ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* d return TRUE; } -static void +ICALL_EXPORT void ves_icall_System_Array_GetGenericValueImpl (MonoObject *this, guint32 pos, gpointer value) { MonoClass *ac; @@ -797,10 +798,10 @@ ves_icall_System_Array_GetGenericValueImpl (MonoObject *this, guint32 pos, gpoin esize = mono_array_element_size (ac); ea = (gpointer*)((char*)ao->vector + (pos * esize)); - memcpy (value, ea, esize); + mono_gc_memmove (value, ea, esize); } -static void +ICALL_EXPORT void ves_icall_System_Array_SetGenericValueImpl (MonoObject *this, guint32 pos, gpointer value) { MonoClass *ac, *ec; @@ -826,11 +827,11 @@ ves_icall_System_Array_SetGenericValueImpl (MonoObject *this, guint32 pos, gpoin if (ec->has_references) mono_gc_wbarrier_value_copy (ea, value, 1, ec); else - memcpy (ea, value, esize); + mono_gc_memmove (ea, value, esize); } } -static void +ICALL_EXPORT void ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArray *array, MonoClassField *field_handle) { MonoClass *klass = array->obj.vtable->klass; @@ -910,7 +911,7 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoAr #endif } -static gint +ICALL_EXPORT gint ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData (void) { MONO_ARCH_SAVE_REGS; @@ -918,7 +919,7 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData ( return offsetof (MonoString, chars); } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObject *obj) { MONO_ARCH_SAVE_REGS; @@ -929,7 +930,7 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObj return mono_object_clone (obj); } -static void +ICALL_EXPORT void ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (MonoType *handle) { MonoClass *klass; @@ -946,7 +947,7 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (Mo mono_runtime_class_init (vtable); } -static void +ICALL_EXPORT void ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor (MonoImage *image) { MONO_ARCH_SAVE_REGS; @@ -959,7 +960,7 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor (M } } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void) { guint8 *stack_addr; @@ -982,7 +983,7 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStac return TRUE; } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Object_MemberwiseClone (MonoObject *this) { MONO_ARCH_SAVE_REGS; @@ -990,7 +991,7 @@ ves_icall_System_Object_MemberwiseClone (MonoObject *this) return mono_object_clone (this); } -static gint32 +ICALL_EXPORT gint32 ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fields) { MonoClass *klass; @@ -1050,7 +1051,7 @@ ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fi return result; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray **fields) { MonoClass *klass; @@ -1162,7 +1163,7 @@ ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray } } -static MonoReflectionType * +ICALL_EXPORT MonoReflectionType * ves_icall_System_Object_GetType (MonoObject *obj) { MONO_ARCH_SAVE_REGS; @@ -1173,7 +1174,7 @@ ves_icall_System_Object_GetType (MonoObject *obj) return mono_type_get_object (mono_object_domain (obj), &((MonoTransparentProxy*)obj)->remote_class->proxy_class->byval_arg); } -static void +ICALL_EXPORT void mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj) { MONO_ARCH_SAVE_REGS; @@ -1182,7 +1183,7 @@ mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj) g_assert (mtype->type->type); } -static gint32 +ICALL_EXPORT gint32 ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilder *mb, MonoObject *obj, gboolean create_open_instance) { MONO_ARCH_SAVE_REGS; @@ -1192,7 +1193,7 @@ ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilder *mb, MonoObject *o return mono_image_create_token (mb->dynamic_image, obj, create_open_instance, TRUE); } -static gint32 +ICALL_EXPORT gint32 ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilder *mb, MonoReflectionMethod *method, MonoArray *opt_param_types) @@ -1205,7 +1206,7 @@ ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilder *mb, mb->dynamic_image, (MonoObject *) method, opt_param_types); } -static void +ICALL_EXPORT void ves_icall_ModuleBuilder_WriteToFile (MonoReflectionModuleBuilder *mb, HANDLE file) { MONO_ARCH_SAVE_REGS; @@ -1213,7 +1214,7 @@ ves_icall_ModuleBuilder_WriteToFile (MonoReflectionModuleBuilder *mb, HANDLE fil mono_image_create_pefile (mb, file); } -static void +ICALL_EXPORT void ves_icall_ModuleBuilder_build_metadata (MonoReflectionModuleBuilder *mb) { MONO_ARCH_SAVE_REGS; @@ -1221,7 +1222,7 @@ ves_icall_ModuleBuilder_build_metadata (MonoReflectionModuleBuilder *mb) mono_image_build_metadata (mb); } -static void +ICALL_EXPORT void ves_icall_ModuleBuilder_RegisterToken (MonoReflectionModuleBuilder *mb, MonoObject *obj, guint32 token) { MONO_ARCH_SAVE_REGS; @@ -1371,7 +1372,7 @@ mono_type_get (const char *str) } #endif -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_type_from_name (MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase) @@ -1396,7 +1397,7 @@ ves_icall_type_from_name (MonoString *name, } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_type_from_handle (MonoType *handle) { MonoDomain *domain = mono_domain_get (); @@ -1406,7 +1407,7 @@ ves_icall_type_from_handle (MonoType *handle) return mono_type_get_object (domain, handle); } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_Type_EqualsInternal (MonoReflectionType *type, MonoReflectionType *c) { MONO_ARCH_SAVE_REGS; @@ -1439,7 +1440,7 @@ typedef enum { TYPECODE_STRING = 18 } TypeCode; -static guint32 +ICALL_EXPORT guint32 ves_icall_type_GetTypeCodeInternal (MonoReflectionType *type) { int t = type->type->type; @@ -1523,7 +1524,7 @@ handle_enum: return 0; } -static guint32 +ICALL_EXPORT guint32 ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, MonoBoolean check_interfaces) { MonoDomain *domain; @@ -1578,7 +1579,7 @@ mono_type_get_underlying_type_ignore_byref (MonoType *type) return type; } -static guint32 +ICALL_EXPORT guint32 ves_icall_type_is_assignable_from (MonoReflectionType *type, MonoReflectionType *c) { MonoDomain *domain; @@ -1625,7 +1626,7 @@ ves_icall_type_is_assignable_from (MonoReflectionType *type, MonoReflectionType return mono_class_is_assignable_from (klass, klassc); } -static guint32 +ICALL_EXPORT guint32 ves_icall_type_IsInstanceOfType (MonoReflectionType *type, MonoObject *obj) { MonoClass *klass = mono_class_from_mono_type (type->type); @@ -1633,14 +1634,14 @@ ves_icall_type_IsInstanceOfType (MonoReflectionType *type, MonoObject *obj) return mono_object_isinst (obj, klass) != NULL; } -static guint32 +ICALL_EXPORT guint32 ves_icall_get_attributes (MonoReflectionType *type) { MonoClass *klass = mono_class_from_mono_type (type->type); return klass->flags; } -static MonoReflectionMarshal* +ICALL_EXPORT MonoReflectionMarshal* ves_icall_System_Reflection_FieldInfo_GetUnmanagedMarshal (MonoReflectionField *field) { MonoClass *klass = field->field->parent; @@ -1665,7 +1666,7 @@ ves_icall_System_Reflection_FieldInfo_GetUnmanagedMarshal (MonoReflectionField * return NULL; } -static MonoReflectionField* +ICALL_EXPORT MonoReflectionField* ves_icall_System_Reflection_FieldInfo_internal_from_handle_type (MonoClassField *handle, MonoType *type) { gboolean found = FALSE; @@ -1695,7 +1696,7 @@ ves_icall_System_Reflection_FieldInfo_internal_from_handle_type (MonoClassField return mono_field_get_object (mono_domain_get (), klass, handle); } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_System_Reflection_FieldInfo_GetTypeModifiers (MonoReflectionField *field, MonoBoolean optional) { MonoError error; @@ -1706,13 +1707,13 @@ ves_icall_System_Reflection_FieldInfo_GetTypeModifiers (MonoReflectionField *fie return type_array_from_modifiers (field->field->parent->image, type, optional); } -static int +ICALL_EXPORT int vell_icall_get_method_attributes (MonoMethod *method) { return method->flags; } -static void +ICALL_EXPORT void ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info) { MonoError error; @@ -1740,7 +1741,7 @@ ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info) info->callconv |= (sig->hasthis << 5) | (sig->explicit_this << 6); } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_get_parameter_info (MonoMethod *method, MonoReflectionMethod *member) { MonoDomain *domain = mono_domain_get (); @@ -1748,7 +1749,7 @@ ves_icall_get_parameter_info (MonoMethod *method, MonoReflectionMethod *member) return mono_param_get_objects_internal (domain, method, member->reftype ? mono_class_from_mono_type (member->reftype->type) : NULL); } -static MonoReflectionMarshal* +ICALL_EXPORT MonoReflectionMarshal* ves_icall_System_MonoMethodInfo_get_retval_marshal (MonoMethod *method) { MonoDomain *domain = mono_domain_get (); @@ -1770,7 +1771,7 @@ ves_icall_System_MonoMethodInfo_get_retval_marshal (MonoMethod *method) return res; } -static gint32 +ICALL_EXPORT gint32 ves_icall_MonoField_GetFieldOffset (MonoReflectionField *field) { MonoClass *parent = field->field->parent; @@ -1780,7 +1781,7 @@ ves_icall_MonoField_GetFieldOffset (MonoReflectionField *field) return field->field->offset - sizeof (MonoObject); } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_MonoField_GetParentType (MonoReflectionField *field, MonoBoolean declaring) { MonoClass *parent; @@ -1791,7 +1792,7 @@ ves_icall_MonoField_GetParentType (MonoReflectionField *field, MonoBoolean decla return mono_type_get_object (mono_object_domain (field), &parent->byval_arg); } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *obj) { MonoClass *fklass = field->klass; @@ -1808,7 +1809,7 @@ ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *ob return mono_field_get_value_object (domain, cf, obj); } -static void +ICALL_EXPORT void ves_icall_MonoField_SetValueInternal (MonoReflectionField *field, MonoObject *obj, MonoObject *value) { MonoError error; @@ -1899,7 +1900,7 @@ ves_icall_MonoField_SetValueInternal (MonoReflectionField *field, MonoObject *ob } } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_MonoField_GetRawConstantValue (MonoReflectionField *this) { MonoObject *o = NULL; @@ -1929,6 +1930,8 @@ ves_icall_MonoField_GetRawConstantValue (MonoReflectionField *this) } def_value = mono_class_get_field_default_value (field, &def_type); + if (!def_value) /*FIXME, maybe we should try to raise TLE if field->parent is broken */ + mono_raise_exception (mono_get_exception_invalid_operation (NULL)); /*FIXME unify this with reflection.c:mono_get_object_from_blob*/ switch (def_type) { @@ -1969,7 +1972,7 @@ ves_icall_MonoField_GetRawConstantValue (MonoReflectionField *this) return o; } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_MonoField_ResolveType (MonoReflectionField *ref_field) { MonoError error; @@ -1980,7 +1983,7 @@ ves_icall_MonoField_ResolveType (MonoReflectionField *ref_field) return mono_type_get_object (mono_object_domain (ref_field), type); } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_MonoGenericMethod_get_ReflectedType (MonoReflectionGenericMethod *rmethod) { MonoMethod *method = rmethod->method.method; @@ -1998,7 +2001,7 @@ typedef enum { PInfo_Name = 1 << 5 } PInfo; -static void +ICALL_EXPORT void ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info, PInfo req_info) { MonoDomain *domain = mono_object_domain (property); @@ -2029,7 +2032,7 @@ ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo */ } -static void +ICALL_EXPORT void ves_icall_get_event_info (MonoReflectionMonoEvent *event, MonoEventInfo *info) { MonoDomain *domain = mono_object_domain (event); @@ -2108,7 +2111,7 @@ fill_iface_array (gpointer key, gpointer value, gpointer user_data) mono_metadata_free_type (inflated); } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_Type_GetInterfaces (MonoReflectionType* type) { MonoError error; @@ -2158,7 +2161,7 @@ fail: return NULL; } -static void +ICALL_EXPORT void ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType *iface, MonoArray **targets, MonoArray **methods) { gboolean variance_used; @@ -2195,7 +2198,7 @@ ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType } } -static void +ICALL_EXPORT void ves_icall_Type_GetPacking (MonoReflectionType *type, guint32 *packing, guint32 *size) { MonoClass *klass = mono_class_from_mono_type (type->type); @@ -2210,7 +2213,7 @@ ves_icall_Type_GetPacking (MonoReflectionType *type, guint32 *packing, guint32 * } } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_MonoType_GetElementType (MonoReflectionType *type) { MonoClass *class; @@ -2235,14 +2238,14 @@ ves_icall_MonoType_GetElementType (MonoReflectionType *type) return NULL; } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_get_type_parent (MonoReflectionType *type) { MonoClass *class = mono_class_from_mono_type (type->type); return class->parent ? mono_type_get_object (mono_object_domain (type), &class->parent->byval_arg): NULL; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_type_ispointer (MonoReflectionType *type) { MONO_ARCH_SAVE_REGS; @@ -2250,7 +2253,7 @@ ves_icall_type_ispointer (MonoReflectionType *type) return type->type->type == MONO_TYPE_PTR; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_type_isprimitive (MonoReflectionType *type) { MONO_ARCH_SAVE_REGS; @@ -2258,7 +2261,7 @@ ves_icall_type_isprimitive (MonoReflectionType *type) return (!type->type->byref && (((type->type->type >= MONO_TYPE_BOOLEAN) && (type->type->type <= MONO_TYPE_R8)) || (type->type->type == MONO_TYPE_I) || (type->type->type == MONO_TYPE_U))); } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_type_isbyref (MonoReflectionType *type) { MONO_ARCH_SAVE_REGS; @@ -2266,7 +2269,7 @@ ves_icall_type_isbyref (MonoReflectionType *type) return type->type->byref; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_type_iscomobject (MonoReflectionType *type) { MonoClass *klass = mono_class_from_mono_type (type->type); @@ -2275,14 +2278,14 @@ ves_icall_type_iscomobject (MonoReflectionType *type) return (klass && klass->is_com_object); } -static MonoReflectionModule* +ICALL_EXPORT MonoReflectionModule* ves_icall_MonoType_get_Module (MonoReflectionType *type) { MonoClass *class = mono_class_from_mono_type (type->type); return mono_module_get_object (mono_object_domain (type), class->image); } -static MonoReflectionAssembly* +ICALL_EXPORT MonoReflectionAssembly* ves_icall_MonoType_get_Assembly (MonoReflectionType *type) { MonoDomain *domain = mono_domain_get (); @@ -2290,7 +2293,7 @@ ves_icall_MonoType_get_Assembly (MonoReflectionType *type) return mono_assembly_get_object (domain, class->image->assembly); } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_MonoType_get_DeclaringType (MonoReflectionType *type) { MonoDomain *domain = mono_domain_get (); @@ -2310,7 +2313,7 @@ ves_icall_MonoType_get_DeclaringType (MonoReflectionType *type) return class ? mono_type_get_object (domain, &class->byval_arg) : NULL; } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_MonoType_get_Name (MonoReflectionType *type) { MonoDomain *domain = mono_domain_get (); @@ -2328,7 +2331,7 @@ ves_icall_MonoType_get_Name (MonoReflectionType *type) } } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_MonoType_get_Namespace (MonoReflectionType *type) { MonoDomain *domain = mono_domain_get (); @@ -2343,7 +2346,7 @@ ves_icall_MonoType_get_Namespace (MonoReflectionType *type) return mono_string_new (domain, class->name_space); } -static gint32 +ICALL_EXPORT gint32 ves_icall_MonoType_GetArrayRank (MonoReflectionType *type) { MonoClass *class; @@ -2356,7 +2359,7 @@ ves_icall_MonoType_GetArrayRank (MonoReflectionType *type) return class->rank; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type) { MonoArray *res; @@ -2386,7 +2389,7 @@ ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type) return res; } -static gboolean +ICALL_EXPORT gboolean ves_icall_Type_get_IsGenericTypeDefinition (MonoReflectionType *type) { MonoClass *klass; @@ -2402,7 +2405,7 @@ ves_icall_Type_get_IsGenericTypeDefinition (MonoReflectionType *type) return klass->generic_container != NULL; } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_Type_GetGenericTypeDefinition_impl (MonoReflectionType *type) { MonoClass *klass; @@ -2430,7 +2433,7 @@ ves_icall_Type_GetGenericTypeDefinition_impl (MonoReflectionType *type) return NULL; } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_Type_MakeGenericType (MonoReflectionType *type, MonoArray *type_array) { MonoClass *class; @@ -2462,7 +2465,7 @@ ves_icall_Type_MakeGenericType (MonoReflectionType *type, MonoArray *type_array) return mono_type_get_object (mono_object_domain (type), geninst); } -static gboolean +ICALL_EXPORT gboolean ves_icall_Type_get_IsGenericInstance (MonoReflectionType *type) { MonoClass *klass; @@ -2476,7 +2479,7 @@ ves_icall_Type_get_IsGenericInstance (MonoReflectionType *type) return klass->generic_class != NULL; } -static gboolean +ICALL_EXPORT gboolean ves_icall_Type_get_IsGenericType (MonoReflectionType *type) { MonoClass *klass; @@ -2492,7 +2495,7 @@ ves_icall_Type_get_IsGenericType (MonoReflectionType *type) return klass->generic_class != NULL || klass->generic_container != NULL; } -static gint32 +ICALL_EXPORT gint32 ves_icall_Type_GetGenericParameterPosition (MonoReflectionType *type) { MONO_ARCH_SAVE_REGS; @@ -2505,7 +2508,7 @@ ves_icall_Type_GetGenericParameterPosition (MonoReflectionType *type) return -1; } -static GenericParameterAttributes +ICALL_EXPORT GenericParameterAttributes ves_icall_Type_GetGenericParameterAttributes (MonoReflectionType *type) { MONO_ARCH_SAVE_REGS; @@ -2515,7 +2518,7 @@ ves_icall_Type_GetGenericParameterAttributes (MonoReflectionType *type) return mono_generic_param_info (type->type->data.generic_param)->flags; } -static MonoArray * +ICALL_EXPORT MonoArray * ves_icall_Type_GetGenericParameterConstraints (MonoReflectionType *type) { MonoGenericParamInfo *param_info; @@ -2541,28 +2544,28 @@ ves_icall_Type_GetGenericParameterConstraints (MonoReflectionType *type) return res; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_MonoType_get_IsGenericParameter (MonoReflectionType *type) { MONO_ARCH_SAVE_REGS; return is_generic_parameter (type->type); } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_TypeBuilder_get_IsGenericParameter (MonoReflectionTypeBuilder *tb) { MONO_ARCH_SAVE_REGS; return is_generic_parameter (tb->type.type); } -static void +ICALL_EXPORT void ves_icall_EnumBuilder_setup_enum_type (MonoReflectionType *enumtype, MonoReflectionType *t) { enumtype->type = t->type; } -static MonoReflectionMethod* +ICALL_EXPORT MonoReflectionMethod* ves_icall_MonoType_GetCorrespondingInflatedMethod (MonoReflectionType *type, MonoReflectionMethod* generic) { @@ -2589,7 +2592,7 @@ ves_icall_MonoType_GetCorrespondingInflatedMethod (MonoReflectionType *type, -static MonoReflectionMethod * +ICALL_EXPORT MonoReflectionMethod * ves_icall_MonoType_get_DeclaringMethod (MonoReflectionType *ref_type) { MonoMethod *method; @@ -2607,7 +2610,7 @@ ves_icall_MonoType_get_DeclaringMethod (MonoReflectionType *ref_type) return mono_method_get_object (mono_object_domain (ref_type), method, method->klass); } -static MonoReflectionDllImportAttribute* +ICALL_EXPORT MonoReflectionDllImportAttribute* ves_icall_MonoMethod_GetDllImportAttribute (MonoMethod *method) { static MonoClass *DllImportAttributeClass = NULL; @@ -2677,7 +2680,7 @@ ves_icall_MonoMethod_GetDllImportAttribute (MonoMethod *method) return attr; } -static MonoReflectionMethod * +ICALL_EXPORT MonoReflectionMethod * ves_icall_MonoMethod_GetGenericMethodDefinition (MonoReflectionMethod *method) { MonoMethodInflated *imethod; @@ -2724,7 +2727,7 @@ ves_icall_MonoMethod_GetGenericMethodDefinition (MonoReflectionMethod *method) return mono_method_get_object (mono_object_domain (method), result, NULL); } -static gboolean +ICALL_EXPORT gboolean ves_icall_MonoMethod_get_IsGenericMethod (MonoReflectionMethod *method) { MONO_ARCH_SAVE_REGS; @@ -2732,7 +2735,7 @@ ves_icall_MonoMethod_get_IsGenericMethod (MonoReflectionMethod *method) return mono_method_signature (method->method)->generic_param_count != 0; } -static gboolean +ICALL_EXPORT gboolean ves_icall_MonoMethod_get_IsGenericMethodDefinition (MonoReflectionMethod *method) { MONO_ARCH_SAVE_REGS; @@ -2740,7 +2743,7 @@ ves_icall_MonoMethod_get_IsGenericMethodDefinition (MonoReflectionMethod *method return method->method->is_generic; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethod *method) { MonoArray *res; @@ -2779,7 +2782,7 @@ ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethod *method) return res; } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoException **exc) { /* @@ -2788,6 +2791,7 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr * greater flexibility. */ MonoMethod *m = method->method; + MonoMethodSignature *sig = mono_method_signature (m); int pcount; void *obj = this; @@ -2806,7 +2810,13 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr if (this) { if (!mono_object_isinst (this, m->klass)) { - mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_exception_from_name_msg (mono_defaults.corlib, "System.Reflection", "TargetException", "Object does not match target type.")); + char *this_name = mono_type_get_full_name (mono_object_get_class (this)); + char *target_name = mono_type_get_full_name (m->klass); + char *msg = g_strdup_printf ("Object of type '%s' doesn't match target type '%s'", this_name, target_name); + mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_exception_from_name_msg (mono_defaults.corlib, "System.Reflection", "TargetException", msg)); + g_free (msg); + g_free (target_name); + g_free (this_name); return NULL; } m = mono_object_get_virtual_method (this, m); @@ -2819,8 +2829,13 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr } } + if (sig->ret->byref) { + mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_exception_from_name_msg (mono_defaults.corlib, "System", "NotSupportedException", "Cannot invoke method returning ByRef type via reflection")); + return NULL; + } + pcount = params? mono_array_length (params): 0; - if (pcount != mono_method_signature (m)->param_count) { + if (pcount != sig->param_count) { mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetParameterCountException")); return NULL; } @@ -2860,7 +2875,7 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr return mono_runtime_invoke_array (m, obj, params, NULL); } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoArray **outArgs) { MonoDomain *domain = mono_object_domain (method); @@ -3048,7 +3063,7 @@ write_enum_value (char *mem, int type, guint64 value) return; } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Enum_ToObject (MonoReflectionType *enumType, MonoObject *value) { MonoDomain *domain; @@ -3086,7 +3101,7 @@ ves_icall_System_Enum_ToObject (MonoReflectionType *enumType, MonoObject *value) return res; } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Enum_get_value (MonoObject *this) { MonoObject *res; @@ -3113,7 +3128,7 @@ ves_icall_System_Enum_get_value (MonoObject *this) return res; } -static MonoReflectionType * +ICALL_EXPORT MonoReflectionType * ves_icall_System_Enum_get_underlying_type (MonoReflectionType *type) { MonoType *etype; @@ -3132,7 +3147,7 @@ ves_icall_System_Enum_get_underlying_type (MonoReflectionType *type) return mono_type_get_object (mono_object_domain (type), etype); } -static int +ICALL_EXPORT int ves_icall_System_Enum_compare_value_to (MonoObject *this, MonoObject *other) { gpointer tdata = (char *)this + sizeof (MonoObject); @@ -3182,7 +3197,7 @@ ves_icall_System_Enum_compare_value_to (MonoObject *this, MonoObject *other) return 0; } -static int +ICALL_EXPORT int ves_icall_System_Enum_get_hashcode (MonoObject *this) { gpointer data = (char *)this + sizeof (MonoObject); @@ -3215,7 +3230,7 @@ ves_icall_System_Enum_get_hashcode (MonoObject *this) return 0; } -static void +ICALL_EXPORT void ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info) { MonoDomain *domain = mono_object_domain (type); @@ -3294,7 +3309,7 @@ enum { BFLAGS_OptionalParamBinding = 0x40000 }; -static MonoReflectionField * +ICALL_EXPORT MonoReflectionField * ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bflags) { MonoDomain *domain; @@ -3364,7 +3379,7 @@ handle_parent: return NULL; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_Type_GetFields_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype) { MonoDomain *domain; @@ -3451,66 +3466,42 @@ method_nonpublic (MonoMethod* method, gboolean start_klass) } } -static MonoArray* -ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype) +GPtrArray* +mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoException **ex) { - static MonoClass *MethodInfo_array; - MonoDomain *domain; - MonoClass *startklass, *klass, *refklass; - MonoArray *res; + GPtrArray *array; + MonoClass *startklass; MonoMethod *method; gpointer iter; - MonoObject *member; - int i, len, match, nslots; + int len, match, nslots; /*FIXME, use MonoBitSet*/ guint32 method_slots_default [8]; guint32 *method_slots = NULL; - gchar *mname = NULL; int (*compare_func) (const char *s1, const char *s2) = NULL; - MonoVTable *array_vtable; - MonoException *ex; - MonoPtrArray tmp_array; - mono_ptr_array_init (tmp_array, 4); - - if (!MethodInfo_array) { - MonoClass *klass = mono_array_class_get (mono_defaults.method_info_class, 1); - mono_memory_barrier (); - MethodInfo_array = klass; - } - - domain = ((MonoObject *)type)->vtable->domain; - array_vtable = mono_class_vtable_full (domain, MethodInfo_array, TRUE); - if (type->type->byref) - return mono_array_new_specific (array_vtable, 0); - klass = startklass = mono_class_from_mono_type (type->type); - refklass = mono_class_from_mono_type (reftype->type); + array = g_ptr_array_new (); + startklass = klass; + *ex = NULL; len = 0; - if (name != NULL) { - mname = mono_string_to_utf8 (name); + if (name != NULL) compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp; - } /* An optimization for calls made from Delegate:CreateDelegate () */ - if (klass->delegate && mname && !strcmp (mname, "Invoke") && (bflags == (BFLAGS_Public | BFLAGS_Static | BFLAGS_Instance))) { + if (klass->delegate && name && !strcmp (name, "Invoke") && (bflags == (BFLAGS_Public | BFLAGS_Static | BFLAGS_Instance))) { method = mono_get_delegate_invoke (klass); if (mono_loader_get_last_error ()) goto loader_error; - member = (MonoObject*)mono_method_get_object (domain, method, refklass); - - res = mono_array_new_specific (array_vtable, 1); - mono_array_setref (res, 0, member); - g_free (mname); - return res; + g_ptr_array_add (array, method); + return array; } mono_class_setup_vtable (klass); if (klass->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ()) goto loader_error; - if (is_generic_parameter (type->type)) + if (is_generic_parameter (&klass->byval_arg)) nslots = mono_class_get_vtable_size (klass->parent); else nslots = MONO_CLASS_IS_INTERFACE (klass) ? mono_class_num_methods (klass) : mono_class_get_vtable_size (klass); @@ -3536,7 +3527,7 @@ handle_parent: method_slots [method->slot >> 5] |= 1 << (method->slot & 0x1f); } - if (method->name [0] == '.' && (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)) + if (!allow_ctors && method->name [0] == '.' && (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)) continue; if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) { if (bflags & BFLAGS_Public) @@ -3560,47 +3551,81 @@ handle_parent: continue; if (name != NULL) { - if (compare_func (mname, method->name)) + if (compare_func (name, method->name)) continue; } match = 0; - - member = (MonoObject*)mono_method_get_object (domain, method, refklass); - - mono_ptr_array_append (tmp_array, member); + g_ptr_array_add (array, method); } if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)) goto handle_parent; - - g_free (mname); if (method_slots != method_slots_default) g_free (method_slots); - res = mono_array_new_specific (array_vtable, mono_ptr_array_size (tmp_array)); - - for (i = 0; i < mono_ptr_array_size (tmp_array); ++i) - mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i)); - - mono_ptr_array_destroy (tmp_array); - return res; + return array; loader_error: - g_free (mname); if (method_slots != method_slots_default) g_free (method_slots); - mono_ptr_array_destroy (tmp_array); + g_ptr_array_free (array, TRUE); + if (klass->exception_type != MONO_EXCEPTION_NONE) { - ex = mono_class_get_exception_for_failure (klass); + *ex = mono_class_get_exception_for_failure (klass); } else { - ex = mono_loader_error_prepare_exception (mono_loader_get_last_error ()); + *ex = mono_loader_error_prepare_exception (mono_loader_get_last_error ()); mono_loader_clear_error (); } - mono_raise_exception (ex); return NULL; } -static MonoArray* +ICALL_EXPORT MonoArray* +ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype) +{ + static MonoClass *MethodInfo_array; + MonoDomain *domain; + MonoArray *res; + MonoVTable *array_vtable; + MonoException *ex = NULL; + const char *mname = NULL; + GPtrArray *method_array; + MonoClass *klass, *refklass; + int i; + + if (!MethodInfo_array) { + MonoClass *klass = mono_array_class_get (mono_defaults.method_info_class, 1); + mono_memory_barrier (); + MethodInfo_array = klass; + } + + klass = mono_class_from_mono_type (type->type); + refklass = mono_class_from_mono_type (reftype->type); + domain = ((MonoObject *)type)->vtable->domain; + array_vtable = mono_class_vtable_full (domain, MethodInfo_array, TRUE); + if (type->type->byref) + return mono_array_new_specific (array_vtable, 0); + + if (name) + mname = mono_string_to_utf8 (name); + + method_array = mono_class_get_methods_by_name (klass, mname, bflags, ignore_case, FALSE, &ex); + g_free ((char*)mname); + if (ex) + mono_raise_exception (ex); + + res = mono_array_new_specific (array_vtable, method_array->len); + + + for (i = 0; i < method_array->len; ++i) { + MonoMethod *method = g_ptr_array_index (method_array, i); + mono_array_setref (res, i, mono_method_get_object (domain, method, refklass)); + } + + g_ptr_array_free (method_array, TRUE); + return res; +} + +ICALL_EXPORT MonoArray* ves_icall_Type_GetConstructors_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype) { MonoDomain *domain; @@ -3699,7 +3724,7 @@ property_accessor_nonpublic (MonoMethod* accessor, gboolean start_klass) return method_nonpublic (accessor, start_klass); } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_Type_GetPropertiesByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype) { MonoException *ex; @@ -3820,7 +3845,7 @@ loader_error: return NULL; } -static MonoReflectionEvent * +ICALL_EXPORT MonoReflectionEvent * ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32 bflags) { MonoDomain *domain; @@ -3891,7 +3916,7 @@ handle_parent: return NULL; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_Type_GetEvents_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype) { MonoException *ex; @@ -3988,7 +4013,7 @@ loader_error: return NULL; } -static MonoReflectionType * +ICALL_EXPORT MonoReflectionType * ves_icall_Type_GetNestedType (MonoReflectionType *type, MonoString *name, guint32 bflags) { MonoDomain *domain; @@ -4048,7 +4073,7 @@ ves_icall_Type_GetNestedType (MonoReflectionType *type, MonoString *name, guint3 return NULL; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags) { MonoDomain *domain; @@ -4106,7 +4131,7 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags) return res; } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *assembly, MonoReflectionModule *module, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase) { gchar *str; @@ -4248,7 +4273,7 @@ replace_shadow_path (MonoDomain *domain, gchar *dirname, gchar **filename) return FALSE; } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *assembly, MonoBoolean escaped) { MonoDomain *domain = mono_object_domain (assembly); @@ -4300,7 +4325,7 @@ ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *asse return res; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_Reflection_Assembly_get_global_assembly_cache (MonoReflectionAssembly *assembly) { MonoAssembly *mass = assembly->assembly; @@ -4310,7 +4335,7 @@ ves_icall_System_Reflection_Assembly_get_global_assembly_cache (MonoReflectionAs return mass->in_gac; } -static MonoReflectionAssembly* +ICALL_EXPORT MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_load_with_partial_name (MonoString *mname, MonoObject *evidence) { gchar *name; @@ -4329,7 +4354,7 @@ ves_icall_System_Reflection_Assembly_load_with_partial_name (MonoString *mname, return mono_assembly_get_object (mono_domain_get (), res); } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly *assembly) { MonoDomain *domain = mono_object_domain (assembly); @@ -4342,7 +4367,7 @@ ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly *assem return res; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_Reflection_Assembly_get_ReflectionOnly (MonoReflectionAssembly *assembly) { MONO_ARCH_SAVE_REGS; @@ -4350,7 +4375,7 @@ ves_icall_System_Reflection_Assembly_get_ReflectionOnly (MonoReflectionAssembly return assembly->assembly->ref_only; } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion (MonoReflectionAssembly *assembly) { MonoDomain *domain = mono_object_domain (assembly); @@ -4360,7 +4385,7 @@ ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion (MonoReflection return mono_string_new (domain, assembly->assembly->image->version); } -static MonoReflectionMethod* +ICALL_EXPORT MonoReflectionMethod* ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssembly *assembly) { guint32 token = mono_image_get_entry_point (assembly->assembly->image); @@ -4372,13 +4397,13 @@ ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssembly *ass return mono_method_get_object (mono_object_domain (assembly), mono_get_method (assembly->assembly->image, token, NULL), NULL); } -static MonoReflectionModule* +ICALL_EXPORT MonoReflectionModule* ves_icall_System_Reflection_Assembly_GetManifestModuleInternal (MonoReflectionAssembly *assembly) { return mono_module_get_object (mono_object_domain (assembly), assembly->assembly->image); } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssembly *assembly) { MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE]; @@ -4425,7 +4450,7 @@ create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, return result; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly *assembly) { static MonoClass *System_Reflection_AssemblyName; @@ -4522,7 +4547,7 @@ foreach_namespace (const char* key, gconstpointer val, NameSpaceInfo *info) info->idx++; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Assembly_GetNamespaces (MonoReflectionAssembly *assembly) { MonoImage *img = assembly->assembly->image; @@ -4572,7 +4597,7 @@ g_concat_dir_and_file (const char *dir, const char *file) return g_strconcat (dir, file, NULL); } -static void * +ICALL_EXPORT void * ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly *assembly, MonoString *name, gint32 *size, MonoReflectionModule **ref_module) { char *n = mono_string_to_utf8 (name); @@ -4616,7 +4641,7 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflection return (void*)mono_image_get_resource (module, cols [MONO_MANIFEST_OFFSET], (guint32*)size); } -static gboolean +ICALL_EXPORT gboolean ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflectionAssembly *assembly, MonoString *name, MonoManifestResourceInfo *info) { MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE]; @@ -4681,7 +4706,7 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflec return TRUE; } -static MonoObject* +ICALL_EXPORT MonoObject* ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean resource_modules) { MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_FILE]; @@ -4731,7 +4756,7 @@ ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *a return (MonoObject*)result; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly *assembly) { MonoDomain *domain = mono_domain_get(); @@ -4786,7 +4811,7 @@ ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly return res; } -static MonoReflectionMethod* +ICALL_EXPORT MonoReflectionMethod* ves_icall_GetCurrentMethod (void) { MonoMethod *m = mono_method_get_last_managed (); @@ -4831,7 +4856,7 @@ mono_method_get_equivalent_method (MonoMethod *method, MonoClass *klass) return klass->methods [offset]; } -static MonoReflectionMethod* +ICALL_EXPORT MonoReflectionMethod* ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternalType (MonoMethod *method, MonoType *type) { MonoClass *klass; @@ -4849,19 +4874,19 @@ ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternalType (MonoMeth return mono_method_get_object (mono_domain_get (), method, klass); } -static MonoReflectionMethod* +ICALL_EXPORT MonoReflectionMethod* ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternal (MonoMethod *method) { return mono_method_get_object (mono_domain_get (), method, NULL); } -static MonoReflectionMethodBody* +ICALL_EXPORT MonoReflectionMethodBody* ves_icall_System_Reflection_MethodBase_GetMethodBodyInternal (MonoMethod *method) { return mono_method_body_get_object (mono_domain_get (), method); } -static MonoReflectionAssembly* +ICALL_EXPORT MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetExecutingAssembly (void) { MonoMethod *dest = NULL; @@ -4873,7 +4898,7 @@ ves_icall_System_Reflection_Assembly_GetExecutingAssembly (void) } -static MonoReflectionAssembly* +ICALL_EXPORT MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetEntryAssembly (void) { MonoDomain* domain = mono_domain_get (); @@ -4886,7 +4911,7 @@ ves_icall_System_Reflection_Assembly_GetEntryAssembly (void) return mono_assembly_get_object (domain, domain->entry_assembly); } -static MonoReflectionAssembly* +ICALL_EXPORT MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void) { MonoMethod *m; @@ -4903,7 +4928,7 @@ ves_icall_System_Reflection_Assembly_GetCallingAssembly (void) return mono_assembly_get_object (mono_domain_get (), dest->klass->image->assembly); } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_MonoType_getFullName (MonoReflectionType *object, gboolean full_name, gboolean assembly_qualified) { @@ -4934,7 +4959,7 @@ ves_icall_System_MonoType_getFullName (MonoReflectionType *object, gboolean full return res; } -static int +ICALL_EXPORT int vell_icall_MonoType_get_core_clr_security_level (MonoReflectionType *this) { MonoClass *klass = mono_class_from_mono_type (this->type); @@ -5041,7 +5066,7 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a } } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Reflection_Assembly_get_fullName (MonoReflectionAssembly *assembly) { MonoDomain *domain = mono_object_domain (assembly); @@ -5056,7 +5081,7 @@ ves_icall_System_Reflection_Assembly_get_fullName (MonoReflectionAssembly *assem return res; } -static void +ICALL_EXPORT void ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname) { gchar *absolute; @@ -5079,7 +5104,7 @@ ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, g_free (absolute); } -static void +ICALL_EXPORT void ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString *fname, MonoReflectionAssemblyName *aname) { char *filename; @@ -5124,7 +5149,7 @@ ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString *fname, mono_image_close (image); } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_Reflection_Assembly_LoadPermissions (MonoReflectionAssembly *assembly, char **minimum, guint32 *minLength, char **optional, guint32 *optLength, char **refused, guint32 *refLength) { @@ -5203,7 +5228,7 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **excepti return res; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly) { MonoArray *res = NULL; @@ -5311,7 +5336,7 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, return res; } -static gboolean +ICALL_EXPORT gboolean ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName *name, MonoString *assname) { MonoAssemblyName aname; @@ -5338,7 +5363,7 @@ ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName * return TRUE; } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_System_Reflection_Module_GetGlobalType (MonoReflectionModule *module) { MonoDomain *domain = mono_object_domain (module); @@ -5356,14 +5381,14 @@ ves_icall_System_Reflection_Module_GetGlobalType (MonoReflectionModule *module) return mono_type_get_object (domain, &klass->byval_arg); } -static void +ICALL_EXPORT void ves_icall_System_Reflection_Module_Close (MonoReflectionModule *module) { /*if (module->image) mono_image_close (module->image);*/ } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_System_Reflection_Module_GetGuidInternal (MonoReflectionModule *module) { MonoDomain *domain = mono_object_domain (module); @@ -5374,7 +5399,7 @@ ves_icall_System_Reflection_Module_GetGuidInternal (MonoReflectionModule *module return mono_string_new (domain, module->image->guid); } -static gpointer +ICALL_EXPORT gpointer ves_icall_System_Reflection_Module_GetHINSTANCE (MonoReflectionModule *module) { #ifdef HOST_WIN32 @@ -5385,7 +5410,7 @@ ves_icall_System_Reflection_Module_GetHINSTANCE (MonoReflectionModule *module) return (gpointer) (-1); } -static void +ICALL_EXPORT void ves_icall_System_Reflection_Module_GetPEKind (MonoImage *image, gint32 *pe_kind, gint32 *machine) { if (image->dynamic) { @@ -5399,13 +5424,13 @@ ves_icall_System_Reflection_Module_GetPEKind (MonoImage *image, gint32 *pe_kind, } } -static gint32 +ICALL_EXPORT gint32 ves_icall_System_Reflection_Module_GetMDStreamVersion (MonoImage *image) { return (image->md_version_major << 16) | (image->md_version_minor); } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Module_InternalGetTypes (MonoReflectionModule *module) { MonoArray *exceptions; @@ -5461,7 +5486,7 @@ init_generic_context_from_args (MonoGenericContext *context, MonoArray *type_arg context->method_inst = NULL; } -static MonoType* +ICALL_EXPORT MonoType* ves_icall_System_Reflection_Module_ResolveTypeToken (MonoImage *image, guint32 token, MonoArray *type_args, MonoArray *method_args, MonoResolveTokenError *error) { MonoClass *klass; @@ -5506,7 +5531,7 @@ ves_icall_System_Reflection_Module_ResolveTypeToken (MonoImage *image, guint32 t return NULL; } -static MonoMethod* +ICALL_EXPORT MonoMethod* ves_icall_System_Reflection_Module_ResolveMethodToken (MonoImage *image, guint32 token, MonoArray *type_args, MonoArray *method_args, MonoResolveTokenError *error) { int table = mono_metadata_token_table (token); @@ -5554,7 +5579,7 @@ ves_icall_System_Reflection_Module_ResolveMethodToken (MonoImage *image, guint32 return method; } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_System_Reflection_Module_ResolveStringToken (MonoImage *image, guint32 token, MonoResolveTokenError *error) { int index = mono_metadata_token_index (token); @@ -5580,7 +5605,7 @@ ves_icall_System_Reflection_Module_ResolveStringToken (MonoImage *image, guint32 return mono_ldstr (mono_domain_get (), image, index); } -static MonoClassField* +ICALL_EXPORT MonoClassField* ves_icall_System_Reflection_Module_ResolveFieldToken (MonoImage *image, guint32 token, MonoArray *type_args, MonoArray *method_args, MonoResolveTokenError *error) { MonoClass *klass; @@ -5629,7 +5654,7 @@ ves_icall_System_Reflection_Module_ResolveFieldToken (MonoImage *image, guint32 } -static MonoObject* +ICALL_EXPORT MonoObject* ves_icall_System_Reflection_Module_ResolveMemberToken (MonoImage *image, guint32 token, MonoArray *type_args, MonoArray *method_args, MonoResolveTokenError *error) { int table = mono_metadata_token_table (token); @@ -5685,7 +5710,7 @@ ves_icall_System_Reflection_Module_ResolveMemberToken (MonoImage *image, guint32 return NULL; } -static MonoArray* +ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Module_ResolveSignature (MonoImage *image, guint32 token, MonoResolveTokenError *error) { int table = mono_metadata_token_table (token); @@ -5717,7 +5742,7 @@ ves_icall_System_Reflection_Module_ResolveSignature (MonoImage *image, guint32 t return res; } -static MonoReflectionType* +ICALL_EXPORT MonoReflectionType* ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, MonoString *smodifiers) { MonoClass *klass; @@ -5777,7 +5802,7 @@ ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, Mon return mono_type_get_object (mono_object_domain (tb), &klass->byval_arg); } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_Type_IsArrayImpl (MonoReflectionType *t) { MonoType *type; @@ -5805,7 +5830,7 @@ check_for_invalid_type (MonoClass *klass) mono_raise_exception ((MonoException*)mono_get_exception_type_load (str, NULL)); } -static MonoReflectionType * +ICALL_EXPORT MonoReflectionType * ves_icall_Type_make_array_type (MonoReflectionType *type, int rank) { MonoClass *klass, *aklass; @@ -5823,7 +5848,7 @@ ves_icall_Type_make_array_type (MonoReflectionType *type, int rank) return mono_type_get_object (mono_object_domain (type), &aklass->byval_arg); } -static MonoReflectionType * +ICALL_EXPORT MonoReflectionType * ves_icall_Type_make_byref_type (MonoReflectionType *type) { MonoClass *klass; @@ -5837,7 +5862,7 @@ ves_icall_Type_make_byref_type (MonoReflectionType *type) return mono_type_get_object (mono_object_domain (type), &klass->this_arg); } -static MonoReflectionType * +ICALL_EXPORT MonoReflectionType * ves_icall_Type_MakePointerType (MonoReflectionType *type) { MonoClass *klass, *pklass; @@ -5851,7 +5876,7 @@ ves_icall_Type_MakePointerType (MonoReflectionType *type) return mono_type_get_object (mono_object_domain (type), &pklass->byval_arg); } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, MonoObject *target, MonoReflectionMethod *info, MonoBoolean throwOnBindFailure) { @@ -5888,7 +5913,7 @@ ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, Mon return delegate; } -static void +ICALL_EXPORT void ves_icall_System_Delegate_SetMulticastInvoke (MonoDelegate *this) { /* Reset the invoke impl to the default one */ @@ -5973,7 +5998,7 @@ gmt_offset(struct tm *tm, time_t t) * * Returns true on success and zero on failure. */ -static guint32 +ICALL_EXPORT guint32 ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names) { #ifndef HOST_WIN32 @@ -6051,8 +6076,19 @@ ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L); return 1; } else { + struct tm end; + time_t te; + + memset (&end, 0, sizeof (end)); + end.tm_year = year-1900 + 1; + end.tm_mday = 1; + + te = mktime (&end); + mono_array_setref ((*names), 1, mono_string_new (domain, tzone)); mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L); + mono_array_setref ((*names), 0, mono_string_new (domain, tzone)); + mono_array_set ((*data), gint64, 1, ((gint64)te + EPOCH_ADJUST) * 10000000L); is_daylight = 1; } @@ -6135,7 +6171,7 @@ ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray #endif } -static gpointer +ICALL_EXPORT gpointer ves_icall_System_Object_obj_address (MonoObject *this) { MONO_ARCH_SAVE_REGS; @@ -6187,7 +6223,7 @@ mono_array_get_byte_length (MonoArray *array) } } -static gint32 +ICALL_EXPORT gint32 ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) { MONO_ARCH_SAVE_REGS; @@ -6195,7 +6231,7 @@ ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) return mono_array_get_byte_length (array); } -static gint8 +ICALL_EXPORT gint8 ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx) { MONO_ARCH_SAVE_REGS; @@ -6203,7 +6239,7 @@ ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx) return mono_array_get (array, gint8, idx); } -static void +ICALL_EXPORT void ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value) { MONO_ARCH_SAVE_REGS; @@ -6211,7 +6247,7 @@ ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 val mono_array_set (array, gint8, idx, value); } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count) { guint8 *src_buf, *dest_buf; @@ -6228,12 +6264,12 @@ ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, Mo if (src != dest) memcpy (dest_buf, src_buf, count); else - memmove (dest_buf, src_buf, count); /* Source and dest are the same array */ + mono_gc_memmove (dest_buf, src_buf, count); /* Source and dest are the same array */ return TRUE; } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this, MonoString *class_name) { MonoDomain *domain = mono_object_domain (this); @@ -6259,7 +6295,7 @@ ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this, MonoString * return res; } -static MonoReflectionType * +ICALL_EXPORT MonoReflectionType * ves_icall_Remoting_RealProxy_InternalGetProxyType (MonoTransparentProxy *tp) { return mono_type_get_object (mono_object_domain (tp), &tp->remote_class->proxy_class->byval_arg); @@ -6277,7 +6313,7 @@ ves_icall_System_Environment_get_UserName (void) } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Environment_get_MachineName (void) { #if defined (HOST_WIN32) @@ -6309,7 +6345,7 @@ ves_icall_System_Environment_get_MachineName (void) #endif } -static int +ICALL_EXPORT int ves_icall_System_Environment_get_Platform (void) { #if defined (TARGET_WIN32) @@ -6331,7 +6367,7 @@ ves_icall_System_Environment_get_Platform (void) #endif } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Environment_get_NewLine (void) { MONO_ARCH_SAVE_REGS; @@ -6343,7 +6379,7 @@ ves_icall_System_Environment_get_NewLine (void) #endif } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name) { const gchar *value; @@ -6384,7 +6420,7 @@ char **environ; #endif #endif -static MonoArray * +ICALL_EXPORT MonoArray * ves_icall_System_Environment_GetEnvironmentVariableNames (void) { #ifdef HOST_WIN32 @@ -6476,7 +6512,7 @@ ves_icall_System_Environment_GetEnvironmentVariableNames (void) #define g_unsetenv(a) unsetenv(a) #endif -static void +ICALL_EXPORT void ves_icall_System_Environment_InternalSetEnvironmentVariable (MonoString *name, MonoString *value) { MonoError error; @@ -6524,7 +6560,7 @@ ves_icall_System_Environment_InternalSetEnvironmentVariable (MonoString *name, M #endif } -static void +ICALL_EXPORT void ves_icall_System_Environment_Exit (int result) { MONO_ARCH_SAVE_REGS; @@ -6545,13 +6581,13 @@ ves_icall_System_Environment_Exit (int result) exit (result); } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_System_Environment_GetGacPath (void) { return mono_string_new (mono_domain_get (), mono_assembly_getrootdir ()); } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_System_Environment_GetWindowsFolderPath (int folder) { #if defined (HOST_WIN32) @@ -6573,7 +6609,7 @@ ves_icall_System_Environment_GetWindowsFolderPath (int folder) return mono_string_new (mono_domain_get (), ""); } -static MonoArray * +ICALL_EXPORT MonoArray * ves_icall_System_Environment_GetLogicalDrives (void) { gunichar2 buf [256], *ptr, *dname; @@ -6627,7 +6663,7 @@ ves_icall_System_Environment_GetLogicalDrives (void) return result; } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_IO_DriveInfo_GetDriveFormat (MonoString *path) { gunichar2 volume_name [MAX_PATH + 1]; @@ -6637,7 +6673,7 @@ ves_icall_System_IO_DriveInfo_GetDriveFormat (MonoString *path) return mono_string_from_utf16 (volume_name); } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Environment_InternalGetHome (void) { MONO_ARCH_SAVE_REGS; @@ -6672,7 +6708,7 @@ static const char *encodings [] = { * 1 at entry, and we can not compute a suitable code page number, * returns the code page as a string */ -static MonoString* +ICALL_EXPORT MonoString* ves_icall_System_Text_Encoding_InternalCodePage (gint32 *int_code_page) { const char *cset; @@ -6722,7 +6758,7 @@ ves_icall_System_Text_Encoding_InternalCodePage (gint32 *int_code_page) return NULL; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_Environment_get_HasShutdownStarted (void) { if (mono_runtime_is_shutting_down ()) @@ -6734,7 +6770,7 @@ ves_icall_System_Environment_get_HasShutdownStarted (void) return FALSE; } -static void +ICALL_EXPORT void ves_icall_System_Environment_BroadcastSettingChange (void) { #ifdef HOST_WIN32 @@ -6742,7 +6778,7 @@ ves_icall_System_Environment_BroadcastSettingChange (void) #endif } -static void +ICALL_EXPORT void ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this, MonoReflectionMethod *method, MonoArray *out_args) @@ -6752,7 +6788,7 @@ ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this, mono_message_init (mono_object_domain (this), this, method, out_args); } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_IsTransparentProxy (MonoObject *proxy) { MONO_ARCH_SAVE_REGS; @@ -6766,7 +6802,7 @@ ves_icall_IsTransparentProxy (MonoObject *proxy) return 0; } -static MonoReflectionMethod * +ICALL_EXPORT MonoReflectionMethod * ves_icall_Remoting_RemotingServices_GetVirtualMethod ( MonoReflectionType *rtype, MonoReflectionMethod *rmethod) { @@ -6818,7 +6854,7 @@ ves_icall_Remoting_RemotingServices_GetVirtualMethod ( return mono_method_get_object (mono_domain_get (), res, NULL); } -static void +ICALL_EXPORT void ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionType *type, MonoBoolean enable) { MonoClass *klass; @@ -6833,7 +6869,7 @@ ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (Mo else vtable->remote = 0; } -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionType *type) { MonoClass *klass; @@ -6857,7 +6893,7 @@ ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClas } } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_IO_get_temp_path (void) { MONO_ARCH_SAVE_REGS; @@ -6866,7 +6902,7 @@ ves_icall_System_IO_get_temp_path (void) } #ifndef PLATFORM_NO_DRIVEINFO -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_IO_DriveInfo_GetDiskFreeSpace (MonoString *path_name, guint64 *free_bytes_avail, guint64 *total_number_of_bytes, guint64 *total_number_of_free_bytes, gint32 *error) @@ -6896,7 +6932,7 @@ ves_icall_System_IO_DriveInfo_GetDiskFreeSpace (MonoString *path_name, guint64 * return result; } -static guint32 +ICALL_EXPORT guint32 ves_icall_System_IO_DriveInfo_GetDriveType (MonoString *root_path_name) { MONO_ARCH_SAVE_REGS; @@ -6905,7 +6941,7 @@ ves_icall_System_IO_DriveInfo_GetDriveType (MonoString *root_path_name) } #endif -static gpointer +ICALL_EXPORT gpointer ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod *method) { MONO_ARCH_SAVE_REGS; @@ -6913,7 +6949,7 @@ ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod *method) return mono_compile_method (method); } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void) { MonoString *mcpath; @@ -6992,7 +7028,7 @@ get_bundled_machine_config (void) return mono_string_new (mono_domain_get (), machine_config); } -static MonoString * +ICALL_EXPORT MonoString * ves_icall_System_Web_Util_ICalls_get_machine_install_dir (void) { MonoString *ipath; @@ -7017,7 +7053,7 @@ ves_icall_System_Web_Util_ICalls_get_machine_install_dir (void) return ipath; } -static gboolean +ICALL_EXPORT gboolean ves_icall_get_resources_ptr (MonoReflectionAssembly *assembly, gpointer *result, gint32 *size) { MonoPEResourceDataEntry *entry; @@ -7045,13 +7081,29 @@ ves_icall_get_resources_ptr (MonoReflectionAssembly *assembly, gpointer *result, return TRUE; } -static MonoBoolean +ICALL_EXPORT MonoBoolean ves_icall_System_Diagnostics_Debugger_IsAttached_internal (void) { return mono_debug_using_mono_debugger () || mono_is_debugger_attached (); } -static void +ICALL_EXPORT MonoBoolean +ves_icall_System_Diagnostics_Debugger_IsLogging (void) +{ + if (mono_get_runtime_callbacks ()->debug_log_is_enabled) + return mono_get_runtime_callbacks ()->debug_log_is_enabled (); + else + return FALSE; +} + +ICALL_EXPORT void +ves_icall_System_Diagnostics_Debugger_Log (int level, MonoString *category, MonoString *message) +{ + if (mono_get_runtime_callbacks ()->debug_log) + mono_get_runtime_callbacks ()->debug_log (level, category, message); +} + +ICALL_EXPORT void ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (MonoString *message) { #if defined (HOST_WIN32) @@ -7062,7 +7114,7 @@ ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (MonoS } /* Only used for value types */ -static MonoObject * +ICALL_EXPORT MonoObject * ves_icall_System_Activator_CreateInstanceInternal (MonoReflectionType *type) { MonoClass *klass; @@ -7081,7 +7133,7 @@ ves_icall_System_Activator_CreateInstanceInternal (MonoReflectionType *type) return mono_object_new (domain, klass); } -static MonoReflectionMethod * +ICALL_EXPORT MonoReflectionMethod * ves_icall_MonoMethod_get_base_method (MonoReflectionMethod *m, gboolean definition) { MonoClass *klass, *parent; @@ -7147,7 +7199,7 @@ ves_icall_MonoMethod_get_base_method (MonoReflectionMethod *m, gboolean definiti return mono_method_get_object (mono_domain_get (), result, NULL); } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_MonoMethod_get_name (MonoReflectionMethod *m) { MonoMethod *method = m->method; @@ -7156,7 +7208,7 @@ ves_icall_MonoMethod_get_name (MonoReflectionMethod *m) return m->name; } -static void +ICALL_EXPORT void mono_ArgIterator_Setup (MonoArgIterator *iter, char* argsp, char* start) { MONO_ARCH_SAVE_REGS; @@ -7178,7 +7230,7 @@ mono_ArgIterator_Setup (MonoArgIterator *iter, char* argsp, char* start) /* g_print ("sig %p, param_count: %d, sent: %d\n", iter->sig, iter->sig->param_count, iter->sig->sentinelpos); */ } -static MonoTypedRef +ICALL_EXPORT MonoTypedRef mono_ArgIterator_IntGetNextArg (MonoArgIterator *iter) { guint32 i, arg_size; @@ -7193,7 +7245,7 @@ mono_ArgIterator_IntGetNextArg (MonoArgIterator *iter) res.type = iter->sig->params [i]; res.klass = mono_class_from_mono_type (res.type); arg_size = mono_type_stack_size (res.type, &align); -#if defined(__arm__) +#if defined(__arm__) || defined(__mips__) iter->args = (guint8*)(((gsize)iter->args + (align) - 1) & ~(align - 1)); #endif res.value = iter->args; @@ -7212,7 +7264,7 @@ mono_ArgIterator_IntGetNextArg (MonoArgIterator *iter) return res; } -static MonoTypedRef +ICALL_EXPORT MonoTypedRef mono_ArgIterator_IntGetNextArgT (MonoArgIterator *iter, MonoType *type) { guint32 i, arg_size; @@ -7231,7 +7283,7 @@ mono_ArgIterator_IntGetNextArgT (MonoArgIterator *iter, MonoType *type) res.klass = mono_class_from_mono_type (res.type); /* FIXME: endianess issue... */ arg_size = mono_type_stack_size (res.type, &align); -#if defined(__arm__) +#if defined(__arm__) || defined(__mips__) iter->args = (guint8*)(((gsize)iter->args + (align) - 1) & ~(align - 1)); #endif res.value = iter->args; @@ -7248,7 +7300,7 @@ mono_ArgIterator_IntGetNextArgT (MonoArgIterator *iter, MonoType *type) return res; } -static MonoType* +ICALL_EXPORT MonoType* mono_ArgIterator_IntGetNextArgType (MonoArgIterator *iter) { gint i; @@ -7261,7 +7313,7 @@ mono_ArgIterator_IntGetNextArgType (MonoArgIterator *iter) return iter->sig->params [i]; } -static MonoObject* +ICALL_EXPORT MonoObject* mono_TypedReference_ToObject (MonoTypedRef tref) { MONO_ARCH_SAVE_REGS; @@ -7274,7 +7326,7 @@ mono_TypedReference_ToObject (MonoTypedRef tref) return mono_value_box (mono_domain_get (), tref.klass, tref.value); } -static MonoObject* +ICALL_EXPORT MonoObject* mono_TypedReference_ToObjectInternal (MonoType *type, gpointer value, MonoClass *klass) { MONO_ARCH_SAVE_REGS; @@ -7301,14 +7353,14 @@ prelink_method (MonoMethod *method) /* create the wrapper, too? */ } -static void +ICALL_EXPORT void ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethod *method) { MONO_ARCH_SAVE_REGS; prelink_method (method->method); } -static void +ICALL_EXPORT void ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType *type) { MonoClass *klass = mono_class_from_mono_type (type->type); @@ -7323,7 +7375,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType } /* These parameters are "readonly" in corlib/System/NumberFormatter.cs */ -static void +ICALL_EXPORT void ves_icall_System_NumberFormatter_GetFormatterTables (guint64 const **mantissas, gint32 const **exponents, gunichar2 const **digitLowerTable, @@ -7339,9 +7391,34 @@ ves_icall_System_NumberFormatter_GetFormatterTables (guint64 const **mantissas, *decHexDigits = Formatter_DecHexDigits; } +ICALL_EXPORT void +get_category_data (int version, + guint8 const **category_data, + guint16 const **category_astral_index) +{ + *category_astral_index = NULL; + +#ifndef DISABLE_NET_4_0 + if (version == 4) { + *category_data = CategoryData_v4; +#ifndef DISABLE_ASTRAL + *category_astral_index = CategoryData_v4_astral_index; +#endif + return; + } +#endif + + *category_data = CategoryData_v2; +#ifndef DISABLE_ASTRAL + *category_astral_index = CategoryData_v2_astral_index; +#endif +} + /* These parameters are "readonly" in corlib/System/Char.cs */ -static void -ves_icall_System_Char_GetDataTablePointers (guint8 const **category_data, +ICALL_EXPORT void +ves_icall_System_Char_GetDataTablePointers (int category_data_version, + guint8 const **category_data, + guint16 const **category_astral_index, guint8 const **numeric_data, gdouble const **numeric_data_values, guint16 const **to_lower_data_low, @@ -7349,7 +7426,7 @@ ves_icall_System_Char_GetDataTablePointers (guint8 const **category_data, guint16 const **to_upper_data_low, guint16 const **to_upper_data_high) { - *category_data = CategoryData; + get_category_data (category_data_version, category_data, category_astral_index); *numeric_data = NumericData; *numeric_data_values = NumericDataValues; *to_lower_data_low = ToLowerDataLow; @@ -7358,7 +7435,7 @@ ves_icall_System_Char_GetDataTablePointers (guint8 const **category_data, *to_upper_data_high = ToUpperDataHigh; } -static gint32 +ICALL_EXPORT gint32 ves_icall_MonoDebugger_GetMethodToken (MonoReflectionMethod *method) { return method->method->token; @@ -7391,7 +7468,7 @@ type_array_from_modifiers (MonoImage *image, MonoType *type, int optional) return res; } -static MonoArray* +ICALL_EXPORT MonoArray* param_info_get_type_modifiers (MonoReflectionParameter *param, MonoBoolean optional) { MonoType *type = param->ClassImpl->type; @@ -7443,7 +7520,7 @@ get_property_type (MonoProperty *prop) return NULL; } -static MonoArray* +ICALL_EXPORT MonoArray* property_info_get_type_modifiers (MonoReflectionProperty *property, MonoBoolean optional) { MonoType *type = get_property_type (property->property); @@ -7476,7 +7553,7 @@ mono_type_from_blob_type (MonoType *type, MonoTypeEnum blob_type, MonoType *real type->data.klass = mono_class_from_mono_type (real_type); } -static MonoObject* +ICALL_EXPORT MonoObject* property_info_get_default_value (MonoReflectionProperty *property) { MonoType blob_type; @@ -7500,7 +7577,7 @@ property_info_get_default_value (MonoReflectionProperty *property) return o; } -static MonoBoolean +ICALL_EXPORT MonoBoolean custom_attrs_defined_internal (MonoObject *obj, MonoReflectionType *attr_type) { MonoClass *attr_class = mono_class_from_mono_type (attr_type->type); @@ -7518,7 +7595,7 @@ custom_attrs_defined_internal (MonoObject *obj, MonoReflectionType *attr_type) return found; } -static MonoArray* +ICALL_EXPORT MonoArray* custom_attrs_get_by_type (MonoObject *obj, MonoReflectionType *attr_type) { MonoClass *attr_class = attr_type ? mono_class_from_mono_type (attr_type->type) : NULL; @@ -7541,7 +7618,7 @@ custom_attrs_get_by_type (MonoObject *obj, MonoReflectionType *attr_type) } } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_Mono_Runtime_GetDisplayName (void) { char *info; @@ -7553,7 +7630,7 @@ ves_icall_Mono_Runtime_GetDisplayName (void) return display_name; } -static MonoString* +ICALL_EXPORT MonoString* ves_icall_System_ComponentModel_Win32Exception_W32ErrorMessage (guint32 code) { MonoString *message; @@ -7597,6 +7674,7 @@ base64_to_byte_array (gunichar2 *start, gint ilength, MonoBoolean allowWhitespac gint a [4], b [4]; MonoException *exc; + int havePadding = 0; ignored = 0; last = prev_last = 0, prev2_last = 0; for (i = 0; i < ilength; i++) { @@ -7608,7 +7686,13 @@ base64_to_byte_array (gunichar2 *start, gint ilength, MonoBoolean allowWhitespac mono_raise_exception (exc); } else if (isspace (c)) { ignored++; + } else if (havePadding && c != '=') { + exc = mono_exception_from_name_msg (mono_get_corlib (), + "System", "FormatException", + "Invalid character found."); + mono_raise_exception (exc); } else { + if (c == '=') havePadding = 1; prev2_last = prev_last; prev_last = last; last = c; @@ -7672,7 +7756,7 @@ base64_to_byte_array (gunichar2 *start, gint ilength, MonoBoolean allowWhitespac return result; } -static MonoArray * +ICALL_EXPORT MonoArray * InternalFromBase64String (MonoString *str, MonoBoolean allowWhitespaceOnly) { MONO_ARCH_SAVE_REGS; @@ -7681,7 +7765,7 @@ InternalFromBase64String (MonoString *str, MonoBoolean allowWhitespaceOnly) mono_string_length (str), allowWhitespaceOnly); } -static MonoArray * +ICALL_EXPORT MonoArray * InternalFromBase64CharArray (MonoArray *input, gint offset, gint length) { MONO_ARCH_SAVE_REGS; @@ -7690,6 +7774,8 @@ InternalFromBase64CharArray (MonoArray *input, gint offset, gint length) length, FALSE); } +#ifndef DISABLE_ICALL_TABLES + #define ICALL_TYPE(id,name,first) #define ICALL(id,name,func) Icall_ ## id, @@ -7804,6 +7890,20 @@ icall_functions [] = { NULL }; +#ifdef ENABLE_ICALL_SYMBOL_MAP +#undef ICALL_TYPE +#undef ICALL +#define ICALL_TYPE(id,name,first) +#define ICALL(id,name,func) #func, +static const gconstpointer +icall_symbols [] = { +#include "metadata/icall-def.h" + NULL +}; +#endif + +#endif /* DISABLE_ICALL_TABLES */ + static GHashTable *icall_hash = NULL; static GHashTable *jit_icall_hash_name = NULL; static GHashTable *jit_icall_hash_addr = NULL; @@ -7811,6 +7911,7 @@ static GHashTable *jit_icall_hash_addr = NULL; void mono_icall_init (void) { +#ifndef DISABLE_ICALL_TABLES int i = 0; /* check that tables are sorted: disable in release */ @@ -7837,6 +7938,7 @@ mono_icall_init (void) } } } +#endif icall_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); } @@ -7859,6 +7961,8 @@ mono_add_internal_call (const char *name, gconstpointer method) mono_loader_unlock (); } +#ifndef DISABLE_ICALL_TABLES + #ifdef HAVE_ARRAY_ELEM_INIT static int compare_method_imap (const void *key, const void *elem) @@ -7892,7 +7996,8 @@ find_class_icalls (const char *name) return &icall_type_descs [nameslot - &icall_type_names_idx [0]]; } -#else +#else /* HAVE_ARRAY_ELEM_INIT */ + static int compare_method_imap (const void *key, const void *elem) { @@ -7925,7 +8030,9 @@ find_class_icalls (const char *name) return &icall_type_descs [nameslot - icall_type_names]; } -#endif +#endif /* HAVE_ARRAY_ELEM_INIT */ + +#endif /* DISABLE_ICALL_TABLES */ /* * we should probably export this as an helper (handle nested types). @@ -7948,6 +8055,14 @@ concat_class_name (char *buf, int bufsize, MonoClass *klass) return nspacelen + cnamelen; } +#ifdef DISABLE_ICALL_TABLES +static void +no_icall_table (void) +{ + g_assert_not_reached (); +} +#endif + gpointer mono_lookup_internal_call (MonoMethod *method) { @@ -7956,7 +8071,9 @@ mono_lookup_internal_call (MonoMethod *method) char mname [2048]; int typelen = 0, mlen, siglen; gpointer res; - const IcallTypeDesc *imap; +#ifndef DISABLE_ICALL_TABLES + const IcallTypeDesc *imap = NULL; +#endif g_assert (method != NULL); @@ -7982,7 +8099,9 @@ mono_lookup_internal_call (MonoMethod *method) return NULL; } +#ifndef DISABLE_ICALL_TABLES imap = find_class_icalls (mname); +#endif mname [typelen] = ':'; mname [typelen + 1] = ':'; @@ -8017,6 +8136,15 @@ mono_lookup_internal_call (MonoMethod *method) return res; } +#ifdef DISABLE_ICALL_TABLES + mono_loader_unlock (); + /* Fail only when the result is actually used */ + /* mono_marshal_get_native_wrapper () depends on this */ + if (method->klass == mono_defaults.string_class && !strcmp (method->name, ".ctor")) + return ves_icall_System_String_ctor_RedirectToCreateString; + else + return no_icall_table; +#else /* it wasn't found in the static call tables */ if (!imap) { mono_loader_unlock (); @@ -8046,6 +8174,78 @@ mono_lookup_internal_call (MonoMethod *method) mono_loader_unlock (); return NULL; +#endif +} + +#ifdef ENABLE_ICALL_SYMBOL_MAP +static int +func_cmp (gconstpointer key, gconstpointer p) +{ + return (gsize)key - (gsize)*(gsize*)p; +} +#endif + +/* + * mono_lookup_icall_symbol: + * + * Given the icall METHOD, returns its C symbol. + */ +const char* +mono_lookup_icall_symbol (MonoMethod *m) +{ +#ifdef DISABLE_ICALL_TABLES + g_assert_not_reached (); + return NULL; +#else +#ifdef ENABLE_ICALL_SYMBOL_MAP + gpointer func; + int i; + gpointer slot; + static gconstpointer *functions_sorted; + static const char**symbols_sorted; + static gboolean inited; + + if (!inited) { + gboolean changed; + + functions_sorted = g_malloc (G_N_ELEMENTS (icall_functions) * sizeof (gpointer)); + memcpy (functions_sorted, icall_functions, G_N_ELEMENTS (icall_functions) * sizeof (gpointer)); + symbols_sorted = g_malloc (G_N_ELEMENTS (icall_functions) * sizeof (gpointer)); + memcpy (symbols_sorted, icall_symbols, G_N_ELEMENTS (icall_functions) * sizeof (gpointer)); + /* Bubble sort the two arrays */ + changed = TRUE; + while (changed) { + changed = FALSE; + for (i = 0; i < G_N_ELEMENTS (icall_functions) - 1; ++i) { + if (functions_sorted [i] > functions_sorted [i + 1]) { + gconstpointer tmp; + + tmp = functions_sorted [i]; + functions_sorted [i] = functions_sorted [i + 1]; + functions_sorted [i + 1] = tmp; + tmp = symbols_sorted [i]; + symbols_sorted [i] = symbols_sorted [i + 1]; + symbols_sorted [i + 1] = tmp; + changed = TRUE; + } + } + } + } + + func = mono_lookup_internal_call (m); + if (!func) + return NULL; + slot = bsearch (func, functions_sorted, G_N_ELEMENTS (icall_functions), sizeof (gpointer), func_cmp); + if (!slot) + return NULL; + g_assert (slot); + return symbols_sorted [(gpointer*)slot - (gpointer*)functions_sorted]; +#else + fprintf (stderr, "icall symbol maps not enabled, pass --enable-icall-symbol-map to configure.\n"); + g_assert_not_reached (); + return 0; +#endif +#endif } static MonoType*