Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions runtime/delegates.t4
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion runtime/monotouch-debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions runtime/monotouch-debug.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion runtime/monotouch-main.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/monotouch-support.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -2066,7 +2066,7 @@ -(void) xamarinSetGCHandle: (uint32_t) gc_handle;

typedef struct {
MonoMethod *method;
unsigned long par;
int par;
} MethodAndPar;

static gboolean
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions runtime/trampolines-arm64.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -105,7 +105,7 @@

if (target == NULL) {
LOGZ (" not reading, since target is NULL.\n");
return size;
return (int) size;
}

switch (size) {
Expand All @@ -130,7 +130,7 @@
return 0;
}

return size;
return (int) size;
}
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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];
}
Expand All @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/trampolines-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions runtime/trampolines-invoke.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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]);
Expand All @@ -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];
Expand All @@ -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)) {
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would not this be simpler (less changes) if int i was used ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly, no.

goto exception_handling;
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/trampolines.m
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
return true;
}

unsigned long
int
xamarin_get_frame_length (id self, SEL sel)
{
if (self == NULL)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions runtime/xamarin-support.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion runtime/xamarin/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions runtime/xamarin/trampolines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/ObjCRuntime/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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!!!)
Expand Down
4 changes: 2 additions & 2 deletions tests/linker/ios/link all/InternalsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down