Skip to content

Commit

Permalink
Merge branch 'main' into Xcode13-UserNotifications-beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque authored Jul 20, 2021
2 parents 09b686f + eea8142 commit 9306dc7
Show file tree
Hide file tree
Showing 25 changed files with 139 additions and 203 deletions.
1 change: 1 addition & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
<StartupHookSupport Condition="'$(StartupHookSupport)' == ''">false</StartupHookSupport>
<UseSystemResourceKeys Condition="'$(UseSystemResourceKeys)' == ''">true</UseSystemResourceKeys>
<UseNativeHttpHandler Condition="'$(_PlatformName)' != 'macOS' And '$(UseNativeHttpHandler)' == ''">true</UseNativeHttpHandler>
<AutoreleasePoolSupport Condition="'$(AutoreleasePoolSupport)' == ''">true</AutoreleasePoolSupport>

<!-- We don't need to generate reference assemblies for apps or app extensions -->
<ProduceReferenceAssembly Condition="'$(ProduceReferenceAssembly)' == '' And ('$(OutputType)' == 'Exe' Or '$(IsAppExtension)' == 'true')">false</ProduceReferenceAssembly>
Expand Down
2 changes: 1 addition & 1 deletion runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
if (main_bundle == NULL)
xamarin_assertion_message ("Could not find the main bundle in the app ([NSBundle mainBundle] returned nil)");

