Skip to content

Commit 0af8101

Browse files
authored
[src] Remove pointer-size checks and code. (#22666)
All pointers we support are now 64-bits.
1 parent a1dc051 commit 0af8101

File tree

6 files changed

+8
-58
lines changed

6 files changed

+8
-58
lines changed

docs/website/mtouch-errors.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,11 +3555,7 @@ This indicates something is wrong in the build process. Please file a new issue
35553555

35563556
This indicates an API wasn't bound correctly. If this is an API exposed by Xamarin, please file a new issue on [GitHub](https://github.com/xamarin/xamarin-macios/issues/new). If it's a third-party binding, please contact the vendor.
35573557

3558-
<a name="MT8010"></a>
3559-
3560-
### MT8010: Native type size mismatch between Xamarin.[iOS|Mac].dll and the executing architecture. Xamarin.[iOS|Mac].dll was built for *-bit, while the current process is *-bit.
3561-
3562-
This indicates something is wrong in the build process. Please file a new issue on [GitHub](https://github.com/xamarin/xamarin-macios/issues/new).
3558+
<!-- MT8010 is not reported anymore -->
35633559

35643560
<a name="MT8011"></a>
35653561

src/AppKit/NSGradient.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ public NSGradient (NSColor [] colors, float [] locations, NSColorSpace colorSpac
7474
public NSGradient (NSColor [] colors, double [] locations, NSColorSpace colorSpace) : base (NSObjectFlag.Empty)
7575
{
7676
unsafe {
77-
if (IntPtr.Size != 8)
78-
throw new PlatformNotSupportedException ("Use the overload that takes an array of 'nfloat' values as locations instead.");
79-
8077
fixed (void* locationPtr = locations) {
8178
Initialize (colors, locations?.Length, (IntPtr) locationPtr, colorSpace);
8279
}

src/ObjCRuntime/BindAs.cs

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,7 @@ unsafe static IntPtr ConvertManagedArrayToNSArray2<T, U> (T []? array, delegate*
205205
static System.Single xamarin_nsnumber_to_float (IntPtr value) { if (value == IntPtr.Zero) return default (System.Single); return Runtime.GetNSObject<NSNumber> (value)?.FloatValue ?? default (System.Single); }
206206
static System.Double xamarin_nsnumber_to_double (IntPtr value) { if (value == IntPtr.Zero) return default (System.Double); return Runtime.GetNSObject<NSNumber> (value)?.DoubleValue ?? default (System.Double); }
207207
static System.Boolean xamarin_nsnumber_to_bool (IntPtr value) { if (value == IntPtr.Zero) return default (System.Boolean); return Runtime.GetNSObject<NSNumber> (value)?.BoolValue ?? default (System.Boolean); }
208-
static nfloat xamarin_nsnumber_to_nfloat (IntPtr value)
209-
{
210-
if (value == IntPtr.Zero)
211-
return default (nfloat);
212-
var number = Runtime.GetNSObject<NSNumber> (value);
213-
if (number is null)
214-
return default (nfloat);
215-
if (IntPtr.Size == 4)
216-
return (nfloat) number.FloatValue;
217-
return (nfloat) number.DoubleValue;
218-
}
208+
static nfloat xamarin_nsnumber_to_nfloat (IntPtr value) { if (value == IntPtr.Zero) return default (nfloat); return (nfloat?) Runtime.GetNSObject<NSNumber> (value)?.DoubleValue ?? default (nfloat); }
219209

220210
static System.SByte? xamarin_nsnumber_to_nullable_sbyte (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.SByteValue ?? null; }
221211
static System.Byte? xamarin_nsnumber_to_nullable_byte (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.ByteValue ?? null; }
@@ -230,17 +220,7 @@ static nfloat xamarin_nsnumber_to_nfloat (IntPtr value)
230220
static System.Single? xamarin_nsnumber_to_nullable_float (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.FloatValue ?? null; }
231221
static System.Double? xamarin_nsnumber_to_nullable_double (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.DoubleValue ?? null; }
232222
static System.Boolean? xamarin_nsnumber_to_nullable_bool (IntPtr value) { return Runtime.GetNSObject<NSNumber> (value)?.BoolValue ?? null; }
233-
static nfloat? xamarin_nsnumber_to_nullable_nfloat (IntPtr value)
234-
{
235-
if (value == IntPtr.Zero)
236-
return null;
237-
var number = Runtime.GetNSObject<NSNumber> (value);
238-
if (number is null)
239-
return null;
240-
if (IntPtr.Size == 4)
241-
return (nfloat) number.FloatValue;
242-
return (nfloat) number.DoubleValue;
243-
}
223+
static nfloat? xamarin_nsnumber_to_nullable_nfloat (IntPtr value) { return (nfloat?) Runtime.GetNSObject<NSNumber> (value)?.DoubleValue ?? null; }
244224

245225
static IntPtr xamarin_sbyte_to_nsnumber (System.SByte value) { return NSNumber.FromSByte (value).DangerousRetain ().DangerousAutorelease ().Handle; }
246226
static IntPtr xamarin_byte_to_nsnumber (System.Byte value) { return NSNumber.FromByte (value).DangerousRetain ().DangerousAutorelease ().Handle; }
@@ -255,12 +235,7 @@ static nfloat xamarin_nsnumber_to_nfloat (IntPtr value)
255235
static IntPtr xamarin_float_to_nsnumber (System.Single value) { return NSNumber.FromFloat (value).DangerousRetain ().DangerousAutorelease ().Handle; }
256236
static IntPtr xamarin_double_to_nsnumber (System.Double value) { return NSNumber.FromDouble (value).DangerousRetain ().DangerousAutorelease ().Handle; }
257237
static IntPtr xamarin_bool_to_nsnumber (System.Boolean value) { return NSNumber.FromBoolean (value).DangerousRetain ().DangerousAutorelease ().Handle; }
258-
static IntPtr xamarin_nfloat_to_nsnumber (nfloat value)
259-
{
260-
if (IntPtr.Size == 4)
261-
return NSNumber.FromFloat ((float) value).DangerousRetain ().DangerousAutorelease ().Handle;
262-
return NSNumber.FromDouble ((double) value).DangerousRetain ().DangerousAutorelease ().Handle;
263-
}
238+
static IntPtr xamarin_nfloat_to_nsnumber (nfloat value) { return NSNumber.FromDouble ((double) value).DangerousRetain ().DangerousAutorelease ().Handle; }
264239

265240
static IntPtr xamarin_nullable_sbyte_to_nsnumber (System.SByte? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromSByte (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
266241
static IntPtr xamarin_nullable_byte_to_nsnumber (System.Byte? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromByte (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
@@ -275,13 +250,6 @@ static IntPtr xamarin_nfloat_to_nsnumber (nfloat value)
275250
static IntPtr xamarin_nullable_float_to_nsnumber (System.Single? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromFloat (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
276251
static IntPtr xamarin_nullable_double_to_nsnumber (System.Double? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromDouble (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
277252
static IntPtr xamarin_nullable_bool_to_nsnumber (System.Boolean? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromBoolean (value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
278-
static IntPtr xamarin_nullable_nfloat_to_nsnumber (nfloat? value)
279-
{
280-
if (!value.HasValue)
281-
return IntPtr.Zero;
282-
if (IntPtr.Size == 4)
283-
return NSNumber.FromFloat ((float) value.Value).DangerousRetain ().DangerousAutorelease ().Handle;
284-
return NSNumber.FromDouble ((double) value.Value).DangerousRetain ().DangerousAutorelease ().Handle;
285-
}
253+
static IntPtr xamarin_nullable_nfloat_to_nsnumber (nfloat? value) { if (!value.HasValue) return IntPtr.Zero; return NSNumber.FromDouble ((double) value.Value).DangerousRetain ().DangerousAutorelease ().Handle; }
286254
}
287255
}

src/ObjCRuntime/Runtime.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,6 @@ unsafe static void Initialize (InitializationOptions* options)
325325
throw ErrorHelper.CreateError (8001, msg);
326326
}
327327

328-
if (IntPtr.Size != sizeof (nint)) {
329-
string msg = $"Native type size mismatch between {AssemblyName} and the executing architecture. {AssemblyName} was built for {(IntPtr.Size == 4 ? 64 : 32)}-bit, while the current process is {(IntPtr.Size == 4 ? 32 : 64)}-bit.";
330-
NSLog (msg);
331-
throw ErrorHelper.CreateError (8010, msg);
332-
}
333-
334328
if (System.Runtime.GCSettings.IsServerGC) {
335329
var msg = $".NET for {PlatformName} does not support server garbage collection.";
336330
NSLog (msg);
@@ -2543,9 +2537,6 @@ public string Description {
25432537
[BindingImpl (BindingImplOptions.Optimizable)]
25442538
static bool GetIsARM64CallingConvention ()
25452539
{
2546-
if (IntPtr.Size != 8)
2547-
return false;
2548-
25492540
unsafe {
25502541
return NXGetLocalArchInfo ()->Name.StartsWith ("arm64", StringComparison.OrdinalIgnoreCase);
25512542
}

src/ObjCRuntime/TypeConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ public static string ToNative (Type type)
140140
if (type == typeof (string)) return "@"; // We handle NSString as MonoString automagicaly
141141
if (type == typeof (Selector)) return ":";
142142
if (type == typeof (Class)) return "#";
143-
if (type == typeof (nfloat)) return IntPtr.Size == 8 ? "d" : "f";
144-
if (type == typeof (nint)) return IntPtr.Size == 8 ? "q" : "i";
145-
if (type == typeof (nuint)) return IntPtr.Size == 8 ? "Q" : "I";
143+
if (type == typeof (nfloat)) return "d";
144+
if (type == typeof (nint)) return "q";
145+
if (type == typeof (nuint)) return "Q";
146146
if (typeof (INativeObject).IsAssignableFrom (type)) return "@";
147147
if (type.IsValueType && !type.IsEnum) {
148148
// TODO: We should cache the results of this in a temporary hash that we destroy when we're done initializing/registrations

src/WebKit/WKWindowFeatures.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public bool? AllowsResizing {
4848
{
4949
if (number is null)
5050
return null;
51-
else if (IntPtr.Size == 4)
52-
return (nfloat) number.FloatValue;
5351
else
5452
return (nfloat) number.DoubleValue;
5553
}

0 commit comments

Comments
 (0)