From 75b150ef5f3aa963ffd7c9a4623a9234bf3b534b Mon Sep 17 00:00:00 2001 From: Rachel Kang Date: Tue, 3 Aug 2021 16:37:56 -0400 Subject: [PATCH 1/4] [QuickLook] Update bindings for Xcode 13.0 beta 1,2,3,4 --- src/generator.cs | 6 +- src/quicklook.cs | 87 +++++++++++++++++++ tests/introspection/iOS/iOSApiProtocolTest.cs | 4 + tests/xtro-sharpie/MacCatalyst-QuickLook.todo | 23 ----- tests/xtro-sharpie/iOS-QuickLook.todo | 22 ----- 5 files changed, 96 insertions(+), 46 deletions(-) diff --git a/src/generator.cs b/src/generator.cs index c78255c1e6e9..1b4196177109 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -1727,7 +1727,11 @@ public TrampolineInfo MakeTrampoline (Type t) convert.Append ($"var {refname} = Runtime.GetINativeObject<{RenderType (nt)}> ({safe_name}, false);"); pars.Append ($"ref IntPtr {safe_name}"); postConvert.Append ($"{safe_name} = {refname} is null ? IntPtr.Zero : {refname}.Handle;"); - invoke.Append ($"ref {refname}"); + if (pi.IsOut) + invoke.Append ("out "); + else + invoke.Append ("ref "); + invoke.Append (refname); continue; } } else if (IsNativeEnum (pi.ParameterType)) { diff --git a/src/quicklook.cs b/src/quicklook.cs index 61dedb58121a..5c42694b7b31 100644 --- a/src/quicklook.cs +++ b/src/quicklook.cs @@ -38,6 +38,7 @@ #endif using System; using System.ComponentModel; +using UniformTypeIdentifiers; namespace QuickLook { #if !MONOMAC @@ -170,6 +171,88 @@ interface QLPreviewItem { #endif } + delegate bool QLPreviewReplyDrawingHandler (CGContext context, QLPreviewReply reply, out NSError error); + delegate NSData QLPreviewReplyDataCreationHandler (QLPreviewReply reply, out NSError error); + delegate CGPDFDocument QLPreviewReply_UIDocumentCreationHandler (QLPreviewReply reply, out NSError error); + + [NoWatch, NoTV, Mac (12,0), iOS (15,0), MacCatalyst (15,0)] + [BaseType (typeof(NSObject))] + interface QLPreviewReply + { + [Export ("stringEncoding")] + nuint StringEncoding { get; set; } + + [Export ("attachments", ArgumentSemantic.Copy)] + NSDictionary Attachments { get; set; } + + [Export ("title")] + string Title { get; set; } + + [Export ("initWithContextSize:isBitmap:drawingBlock:")] + IntPtr Constructor (CGSize contextSize, bool isBitmap, QLPreviewReplyDrawingHandler drawingHandler); + + [Export ("initWithFileURL:")] + IntPtr Constructor (NSUrl fileURL); + + [Export ("initWithDataOfContentType:contentSize:dataCreationBlock:")] + IntPtr Constructor (UTType contentType, CGSize contentSize, QLPreviewReplyDataCreationHandler dataCreationHandler); + + // QLPreviewReply_UI + [Export ("initForPDFWithPageSize:documentCreationBlock:")] + IntPtr Constructor (CGSize defaultPageSize, QLPreviewReply_UIDocumentCreationHandler documentCreationHandler); + } + + [NoWatch, NoTV, Mac (12,0), iOS (15,0), MacCatalyst (15,0)] + [BaseType (typeof(NSObject))] + interface QLPreviewReplyAttachment + { + [Export ("data")] + NSData Data { get; } + + [Export ("contentType")] + UTType ContentType { get; } + + [Export ("initWithData:contentType:")] + IntPtr Constructor (NSData data, UTType contentType); + } + + [NoWatch, NoTV, Mac (12,0), iOS (15,0), MacCatalyst (15,0)] + [BaseType (typeof(NSObject))] + interface QLFilePreviewRequest + { + [Export ("fileURL")] + NSUrl FileURL { get; } + } + + [NoWatch, NoTV, Mac (12,0), iOS (15,0), MacCatalyst (15,0)] + [BaseType (typeof(NSObject))] + interface QLPreviewProvider : NSExtensionRequestHandling + { + } + + [iOS (15,0), MacCatalyst (15,0)] + [BaseType (typeof(NSObject))] + interface QLPreviewSceneOptions + { + [Export ("initialPreviewIndex")] + nint InitialPreviewIndex { get; set; } + } + + // TODO: BaseType UIWindowSceneActivationConfiguration must first be implemented in UIKit + // [iOS (15,0), NoMacCatalyst] + // [Advice ("This API is not available when using UIKit on macOS.")] + // [BaseType (typeof(UIWindowSceneActivationConfiguration))] + // interface QLPreviewSceneActivationConfiguration + // { + // [Export ("initWithItemsAtURLs:options:")] + // [DesignatedInitializer] + // IntPtr Constructor (NSUrl[] urls, [NullAllowed] QLPreviewSceneOptions options); + + // [Export ("initWithUserActivity:")] + // [DesignatedInitializer] + // IntPtr Constructor (NSUserActivity userActivity); + // } + [iOS (11,0)] [Protocol] interface QLPreviewingController { @@ -178,6 +261,10 @@ interface QLPreviewingController { [Export ("preparePreviewOfFileAtURL:completionHandler:")] void PreparePreviewOfFile (NSUrl url, Action handler); + + [iOS (15,0), Mac (12,0), MacCatalyst (15,0)] + [Export ("providePreviewForFileRequest:completionHandler:")] + void ProvidePreview (QLFilePreviewRequest request, Action handler); } #else [Static] diff --git a/tests/introspection/iOS/iOSApiProtocolTest.cs b/tests/introspection/iOS/iOSApiProtocolTest.cs index 9b454b5d1f1f..ba8c08e608dd 100644 --- a/tests/introspection/iOS/iOSApiProtocolTest.cs +++ b/tests/introspection/iOS/iOSApiProtocolTest.cs @@ -443,6 +443,8 @@ protected override bool Skip (Type type, string protocolName) case "NSMergePolicy": case "SFSafariViewControllerPrewarmingToken": // conformance not in headers case "SRTextInputSession": // conformance not in headers + case "QLPreviewReply": // conformance not in headers + case "QLPreviewReplyAttachment": // conformance not in headers return true; } break; @@ -684,6 +686,8 @@ protected override bool Skip (Type type, string protocolName) case "NSMergePolicy": case "SFSafariViewControllerPrewarmingToken": // conformance not in headers case "SRTextInputSession": // conformance not in headers + case "QLPreviewReply": // conformance not in headers + case "QLPreviewReplyAttachment": // conformance not in headers return true; } break; diff --git a/tests/xtro-sharpie/MacCatalyst-QuickLook.todo b/tests/xtro-sharpie/MacCatalyst-QuickLook.todo index 097b40abe020..c8fa3a6aea90 100644 --- a/tests/xtro-sharpie/MacCatalyst-QuickLook.todo +++ b/tests/xtro-sharpie/MacCatalyst-QuickLook.todo @@ -1,27 +1,4 @@ !extra-null-allowed! 'CoreGraphics.CGRect QuickLook.QLPreviewControllerDelegate::FrameForPreviewItem(QuickLook.QLPreviewController,QuickLook.IQLPreviewItem,UIKit.UIView&)' has a extraneous [NullAllowed] on parameter #2 !incorrect-protocol-member! QLPreviewItem::previewItemTitle is OPTIONAL and should NOT be abstract -## appended from unclassified file -!missing-protocol-member! QLPreviewingController::providePreviewForFileRequest:completionHandler: not found -!missing-selector! QLFilePreviewRequest::fileURL not bound -!missing-selector! QLPreviewReply::attachments not bound -!missing-selector! QLPreviewReply::initForPDFWithPageSize:documentCreationBlock: not bound -!missing-selector! QLPreviewReply::initWithContextSize:isBitmap:drawingBlock: not bound -!missing-selector! QLPreviewReply::initWithDataOfContentType:contentSize:dataCreationBlock: not bound -!missing-selector! QLPreviewReply::initWithFileURL: not bound -!missing-selector! QLPreviewReply::setAttachments: not bound -!missing-selector! QLPreviewReply::setStringEncoding: not bound -!missing-selector! QLPreviewReply::setTitle: not bound -!missing-selector! QLPreviewReply::stringEncoding not bound -!missing-selector! QLPreviewReply::title not bound -!missing-selector! QLPreviewReplyAttachment::contentType not bound -!missing-selector! QLPreviewReplyAttachment::data not bound -!missing-selector! QLPreviewReplyAttachment::initWithData:contentType: not bound -!missing-type! QLFilePreviewRequest not bound -!missing-type! QLPreviewProvider not bound -!missing-type! QLPreviewReply not bound -!missing-type! QLPreviewReplyAttachment not bound !missing-selector! QLPreviewSceneActivationConfiguration::initWithItemsAtURLs:options: not bound -!missing-selector! QLPreviewSceneOptions::initialPreviewIndex not bound -!missing-selector! QLPreviewSceneOptions::setInitialPreviewIndex: not bound !missing-type! QLPreviewSceneActivationConfiguration not bound -!missing-type! QLPreviewSceneOptions not bound diff --git a/tests/xtro-sharpie/iOS-QuickLook.todo b/tests/xtro-sharpie/iOS-QuickLook.todo index dd5c9559f13b..6abdf71e7470 100644 --- a/tests/xtro-sharpie/iOS-QuickLook.todo +++ b/tests/xtro-sharpie/iOS-QuickLook.todo @@ -1,24 +1,2 @@ -!missing-protocol-member! QLPreviewingController::providePreviewForFileRequest:completionHandler: not found -!missing-selector! QLFilePreviewRequest::fileURL not bound -!missing-selector! QLPreviewReply::attachments not bound -!missing-selector! QLPreviewReply::initForPDFWithPageSize:documentCreationBlock: not bound -!missing-selector! QLPreviewReply::initWithContextSize:isBitmap:drawingBlock: not bound -!missing-selector! QLPreviewReply::initWithDataOfContentType:contentSize:dataCreationBlock: not bound -!missing-selector! QLPreviewReply::initWithFileURL: not bound -!missing-selector! QLPreviewReply::setAttachments: not bound -!missing-selector! QLPreviewReply::setStringEncoding: not bound -!missing-selector! QLPreviewReply::setTitle: not bound -!missing-selector! QLPreviewReply::stringEncoding not bound -!missing-selector! QLPreviewReply::title not bound -!missing-selector! QLPreviewReplyAttachment::contentType not bound -!missing-selector! QLPreviewReplyAttachment::data not bound -!missing-selector! QLPreviewReplyAttachment::initWithData:contentType: not bound -!missing-type! QLFilePreviewRequest not bound -!missing-type! QLPreviewProvider not bound -!missing-type! QLPreviewReply not bound -!missing-type! QLPreviewReplyAttachment not bound !missing-selector! QLPreviewSceneActivationConfiguration::initWithItemsAtURLs:options: not bound -!missing-selector! QLPreviewSceneOptions::initialPreviewIndex not bound -!missing-selector! QLPreviewSceneOptions::setInitialPreviewIndex: not bound !missing-type! QLPreviewSceneActivationConfiguration not bound -!missing-type! QLPreviewSceneOptions not bound From 6adb0c56e73a9715cc7799e45b20f1b3ac126177 Mon Sep 17 00:00:00 2001 From: Rachel Kang Date: Tue, 3 Aug 2021 16:53:02 -0400 Subject: [PATCH 2/4] Update catalyst availability of API to be introduced --- src/quicklook.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/quicklook.cs b/src/quicklook.cs index 5c42694b7b31..e2cd731eea72 100644 --- a/src/quicklook.cs +++ b/src/quicklook.cs @@ -239,8 +239,7 @@ interface QLPreviewSceneOptions } // TODO: BaseType UIWindowSceneActivationConfiguration must first be implemented in UIKit - // [iOS (15,0), NoMacCatalyst] - // [Advice ("This API is not available when using UIKit on macOS.")] + // [iOS (15,0), MacCatalyst (15,0)] // [BaseType (typeof(UIWindowSceneActivationConfiguration))] // interface QLPreviewSceneActivationConfiguration // { From cae72a9fa7c7b53752a3cdc5fba4688ddcfdceb3 Mon Sep 17 00:00:00 2001 From: Rachel Kang Date: Thu, 5 Aug 2021 10:47:56 -0400 Subject: [PATCH 3/4] Update based on feedback --- src/quicklook.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/quicklook.cs b/src/quicklook.cs index e2cd731eea72..9520204c8bf0 100644 --- a/src/quicklook.cs +++ b/src/quicklook.cs @@ -173,7 +173,7 @@ interface QLPreviewItem { delegate bool QLPreviewReplyDrawingHandler (CGContext context, QLPreviewReply reply, out NSError error); delegate NSData QLPreviewReplyDataCreationHandler (QLPreviewReply reply, out NSError error); - delegate CGPDFDocument QLPreviewReply_UIDocumentCreationHandler (QLPreviewReply reply, out NSError error); + delegate CGPDFDocument QLPreviewReplyUIDocumentCreationHandler (QLPreviewReply reply, out NSError error); [NoWatch, NoTV, Mac (12,0), iOS (15,0), MacCatalyst (15,0)] [BaseType (typeof(NSObject))] @@ -192,14 +192,14 @@ interface QLPreviewReply IntPtr Constructor (CGSize contextSize, bool isBitmap, QLPreviewReplyDrawingHandler drawingHandler); [Export ("initWithFileURL:")] - IntPtr Constructor (NSUrl fileURL); + IntPtr Constructor (NSUrl fileUrl); [Export ("initWithDataOfContentType:contentSize:dataCreationBlock:")] IntPtr Constructor (UTType contentType, CGSize contentSize, QLPreviewReplyDataCreationHandler dataCreationHandler); // QLPreviewReply_UI [Export ("initForPDFWithPageSize:documentCreationBlock:")] - IntPtr Constructor (CGSize defaultPageSize, QLPreviewReply_UIDocumentCreationHandler documentCreationHandler); + IntPtr Constructor (CGSize defaultPageSize, QLPreviewReplyUIDocumentCreationHandler documentCreationHandler); } [NoWatch, NoTV, Mac (12,0), iOS (15,0), MacCatalyst (15,0)] @@ -221,16 +221,17 @@ interface QLPreviewReplyAttachment interface QLFilePreviewRequest { [Export ("fileURL")] - NSUrl FileURL { get; } + NSUrl FileUrl { get; } } [NoWatch, NoTV, Mac (12,0), iOS (15,0), MacCatalyst (15,0)] + [DisableDefaultCtor] [BaseType (typeof(NSObject))] interface QLPreviewProvider : NSExtensionRequestHandling { } - [iOS (15,0), MacCatalyst (15,0)] + [NoWatch, NoTV, NoMac, iOS (15,0), MacCatalyst (15,0)] [BaseType (typeof(NSObject))] interface QLPreviewSceneOptions { From 75ac7eb7b4a3c754506addfc88c11e4b0ae3d9ac Mon Sep 17 00:00:00 2001 From: Rachel Kang Date: Thu, 5 Aug 2021 11:12:01 -0400 Subject: [PATCH 4/4] Add comment about NoPlatform availabilities --- src/quicklook.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/quicklook.cs b/src/quicklook.cs index 9520204c8bf0..1df0f5bea090 100644 --- a/src/quicklook.cs +++ b/src/quicklook.cs @@ -231,7 +231,8 @@ interface QLPreviewProvider : NSExtensionRequestHandling { } - [NoWatch, NoTV, NoMac, iOS (15,0), MacCatalyst (15,0)] + [NoWatch][NoTV][NoMac] // availability not mentioned in the header files + [iOS (15,0), MacCatalyst (15,0)] [BaseType (typeof(NSObject))] interface QLPreviewSceneOptions {