Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[foundation] Xcode 13 & Xcode 14 beta 1-3 bindings #15579

Merged
merged 14 commits into from Aug 1, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/Foundation/Enum.cs
Expand Up @@ -372,6 +372,7 @@ public enum NSCocoaError : int {
XpcConnectionInterrupted = 4097,
XpcConnectionInvalid = 4099,
XpcConnectionReplyInvalid = 4101,
XpcConnectionCodeSigningRequirementFailure = 4102,
XpcConnectionErrorMinimum = 4096,
XpcConnectionErrorMaximum = 4224,

Expand Down Expand Up @@ -617,6 +618,7 @@ public enum NSSearchPathDirectory : ulong {
ItemReplacementDirectory = 99,
AllApplicationsDirectory = 100,
AllLibrariesDirectory = 101,
[NoTV, NoWatch]
TrashDirectory = 102,
}

Expand Down Expand Up @@ -749,6 +751,10 @@ public enum NSJsonReadingOptions : ulong {
MutableContainers = 1,
MutableLeaves = 2,
FragmentsAllowed = 4,
[Mac (12,0), iOS (15,0), TV (15,0), Watch (8,0), MacCatalyst (15,0)]
Json5Allowed = 8,
[Mac (12,0), iOS (15,0), TV (15,0), Watch (8,0), MacCatalyst (15,0)]
TopLevelDictionaryAssumed = 16,
#if !NET
[Obsolete ("Use 'FragmentsAllowed. instead.")]
AllowFragments = FragmentsAllowed,
Expand Down Expand Up @@ -880,16 +886,23 @@ public enum NSUrlBookmarkCreationOptions : ulong {
PreferFileIDResolution = 1 << 8,
MinimalBookmark = 1 << 9,
SuitableForBookmarkFile = 1 << 10,
[NoiOS, NoTV, NoWatch]
WithSecurityScope = 1 << 11,
SecurityScopeAllowOnlyReadAccess = 1 << 12
[NoiOS, NoTV, NoWatch]
SecurityScopeAllowOnlyReadAccess = 1 << 12,
[Mac (12,0), iOS (15,0), TV (15,0), Watch (8,0), MacCatalyst (15,0)]
CreationWithoutImplicitSecurityScope = 1 << 29,
}

[Flags]
[Native]
public enum NSUrlBookmarkResolutionOptions : ulong {
WithoutUI = 1 << 8,
WithoutMounting = 1 << 9,
[NoiOS, NoTV, NoWatch]
WithSecurityScope = 1 << 10,
[Mac (12,0), iOS (15,0), TV (15,0), Watch (8,0), MacCatalyst (15,0)]
WithoutImplicitStartAccessing = 1 << 15,
}

[Native]
Expand Down Expand Up @@ -1032,6 +1045,9 @@ public enum NSActivityOptions : ulong {
IdleSystemSleepDisabled = 1UL << 20,
SuddenTerminationDisabled = 1UL << 14,
AutomaticTerminationDisabled = 1UL << 15,
AnimationTrackingEnabled = 1uL << 45,
TrackingEnabled = 1uL << 46,
UserInteractive = (UserInitiated | LatencyCritical),
UserInitiated = 0x00FFFFFFUL | IdleSystemSleepDisabled,
Background = 0x000000ffUL,
LatencyCritical = 0xFF00000000UL,
Expand Down Expand Up @@ -1305,7 +1321,9 @@ public enum NSMeasurementFormatterUnitOptions : ulong {
[Native]
public enum NSItemProviderRepresentationVisibility : long {
All = 0,
[NoMac]
Team = 1,
[NoiOS, NoTV, NoWatch]
Group = 2,
OwnProcess = 3,
}
Expand Down
108 changes: 108 additions & 0 deletions src/Foundation/Enums.cs
Expand Up @@ -275,5 +275,113 @@ public enum NSStringEnumerationOptions : ulong
SubstringNotRequired = 1uL << 9,
Localized = 1uL << 10,
}

[Mac (12,0), TV (15,0), iOS (15,0), MacCatalyst (15, 0), Watch (8,0)]
[Flags]
[Native]
public enum NSAttributedStringFormattingOptions : ulong {
InsertArgumentAttributesWithoutMerging = 1uL << 0,
ApplyReplacementIndexAttribute = 1uL << 1,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSAttributedStringMarkdownInterpretedSyntax : long {
Full = 0,
InlineOnly = 1,
InlineOnlyPreservingWhitespace = 2,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSAttributedStringMarkdownParsingFailurePolicy : long {
Error = 0,
PartiallyParsedIfPossible = 1,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSGrammaticalGender : long {
NotSet = 0,
Feminine,
Masculine,
Neuter,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSGrammaticalNumber : long {
NotSet = 0,
Singular,
Zero,
Plural,
PluralTwo,
PluralFew,
PluralMany,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSGrammaticalPartOfSpeech : long {
NotSet = 0,
Determiner,
Pronoun,
Letter,
Adverb,
Particle,
Adjective,
Adposition,
Verb,
Noun,
Conjunction,
Numeral,
Interjection,
Preposition,
Abbreviation,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSInlinePresentationIntent : ulong {
Emphasized = 1uL << 0,
StronglyEmphasized = 1uL << 1,
Code = 1uL << 2,
Strikethrough = 1uL << 5,
SoftBreak = 1uL << 6,
LineBreak = 1uL << 7,
InlineHTML = 1uL << 8,
BlockHTML = 1uL << 9,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSPresentationIntentKind : long {
Paragraph,
Header,
OrderedList,
UnorderedList,
ListItem,
CodeBlock,
BlockQuote,
ThematicBreak,
Table,
TableHeaderRow,
TableRow,
TableCell,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSPresentationIntentTableColumnAlignment : long {
Left,
Center,
Right,
}

[Watch (8,0), TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Native]
public enum NSURLRequestAttribution : ulong {
Developer = 0,
User = 1,
}
}
41 changes: 41 additions & 0 deletions src/Foundation/NSArray.cs
Expand Up @@ -27,6 +27,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

using CoreFoundation;
using ObjCRuntime;
Expand All @@ -37,6 +38,10 @@

namespace Foundation {

#if false // https://github.com/xamarin/xamarin-macios/issues/15577
public delegate bool NSOrderedCollectionDifferenceEquivalenceTest (NSObject first, NSObject second);
#endif

public partial class NSArray {

//
Expand Down Expand Up @@ -429,5 +434,41 @@ public static NSArray From (NSObject[][] items)
return null;
}
}

#if false // https://github.com/xamarin/xamarin-macios/issues/15577

static readonly NSOrderedCollectionDifferenceEquivalenceTestProxy static_DiffEquality = DiffEqualityHandler;

[MonoPInvokeCallback (typeof (NSOrderedCollectionDifferenceEquivalenceTestProxy))]
static bool DiffEqualityHandler (IntPtr block, IntPtr first, IntPtr second)
{
var callback = BlockLiteral.GetTarget<NSOrderedCollectionDifferenceEquivalenceTest> (block);
if (callback is not null) {
var nsFirst = Runtime.GetNSObject<NSObject> (first, false);
var nsSecond = Runtime.GetNSObject<NSObject> (second, false);
return callback (nsFirst, nsSecond);
}
return false;
}

#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos10.15")]
#endif
public NSOrderedCollectionDifference GetDifferenceFromArray (NSArray other, NSOrderedCollectionDifferenceCalculationOptions options, NSOrderedCollectionDifferenceEquivalenceTest equivalenceTest)
{
if (equivalenceTest is null)
throw new ArgumentNullException (nameof (equivalenceTest));

var block = new BlockLiteral ();
block.SetupBlock (static_DiffEquality, equivalenceTest);
try {
return Runtime.GetNSObject<NSOrderedCollectionDifference> (_GetDifferenceFromArray (other, options, ref block));
} finally {
block.CleanupBlock ();
}
}
#endif
}
}
73 changes: 69 additions & 4 deletions src/Foundation/NSArray_1.cs
Expand Up @@ -7,6 +7,8 @@
// Copyright 2015, Xamarin Inc.
//

#nullable enable

using System;
using System.Collections.Generic;
using System.Collections;
Expand All @@ -20,6 +22,10 @@
#endif

namespace Foundation {
#if false // https://github.com/xamarin/xamarin-macios/issues/15577
public delegate bool NSOrderedCollectionDifferenceEquivalenceTest<TValue> (TValue? first, TValue? second);
internal delegate bool NSOrderedCollectionDifferenceEquivalenceTestProxy (IntPtr blockLiteral, /* NSObject */ IntPtr first, /* NSObject */ IntPtr second);
#endif
#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
Expand All @@ -42,15 +48,15 @@ internal NSArray (NativeHandle handle) : base (handle)
{
}

static public NSArray<TKey> FromNSObjects (params TKey [] items)
static public NSArray<TKey>? FromNSObjects (params TKey [] items)
{
if (items == null)
if (items is null)
throw new ArgumentNullException (nameof (items));

return FromNSObjects (items.Length, items);
}

static public NSArray<TKey> FromNSObjects (int count, params TKey [] items)
static public NSArray<TKey>? FromNSObjects (int count, params TKey [] items)
{
if (items == null)
throw new ArgumentNullException (nameof (items));
Expand All @@ -65,7 +71,7 @@ static public NSArray<TKey> FromNSObjects (int count, params TKey [] items)
Marshal.WriteIntPtr (buf, (int)(i * IntPtr.Size), h);
}
IntPtr ret = NSArray.FromObjects (buf, count);
NSArray<TKey> arr = Runtime.GetNSObject<NSArray<TKey>> (ret);
var arr = Runtime.GetNSObject<NSArray<TKey>> (ret);
Marshal.FreeHGlobal (buf);
return arr;
}
Expand All @@ -89,5 +95,64 @@ IEnumerator IEnumerable.GetEnumerator ()
return GetItem<TKey> ((nuint)idx);
}
}

#if false // https://github.com/xamarin/xamarin-macios/issues/15577

#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos10.15")]
#endif
public NSOrderedCollectionDifference<TKey>? GetDifference (TKey[] other, NSOrderedCollectionDifferenceCalculationOptions options)
=> Runtime.GetNSObject <NSOrderedCollectionDifference<TKey>> (_GetDifference (NSArray.FromNSObjects (other), options));

#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos10.15")]
#endif
public NSOrderedCollectionDifference<TKey>? GetDifference (TKey[] other)
=> Runtime.GetNSObject <NSOrderedCollectionDifference<TKey>> (_GetDifference (NSArray.FromNSObjects (other)));

#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos10.15")]
#endif
public TKey[]? GetArrayByApplyingDifference (NSOrderedCollectionDifference difference)
=> NSArray.ArrayFromHandle<TKey> (_GetArrayByApplyingDifference (difference));
static readonly NSOrderedCollectionDifferenceEquivalenceTestProxy static_DiffEqualityGeneric = DiffEqualityHandlerGeneric;

[MonoPInvokeCallback (typeof (NSOrderedCollectionDifferenceEquivalenceTestProxy))]
static bool DiffEqualityHandlerGeneric (IntPtr block, IntPtr first, IntPtr second)
{
var callback = BlockLiteral.GetTarget<NSOrderedCollectionDifferenceEquivalenceTest<TKey>> (block);
if (callback is not null) {
var nsFirst = Runtime.GetINativeObject<TKey> (first, false);
var nsSecond = Runtime.GetINativeObject<TKey> (second, false);
return callback (nsFirst, nsSecond);
}
return false;
}

#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos10.15")]
#endif
public NSOrderedCollectionDifference<TKey>? GetDifferenceFromArray (NSArray<TKey> other, NSOrderedCollectionDifferenceCalculationOptions options, NSOrderedCollectionDifferenceEquivalenceTest<TKey> equivalenceTest)
{
if (equivalenceTest is null)
throw new ArgumentNullException (nameof (equivalenceTest));

var block = new BlockLiteral ();
block.SetupBlock (static_DiffEqualityGeneric, equivalenceTest);
try {
return Runtime.GetNSObject<NSOrderedCollectionDifference<TKey>> (_GetDifferenceFromArray (other, options, ref block));
} finally {
block.CleanupBlock ();
}
}
#endif
}
}
10 changes: 10 additions & 0 deletions src/Foundation/NSMutableArray_1.cs
Expand Up @@ -198,5 +198,15 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
return GetEnumerator ();
}
#endregion

#if false // https://github.com/xamarin/xamarin-macios/issues/15577
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos10.15")]
#endif
public void ApplyDifference (NSOrderedCollectionDifference<TValue> difference)
=> ApplyDifference ((NSOrderedCollectionDifference) difference);
#endif
}
}
14 changes: 14 additions & 0 deletions src/Foundation/NSMutableOrderedSet_1.cs
Expand Up @@ -232,5 +232,19 @@ IEnumerator IEnumerable.GetEnumerator ()
copy.MinusSet (second);
return copy;
}

#if false // https://github.com/xamarin/xamarin-macios/issues/15577
#if !NET
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
#else
[SupportedOSPlatform ("ios13.0"), SupportedOSPlatform ("tvos13.0"), SupportedOSPlatform ("macos10.15")]
#endif
public void ApplyDifference (NSOrderedCollectionDifference<TKey> difference)
{
if (difference is null)
throw new ArgumentNullException (nameof (difference));
_ApplyDifference (difference.Handle);
}
#endif
}
}