diff --git a/src/generator.cs b/src/generator.cs index 0cf881570ae0..833b177b7547 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..1df0f5bea090 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,89 @@ interface QLPreviewItem { #endif } + delegate bool QLPreviewReplyDrawingHandler (CGContext context, QLPreviewReply reply, out NSError error); + delegate NSData QLPreviewReplyDataCreationHandler (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))] + 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, QLPreviewReplyUIDocumentCreationHandler 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)] + [DisableDefaultCtor] + [BaseType (typeof(NSObject))] + interface QLPreviewProvider : NSExtensionRequestHandling + { + } + + [NoWatch][NoTV][NoMac] // availability not mentioned in the header files + [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), MacCatalyst (15,0)] + // [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 +262,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 7c09fc8aad03..714ee2b3a32e 100644 --- a/tests/introspection/iOS/iOSApiProtocolTest.cs +++ b/tests/introspection/iOS/iOSApiProtocolTest.cs @@ -444,6 +444,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; @@ -685,6 +687,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