#if MONOMAC
#if TARGET_OS_MACCATALYST || TARGET_OS_OSX
if (xamarin_launch_mode == XamarinLaunchModeEmbedded) {
bundle_path = [[[NSBundle bundleForClass: [XamarinAssociatedObject class]] bundlePath] stringByAppendingPathComponent: @"Versions/Current"];
} else {
Expand Down
64 changes: 18 additions & 46 deletions src/CoreFoundation/CFArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,53 +38,25 @@
using CFArrayRef = System.IntPtr;
using CFAllocatorRef = System.IntPtr;

#nullable enable

namespace CoreFoundation {

partial class CFArray : INativeObject, IDisposable {

internal IntPtr handle;
public partial class CFArray : NativeObject {

internal CFArray (IntPtr handle)
: this (handle, false)
: base (handle, false)
{
}

[Preserve (Conditional = true)]
internal CFArray (IntPtr handle, bool owns)
: base (handle, owns)
{
if (handle == IntPtr.Zero)
throw new ArgumentNullException ("handle");

this.handle = handle;
if (!owns)
CFObject.CFRetain (handle);
}

public IntPtr Handle {
get {return handle;}
}

[DllImport (Constants.CoreFoundationLibrary, EntryPoint="CFArrayGetTypeID")]
public extern static /* CFTypeID */ nint GetTypeID ();

~CFArray ()
{
Dispose (false);
}

public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}

protected virtual void Dispose (bool disposing)
{
if (handle != IntPtr.Zero){
CFObject.CFRelease (handle);
handle = IntPtr.Zero;
}
}
internal extern static /* CFTypeID */ nint GetTypeID ();

// pointer to a const struct (REALLY APPLE?)
static IntPtr kCFTypeArrayCallbacks_ptr_value;
Expand All @@ -97,18 +69,18 @@ static IntPtr kCFTypeArrayCallbacks_ptr {
}
}

public static CFArray FromIntPtrs (params IntPtr[] values)
internal static CFArray FromIntPtrs (params IntPtr[] values)
{
return new CFArray (Create (values), true);
}

public static CFArray FromNativeObjects (params INativeObject[] values)
internal static CFArray FromNativeObjects (params INativeObject[] values)
{
return new CFArray (Create (values), true);
}

public nint Count {
get {return CFArrayGetCount (handle);}
get { return CFArrayGetCount (GetCheckedHandle ()); }
}

[DllImport (Constants.CoreFoundationLibrary)]
Expand All @@ -119,13 +91,13 @@ public nint Count {

public IntPtr GetValue (nint index)
{
return CFArrayGetValueAtIndex (handle, index);
return CFArrayGetValueAtIndex (GetCheckedHandle (), index);
}

public static unsafe IntPtr Create (params IntPtr[] values)
internal static unsafe IntPtr Create (params IntPtr[] values)
{
if (values == null)
throw new ArgumentNullException ("values");
if (values is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (values));
fixed (IntPtr* pv = values) {
return CFArrayCreate (IntPtr.Zero,
(IntPtr) pv,
Expand All @@ -134,10 +106,10 @@ public static unsafe IntPtr Create (params IntPtr[] values)
}
}

public static IntPtr Create (params INativeObject[] values)
internal static IntPtr Create (params INativeObject[] values)
{
if (values == null)
throw new ArgumentNullException ("values");
if (values is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (values));
IntPtr[] _values = new IntPtr [values.Length];
for (int i = 0; i < _values.Length; ++i)
_values [i] = values [i].Handle;
Expand All @@ -147,15 +119,15 @@ public static IntPtr Create (params INativeObject[] values)
[DllImport (Constants.CoreFoundationLibrary)]
extern static /* CFIndex */ nint CFArrayGetCount (/* CFArrayRef */ IntPtr theArray);

public static nint GetCount (IntPtr array)
internal static nint GetCount (IntPtr array)
{
return CFArrayGetCount (array);
}

[DllImport (Constants.CoreFoundationLibrary)]
extern static CFArrayRef CFArrayCreateCopy (CFAllocatorRef allocator, CFArrayRef theArray);

public CFArray Clone () => new CFArray (CFArrayCreateCopy (IntPtr.Zero, this.Handle), true);
internal CFArray Clone () => new CFArray (CFArrayCreateCopy (IntPtr.Zero, GetCheckedHandle ()), true);
}
}

2 changes: 1 addition & 1 deletion src/Foundation/DictionaryContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ protected void SetArrayValue (NSString key, string[]? values)
protected void SetArrayValue (NSString key, INativeObject[]? values)
{
if (NullCheckAndRemoveKey (key, values == null))
CFMutableDictionary.SetValue (Dictionary.Handle, key!.Handle, CFArray.FromNativeObjects (values).Handle);
CFMutableDictionary.SetValue (Dictionary.Handle, key!.Handle, CFArray.FromNativeObjects (values!).Handle);
}

#region Sets CFBoolean value
Expand Down
49 changes: 0 additions & 49 deletions src/appkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17672,55 +17672,6 @@ interface NSTextAttachmentCell {
NSTextAttachment Attachment { get; set; }
}

[BaseType (typeof (NSObject))]
interface NSTextAttachment : NSCoding, NSSecureCoding {
[Export ("initWithFileWrapper:")]
IntPtr Constructor (NSFileWrapper fileWrapper);

[Mac (10,11)]
[Export ("initWithData:ofType:")]
[DesignatedInitializer]
IntPtr Constructor ([NullAllowed] NSData contentData, [NullAllowed] string uti);

//Detected properties
[Export ("fileWrapper", ArgumentSemantic.Retain)]
NSFileWrapper FileWrapper { get; set; }

[Export ("attachmentCell", ArgumentSemantic.Retain)]
NSTextAttachmentCell AttachmentCell { get; set; }

[Mac (10,11)] // 32-bit gives: [FAIL] Selector not found for AppKit.NSTextAttachment : contents
[NullAllowed, Export ("contents", ArgumentSemantic.Copy)]
NSData Contents { get; set; }

[Mac (10,11)]
[NullAllowed, Export ("fileType")]
string FileType { get; set; }

[Mac (10,11)] // 32-bit gives: [FAIL] Selector not found for AppKit.NSTextAttachment : image
[NullAllowed, Export ("image", ArgumentSemantic.Strong)]
NSImage Image { get; set; }

[Mac (10,11)] // 32-bit gives: [FAIL] Selector not found for AppKit.NSTextAttachment : bounds
[Export ("bounds", ArgumentSemantic.Assign)]
CGRect Bounds { get; set; }
}

[Mac (10,11)]
[Protocol, Model]
[BaseType (typeof(NSObject))]
interface NSTextAttachmentContainer
{
[Abstract]
[Export ("imageForBounds:textContainer:characterIndex:")]
[return: NullAllowed]
NSImage GetImage (CGRect imageBounds, [NullAllowed] NSTextContainer textContainer, nuint charIndex);

[Abstract]
[Export ("attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex:")]
CGRect GetAttachmentBounds ([NullAllowed] NSTextContainer textContainer, CGRect lineFrag, CGPoint position, nuint charIndex);
}

[DesignatedDefaultCtor]
[BaseType (typeof (NSObject))]
interface NSTextBlock : NSCoding, NSCopying, NSSecureCoding {
Expand Down
36 changes: 30 additions & 6 deletions src/gamecontroller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,26 @@ enum GCInputDirectional {

[Field ("GCInputDirectionalCardinalDpad")]
CardinalDpad,

[TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)]
[Field ("GCInputDirectionalCenterButton")]
CenterButton,

[TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)]
[Field ("GCInputDirectionalTouchSurfaceButton")]
TouchSurfaceButton,
}

[TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)]
enum GCInputMicroGamepad {
[Field ("GCInputMicroGamepadDpad")]
Dpad,

[Field ("GCInputMicroGamepadButtonA")]
ButtonA,

[Field ("GCInputMicroGamepadButtonX")]
ButtonX,
}

delegate GCVirtualControllerElementConfiguration GCVirtualControllerElementUpdateBlock (GCVirtualControllerElementConfiguration configuration);
Expand All @@ -2008,8 +2028,12 @@ interface GCVirtualController
[Export ("virtualControllerWithConfiguration:")]
GCVirtualController Create (GCVirtualControllerConfiguration configuration);

[Export ("initWithConfiguration:")]
[DesignatedInitializer]
IntPtr Constructor (GCVirtualControllerConfiguration configuration);

[Async]
[Export ("connectWithReply:")]
[Export ("connectWithReplyHandler:")]
void Connect ([NullAllowed] Action<NSError> reply);

[Export ("disconnect")]
Expand All @@ -2018,8 +2042,8 @@ interface GCVirtualController
[NullAllowed, Export ("controller", ArgumentSemantic.Weak)]
GCController Controller { get; }

[Export ("changeElement:configuration:")]
void Change (string element, GCVirtualControllerElementUpdateBlock configuration);
[Export ("updateConfigurationForElement:configuration:")]
void UpdateConfiguration (string element, GCVirtualControllerElementUpdateBlock configuration);
}

