diff --git a/runtime/delegates.t4 b/runtime/delegates.t4 index 7fb794bf8ce4..50ab0d2248e7 100644 --- a/runtime/delegates.t4 +++ b/runtime/delegates.t4 @@ -52,7 +52,7 @@ new XDelegate ("MonoObject *", "IntPtr", "xamarin_get_block_wrapper_creator", "MonoObject *", "IntPtr", "method", - "unsigned long", "uint", "parameter" + "int", "int", "parameter" ) { WrappedManagedFunction = "GetBlockWrapperCreator", OnlyDynamicUsage = true, @@ -203,7 +203,7 @@ new XDelegate ("bool", "bool", "xamarin_is_parameter_out", "MonoReflectionMethod *", "IntPtr", "method", - "unsigned long", "uint", "parameter" + "int", "int", "parameter" ) { WrappedManagedFunction = "IsParameterOut", OnlyDynamicUsage = true, diff --git a/runtime/monotouch-debug.h b/runtime/monotouch-debug.h index 4ef8a4b04135..80c2bd031a29 100644 --- a/runtime/monotouch-debug.h +++ b/runtime/monotouch-debug.h @@ -23,7 +23,7 @@ void monotouch_start_debugging (); void monotouch_start_profiling (); void monotouch_set_connection_mode (const char *mode); -void monotouch_set_monodevelop_port (long port); +void monotouch_set_monodevelop_port (int port); typedef struct { diff --git a/runtime/monotouch-debug.m b/runtime/monotouch-debug.m index 6442732857a8..8d4d7f741d6a 100644 --- a/runtime/monotouch-debug.m +++ b/runtime/monotouch-debug.m @@ -381,9 +381,9 @@ -(void) URLSession: (NSURLSession *) session task: (NSURLSessionTask *) task did } void -monotouch_set_monodevelop_port (long port) +monotouch_set_monodevelop_port (int port) { - monodevelop_port = port; + monodevelop_port = (long) port; } void diff --git a/runtime/monotouch-main.m b/runtime/monotouch-main.m index 879e773445fa..d4d2947f1b03 100644 --- a/runtime/monotouch-main.m +++ b/runtime/monotouch-main.m @@ -340,7 +340,7 @@ - (void) memoryWarning: (NSNotification *) sender if (!value && argc > i + 1) value = argv [++i]; if (value) { - monotouch_set_monodevelop_port (strtol (value, NULL, 10)); + monotouch_set_monodevelop_port ((int) strtol (value, NULL, 10)); } else { PRINT ("MonoTouch: --%s requires an argument.", name); } diff --git a/runtime/monotouch-support.h b/runtime/monotouch-support.h index 286b31dd578f..094073a4f382 100644 --- a/runtime/monotouch-support.h +++ b/runtime/monotouch-support.h @@ -9,8 +9,8 @@ extern "C" { const char * xamarin_get_locale_country_code (); void xamarin_log (const unsigned short *unicodeMessage); -void * xamarin_timezone_get_data (const char *name, unsigned long *size); -char ** xamarin_timezone_get_names (unsigned long *count); +void * xamarin_timezone_get_data (const char *name, uint32_t *size); +char ** xamarin_timezone_get_names (uint32_t *count); char * xamarin_timezone_get_local_name (); void xamarin_start_wwan (const char *uri); void xamarin_os_log (os_log_t logger, os_log_type_t type, const char *message); diff --git a/runtime/runtime.m b/runtime/runtime.m index 843ae4dd0954..f230e06cf156 100644 --- a/runtime/runtime.m +++ b/runtime/runtime.m @@ -2066,7 +2066,7 @@ -(void) xamarinSetGCHandle: (uint32_t) gc_handle; typedef struct { MonoMethod *method; - unsigned long par; + int par; } MethodAndPar; static gboolean @@ -2094,7 +2094,7 @@ -(void) xamarinSetGCHandle: (uint32_t) gc_handle; * create the method */ static MonoObject * -get_method_block_wrapper_creator (MonoMethod *method, unsigned long par, guint32 *exception_gchandle) +get_method_block_wrapper_creator (MonoMethod *method, int par, guint32 *exception_gchandle) { // COOP: accesses managed memory: unsafe mode. MONO_ASSERT_GC_UNSAFE; @@ -2120,7 +2120,7 @@ -(void) xamarinSetGCHandle: (uint32_t) gc_handle; return res; } - res = xamarin_get_block_wrapper_creator ((MonoObject *) mono_method_get_object (mono_domain_get (), method, NULL), par, exception_gchandle); + res = xamarin_get_block_wrapper_creator ((MonoObject *) mono_method_get_object (mono_domain_get (), method, NULL), (int) par, exception_gchandle); if (*exception_gchandle != 0) return NULL; // PRINT ("New value: %x", (int) res); @@ -2162,7 +2162,7 @@ -(void) xamarinSetGCHandle: (uint32_t) gc_handle; * Returns: the instantiated delegate. */ int * -xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, unsigned long par, void *nativeBlock, guint32 *exception_gchandle) +xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, int par, void *nativeBlock, guint32 *exception_gchandle) { // COOP: accesses managed memory: unsafe mode. MONO_ASSERT_GC_UNSAFE; diff --git a/runtime/trampolines-arm64.m b/runtime/trampolines-arm64.m index 5916c99d26d3..e53b17c77304 100644 --- a/runtime/trampolines-arm64.m +++ b/runtime/trampolines-arm64.m @@ -40,7 +40,7 @@ #define dump_state(...) #endif -static size_t +static int param_read_primitive (struct ParamIterator *it, const char *type_ptr, void *target, size_t total_size, guint32 *exception_gchandle) { // COOP: does not access managed memory: any mode. @@ -105,7 +105,7 @@ if (target == NULL) { LOGZ (" not reading, since target is NULL.\n"); - return size; + return (int) size; } switch (size) { @@ -130,7 +130,7 @@ return 0; } - return size; + return (int) size; } } } @@ -182,7 +182,7 @@ const char *t = struct_name; uint8_t *targ = (uint8_t *) target; do { - size_t c = param_read_primitive (it, t, targ, size, exception_gchandle); + int c = param_read_primitive (it, t, targ, size, exception_gchandle); if (*exception_gchandle != 0) return; if (targ != NULL) @@ -230,7 +230,7 @@ (size == 8 && !strncmp (struct_name, "d", 1))) { LOGZ (" marshalling as %i doubles (struct name: %s)\n", (int) size / 8, struct_name); double* ptr = (double *) mono_object_unbox (value); - for (unsigned long i = 0; i < size / 8; i++) { + for (int i = 0; i < size / 8; i++) { LOGZ (" #%i: %f\n", i, ptr [i]); it->q [i].d = ptr [i]; } @@ -240,7 +240,7 @@ (size == 4 && !strncmp (struct_name, "f", 1))) { LOGZ (" marshalling as %i floats (struct name: %s)\n", (int) size / 4, struct_name); float* ptr = (float *) mono_object_unbox (value); - for (unsigned long i = 0; i < size / 4; i++) { + for (int i = 0; i < size / 4; i++) { LOGZ (" #%i: %f\n", i, ptr [i]); it->q [i].f.f1 = ptr [i]; } diff --git a/runtime/trampolines-internal.h b/runtime/trampolines-internal.h index 7bac5ca1c4f2..67c8562d708d 100644 --- a/runtime/trampolines-internal.h +++ b/runtime/trampolines-internal.h @@ -48,7 +48,7 @@ typedef void (*marshal_return_value_func) (void *context, const char *type, size void xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_func iterator, marshal_return_value_func marshal_return_value, void *context); -unsigned long xamarin_get_frame_length (id self, SEL sel); +int xamarin_get_frame_length (id self, SEL sel); const char * xamarin_skip_type_name (const char *ptr); #ifdef __cplusplus diff --git a/runtime/trampolines-invoke.m b/runtime/trampolines-invoke.m index ea5079114f4c..8b76f9947915 100644 --- a/runtime/trampolines-invoke.m +++ b/runtime/trampolines-invoke.m @@ -26,7 +26,7 @@ } guint32 -xamarin_get_exception_for_parameter (int code, guint32 inner_exception_gchandle, const char *reason, SEL sel, MonoMethod *method, MonoType *p, unsigned long i, bool to_managed) +xamarin_get_exception_for_parameter (int code, guint32 inner_exception_gchandle, const char *reason, SEL sel, MonoMethod *method, MonoType *p, int i, bool to_managed) { guint32 exception_gchandle = 0; char *to_name = xamarin_type_get_full_name (p, &exception_gchandle); @@ -246,7 +246,7 @@ exception = (MonoObject *) mono_get_exception_execution_engine ("Invalid type encoding for parameter"); goto exception_handling; } - bool is_parameter_out = xamarin_is_parameter_out (mono_method_get_object (domain, method, NULL), i, &exception_gchandle); + bool is_parameter_out = xamarin_is_parameter_out (mono_method_get_object (domain, method, NULL), (int) i, &exception_gchandle); if (exception_gchandle != 0) goto exception_handling; @@ -272,7 +272,7 @@ } else if (xamarin_is_class_nsobject (p_klass)) { arg_frame [ofs] = xamarin_get_nsobject_with_type_for_ptr (*(NSObject **) arg, false, p, &exception_gchandle); if (exception_gchandle != 0) { - exception_gchandle = xamarin_get_exception_for_parameter (8029, exception_gchandle, "Unable to marshal the byref parameter", sel, method, p, i, true); + exception_gchandle = xamarin_get_exception_for_parameter (8029, exception_gchandle, "Unable to marshal the byref parameter", sel, method, p, (int) i, true); goto exception_handling; } LOGZ (" argument %i is a ref NSObject parameter: %p = %p\n", i + 1, arg, arg_frame [ofs]); @@ -287,12 +287,12 @@ } else if (xamarin_is_class_array (p_klass)) { arg_frame [ofs] = xamarin_nsarray_to_managed_array (*(NSArray **) arg, p, p_klass, &exception_gchandle); if (exception_gchandle != 0) { - exception_gchandle = xamarin_get_exception_for_parameter (8029, exception_gchandle, "Unable to marshal the byref parameter", sel, method, p, i, true); + exception_gchandle = xamarin_get_exception_for_parameter (8029, exception_gchandle, "Unable to marshal the byref parameter", sel, method, p, (int) i, true); goto exception_handling; } LOGZ (" argument %i is ref NSArray (%p => %p => %p)\n", i + 1, arg, *(NSArray **) arg, arg_frame [ofs]); } else { - exception_gchandle = xamarin_get_exception_for_parameter (8029, 0, "Unable to marshal the byref parameter", sel, method, p, i, true); + exception_gchandle = xamarin_get_exception_for_parameter (8029, 0, "Unable to marshal the byref parameter", sel, method, p, (int) i, true); goto exception_handling; } arg_copy [i + mofs] = arg_frame [ofs]; @@ -311,7 +311,7 @@ default: { MonoClass *p_klass = mono_class_from_mono_type (p); if (mono_class_is_delegate (p_klass)) { - arg_ptrs [i + mofs] = xamarin_get_delegate_for_block_parameter (method, INVALID_TOKEN_REF, i, arg, &exception_gchandle); + arg_ptrs [i + mofs] = xamarin_get_delegate_for_block_parameter (method, INVALID_TOKEN_REF, (int) i, arg, &exception_gchandle); if (exception_gchandle != 0) goto exception_handling; } else if (xamarin_is_class_inativeobject (p_klass)) { @@ -397,7 +397,7 @@ } else if (xamarin_is_class_array (p_klass)) { arg_ptrs [i + mofs] = xamarin_nsarray_to_managed_array ((NSArray *) id_arg, p, p_klass, &exception_gchandle); if (exception_gchandle != 0) { - exception_gchandle = xamarin_get_exception_for_parameter (8029, exception_gchandle, "Unable to marshal the array parameter", sel, method, p, i, true); + exception_gchandle = xamarin_get_exception_for_parameter (8029, exception_gchandle, "Unable to marshal the array parameter", sel, method, p, (int) i, true); goto exception_handling; } LOGZ (" argument %i is NSArray\n", i + 1); @@ -410,7 +410,7 @@ int32_t created = false; obj = xamarin_get_nsobject_with_type_for_ptr_created (id_arg, false, p, &created, &exception_gchandle); if (exception_gchandle != 0) { - exception_gchandle = xamarin_get_exception_for_parameter (8029, exception_gchandle, "Unable to marshal the parameter", sel, method, p, i, true); + exception_gchandle = xamarin_get_exception_for_parameter (8029, exception_gchandle, "Unable to marshal the parameter", sel, method, p, (int) i, true); goto exception_handling; } @@ -438,7 +438,7 @@ LOGZ (" argument %i is NSObject/INativeObject %p: %p\n", i + 1, id_arg, obj); arg_ptrs [i + mofs] = obj; } else if (mono_class_is_delegate (p_klass)) { - arg_ptrs [i + mofs] = xamarin_get_delegate_for_block_parameter (method, INVALID_TOKEN_REF, i, id_arg, &exception_gchandle); + arg_ptrs [i + mofs] = xamarin_get_delegate_for_block_parameter (method, INVALID_TOKEN_REF, (int) i, id_arg, &exception_gchandle); if (exception_gchandle != 0) goto exception_handling; } else { @@ -598,17 +598,17 @@ } else if (xamarin_is_class_array (p_klass)) { obj = xamarin_managed_array_to_nsarray ((MonoArray *) value, p, p_klass, &exception_gchandle); if (exception_gchandle != 0) { - exception_gchandle = xamarin_get_exception_for_parameter (8030, exception_gchandle, "Unable to marshal the out/ref parameter", sel, method, p, i, false); + exception_gchandle = xamarin_get_exception_for_parameter (8030, exception_gchandle, "Unable to marshal the out/ref parameter", sel, method, p, (int) i, false); goto exception_handling; } LOGZ (" writing back managed array %p to argument at index %i (%p)\n", value, i + 1, arg); } else { - exception_gchandle = xamarin_get_exception_for_parameter (8030, 0, "Unable to marshal the out/ref parameter", sel, method, p, i, false); + exception_gchandle = xamarin_get_exception_for_parameter (8030, 0, "Unable to marshal the out/ref parameter", sel, method, p, (int) i, false); goto exception_handling; } *(NSObject **) arg = obj; } else { - exception_gchandle = xamarin_get_exception_for_parameter (8030, 0, "Unable to marshal the out/ref parameter", sel, method, p, i, false); + exception_gchandle = xamarin_get_exception_for_parameter (8030, 0, "Unable to marshal the out/ref parameter", sel, method, p, (int) i, false); goto exception_handling; } } diff --git a/runtime/trampolines.m b/runtime/trampolines.m index 19a679a802b5..b64a82e01f03 100644 --- a/runtime/trampolines.m +++ b/runtime/trampolines.m @@ -449,7 +449,7 @@ return true; } -unsigned long +int xamarin_get_frame_length (id self, SEL sel) { if (self == NULL) @@ -516,7 +516,7 @@ // we can't detect varargs, so just add 16 more pointer sized arguments to be on the safe-ish side. length += sizeof (void *) * 16; - return length; + return (int) length; } static inline void diff --git a/runtime/xamarin-support.m b/runtime/xamarin-support.m index 21a3019707ed..8e1330e89373 100644 --- a/runtime/xamarin-support.m +++ b/runtime/xamarin-support.m @@ -87,7 +87,7 @@ // See in Mono sdks/ios/runtime/runtime.m void* -xamarin_timezone_get_data (const char *name, unsigned long *size) +xamarin_timezone_get_data (const char *name, uint32_t *size) { // COOP: no managed memory access: any mode. NSTimeZone *tz = nil; @@ -99,18 +99,18 @@ tz = [NSTimeZone localTimeZone]; } NSData *data = [tz data]; - *size = [data length]; + *size = (uint32_t) [data length]; void* result = malloc (*size); memcpy (result, data.bytes, *size); return result; } char** -xamarin_timezone_get_names (unsigned long *count) +xamarin_timezone_get_names (uint32_t *count) { // COOP: no managed memory access: any mode. NSArray *array = [NSTimeZone knownTimeZoneNames]; - *count = array.count; + *count = (uint32_t) array.count; char** result = (char**) malloc (sizeof (char*) * (*count)); for (unsigned long i = 0; i < *count; i++) { NSString *s = [array objectAtIndex: i]; diff --git a/runtime/xamarin/runtime.h b/runtime/xamarin/runtime.h index 9867bc9376d7..48520b24abfb 100644 --- a/runtime/xamarin/runtime.h +++ b/runtime/xamarin/runtime.h @@ -181,7 +181,7 @@ MonoClass * xamarin_get_nullable_type (MonoClass *cls, guint32 *exception_gchan MonoType * xamarin_get_parameter_type (MonoMethod *managed_method, int index); MonoObject * xamarin_get_nsobject_with_type_for_ptr (id self, bool owns, MonoType* type, guint32 *exception_gchandle); MonoObject * xamarin_get_nsobject_with_type_for_ptr_created (id self, bool owns, MonoType *type, int32_t *created, guint32 *exception_gchandle); -int * xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, unsigned long par, void *nativeBlock, guint32 *exception_gchandle); +int * xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, int par, void *nativeBlock, guint32 *exception_gchandle); id xamarin_get_block_for_delegate (MonoMethod *method, MonoObject *delegate, const char *signature /* NULL allowed, but requires the dynamic registrar at runtime to compute */, guint32 token_ref /* INVALID_TOKEN_REF allowed, but requires the dynamic registrar at runtime */, guint32 *exception_gchandle); id xamarin_get_nsobject_handle (MonoObject *obj); void xamarin_set_nsobject_handle (MonoObject *obj, id handle); diff --git a/runtime/xamarin/trampolines.h b/runtime/xamarin/trampolines.h index 6e00e7a106ac..61ebe19daf94 100644 --- a/runtime/xamarin/trampolines.h +++ b/runtime/xamarin/trampolines.h @@ -35,7 +35,7 @@ id xamarin_copyWithZone_trampoline2 (id self, SEL sel, NSZone *zone); uint32_t xamarin_get_gchandle_trampoline (id self, SEL sel); void xamarin_set_gchandle_trampoline (id self, SEL sel, uint32_t gc_handle); -unsigned long xamarin_get_frame_length (id self, SEL sel); +int xamarin_get_frame_length (id self, SEL sel); bool xamarin_collapse_struct_name (const char *type, char struct_name[], int max_char, guint32 *exception_gchandle); guint32 xamarin_create_mt_exception (char *msg); size_t xamarin_get_primitive_size (char type); @@ -95,7 +95,7 @@ MonoObject * xamarin_convert_nsnumber_to_managed (NSNumber *value, MonoType * MonoObject * xamarin_convert_nsvalue_to_managed (NSValue *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle); MonoObject * xamarin_convert_nsstring_to_managed (NSString *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle); guint32 xamarin_create_bindas_exception (MonoType *inputType, MonoType *outputType, MonoMethod *method); -guint32 xamarin_get_exception_for_parameter (int code, guint32 inner_exception_gchandle, const char *reason, SEL sel, MonoMethod *method, MonoType *p, unsigned long i, bool to_managed); +guint32 xamarin_get_exception_for_parameter (int code, guint32 inner_exception_gchandle, const char *reason, SEL sel, MonoMethod *method, MonoType *p, int i, bool to_managed); xamarin_id_to_managed_func xamarin_get_nsnumber_to_managed_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle); xamarin_managed_to_id_func xamarin_get_managed_to_nsnumber_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle); diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index fa979efe8ed7..d6b33a93b9d6 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -445,7 +445,7 @@ static IntPtr UnwrapNSException (uint exc_handle) } } - static IntPtr GetBlockWrapperCreator (IntPtr method, uint parameter) + static IntPtr GetBlockWrapperCreator (IntPtr method, int parameter) { return ObjectWrapper.Convert (GetBlockWrapperCreator ((MethodInfo) ObjectWrapper.Convert (method), parameter)); } @@ -727,7 +727,7 @@ static bool IsParameterTransient (IntPtr info, int parameter) return parameters [parameter].IsDefined (typeof(TransientAttribute), false); } - static bool IsParameterOut (IntPtr info, uint parameter) + static bool IsParameterOut (IntPtr info, int parameter) { var minfo = ObjectWrapper.Convert (info) as MethodInfo; if (minfo == null) @@ -773,7 +773,7 @@ static IntPtr LookupManagedTypeName (IntPtr klass) } #endregion - static MethodInfo GetBlockProxyAttributeMethod (MethodInfo method, uint parameter) + static MethodInfo GetBlockProxyAttributeMethod (MethodInfo method, int parameter) { var attrs = method.GetParameters () [parameter].GetCustomAttributes (typeof (BlockProxyAttribute), true); if (attrs.Length == 1) { @@ -840,7 +840,7 @@ internal static ProtocolMemberAttribute GetProtocolMemberAttribute (Type type, s #else public #endif - static MethodInfo GetBlockWrapperCreator (MethodInfo method, uint parameter) + static MethodInfo GetBlockWrapperCreator (MethodInfo method, int parameter) { // A mirror of this method is also implemented in StaticRegistrar:FindBlockProxyCreatorMethod // If this method is changed, that method will probably have to be updated too (tests!!!) diff --git a/tests/linker/ios/link all/InternalsTest.cs b/tests/linker/ios/link all/InternalsTest.cs index daad43baf3ec..719c938d01ef 100644 --- a/tests/linker/ios/link all/InternalsTest.cs +++ b/tests/linker/ios/link all/InternalsTest.cs @@ -73,12 +73,12 @@ public void TimeZone_Names () } [DllImport ("__Internal")] - extern static IntPtr xamarin_timezone_get_data (string name, ref int size); + extern static IntPtr xamarin_timezone_get_data (string name, ref uint size); [Test] public void TimeZone_Data () { - int size = 0; + uint size = 0; IntPtr data = xamarin_timezone_get_data (null, ref size); Assert.That (data, Is.Not.EqualTo (IntPtr.Zero), "default"); Assert.That (size, Is.GreaterThan (0), "default size");