From d961c2f38af8c55d83b97207c3aa15982ba5ab3f Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 25 Nov 2024 16:56:33 -0800 Subject: [PATCH] Fix headers --- .../Sources/cupertino_http/utils.h | 20 +++++++++++++++++++ .../Sources/cupertino_http/utils.m | 19 ++---------------- 2 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.h diff --git a/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.h b/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.h new file mode 100644 index 0000000000..0786ebb6d6 --- /dev/null +++ b/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.h @@ -0,0 +1,20 @@ +#import +#import +#import +#include + +#if !__has_feature(objc_arc) +#error "This file must be compiled with ARC enabled" +#endif + +typedef void (^_DidFinish)(void *closure, NSURLSession *session, + NSURLSessionDownloadTask *downloadTask, + NSURL *location); +typedef void (^_DidFinishWithLock)(NSCondition *lock, NSURLSession *session, + NSURLSessionDownloadTask *downloadTask, + NSURL *location); +/// Create a block useable as a +/// `URLSession:downloadTask:didFinishDownloadingToURL:` that can be used to +/// make an async Dart callback behave synchronously. +__attribute__((visibility("default"))) __attribute__((used)) +_DidFinish adaptFinishWithLock(_DidFinishWithLock block); diff --git a/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.m b/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.m index d990d5b967..7095650d18 100644 --- a/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.m +++ b/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/utils.m @@ -1,21 +1,6 @@ -#import -#import -#import -#include +#include "utils.h" -#if !__has_feature(objc_arc) -#error "This file must be compiled with ARC enabled" -#endif - -typedef void (^_DidFinish)(void *closure, NSURLSession *session, - NSURLSessionDownloadTask *downloadTask, - NSURL *location); -typedef void (^_DidFinishWithLock)(NSCondition *lock, NSURLSession *session, - NSURLSessionDownloadTask *downloadTask, - NSURL *location); - -__attribute__((visibility("default"))) __attribute__((used)) _DidFinish -adaptFinishWithLock(_DidFinishWithLock block) { +_DidFinish adaptFinishWithLock(_DidFinishWithLock block) { return ^void(void *closure, NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location) { NSCondition *lock = [[NSCondition alloc] init];