[NoTV, NoMac, NoWatch, iOS (15,0), MacCatalyst (15,0)]
Expand All @@ -2035,12 +2059,12 @@ interface GCVirtualControllerConfiguration
interface GCVirtualControllerElementConfiguration
{
[Export ("hidden")]
bool Hidden { get; set; }
bool Hidden { [Bind ("isHidden")] get; set; }

[NullAllowed, Export ("path", ArgumentSemantic.Strong)]
BezierPath Path { get; set; }

[Export ("touchpad")]
bool Touchpad { get; set; }
[Export ("actsAsTouchpad")]
bool ActsAsTouchpad { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/imageio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ interface CGImageProperties {
NSString PNGSoftware { get; }
[Field ("kCGImagePropertyPNGTitle")]
NSString PNGTitle { get; }
[Mac (12, 0), iOS (15, 0), TV (15,0), MacCatalyst (15,0), Watch (8,0)]
[Field ("kCGImagePropertyPNGPixelsAspectRatio")]
NSString PNGPixelsAspectRatio { get; }

[iOS (9,0)][Mac (10,11)]
[Field ("kCGImagePropertyPNGCompressionFilter")]
Expand Down
50 changes: 0 additions & 50 deletions src/uikit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,56 +412,6 @@ interface NSShadow : NSSecureCoding, NSCopying {
}

#if !WATCH
[Model]
[Protocol]
[BaseType (typeof (NSObject))]
partial interface NSTextAttachmentContainer {
[Abstract]
[Export ("imageForBounds:textContainer:characterIndex:")]
UIImage GetImageForBounds (CGRect bounds, [NullAllowed] NSTextContainer textContainer, nuint characterIndex);

[Abstract]
[Export ("attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex:")]
CGRect GetAttachmentBounds (NSTextContainer textContainer, CGRect proposedLineFragment, CGPoint glyphPosition, nuint characterIndex);
}

[iOS (7,0)]
[BaseType (typeof (NSObject))]
partial interface NSTextAttachment : NSTextAttachmentContainer, NSSecureCoding
#if !WATCH
, UIAccessibilityContentSizeCategoryImageAdjusting
#endif // !WATCH
{
[DesignatedInitializer]
[Export ("initWithData:ofType:")]
[PostGet ("Contents")]
IntPtr Constructor ([NullAllowed] NSData contentData, [NullAllowed] string uti);

[NullAllowed] // by default this property is null
[Export ("contents", ArgumentSemantic.Retain)]
NSData Contents { get; set; }

[NullAllowed] // by default this property is null
[Export ("fileType", ArgumentSemantic.Retain)]
string FileType { get; set; }

[NullAllowed] // by default this property is null
[Export ("image", ArgumentSemantic.Retain)]
UIImage Image { get; set; }

[Export ("bounds")]
CGRect Bounds { get; set; }

[NullAllowed] // by default this property is null
[Export ("fileWrapper", ArgumentSemantic.Retain)]
NSFileWrapper FileWrapper { get; set; }

[Watch (6,0), TV (13,0), iOS (13,0)]
[Static]
[Export ("textAttachmentWithImage:")]
NSTextAttachment Create (UIImage image);
}

[Protocol]
// no [Model] since it's not exposed in any API
// only NSTextContainer conforms to it but it's only queried by iOS itself
Expand Down
Loading

0 comments on commit 9306dc7

Please sign in to comment.