diff --git a/pkgs/cupertino_http/CHANGELOG.md b/pkgs/cupertino_http/CHANGELOG.md index 898f0bb7eb..957a2171d0 100644 --- a/pkgs/cupertino_http/CHANGELOG.md +++ b/pkgs/cupertino_http/CHANGELOG.md @@ -1,6 +1,7 @@ ## 3.0.0-wip * Remove `shouldUseExtendedBackgroundIdleMode` from `URLSessionConfiguration`. +* Exclude unnecessary generated code. Slightly reduces disk space requirements. ## 2.4.0 diff --git a/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/native_cupertino_bindings.m b/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/native_cupertino_bindings.m index d255bc826c..aae636a34a 100644 --- a/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/native_cupertino_bindings.m +++ b/pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/native_cupertino_bindings.m @@ -59,48 +59,25 @@ }; -typedef void (^_ListenerTrampoline)(void); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline _NativeCupertinoHttp_wrapListenerBlock_1pl9qdv(_ListenerTrampoline block) NS_RETURNS_RETAINED { - return ^void() { - objc_retainBlock(block); - block(); - }; -} - -typedef void (^_BlockingTrampoline)(void * waiter); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline _NativeCupertinoHttp_wrapBlockingBlock_1pl9qdv( - _BlockingTrampoline block, _BlockingTrampoline listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(), { - objc_retainBlock(block); - block(nil); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter); - }); -} - typedef BOOL (^_ProtocolTrampoline)(void * sel); __attribute__((visibility("default"))) __attribute__((used)) BOOL _NativeCupertinoHttp_protocolTrampoline_e3qsqz(id target, void * sel) { return ((_ProtocolTrampoline)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); } -typedef void (^_ListenerTrampoline_1)(void * arg0, id arg1); +typedef void (^_ListenerTrampoline)(void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_1 _NativeCupertinoHttp_wrapListenerBlock_18v1jvf(_ListenerTrampoline_1 block) NS_RETURNS_RETAINED { +_ListenerTrampoline _NativeCupertinoHttp_wrapListenerBlock_18v1jvf(_ListenerTrampoline block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1)); }; } -typedef void (^_BlockingTrampoline_1)(void * waiter, void * arg0, id arg1); +typedef void (^_BlockingTrampoline)(void * waiter, void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_1 _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( - _BlockingTrampoline_1 block, _BlockingTrampoline_1 listenerBlock, +_ListenerTrampoline _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( + _BlockingTrampoline block, _BlockingTrampoline listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1), { objc_retainBlock(block); @@ -123,19 +100,19 @@ id _NativeCupertinoHttp_protocolTrampoline_xr62hr(id target, void * sel, id arg return ((_ProtocolTrampoline_2)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); } -typedef void (^_ListenerTrampoline_2)(id arg0); +typedef void (^_ListenerTrampoline_1)(id arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_2 _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(_ListenerTrampoline_2 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_1 _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(_ListenerTrampoline_1 block) NS_RETURNS_RETAINED { return ^void(id arg0) { objc_retainBlock(block); block((__bridge id)(__bridge_retained void*)(arg0)); }; } -typedef void (^_BlockingTrampoline_2)(void * waiter, id arg0); +typedef void (^_BlockingTrampoline_1)(void * waiter, id arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_2 _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - _BlockingTrampoline_2 block, _BlockingTrampoline_2 listenerBlock, +_ListenerTrampoline_1 _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( + _BlockingTrampoline_1 block, _BlockingTrampoline_1 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0), { objc_retainBlock(block); @@ -152,232 +129,65 @@ id _NativeCupertinoHttp_protocolTrampoline_1mbt9g9(id target, void * sel) { return ((_ProtocolTrampoline_3)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); } -typedef unsigned long (^_ProtocolTrampoline_4)(void * sel, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3); -__attribute__((visibility("default"))) __attribute__((used)) -unsigned long _NativeCupertinoHttp_protocolTrampoline_17ap02x(id target, void * sel, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3) { - return ((_ProtocolTrampoline_4)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); -} - -typedef void (^_ListenerTrampoline_3)(struct __CFRunLoopObserver * arg0, CFRunLoopActivity arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_3 _NativeCupertinoHttp_wrapListenerBlock_tg5tbv(_ListenerTrampoline_3 block) NS_RETURNS_RETAINED { - return ^void(struct __CFRunLoopObserver * arg0, CFRunLoopActivity arg1) { - objc_retainBlock(block); - block(arg0, arg1); - }; -} - -typedef void (^_BlockingTrampoline_3)(void * waiter, struct __CFRunLoopObserver * arg0, CFRunLoopActivity arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_3 _NativeCupertinoHttp_wrapBlockingBlock_tg5tbv( - _BlockingTrampoline_3 block, _BlockingTrampoline_3 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(struct __CFRunLoopObserver * arg0, CFRunLoopActivity arg1), { - objc_retainBlock(block); - block(nil, arg0, arg1); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, arg1); - }); -} - -typedef void (^_ListenerTrampoline_4)(struct __CFRunLoopTimer * arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_4 _NativeCupertinoHttp_wrapListenerBlock_1dqvvol(_ListenerTrampoline_4 block) NS_RETURNS_RETAINED { - return ^void(struct __CFRunLoopTimer * arg0) { - objc_retainBlock(block); - block(arg0); - }; -} - -typedef void (^_BlockingTrampoline_4)(void * waiter, struct __CFRunLoopTimer * arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_4 _NativeCupertinoHttp_wrapBlockingBlock_1dqvvol( - _BlockingTrampoline_4 block, _BlockingTrampoline_4 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(struct __CFRunLoopTimer * arg0), { - objc_retainBlock(block); - block(nil, arg0); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0); - }); -} - -typedef void (^_ListenerTrampoline_5)(size_t arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_5 _NativeCupertinoHttp_wrapListenerBlock_6enxqz(_ListenerTrampoline_5 block) NS_RETURNS_RETAINED { - return ^void(size_t arg0) { - objc_retainBlock(block); - block(arg0); - }; -} - -typedef void (^_BlockingTrampoline_5)(void * waiter, size_t arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_5 _NativeCupertinoHttp_wrapBlockingBlock_6enxqz( - _BlockingTrampoline_5 block, _BlockingTrampoline_5 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(size_t arg0), { - objc_retainBlock(block); - block(nil, arg0); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0); - }); -} - -typedef void (^_ListenerTrampoline_6)(id arg0, int arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_6 _NativeCupertinoHttp_wrapListenerBlock_18kzm6a(_ListenerTrampoline_6 block) NS_RETURNS_RETAINED { - return ^void(id arg0, int arg1) { - objc_retainBlock(block); - block((__bridge id)(__bridge_retained void*)(arg0), arg1); - }; -} - -typedef void (^_BlockingTrampoline_6)(void * waiter, id arg0, int arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_6 _NativeCupertinoHttp_wrapBlockingBlock_18kzm6a( - _BlockingTrampoline_6 block, _BlockingTrampoline_6 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, int arg1), { - objc_retainBlock(block); - block(nil, (__bridge id)(__bridge_retained void*)(arg0), arg1); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), arg1); - }); -} - -typedef void (^_ListenerTrampoline_7)(int arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_7 _NativeCupertinoHttp_wrapListenerBlock_9o8504(_ListenerTrampoline_7 block) NS_RETURNS_RETAINED { - return ^void(int arg0) { - objc_retainBlock(block); - block(arg0); - }; -} - -typedef void (^_BlockingTrampoline_7)(void * waiter, int arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_7 _NativeCupertinoHttp_wrapBlockingBlock_9o8504( - _BlockingTrampoline_7 block, _BlockingTrampoline_7 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(int arg0), { - objc_retainBlock(block); - block(nil, arg0); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0); - }); -} - -typedef void (^_ListenerTrampoline_8)(BOOL arg0, id arg1, int arg2); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_8 _NativeCupertinoHttp_wrapListenerBlock_og5b6y(_ListenerTrampoline_8 block) NS_RETURNS_RETAINED { - return ^void(BOOL arg0, id arg1, int arg2) { - objc_retainBlock(block); - block(arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); - }; -} - -typedef void (^_BlockingTrampoline_8)(void * waiter, BOOL arg0, id arg1, int arg2); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_8 _NativeCupertinoHttp_wrapBlockingBlock_og5b6y( - _BlockingTrampoline_8 block, _BlockingTrampoline_8 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(BOOL arg0, id arg1, int arg2), { - objc_retainBlock(block); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); - }); -} - -typedef void (^_ListenerTrampoline_9)(struct __SecTrust * arg0, SecTrustResultType arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_9 _NativeCupertinoHttp_wrapListenerBlock_gwxhxt(_ListenerTrampoline_9 block) NS_RETURNS_RETAINED { - return ^void(struct __SecTrust * arg0, SecTrustResultType arg1) { - objc_retainBlock(block); - block(arg0, arg1); - }; -} - -typedef void (^_BlockingTrampoline_9)(void * waiter, struct __SecTrust * arg0, SecTrustResultType arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_9 _NativeCupertinoHttp_wrapBlockingBlock_gwxhxt( - _BlockingTrampoline_9 block, _BlockingTrampoline_9 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(struct __SecTrust * arg0, SecTrustResultType arg1), { - objc_retainBlock(block); - block(nil, arg0, arg1); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, arg1); - }); -} - -typedef void (^_ListenerTrampoline_10)(struct __SecTrust * arg0, BOOL arg1, struct __CFError * arg2); +typedef void (^_ListenerTrampoline_2)(void); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_10 _NativeCupertinoHttp_wrapListenerBlock_k73ff5(_ListenerTrampoline_10 block) NS_RETURNS_RETAINED { - return ^void(struct __SecTrust * arg0, BOOL arg1, struct __CFError * arg2) { +_ListenerTrampoline_2 _NativeCupertinoHttp_wrapListenerBlock_1pl9qdv(_ListenerTrampoline_2 block) NS_RETURNS_RETAINED { + return ^void() { objc_retainBlock(block); - block(arg0, arg1, arg2); + block(); }; } -typedef void (^_BlockingTrampoline_10)(void * waiter, struct __SecTrust * arg0, BOOL arg1, struct __CFError * arg2); +typedef void (^_BlockingTrampoline_2)(void * waiter); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_10 _NativeCupertinoHttp_wrapBlockingBlock_k73ff5( - _BlockingTrampoline_10 block, _BlockingTrampoline_10 listenerBlock, +_ListenerTrampoline_2 _NativeCupertinoHttp_wrapBlockingBlock_1pl9qdv( + _BlockingTrampoline_2 block, _BlockingTrampoline_2 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(struct __SecTrust * arg0, BOOL arg1, struct __CFError * arg2), { + BLOCKING_BLOCK_IMPL(ctx, ^void(), { objc_retainBlock(block); - block(nil, arg0, arg1, arg2); + block(nil); }, { objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, arg1, arg2); + listenerBlock(waiter); }); } -typedef void (^_ListenerTrampoline_11)(uint16_t arg0); +typedef void (^_ListenerTrampoline_3)(id arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_11 _NativeCupertinoHttp_wrapListenerBlock_15f11yh(_ListenerTrampoline_11 block) NS_RETURNS_RETAINED { - return ^void(uint16_t arg0) { +_ListenerTrampoline_3 _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(_ListenerTrampoline_3 block) NS_RETURNS_RETAINED { + return ^void(id arg0, id arg1, id arg2) { objc_retainBlock(block); - block(arg0); + block((__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); }; } -typedef void (^_BlockingTrampoline_11)(void * waiter, uint16_t arg0); +typedef void (^_BlockingTrampoline_3)(void * waiter, id arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_11 _NativeCupertinoHttp_wrapBlockingBlock_15f11yh( - _BlockingTrampoline_11 block, _BlockingTrampoline_11 listenerBlock, +_ListenerTrampoline_3 _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( + _BlockingTrampoline_3 block, _BlockingTrampoline_3 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(uint16_t arg0), { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1, id arg2), { objc_retainBlock(block); - block(nil, arg0); + block(nil, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); }, { objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); }); } -typedef void (^_ListenerTrampoline_12)(id arg0, id arg1); +typedef void (^_ListenerTrampoline_4)(id arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_12 _NativeCupertinoHttp_wrapListenerBlock_pfv6jd(_ListenerTrampoline_12 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_4 _NativeCupertinoHttp_wrapListenerBlock_pfv6jd(_ListenerTrampoline_4 block) NS_RETURNS_RETAINED { return ^void(id arg0, id arg1) { objc_retainBlock(block); block((__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1)); }; } -typedef void (^_BlockingTrampoline_12)(void * waiter, id arg0, id arg1); +typedef void (^_BlockingTrampoline_4)(void * waiter, id arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_12 _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( - _BlockingTrampoline_12 block, _BlockingTrampoline_12 listenerBlock, +_ListenerTrampoline_4 _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( + _BlockingTrampoline_4 block, _BlockingTrampoline_4 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1), { objc_retainBlock(block); @@ -388,111 +198,19 @@ _ListenerTrampoline_12 _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( }); } -typedef void (^_ListenerTrampoline_13)(id arg0, id arg1, id arg2); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_13 _NativeCupertinoHttp_wrapListenerBlock_18qun1e(_ListenerTrampoline_13 block) NS_RETURNS_RETAINED { - return ^void(id arg0, id arg1, id arg2) { - objc_retainBlock(block); - block((__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), objc_retainBlock(arg2)); - }; -} - -typedef void (^_BlockingTrampoline_13)(void * waiter, id arg0, id arg1, id arg2); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_13 _NativeCupertinoHttp_wrapBlockingBlock_18qun1e( - _BlockingTrampoline_13 block, _BlockingTrampoline_13 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1, id arg2), { - objc_retainBlock(block); - block(nil, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), objc_retainBlock(arg2)); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), objc_retainBlock(arg2)); - }); -} - -typedef void (^_ListenerTrampoline_14)(id arg0, id arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_14 _NativeCupertinoHttp_wrapListenerBlock_o762yo(_ListenerTrampoline_14 block) NS_RETURNS_RETAINED { - return ^void(id arg0, id arg1) { - objc_retainBlock(block); - block((__bridge id)(__bridge_retained void*)(arg0), objc_retainBlock(arg1)); - }; -} - -typedef void (^_BlockingTrampoline_14)(void * waiter, id arg0, id arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_14 _NativeCupertinoHttp_wrapBlockingBlock_o762yo( - _BlockingTrampoline_14 block, _BlockingTrampoline_14 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1), { - objc_retainBlock(block); - block(nil, (__bridge id)(__bridge_retained void*)(arg0), objc_retainBlock(arg1)); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), objc_retainBlock(arg1)); - }); -} - -typedef void (^_ListenerTrampoline_15)(BOOL arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_15 _NativeCupertinoHttp_wrapListenerBlock_1s56lr9(_ListenerTrampoline_15 block) NS_RETURNS_RETAINED { - return ^void(BOOL arg0) { - objc_retainBlock(block); - block(arg0); - }; -} - -typedef void (^_BlockingTrampoline_15)(void * waiter, BOOL arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_15 _NativeCupertinoHttp_wrapBlockingBlock_1s56lr9( - _BlockingTrampoline_15 block, _BlockingTrampoline_15 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(BOOL arg0), { - objc_retainBlock(block); - block(nil, arg0); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0); - }); -} - -typedef void (^_ListenerTrampoline_16)(id arg0, id arg1, id arg2); +typedef void (^_ListenerTrampoline_5)(NSURLSessionResponseDisposition arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_16 _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(_ListenerTrampoline_16 block) NS_RETURNS_RETAINED { - return ^void(id arg0, id arg1, id arg2) { - objc_retainBlock(block); - block((__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); - }; -} - -typedef void (^_BlockingTrampoline_16)(void * waiter, id arg0, id arg1, id arg2); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_16 _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( - _BlockingTrampoline_16 block, _BlockingTrampoline_16 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1, id arg2), { - objc_retainBlock(block); - block(nil, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); - }); -} - -typedef void (^_ListenerTrampoline_17)(NSURLSessionResponseDisposition arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_17 _NativeCupertinoHttp_wrapListenerBlock_16sve1d(_ListenerTrampoline_17 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_5 _NativeCupertinoHttp_wrapListenerBlock_16sve1d(_ListenerTrampoline_5 block) NS_RETURNS_RETAINED { return ^void(NSURLSessionResponseDisposition arg0) { objc_retainBlock(block); block(arg0); }; } -typedef void (^_BlockingTrampoline_17)(void * waiter, NSURLSessionResponseDisposition arg0); +typedef void (^_BlockingTrampoline_5)(void * waiter, NSURLSessionResponseDisposition arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_17 _NativeCupertinoHttp_wrapBlockingBlock_16sve1d( - _BlockingTrampoline_17 block, _BlockingTrampoline_17 listenerBlock, +_ListenerTrampoline_5 _NativeCupertinoHttp_wrapBlockingBlock_16sve1d( + _BlockingTrampoline_5 block, _BlockingTrampoline_5 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(NSURLSessionResponseDisposition arg0), { objc_retainBlock(block); @@ -503,19 +221,19 @@ _ListenerTrampoline_17 _NativeCupertinoHttp_wrapBlockingBlock_16sve1d( }); } -typedef void (^_ListenerTrampoline_18)(NSURLSessionDelayedRequestDisposition arg0, id arg1); +typedef void (^_ListenerTrampoline_6)(NSURLSessionDelayedRequestDisposition arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_18 _NativeCupertinoHttp_wrapListenerBlock_1otpo83(_ListenerTrampoline_18 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_6 _NativeCupertinoHttp_wrapListenerBlock_1otpo83(_ListenerTrampoline_6 block) NS_RETURNS_RETAINED { return ^void(NSURLSessionDelayedRequestDisposition arg0, id arg1) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1)); }; } -typedef void (^_BlockingTrampoline_18)(void * waiter, NSURLSessionDelayedRequestDisposition arg0, id arg1); +typedef void (^_BlockingTrampoline_6)(void * waiter, NSURLSessionDelayedRequestDisposition arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_18 _NativeCupertinoHttp_wrapBlockingBlock_1otpo83( - _BlockingTrampoline_18 block, _BlockingTrampoline_18 listenerBlock, +_ListenerTrampoline_6 _NativeCupertinoHttp_wrapBlockingBlock_1otpo83( + _BlockingTrampoline_6 block, _BlockingTrampoline_6 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(NSURLSessionDelayedRequestDisposition arg0, id arg1), { objc_retainBlock(block); @@ -526,19 +244,19 @@ _ListenerTrampoline_18 _NativeCupertinoHttp_wrapBlockingBlock_1otpo83( }); } -typedef void (^_ListenerTrampoline_19)(void * arg0, id arg1, id arg2, id arg3, id arg4); +typedef void (^_ListenerTrampoline_7)(void * arg0, id arg1, id arg2, id arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_19 _NativeCupertinoHttp_wrapListenerBlock_xx612k(_ListenerTrampoline_19 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_7 _NativeCupertinoHttp_wrapListenerBlock_xx612k(_ListenerTrampoline_7 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, id arg3, id arg4) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), (__bridge id)(__bridge_retained void*)(arg3), objc_retainBlock(arg4)); }; } -typedef void (^_BlockingTrampoline_19)(void * waiter, void * arg0, id arg1, id arg2, id arg3, id arg4); +typedef void (^_BlockingTrampoline_7)(void * waiter, void * arg0, id arg1, id arg2, id arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_19 _NativeCupertinoHttp_wrapBlockingBlock_xx612k( - _BlockingTrampoline_19 block, _BlockingTrampoline_19 listenerBlock, +_ListenerTrampoline_7 _NativeCupertinoHttp_wrapBlockingBlock_xx612k( + _BlockingTrampoline_7 block, _BlockingTrampoline_7 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, id arg3, id arg4), { objc_retainBlock(block); @@ -549,25 +267,25 @@ _ListenerTrampoline_19 _NativeCupertinoHttp_wrapBlockingBlock_xx612k( }); } -typedef void (^_ProtocolTrampoline_5)(void * sel, id arg1, id arg2, id arg3, id arg4); +typedef void (^_ProtocolTrampoline_4)(void * sel, id arg1, id arg2, id arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_xx612k(id target, void * sel, id arg1, id arg2, id arg3, id arg4) { - return ((_ProtocolTrampoline_5)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); + return ((_ProtocolTrampoline_4)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } -typedef void (^_ListenerTrampoline_20)(void * arg0, id arg1, id arg2, id arg3); +typedef void (^_ListenerTrampoline_8)(void * arg0, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_20 _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(_ListenerTrampoline_20 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_8 _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(_ListenerTrampoline_8 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, id arg3) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), (__bridge id)(__bridge_retained void*)(arg3)); }; } -typedef void (^_BlockingTrampoline_20)(void * waiter, void * arg0, id arg1, id arg2, id arg3); +typedef void (^_BlockingTrampoline_8)(void * waiter, void * arg0, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_20 _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - _BlockingTrampoline_20 block, _BlockingTrampoline_20 listenerBlock, +_ListenerTrampoline_8 _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + _BlockingTrampoline_8 block, _BlockingTrampoline_8 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, id arg3), { objc_retainBlock(block); @@ -578,25 +296,25 @@ _ListenerTrampoline_20 _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( }); } -typedef void (^_ProtocolTrampoline_6)(void * sel, id arg1, id arg2, id arg3); +typedef void (^_ProtocolTrampoline_5)(void * sel, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_1tz5yf(id target, void * sel, id arg1, id arg2, id arg3) { - return ((_ProtocolTrampoline_6)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); + return ((_ProtocolTrampoline_5)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); } -typedef void (^_ListenerTrampoline_21)(void * arg0, id arg1, id arg2); +typedef void (^_ListenerTrampoline_9)(void * arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_21 _NativeCupertinoHttp_wrapListenerBlock_fjrv01(_ListenerTrampoline_21 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_9 _NativeCupertinoHttp_wrapListenerBlock_fjrv01(_ListenerTrampoline_9 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); }; } -typedef void (^_BlockingTrampoline_21)(void * waiter, void * arg0, id arg1, id arg2); +typedef void (^_BlockingTrampoline_9)(void * waiter, void * arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_21 _NativeCupertinoHttp_wrapBlockingBlock_fjrv01( - _BlockingTrampoline_21 block, _BlockingTrampoline_21 listenerBlock, +_ListenerTrampoline_9 _NativeCupertinoHttp_wrapBlockingBlock_fjrv01( + _BlockingTrampoline_9 block, _BlockingTrampoline_9 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2), { objc_retainBlock(block); @@ -607,25 +325,25 @@ _ListenerTrampoline_21 _NativeCupertinoHttp_wrapBlockingBlock_fjrv01( }); } -typedef void (^_ProtocolTrampoline_7)(void * sel, id arg1, id arg2); +typedef void (^_ProtocolTrampoline_6)(void * sel, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_fjrv01(id target, void * sel, id arg1, id arg2) { - return ((_ProtocolTrampoline_7)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); + return ((_ProtocolTrampoline_6)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); } -typedef void (^_ListenerTrampoline_22)(void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5); +typedef void (^_ListenerTrampoline_10)(void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_22 _NativeCupertinoHttp_wrapListenerBlock_l2g8ke(_ListenerTrampoline_22 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_10 _NativeCupertinoHttp_wrapListenerBlock_l2g8ke(_ListenerTrampoline_10 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), (__bridge id)(__bridge_retained void*)(arg3), (__bridge id)(__bridge_retained void*)(arg4), objc_retainBlock(arg5)); }; } -typedef void (^_BlockingTrampoline_22)(void * waiter, void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5); +typedef void (^_BlockingTrampoline_10)(void * waiter, void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_22 _NativeCupertinoHttp_wrapBlockingBlock_l2g8ke( - _BlockingTrampoline_22 block, _BlockingTrampoline_22 listenerBlock, +_ListenerTrampoline_10 _NativeCupertinoHttp_wrapBlockingBlock_l2g8ke( + _BlockingTrampoline_10 block, _BlockingTrampoline_10 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5), { objc_retainBlock(block); @@ -636,25 +354,25 @@ _ListenerTrampoline_22 _NativeCupertinoHttp_wrapBlockingBlock_l2g8ke( }); } -typedef void (^_ProtocolTrampoline_8)(void * sel, id arg1, id arg2, id arg3, id arg4, id arg5); +typedef void (^_ProtocolTrampoline_7)(void * sel, id arg1, id arg2, id arg3, id arg4, id arg5); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_l2g8ke(id target, void * sel, id arg1, id arg2, id arg3, id arg4, id arg5) { - return ((_ProtocolTrampoline_8)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4, arg5); + return ((_ProtocolTrampoline_7)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4, arg5); } -typedef void (^_ListenerTrampoline_23)(NSURLSessionAuthChallengeDisposition arg0, id arg1); +typedef void (^_ListenerTrampoline_11)(NSURLSessionAuthChallengeDisposition arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_23 _NativeCupertinoHttp_wrapListenerBlock_n8yd09(_ListenerTrampoline_23 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_11 _NativeCupertinoHttp_wrapListenerBlock_n8yd09(_ListenerTrampoline_11 block) NS_RETURNS_RETAINED { return ^void(NSURLSessionAuthChallengeDisposition arg0, id arg1) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1)); }; } -typedef void (^_BlockingTrampoline_23)(void * waiter, NSURLSessionAuthChallengeDisposition arg0, id arg1); +typedef void (^_BlockingTrampoline_11)(void * waiter, NSURLSessionAuthChallengeDisposition arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_23 _NativeCupertinoHttp_wrapBlockingBlock_n8yd09( - _BlockingTrampoline_23 block, _BlockingTrampoline_23 listenerBlock, +_ListenerTrampoline_11 _NativeCupertinoHttp_wrapBlockingBlock_n8yd09( + _BlockingTrampoline_11 block, _BlockingTrampoline_11 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(NSURLSessionAuthChallengeDisposition arg0, id arg1), { objc_retainBlock(block); @@ -665,19 +383,19 @@ _ListenerTrampoline_23 _NativeCupertinoHttp_wrapBlockingBlock_n8yd09( }); } -typedef void (^_ListenerTrampoline_24)(void * arg0, id arg1, id arg2, id arg3); +typedef void (^_ListenerTrampoline_12)(void * arg0, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_24 _NativeCupertinoHttp_wrapListenerBlock_bklti2(_ListenerTrampoline_24 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_12 _NativeCupertinoHttp_wrapListenerBlock_bklti2(_ListenerTrampoline_12 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, id arg3) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), objc_retainBlock(arg3)); }; } -typedef void (^_BlockingTrampoline_24)(void * waiter, void * arg0, id arg1, id arg2, id arg3); +typedef void (^_BlockingTrampoline_12)(void * waiter, void * arg0, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_24 _NativeCupertinoHttp_wrapBlockingBlock_bklti2( - _BlockingTrampoline_24 block, _BlockingTrampoline_24 listenerBlock, +_ListenerTrampoline_12 _NativeCupertinoHttp_wrapBlockingBlock_bklti2( + _BlockingTrampoline_12 block, _BlockingTrampoline_12 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, id arg3), { objc_retainBlock(block); @@ -688,25 +406,25 @@ _ListenerTrampoline_24 _NativeCupertinoHttp_wrapBlockingBlock_bklti2( }); } -typedef void (^_ProtocolTrampoline_9)(void * sel, id arg1, id arg2, id arg3); +typedef void (^_ProtocolTrampoline_8)(void * sel, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_bklti2(id target, void * sel, id arg1, id arg2, id arg3) { - return ((_ProtocolTrampoline_9)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); + return ((_ProtocolTrampoline_8)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); } -typedef void (^_ListenerTrampoline_25)(void * arg0, id arg1, id arg2, int64_t arg3, id arg4); +typedef void (^_ListenerTrampoline_13)(void * arg0, id arg1, id arg2, int64_t arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_25 _NativeCupertinoHttp_wrapListenerBlock_jyim80(_ListenerTrampoline_25 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_13 _NativeCupertinoHttp_wrapListenerBlock_jyim80(_ListenerTrampoline_13 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, int64_t arg3, id arg4) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, objc_retainBlock(arg4)); }; } -typedef void (^_BlockingTrampoline_25)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, id arg4); +typedef void (^_BlockingTrampoline_13)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_25 _NativeCupertinoHttp_wrapBlockingBlock_jyim80( - _BlockingTrampoline_25 block, _BlockingTrampoline_25 listenerBlock, +_ListenerTrampoline_13 _NativeCupertinoHttp_wrapBlockingBlock_jyim80( + _BlockingTrampoline_13 block, _BlockingTrampoline_13 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, int64_t arg3, id arg4), { objc_retainBlock(block); @@ -717,25 +435,25 @@ _ListenerTrampoline_25 _NativeCupertinoHttp_wrapBlockingBlock_jyim80( }); } -typedef void (^_ProtocolTrampoline_10)(void * sel, id arg1, id arg2, int64_t arg3, id arg4); +typedef void (^_ProtocolTrampoline_9)(void * sel, id arg1, id arg2, int64_t arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_jyim80(id target, void * sel, id arg1, id arg2, int64_t arg3, id arg4) { - return ((_ProtocolTrampoline_10)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); + return ((_ProtocolTrampoline_9)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } -typedef void (^_ListenerTrampoline_26)(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); +typedef void (^_ListenerTrampoline_14)(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_26 _NativeCupertinoHttp_wrapListenerBlock_h68abb(_ListenerTrampoline_26 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_14 _NativeCupertinoHttp_wrapListenerBlock_h68abb(_ListenerTrampoline_14 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, arg4, arg5); }; } -typedef void (^_BlockingTrampoline_26)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); +typedef void (^_BlockingTrampoline_14)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_26 _NativeCupertinoHttp_wrapBlockingBlock_h68abb( - _BlockingTrampoline_26 block, _BlockingTrampoline_26 listenerBlock, +_ListenerTrampoline_14 _NativeCupertinoHttp_wrapBlockingBlock_h68abb( + _BlockingTrampoline_14 block, _BlockingTrampoline_14 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5), { objc_retainBlock(block); @@ -746,27 +464,27 @@ _ListenerTrampoline_26 _NativeCupertinoHttp_wrapBlockingBlock_h68abb( }); } -typedef void (^_ProtocolTrampoline_11)(void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); +typedef void (^_ProtocolTrampoline_10)(void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_h68abb(id target, void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5) { - return ((_ProtocolTrampoline_11)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4, arg5); + return ((_ProtocolTrampoline_10)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4, arg5); } Protocol* _NativeCupertinoHttp_NSURLSessionDataDelegate(void) { return @protocol(NSURLSessionDataDelegate); } -typedef void (^_ListenerTrampoline_27)(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4); +typedef void (^_ListenerTrampoline_15)(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_27 _NativeCupertinoHttp_wrapListenerBlock_ly2579(_ListenerTrampoline_27 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_15 _NativeCupertinoHttp_wrapListenerBlock_ly2579(_ListenerTrampoline_15 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, arg4); }; } -typedef void (^_BlockingTrampoline_27)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4); +typedef void (^_BlockingTrampoline_15)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_27 _NativeCupertinoHttp_wrapBlockingBlock_ly2579( - _BlockingTrampoline_27 block, _BlockingTrampoline_27 listenerBlock, +_ListenerTrampoline_15 _NativeCupertinoHttp_wrapBlockingBlock_ly2579( + _BlockingTrampoline_15 block, _BlockingTrampoline_15 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4), { objc_retainBlock(block); @@ -777,27 +495,27 @@ _ListenerTrampoline_27 _NativeCupertinoHttp_wrapBlockingBlock_ly2579( }); } -typedef void (^_ProtocolTrampoline_12)(void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4); +typedef void (^_ProtocolTrampoline_11)(void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_ly2579(id target, void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4) { - return ((_ProtocolTrampoline_12)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); + return ((_ProtocolTrampoline_11)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } Protocol* _NativeCupertinoHttp_NSURLSessionDownloadDelegate(void) { return @protocol(NSURLSessionDownloadDelegate); } -typedef void (^_ListenerTrampoline_28)(void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); +typedef void (^_ListenerTrampoline_16)(void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_28 _NativeCupertinoHttp_wrapListenerBlock_1lx650f(_ListenerTrampoline_28 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_16 _NativeCupertinoHttp_wrapListenerBlock_1lx650f(_ListenerTrampoline_16 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, (__bridge id)(__bridge_retained void*)(arg4)); }; } -typedef void (^_BlockingTrampoline_28)(void * waiter, void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); +typedef void (^_BlockingTrampoline_16)(void * waiter, void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_28 _NativeCupertinoHttp_wrapBlockingBlock_1lx650f( - _BlockingTrampoline_28 block, _BlockingTrampoline_28 listenerBlock, +_ListenerTrampoline_16 _NativeCupertinoHttp_wrapBlockingBlock_1lx650f( + _BlockingTrampoline_16 block, _BlockingTrampoline_16 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4), { objc_retainBlock(block); @@ -808,68 +526,27 @@ _ListenerTrampoline_28 _NativeCupertinoHttp_wrapBlockingBlock_1lx650f( }); } -typedef void (^_ProtocolTrampoline_13)(void * sel, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); +typedef void (^_ProtocolTrampoline_12)(void * sel, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_1lx650f(id target, void * sel, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4) { - return ((_ProtocolTrampoline_13)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); + return ((_ProtocolTrampoline_12)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } Protocol* _NativeCupertinoHttp_NSURLSessionWebSocketDelegate(void) { return @protocol(NSURLSessionWebSocketDelegate); } -typedef void (^_ListenerTrampoline_29)(id arg0, id arg1, id arg2); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_29 _NativeCupertinoHttp_wrapListenerBlock_1b3bb6a(_ListenerTrampoline_29 block) NS_RETURNS_RETAINED { - return ^void(id arg0, id arg1, id arg2) { - objc_retainBlock(block); - block(objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); - }; -} - -typedef void (^_BlockingTrampoline_29)(void * waiter, id arg0, id arg1, id arg2); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_29 _NativeCupertinoHttp_wrapBlockingBlock_1b3bb6a( - _BlockingTrampoline_29 block, _BlockingTrampoline_29 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1, id arg2), { - objc_retainBlock(block); - block(nil, objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); - }); -} - -typedef id (^_ProtocolTrampoline_14)(void * sel, id arg1, id arg2, id * arg3); -__attribute__((visibility("default"))) __attribute__((used)) -id _NativeCupertinoHttp_protocolTrampoline_10z9f5k(id target, void * sel, id arg1, id arg2, id * arg3) { - return ((_ProtocolTrampoline_14)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); -} - -typedef NSItemProviderRepresentationVisibility (^_ProtocolTrampoline_15)(void * sel, id arg1); -__attribute__((visibility("default"))) __attribute__((used)) -NSItemProviderRepresentationVisibility _NativeCupertinoHttp_protocolTrampoline_1ldqghh(id target, void * sel, id arg1) { - return ((_ProtocolTrampoline_15)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); -} - -typedef id (^_ProtocolTrampoline_16)(void * sel, id arg1, id arg2); +typedef void (^_ListenerTrampoline_17)(void * arg0); __attribute__((visibility("default"))) __attribute__((used)) -id _NativeCupertinoHttp_protocolTrampoline_1q0i84(id target, void * sel, id arg1, id arg2) { - return ((_ProtocolTrampoline_16)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); -} - -typedef void (^_ListenerTrampoline_30)(void * arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_30 _NativeCupertinoHttp_wrapListenerBlock_ovsamd(_ListenerTrampoline_30 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_17 _NativeCupertinoHttp_wrapListenerBlock_ovsamd(_ListenerTrampoline_17 block) NS_RETURNS_RETAINED { return ^void(void * arg0) { objc_retainBlock(block); block(arg0); }; } -typedef void (^_BlockingTrampoline_30)(void * waiter, void * arg0); +typedef void (^_BlockingTrampoline_17)(void * waiter, void * arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_30 _NativeCupertinoHttp_wrapBlockingBlock_ovsamd( - _BlockingTrampoline_30 block, _BlockingTrampoline_30 listenerBlock, +_ListenerTrampoline_17 _NativeCupertinoHttp_wrapBlockingBlock_ovsamd( + _BlockingTrampoline_17 block, _BlockingTrampoline_17 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0), { objc_retainBlock(block); @@ -880,10 +557,10 @@ _ListenerTrampoline_30 _NativeCupertinoHttp_wrapBlockingBlock_ovsamd( }); } -typedef void (^_ProtocolTrampoline_17)(void * sel); +typedef void (^_ProtocolTrampoline_13)(void * sel); __attribute__((visibility("default"))) __attribute__((used)) void _NativeCupertinoHttp_protocolTrampoline_ovsamd(id target, void * sel) { - return ((_ProtocolTrampoline_17)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); + return ((_ProtocolTrampoline_13)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); } #undef BLOCKING_BLOCK_IMPL diff --git a/pkgs/cupertino_http/ffigen.yaml b/pkgs/cupertino_http/ffigen.yaml index 70935a1f74..853ce7e415 100644 --- a/pkgs/cupertino_http/ffigen.yaml +++ b/pkgs/cupertino_http/ffigen.yaml @@ -28,6 +28,7 @@ preamble: | // ignore_for_file: unused_element // ignore_for_file: unused_field // ignore_for_file: return_of_invalid_type +exclude-all-by-default: true objc-interfaces: include: - 'NSCondition' diff --git a/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart b/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart index f36f3c06fa..149f58ef51 100644 --- a/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart +++ b/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart @@ -13,104943 +13,33886 @@ import 'dart:ffi' as ffi; import 'package:objective_c/objective_c.dart' as objc; import 'package:ffi/ffi.dart' as pkg_ffi; -/// Bindings for the Foundation URL Loading System and supporting libraries. -/// -/// Regenerate bindings with `flutter packages pub run ffigen --config ffigen.yaml`. -/// -class NativeCupertinoHttp { - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - NativeCupertinoHttp(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - NativeCupertinoHttp.fromLookup( - ffi.Pointer Function(String symbolName) lookup, - ) : _lookup = lookup; - - ffi.Pointer> signal( - int arg0, - ffi.Pointer> arg1, - ) { - return _signal(arg0, arg1); - } +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer) +>() +external bool _NativeCupertinoHttp_protocolTrampoline_e3qsqz( + ffi.Pointer target, + ffi.Pointer arg0, +); - late final _signalPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer> Function( - ffi.Int, - ffi.Pointer>, - ) - > - >('signal'); - late final _signal = _signalPtr - .asFunction< - ffi.Pointer> Function( - int, - ffi.Pointer>, - ) - >(); +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_18v1jvf( + ffi.Pointer block, +); - int getpriority(int arg0, int arg1) { - return _getpriority(arg0, arg1); - } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - late final _getpriorityPtr = - _lookup>( - 'getpriority', - ); - late final _getpriority = _getpriorityPtr - .asFunction(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_18v1jvf( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, +); - int getiopolicy_np(int arg0, int arg1) { - return _getiopolicy_np(arg0, arg1); - } +@ffi.Native< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external instancetype _NativeCupertinoHttp_protocolTrampoline_xr62hr( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, +); - late final _getiopolicy_npPtr = - _lookup>( - 'getiopolicy_np', - ); - late final _getiopolicy_np = _getiopolicy_npPtr - .asFunction(); +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_xtuoz7( + ffi.Pointer block, +); - int getrlimit(int arg0, ffi.Pointer arg1) { - return _getrlimit(arg0, arg1); - } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - late final _getrlimitPtr = - _lookup< - ffi.NativeFunction)> - >('getrlimit'); - late final _getrlimit = _getrlimitPtr - .asFunction)>(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) +>() +external ffi.Pointer +_NativeCupertinoHttp_protocolTrampoline_1mbt9g9( + ffi.Pointer target, + ffi.Pointer arg0, +); - int getrusage(int arg0, ffi.Pointer arg1) { - return _getrusage(arg0, arg1); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_1pl9qdv( + ffi.Pointer block, +); - late final _getrusagePtr = - _lookup< - ffi.NativeFunction)> - >('getrusage'); - late final _getrusage = _getrusagePtr - .asFunction)>(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_1pl9qdv( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - int setpriority(int arg0, int arg1, int arg2) { - return _setpriority(arg0, arg1, arg2); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_r8gdi7( + ffi.Pointer block, +); - late final _setpriorityPtr = - _lookup>( - 'setpriority', - ); - late final _setpriority = _setpriorityPtr - .asFunction(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - int setiopolicy_np(int arg0, int arg1, int arg2) { - return _setiopolicy_np(arg0, arg1, arg2); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_pfv6jd( + ffi.Pointer block, +); - late final _setiopolicy_npPtr = - _lookup>( - 'setiopolicy_np', - ); - late final _setiopolicy_np = _setiopolicy_npPtr - .asFunction(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - int setrlimit(int arg0, ffi.Pointer arg1) { - return _setrlimit(arg0, arg1); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_16sve1d( + ffi.Pointer block, +); - late final _setrlimitPtr = - _lookup< - ffi.NativeFunction)> - >('setrlimit'); - late final _setrlimit = _setrlimitPtr - .asFunction)>(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_16sve1d( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - int wait(ffi.Pointer arg0) { - return _wait(arg0); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_xx612k( + ffi.Pointer block, +); - late final _waitPtr = - _lookup)>>('wait'); - late final _wait = _waitPtr.asFunction)>(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_xx612k( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - int waitpid(int arg0, ffi.Pointer arg1, int arg2) { - return _waitpid(arg0, arg1, arg2); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_1otpo83( + ffi.Pointer block, +); - late final _waitpidPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('waitpid'); - late final _waitpid = _waitpidPtr - .asFunction, int)>(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_1otpo83( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - int waitid( - idtype_t arg0, - Dart__uint32_t arg1, - ffi.Pointer arg2, - int arg3, - ) { - return _waitid(arg0.value, arg1, arg2, arg3); - } +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_xx612k( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, +); - late final _waitidPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.UnsignedInt, - id_t, - ffi.Pointer, - ffi.Int, - ) - > - >('waitid'); - late final _waitid = _waitidPtr - .asFunction, int)>(); +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_1tz5yf( + ffi.Pointer block, +); - int wait3(ffi.Pointer arg0, int arg1, ffi.Pointer arg2) { - return _wait3(arg0, arg1, arg2); - } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - late final _wait3Ptr = - _lookup< - ffi.NativeFunction< - pid_t Function(ffi.Pointer, ffi.Int, ffi.Pointer) - > - >('wait3'); - late final _wait3 = _wait3Ptr - .asFunction< - int Function(ffi.Pointer, int, ffi.Pointer) - >(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_1tz5yf( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, +); - int wait4( - int arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer arg3, - ) { - return _wait4(arg0, arg1, arg2, arg3); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_fjrv01( + ffi.Pointer block, +); - late final _wait4Ptr = - _lookup< - ffi.NativeFunction< - pid_t Function( - pid_t, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >('wait4'); - late final _wait4 = _wait4Ptr - .asFunction< - int Function(int, ffi.Pointer, int, ffi.Pointer) - >(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_fjrv01( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - ffi.Pointer alloca(int __size) { - return _alloca(__size); - } +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_fjrv01( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, +); - late final _allocaPtr = - _lookup Function(ffi.Size)>>( - 'alloca', - ); - late final _alloca = _allocaPtr - .asFunction Function(int)>(); +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_l2g8ke( + ffi.Pointer block, +); - late final ffi.Pointer ___mb_cur_max = _lookup( - '__mb_cur_max', - ); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_l2g8ke( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - int get __mb_cur_max => ___mb_cur_max.value; +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_l2g8ke( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, +); - set __mb_cur_max(int value) => ___mb_cur_max.value = value; +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_n8yd09( + ffi.Pointer block, +); - ffi.Pointer malloc_type_malloc(int size, int type_id) { - return _malloc_type_malloc(size, type_id); - } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_n8yd09( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - late final _malloc_type_mallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Size, malloc_type_id_t) - > - >('malloc_type_malloc'); - late final _malloc_type_malloc = _malloc_type_mallocPtr - .asFunction Function(int, int)>(); +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_bklti2( + ffi.Pointer block, +); - ffi.Pointer malloc_type_calloc(int count, int size, int type_id) { - return _malloc_type_calloc(count, size, type_id); - } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_bklti2( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - late final _malloc_type_callocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Size, ffi.Size, malloc_type_id_t) - > - >('malloc_type_calloc'); - late final _malloc_type_calloc = _malloc_type_callocPtr - .asFunction Function(int, int, int)>(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_bklti2( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, +); - void malloc_type_free(ffi.Pointer ptr, int type_id) { - return _malloc_type_free(ptr, type_id); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_jyim80( + ffi.Pointer block, +); - late final _malloc_type_freePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, malloc_type_id_t) - > - >('malloc_type_free'); - late final _malloc_type_free = _malloc_type_freePtr - .asFunction, int)>(); - - ffi.Pointer malloc_type_realloc( - ffi.Pointer ptr, - int size, - int type_id, - ) { - return _malloc_type_realloc(ptr, size, type_id); - } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_jyim80( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - late final _malloc_type_reallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size, - malloc_type_id_t, - ) - > - >('malloc_type_realloc'); - late final _malloc_type_realloc = _malloc_type_reallocPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_jyim80( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, +); - ffi.Pointer malloc_type_valloc(int size, int type_id) { - return _malloc_type_valloc(size, type_id); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_h68abb( + ffi.Pointer block, +); - late final _malloc_type_vallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Size, malloc_type_id_t) - > - >('malloc_type_valloc'); - late final _malloc_type_valloc = _malloc_type_vallocPtr - .asFunction Function(int, int)>(); - - ffi.Pointer malloc_type_aligned_alloc( - int alignment, - int size, - int type_id, - ) { - return _malloc_type_aligned_alloc(alignment, size, type_id); - } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_h68abb( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - late final _malloc_type_aligned_allocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Size, ffi.Size, malloc_type_id_t) - > - >('malloc_type_aligned_alloc'); - late final _malloc_type_aligned_alloc = _malloc_type_aligned_allocPtr - .asFunction Function(int, int, int)>(); - - int malloc_type_posix_memalign( - ffi.Pointer> memptr, - int alignment, - int size, - int type_id, - ) { - return _malloc_type_posix_memalign(memptr, alignment, size, type_id); - } - - late final _malloc_type_posix_memalignPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Size, - ffi.Size, - malloc_type_id_t, - ) - > - >('malloc_type_posix_memalign'); - late final _malloc_type_posix_memalign = _malloc_type_posix_memalignPtr - .asFunction< - int Function(ffi.Pointer>, int, int, int) - >(); - - ffi.Pointer malloc_type_zone_malloc( - ffi.Pointer zone, - int size, - int type_id, - ) { - return _malloc_type_zone_malloc(zone, size, type_id); - } - - late final _malloc_type_zone_mallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size, - malloc_type_id_t, - ) - > - >('malloc_type_zone_malloc'); - late final _malloc_type_zone_malloc = _malloc_type_zone_mallocPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); - - ffi.Pointer malloc_type_zone_calloc( - ffi.Pointer zone, - int count, - int size, - int type_id, - ) { - return _malloc_type_zone_calloc(zone, count, size, type_id); - } - - late final _malloc_type_zone_callocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - malloc_type_id_t, - ) - > - >('malloc_type_zone_calloc'); - late final _malloc_type_zone_calloc = _malloc_type_zone_callocPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - int, - int, - int, - ) - >(); - - void malloc_type_zone_free( - ffi.Pointer zone, - ffi.Pointer ptr, - int type_id, - ) { - return _malloc_type_zone_free(zone, ptr, type_id); - } - - late final _malloc_type_zone_freePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - malloc_type_id_t, - ) - > - >('malloc_type_zone_free'); - late final _malloc_type_zone_free = _malloc_type_zone_freePtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); - - ffi.Pointer malloc_type_zone_realloc( - ffi.Pointer zone, - ffi.Pointer ptr, - int size, - int type_id, - ) { - return _malloc_type_zone_realloc(zone, ptr, size, type_id); - } - - late final _malloc_type_zone_reallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - malloc_type_id_t, - ) - > - >('malloc_type_zone_realloc'); - late final _malloc_type_zone_realloc = _malloc_type_zone_reallocPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >(); - - ffi.Pointer malloc_type_zone_valloc( - ffi.Pointer zone, - int size, - int type_id, - ) { - return _malloc_type_zone_valloc(zone, size, type_id); - } - - late final _malloc_type_zone_vallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size, - malloc_type_id_t, - ) - > - >('malloc_type_zone_valloc'); - late final _malloc_type_zone_valloc = _malloc_type_zone_vallocPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); - - ffi.Pointer malloc_type_zone_memalign( - ffi.Pointer zone, - int alignment, - int size, - int type_id, - ) { - return _malloc_type_zone_memalign(zone, alignment, size, type_id); - } - - late final _malloc_type_zone_memalignPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - malloc_type_id_t, - ) - > - >('malloc_type_zone_memalign'); - late final _malloc_type_zone_memalign = _malloc_type_zone_memalignPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - int, - int, - int, - ) - >(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_h68abb( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, +); - ffi.Pointer malloc(int __size) { - return _malloc(__size); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_ly2579( + ffi.Pointer block, +); - late final _mallocPtr = - _lookup Function(ffi.Size)>>( - 'malloc', - ); - late final _malloc = _mallocPtr - .asFunction Function(int)>(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_ly2579( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - ffi.Pointer calloc(int __count, int __size) { - return _calloc(__count, __size); - } +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_ly2579( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, +); - late final _callocPtr = - _lookup< - ffi.NativeFunction Function(ffi.Size, ffi.Size)> - >('calloc'); - late final _calloc = _callocPtr - .asFunction Function(int, int)>(); +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_1lx650f( + ffi.Pointer block, +); - void free(ffi.Pointer arg0) { - return _free(arg0); - } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_1lx650f( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - late final _freePtr = - _lookup)>>( - 'free', - ); - late final _free = _freePtr - .asFunction)>(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) +>() +external void _NativeCupertinoHttp_protocolTrampoline_1lx650f( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, +); - ffi.Pointer realloc(ffi.Pointer __ptr, int __size) { - return _realloc(__ptr, __size); - } +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapListenerBlock_ovsamd( + ffi.Pointer block, +); - late final _reallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Size) - > - >('realloc'); - late final _realloc = _reallocPtr - .asFunction Function(ffi.Pointer, int)>(); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer +_NativeCupertinoHttp_wrapBlockingBlock_ovsamd( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); - ffi.Pointer reallocf(ffi.Pointer __ptr, int __size) { - return _reallocf(__ptr, __size); - } +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer) +>() +external void _NativeCupertinoHttp_protocolTrampoline_ovsamd( + ffi.Pointer target, + ffi.Pointer arg0, +); - late final _reallocfPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Size) - > - >('reallocf'); - late final _reallocf = _reallocfPtr - .asFunction Function(ffi.Pointer, int)>(); +/// ! +/// @enum NSURLCacheStoragePolicy +/// +/// @discussion The NSURLCacheStoragePolicy enum defines constants that +/// can be used to specify the type of storage that is allowable for an +/// NSCachedURLResponse object that is to be stored in an NSURLCache. +/// +/// @constant NSURLCacheStorageAllowed Specifies that storage in an +/// NSURLCache is allowed without restriction. +/// +/// @constant NSURLCacheStorageAllowedInMemoryOnly Specifies that +/// storage in an NSURLCache is allowed; however storage should be +/// done in memory only, no disk storage should be done. +/// +/// @constant NSURLCacheStorageNotAllowed Specifies that storage in an +/// NSURLCache is not allowed in any fashion, either in memory or on +/// disk. +enum NSURLCacheStoragePolicy { + NSURLCacheStorageAllowed(0), + NSURLCacheStorageAllowedInMemoryOnly(1), + NSURLCacheStorageNotAllowed(2); - ffi.Pointer valloc(int __size) { - return _valloc(__size); - } + final int value; + const NSURLCacheStoragePolicy(this.value); - late final _vallocPtr = - _lookup Function(ffi.Size)>>( - 'valloc', - ); - late final _valloc = _vallocPtr - .asFunction Function(int)>(); + static NSURLCacheStoragePolicy fromValue(int value) => switch (value) { + 0 => NSURLCacheStorageAllowed, + 1 => NSURLCacheStorageAllowedInMemoryOnly, + 2 => NSURLCacheStorageNotAllowed, + _ => throw ArgumentError( + 'Unknown value for NSURLCacheStoragePolicy: $value', + ), + }; +} - ffi.Pointer aligned_alloc(int __alignment, int __size) { - return _aligned_alloc(__alignment, __size); +/// WARNING: NSCachedURLResponse is a stub. To generate bindings for this class, include +/// NSCachedURLResponse in your config's objc-interfaces list. +/// +/// ! +/// @class NSCachedURLResponse +/// NSCachedURLResponse is a class whose objects functions as a wrapper for +/// objects that are stored in the framework's caching system. +/// It is used to maintain characteristics and attributes of a cached +/// object. +extension type NSCachedURLResponse._(objc.ObjCObject object$) + implements + objc.ObjCObject, + objc.NSObject, + objc.NSSecureCoding, + objc.NSCopying { + /// Constructs a [NSCachedURLResponse] that points to the same underlying object as [other]. + NSCachedURLResponse.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSCachedURLResponse', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); } - late final _aligned_allocPtr = - _lookup< - ffi.NativeFunction Function(ffi.Size, ffi.Size)> - >('aligned_alloc'); - late final _aligned_alloc = _aligned_allocPtr - .asFunction Function(int, int)>(); - - int posix_memalign( - ffi.Pointer> __memptr, - int __alignment, - int __size, - ) { - return _posix_memalign(__memptr, __alignment, __size); + /// Constructs a [NSCachedURLResponse] that wraps the given raw object pointer. + NSCachedURLResponse.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSCachedURLResponse', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); } +} - late final _posix_memalignPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Size, - ffi.Size, - ) - > - >('posix_memalign'); - late final _posix_memalign = _posix_memalignPtr - .asFunction>, int, int)>(); - - void abort() { - return _abort(); - } +late final _class_NSURLCache = objc.getClass("NSURLCache"); +late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); +final _objc_msgSend_19nvye5 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_sharedURLCache = objc.registerName("sharedURLCache"); +final _objc_msgSend_151sglz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setSharedURLCache_ = objc.registerName("setSharedURLCache:"); +final _objc_msgSend_xtuoz7 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +typedef instancetype = ffi.Pointer; +typedef Dartinstancetype = objc.ObjCObject; +late final _sel_initWithMemoryCapacity_diskCapacity_diskPath_ = objc + .registerName("initWithMemoryCapacity:diskCapacity:diskPath:"); +final _objc_msgSend_1dqnse5 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.UnsignedLong, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + int, + int, + ffi.Pointer, + ) + >(); +late final _sel_initWithMemoryCapacity_diskCapacity_directoryURL_ = objc + .registerName("initWithMemoryCapacity:diskCapacity:directoryURL:"); +late final _class_NSURLRequest = objc.getClass("NSURLRequest"); +late final _sel_requestWithURL_ = objc.registerName("requestWithURL:"); +final _objc_msgSend_1sotr3r = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_supportsSecureCoding = objc.registerName( + "supportsSecureCoding", +); +final _objc_msgSend_91o635 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); - late final _abortPtr = _lookup>( - 'abort', +/// Construction methods for `objc.ObjCBlock)>`. +abstract final class ObjCBlock_bool_ffiVoid { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock)> fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock)>( + pointer, + retain: retain, + release: release, ); - late final _abort = _abortPtr.asFunction(); - - int abs(int arg0) { - return _abs(arg0); - } - late final _absPtr = _lookup>( - 'abs', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock)> + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction arg0)> + > + ptr, + ) => objc.ObjCBlock)>( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _abs = _absPtr.asFunction(); - - int atexit(ffi.Pointer> arg0) { - return _atexit(arg0); - } - late final _atexitPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer>) - > - >('atexit'); - late final _atexit = _atexitPtr - .asFunction< - int Function(ffi.Pointer>) - >(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock)> fromFunction( + bool Function(ffi.Pointer) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock)>( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn(arg0), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - int at_quick_exit(ffi.Pointer> arg0) { - return _at_quick_exit(arg0); - } + static bool _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast arg0)>>() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline, false) + .cast(); + static bool _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => (objc.getBlockClosure(block) as bool Function(ffi.Pointer))( + arg0, + ); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline, false) + .cast(); +} - late final _at_quick_exitPtr = - _lookup< +/// Call operator for `objc.ObjCBlock)>`. +extension ObjCBlock_bool_ffiVoid$CallExtension + on objc.ObjCBlock)> { + bool call(ffi.Pointer arg0) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer>) + ffi.Bool Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) > - >('at_quick_exit'); - late final _at_quick_exit = _at_quick_exitPtr + >() .asFunction< - int Function(ffi.Pointer>) - >(); - - double atof(ffi.Pointer arg0) { - return _atof(arg0); - } - - late final _atofPtr = - _lookup)>>( - 'atof', - ); - late final _atof = _atofPtr - .asFunction)>(); - - int atoi(ffi.Pointer arg0) { - return _atoi(arg0); - } - - late final _atoiPtr = - _lookup)>>( - 'atoi', - ); - late final _atoi = _atoiPtr.asFunction)>(); - - int atol(ffi.Pointer arg0) { - return _atol(arg0); - } - - late final _atolPtr = - _lookup)>>( - 'atol', - ); - late final _atol = _atolPtr.asFunction)>(); - - int atoll(ffi.Pointer arg0) { - return _atoll(arg0); - } - - late final _atollPtr = - _lookup)>>( - 'atoll', - ); - late final _atoll = _atollPtr - .asFunction)>(); - - ffi.Pointer bsearch( - ffi.Pointer __key, - ffi.Pointer __base, - int __nel, - int __width, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - > - __compar, - ) { - return _bsearch(__key, __base, __nel, __width, __compar); - } + bool Function(ffi.Pointer, ffi.Pointer) + >()(ref.pointer, arg0); +} - late final _bsearchPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, - ) - > - >('bsearch'); - late final _bsearch = _bsearchPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, - ) - >(); - - div_t div(int arg0, int arg1) { - return _div(arg0, arg1); - } +/// ! +/// @enum NSURLRequestCachePolicy +/// +/// @discussion The NSURLRequestCachePolicy enum defines constants that +/// can be used to specify the type of interactions that take place with +/// the caching system when the URL loading system processes a request. +/// Specifically, these constants cover interactions that have to do +/// with whether already-existing cache data is returned to satisfy a +/// URL load request. +/// +/// @constant NSURLRequestUseProtocolCachePolicy Specifies that the +/// caching logic defined in the protocol implementation, if any, is +/// used for a particular URL load request. This is the default policy +/// for URL load requests. +/// +/// @constant NSURLRequestReloadIgnoringLocalCacheData Specifies that the +/// data for the URL load should be loaded from the origin source. No +/// existing local cache data, regardless of its freshness or validity, +/// should be used to satisfy a URL load request. +/// +/// @constant NSURLRequestReloadIgnoringLocalAndRemoteCacheData Specifies that +/// not only should the local cache data be ignored, but that proxies and +/// other intermediates should be instructed to disregard their caches +/// so far as the protocol allows. +/// +/// @constant NSURLRequestReloadIgnoringCacheData Older name for +/// NSURLRequestReloadIgnoringLocalCacheData. +/// +/// @constant NSURLRequestReturnCacheDataElseLoad Specifies that the +/// existing cache data should be used to satisfy a URL load request, +/// regardless of its age or expiration date. However, if there is no +/// existing data in the cache corresponding to a URL load request, +/// the URL is loaded from the origin source. +/// +/// @constant NSURLRequestReturnCacheDataDontLoad Specifies that the +/// existing cache data should be used to satisfy a URL load request, +/// regardless of its age or expiration date. However, if there is no +/// existing data in the cache corresponding to a URL load request, no +/// attempt is made to load the URL from the origin source, and the +/// load is considered to have failed. This constant specifies a +/// behavior that is similar to an "offline" mode. +/// +/// @constant NSURLRequestReloadRevalidatingCacheData Specifies that +/// the existing cache data may be used provided the origin source +/// confirms its validity, otherwise the URL is loaded from the +/// origin source. +enum NSURLRequestCachePolicy { + NSURLRequestUseProtocolCachePolicy(0), + NSURLRequestReloadIgnoringLocalCacheData(1), + NSURLRequestReloadIgnoringLocalAndRemoteCacheData(4), + NSURLRequestReturnCacheDataElseLoad(2), + NSURLRequestReturnCacheDataDontLoad(3), + NSURLRequestReloadRevalidatingCacheData(5); - late final _divPtr = - _lookup>('div'); - late final _div = _divPtr.asFunction(); + static const NSURLRequestReloadIgnoringCacheData = + NSURLRequestReloadIgnoringLocalCacheData; - void exit(int arg0) { - return _exit$1(arg0); - } + final int value; + const NSURLRequestCachePolicy(this.value); - late final _exitPtr = _lookup>( - 'exit', - ); - late final _exit$1 = _exitPtr.asFunction(); + static NSURLRequestCachePolicy fromValue(int value) => switch (value) { + 0 => NSURLRequestUseProtocolCachePolicy, + 1 => NSURLRequestReloadIgnoringLocalCacheData, + 4 => NSURLRequestReloadIgnoringLocalAndRemoteCacheData, + 2 => NSURLRequestReturnCacheDataElseLoad, + 3 => NSURLRequestReturnCacheDataDontLoad, + 5 => NSURLRequestReloadRevalidatingCacheData, + _ => throw ArgumentError( + 'Unknown value for NSURLRequestCachePolicy: $value', + ), + }; - ffi.Pointer getenv(ffi.Pointer arg0) { - return _getenv(arg0); + @override + String toString() { + if (this == NSURLRequestReloadIgnoringLocalCacheData) + return "NSURLRequestCachePolicy.NSURLRequestReloadIgnoringLocalCacheData, NSURLRequestCachePolicy.NSURLRequestReloadIgnoringCacheData"; + return super.toString(); } +} - late final _getenvPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('getenv'); - late final _getenv = _getenvPtr - .asFunction Function(ffi.Pointer)>(); +late final _sel_requestWithURL_cachePolicy_timeoutInterval_ = objc.registerName( + "requestWithURL:cachePolicy:timeoutInterval:", +); +final _objc_msgSend_1ajs603 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Double, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + double, + ) + >(); +late final _sel_initWithURL_ = objc.registerName("initWithURL:"); +late final _sel_initWithURL_cachePolicy_timeoutInterval_ = objc.registerName( + "initWithURL:cachePolicy:timeoutInterval:", +); +late final _sel_URL = objc.registerName("URL"); +late final _sel_cachePolicy = objc.registerName("cachePolicy"); +final _objc_msgSend_8jm3uo = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_timeoutInterval = objc.registerName("timeoutInterval"); +final _objc_msgSend_1ukqyt8 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Double Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + double Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1ukqyt8Fpret = objc.msgSendFpretPointer + .cast< + ffi.NativeFunction< + ffi.Double Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + double Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_mainDocumentURL = objc.registerName("mainDocumentURL"); - int labs(int arg0) { - return _labs(arg0); - } +/// ! +/// @enum NSURLRequestNetworkServiceType +/// +/// @discussion The NSURLRequestNetworkServiceType enum defines constants that +/// can be used to specify the service type to associate with this request. The +/// service type is used to provide the networking layers a hint of the purpose +/// of the request. +/// +/// @constant NSURLNetworkServiceTypeDefault Is the default value for an NSURLRequest +/// when created. This value should be left unchanged for the vast majority of requests. +/// +/// @constant NSURLNetworkServiceTypeVoIP Specifies that the request is for voice over IP +/// control traffic. +/// +/// @constant NSURLNetworkServiceTypeVideo Specifies that the request is for video +/// traffic. +/// +/// @constant NSURLNetworkServiceTypeBackground Specifies that the request is for background +/// traffic (such as a file download). +/// +/// @constant NSURLNetworkServiceTypeVoice Specifies that the request is for voice data. +/// +/// @constant NSURLNetworkServiceTypeResponsiveData Specifies that the request is for responsive (time sensitive) data. +/// +/// @constant NSURLNetworkServiceTypeAVStreaming Specifies that the request is streaming audio/video data. +/// +/// @constant NSURLNetworkServiceTypeResponsiveAV Specifies that the request is for responsive (time sensitive) audio/video data. +/// +/// @constant NSURLNetworkServiceTypeCallSignaling Specifies that the request is for call signaling. +enum NSURLRequestNetworkServiceType { + /// Standard internet traffic + NSURLNetworkServiceTypeDefault(0), - late final _labsPtr = - _lookup>('labs'); - late final _labs = _labsPtr.asFunction(); + /// Voice over IP control traffic + NSURLNetworkServiceTypeVoIP(1), - ldiv_t ldiv(int arg0, int arg1) { - return _ldiv(arg0, arg1); - } + /// Video traffic + NSURLNetworkServiceTypeVideo(2), - late final _ldivPtr = - _lookup>('ldiv'); - late final _ldiv = _ldivPtr.asFunction(); + /// Background traffic + NSURLNetworkServiceTypeBackground(3), - int llabs(int arg0) { - return _llabs(arg0); - } + /// Voice data + NSURLNetworkServiceTypeVoice(4), - late final _llabsPtr = - _lookup>('llabs'); - late final _llabs = _llabsPtr.asFunction(); + /// Responsive data + NSURLNetworkServiceTypeResponsiveData(6), - lldiv_t lldiv(int arg0, int arg1) { - return _lldiv(arg0, arg1); - } + /// Multimedia Audio/Video Streaming + NSURLNetworkServiceTypeAVStreaming(8), - late final _lldivPtr = - _lookup>( - 'lldiv', - ); - late final _lldiv = _lldivPtr.asFunction(); + /// Responsive Multimedia Audio/Video + NSURLNetworkServiceTypeResponsiveAV(9), - int mblen(ffi.Pointer __s, int __n) { - return _mblen(__s, __n); - } + /// Call Signaling + NSURLNetworkServiceTypeCallSignaling(11); - late final _mblenPtr = - _lookup< - ffi.NativeFunction, ffi.Size)> - >('mblen'); - late final _mblen = _mblenPtr - .asFunction, int)>(); + final int value; + const NSURLRequestNetworkServiceType(this.value); - int mbstowcs( - ffi.Pointer arg0, - ffi.Pointer arg1, - int __n, - ) { - return _mbstowcs(arg0, arg1, __n); - } + static NSURLRequestNetworkServiceType fromValue(int value) => switch (value) { + 0 => NSURLNetworkServiceTypeDefault, + 1 => NSURLNetworkServiceTypeVoIP, + 2 => NSURLNetworkServiceTypeVideo, + 3 => NSURLNetworkServiceTypeBackground, + 4 => NSURLNetworkServiceTypeVoice, + 6 => NSURLNetworkServiceTypeResponsiveData, + 8 => NSURLNetworkServiceTypeAVStreaming, + 9 => NSURLNetworkServiceTypeResponsiveAV, + 11 => NSURLNetworkServiceTypeCallSignaling, + _ => throw ArgumentError( + 'Unknown value for NSURLRequestNetworkServiceType: $value', + ), + }; +} - late final _mbstowcsPtr = - _lookup< - ffi.NativeFunction< - ffi.Size Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('mbstowcs'); - late final _mbstowcs = _mbstowcsPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); +late final _sel_networkServiceType = objc.registerName("networkServiceType"); +final _objc_msgSend_t4uaw1 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_allowsCellularAccess = objc.registerName( + "allowsCellularAccess", +); +late final _sel_allowsExpensiveNetworkAccess = objc.registerName( + "allowsExpensiveNetworkAccess", +); +late final _sel_allowsConstrainedNetworkAccess = objc.registerName( + "allowsConstrainedNetworkAccess", +); +late final _sel_assumesHTTP3Capable = objc.registerName("assumesHTTP3Capable"); - int mbtowc(ffi.Pointer arg0, ffi.Pointer arg1, int __n) { - return _mbtowc(arg0, arg1, __n); - } +/// ! +/// @enum NSURLRequestAttribution +/// +/// @discussion The NSURLRequestAttribution enum is used to indicate whether the +/// user or developer specified the URL. +/// +/// @constant NSURLRequestAttributionDeveloper Indicates that the URL was specified +/// by the developer. This is the default value for an NSURLRequest when created. +/// +/// @constant NSURLRequestAttributionUser Indicates that the URL was specified by +/// the user. +enum NSURLRequestAttribution { + NSURLRequestAttributionDeveloper(0), + NSURLRequestAttributionUser(1); - late final _mbtowcPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('mbtowc'); - late final _mbtowc = _mbtowcPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); + final int value; + const NSURLRequestAttribution(this.value); - void qsort( - ffi.Pointer __base, - int __nel, - int __width, - ffi.Pointer< + static NSURLRequestAttribution fromValue(int value) => switch (value) { + 0 => NSURLRequestAttributionDeveloper, + 1 => NSURLRequestAttributionUser, + _ => throw ArgumentError( + 'Unknown value for NSURLRequestAttribution: $value', + ), + }; +} + +late final _sel_attribution = objc.registerName("attribution"); +final _objc_msgSend_i3avs9 = objc.msgSendPointer + .cast< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) > - > - __compar, - ) { - return _qsort(__base, __nel, __width, __compar); - } - - late final _qsortPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, - ) - > - >('qsort'); - late final _qsort = _qsortPtr - .asFunction< - void Function( - ffi.Pointer, - int, - int, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_requiresDNSSECValidation = objc.registerName( + "requiresDNSSECValidation", +); +late final _sel_allowsPersistentDNS = objc.registerName("allowsPersistentDNS"); +late final _sel_cookiePartitionIdentifier = objc.registerName( + "cookiePartitionIdentifier", +); +late final _sel_init = objc.registerName("init"); +late final _sel_new = objc.registerName("new"); +late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); +final _objc_msgSend_1cwp428 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - void quick_exit(int arg0) { - return _quick_exit(arg0); - } + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_alloc = objc.registerName("alloc"); +late final _sel_encodeWithCoder_ = objc.registerName("encodeWithCoder:"); - late final _quick_exitPtr = - _lookup>('quick_exit'); - late final _quick_exit = _quick_exitPtr.asFunction(); +/// Construction methods for `objc.ObjCBlock, objc.NSCoder)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock, objc.NSCoder)> + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock, objc.NSCoder)>( + pointer, + retain: retain, + release: release, + ); - int rand() { - return _rand(); - } + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock, objc.NSCoder)> + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + > + ptr, + ) => objc.ObjCBlock, objc.NSCoder)>( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _randPtr = _lookup>('rand'); - late final _rand = _randPtr.asFunction(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock, objc.NSCoder)> + fromFunction( + void Function(ffi.Pointer, objc.NSCoder) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock, objc.NSCoder)>( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0, ffi.Pointer arg1) => + fn(arg0, objc.NSCoder.fromPointer(arg1, retain: true, release: true)), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - void srand(int arg0) { - return _srand(arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock, objc.NSCoder)> + listener( + void Function(ffi.Pointer, objc.NSCoder) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + objc.NSCoder.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_18v1jvf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, objc.NSCoder) + >(wrapper, retain: false, release: true); } - late final _srandPtr = - _lookup>('srand'); - late final _srand = _srandPtr.asFunction(); - - double strtod( - ffi.Pointer arg0, - ffi.Pointer> arg1, - ) { - return _strtod(arg0, arg1); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock, objc.NSCoder)> + blocking( + void Function(ffi.Pointer, objc.NSCoder) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + objc.NSCoder.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + objc.NSCoder.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, objc.NSCoder) + >(wrapper, retain: false, release: true); } - late final _strtodPtr = - _lookup< - ffi.NativeFunction< - ffi.Double Function( - ffi.Pointer, - ffi.Pointer>, - ) - > - >('strtod'); - late final _strtod = _strtodPtr - .asFunction< - double Function( - ffi.Pointer, - ffi.Pointer>, - ) - >(); - - double strtof( - ffi.Pointer arg0, - ffi.Pointer> arg1, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _strtof(arg0, arg1); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + objc.objectRelease(block.cast()); } - late final _strtofPtr = - _lookup< - ffi.NativeFunction< - ffi.Float Function( - ffi.Pointer, - ffi.Pointer>, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('strtof'); - late final _strtof = _strtofPtr - .asFunction< - double Function( - ffi.Pointer, - ffi.Pointer>, - ) - >(); - - int strtol( - ffi.Pointer __str, - ffi.Pointer> __endptr, - int __base, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _strtol(__str, __endptr, __base); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _strtolPtr = - _lookup< - ffi.NativeFunction< - ffi.Long Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('strtol'); - late final _strtol = _strtolPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - - int strtoll( - ffi.Pointer __str, - ffi.Pointer> __endptr, - int __base, - ) { - return _strtoll(__str, __endptr, __base); - } - - late final _strtollPtr = - _lookup< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.LongLong Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, ) > - >('strtoll'); - late final _strtoll = _strtollPtr + >() .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - - int strtoul( - ffi.Pointer __str, - ffi.Pointer> __endptr, - int __base, - ) { - return _strtoul(__str, __endptr, __base); - } + void Function(ffi.Pointer, ffi.Pointer) + >()(arg0, arg1); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _strtoulPtr = - _lookup< +/// Call operator for `objc.ObjCBlock, objc.NSCoder)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSCoder$CallExtension + on objc.ObjCBlock, objc.NSCoder)> { + void call(ffi.Pointer arg0, objc.NSCoder arg1) => ref + .pointer + .ref + .invoke + .cast< ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, ) > - >('strtoul'); - late final _strtoul = _strtoulPtr + >() .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); + >()(ref.pointer, arg0, arg1.ref.pointer); +} - int strtoull( - ffi.Pointer __str, - ffi.Pointer> __endptr, - int __base, - ) { - return _strtoull(__str, __endptr, __base); - } +late final _sel_initWithCoder_ = objc.registerName("initWithCoder:"); - late final _strtoullPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLongLong Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ) - > - >('strtoull'); - late final _strtoull = _strtoullPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, +/// Construction methods for `objc.ObjCBlock?> Function(ffi.Pointer, objc.NSCoder)>`. +abstract final class ObjCBlock_instancetype_ffiVoid_NSCoder { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + objc.Retained?> Function( + ffi.Pointer, + objc.NSCoder, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + objc.Retained?> Function( + ffi.Pointer, + objc.NSCoder, ) - >(); - - int system(ffi.Pointer arg0) { - return _system(arg0); - } + >(pointer, retain: retain, release: release); - late final _systemPtr = - _lookup)>>( - 'system', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + objc.Retained?> Function( + ffi.Pointer, + objc.NSCoder, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + objc.Retained?> Function( + ffi.Pointer, + objc.NSCoder, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _system = _systemPtr - .asFunction)>(); - - int wcstombs( - ffi.Pointer arg0, - ffi.Pointer arg1, - int __n, - ) { - return _wcstombs(arg0, arg1, __n); - } - late final _wcstombsPtr = - _lookup< - ffi.NativeFunction< - ffi.Size Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('wcstombs'); - late final _wcstombs = _wcstombsPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int wctomb(ffi.Pointer arg0, int arg1) { - return _wctomb(arg0, arg1); - } - - late final _wctombPtr = - _lookup< - ffi.NativeFunction, ffi.WChar)> - >('wctomb'); - late final _wctomb = _wctombPtr - .asFunction, int)>(); - - void _Exit(int arg0) { - return __Exit(arg0); - } - - late final __ExitPtr = - _lookup>('_Exit'); - late final __Exit = __ExitPtr.asFunction(); - - int a64l(ffi.Pointer arg0) { - return _a64l(arg0); - } - - late final _a64lPtr = - _lookup)>>( - 'a64l', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + objc.Retained?> Function( + ffi.Pointer, + objc.NSCoder, + ) + > + fromFunction( + Dartinstancetype? Function(ffi.Pointer, objc.NSCoder) fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + objc.Retained?> Function( + ffi.Pointer, + objc.NSCoder, + ) + >( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0, ffi.Pointer arg1) => + fn( + arg0, + objc.NSCoder.fromPointer(arg1, retain: true, release: true), + )?.ref.retainAndReturnPointer() ?? + ffi.nullptr, + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _a64l = _a64lPtr.asFunction)>(); - - double drand48() { - return _drand48(); - } - - late final _drand48Ptr = _lookup>( - 'drand48', - ); - late final _drand48 = _drand48Ptr.asFunction(); - - ffi.Pointer ecvt( - double arg0, - int arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - return _ecvt(arg0, arg1, arg2, arg3); - } - late final _ecvtPtr = - _lookup< + static instancetype _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Double, - ffi.Int, - ffi.Pointer, - ffi.Pointer, + instancetype Function( + ffi.Pointer arg0, + ffi.Pointer arg1, ) > - >('ecvt'); - late final _ecvt = _ecvtPtr + >() .asFunction< - ffi.Pointer Function( - double, - int, - ffi.Pointer, - ffi.Pointer, + instancetype Function( + ffi.Pointer, + ffi.Pointer, ) - >(); - - double erand48(ffi.Pointer arg0) { - return _erand48(arg0); - } - - late final _erand48Ptr = - _lookup< - ffi.NativeFunction)> - >('erand48'); - late final _erand48 = _erand48Ptr - .asFunction)>(); - - ffi.Pointer fcvt( - double arg0, - int arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - return _fcvt(arg0, arg1, arg2, arg3); - } + >()(arg0, arg1); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static instancetype _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => + (objc.getBlockClosure(block) + as instancetype Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _fcvtPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Double, - ffi.Int, - ffi.Pointer, - ffi.Pointer, +/// Call operator for `objc.ObjCBlock?> Function(ffi.Pointer, objc.NSCoder)>`. +extension ObjCBlock_instancetype_ffiVoid_NSCoder$CallExtension + on + objc.ObjCBlock< + objc.Retained?> Function( + ffi.Pointer, + objc.NSCoder, ) - > - >('fcvt'); - late final _fcvt = _fcvtPtr - .asFunction< - ffi.Pointer Function( - double, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - ffi.Pointer gcvt( - double arg0, - int arg1, - ffi.Pointer arg2, - ) { - return _gcvt(arg0, arg1, arg2); - } + > { + Dartinstancetype? call(ffi.Pointer arg0, objc.NSCoder arg1) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0, arg1.ref.pointer) + .address == + 0 + ? null + : objc.ObjCObject( + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0, arg1.ref.pointer), + retain: false, + release: true, + ); +} - late final _gcvtPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Double, - ffi.Int, - ffi.Pointer, - ) - > - >('gcvt'); - late final _gcvt = _gcvtPtr - .asFunction< - ffi.Pointer Function(double, int, ffi.Pointer) - >(); +late final _sel_HTTPMethod = objc.registerName("HTTPMethod"); +late final _sel_allHTTPHeaderFields = objc.registerName("allHTTPHeaderFields"); +late final _sel_valueForHTTPHeaderField_ = objc.registerName( + "valueForHTTPHeaderField:", +); +late final _sel_HTTPBody = objc.registerName("HTTPBody"); +late final _sel_HTTPBodyStream = objc.registerName("HTTPBodyStream"); +late final _sel_HTTPShouldHandleCookies = objc.registerName( + "HTTPShouldHandleCookies", +); +late final _sel_HTTPShouldUsePipelining = objc.registerName( + "HTTPShouldUsePipelining", +); - int getsubopt( - ffi.Pointer> arg0, - ffi.Pointer> arg1, - ffi.Pointer> arg2, - ) { - return _getsubopt(arg0, arg1, arg2); +/// ! +/// @category NSURLRequest(NSHTTPURLRequest) +/// The NSHTTPURLRequest on NSURLRequest provides methods for accessing +/// information specific to HTTP protocol requests. +extension NSHTTPURLRequest on NSURLRequest { + /// ! + /// @abstract Returns the request body data of the receiver. + /// @discussion This data is sent as the message body of the request, as + /// in done in an HTTP POST request. + /// @result The request body data of the receiver. + objc.NSData? get HTTPBody { + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPBody', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPBody); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); } - late final _getsuboptPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer>, - ) - > - >('getsubopt'); - late final _getsubopt = _getsuboptPtr - .asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer>, - ) - >(); - - int grantpt(int arg0) { - return _grantpt(arg0); + /// ! + /// @abstract Returns the request body stream of the receiver + /// if any has been set + /// @discussion The stream is returned for examination only; it is + /// not safe for the caller to manipulate the stream in any way. Also + /// note that the HTTPBodyStream and HTTPBody are mutually exclusive - only + /// one can be set on a given request. Also note that the body stream is + /// preserved across copies, but is LOST when the request is coded via the + /// NSCoding protocol + /// @result The request body stream of the receiver. + objc.NSInputStream? get HTTPBodyStream { + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPBodyStream', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_HTTPBodyStream, + ); + return $ret.address == 0 + ? null + : objc.NSInputStream.fromPointer($ret, retain: true, release: true); } - late final _grantptPtr = - _lookup>('grantpt'); - late final _grantpt = _grantptPtr.asFunction(); - - ffi.Pointer initstate( - int arg0, - ffi.Pointer arg1, - int __size, - ) { - return _initstate(arg0, arg1, __size); + /// ! + /// @abstract Returns the HTTP request method of the receiver. + /// @result the HTTP request method of the receiver. + objc.NSString? get HTTPMethod { + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPMethod', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPMethod); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _initstatePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.UnsignedInt, - ffi.Pointer, - ffi.Size, - ) - > - >('initstate'); - late final _initstate = _initstatePtr - .asFunction< - ffi.Pointer Function(int, ffi.Pointer, int) - >(); - - int jrand48(ffi.Pointer arg0) { - return _jrand48(arg0); + /// ! + /// @abstract Determine whether default cookie handling will happen for + /// this request. + /// @discussion NOTE: This value is not used prior to 10.3 + /// @result YES if cookies will be sent with and set for this request; + /// otherwise NO. + bool get HTTPShouldHandleCookies { + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPShouldHandleCookies', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_HTTPShouldHandleCookies, + ); } - late final _jrand48Ptr = - _lookup< - ffi.NativeFunction)> - >('jrand48'); - late final _jrand48 = _jrand48Ptr - .asFunction)>(); + /// ! + /// @abstract Reports whether the receiver is not expected to wait for the + /// previous response before transmitting. + /// @result YES if the receiver should transmit before the previous response + /// is received. NO if the receiver should wait for the previous response + /// before transmitting. + bool get HTTPShouldUsePipelining { + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPShouldUsePipelining', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_HTTPShouldUsePipelining, + ); + } - ffi.Pointer l64a(int arg0) { - return _l64a(arg0); + /// ! + /// @abstract Returns a dictionary containing all the HTTP header fields + /// of the receiver. + /// @result a dictionary containing all the HTTP header fields of the + /// receiver. + objc.NSDictionary? get allHTTPHeaderFields { + objc.checkOsVersionInternal( + 'NSURLRequest.allHTTPHeaderFields', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_allHTTPHeaderFields, + ); + return $ret.address == 0 + ? null + : objc.NSDictionary.fromPointer($ret, retain: true, release: true); } - late final _l64aPtr = - _lookup Function(ffi.Long)>>( - 'l64a', - ); - late final _l64a = _l64aPtr.asFunction Function(int)>(); - - void lcong48(ffi.Pointer arg0) { - return _lcong48(arg0); - } - - late final _lcong48Ptr = - _lookup< - ffi.NativeFunction)> - >('lcong48'); - late final _lcong48 = _lcong48Ptr - .asFunction)>(); - - int lrand48() { - return _lrand48(); - } - - late final _lrand48Ptr = _lookup>( - 'lrand48', - ); - late final _lrand48 = _lrand48Ptr.asFunction(); - - ffi.Pointer mktemp(ffi.Pointer arg0) { - return _mktemp(arg0); + /// ! + /// @method valueForHTTPHeaderField: + /// @abstract Returns the value which corresponds to the given header + /// field. Note that, in keeping with the HTTP RFC, HTTP header field + /// names are case-insensitive. + /// @param field the header field name to use for the lookup + /// (case-insensitive). + /// @result the value associated with the given header field, or nil if + /// there is no value associated with the given header field. + objc.NSString? valueForHTTPHeaderField(objc.NSString field) { + objc.checkOsVersionInternal( + 'NSURLRequest.valueForHTTPHeaderField:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_valueForHTTPHeaderField_, + field.ref.pointer, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } +} - late final _mktempPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('mktemp'); - late final _mktemp = _mktempPtr - .asFunction Function(ffi.Pointer)>(); - - int mkstemp(ffi.Pointer arg0) { - return _mkstemp(arg0); +/// NSURLRequest +extension type NSURLRequest._(objc.ObjCObject object$) + implements + objc.ObjCObject, + objc.NSObject, + objc.NSSecureCoding, + objc.NSCopying, + objc.NSMutableCopying { + /// Constructs a [NSURLRequest] that points to the same underlying object as [other]. + NSURLRequest.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); } - late final _mkstempPtr = - _lookup)>>( - 'mkstemp', - ); - late final _mkstemp = _mkstempPtr - .asFunction)>(); - - int mrand48() { - return _mrand48(); + /// Constructs a [NSURLRequest] that wraps the given raw object pointer. + NSURLRequest.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); } - late final _mrand48Ptr = _lookup>( - 'mrand48', + /// Returns whether [obj] is an instance of [NSURLRequest]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLRequest, ); - late final _mrand48 = _mrand48Ptr.asFunction(); - - int nrand48(ffi.Pointer arg0) { - return _nrand48(arg0); - } - - late final _nrand48Ptr = - _lookup< - ffi.NativeFunction)> - >('nrand48'); - late final _nrand48 = _nrand48Ptr - .asFunction)>(); - int posix_openpt(int arg0) { - return _posix_openpt(arg0); - } - - late final _posix_openptPtr = - _lookup>('posix_openpt'); - late final _posix_openpt = _posix_openptPtr.asFunction(); - - ffi.Pointer ptsname(int arg0) { - return _ptsname(arg0); - } - - late final _ptsnamePtr = - _lookup Function(ffi.Int)>>( - 'ptsname', - ); - late final _ptsname = _ptsnamePtr - .asFunction Function(int)>(); - - int ptsname_r(int fildes, ffi.Pointer buffer, int buflen) { - return _ptsname_r(fildes, buffer, buflen); + /// alloc + static NSURLRequest alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSURLRequest, _sel_alloc); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } - late final _ptsname_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Size) - > - >('ptsname_r'); - late final _ptsname_r = _ptsname_rPtr - .asFunction, int)>(); - - int putenv(ffi.Pointer arg0) { - return _putenv(arg0); + /// allocWithZone: + static NSURLRequest allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLRequest, + _sel_allocWithZone_, + zone, + ); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } - late final _putenvPtr = - _lookup)>>( - 'putenv', - ); - late final _putenv = _putenvPtr - .asFunction)>(); - - int random() { - return _random(); + /// new + static NSURLRequest new$() { + final $ret = _objc_msgSend_151sglz(_class_NSURLRequest, _sel_new); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } - late final _randomPtr = _lookup>( - 'random', - ); - late final _random = _randomPtr.asFunction(); - - int rand_r(ffi.Pointer arg0) { - return _rand_r(arg0); + /// ! + /// @method requestWithURL: + /// @abstract Allocates and initializes an NSURLRequest with the given + /// URL. + /// @discussion Default values are used for cache policy + /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 + /// seconds). + /// @param URL The URL for the request. + /// @result A newly-created and autoreleased NSURLRequest instance. + static NSURLRequest requestWithURL(objc.NSURL URL) { + objc.checkOsVersionInternal( + 'NSURLRequest.requestWithURL:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _class_NSURLRequest, + _sel_requestWithURL_, + URL.ref.pointer, + ); + return NSURLRequest.fromPointer($ret, retain: true, release: true); } - late final _rand_rPtr = - _lookup< - ffi.NativeFunction)> - >('rand_r'); - late final _rand_r = _rand_rPtr - .asFunction)>(); - - ffi.Pointer realpath( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _realpath(arg0, arg1); + /// ! + /// @method requestWithURL:cachePolicy:timeoutInterval: + /// @abstract Allocates and initializes a NSURLRequest with the given + /// URL and cache policy. + /// @param URL The URL for the request. + /// @param cachePolicy The cache policy for the request. + /// @param timeoutInterval The timeout interval for the request. See the + /// commentary for the timeoutInterval for more information on + /// timeout intervals. + /// @result A newly-created and autoreleased NSURLRequest instance. + static NSURLRequest requestWithURL$1( + objc.NSURL URL, { + required NSURLRequestCachePolicy cachePolicy, + required double timeoutInterval, + }) { + objc.checkOsVersionInternal( + 'NSURLRequest.requestWithURL:cachePolicy:timeoutInterval:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1ajs603( + _class_NSURLRequest, + _sel_requestWithURL_cachePolicy_timeoutInterval_, + URL.ref.pointer, + cachePolicy.value, + timeoutInterval, + ); + return NSURLRequest.fromPointer($ret, retain: true, release: true); } - late final _realpathPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('realpath'); - late final _realpath = _realpathPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - ffi.Pointer seed48(ffi.Pointer arg0) { - return _seed48(arg0); + /// supportsSecureCoding + static bool getSupportsSecureCoding() { + return _objc_msgSend_91o635(_class_NSURLRequest, _sel_supportsSecureCoding); } - late final _seed48Ptr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - > - >('seed48'); - late final _seed48 = _seed48Ptr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); + /// Returns a new instance of NSURLRequest constructed with the default `new` method. + NSURLRequest() : this.as(new$().object$); +} - int setenv( - ffi.Pointer __name, - ffi.Pointer __value, - int __overwrite, - ) { - return _setenv(__name, __value, __overwrite); +extension NSURLRequest$Methods on NSURLRequest { + /// ! + /// @abstract Returns the URL of the receiver. + /// @result The URL of the receiver. + objc.NSURL? get URL { + objc.checkOsVersionInternal( + 'NSURLRequest.URL', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URL); + return $ret.address == 0 + ? null + : objc.NSURL.fromPointer($ret, retain: true, release: true); } - late final _setenvPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >('setenv'); - late final _setenv = _setenvPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - void setkey(ffi.Pointer arg0) { - return _setkey(arg0); + /// ! + /// @abstract returns whether a connection created with this request is allowed to use + /// the built in cellular radios (if present). + /// @result YES if the receiver is allowed to use the built in cellular radios to + /// satisfy the request, NO otherwise. + bool get allowsCellularAccess { + objc.checkOsVersionInternal( + 'NSURLRequest.allowsCellularAccess', + iOS: (false, (6, 0, 0)), + macOS: (false, (10, 8, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsCellularAccess); } - late final _setkeyPtr = - _lookup)>>( - 'setkey', - ); - late final _setkey = _setkeyPtr - .asFunction)>(); - - ffi.Pointer setstate(ffi.Pointer arg0) { - return _setstate(arg0); + /// ! + /// @abstract returns whether a connection created with this request is allowed to use + /// network interfaces which have been marked as constrained. + /// @result YES if the receiver is allowed to use an interface marked as constrained to + /// satisfy the request, NO otherwise. + bool get allowsConstrainedNetworkAccess { + objc.checkOsVersionInternal( + 'NSURLRequest.allowsConstrainedNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_allowsConstrainedNetworkAccess, + ); } - late final _setstatePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('setstate'); - late final _setstate = _setstatePtr - .asFunction Function(ffi.Pointer)>(); - - void srand48(int arg0) { - return _srand48(arg0); + /// ! + /// @abstract returns whether a connection created with this request is allowed to use + /// network interfaces which have been marked as expensive. + /// @result YES if the receiver is allowed to use an interface marked as expensive to + /// satisfy the request, NO otherwise. + bool get allowsExpensiveNetworkAccess { + objc.checkOsVersionInternal( + 'NSURLRequest.allowsExpensiveNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_allowsExpensiveNetworkAccess, + ); } - late final _srand48Ptr = - _lookup>('srand48'); - late final _srand48 = _srand48Ptr.asFunction(); - - void srandom(int arg0) { - return _srandom(arg0); + /// ! + /// @abstract Allows storing and usage of DNS answers, potentially beyond TTL expiry, + /// in a persistent per-process cache. This should only be set for hostnames whose resolutions + /// are not expected to change across networks. + /// @discussion YES, if the DNS lookup for this request is allowed to use a persistent per-process cache, + /// NO otherwise. Defaults to NO. + bool get allowsPersistentDNS { + objc.checkOsVersionInternal( + 'NSURLRequest.allowsPersistentDNS', + iOS: (false, (18, 0, 0)), + macOS: (false, (15, 0, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsPersistentDNS); } - late final _srandomPtr = - _lookup>( - 'srandom', - ); - late final _srandom = _srandomPtr.asFunction(); - - int unlockpt(int arg0) { - return _unlockpt(arg0); + /// ! + /// @abstract returns whether we assume that server supports HTTP/3. Enables QUIC + /// racing without HTTP/3 service discovery. + /// @result YES if server endpoint is known to support HTTP/3. Defaults to NO. + /// The default may be YES in a future OS update. + bool get assumesHTTP3Capable { + objc.checkOsVersionInternal( + 'NSURLRequest.assumesHTTP3Capable', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_assumesHTTP3Capable); } - late final _unlockptPtr = - _lookup>('unlockpt'); - late final _unlockpt = _unlockptPtr.asFunction(); - - int unsetenv(ffi.Pointer arg0) { - return _unsetenv(arg0); + /// ! + /// @abstract Returns the NSURLRequestAttribution associated with this request. + /// @discussion This will return NSURLRequestAttributionDeveloper for requests that + /// have not explicitly set an attribution. + /// @result The NSURLRequestAttribution associated with this request. + NSURLRequestAttribution get attribution { + objc.checkOsVersionInternal( + 'NSURLRequest.attribution', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), + ); + final $ret = _objc_msgSend_i3avs9(object$.ref.pointer, _sel_attribution); + return NSURLRequestAttribution.fromValue($ret); } - late final _unsetenvPtr = - _lookup)>>( - 'unsetenv', - ); - late final _unsetenv = _unsetenvPtr - .asFunction)>(); - - int arc4random() { - return _arc4random(); + /// ! + /// @abstract Returns the cache policy of the receiver. + /// @result The cache policy of the receiver. + NSURLRequestCachePolicy get cachePolicy { + objc.checkOsVersionInternal( + 'NSURLRequest.cachePolicy', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_8jm3uo(object$.ref.pointer, _sel_cachePolicy); + return NSURLRequestCachePolicy.fromValue($ret); } - late final _arc4randomPtr = - _lookup>('arc4random'); - late final _arc4random = _arc4randomPtr.asFunction(); - - void arc4random_addrandom(ffi.Pointer arg0, int __datlen) { - return _arc4random_addrandom(arg0, __datlen); + /// Cookie partition identifier used for cookie storage and retrieval. + objc.NSString? get cookiePartitionIdentifier { + objc.checkOsVersionInternal( + 'NSURLRequest.cookiePartitionIdentifier', + iOS: (false, (18, 2, 0)), + macOS: (false, (15, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_cookiePartitionIdentifier, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _arc4random_addrandomPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int) - > - >('arc4random_addrandom'); - late final _arc4random_addrandom = _arc4random_addrandomPtr - .asFunction, int)>(); - - void arc4random_buf(ffi.Pointer __buf, int __nbytes) { - return _arc4random_buf(__buf, __nbytes); + /// encodeWithCoder: + void encodeWithCoder(objc.NSCoder coder) { + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_encodeWithCoder_, + coder.ref.pointer, + ); } - late final _arc4random_bufPtr = - _lookup< - ffi.NativeFunction, ffi.Size)> - >('arc4random_buf'); - late final _arc4random_buf = _arc4random_bufPtr - .asFunction, int)>(); - - void arc4random_stir() { - return _arc4random_stir(); + /// init + NSURLRequest init() { + objc.checkOsVersionInternal( + 'NSURLRequest.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } - late final _arc4random_stirPtr = - _lookup>('arc4random_stir'); - late final _arc4random_stir = _arc4random_stirPtr - .asFunction(); - - int arc4random_uniform(int __upper_bound) { - return _arc4random_uniform(__upper_bound); + /// initWithCoder: + NSURLRequest? initWithCoder(objc.NSCoder coder) { + final $ret = _objc_msgSend_1sotr3r( + object$.ref.retainAndReturnPointer(), + _sel_initWithCoder_, + coder.ref.pointer, + ); + return $ret.address == 0 + ? null + : NSURLRequest.fromPointer($ret, retain: false, release: true); } - late final _arc4random_uniformPtr = - _lookup>( - 'arc4random_uniform', - ); - late final _arc4random_uniform = _arc4random_uniformPtr - .asFunction(); - - int atexit_b(objc.ObjCBlock arg0) { - return _atexit_b(arg0.ref.pointer); + /// ! + /// @method initWithURL: + /// @abstract Initializes an NSURLRequest with the given URL. + /// @discussion Default values are used for cache policy + /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 + /// seconds). + /// @param URL The URL for the request. + /// @result An initialized NSURLRequest. + NSURLRequest initWithURL(objc.NSURL URL) { + objc.checkOsVersionInternal( + 'NSURLRequest.initWithURL:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.retainAndReturnPointer(), + _sel_initWithURL_, + URL.ref.pointer, + ); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } - late final _atexit_bPtr = - _lookup< - ffi.NativeFunction)> - >('atexit_b'); - late final _atexit_b = _atexit_bPtr - .asFunction)>(); - - ffi.Pointer bsearch_b( - ffi.Pointer __key, - ffi.Pointer __base, - int __nel, - int __width, - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - __compar, - ) { - return _bsearch_b(__key, __base, __nel, __width, __compar.ref.pointer); + /// ! + /// @method initWithURL: + /// @abstract Initializes an NSURLRequest with the given URL and + /// cache policy. + /// @discussion This is the designated initializer for the + /// NSURLRequest class. + /// @param URL The URL for the request. + /// @param cachePolicy The cache policy for the request. + /// @param timeoutInterval The timeout interval for the request. See the + /// commentary for the timeoutInterval for more information on + /// timeout intervals. + /// @result An initialized NSURLRequest. + NSURLRequest initWithURL$1( + objc.NSURL URL, { + required NSURLRequestCachePolicy cachePolicy, + required double timeoutInterval, + }) { + objc.checkOsVersionInternal( + 'NSURLRequest.initWithURL:cachePolicy:timeoutInterval:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1ajs603( + object$.ref.retainAndReturnPointer(), + _sel_initWithURL_cachePolicy_timeoutInterval_, + URL.ref.pointer, + cachePolicy.value, + timeoutInterval, + ); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } - late final _bsearch_bPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer, - ) - > - >('bsearch_b'); - late final _bsearch_b = _bsearch_bPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ffi.Pointer, - ) - >(); - - ffi.Pointer cgetcap( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ) { - return _cgetcap(arg0, arg1, arg2); + /// ! + /// @abstract The main document URL associated with this load. + /// @discussion This URL is used for the cookie "same domain as main + /// document" policy, and attributing the request as a sub-resource + /// of a user-specified URL. There may also be other future uses. + /// See setMainDocumentURL: + /// @result The main document URL. + objc.NSURL? get mainDocumentURL { + objc.checkOsVersionInternal( + 'NSURLRequest.mainDocumentURL', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_mainDocumentURL, + ); + return $ret.address == 0 + ? null + : objc.NSURL.fromPointer($ret, retain: true, release: true); } - late final _cgetcapPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >('cgetcap'); - late final _cgetcap = _cgetcapPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - int cgetclose() { - return _cgetclose(); + /// ! + /// @abstract Returns the NSURLRequestNetworkServiceType associated with this request. + /// @discussion This will return NSURLNetworkServiceTypeDefault for requests that have + /// not explicitly set a networkServiceType (using the setNetworkServiceType method). + /// @result The NSURLRequestNetworkServiceType associated with this request. + NSURLRequestNetworkServiceType get networkServiceType { + objc.checkOsVersionInternal( + 'NSURLRequest.networkServiceType', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + final $ret = _objc_msgSend_t4uaw1( + object$.ref.pointer, + _sel_networkServiceType, + ); + return NSURLRequestNetworkServiceType.fromValue($ret); } - late final _cgetclosePtr = _lookup>( - 'cgetclose', - ); - late final _cgetclose = _cgetclosePtr.asFunction(); - - int cgetent( - ffi.Pointer> arg0, - ffi.Pointer> arg1, - ffi.Pointer arg2, - ) { - return _cgetent(arg0, arg1, arg2); + /// ! + /// @abstract sets whether a request is required to do DNSSEC validation during DNS lookup. + /// @discussion YES, if the DNS lookup for this request should require DNSSEC validation, + /// No otherwise. Defaults to NO. + bool get requiresDNSSECValidation { + objc.checkOsVersionInternal( + 'NSURLRequest.requiresDNSSECValidation', + iOS: (false, (16, 1, 0)), + macOS: (false, (13, 0, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_requiresDNSSECValidation, + ); } - late final _cgetentPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer, - ) - > - >('cgetent'); - late final _cgetent = _cgetentPtr - .asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer, - ) - >(); - - int cgetfirst( - ffi.Pointer> arg0, - ffi.Pointer> arg1, - ) { - return _cgetfirst(arg0, arg1); + /// ! + /// @abstract Returns the timeout interval of the receiver. + /// @discussion The timeout interval specifies the limit on the idle + /// interval allotted to a request in the process of loading. The "idle + /// interval" is defined as the period of time that has passed since the + /// last instance of load activity occurred for a request that is in the + /// process of loading. Hence, when an instance of load activity occurs + /// (e.g. bytes are received from the network for a request), the idle + /// interval for a request is reset to 0. If the idle interval ever + /// becomes greater than or equal to the timeout interval, the request + /// is considered to have timed out. This timeout interval is measured + /// in seconds. + /// @result The timeout interval of the receiver. + double get timeoutInterval { + objc.checkOsVersionInternal( + 'NSURLRequest.timeoutInterval', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return objc.useMsgSendVariants + ? _objc_msgSend_1ukqyt8Fpret(object$.ref.pointer, _sel_timeoutInterval) + : _objc_msgSend_1ukqyt8(object$.ref.pointer, _sel_timeoutInterval); } +} - late final _cgetfirstPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Pointer>, - ) - > - >('cgetfirst'); - late final _cgetfirst = _cgetfirstPtr - .asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer>, +late final _sel_cachedResponseForRequest_ = objc.registerName( + "cachedResponseForRequest:", +); +late final _sel_storeCachedResponse_forRequest_ = objc.registerName( + "storeCachedResponse:forRequest:", +); +final _objc_msgSend_pfv6jd = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - int cgetmatch(ffi.Pointer arg0, ffi.Pointer arg1) { - return _cgetmatch(arg0, arg1); - } - - late final _cgetmatchPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('cgetmatch'); - late final _cgetmatch = _cgetmatchPtr - .asFunction, ffi.Pointer)>(); - - int cgetnext( - ffi.Pointer> arg0, - ffi.Pointer> arg1, - ) { - return _cgetnext(arg0, arg1); - } - - late final _cgetnextPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Pointer>, - ) - > - >('cgetnext'); - late final _cgetnext = _cgetnextPtr - .asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer>, - ) - >(); - - int cgetnum( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - return _cgetnum(arg0, arg1, arg2); - } - - late final _cgetnumPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('cgetnum'); - late final _cgetnum = _cgetnumPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int cgetset(ffi.Pointer arg0) { - return _cgetset(arg0); - } - - late final _cgetsetPtr = - _lookup)>>( - 'cgetset', - ); - late final _cgetset = _cgetsetPtr - .asFunction)>(); - - int cgetstr( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - ) { - return _cgetstr(arg0, arg1, arg2); - } - - late final _cgetstrPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - > - >('cgetstr'); - late final _cgetstr = _cgetstrPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_removeCachedResponseForRequest_ = objc.registerName( + "removeCachedResponseForRequest:", +); +late final _sel_removeAllCachedResponses = objc.registerName( + "removeAllCachedResponses", +); +final _objc_msgSend_1pl9qdv = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, ) - >(); - - int cgetustr( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - ) { - return _cgetustr(arg0, arg1, arg2); - } - - late final _cgetustrPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - > - >('cgetustr'); - late final _cgetustr = _cgetustrPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_removeCachedResponsesSinceDate_ = objc.registerName( + "removeCachedResponsesSinceDate:", +); +late final _sel_memoryCapacity = objc.registerName("memoryCapacity"); +final _objc_msgSend_xw2lbc = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, ) - >(); - - int daemon(int arg0, int arg1) { - return _daemon(arg0, arg1); - } - - late final _daemonPtr = - _lookup>('daemon'); - late final _daemon = _daemonPtr.asFunction(); - - ffi.Pointer devname(int arg0, int arg1) { - return _devname(arg0, arg1); - } - - late final _devnamePtr = - _lookup< - ffi.NativeFunction Function(dev_t, mode_t)> - >('devname'); - late final _devname = _devnamePtr - .asFunction Function(int, int)>(); - - ffi.Pointer devname_r( - int arg0, - int arg1, - ffi.Pointer buf, - int len, - ) { - return _devname_r(arg0, arg1, buf, len); - } - - late final _devname_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - dev_t, - mode_t, - ffi.Pointer, - ffi.Int, - ) - > - >('devname_r'); - late final _devname_r = _devname_rPtr - .asFunction< - ffi.Pointer Function(int, int, ffi.Pointer, int) - >(); - - ffi.Pointer getbsize( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _getbsize(arg0, arg1); - } - - late final _getbsizePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('getbsize'); - late final _getbsize = _getbsizePtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setMemoryCapacity_ = objc.registerName("setMemoryCapacity:"); +final _objc_msgSend_1i9r4xy = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, ) - >(); - - int getloadavg(ffi.Pointer arg0, int __nelem) { - return _getloadavg(arg0, __nelem); - } - - late final _getloadavgPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('getloadavg'); - late final _getloadavg = _getloadavgPtr - .asFunction, int)>(); + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_diskCapacity = objc.registerName("diskCapacity"); +late final _sel_setDiskCapacity_ = objc.registerName("setDiskCapacity:"); +late final _sel_currentMemoryUsage = objc.registerName("currentMemoryUsage"); +late final _sel_currentDiskUsage = objc.registerName("currentDiskUsage"); - ffi.Pointer getprogname() { - return _getprogname(); - } +/// WARNING: NSURLSessionDataTask is a stub. To generate bindings for this class, include +/// NSURLSessionDataTask in your config's objc-interfaces list. +/// +/// NSURLSessionDataTask +extension type NSURLSessionDataTask._(objc.ObjCObject object$) + implements objc.ObjCObject, NSURLSessionTask { + /// Constructs a [NSURLSessionDataTask] that points to the same underlying object as [other]. + NSURLSessionDataTask.as(objc.ObjCObject other) : object$ = other {} - late final _getprognamePtr = - _lookup Function()>>( - 'getprogname', - ); - late final _getprogname = _getprognamePtr - .asFunction Function()>(); + /// Constructs a [NSURLSessionDataTask] that wraps the given raw object pointer. + NSURLSessionDataTask.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} +} - void setprogname(ffi.Pointer arg0) { - return _setprogname(arg0); - } +late final _sel_storeCachedResponse_forDataTask_ = objc.registerName( + "storeCachedResponse:forDataTask:", +); - late final _setprognamePtr = - _lookup)>>( - 'setprogname', - ); - late final _setprogname = _setprognamePtr - .asFunction)>(); +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSCachedURLResponse { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); - int heapsort( - ffi.Pointer __base, - int __nel, - int __width, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock + fromFunctionPointer( ffi.Pointer< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function(ffi.Pointer arg0) > > - __compar, - ) { - return _heapsort(__base, __nel, __width, __compar); - } + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _heapsortPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, - ) - > - >('heapsort'); - late final _heapsort = _heapsortPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, - ) - >(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(NSCachedURLResponse?) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : NSCachedURLResponse.fromPointer( + arg0, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - int heapsort_b( - ffi.Pointer __base, - int __nel, - int __width, - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - __compar, - ) { - return _heapsort_b(__base, __nel, __width, __compar.ref.pointer); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(NSCachedURLResponse?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : NSCachedURLResponse.fromPointer( + arg0, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _heapsort_bPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer, - ) - > - >('heapsort_b'); - late final _heapsort_b = _heapsort_bPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - ffi.Pointer, - ) - >(); - - int mergesort( - ffi.Pointer __base, - int __nel, - int __width, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - > - __compar, - ) { - return _mergesort(__base, __nel, __width, __compar); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(NSCachedURLResponse?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : NSCachedURLResponse.fromPointer( + arg0, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : NSCachedURLResponse.fromPointer( + arg0, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _mergesortPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, - ) - > - >('mergesort'); - late final _mergesort = _mergesortPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, - ) - >(); - - int mergesort_b( - ffi.Pointer __base, - int __nel, - int __width, - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - __compar, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, ) { - return _mergesort_b(__base, __nel, __width, __compar.ref.pointer); + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); } - late final _mergesort_bPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Size, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( ffi.Pointer, + ffi.Pointer, ) - > - >('mergesort_b'); - late final _mergesort_b = _mergesort_bPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - ffi.Pointer, - ) - >(); - - void psort( - ffi.Pointer __base, - int __nel, - int __width, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - > - __compar, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, ) { - return _psort(__base, __nel, __width, __compar); + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _psortPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( + ffi.Pointer, ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) > - >('psort'); - late final _psort = _psortPtr - .asFunction< - void Function( - ffi.Pointer, - int, - int, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >, - ) - >(); - - void psort_b( - ffi.Pointer __base, - int __nel, - int __width, - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - __compar, - ) { - return _psort_b(__base, __nel, __width, __compar.ref.pointer); - } + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _psort_bPtr = - _lookup< +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSCachedURLResponse$CallExtension + on objc.ObjCBlock { + void call(NSCachedURLResponse? arg0) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer, + ffi.Pointer block, + ffi.Pointer arg0, ) > - >('psort_b'); - late final _psort_b = _psort_bPtr + >() .asFunction< void Function( - ffi.Pointer, - int, - int, ffi.Pointer, + ffi.Pointer, ) - >(); + >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); +} - void psort_r( - ffi.Pointer __base, - int __nel, - int __width, - ffi.Pointer arg3, - ffi.Pointer< +late final _sel_getCachedResponseForDataTask_completionHandler_ = objc + .registerName("getCachedResponseForDataTask:completionHandler:"); +final _objc_msgSend_o762yo = objc.msgSendPointer + .cast< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) > - > - __compar, - ) { - return _psort_r(__base, __nel, __width, arg3, __compar); - } + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_removeCachedResponseForDataTask_ = objc.registerName( + "removeCachedResponseForDataTask:", +); - late final _psort_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ) - > - >('psort_r'); - late final _psort_r = _psort_rPtr - .asFunction< - void Function( - ffi.Pointer, - int, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ) - >(); - - void qsort_b( - ffi.Pointer __base, - int __nel, - int __width, - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - __compar, - ) { - return _qsort_b(__base, __nel, __width, __compar.ref.pointer); - } - - late final _qsort_bPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer, - ) - > - >('qsort_b'); - late final _qsort_b = _qsort_bPtr - .asFunction< - void Function( - ffi.Pointer, - int, - int, - ffi.Pointer, - ) - >(); - - void qsort_r( - ffi.Pointer __base, - int __nel, - int __width, - ffi.Pointer arg3, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - > - __compar, - ) { - return _qsort_r(__base, __nel, __width, arg3, __compar); - } - - late final _qsort_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ) - > - >('qsort_r'); - late final _qsort_r = _qsort_rPtr - .asFunction< - void Function( - ffi.Pointer, - int, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ) - >(); - - int radixsort( - ffi.Pointer> __base, - int __nel, - ffi.Pointer __table, - int __endbyte, - ) { - return _radixsort(__base, __nel, __table, __endbyte); +/// NSURLSessionTaskAdditions +extension NSURLSessionTaskAdditions on NSURLCache { + /// getCachedResponseForDataTask:completionHandler: + void getCachedResponseForDataTask( + NSURLSessionDataTask dataTask, { + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLCache.getCachedResponseForDataTask:completionHandler:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_o762yo( + object$.ref.pointer, + _sel_getCachedResponseForDataTask_completionHandler_, + dataTask.ref.pointer, + completionHandler.ref.pointer, + ); } - late final _radixsortPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.UnsignedInt, - ) - > - >('radixsort'); - late final _radixsort = _radixsortPtr - .asFunction< - int Function( - ffi.Pointer>, - int, - ffi.Pointer, - int, - ) - >(); - - int rpmatch(ffi.Pointer arg0) { - return _rpmatch(arg0); + /// removeCachedResponseForDataTask: + void removeCachedResponseForDataTask(NSURLSessionDataTask dataTask) { + objc.checkOsVersionInternal( + 'NSURLCache.removeCachedResponseForDataTask:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_removeCachedResponseForDataTask_, + dataTask.ref.pointer, + ); } - late final _rpmatchPtr = - _lookup)>>( - 'rpmatch', - ); - late final _rpmatch = _rpmatchPtr - .asFunction)>(); - - int sradixsort( - ffi.Pointer> __base, - int __nel, - ffi.Pointer __table, - int __endbyte, - ) { - return _sradixsort(__base, __nel, __table, __endbyte); + /// storeCachedResponse:forDataTask: + void storeCachedResponse$1( + NSCachedURLResponse cachedResponse, { + required NSURLSessionDataTask forDataTask, + }) { + objc.checkOsVersionInternal( + 'NSURLCache.storeCachedResponse:forDataTask:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_storeCachedResponse_forDataTask_, + cachedResponse.ref.pointer, + forDataTask.ref.pointer, + ); } +} - late final _sradixsortPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.UnsignedInt, - ) - > - >('sradixsort'); - late final _sradixsort = _sradixsortPtr - .asFunction< - int Function( - ffi.Pointer>, - int, - ffi.Pointer, - int, - ) - >(); - - void sranddev() { - return _sranddev(); +/// NSURLCache +extension type NSURLCache._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [NSURLCache] that points to the same underlying object as [other]. + NSURLCache.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLCache', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + assert(isA(object$)); } - late final _sranddevPtr = _lookup>( - 'sranddev', - ); - late final _sranddev = _sranddevPtr.asFunction(); - - void srandomdev() { - return _srandomdev(); + /// Constructs a [NSURLCache] that wraps the given raw object pointer. + NSURLCache.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLCache', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + assert(isA(object$)); } - late final _srandomdevPtr = _lookup>( - 'srandomdev', + /// Returns whether [obj] is an instance of [NSURLCache]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLCache, ); - late final _srandomdev = _srandomdevPtr.asFunction(); - int strtonum( - ffi.Pointer __numstr, - int __minval, - int __maxval, - ffi.Pointer> __errstrp, - ) { - return _strtonum(__numstr, __minval, __maxval, __errstrp); + /// alloc + static NSURLCache alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSURLCache, _sel_alloc); + return NSURLCache.fromPointer($ret, retain: false, release: true); } - late final _strtonumPtr = - _lookup< - ffi.NativeFunction< - ffi.LongLong Function( - ffi.Pointer, - ffi.LongLong, - ffi.LongLong, - ffi.Pointer>, - ) - > - >('strtonum'); - late final _strtonum = _strtonumPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - ffi.Pointer>, - ) - >(); - - int strtoq( - ffi.Pointer __str, - ffi.Pointer> __endptr, - int __base, - ) { - return _strtoq(__str, __endptr, __base); + /// allocWithZone: + static NSURLCache allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLCache, + _sel_allocWithZone_, + zone, + ); + return NSURLCache.fromPointer($ret, retain: false, release: true); } - late final _strtoqPtr = - _lookup< - ffi.NativeFunction< - ffi.LongLong Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ) - > - >('strtoq'); - late final _strtoq = _strtoqPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - - int strtouq( - ffi.Pointer __str, - ffi.Pointer> __endptr, - int __base, - ) { - return _strtouq(__str, __endptr, __base); + /// new + static NSURLCache new$() { + final $ret = _objc_msgSend_151sglz(_class_NSURLCache, _sel_new); + return NSURLCache.fromPointer($ret, retain: false, release: true); } - late final _strtouqPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLongLong Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ) - > - >('strtouq'); - late final _strtouq = _strtouqPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - - late final ffi.Pointer> _suboptarg = - _lookup>('suboptarg'); - - ffi.Pointer get suboptarg => _suboptarg.value; - - set suboptarg(ffi.Pointer value) => _suboptarg.value = value; - - int __darwin_check_fd_set_overflow( - int arg0, - ffi.Pointer arg1, - int arg2, - ) { - return ___darwin_check_fd_set_overflow(arg0, arg1, arg2); + /// ! + /// @property sharedURLCache + /// @abstract Returns the shared NSURLCache instance or + /// sets the NSURLCache instance shared by all clients of + /// the current process. This will be the new object returned when + /// calls to the sharedURLCache method are made. + /// @discussion Unless set explicitly through a call to + /// +setSharedURLCache:, this method returns an NSURLCache + /// instance created with the following default values: + ///
    + ///
  • Memory capacity: 4 megabytes (4 * 1024 * 1024 bytes) + ///
  • Disk capacity: 20 megabytes (20 * 1024 * 1024 bytes) + ///
  • Disk path: (user home directory)/Library/Caches/(application bundle id) + ///
+ ///

Users who do not have special caching requirements or + /// constraints should find the default shared cache instance + /// acceptable. If this default shared cache instance is not + /// acceptable, +setSharedURLCache: can be called to set a + /// different NSURLCache instance to be returned from this method. + /// Callers should take care to ensure that the setter is called + /// at a time when no other caller has a reference to the previously-set + /// shared URL cache. This is to prevent storing cache data from + /// becoming unexpectedly unretrievable. + /// @result the shared NSURLCache instance. + static void setSharedURLCache(NSURLCache value) { + objc.checkOsVersionInternal( + 'NSURLCache.setSharedURLCache:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + _class_NSURLCache, + _sel_setSharedURLCache_, + value.ref.pointer, + ); } - late final ___darwin_check_fd_set_overflowPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int) - > - >('__darwin_check_fd_set_overflow'); - late final ___darwin_check_fd_set_overflow = - ___darwin_check_fd_set_overflowPtr - .asFunction, int)>(); - - ffi.Pointer sel_getName(ffi.Pointer sel) { - return _sel_getName(sel); + /// ! + /// @property sharedURLCache + /// @abstract Returns the shared NSURLCache instance or + /// sets the NSURLCache instance shared by all clients of + /// the current process. This will be the new object returned when + /// calls to the sharedURLCache method are made. + /// @discussion Unless set explicitly through a call to + /// +setSharedURLCache:, this method returns an NSURLCache + /// instance created with the following default values: + ///

    + ///
  • Memory capacity: 4 megabytes (4 * 1024 * 1024 bytes) + ///
  • Disk capacity: 20 megabytes (20 * 1024 * 1024 bytes) + ///
  • Disk path: (user home directory)/Library/Caches/(application bundle id) + ///
+ ///

Users who do not have special caching requirements or + /// constraints should find the default shared cache instance + /// acceptable. If this default shared cache instance is not + /// acceptable, +setSharedURLCache: can be called to set a + /// different NSURLCache instance to be returned from this method. + /// Callers should take care to ensure that the setter is called + /// at a time when no other caller has a reference to the previously-set + /// shared URL cache. This is to prevent storing cache data from + /// becoming unexpectedly unretrievable. + /// @result the shared NSURLCache instance. + static NSURLCache getSharedURLCache() { + objc.checkOsVersionInternal( + 'NSURLCache.sharedURLCache', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(_class_NSURLCache, _sel_sharedURLCache); + return NSURLCache.fromPointer($ret, retain: true, release: true); } - late final _sel_getNamePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sel_getName'); - late final _sel_getName = _sel_getNamePtr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); + /// Returns a new instance of NSURLCache constructed with the default `new` method. + NSURLCache() : this.as(new$().object$); +} - ffi.Pointer sel_registerName(ffi.Pointer str) { - return _sel_registerName(str); +extension NSURLCache$Methods on NSURLCache { + /// ! + /// @method cachedResponseForRequest: + /// @abstract Returns the NSCachedURLResponse stored in the cache with + /// the given request. + /// @discussion The method returns nil if there is no + /// NSCachedURLResponse stored using the given request. + /// @param request the NSURLRequest to use as a key for the lookup. + /// @result The NSCachedURLResponse stored in the cache with the given + /// request, or nil if there is no NSCachedURLResponse stored with the + /// given request. + NSCachedURLResponse? cachedResponseForRequest(NSURLRequest request) { + objc.checkOsVersionInternal( + 'NSURLCache.cachedResponseForRequest:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_cachedResponseForRequest_, + request.ref.pointer, + ); + return $ret.address == 0 + ? null + : NSCachedURLResponse.fromPointer($ret, retain: true, release: true); } - late final _sel_registerNamePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sel_registerName'); - late final _sel_registerName = _sel_registerNamePtr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); - - ffi.Pointer object_getClassName(objc.ObjCObject? obj) { - return _object_getClassName(obj?.ref.pointer ?? ffi.nullptr); + /// ! + /// @abstract Returns the current amount of space consumed by the + /// on-disk cache of the receiver. + /// @discussion This size, measured in bytes, indicates the current + /// usage of the on-disk cache. + /// @result the current usage of the on-disk cache of the receiver. + int get currentDiskUsage { + objc.checkOsVersionInternal( + 'NSURLCache.currentDiskUsage', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_currentDiskUsage); } - late final _object_getClassNamePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('object_getClassName'); - late final _object_getClassName = _object_getClassNamePtr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); - - ffi.Pointer object_getIndexedIvars(objc.ObjCObject? obj) { - return _object_getIndexedIvars(obj?.ref.pointer ?? ffi.nullptr); + /// ! + /// @abstract Returns the current amount of space consumed by the + /// in-memory cache of the receiver. + /// @discussion This size, measured in bytes, indicates the current + /// usage of the in-memory cache. + /// @result the current usage of the in-memory cache of the receiver. + int get currentMemoryUsage { + objc.checkOsVersionInternal( + 'NSURLCache.currentMemoryUsage', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_currentMemoryUsage); } - late final _object_getIndexedIvarsPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('object_getIndexedIvars'); - late final _object_getIndexedIvars = _object_getIndexedIvarsPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); - - bool sel_isMapped(ffi.Pointer sel) { - return _sel_isMapped(sel); + /// ! + /// @abstract The on-disk capacity of the receiver. + /// @discussion The on-disk capacity, measured in bytes, for the receiver. On mutation the on-disk cache will truncate its contents to the size given, if necessary. + int get diskCapacity { + objc.checkOsVersionInternal( + 'NSURLCache.diskCapacity', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_diskCapacity); } - late final _sel_isMappedPtr = - _lookup< - ffi.NativeFunction)> - >('sel_isMapped'); - late final _sel_isMapped = _sel_isMappedPtr - .asFunction)>(); - - ffi.Pointer sel_getUid(ffi.Pointer str) { - return _sel_getUid(str); + /// init + NSURLCache init() { + objc.checkOsVersionInternal( + 'NSURLCache.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLCache.fromPointer($ret, retain: false, release: true); } - late final _sel_getUidPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sel_getUid'); - late final _sel_getUid = _sel_getUidPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); - - objc.ObjCObject? objc_retainedObject(objc_objectptr_t obj) { - return _objc_retainedObject(obj).address == 0 - ? null - : objc.ObjCObject( - _objc_retainedObject(obj), - retain: true, - release: true, - ); + /// ! + /// @method initWithMemoryCapacity:diskCapacity:directoryURL: + /// @abstract Initializes an NSURLCache with the given capacity and directory. + /// @param memoryCapacity the capacity, measured in bytes, for the cache in memory. Or 0 to disable memory cache. + /// @param diskCapacity the capacity, measured in bytes, for the cache on disk. Or 0 to disable disk cache. + /// @param directoryURL the path to a directory on disk where the cache data is stored. Or nil for default directory. + /// @result an initialized NSURLCache, with the given capacity, optionally backed by disk. + NSURLCache initWithMemoryCapacity( + int memoryCapacity, { + required int diskCapacity, + objc.NSURL? directoryURL, + }) { + objc.checkOsVersionInternal( + 'NSURLCache.initWithMemoryCapacity:diskCapacity:directoryURL:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1dqnse5( + object$.ref.retainAndReturnPointer(), + _sel_initWithMemoryCapacity_diskCapacity_directoryURL_, + memoryCapacity, + diskCapacity, + directoryURL?.ref.pointer ?? ffi.nullptr, + ); + return NSURLCache.fromPointer($ret, retain: false, release: true); } - late final _objc_retainedObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(objc_objectptr_t) - > - >('objc_retainedObject'); - late final _objc_retainedObject = _objc_retainedObjectPtr - .asFunction< - ffi.Pointer Function(objc_objectptr_t) - >(); - - objc.ObjCObject? objc_unretainedObject(objc_objectptr_t obj) { - return _objc_unretainedObject(obj).address == 0 - ? null - : objc.ObjCObject( - _objc_unretainedObject(obj), - retain: true, - release: true, - ); + /// ! + /// @method initWithMemoryCapacity:diskCapacity:diskPath: + /// @abstract Initializes an NSURLCache with the given capacity and + /// path. + /// @discussion The returned NSURLCache is backed by disk, so + /// developers can be more liberal with space when choosing the + /// capacity for this kind of cache. A disk cache measured in the tens + /// of megabytes should be acceptable in most cases. + /// @param memoryCapacity the capacity, measured in bytes, for the cache in memory. + /// @param diskCapacity the capacity, measured in bytes, for the cache on disk. + /// @param path the path on disk where the cache data is stored. + /// @result an initialized NSURLCache, with the given capacity, backed + /// by disk. + NSURLCache initWithMemoryCapacity$1( + int memoryCapacity, { + required int diskCapacity, + objc.NSString? diskPath, + }) { + objc.checkOsVersionInternal( + 'NSURLCache.initWithMemoryCapacity:diskCapacity:diskPath:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1dqnse5( + object$.ref.retainAndReturnPointer(), + _sel_initWithMemoryCapacity_diskCapacity_diskPath_, + memoryCapacity, + diskCapacity, + diskPath?.ref.pointer ?? ffi.nullptr, + ); + return NSURLCache.fromPointer($ret, retain: false, release: true); } - late final _objc_unretainedObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(objc_objectptr_t) - > - >('objc_unretainedObject'); - late final _objc_unretainedObject = _objc_unretainedObjectPtr - .asFunction< - ffi.Pointer Function(objc_objectptr_t) - >(); - - objc_objectptr_t objc_unretainedPointer(objc.ObjCObject? obj) { - return _objc_unretainedPointer(obj?.ref.pointer ?? ffi.nullptr); + /// ! + /// @abstract In-memory capacity of the receiver. + /// @discussion At the time this call is made, the in-memory cache will truncate its contents to the size given, if necessary. + /// @result The in-memory capacity, measured in bytes, for the receiver. + int get memoryCapacity { + objc.checkOsVersionInternal( + 'NSURLCache.memoryCapacity', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_memoryCapacity); } - late final _objc_unretainedPointerPtr = - _lookup< - ffi.NativeFunction< - objc_objectptr_t Function(ffi.Pointer) - > - >('objc_unretainedPointer'); - late final _objc_unretainedPointer = _objc_unretainedPointerPtr - .asFunction< - objc_objectptr_t Function(ffi.Pointer) - >(); - - late final ffi.Pointer _NSFoundationVersionNumber = - _lookup('NSFoundationVersionNumber'); - - double get NSFoundationVersionNumber => _NSFoundationVersionNumber.value; - - set NSFoundationVersionNumber(double value) => - _NSFoundationVersionNumber.value = value; - - objc.NSString NSStringFromSelector(ffi.Pointer aSelector) { - return objc.NSString.fromPointer( - _NSStringFromSelector(aSelector), - retain: true, - release: true, + /// ! + /// @method removeAllCachedResponses + /// @abstract Clears the given cache, removing all NSCachedURLResponse + /// objects that it stores. + void removeAllCachedResponses() { + objc.checkOsVersionInternal( + 'NSURLCache.removeAllCachedResponses', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_removeAllCachedResponses); } - late final _NSStringFromSelectorPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - > - >('NSStringFromSelector'); - late final _NSStringFromSelector = - _NSStringFromSelectorPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - >(); - - ffi.Pointer NSSelectorFromString( - objc.NSString aSelectorName, - ) { - return _NSSelectorFromString(aSelectorName.ref.pointer); + /// ! + /// @method removeCachedResponseForRequest: + /// @abstract Removes the NSCachedURLResponse from the cache that is + /// stored using the given request. + /// @discussion No action is taken if there is no NSCachedURLResponse + /// stored with the given request. + /// @param request the NSURLRequest to use as a key for the lookup. + void removeCachedResponseForRequest(NSURLRequest request) { + objc.checkOsVersionInternal( + 'NSURLCache.removeCachedResponseForRequest:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_removeCachedResponseForRequest_, + request.ref.pointer, + ); } - late final _NSSelectorFromStringPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - > - >('NSSelectorFromString'); - late final _NSSelectorFromString = - _NSSelectorFromStringPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - >(); - - objc.NSString NSStringFromClass(objc.ObjCObject aClass) { - return objc.NSString.fromPointer( - _NSStringFromClass(aClass.ref.pointer), - retain: true, - release: true, + /// ! + /// @method removeCachedResponsesSince: + /// @abstract Clears the given cache of any cached responses since the provided date. + void removeCachedResponsesSinceDate(objc.NSDate date) { + objc.checkOsVersionInternal( + 'NSURLCache.removeCachedResponsesSinceDate:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_removeCachedResponsesSinceDate_, + date.ref.pointer, ); } - late final _NSStringFromClassPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - > - >('NSStringFromClass'); - late final _NSStringFromClass = - _NSStringFromClassPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - >(); - - objc.ObjCObject? NSClassFromString(objc.NSString aClassName) { - return _NSClassFromString(aClassName.ref.pointer).address == 0 - ? null - : objc.ObjCObject( - _NSClassFromString(aClassName.ref.pointer), - retain: true, - release: true, - ); + /// ! + /// @abstract The on-disk capacity of the receiver. + /// @discussion The on-disk capacity, measured in bytes, for the receiver. On mutation the on-disk cache will truncate its contents to the size given, if necessary. + set diskCapacity(int value) { + objc.checkOsVersionInternal( + 'NSURLCache.setDiskCapacity:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_1i9r4xy(object$.ref.pointer, _sel_setDiskCapacity_, value); } - late final _NSClassFromStringPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - > - >('NSClassFromString'); - late final _NSClassFromString = - _NSClassFromStringPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - >(); + /// ! + /// @abstract In-memory capacity of the receiver. + /// @discussion At the time this call is made, the in-memory cache will truncate its contents to the size given, if necessary. + /// @result The in-memory capacity, measured in bytes, for the receiver. + set memoryCapacity(int value) { + objc.checkOsVersionInternal( + 'NSURLCache.setMemoryCapacity:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_1i9r4xy(object$.ref.pointer, _sel_setMemoryCapacity_, value); + } - objc.NSString NSStringFromProtocol(objc.Protocol proto) { - return objc.NSString.fromPointer( - _NSStringFromProtocol(proto.ref.pointer), - retain: true, - release: true, + /// ! + /// @method storeCachedResponse:forRequest: + /// @abstract Stores the given NSCachedURLResponse in the cache using + /// the given request. + /// @param cachedResponse The cached response to store. + /// @param request the NSURLRequest to use as a key for the storage. + void storeCachedResponse( + NSCachedURLResponse cachedResponse, { + required NSURLRequest forRequest, + }) { + objc.checkOsVersionInternal( + 'NSURLCache.storeCachedResponse:forRequest:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_storeCachedResponse_forRequest_, + cachedResponse.ref.pointer, + forRequest.ref.pointer, ); } +} - late final _NSStringFromProtocolPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - > - >('NSStringFromProtocol'); - late final _NSStringFromProtocol = - _NSStringFromProtocolPtr.asFunction< - ffi.Pointer Function( +late final _class_NSMutableURLRequest = objc.getClass("NSMutableURLRequest"); +late final _sel_setURL_ = objc.registerName("setURL:"); +late final _sel_setCachePolicy_ = objc.registerName("setCachePolicy:"); +final _objc_msgSend_1yjxuv2 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, ) - >(); - - objc.Protocol? NSProtocolFromString(objc.NSString namestr) { - return _NSProtocolFromString(namestr.ref.pointer).address == 0 - ? null - : objc.Protocol.fromPointer( - _NSProtocolFromString(namestr.ref.pointer), - retain: true, - release: true, - ); - } - - late final _NSProtocolFromStringPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ) - > - >('NSProtocolFromString'); - late final _NSProtocolFromString = - _NSProtocolFromStringPtr.asFunction< - ffi.Pointer Function( + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_setTimeoutInterval_ = objc.registerName("setTimeoutInterval:"); +final _objc_msgSend_hwm8nu = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( ffi.Pointer, + ffi.Pointer, + ffi.Double, ) - >(); - - ffi.Pointer NSGetSizeAndAlignment( - ffi.Pointer typePtr, - ffi.Pointer sizep, - ffi.Pointer alignp, - ) { - return _NSGetSizeAndAlignment(typePtr, sizep, alignp); - } - - late final _NSGetSizeAndAlignmentPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('NSGetSizeAndAlignment'); - late final _NSGetSizeAndAlignment = - _NSGetSizeAndAlignmentPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + double, + ) + >(); +late final _sel_setMainDocumentURL_ = objc.registerName("setMainDocumentURL:"); +late final _sel_setNetworkServiceType_ = objc.registerName( + "setNetworkServiceType:", +); +final _objc_msgSend_1mse4s1 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, ) - >(); - - void NSLog(objc.NSString format) { - return _NSLog(format.ref.pointer); - } - - late final _NSLogPtr = - _lookup< - ffi.NativeFunction)> - >('NSLog'); - late final _NSLog = - _NSLogPtr.asFunction)>(); + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_setAllowsCellularAccess_ = objc.registerName( + "setAllowsCellularAccess:", +); +final _objc_msgSend_1s56lr9 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + bool, + ) + >(); +late final _sel_setAllowsExpensiveNetworkAccess_ = objc.registerName( + "setAllowsExpensiveNetworkAccess:", +); +late final _sel_setAllowsConstrainedNetworkAccess_ = objc.registerName( + "setAllowsConstrainedNetworkAccess:", +); +late final _sel_setAssumesHTTP3Capable_ = objc.registerName( + "setAssumesHTTP3Capable:", +); +late final _sel_setAttribution_ = objc.registerName("setAttribution:"); +final _objc_msgSend_1nw1jep = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_setRequiresDNSSECValidation_ = objc.registerName( + "setRequiresDNSSECValidation:", +); +late final _sel_setAllowsPersistentDNS_ = objc.registerName( + "setAllowsPersistentDNS:", +); +late final _sel_setCookiePartitionIdentifier_ = objc.registerName( + "setCookiePartitionIdentifier:", +); +late final _sel_setHTTPMethod_ = objc.registerName("setHTTPMethod:"); +late final _sel_setAllHTTPHeaderFields_ = objc.registerName( + "setAllHTTPHeaderFields:", +); +late final _sel_setValue_forHTTPHeaderField_ = objc.registerName( + "setValue:forHTTPHeaderField:", +); +late final _sel_addValue_forHTTPHeaderField_ = objc.registerName( + "addValue:forHTTPHeaderField:", +); +late final _sel_setHTTPBody_ = objc.registerName("setHTTPBody:"); +late final _sel_setHTTPBodyStream_ = objc.registerName("setHTTPBodyStream:"); +late final _sel_setHTTPShouldHandleCookies_ = objc.registerName( + "setHTTPShouldHandleCookies:", +); +late final _sel_setHTTPShouldUsePipelining_ = objc.registerName( + "setHTTPShouldUsePipelining:", +); - void NSLogv(objc.NSString format, va_list args) { - return _NSLogv(format.ref.pointer, args); +/// ! +/// @category NSMutableURLRequest(NSMutableHTTPURLRequest) +/// The NSMutableHTTPURLRequest on NSMutableURLRequest provides methods +/// for configuring information specific to HTTP protocol requests. +extension NSMutableHTTPURLRequest on NSMutableURLRequest { + /// ! + /// @abstract Sets the request body data of the receiver. + /// @discussion This data is sent as the message body of the request, as + /// in done in an HTTP POST request. + objc.NSData? get HTTPBody { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPBody', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPBody); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); } - late final _NSLogvPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, va_list) - > - >('NSLogv'); - late final _NSLogv = - _NSLogvPtr.asFunction< - void Function(ffi.Pointer, va_list) - >(); - - late final ffi.Pointer _NSNotFound = _lookup( - 'NSNotFound', - ); - - DartNSInteger get NSNotFound => _NSNotFound.value; - - ffi.Pointer _Block_copy(ffi.Pointer aBlock) { - return __Block_copy(aBlock); + /// ! + /// @abstract Sets the request body to be the contents of the given stream. + /// @discussion The provided stream should be unopened; the request will take + /// over the stream's delegate. The entire stream's contents will be + /// transmitted as the HTTP body of the request. Note that the body stream + /// and the body data (set by setHTTPBody:, above) are mutually exclusive + /// - setting one will clear the other. + objc.NSInputStream? get HTTPBodyStream { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPBodyStream', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_HTTPBodyStream, + ); + return $ret.address == 0 + ? null + : objc.NSInputStream.fromPointer($ret, retain: true, release: true); } - late final __Block_copyPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('_Block_copy'); - late final __Block_copy = __Block_copyPtr - .asFunction Function(ffi.Pointer)>(); - - void _Block_release(ffi.Pointer aBlock) { - return __Block_release(aBlock); + /// ! + /// @abstract Sets the HTTP request method of the receiver. + objc.NSString get HTTPMethod { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPMethod', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPMethod); + return objc.NSString.fromPointer($ret, retain: true, release: true); } - late final __Block_releasePtr = - _lookup)>>( - '_Block_release', - ); - late final __Block_release = __Block_releasePtr - .asFunction)>(); - - void _Block_object_assign( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ) { - return __Block_object_assign(arg0, arg1, arg2); + /// ! + /// @abstract Decide whether default cookie handling will happen for + /// this request (YES if cookies should be sent with and set for this request; + /// otherwise NO). + /// @discussion The default is YES - in other words, cookies are sent from and + /// stored to the cookie manager by default. + /// NOTE: In releases prior to 10.3, this value is ignored + bool get HTTPShouldHandleCookies { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPShouldHandleCookies', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_HTTPShouldHandleCookies, + ); } - late final __Block_object_assignPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >('_Block_object_assign'); - late final __Block_object_assign = __Block_object_assignPtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); - - void _Block_object_dispose(ffi.Pointer arg0, int arg1) { - return __Block_object_dispose(arg0, arg1); + /// ! + /// @abstract Sets whether the request should not wait for the previous response + /// before transmitting (YES if the receiver should transmit before the previous response is + /// received. NO to wait for the previous response before transmitting) + /// @discussion Calling this method with a YES value does not guarantee HTTP + /// pipelining behavior. This method may have no effect if an HTTP proxy is + /// configured, or if the HTTP request uses an unsafe request method (e.g., POST + /// requests will not pipeline). Pipelining behavior also may not begin until + /// the second request on a given TCP connection. There may be other situations + /// where pipelining does not occur even though YES was set. + /// HTTP 1.1 allows the client to send multiple requests to the server without + /// waiting for a response. Though HTTP 1.1 requires support for pipelining, + /// some servers report themselves as being HTTP 1.1 but do not support + /// pipelining (disconnecting, sending resources misordered, omitting part of + /// a resource, etc.). + bool get HTTPShouldUsePipelining { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPShouldUsePipelining', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_HTTPShouldUsePipelining, + ); } - late final __Block_object_disposePtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('_Block_object_dispose'); - late final __Block_object_dispose = __Block_object_disposePtr - .asFunction, int)>(); - - late final ffi.Pointer> __NSConcreteGlobalBlock = - _lookup>('_NSConcreteGlobalBlock'); - - ffi.Pointer> get _NSConcreteGlobalBlock => - __NSConcreteGlobalBlock; - - late final ffi.Pointer> __NSConcreteStackBlock = - _lookup>('_NSConcreteStackBlock'); - - ffi.Pointer> get _NSConcreteStackBlock => - __NSConcreteStackBlock; - - void Debugger() { - return _Debugger(); + /// ! + /// @method addValue:forHTTPHeaderField: + /// @abstract Adds an HTTP header field in the current header + /// dictionary. + /// @discussion This method provides a way to add values to header + /// fields incrementally. If a value was previously set for the given + /// header field, the given value is appended to the previously-existing + /// value. The appropriate field delimiter, a comma in the case of HTTP, + /// is added by the implementation, and should not be added to the given + /// value by the caller. Note that, in keeping with the HTTP RFC, HTTP + /// header field names are case-insensitive. + /// @param value the header field value. + /// @param field the header field name (case-insensitive). + void addValue( + objc.NSString value, { + required objc.NSString forHTTPHeaderField, + }) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.addValue:forHTTPHeaderField:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_addValue_forHTTPHeaderField_, + value.ref.pointer, + forHTTPHeaderField.ref.pointer, + ); } - late final _DebuggerPtr = _lookup>( - 'Debugger', - ); - late final _Debugger = _DebuggerPtr.asFunction(); - - void DebugStr(ConstStr255Param debuggerMsg) { - return _DebugStr(debuggerMsg); + /// ! + /// @abstract Sets the HTTP header fields of the receiver to the given + /// dictionary. + /// @discussion This method replaces all header fields that may have + /// existed before this method call. + ///

Since HTTP header fields must be string values, each object and + /// key in the dictionary passed to this method must answer YES when + /// sent an -isKindOfClass:[NSString class] message. If either + /// the key or value for a key-value pair answers NO when sent this + /// message, the key-value pair is skipped. + objc.NSDictionary? get allHTTPHeaderFields { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allHTTPHeaderFields', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_allHTTPHeaderFields, + ); + return $ret.address == 0 + ? null + : objc.NSDictionary.fromPointer($ret, retain: true, release: true); } - late final _DebugStrPtr = - _lookup>( - 'DebugStr', - ); - late final _DebugStr = - _DebugStrPtr.asFunction(); - - void SysBreak() { - return _SysBreak(); + /// ! + /// @abstract Sets the HTTP header fields of the receiver to the given + /// dictionary. + /// @discussion This method replaces all header fields that may have + /// existed before this method call. + ///

Since HTTP header fields must be string values, each object and + /// key in the dictionary passed to this method must answer YES when + /// sent an -isKindOfClass:[NSString class] message. If either + /// the key or value for a key-value pair answers NO when sent this + /// message, the key-value pair is skipped. + set allHTTPHeaderFields(objc.NSDictionary? value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAllHTTPHeaderFields:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setAllHTTPHeaderFields_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _SysBreakPtr = _lookup>( - 'SysBreak', - ); - late final _SysBreak = _SysBreakPtr.asFunction(); - - void SysBreakStr(ConstStr255Param debuggerMsg) { - return _SysBreakStr(debuggerMsg); + /// ! + /// @abstract Sets the request body data of the receiver. + /// @discussion This data is sent as the message body of the request, as + /// in done in an HTTP POST request. + set HTTPBody(objc.NSData? value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setHTTPBody:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setHTTPBody_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _SysBreakStrPtr = - _lookup>( - 'SysBreakStr', - ); - late final _SysBreakStr = - _SysBreakStrPtr.asFunction(); - - void SysBreakFunc(ConstStr255Param debuggerMsg) { - return _SysBreakFunc(debuggerMsg); + /// ! + /// @abstract Sets the request body to be the contents of the given stream. + /// @discussion The provided stream should be unopened; the request will take + /// over the stream's delegate. The entire stream's contents will be + /// transmitted as the HTTP body of the request. Note that the body stream + /// and the body data (set by setHTTPBody:, above) are mutually exclusive + /// - setting one will clear the other. + set HTTPBodyStream(objc.NSInputStream? value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setHTTPBodyStream:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setHTTPBodyStream_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _SysBreakFuncPtr = - _lookup>( - 'SysBreakFunc', - ); - late final _SysBreakFunc = - _SysBreakFuncPtr.asFunction(); - - late final ffi.Pointer _kCFCoreFoundationVersionNumber = - _lookup('kCFCoreFoundationVersionNumber'); - - double get kCFCoreFoundationVersionNumber => - _kCFCoreFoundationVersionNumber.value; - - set kCFCoreFoundationVersionNumber(double value) => - _kCFCoreFoundationVersionNumber.value = value; - - late final ffi.Pointer _kCFNotFound = _lookup( - 'kCFNotFound', - ); - - DartCFIndex get kCFNotFound => _kCFNotFound.value; - - CFRange __CFRangeMake(int loc, int len) { - return ___CFRangeMake(loc, len); + /// ! + /// @abstract Sets the HTTP request method of the receiver. + set HTTPMethod(objc.NSString value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setHTTPMethod:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setHTTPMethod_, + value.ref.pointer, + ); } - late final ___CFRangeMakePtr = - _lookup>( - '__CFRangeMake', - ); - late final ___CFRangeMake = ___CFRangeMakePtr - .asFunction(); - - int CFNullGetTypeID() { - return _CFNullGetTypeID(); + /// ! + /// @abstract Decide whether default cookie handling will happen for + /// this request (YES if cookies should be sent with and set for this request; + /// otherwise NO). + /// @discussion The default is YES - in other words, cookies are sent from and + /// stored to the cookie manager by default. + /// NOTE: In releases prior to 10.3, this value is ignored + set HTTPShouldHandleCookies(bool value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setHTTPShouldHandleCookies:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setHTTPShouldHandleCookies_, + value, + ); } - late final _CFNullGetTypeIDPtr = - _lookup>('CFNullGetTypeID'); - late final _CFNullGetTypeID = - _CFNullGetTypeIDPtr.asFunction(); - - late final ffi.Pointer _kCFNull = _lookup('kCFNull'); - - CFNullRef get kCFNull => _kCFNull.value; - - late final ffi.Pointer _kCFAllocatorDefault = - _lookup('kCFAllocatorDefault'); - - CFAllocatorRef get kCFAllocatorDefault => _kCFAllocatorDefault.value; - - late final ffi.Pointer _kCFAllocatorSystemDefault = - _lookup('kCFAllocatorSystemDefault'); - - CFAllocatorRef get kCFAllocatorSystemDefault => - _kCFAllocatorSystemDefault.value; - - late final ffi.Pointer _kCFAllocatorMalloc = - _lookup('kCFAllocatorMalloc'); - - CFAllocatorRef get kCFAllocatorMalloc => _kCFAllocatorMalloc.value; - - late final ffi.Pointer _kCFAllocatorMallocZone = - _lookup('kCFAllocatorMallocZone'); - - CFAllocatorRef get kCFAllocatorMallocZone => _kCFAllocatorMallocZone.value; - - late final ffi.Pointer _kCFAllocatorNull = - _lookup('kCFAllocatorNull'); - - CFAllocatorRef get kCFAllocatorNull => _kCFAllocatorNull.value; - - late final ffi.Pointer _kCFAllocatorUseContext = - _lookup('kCFAllocatorUseContext'); - - CFAllocatorRef get kCFAllocatorUseContext => _kCFAllocatorUseContext.value; - - int CFAllocatorGetTypeID() { - return _CFAllocatorGetTypeID(); + /// ! + /// @abstract Sets whether the request should not wait for the previous response + /// before transmitting (YES if the receiver should transmit before the previous response is + /// received. NO to wait for the previous response before transmitting) + /// @discussion Calling this method with a YES value does not guarantee HTTP + /// pipelining behavior. This method may have no effect if an HTTP proxy is + /// configured, or if the HTTP request uses an unsafe request method (e.g., POST + /// requests will not pipeline). Pipelining behavior also may not begin until + /// the second request on a given TCP connection. There may be other situations + /// where pipelining does not occur even though YES was set. + /// HTTP 1.1 allows the client to send multiple requests to the server without + /// waiting for a response. Though HTTP 1.1 requires support for pipelining, + /// some servers report themselves as being HTTP 1.1 but do not support + /// pipelining (disconnecting, sending resources misordered, omitting part of + /// a resource, etc.). + set HTTPShouldUsePipelining(bool value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setHTTPShouldUsePipelining:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setHTTPShouldUsePipelining_, + value, + ); } - late final _CFAllocatorGetTypeIDPtr = - _lookup>('CFAllocatorGetTypeID'); - late final _CFAllocatorGetTypeID = - _CFAllocatorGetTypeIDPtr.asFunction(); - - void CFAllocatorSetDefault(CFAllocatorRef allocator) { - return _CFAllocatorSetDefault(allocator); + /// ! + /// @method setValue:forHTTPHeaderField: + /// @abstract Sets the value of the given HTTP header field. + /// @discussion If a value was previously set for the given header + /// field, that value is replaced with the given value. Note that, in + /// keeping with the HTTP RFC, HTTP header field names are + /// case-insensitive. + /// @param value the header field value. + /// @param field the header field name (case-insensitive). + void setValue( + objc.NSString? value, { + required objc.NSString forHTTPHeaderField, + }) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setValue:forHTTPHeaderField:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_setValue_forHTTPHeaderField_, + value?.ref.pointer ?? ffi.nullptr, + forHTTPHeaderField.ref.pointer, + ); } +} - late final _CFAllocatorSetDefaultPtr = - _lookup>( - 'CFAllocatorSetDefault', - ); - late final _CFAllocatorSetDefault = - _CFAllocatorSetDefaultPtr.asFunction(); - - CFAllocatorRef CFAllocatorGetDefault() { - return _CFAllocatorGetDefault(); +/// ! +/// @class NSMutableURLRequest +/// +/// @abstract An NSMutableURLRequest object represents a mutable URL load +/// request in a manner independent of protocol and URL scheme. +/// +/// @discussion This specialization of NSURLRequest is provided to aid +/// developers who may find it more convenient to mutate a single request +/// object for a series of URL loads instead of creating an immutable +/// NSURLRequest for each load. This programming model is supported by +/// the following contract stipulation between NSMutableURLRequest and +/// NSURLConnection: NSURLConnection makes a deep copy of each +/// NSMutableURLRequest object passed to one of its initializers. +///

NSMutableURLRequest is designed to be extended to support +/// protocol-specific data by adding categories to access a property +/// object provided in an interface targeted at protocol implementors. +///

    +///
  • Protocol implementors should direct their attention to the +/// NSMutableURLRequestExtensibility category on +/// NSMutableURLRequest for more information on how to provide +/// extensions on NSMutableURLRequest to support protocol-specific +/// request information. +///
  • Clients of this API who wish to create NSMutableURLRequest +/// objects to load URL content should consult the protocol-specific +/// NSMutableURLRequest categories that are available. The +/// NSMutableHTTPURLRequest category on NSMutableURLRequest is an +/// example. +///
+extension type NSMutableURLRequest._(objc.ObjCObject object$) + implements objc.ObjCObject, NSURLRequest { + /// Constructs a [NSMutableURLRequest] that points to the same underlying object as [other]. + NSMutableURLRequest.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSMutableURLRequest', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + assert(isA(object$)); } - late final _CFAllocatorGetDefaultPtr = - _lookup>( - 'CFAllocatorGetDefault', - ); - late final _CFAllocatorGetDefault = - _CFAllocatorGetDefaultPtr.asFunction(); - - CFAllocatorRef CFAllocatorCreate( - CFAllocatorRef allocator, - ffi.Pointer context, - ) { - return _CFAllocatorCreate(allocator, context); + /// Constructs a [NSMutableURLRequest] that wraps the given raw object pointer. + NSMutableURLRequest.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + assert(isA(object$)); } - late final _CFAllocatorCreatePtr = - _lookup< - ffi.NativeFunction< - CFAllocatorRef Function( - CFAllocatorRef, - ffi.Pointer, - ) - > - >('CFAllocatorCreate'); - late final _CFAllocatorCreate = - _CFAllocatorCreatePtr.asFunction< - CFAllocatorRef Function(CFAllocatorRef, ffi.Pointer) - >(); - - CFAllocatorRef CFAllocatorCreateWithZone( - CFAllocatorRef allocator, - ffi.Pointer<_malloc_zone_t> zone, - ) { - return _CFAllocatorCreateWithZone(allocator, zone); - } + /// Returns whether [obj] is an instance of [NSMutableURLRequest]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMutableURLRequest, + ); - late final _CFAllocatorCreateWithZonePtr = - _lookup< - ffi.NativeFunction< - CFAllocatorRef Function(CFAllocatorRef, ffi.Pointer<_malloc_zone_t>) - > - >('CFAllocatorCreateWithZone'); - late final _CFAllocatorCreateWithZone = - _CFAllocatorCreateWithZonePtr.asFunction< - CFAllocatorRef Function(CFAllocatorRef, ffi.Pointer<_malloc_zone_t>) - >(); - - ffi.Pointer CFAllocatorAllocateTyped( - CFAllocatorRef allocator, - int size, - int descriptor, - int hint, - ) { - return _CFAllocatorAllocateTyped(allocator, size, descriptor, hint); + /// alloc + static NSMutableURLRequest alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSMutableURLRequest, _sel_alloc); + return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); } - late final _CFAllocatorAllocateTypedPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - CFAllocatorRef, - CFIndex, - CFAllocatorTypeID, - CFOptionFlags, - ) - > - >('CFAllocatorAllocateTyped'); - late final _CFAllocatorAllocateTyped = - _CFAllocatorAllocateTypedPtr.asFunction< - ffi.Pointer Function(CFAllocatorRef, int, int, int) - >(); - - ffi.Pointer CFAllocatorReallocateTyped( - CFAllocatorRef allocator, - ffi.Pointer ptr, - int newsize, - int descriptor, - int hint, - ) { - return _CFAllocatorReallocateTyped( - allocator, - ptr, - newsize, - descriptor, - hint, + /// allocWithZone: + static NSMutableURLRequest allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSMutableURLRequest, + _sel_allocWithZone_, + zone, ); + return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); } - late final _CFAllocatorReallocateTypedPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFAllocatorTypeID, - CFOptionFlags, - ) - > - >('CFAllocatorReallocateTyped'); - late final _CFAllocatorReallocateTyped = - _CFAllocatorReallocateTypedPtr.asFunction< - ffi.Pointer Function( - CFAllocatorRef, - ffi.Pointer, - int, - int, - int, - ) - >(); - - ffi.Pointer CFAllocatorAllocateBytes( - CFAllocatorRef allocator, - int size, - int hint, - ) { - return _CFAllocatorAllocateBytes(allocator, size, hint); + /// new + static NSMutableURLRequest new$() { + final $ret = _objc_msgSend_151sglz(_class_NSMutableURLRequest, _sel_new); + return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); } - late final _CFAllocatorAllocateBytesPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFAllocatorRef, CFIndex, CFOptionFlags) - > - >('CFAllocatorAllocateBytes'); - late final _CFAllocatorAllocateBytes = - _CFAllocatorAllocateBytesPtr.asFunction< - ffi.Pointer Function(CFAllocatorRef, int, int) - >(); - - ffi.Pointer CFAllocatorReallocateBytes( - CFAllocatorRef allocator, - ffi.Pointer ptr, - int newsize, - int hint, - ) { - return _CFAllocatorReallocateBytes(allocator, ptr, newsize, hint); + /// ! + /// @method requestWithURL: + /// @abstract Allocates and initializes an NSURLRequest with the given + /// URL. + /// @discussion Default values are used for cache policy + /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 + /// seconds). + /// @param URL The URL for the request. + /// @result A newly-created and autoreleased NSURLRequest instance. + static NSMutableURLRequest requestWithURL(objc.NSURL URL) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.requestWithURL:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _class_NSMutableURLRequest, + _sel_requestWithURL_, + URL.ref.pointer, + ); + return NSMutableURLRequest.fromPointer($ret, retain: true, release: true); } - late final _CFAllocatorReallocateBytesPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFOptionFlags, - ) - > - >('CFAllocatorReallocateBytes'); - late final _CFAllocatorReallocateBytes = - _CFAllocatorReallocateBytesPtr.asFunction< - ffi.Pointer Function( - CFAllocatorRef, - ffi.Pointer, - int, - int, - ) - >(); - - ffi.Pointer CFAllocatorAllocate( - CFAllocatorRef allocator, - int size, - int hint, - ) { - return _CFAllocatorAllocate(allocator, size, hint); + /// ! + /// @method requestWithURL:cachePolicy:timeoutInterval: + /// @abstract Allocates and initializes a NSURLRequest with the given + /// URL and cache policy. + /// @param URL The URL for the request. + /// @param cachePolicy The cache policy for the request. + /// @param timeoutInterval The timeout interval for the request. See the + /// commentary for the timeoutInterval for more information on + /// timeout intervals. + /// @result A newly-created and autoreleased NSURLRequest instance. + static NSMutableURLRequest requestWithURL$1( + objc.NSURL URL, { + required NSURLRequestCachePolicy cachePolicy, + required double timeoutInterval, + }) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.requestWithURL:cachePolicy:timeoutInterval:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1ajs603( + _class_NSMutableURLRequest, + _sel_requestWithURL_cachePolicy_timeoutInterval_, + URL.ref.pointer, + cachePolicy.value, + timeoutInterval, + ); + return NSMutableURLRequest.fromPointer($ret, retain: true, release: true); } - late final _CFAllocatorAllocatePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFAllocatorRef, CFIndex, CFOptionFlags) - > - >('CFAllocatorAllocate'); - late final _CFAllocatorAllocate = - _CFAllocatorAllocatePtr.asFunction< - ffi.Pointer Function(CFAllocatorRef, int, int) - >(); - - ffi.Pointer CFAllocatorReallocate( - CFAllocatorRef allocator, - ffi.Pointer ptr, - int newsize, - int hint, - ) { - return _CFAllocatorReallocate(allocator, ptr, newsize, hint); + /// supportsSecureCoding + static bool getSupportsSecureCoding() { + return _objc_msgSend_91o635( + _class_NSMutableURLRequest, + _sel_supportsSecureCoding, + ); } - late final _CFAllocatorReallocatePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFOptionFlags, - ) - > - >('CFAllocatorReallocate'); - late final _CFAllocatorReallocate = - _CFAllocatorReallocatePtr.asFunction< - ffi.Pointer Function( - CFAllocatorRef, - ffi.Pointer, - int, - int, - ) - >(); + /// Returns a new instance of NSMutableURLRequest constructed with the default `new` method. + NSMutableURLRequest() : this.as(new$().object$); +} - void CFAllocatorDeallocate( - CFAllocatorRef allocator, - ffi.Pointer ptr, - ) { - return _CFAllocatorDeallocate(allocator, ptr); +extension NSMutableURLRequest$Methods on NSMutableURLRequest { + /// ! + /// @abstract The URL of the receiver. + objc.NSURL? get URL { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.URL', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URL); + return $ret.address == 0 + ? null + : objc.NSURL.fromPointer($ret, retain: true, release: true); } - late final _CFAllocatorDeallocatePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFAllocatorRef, ffi.Pointer) - > - >('CFAllocatorDeallocate'); - late final _CFAllocatorDeallocate = - _CFAllocatorDeallocatePtr.asFunction< - void Function(CFAllocatorRef, ffi.Pointer) - >(); - - int CFAllocatorGetPreferredSizeForSize( - CFAllocatorRef allocator, - int size, - int hint, - ) { - return _CFAllocatorGetPreferredSizeForSize(allocator, size, hint); + /// ! + /// @abstract sets whether a connection created with this request is allowed to use + /// the built in cellular radios (if present). + /// @discussion NO if the receiver should not be allowed to use the built in + /// cellular radios to satisfy the request, YES otherwise. The default is YES. + bool get allowsCellularAccess { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsCellularAccess', + iOS: (false, (6, 0, 0)), + macOS: (false, (10, 8, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsCellularAccess); } - late final _CFAllocatorGetPreferredSizeForSizePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFAllocatorRef, CFIndex, CFOptionFlags) - > - >('CFAllocatorGetPreferredSizeForSize'); - late final _CFAllocatorGetPreferredSizeForSize = - _CFAllocatorGetPreferredSizeForSizePtr.asFunction< - int Function(CFAllocatorRef, int, int) - >(); - - void CFAllocatorGetContext( - CFAllocatorRef allocator, - ffi.Pointer context, - ) { - return _CFAllocatorGetContext(allocator, context); + /// ! + /// @abstract sets whether a connection created with this request is allowed to use + /// network interfaces which have been marked as constrained. + /// @discussion NO if the receiver should not be allowed to use an interface marked as constrained to + /// satisfy the request, YES otherwise. + bool get allowsConstrainedNetworkAccess { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsConstrainedNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_allowsConstrainedNetworkAccess, + ); } - late final _CFAllocatorGetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFAllocatorRef, ffi.Pointer) - > - >('CFAllocatorGetContext'); - late final _CFAllocatorGetContext = - _CFAllocatorGetContextPtr.asFunction< - void Function(CFAllocatorRef, ffi.Pointer) - >(); - - int CFGetTypeID(CFTypeRef cf) { - return _CFGetTypeID(cf); + /// ! + /// @abstract sets whether a connection created with this request is allowed to use + /// network interfaces which have been marked as expensive. + /// @discussion NO if the receiver should not be allowed to use an interface marked as expensive to + /// satisfy the request, YES otherwise. + bool get allowsExpensiveNetworkAccess { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsExpensiveNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_allowsExpensiveNetworkAccess, + ); } - late final _CFGetTypeIDPtr = - _lookup>('CFGetTypeID'); - late final _CFGetTypeID = - _CFGetTypeIDPtr.asFunction(); - - CFStringRef CFCopyTypeIDDescription(int type_id) { - return _CFCopyTypeIDDescription(type_id); + /// ! + /// @abstract Allows storing and usage of DNS answers, potentially beyond TTL expiry, + /// in a persistent per-process cache. This should only be set for hostnames whose resolutions + /// are not expected to change across networks. + /// @discussion YES, if the DNS lookup for this request is allowed to use a persistent per-process cache, + /// NO otherwise. Defaults to NO. + bool get allowsPersistentDNS { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsPersistentDNS', + iOS: (false, (18, 0, 0)), + macOS: (false, (15, 0, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsPersistentDNS); } - late final _CFCopyTypeIDDescriptionPtr = - _lookup>( - 'CFCopyTypeIDDescription', - ); - late final _CFCopyTypeIDDescription = - _CFCopyTypeIDDescriptionPtr.asFunction(); - - CFTypeRef CFRetain(CFTypeRef cf) { - return _CFRetain(cf); + /// ! + /// @abstract returns whether we assume that server supports HTTP/3. Enables QUIC + /// racing without HTTP/3 service discovery. + /// @result YES if server endpoint is known to support HTTP/3. Defaults to NO. + /// The default may be YES in a future OS update. + bool get assumesHTTP3Capable { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.assumesHTTP3Capable', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_assumesHTTP3Capable); } - late final _CFRetainPtr = - _lookup>('CFRetain'); - late final _CFRetain = - _CFRetainPtr.asFunction(); - - void CFRelease(CFTypeRef cf) { - return _CFRelease(cf); + /// ! + /// @abstract Sets the NSURLRequestAttribution to associate with this request. + /// @discussion Set to NSURLRequestAttributionUser if the URL was specified by the + /// user. Defaults to NSURLRequestAttributionDeveloper. + NSURLRequestAttribution get attribution { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.attribution', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), + ); + final $ret = _objc_msgSend_i3avs9(object$.ref.pointer, _sel_attribution); + return NSURLRequestAttribution.fromValue($ret); } - late final _CFReleasePtr = - _lookup>('CFRelease'); - late final _CFRelease = _CFReleasePtr.asFunction(); - - CFTypeRef CFAutorelease(CFTypeRef arg) { - return _CFAutorelease(arg); + /// ! + /// @abstract The cache policy of the receiver. + NSURLRequestCachePolicy get cachePolicy { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.cachePolicy', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_8jm3uo(object$.ref.pointer, _sel_cachePolicy); + return NSURLRequestCachePolicy.fromValue($ret); } - late final _CFAutoreleasePtr = - _lookup>( - 'CFAutorelease', - ); - late final _CFAutorelease = - _CFAutoreleasePtr.asFunction(); - - int CFGetRetainCount(CFTypeRef cf) { - return _CFGetRetainCount(cf); + /// Cookie partition identifier used for cookie storage and retrieval. + objc.NSString? get cookiePartitionIdentifier { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.cookiePartitionIdentifier', + iOS: (false, (18, 2, 0)), + macOS: (false, (15, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_cookiePartitionIdentifier, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _CFGetRetainCountPtr = - _lookup>( - 'CFGetRetainCount', - ); - late final _CFGetRetainCount = - _CFGetRetainCountPtr.asFunction(); - - int CFEqual(CFTypeRef cf1, CFTypeRef cf2) { - return _CFEqual(cf1, cf2); + /// init + NSMutableURLRequest init() { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); } - late final _CFEqualPtr = - _lookup>( - 'CFEqual', - ); - late final _CFEqual = - _CFEqualPtr.asFunction(); - - int CFHash(CFTypeRef cf) { - return _CFHash(cf); + /// initWithCoder: + NSMutableURLRequest? initWithCoder(objc.NSCoder coder) { + final $ret = _objc_msgSend_1sotr3r( + object$.ref.retainAndReturnPointer(), + _sel_initWithCoder_, + coder.ref.pointer, + ); + return $ret.address == 0 + ? null + : NSMutableURLRequest.fromPointer($ret, retain: false, release: true); } - late final _CFHashPtr = - _lookup>('CFHash'); - late final _CFHash = _CFHashPtr.asFunction(); - - CFStringRef CFCopyDescription(CFTypeRef cf) { - return _CFCopyDescription(cf); + /// ! + /// @method initWithURL: + /// @abstract Initializes an NSURLRequest with the given URL. + /// @discussion Default values are used for cache policy + /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 + /// seconds). + /// @param URL The URL for the request. + /// @result An initialized NSURLRequest. + NSMutableURLRequest initWithURL(objc.NSURL URL) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.initWithURL:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.retainAndReturnPointer(), + _sel_initWithURL_, + URL.ref.pointer, + ); + return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); } - late final _CFCopyDescriptionPtr = - _lookup>( - 'CFCopyDescription', - ); - late final _CFCopyDescription = - _CFCopyDescriptionPtr.asFunction(); - - CFAllocatorRef CFGetAllocator(CFTypeRef cf) { - return _CFGetAllocator(cf); + /// ! + /// @method initWithURL: + /// @abstract Initializes an NSURLRequest with the given URL and + /// cache policy. + /// @discussion This is the designated initializer for the + /// NSURLRequest class. + /// @param URL The URL for the request. + /// @param cachePolicy The cache policy for the request. + /// @param timeoutInterval The timeout interval for the request. See the + /// commentary for the timeoutInterval for more information on + /// timeout intervals. + /// @result An initialized NSURLRequest. + NSMutableURLRequest initWithURL$1( + objc.NSURL URL, { + required NSURLRequestCachePolicy cachePolicy, + required double timeoutInterval, + }) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.initWithURL:cachePolicy:timeoutInterval:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1ajs603( + object$.ref.retainAndReturnPointer(), + _sel_initWithURL_cachePolicy_timeoutInterval_, + URL.ref.pointer, + cachePolicy.value, + timeoutInterval, + ); + return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); } - late final _CFGetAllocatorPtr = - _lookup>( - 'CFGetAllocator', - ); - late final _CFGetAllocator = - _CFGetAllocatorPtr.asFunction(); - - CFTypeRef CFMakeCollectable(CFTypeRef cf) { - return _CFMakeCollectable(cf); + /// ! + /// @abstract Sets the main document URL + /// @discussion The caller should pass the URL for an appropriate main + /// document, if known. For example, when loading a web page, the URL + /// of the main html document for the top-level frame should be + /// passed. This main document is used to implement the cookie "only + /// from same domain as main document" policy, attributing this request + /// as a sub-resource of a user-specified URL, and possibly other things + /// in the future. + objc.NSURL? get mainDocumentURL { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.mainDocumentURL', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_mainDocumentURL, + ); + return $ret.address == 0 + ? null + : objc.NSURL.fromPointer($ret, retain: true, release: true); } - late final _CFMakeCollectablePtr = - _lookup>( - 'CFMakeCollectable', - ); - late final _CFMakeCollectable = - _CFMakeCollectablePtr.asFunction(); - - ffi.Pointer NSDefaultMallocZone() { - return _NSDefaultMallocZone(); + /// ! + /// @abstract Sets the NSURLRequestNetworkServiceType to associate with this request + /// @discussion This method is used to provide the network layers with a hint as to the purpose + /// of the request. Most clients should not need to use this method. + NSURLRequestNetworkServiceType get networkServiceType { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.networkServiceType', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + final $ret = _objc_msgSend_t4uaw1( + object$.ref.pointer, + _sel_networkServiceType, + ); + return NSURLRequestNetworkServiceType.fromValue($ret); } - late final _NSDefaultMallocZonePtr = - _lookup Function()>>( - 'NSDefaultMallocZone', - ); - late final _NSDefaultMallocZone = - _NSDefaultMallocZonePtr.asFunction Function()>(); - - ffi.Pointer NSCreateZone( - int startSize, - int granularity, - bool canFree, - ) { - return _NSCreateZone(startSize, granularity, canFree); + /// ! + /// @abstract sets whether a request is required to do DNSSEC validation during DNS lookup. + /// @discussion YES, if the DNS lookup for this request should require DNSSEC validation, + /// No otherwise. Defaults to NO. + bool get requiresDNSSECValidation { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.requiresDNSSECValidation', + iOS: (false, (16, 1, 0)), + macOS: (false, (13, 0, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_requiresDNSSECValidation, + ); } - late final _NSCreateZonePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(NSUInteger, NSUInteger, ffi.Bool) - > - >('NSCreateZone'); - late final _NSCreateZone = - _NSCreateZonePtr.asFunction< - ffi.Pointer Function(int, int, bool) - >(); - - void NSRecycleZone(ffi.Pointer zone) { - return _NSRecycleZone(zone); - } - - late final _NSRecycleZonePtr = - _lookup)>>( - 'NSRecycleZone', - ); - late final _NSRecycleZone = - _NSRecycleZonePtr.asFunction)>(); - - void NSSetZoneName(ffi.Pointer zone, objc.NSString name) { - return _NSSetZoneName(zone, name.ref.pointer); - } - - late final _NSSetZoneNamePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('NSSetZoneName'); - late final _NSSetZoneName = - _NSSetZoneNamePtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >(); - - objc.NSString NSZoneName(ffi.Pointer zone) { - return objc.NSString.fromPointer( - _NSZoneName(zone), - retain: true, - release: true, + /// ! + /// @abstract sets whether a connection created with this request is allowed to use + /// the built in cellular radios (if present). + /// @discussion NO if the receiver should not be allowed to use the built in + /// cellular radios to satisfy the request, YES otherwise. The default is YES. + set allowsCellularAccess$1(bool value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAllowsCellularAccess:', + iOS: (false, (6, 0, 0)), + macOS: (false, (10, 8, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setAllowsCellularAccess_, + value, ); } - late final _NSZoneNamePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('NSZoneName'); - late final _NSZoneName = - _NSZoneNamePtr.asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); - - ffi.Pointer NSZoneFromPointer(ffi.Pointer ptr) { - return _NSZoneFromPointer(ptr); - } - - late final _NSZoneFromPointerPtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('NSZoneFromPointer'); - late final _NSZoneFromPointer = - _NSZoneFromPointerPtr.asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); - - ffi.Pointer NSZoneMalloc(ffi.Pointer zone, int size) { - return _NSZoneMalloc(zone, size); - } - - late final _NSZoneMallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, NSUInteger) - > - >('NSZoneMalloc'); - late final _NSZoneMalloc = - _NSZoneMallocPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); - - ffi.Pointer NSZoneCalloc( - ffi.Pointer zone, - int numElems, - int byteSize, - ) { - return _NSZoneCalloc(zone, numElems, byteSize); - } - - late final _NSZoneCallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - NSUInteger, - NSUInteger, - ) - > - >('NSZoneCalloc'); - late final _NSZoneCalloc = - _NSZoneCallocPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); - - ffi.Pointer NSZoneRealloc( - ffi.Pointer zone, - ffi.Pointer ptr, - int size, - ) { - return _NSZoneRealloc(zone, ptr, size); - } - - late final _NSZoneReallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ) - > - >('NSZoneRealloc'); - late final _NSZoneRealloc = - _NSZoneReallocPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - void NSZoneFree(ffi.Pointer zone, ffi.Pointer ptr) { - return _NSZoneFree(zone, ptr); - } - - late final _NSZoneFreePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - >('NSZoneFree'); - late final _NSZoneFree = - _NSZoneFreePtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >(); - - ffi.Pointer NSAllocateCollectable(int size, int options) { - return _NSAllocateCollectable(size, options); - } - - late final _NSAllocateCollectablePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(NSUInteger, NSUInteger) - > - >('NSAllocateCollectable'); - late final _NSAllocateCollectable = - _NSAllocateCollectablePtr.asFunction< - ffi.Pointer Function(int, int) - >(); - - ffi.Pointer NSReallocateCollectable( - ffi.Pointer ptr, - int size, - int options, - ) { - return _NSReallocateCollectable(ptr, size, options); - } - - late final _NSReallocateCollectablePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - NSUInteger, - NSUInteger, - ) - > - >('NSReallocateCollectable'); - late final _NSReallocateCollectable = - _NSReallocateCollectablePtr.asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); - - int NSPageSize() { - return _NSPageSize(); - } - - late final _NSPageSizePtr = - _lookup>('NSPageSize'); - late final _NSPageSize = _NSPageSizePtr.asFunction(); - - int NSLogPageSize() { - return _NSLogPageSize(); - } - - late final _NSLogPageSizePtr = - _lookup>('NSLogPageSize'); - late final _NSLogPageSize = _NSLogPageSizePtr.asFunction(); - - int NSRoundUpToMultipleOfPageSize(int bytes) { - return _NSRoundUpToMultipleOfPageSize(bytes); - } - - late final _NSRoundUpToMultipleOfPageSizePtr = - _lookup>( - 'NSRoundUpToMultipleOfPageSize', - ); - late final _NSRoundUpToMultipleOfPageSize = - _NSRoundUpToMultipleOfPageSizePtr.asFunction(); - - int NSRoundDownToMultipleOfPageSize(int bytes) { - return _NSRoundDownToMultipleOfPageSize(bytes); + /// ! + /// @abstract sets whether a connection created with this request is allowed to use + /// network interfaces which have been marked as constrained. + /// @discussion NO if the receiver should not be allowed to use an interface marked as constrained to + /// satisfy the request, YES otherwise. + set allowsConstrainedNetworkAccess$1(bool value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAllowsConstrainedNetworkAccess:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setAllowsConstrainedNetworkAccess_, + value, + ); } - late final _NSRoundDownToMultipleOfPageSizePtr = - _lookup>( - 'NSRoundDownToMultipleOfPageSize', - ); - late final _NSRoundDownToMultipleOfPageSize = - _NSRoundDownToMultipleOfPageSizePtr.asFunction(); - - ffi.Pointer NSAllocateMemoryPages(int bytes) { - return _NSAllocateMemoryPages(bytes); + /// ! + /// @abstract sets whether a connection created with this request is allowed to use + /// network interfaces which have been marked as expensive. + /// @discussion NO if the receiver should not be allowed to use an interface marked as expensive to + /// satisfy the request, YES otherwise. + set allowsExpensiveNetworkAccess$1(bool value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAllowsExpensiveNetworkAccess:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setAllowsExpensiveNetworkAccess_, + value, + ); } - late final _NSAllocateMemoryPagesPtr = - _lookup Function(NSUInteger)>>( - 'NSAllocateMemoryPages', - ); - late final _NSAllocateMemoryPages = - _NSAllocateMemoryPagesPtr.asFunction< - ffi.Pointer Function(int) - >(); - - void NSDeallocateMemoryPages(ffi.Pointer ptr, int bytes) { - return _NSDeallocateMemoryPages(ptr, bytes); - } - - late final _NSDeallocateMemoryPagesPtr = - _lookup< - ffi.NativeFunction, NSUInteger)> - >('NSDeallocateMemoryPages'); - late final _NSDeallocateMemoryPages = - _NSDeallocateMemoryPagesPtr.asFunction< - void Function(ffi.Pointer, int) - >(); - - void NSCopyMemoryPages( - ffi.Pointer source, - ffi.Pointer dest, - int bytes, - ) { - return _NSCopyMemoryPages(source, dest, bytes); + /// ! + /// @abstract Allows storing and usage of DNS answers, potentially beyond TTL expiry, + /// in a persistent per-process cache. This should only be set for hostnames whose resolutions + /// are not expected to change across networks. + /// @discussion YES, if the DNS lookup for this request is allowed to use a persistent per-process cache, + /// NO otherwise. Defaults to NO. + set allowsPersistentDNS$1(bool value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAllowsPersistentDNS:', + iOS: (false, (18, 0, 0)), + macOS: (false, (15, 0, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setAllowsPersistentDNS_, + value, + ); } - late final _NSCopyMemoryPagesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ) - > - >('NSCopyMemoryPages'); - late final _NSCopyMemoryPages = - _NSCopyMemoryPagesPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int NSRealMemoryAvailable() { - return _NSRealMemoryAvailable(); + /// ! + /// @abstract returns whether we assume that server supports HTTP/3. Enables QUIC + /// racing without HTTP/3 service discovery. + /// @result YES if server endpoint is known to support HTTP/3. Defaults to NO. + /// The default may be YES in a future OS update. + set assumesHTTP3Capable$1(bool value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAssumesHTTP3Capable:', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setAssumesHTTP3Capable_, + value, + ); } - late final _NSRealMemoryAvailablePtr = - _lookup>( - 'NSRealMemoryAvailable', - ); - late final _NSRealMemoryAvailable = - _NSRealMemoryAvailablePtr.asFunction(); - - objc.ObjCObject NSAllocateObject( - objc.ObjCObject aClass, - DartNSUInteger extraBytes, - ffi.Pointer zone, - ) { - return objc.ObjCObject( - _NSAllocateObject(aClass.ref.pointer, extraBytes, zone), - retain: true, - release: true, + /// ! + /// @abstract Sets the NSURLRequestAttribution to associate with this request. + /// @discussion Set to NSURLRequestAttributionUser if the URL was specified by the + /// user. Defaults to NSURLRequestAttributionDeveloper. + set attribution$1(NSURLRequestAttribution value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAttribution:', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), + ); + _objc_msgSend_1nw1jep( + object$.ref.pointer, + _sel_setAttribution_, + value.value, ); } - late final _NSAllocateObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - NSUInteger, - ffi.Pointer, - ) - > - >('NSAllocateObject'); - late final _NSAllocateObject = - _NSAllocateObjectPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - void NSDeallocateObject(objc.ObjCObject object) { - return _NSDeallocateObject(object.ref.pointer); + /// ! + /// @abstract The cache policy of the receiver. + set cachePolicy$1(NSURLRequestCachePolicy value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setCachePolicy:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_1yjxuv2( + object$.ref.pointer, + _sel_setCachePolicy_, + value.value, + ); } - late final _NSDeallocateObjectPtr = - _lookup< - ffi.NativeFunction)> - >('NSDeallocateObject'); - late final _NSDeallocateObject = - _NSDeallocateObjectPtr.asFunction< - void Function(ffi.Pointer) - >(); - - objc.ObjCObject NSCopyObject( - objc.ObjCObject object, - DartNSUInteger extraBytes, - ffi.Pointer zone, - ) { - return objc.ObjCObject( - _NSCopyObject(object.ref.pointer, extraBytes, zone), - retain: true, - release: true, + /// Cookie partition identifier used for cookie storage and retrieval. + set cookiePartitionIdentifier$1(objc.NSString? value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setCookiePartitionIdentifier:', + iOS: (false, (18, 2, 0)), + macOS: (false, (15, 2, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setCookiePartitionIdentifier_, + value?.ref.pointer ?? ffi.nullptr, ); } - late final _NSCopyObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - NSUInteger, - ffi.Pointer, - ) - > - >('NSCopyObject'); - late final _NSCopyObject = - _NSCopyObjectPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - bool NSShouldRetainWithZone( - objc.ObjCObject anObject, - ffi.Pointer requestedZone, - ) { - return _NSShouldRetainWithZone(anObject.ref.pointer, requestedZone); + /// ! + /// @abstract Sets the main document URL + /// @discussion The caller should pass the URL for an appropriate main + /// document, if known. For example, when loading a web page, the URL + /// of the main html document for the top-level frame should be + /// passed. This main document is used to implement the cookie "only + /// from same domain as main document" policy, attributing this request + /// as a sub-resource of a user-specified URL, and possibly other things + /// in the future. + set mainDocumentURL$1(objc.NSURL? value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setMainDocumentURL:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setMainDocumentURL_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _NSShouldRetainWithZonePtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('NSShouldRetainWithZone'); - late final _NSShouldRetainWithZone = - _NSShouldRetainWithZonePtr.asFunction< - bool Function(ffi.Pointer, ffi.Pointer) - >(); - - void NSIncrementExtraRefCount(objc.ObjCObject object) { - return _NSIncrementExtraRefCount(object.ref.pointer); + /// ! + /// @abstract Sets the NSURLRequestNetworkServiceType to associate with this request + /// @discussion This method is used to provide the network layers with a hint as to the purpose + /// of the request. Most clients should not need to use this method. + set networkServiceType$1(NSURLRequestNetworkServiceType value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setNetworkServiceType:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + _objc_msgSend_1mse4s1( + object$.ref.pointer, + _sel_setNetworkServiceType_, + value.value, + ); } - late final _NSIncrementExtraRefCountPtr = - _lookup< - ffi.NativeFunction)> - >('NSIncrementExtraRefCount'); - late final _NSIncrementExtraRefCount = - _NSIncrementExtraRefCountPtr.asFunction< - void Function(ffi.Pointer) - >(); - - bool NSDecrementExtraRefCountWasZero(objc.ObjCObject object) { - return _NSDecrementExtraRefCountWasZero(object.ref.pointer); + /// ! + /// @abstract sets whether a request is required to do DNSSEC validation during DNS lookup. + /// @discussion YES, if the DNS lookup for this request should require DNSSEC validation, + /// No otherwise. Defaults to NO. + set requiresDNSSECValidation$1(bool value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setRequiresDNSSECValidation:', + iOS: (false, (16, 1, 0)), + macOS: (false, (13, 0, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setRequiresDNSSECValidation_, + value, + ); } - late final _NSDecrementExtraRefCountWasZeroPtr = - _lookup< - ffi.NativeFunction)> - >('NSDecrementExtraRefCountWasZero'); - late final _NSDecrementExtraRefCountWasZero = - _NSDecrementExtraRefCountWasZeroPtr.asFunction< - bool Function(ffi.Pointer) - >(); - - DartNSUInteger NSExtraRefCount(objc.ObjCObject object) { - return _NSExtraRefCount(object.ref.pointer); + /// ! + /// @abstract Sets the timeout interval of the receiver. + /// @discussion The timeout interval specifies the limit on the idle + /// interval allotted to a request in the process of loading. The "idle + /// interval" is defined as the period of time that has passed since the + /// last instance of load activity occurred for a request that is in the + /// process of loading. Hence, when an instance of load activity occurs + /// (e.g. bytes are received from the network for a request), the idle + /// interval for a request is reset to 0. If the idle interval ever + /// becomes greater than or equal to the timeout interval, the request + /// is considered to have timed out. This timeout interval is measured + /// in seconds. + set timeoutInterval$1(double value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setTimeoutInterval:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_hwm8nu(object$.ref.pointer, _sel_setTimeoutInterval_, value); } - late final _NSExtraRefCountPtr = - _lookup< - ffi.NativeFunction< - NSUInteger Function(ffi.Pointer) - > - >('NSExtraRefCount'); - late final _NSExtraRefCount = - _NSExtraRefCountPtr.asFunction< - int Function(ffi.Pointer) - >(); - - late final ffi.Pointer - _NSSystemClockDidChangeNotification = _lookup( - 'NSSystemClockDidChangeNotification', - ); - - DartNSNotificationName get NSSystemClockDidChangeNotification => - objc.NSString.fromPointer( - _NSSystemClockDidChangeNotification.value, - retain: true, - release: true, - ); - - set NSSystemClockDidChangeNotification(DartNSNotificationName value) { - objc.NSString.fromPointer( - _NSSystemClockDidChangeNotification.value, - retain: false, - release: true, - ).ref.release(); - _NSSystemClockDidChangeNotification.value = value.ref - .retainAndReturnPointer(); + /// ! + /// @abstract The URL of the receiver. + set URL$1(objc.NSURL? value) { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setURL:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setURL_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final ffi.Pointer - _NSHTTPCookieManagerAcceptPolicyChangedNotification = - _lookup( - 'NSHTTPCookieManagerAcceptPolicyChangedNotification', - ); - - DartNSNotificationName - get NSHTTPCookieManagerAcceptPolicyChangedNotification => - objc.NSString.fromPointer( - _NSHTTPCookieManagerAcceptPolicyChangedNotification.value, - retain: true, - release: true, - ); - - set NSHTTPCookieManagerAcceptPolicyChangedNotification( - DartNSNotificationName value, - ) { - objc.NSString.fromPointer( - _NSHTTPCookieManagerAcceptPolicyChangedNotification.value, - retain: false, - release: true, - ).ref.release(); - _NSHTTPCookieManagerAcceptPolicyChangedNotification.value = value.ref - .retainAndReturnPointer(); + /// ! + /// @abstract Sets the timeout interval of the receiver. + /// @discussion The timeout interval specifies the limit on the idle + /// interval allotted to a request in the process of loading. The "idle + /// interval" is defined as the period of time that has passed since the + /// last instance of load activity occurred for a request that is in the + /// process of loading. Hence, when an instance of load activity occurs + /// (e.g. bytes are received from the network for a request), the idle + /// interval for a request is reset to 0. If the idle interval ever + /// becomes greater than or equal to the timeout interval, the request + /// is considered to have timed out. This timeout interval is measured + /// in seconds. + double get timeoutInterval { + objc.checkOsVersionInternal( + 'NSMutableURLRequest.timeoutInterval', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return objc.useMsgSendVariants + ? _objc_msgSend_1ukqyt8Fpret(object$.ref.pointer, _sel_timeoutInterval) + : _objc_msgSend_1ukqyt8(object$.ref.pointer, _sel_timeoutInterval); } +} - late final ffi.Pointer - _NSHTTPCookieManagerCookiesChangedNotification = _lookup( - 'NSHTTPCookieManagerCookiesChangedNotification', - ); - - DartNSNotificationName get NSHTTPCookieManagerCookiesChangedNotification => - objc.NSString.fromPointer( - _NSHTTPCookieManagerCookiesChangedNotification.value, - retain: true, - release: true, - ); - - set NSHTTPCookieManagerCookiesChangedNotification( - DartNSNotificationName value, - ) { - objc.NSString.fromPointer( - _NSHTTPCookieManagerCookiesChangedNotification.value, - retain: false, - release: true, - ).ref.release(); - _NSHTTPCookieManagerCookiesChangedNotification.value = value.ref - .retainAndReturnPointer(); - } +enum NSHTTPCookieAcceptPolicy { + NSHTTPCookieAcceptPolicyAlways(0), + NSHTTPCookieAcceptPolicyNever(1), + NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain(2); - late final ffi.Pointer - _NSProgressEstimatedTimeRemainingKey = _lookup( - 'NSProgressEstimatedTimeRemainingKey', - ); + final int value; + const NSHTTPCookieAcceptPolicy(this.value); - DartNSProgressUserInfoKey get NSProgressEstimatedTimeRemainingKey => - objc.NSString.fromPointer( - _NSProgressEstimatedTimeRemainingKey.value, - retain: true, - release: true, - ); + static NSHTTPCookieAcceptPolicy fromValue(int value) => switch (value) { + 0 => NSHTTPCookieAcceptPolicyAlways, + 1 => NSHTTPCookieAcceptPolicyNever, + 2 => NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, + _ => throw ArgumentError( + 'Unknown value for NSHTTPCookieAcceptPolicy: $value', + ), + }; +} - set NSProgressEstimatedTimeRemainingKey(DartNSProgressUserInfoKey value) { - objc.NSString.fromPointer( - _NSProgressEstimatedTimeRemainingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressEstimatedTimeRemainingKey.value = value.ref - .retainAndReturnPointer(); +/// WARNING: NSHTTPCookieStorage is a stub. To generate bindings for this class, include +/// NSHTTPCookieStorage in your config's objc-interfaces list. +/// +/// NSHTTPCookieStorage +extension type NSHTTPCookieStorage._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [NSHTTPCookieStorage] that points to the same underlying object as [other]. + NSHTTPCookieStorage.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSHTTPCookieStorage', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); } - late final ffi.Pointer _NSProgressThroughputKey = - _lookup('NSProgressThroughputKey'); - - DartNSProgressUserInfoKey get NSProgressThroughputKey => - objc.NSString.fromPointer( - _NSProgressThroughputKey.value, - retain: true, - release: true, - ); - - set NSProgressThroughputKey(DartNSProgressUserInfoKey value) { - objc.NSString.fromPointer( - _NSProgressThroughputKey.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressThroughputKey.value = value.ref.retainAndReturnPointer(); + /// Constructs a [NSHTTPCookieStorage] that wraps the given raw object pointer. + NSHTTPCookieStorage.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSHTTPCookieStorage', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); } +} - late final ffi.Pointer _NSProgressKindFile = - _lookup('NSProgressKindFile'); - - DartNSProgressKind get NSProgressKindFile => objc.NSString.fromPointer( - _NSProgressKindFile.value, - retain: true, - release: true, - ); - - set NSProgressKindFile(DartNSProgressKind value) { - objc.NSString.fromPointer( - _NSProgressKindFile.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressKindFile.value = value.ref.retainAndReturnPointer(); - } +/// WARNING: NSProgressReporting is a stub. To generate bindings for this class, include +/// NSProgressReporting in your config's objc-protocols list. +/// +/// NSProgressReporting +extension type NSProgressReporting._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol, objc.NSObjectProtocol { + /// Constructs a [NSProgressReporting] that points to the same underlying object as [other]. + NSProgressReporting.as(objc.ObjCObject other) : object$ = other; - late final ffi.Pointer - _NSProgressFileOperationKindKey = _lookup( - 'NSProgressFileOperationKindKey', - ); + /// Constructs a [NSProgressReporting] that wraps the given raw object pointer. + NSProgressReporting.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); +} - DartNSProgressUserInfoKey get NSProgressFileOperationKindKey => - objc.NSString.fromPointer( - _NSProgressFileOperationKindKey.value, - retain: true, - release: true, - ); +enum tls_protocol_version_t { + tls_protocol_version_TLSv10(769), + tls_protocol_version_TLSv11(770), + tls_protocol_version_TLSv12(771), + tls_protocol_version_TLSv13(772), + tls_protocol_version_DTLSv10(-257), + tls_protocol_version_DTLSv12(-259); - set NSProgressFileOperationKindKey(DartNSProgressUserInfoKey value) { - objc.NSString.fromPointer( - _NSProgressFileOperationKindKey.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileOperationKindKey.value = value.ref.retainAndReturnPointer(); - } + final int value; + const tls_protocol_version_t(this.value); - late final ffi.Pointer - _NSProgressFileOperationKindDownloading = - _lookup( - 'NSProgressFileOperationKindDownloading', - ); + static tls_protocol_version_t fromValue(int value) => switch (value) { + 769 => tls_protocol_version_TLSv10, + 770 => tls_protocol_version_TLSv11, + 771 => tls_protocol_version_TLSv12, + 772 => tls_protocol_version_TLSv13, + -257 => tls_protocol_version_DTLSv10, + -259 => tls_protocol_version_DTLSv12, + _ => throw ArgumentError( + 'Unknown value for tls_protocol_version_t: $value', + ), + }; +} - DartNSProgressFileOperationKind get NSProgressFileOperationKindDownloading => - objc.NSString.fromPointer( - _NSProgressFileOperationKindDownloading.value, - retain: true, - release: true, - ); +enum SSLProtocol { + kSSLProtocolUnknown(0), + kTLSProtocol1(4), + kTLSProtocol11(7), + kTLSProtocol12(8), + kDTLSProtocol1(9), + kTLSProtocol13(10), + kDTLSProtocol12(11), + kTLSProtocolMaxSupported(999), + kSSLProtocol2(1), + kSSLProtocol3(2), + kSSLProtocol3Only(3), + kTLSProtocol1Only(5), + kSSLProtocolAll(6); - set NSProgressFileOperationKindDownloading( - DartNSProgressFileOperationKind value, - ) { - objc.NSString.fromPointer( - _NSProgressFileOperationKindDownloading.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileOperationKindDownloading.value = value.ref - .retainAndReturnPointer(); - } + final int value; + const SSLProtocol(this.value); - late final ffi.Pointer - _NSProgressFileOperationKindDecompressingAfterDownloading = - _lookup( - 'NSProgressFileOperationKindDecompressingAfterDownloading', - ); + static SSLProtocol fromValue(int value) => switch (value) { + 0 => kSSLProtocolUnknown, + 4 => kTLSProtocol1, + 7 => kTLSProtocol11, + 8 => kTLSProtocol12, + 9 => kDTLSProtocol1, + 10 => kTLSProtocol13, + 11 => kDTLSProtocol12, + 999 => kTLSProtocolMaxSupported, + 1 => kSSLProtocol2, + 2 => kSSLProtocol3, + 3 => kSSLProtocol3Only, + 5 => kTLSProtocol1Only, + 6 => kSSLProtocolAll, + _ => throw ArgumentError('Unknown value for SSLProtocol: $value'), + }; +} - DartNSProgressFileOperationKind - get NSProgressFileOperationKindDecompressingAfterDownloading => - objc.NSString.fromPointer( - _NSProgressFileOperationKindDecompressingAfterDownloading.value, - retain: true, - release: true, - ); - - set NSProgressFileOperationKindDecompressingAfterDownloading( - DartNSProgressFileOperationKind value, - ) { - objc.NSString.fromPointer( - _NSProgressFileOperationKindDecompressingAfterDownloading.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileOperationKindDecompressingAfterDownloading.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSProgressFileOperationKindReceiving = _lookup( - 'NSProgressFileOperationKindReceiving', - ); +late final _class_NSURLSession = objc.getClass("NSURLSession"); +late final _sel_sharedSession = objc.registerName("sharedSession"); +late final _class_NSURLSessionConfiguration = objc.getClass( + "NSURLSessionConfiguration", +); +late final _sel_defaultSessionConfiguration = objc.registerName( + "defaultSessionConfiguration", +); +late final _sel_ephemeralSessionConfiguration = objc.registerName( + "ephemeralSessionConfiguration", +); +late final _sel_backgroundSessionConfigurationWithIdentifier_ = objc + .registerName("backgroundSessionConfigurationWithIdentifier:"); +late final _sel_identifier = objc.registerName("identifier"); +late final _sel_requestCachePolicy = objc.registerName("requestCachePolicy"); +late final _sel_setRequestCachePolicy_ = objc.registerName( + "setRequestCachePolicy:", +); +late final _sel_timeoutIntervalForRequest = objc.registerName( + "timeoutIntervalForRequest", +); +late final _sel_setTimeoutIntervalForRequest_ = objc.registerName( + "setTimeoutIntervalForRequest:", +); +late final _sel_timeoutIntervalForResource = objc.registerName( + "timeoutIntervalForResource", +); +late final _sel_setTimeoutIntervalForResource_ = objc.registerName( + "setTimeoutIntervalForResource:", +); +late final _sel_waitsForConnectivity = objc.registerName( + "waitsForConnectivity", +); +late final _sel_setWaitsForConnectivity_ = objc.registerName( + "setWaitsForConnectivity:", +); +late final _sel_isDiscretionary = objc.registerName("isDiscretionary"); +late final _sel_setDiscretionary_ = objc.registerName("setDiscretionary:"); +late final _sel_sharedContainerIdentifier = objc.registerName( + "sharedContainerIdentifier", +); +late final _sel_setSharedContainerIdentifier_ = objc.registerName( + "setSharedContainerIdentifier:", +); +late final _sel_sessionSendsLaunchEvents = objc.registerName( + "sessionSendsLaunchEvents", +); +late final _sel_setSessionSendsLaunchEvents_ = objc.registerName( + "setSessionSendsLaunchEvents:", +); +late final _sel_connectionProxyDictionary = objc.registerName( + "connectionProxyDictionary", +); +late final _sel_setConnectionProxyDictionary_ = objc.registerName( + "setConnectionProxyDictionary:", +); +late final _sel_TLSMinimumSupportedProtocol = objc.registerName( + "TLSMinimumSupportedProtocol", +); +final _objc_msgSend_cbopi9 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedInt Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setTLSMinimumSupportedProtocol_ = objc.registerName( + "setTLSMinimumSupportedProtocol:", +); +final _objc_msgSend_268k8x = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedInt, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_TLSMaximumSupportedProtocol = objc.registerName( + "TLSMaximumSupportedProtocol", +); +late final _sel_setTLSMaximumSupportedProtocol_ = objc.registerName( + "setTLSMaximumSupportedProtocol:", +); +late final _sel_TLSMinimumSupportedProtocolVersion = objc.registerName( + "TLSMinimumSupportedProtocolVersion", +); +final _objc_msgSend_9jpwfb = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Uint16 Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setTLSMinimumSupportedProtocolVersion_ = objc.registerName( + "setTLSMinimumSupportedProtocolVersion:", +); +final _objc_msgSend_1mvuct7 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint16, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_TLSMaximumSupportedProtocolVersion = objc.registerName( + "TLSMaximumSupportedProtocolVersion", +); +late final _sel_setTLSMaximumSupportedProtocolVersion_ = objc.registerName( + "setTLSMaximumSupportedProtocolVersion:", +); +late final _sel_HTTPShouldSetCookies = objc.registerName( + "HTTPShouldSetCookies", +); +late final _sel_setHTTPShouldSetCookies_ = objc.registerName( + "setHTTPShouldSetCookies:", +); +late final _sel_HTTPCookieAcceptPolicy = objc.registerName( + "HTTPCookieAcceptPolicy", +); +final _objc_msgSend_104dkoq = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setHTTPCookieAcceptPolicy_ = objc.registerName( + "setHTTPCookieAcceptPolicy:", +); +final _objc_msgSend_3q55ys = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_HTTPAdditionalHeaders = objc.registerName( + "HTTPAdditionalHeaders", +); +late final _sel_setHTTPAdditionalHeaders_ = objc.registerName( + "setHTTPAdditionalHeaders:", +); +late final _sel_HTTPMaximumConnectionsPerHost = objc.registerName( + "HTTPMaximumConnectionsPerHost", +); +final _objc_msgSend_1hz7y9r = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setHTTPMaximumConnectionsPerHost_ = objc.registerName( + "setHTTPMaximumConnectionsPerHost:", +); +final _objc_msgSend_4sp4xj = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_HTTPCookieStorage = objc.registerName("HTTPCookieStorage"); +late final _sel_setHTTPCookieStorage_ = objc.registerName( + "setHTTPCookieStorage:", +); - DartNSProgressFileOperationKind get NSProgressFileOperationKindReceiving => - objc.NSString.fromPointer( - _NSProgressFileOperationKindReceiving.value, - retain: true, - release: true, - ); +/// WARNING: NSURLCredentialStorage is a stub. To generate bindings for this class, include +/// NSURLCredentialStorage in your config's objc-interfaces list. +/// +/// NSURLCredentialStorage +extension type NSURLCredentialStorage._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [NSURLCredentialStorage] that points to the same underlying object as [other]. + NSURLCredentialStorage.as(objc.ObjCObject other) : object$ = other {} - set NSProgressFileOperationKindReceiving( - DartNSProgressFileOperationKind value, - ) { - objc.NSString.fromPointer( - _NSProgressFileOperationKindReceiving.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileOperationKindReceiving.value = value.ref - .retainAndReturnPointer(); - } + /// Constructs a [NSURLCredentialStorage] that wraps the given raw object pointer. + NSURLCredentialStorage.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} +} - late final ffi.Pointer - _NSProgressFileOperationKindCopying = _lookup( - 'NSProgressFileOperationKindCopying', - ); +late final _sel_URLCredentialStorage = objc.registerName( + "URLCredentialStorage", +); +late final _sel_setURLCredentialStorage_ = objc.registerName( + "setURLCredentialStorage:", +); +late final _sel_URLCache = objc.registerName("URLCache"); +late final _sel_setURLCache_ = objc.registerName("setURLCache:"); +late final _sel_shouldUseExtendedBackgroundIdleMode = objc.registerName( + "shouldUseExtendedBackgroundIdleMode", +); +late final _sel_setShouldUseExtendedBackgroundIdleMode_ = objc.registerName( + "setShouldUseExtendedBackgroundIdleMode:", +); +late final _sel_protocolClasses = objc.registerName("protocolClasses"); +late final _sel_setProtocolClasses_ = objc.registerName("setProtocolClasses:"); - DartNSProgressFileOperationKind get NSProgressFileOperationKindCopying => - objc.NSString.fromPointer( - _NSProgressFileOperationKindCopying.value, - retain: true, - release: true, - ); +/// ! +/// @enum NSURLSessionMultipathServiceType +/// +/// @discussion The NSURLSessionMultipathServiceType enum defines constants that +/// can be used to specify the multipath service type to associate an NSURLSession. The +/// multipath service type determines whether multipath TCP should be attempted and the conditions +/// for creating and switching between subflows. Using these service types requires the appropriate entitlement. Any connection attempt will fail if the process does not have the required entitlement. +/// A primary interface is a generally less expensive interface in terms of both cost and power (such as WiFi or ethernet). A secondary interface is more expensive (such as 3G or LTE). +/// +/// @constant NSURLSessionMultipathServiceTypeNone Specifies that multipath tcp should not be used. Connections will use a single flow. +/// This is the default value. No entitlement is required to set this value. +/// +/// @constant NSURLSessionMultipathServiceTypeHandover Specifies that a secondary subflow should only be used +/// when the primary subflow is not performing adequately. Requires the com.apple.developer.networking.multipath entitlement. +/// +/// @constant NSURLSessionMultipathServiceTypeInteractive Specifies that a secondary subflow should be used if the +/// primary subflow is not performing adequately (packet loss, high round trip times, bandwidth issues). The secondary +/// subflow will be created more aggressively than with NSURLSessionMultipathServiceTypeHandover. Requires the com.apple.developer.networking.multipath entitlement. +/// +/// @constant NSURLSessionMultipathServiceTypeAggregate Specifies that multiple subflows across multiple interfaces should be +/// used for better bandwidth. This mode is only available for experimentation on devices configured for development use. +/// It can be enabled in the Developer section of the Settings app. +enum NSURLSessionMultipathServiceType { + /// None - no multipath (default) + NSURLSessionMultipathServiceTypeNone(0), - set NSProgressFileOperationKindCopying( - DartNSProgressFileOperationKind value, - ) { - objc.NSString.fromPointer( - _NSProgressFileOperationKindCopying.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileOperationKindCopying.value = value.ref - .retainAndReturnPointer(); - } + /// Handover - secondary flows brought up when primary flow is not performing adequately. + NSURLSessionMultipathServiceTypeHandover(1), - late final ffi.Pointer - _NSProgressFileOperationKindUploading = _lookup( - 'NSProgressFileOperationKindUploading', - ); + /// Interactive - secondary flows created more aggressively. + NSURLSessionMultipathServiceTypeInteractive(2), - DartNSProgressFileOperationKind get NSProgressFileOperationKindUploading => - objc.NSString.fromPointer( - _NSProgressFileOperationKindUploading.value, - retain: true, - release: true, - ); + /// Aggregate - multiple subflows used for greater bandwidth. + NSURLSessionMultipathServiceTypeAggregate(3); - set NSProgressFileOperationKindUploading( - DartNSProgressFileOperationKind value, - ) { - objc.NSString.fromPointer( - _NSProgressFileOperationKindUploading.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileOperationKindUploading.value = value.ref - .retainAndReturnPointer(); - } + final int value; + const NSURLSessionMultipathServiceType(this.value); - late final ffi.Pointer - _NSProgressFileOperationKindDuplicating = - _lookup( - 'NSProgressFileOperationKindDuplicating', - ); + static NSURLSessionMultipathServiceType fromValue(int value) => + switch (value) { + 0 => NSURLSessionMultipathServiceTypeNone, + 1 => NSURLSessionMultipathServiceTypeHandover, + 2 => NSURLSessionMultipathServiceTypeInteractive, + 3 => NSURLSessionMultipathServiceTypeAggregate, + _ => throw ArgumentError( + 'Unknown value for NSURLSessionMultipathServiceType: $value', + ), + }; +} - DartNSProgressFileOperationKind get NSProgressFileOperationKindDuplicating => - objc.NSString.fromPointer( - _NSProgressFileOperationKindDuplicating.value, - retain: true, - release: true, - ); +late final _sel_multipathServiceType = objc.registerName( + "multipathServiceType", +); +final _objc_msgSend_1wxwnc0 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setMultipathServiceType_ = objc.registerName( + "setMultipathServiceType:", +); +final _objc_msgSend_1hx005a = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_usesClassicLoadingMode = objc.registerName( + "usesClassicLoadingMode", +); +late final _sel_setUsesClassicLoadingMode_ = objc.registerName( + "setUsesClassicLoadingMode:", +); +late final _sel_enablesEarlyData = objc.registerName("enablesEarlyData"); +late final _sel_setEnablesEarlyData_ = objc.registerName( + "setEnablesEarlyData:", +); +late final _sel_backgroundSessionConfiguration_ = objc.registerName( + "backgroundSessionConfiguration:", +); - set NSProgressFileOperationKindDuplicating( - DartNSProgressFileOperationKind value, +/// NSURLSessionDeprecated +extension NSURLSessionDeprecated on NSURLSessionConfiguration { + /// backgroundSessionConfiguration: + static NSURLSessionConfiguration backgroundSessionConfiguration( + objc.NSString identifier, ) { - objc.NSString.fromPointer( - _NSProgressFileOperationKindDuplicating.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileOperationKindDuplicating.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer _NSProgressFileURLKey = - _lookup('NSProgressFileURLKey'); - - DartNSProgressUserInfoKey get NSProgressFileURLKey => - objc.NSString.fromPointer( - _NSProgressFileURLKey.value, - retain: true, - release: true, - ); - - set NSProgressFileURLKey(DartNSProgressUserInfoKey value) { - objc.NSString.fromPointer( - _NSProgressFileURLKey.value, - retain: false, + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.backgroundSessionConfiguration:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _class_NSURLSessionConfiguration, + _sel_backgroundSessionConfiguration_, + identifier.ref.pointer, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, release: true, - ).ref.release(); - _NSProgressFileURLKey.value = value.ref.retainAndReturnPointer(); + ); } +} - late final ffi.Pointer _NSProgressFileTotalCountKey = - _lookup('NSProgressFileTotalCountKey'); - - DartNSProgressUserInfoKey get NSProgressFileTotalCountKey => - objc.NSString.fromPointer( - _NSProgressFileTotalCountKey.value, - retain: true, - release: true, - ); - - set NSProgressFileTotalCountKey(DartNSProgressUserInfoKey value) { - objc.NSString.fromPointer( - _NSProgressFileTotalCountKey.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileTotalCountKey.value = value.ref.retainAndReturnPointer(); +/// Configuration options for an NSURLSession. When a session is +/// created, a copy of the configuration object is made - you cannot +/// modify the configuration of a session after it has been created. +/// +/// The shared session uses the global credential, cache and cookie +/// storage objects. +/// +/// An ephemeral session has no persistent disk storage for cookies, +/// cache or credentials. +/// +/// A background session can be used to perform networking operations +/// on behalf of a suspended application, within certain constraints. +extension type NSURLSessionConfiguration._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject, objc.NSCopying { + /// Constructs a [NSURLSessionConfiguration] that points to the same underlying object as [other]. + NSURLSessionConfiguration.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + assert(isA(object$)); } - late final ffi.Pointer - _NSProgressFileCompletedCountKey = _lookup( - 'NSProgressFileCompletedCountKey', - ); - - DartNSProgressUserInfoKey get NSProgressFileCompletedCountKey => - objc.NSString.fromPointer( - _NSProgressFileCompletedCountKey.value, - retain: true, - release: true, - ); - - set NSProgressFileCompletedCountKey(DartNSProgressUserInfoKey value) { - objc.NSString.fromPointer( - _NSProgressFileCompletedCountKey.value, - retain: false, - release: true, - ).ref.release(); - _NSProgressFileCompletedCountKey.value = value.ref.retainAndReturnPointer(); + /// Constructs a [NSURLSessionConfiguration] that wraps the given raw object pointer. + NSURLSessionConfiguration.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + assert(isA(object$)); } - late final ffi.Pointer - _NSProgressFileAnimationImageKey = _lookup( - 'NSProgressFileAnimationImageKey', + /// Returns whether [obj] is an instance of [NSURLSessionConfiguration]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionConfiguration, ); - DartNSProgressUserInfoKey get NSProgressFileAnimationImageKey => - objc.NSString.fromPointer( - _NSProgressFileAnimationImageKey.value, - retain: true, - release: true, - ); - - set NSProgressFileAnimationImageKey(DartNSProgressUserInfoKey value) { - objc.NSString.fromPointer( - _NSProgressFileAnimationImageKey.value, + /// alloc + static NSURLSessionConfiguration alloc() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionConfiguration, + _sel_alloc, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, retain: false, release: true, - ).ref.release(); - _NSProgressFileAnimationImageKey.value = value.ref.retainAndReturnPointer(); + ); } - late final ffi.Pointer - _NSProgressFileAnimationImageOriginalRectKey = _lookup( - 'NSProgressFileAnimationImageOriginalRectKey', - ); - - DartNSProgressUserInfoKey get NSProgressFileAnimationImageOriginalRectKey => - objc.NSString.fromPointer( - _NSProgressFileAnimationImageOriginalRectKey.value, - retain: true, - release: true, - ); - - set NSProgressFileAnimationImageOriginalRectKey( - DartNSProgressUserInfoKey value, + /// allocWithZone: + static NSURLSessionConfiguration allocWithZone( + ffi.Pointer zone, ) { - objc.NSString.fromPointer( - _NSProgressFileAnimationImageOriginalRectKey.value, + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSessionConfiguration, + _sel_allocWithZone_, + zone, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, retain: false, release: true, - ).ref.release(); - _NSProgressFileAnimationImageOriginalRectKey.value = value.ref - .retainAndReturnPointer(); + ); } - late final ffi.Pointer _NSProgressFileIconKey = - _lookup('NSProgressFileIconKey'); - - DartNSProgressUserInfoKey get NSProgressFileIconKey => - objc.NSString.fromPointer( - _NSProgressFileIconKey.value, - retain: true, - release: true, - ); - - set NSProgressFileIconKey(DartNSProgressUserInfoKey value) { - objc.NSString.fromPointer( - _NSProgressFileIconKey.value, - retain: false, + /// backgroundSessionConfigurationWithIdentifier: + static NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier( + objc.NSString identifier, + ) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _class_NSURLSessionConfiguration, + _sel_backgroundSessionConfigurationWithIdentifier_, + identifier.ref.pointer, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, release: true, - ).ref.release(); - _NSProgressFileIconKey.value = value.ref.retainAndReturnPointer(); + ); } - late final ffi.Pointer _kCFTypeArrayCallBacks = - _lookup('kCFTypeArrayCallBacks'); - - CFArrayCallBacks get kCFTypeArrayCallBacks => _kCFTypeArrayCallBacks.ref; - - int CFArrayGetTypeID() { - return _CFArrayGetTypeID(); + /// defaultSessionConfiguration + static NSURLSessionConfiguration getDefaultSessionConfiguration() { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.defaultSessionConfiguration', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionConfiguration, + _sel_defaultSessionConfiguration, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFArrayGetTypeIDPtr = - _lookup>('CFArrayGetTypeID'); - late final _CFArrayGetTypeID = - _CFArrayGetTypeIDPtr.asFunction(); - - CFArrayRef CFArrayCreate( - CFAllocatorRef allocator, - ffi.Pointer> values, - int numValues, - ffi.Pointer callBacks, - ) { - return _CFArrayCreate(allocator, values, numValues, callBacks); + /// ephemeralSessionConfiguration + static NSURLSessionConfiguration getEphemeralSessionConfiguration() { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.ephemeralSessionConfiguration', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionConfiguration, + _sel_ephemeralSessionConfiguration, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFArrayCreatePtr = - _lookup< - ffi.NativeFunction< - CFArrayRef Function( - CFAllocatorRef, - ffi.Pointer>, - CFIndex, - ffi.Pointer, - ) - > - >('CFArrayCreate'); - late final _CFArrayCreate = - _CFArrayCreatePtr.asFunction< - CFArrayRef Function( - CFAllocatorRef, - ffi.Pointer>, - int, - ffi.Pointer, - ) - >(); - - CFArrayRef CFArrayCreateCopy(CFAllocatorRef allocator, CFArrayRef theArray) { - return _CFArrayCreateCopy(allocator, theArray); + /// new + static NSURLSessionConfiguration new$() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionConfiguration, + _sel_new, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _CFArrayCreateCopyPtr = - _lookup< - ffi.NativeFunction - >('CFArrayCreateCopy'); - late final _CFArrayCreateCopy = - _CFArrayCreateCopyPtr.asFunction< - CFArrayRef Function(CFAllocatorRef, CFArrayRef) - >(); + /// Returns a new instance of NSURLSessionConfiguration constructed with the default `new` method. + NSURLSessionConfiguration() : this.as(new$().object$); +} - CFMutableArrayRef CFArrayCreateMutable( - CFAllocatorRef allocator, - int capacity, - ffi.Pointer callBacks, - ) { - return _CFArrayCreateMutable(allocator, capacity, callBacks); +extension NSURLSessionConfiguration$Methods on NSURLSessionConfiguration { + /// Specifies additional headers which will be set on outgoing requests. + /// Note that these headers are added to the request only if not already present. + objc.NSDictionary? get HTTPAdditionalHeaders { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.HTTPAdditionalHeaders', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_HTTPAdditionalHeaders, + ); + return $ret.address == 0 + ? null + : objc.NSDictionary.fromPointer($ret, retain: true, release: true); } - late final _CFArrayCreateMutablePtr = - _lookup< - ffi.NativeFunction< - CFMutableArrayRef Function( - CFAllocatorRef, - CFIndex, - ffi.Pointer, - ) - > - >('CFArrayCreateMutable'); - late final _CFArrayCreateMutable = - _CFArrayCreateMutablePtr.asFunction< - CFMutableArrayRef Function( - CFAllocatorRef, - int, - ffi.Pointer, - ) - >(); - - CFMutableArrayRef CFArrayCreateMutableCopy( - CFAllocatorRef allocator, - int capacity, - CFArrayRef theArray, - ) { - return _CFArrayCreateMutableCopy(allocator, capacity, theArray); + /// Policy for accepting cookies. This overrides the policy otherwise specified by the cookie storage. + NSHTTPCookieAcceptPolicy get HTTPCookieAcceptPolicy { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.HTTPCookieAcceptPolicy', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_104dkoq( + object$.ref.pointer, + _sel_HTTPCookieAcceptPolicy, + ); + return NSHTTPCookieAcceptPolicy.fromValue($ret); } - late final _CFArrayCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableArrayRef Function(CFAllocatorRef, CFIndex, CFArrayRef) - > - >('CFArrayCreateMutableCopy'); - late final _CFArrayCreateMutableCopy = - _CFArrayCreateMutableCopyPtr.asFunction< - CFMutableArrayRef Function(CFAllocatorRef, int, CFArrayRef) - >(); - - int CFArrayGetCount(CFArrayRef theArray) { - return _CFArrayGetCount(theArray); + /// The cookie storage object to use, or nil to indicate that no cookies should be handled + NSHTTPCookieStorage? get HTTPCookieStorage { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.HTTPCookieStorage', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_HTTPCookieStorage, + ); + return $ret.address == 0 + ? null + : NSHTTPCookieStorage.fromPointer($ret, retain: true, release: true); } - late final _CFArrayGetCountPtr = - _lookup>( - 'CFArrayGetCount', - ); - late final _CFArrayGetCount = - _CFArrayGetCountPtr.asFunction(); - - int CFArrayGetCountOfValue( - CFArrayRef theArray, - CFRange range, - ffi.Pointer value, - ) { - return _CFArrayGetCountOfValue(theArray, range, value); + /// The maximum number of simultaneous persistent connections per host + int get HTTPMaximumConnectionsPerHost { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.HTTPMaximumConnectionsPerHost', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_1hz7y9r( + object$.ref.pointer, + _sel_HTTPMaximumConnectionsPerHost, + ); } - late final _CFArrayGetCountOfValuePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFArrayRef, CFRange, ffi.Pointer) - > - >('CFArrayGetCountOfValue'); - late final _CFArrayGetCountOfValue = - _CFArrayGetCountOfValuePtr.asFunction< - int Function(CFArrayRef, CFRange, ffi.Pointer) - >(); - - int CFArrayContainsValue( - CFArrayRef theArray, - CFRange range, - ffi.Pointer value, - ) { - return _CFArrayContainsValue(theArray, range, value); + /// Allow the session to set cookies on requests + bool get HTTPShouldSetCookies { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.HTTPShouldSetCookies', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_HTTPShouldSetCookies); } - late final _CFArrayContainsValuePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFArrayRef, CFRange, ffi.Pointer) - > - >('CFArrayContainsValue'); - late final _CFArrayContainsValue = - _CFArrayContainsValuePtr.asFunction< - int Function(CFArrayRef, CFRange, ffi.Pointer) - >(); - - ffi.Pointer CFArrayGetValueAtIndex(CFArrayRef theArray, int idx) { - return _CFArrayGetValueAtIndex(theArray, idx); - } - - late final _CFArrayGetValueAtIndexPtr = - _lookup< - ffi.NativeFunction Function(CFArrayRef, CFIndex)> - >('CFArrayGetValueAtIndex'); - late final _CFArrayGetValueAtIndex = - _CFArrayGetValueAtIndexPtr.asFunction< - ffi.Pointer Function(CFArrayRef, int) - >(); - - void CFArrayGetValues( - CFArrayRef theArray, - CFRange range, - ffi.Pointer> values, - ) { - return _CFArrayGetValues(theArray, range, values); + /// Allow the use of HTTP pipelining + bool get HTTPShouldUsePipelining { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.HTTPShouldUsePipelining', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_HTTPShouldUsePipelining, + ); } - late final _CFArrayGetValuesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFArrayRef, - CFRange, - ffi.Pointer>, - ) - > - >('CFArrayGetValues'); - late final _CFArrayGetValues = - _CFArrayGetValuesPtr.asFunction< - void Function(CFArrayRef, CFRange, ffi.Pointer>) - >(); - - void CFArrayApplyFunction( - CFArrayRef theArray, - CFRange range, - CFArrayApplierFunction applier, - ffi.Pointer context, - ) { - return _CFArrayApplyFunction(theArray, range, applier, context); + /// The maximum allowable versions of the TLS protocol, from + SSLProtocol get TLSMaximumSupportedProtocol { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.TLSMaximumSupportedProtocol', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_cbopi9( + object$.ref.pointer, + _sel_TLSMaximumSupportedProtocol, + ); + return SSLProtocol.fromValue($ret); } - late final _CFArrayApplyFunctionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFArrayRef, - CFRange, - CFArrayApplierFunction, - ffi.Pointer, - ) - > - >('CFArrayApplyFunction'); - late final _CFArrayApplyFunction = - _CFArrayApplyFunctionPtr.asFunction< - void Function( - CFArrayRef, - CFRange, - CFArrayApplierFunction, - ffi.Pointer, - ) - >(); - - int CFArrayGetFirstIndexOfValue( - CFArrayRef theArray, - CFRange range, - ffi.Pointer value, - ) { - return _CFArrayGetFirstIndexOfValue(theArray, range, value); + /// The maximum allowable versions of the TLS protocol, from + tls_protocol_version_t get TLSMaximumSupportedProtocolVersion { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.TLSMaximumSupportedProtocolVersion', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_9jpwfb( + object$.ref.pointer, + _sel_TLSMaximumSupportedProtocolVersion, + ); + return tls_protocol_version_t.fromValue($ret); } - late final _CFArrayGetFirstIndexOfValuePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFArrayRef, CFRange, ffi.Pointer) - > - >('CFArrayGetFirstIndexOfValue'); - late final _CFArrayGetFirstIndexOfValue = - _CFArrayGetFirstIndexOfValuePtr.asFunction< - int Function(CFArrayRef, CFRange, ffi.Pointer) - >(); - - int CFArrayGetLastIndexOfValue( - CFArrayRef theArray, - CFRange range, - ffi.Pointer value, - ) { - return _CFArrayGetLastIndexOfValue(theArray, range, value); + /// The minimum allowable versions of the TLS protocol, from + SSLProtocol get TLSMinimumSupportedProtocol { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.TLSMinimumSupportedProtocol', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_cbopi9( + object$.ref.pointer, + _sel_TLSMinimumSupportedProtocol, + ); + return SSLProtocol.fromValue($ret); } - late final _CFArrayGetLastIndexOfValuePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFArrayRef, CFRange, ffi.Pointer) - > - >('CFArrayGetLastIndexOfValue'); - late final _CFArrayGetLastIndexOfValue = - _CFArrayGetLastIndexOfValuePtr.asFunction< - int Function(CFArrayRef, CFRange, ffi.Pointer) - >(); - - int CFArrayBSearchValues( - CFArrayRef theArray, - CFRange range, - ffi.Pointer value, - CFComparatorFunction comparator, - ffi.Pointer context, - ) { - return _CFArrayBSearchValues(theArray, range, value, comparator, context); + /// The minimum allowable versions of the TLS protocol, from + tls_protocol_version_t get TLSMinimumSupportedProtocolVersion { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.TLSMinimumSupportedProtocolVersion', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_9jpwfb( + object$.ref.pointer, + _sel_TLSMinimumSupportedProtocolVersion, + ); + return tls_protocol_version_t.fromValue($ret); } - late final _CFArrayBSearchValuesPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFArrayRef, - CFRange, - ffi.Pointer, - CFComparatorFunction, - ffi.Pointer, - ) - > - >('CFArrayBSearchValues'); - late final _CFArrayBSearchValues = - _CFArrayBSearchValuesPtr.asFunction< - int Function( - CFArrayRef, - CFRange, - ffi.Pointer, - CFComparatorFunction, - ffi.Pointer, - ) - >(); - - void CFArrayAppendValue( - CFMutableArrayRef theArray, - ffi.Pointer value, - ) { - return _CFArrayAppendValue(theArray, value); + /// The URL resource cache, or nil to indicate that no caching is to be performed + NSURLCache? get URLCache { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.URLCache', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URLCache); + return $ret.address == 0 + ? null + : NSURLCache.fromPointer($ret, retain: true, release: true); } - late final _CFArrayAppendValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableArrayRef, ffi.Pointer) - > - >('CFArrayAppendValue'); - late final _CFArrayAppendValue = - _CFArrayAppendValuePtr.asFunction< - void Function(CFMutableArrayRef, ffi.Pointer) - >(); - - void CFArrayInsertValueAtIndex( - CFMutableArrayRef theArray, - int idx, - ffi.Pointer value, - ) { - return _CFArrayInsertValueAtIndex(theArray, idx, value); + /// The credential storage object, or nil to indicate that no credential storage is to be used + NSURLCredentialStorage? get URLCredentialStorage { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.URLCredentialStorage', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_URLCredentialStorage, + ); + return $ret.address == 0 + ? null + : NSURLCredentialStorage.fromPointer($ret, retain: true, release: true); } - late final _CFArrayInsertValueAtIndexPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableArrayRef, CFIndex, ffi.Pointer) - > - >('CFArrayInsertValueAtIndex'); - late final _CFArrayInsertValueAtIndex = - _CFArrayInsertValueAtIndexPtr.asFunction< - void Function(CFMutableArrayRef, int, ffi.Pointer) - >(); - - void CFArraySetValueAtIndex( - CFMutableArrayRef theArray, - int idx, - ffi.Pointer value, - ) { - return _CFArraySetValueAtIndex(theArray, idx, value); + /// allow request to route over cellular. + bool get allowsCellularAccess { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.allowsCellularAccess', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsCellularAccess); } - late final _CFArraySetValueAtIndexPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableArrayRef, CFIndex, ffi.Pointer) - > - >('CFArraySetValueAtIndex'); - late final _CFArraySetValueAtIndex = - _CFArraySetValueAtIndexPtr.asFunction< - void Function(CFMutableArrayRef, int, ffi.Pointer) - >(); - - void CFArrayRemoveValueAtIndex(CFMutableArrayRef theArray, int idx) { - return _CFArrayRemoveValueAtIndex(theArray, idx); + /// allow request to route over networks in constrained mode. Defaults to YES. + bool get allowsConstrainedNetworkAccess { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.allowsConstrainedNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_allowsConstrainedNetworkAccess, + ); } - late final _CFArrayRemoveValueAtIndexPtr = - _lookup< - ffi.NativeFunction - >('CFArrayRemoveValueAtIndex'); - late final _CFArrayRemoveValueAtIndex = - _CFArrayRemoveValueAtIndexPtr.asFunction< - void Function(CFMutableArrayRef, int) - >(); - - void CFArrayRemoveAllValues(CFMutableArrayRef theArray) { - return _CFArrayRemoveAllValues(theArray); + /// allow request to route over expensive networks. Defaults to YES. + bool get allowsExpensiveNetworkAccess { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.allowsExpensiveNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_allowsExpensiveNetworkAccess, + ); } - late final _CFArrayRemoveAllValuesPtr = - _lookup>( - 'CFArrayRemoveAllValues', - ); - late final _CFArrayRemoveAllValues = - _CFArrayRemoveAllValuesPtr.asFunction(); - - void CFArrayReplaceValues( - CFMutableArrayRef theArray, - CFRange range, - ffi.Pointer> newValues, - int newCount, - ) { - return _CFArrayReplaceValues(theArray, range, newValues, newCount); + /// The proxy dictionary, as described by + objc.NSDictionary? get connectionProxyDictionary { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.connectionProxyDictionary', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_connectionProxyDictionary, + ); + return $ret.address == 0 + ? null + : objc.NSDictionary.fromPointer($ret, retain: true, release: true); } - late final _CFArrayReplaceValuesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableArrayRef, - CFRange, - ffi.Pointer>, - CFIndex, - ) - > - >('CFArrayReplaceValues'); - late final _CFArrayReplaceValues = - _CFArrayReplaceValuesPtr.asFunction< - void Function( - CFMutableArrayRef, - CFRange, - ffi.Pointer>, - int, - ) - >(); - - void CFArrayExchangeValuesAtIndices( - CFMutableArrayRef theArray, - int idx1, - int idx2, - ) { - return _CFArrayExchangeValuesAtIndices(theArray, idx1, idx2); + /// Enables HTTP/3 0-RTT early data transmission of safe requests (GET or HEAD + /// requests). + /// + /// WARNING: Inclusion in TLS early data changes the security guarantees offered + /// by TLS. + /// + /// Requests sent in early data are not covered by anti-replay security + /// protections. Early data must be idempotent and the impact of adversarial + /// replays must be carefully evaluated, as the data may be replayed. Early data + /// also does not provide full forward secrecy; data transmitted is more + /// susceptible to data breach and security compromise of the server, even if + /// the breach happens after the data was transmitted. + /// + /// See Section 8 of RFC8446 for more details. + /// + /// https://datatracker.ietf.org/doc/html/rfc8446#section-8 + /// + /// See RFC8470 for additional discussion and security considerations. + /// + /// https://datatracker.ietf.org/doc/html/rfc8470 + /// + /// If these risks are acceptable for your use case, set this property to YES. + /// If unsure, NO is the safest option. + /// + /// NOTE: Not supported in the classic loading mode. + /// + /// Defaults to NO. + bool get enablesEarlyData { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.enablesEarlyData', + iOS: (false, (26, 0, 0)), + macOS: (false, (26, 0, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_enablesEarlyData); } - late final _CFArrayExchangeValuesAtIndicesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableArrayRef, CFIndex, CFIndex) - > - >('CFArrayExchangeValuesAtIndices'); - late final _CFArrayExchangeValuesAtIndices = - _CFArrayExchangeValuesAtIndicesPtr.asFunction< - void Function(CFMutableArrayRef, int, int) - >(); - - void CFArraySortValues( - CFMutableArrayRef theArray, - CFRange range, - CFComparatorFunction comparator, - ffi.Pointer context, - ) { - return _CFArraySortValues(theArray, range, comparator, context); + /// identifier for the background session configuration + objc.NSString? get identifier { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.identifier', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_identifier); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _CFArraySortValuesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableArrayRef, - CFRange, - CFComparatorFunction, - ffi.Pointer, - ) - > - >('CFArraySortValues'); - late final _CFArraySortValues = - _CFArraySortValuesPtr.asFunction< - void Function( - CFMutableArrayRef, - CFRange, - CFComparatorFunction, - ffi.Pointer, - ) - >(); - - void CFArrayAppendArray( - CFMutableArrayRef theArray, - CFArrayRef otherArray, - CFRange otherRange, - ) { - return _CFArrayAppendArray(theArray, otherArray, otherRange); + /// init + NSURLSessionConfiguration init() { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _CFArrayAppendArrayPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableArrayRef, CFArrayRef, CFRange) - > - >('CFArrayAppendArray'); - late final _CFArrayAppendArray = - _CFArrayAppendArrayPtr.asFunction< - void Function(CFMutableArrayRef, CFArrayRef, CFRange) - >(); - - ffi.Pointer os_retain(ffi.Pointer object) { - return _os_retain(object); + /// allows background tasks to be scheduled at the discretion of the system for optimal performance. + bool get isDiscretionary { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.isDiscretionary', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_isDiscretionary); } - late final _os_retainPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('os_retain'); - late final _os_retain = _os_retainPtr - .asFunction Function(ffi.Pointer)>(); - - void os_release(ffi.Pointer object) { - return _os_release(object); + /// multipath service type to use for connections. The default is NSURLSessionMultipathServiceTypeNone + NSURLSessionMultipathServiceType get multipathServiceType { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.multipathServiceType', + iOS: (false, (11, 0, 0)), + macOS: (true, null), + ); + final $ret = _objc_msgSend_1wxwnc0( + object$.ref.pointer, + _sel_multipathServiceType, + ); + return NSURLSessionMultipathServiceType.fromValue($ret); } - late final _os_releasePtr = - _lookup)>>( - 'os_release', - ); - late final _os_release = _os_releasePtr - .asFunction)>(); - - ffi.Pointer sec_retain(ffi.Pointer obj) { - return _sec_retain(obj); + /// type of service for requests. + NSURLRequestNetworkServiceType get networkServiceType { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.networkServiceType', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_t4uaw1( + object$.ref.pointer, + _sel_networkServiceType, + ); + return NSURLRequestNetworkServiceType.fromValue($ret); } - late final _sec_retainPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sec_retain'); - late final _sec_retain = _sec_retainPtr - .asFunction Function(ffi.Pointer)>(); - - void sec_release(ffi.Pointer obj) { - return _sec_release(obj); + /// An optional array of Class objects which subclass NSURLProtocol. + /// The Class will be sent +canInitWithRequest: when determining if + /// an instance of the class can be used for a given URL scheme. + /// You should not use +[NSURLProtocol registerClass:], as that + /// method will register your class with the default session rather + /// than with an instance of NSURLSession. + /// Custom NSURLProtocol subclasses are not available to background + /// sessions. + objc.NSArray? get protocolClasses { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.protocolClasses', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_protocolClasses, + ); + return $ret.address == 0 + ? null + : objc.NSArray.fromPointer($ret, retain: true, release: true); } - late final _sec_releasePtr = - _lookup)>>( - 'sec_release', - ); - late final _sec_release = _sec_releasePtr - .asFunction)>(); - - CFStringRef SecCopyErrorMessageString( - int status, - ffi.Pointer reserved, - ) { - return _SecCopyErrorMessageString(status, reserved); + /// default cache policy for requests + NSURLRequestCachePolicy get requestCachePolicy { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.requestCachePolicy', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_8jm3uo( + object$.ref.pointer, + _sel_requestCachePolicy, + ); + return NSURLRequestCachePolicy.fromValue($ret); } - late final _SecCopyErrorMessageStringPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(OSStatus, ffi.Pointer) - > - >('SecCopyErrorMessageString'); - late final _SecCopyErrorMessageString = - _SecCopyErrorMessageStringPtr.asFunction< - CFStringRef Function(int, ffi.Pointer) - >(); - - void __assert_rtn( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer arg3, - ) { - return ___assert_rtn(arg0, arg1, arg2, arg3); + /// requires requests from the session to be made with DNSSEC validation enabled. Defaults to NO. + bool get requiresDNSSECValidation { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.requiresDNSSECValidation', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_requiresDNSSECValidation, + ); } - late final ___assert_rtnPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >('__assert_rtn'); - late final ___assert_rtn = ___assert_rtnPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - late final ffi.Pointer<_RuneLocale> __DefaultRuneLocale = - _lookup<_RuneLocale>('_DefaultRuneLocale'); - - _RuneLocale get _DefaultRuneLocale => __DefaultRuneLocale.ref; - - late final ffi.Pointer> __CurrentRuneLocale = - _lookup>('_CurrentRuneLocale'); - - ffi.Pointer<_RuneLocale> get _CurrentRuneLocale => __CurrentRuneLocale.value; - - set _CurrentRuneLocale(ffi.Pointer<_RuneLocale> value) => - __CurrentRuneLocale.value = value; - - int ___runetype(int arg0) { - return ____runetype(arg0); - } - - late final ____runetypePtr = - _lookup< - ffi.NativeFunction - >('___runetype'); - late final ____runetype = ____runetypePtr.asFunction(); - - int ___tolower(int arg0) { - return ____tolower(arg0); - } - - late final ____tolowerPtr = - _lookup< - ffi.NativeFunction<__darwin_ct_rune_t Function(__darwin_ct_rune_t)> - >('___tolower'); - late final ____tolower = ____tolowerPtr.asFunction(); - - int ___toupper(int arg0) { - return ____toupper(arg0); - } - - late final ____toupperPtr = - _lookup< - ffi.NativeFunction<__darwin_ct_rune_t Function(__darwin_ct_rune_t)> - >('___toupper'); - late final ____toupper = ____toupperPtr.asFunction(); - - int __maskrune(int arg0, int arg1) { - return ___maskrune(arg0, arg1); - } - - late final ___maskrunePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(__darwin_ct_rune_t, ffi.UnsignedLong) - > - >('__maskrune'); - late final ___maskrune = ___maskrunePtr.asFunction(); - - int __toupper(int arg0) { - return ___toupper$1(arg0); + /// Allows the app to be resumed or launched in the background when tasks in background sessions complete + /// or when auth is required. This only applies to configurations created with +backgroundSessionConfigurationWithIdentifier: + /// and the default value is YES. + /// + /// NOTE: macOS apps based on AppKit do not support background launch. + bool get sessionSendsLaunchEvents { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.sessionSendsLaunchEvents', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_sessionSendsLaunchEvents, + ); } - late final ___toupperPtr = - _lookup< - ffi.NativeFunction<__darwin_ct_rune_t Function(__darwin_ct_rune_t)> - >('__toupper'); - late final ___toupper$1 = ___toupperPtr.asFunction(); - - int __tolower(int arg0) { - return ___tolower$1(arg0); + /// allow request to route over cellular. + set allowsCellularAccess(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setAllowsCellularAccess:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setAllowsCellularAccess_, + value, + ); } - late final ___tolowerPtr = - _lookup< - ffi.NativeFunction<__darwin_ct_rune_t Function(__darwin_ct_rune_t)> - >('__tolower'); - late final ___tolower$1 = ___tolowerPtr.asFunction(); - - ffi.Pointer __error() { - return ___error(); + /// allow request to route over networks in constrained mode. Defaults to YES. + set allowsConstrainedNetworkAccess(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setAllowsConstrainedNetworkAccess:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setAllowsConstrainedNetworkAccess_, + value, + ); } - late final ___errorPtr = - _lookup Function()>>('__error'); - late final ___error = ___errorPtr - .asFunction Function()>(); - - locale_t duplocale(locale_t arg0) { - return _duplocale(arg0); + /// allow request to route over expensive networks. Defaults to YES. + set allowsExpensiveNetworkAccess(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setAllowsExpensiveNetworkAccess:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setAllowsExpensiveNetworkAccess_, + value, + ); } - late final _duplocalePtr = - _lookup>('duplocale'); - late final _duplocale = _duplocalePtr - .asFunction(); - - int freelocale(locale_t arg0) { - return _freelocale(arg0); + /// The proxy dictionary, as described by + set connectionProxyDictionary(objc.NSDictionary? value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setConnectionProxyDictionary:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setConnectionProxyDictionary_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _freelocalePtr = - _lookup>('freelocale'); - late final _freelocale = _freelocalePtr.asFunction(); - - locale_t newlocale(int arg0, ffi.Pointer arg1, locale_t arg2) { - return _newlocale(arg0, arg1, arg2); + /// allows background tasks to be scheduled at the discretion of the system for optimal performance. + set isDiscretionary(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setDiscretionary:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_1s56lr9(object$.ref.pointer, _sel_setDiscretionary_, value); } - late final _newlocalePtr = - _lookup< - ffi.NativeFunction< - locale_t Function(ffi.Int, ffi.Pointer, locale_t) - > - >('newlocale'); - late final _newlocale = _newlocalePtr - .asFunction, locale_t)>(); - - locale_t uselocale(locale_t arg0) { - return _uselocale(arg0); + /// Enables HTTP/3 0-RTT early data transmission of safe requests (GET or HEAD + /// requests). + /// + /// WARNING: Inclusion in TLS early data changes the security guarantees offered + /// by TLS. + /// + /// Requests sent in early data are not covered by anti-replay security + /// protections. Early data must be idempotent and the impact of adversarial + /// replays must be carefully evaluated, as the data may be replayed. Early data + /// also does not provide full forward secrecy; data transmitted is more + /// susceptible to data breach and security compromise of the server, even if + /// the breach happens after the data was transmitted. + /// + /// See Section 8 of RFC8446 for more details. + /// + /// https://datatracker.ietf.org/doc/html/rfc8446#section-8 + /// + /// See RFC8470 for additional discussion and security considerations. + /// + /// https://datatracker.ietf.org/doc/html/rfc8470 + /// + /// If these risks are acceptable for your use case, set this property to YES. + /// If unsure, NO is the safest option. + /// + /// NOTE: Not supported in the classic loading mode. + /// + /// Defaults to NO. + set enablesEarlyData(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setEnablesEarlyData:', + iOS: (false, (26, 0, 0)), + macOS: (false, (26, 0, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setEnablesEarlyData_, + value, + ); } - late final _uselocalePtr = - _lookup>('uselocale'); - late final _uselocale = _uselocalePtr - .asFunction(); - - ffi.Pointer localeconv() { - return _localeconv(); + /// Specifies additional headers which will be set on outgoing requests. + /// Note that these headers are added to the request only if not already present. + set HTTPAdditionalHeaders(objc.NSDictionary? value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setHTTPAdditionalHeaders:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setHTTPAdditionalHeaders_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _localeconvPtr = - _lookup Function()>>('localeconv'); - late final _localeconv = _localeconvPtr - .asFunction Function()>(); - - ffi.Pointer setlocale(int arg0, ffi.Pointer arg1) { - return _setlocale(arg0, arg1); + /// Policy for accepting cookies. This overrides the policy otherwise specified by the cookie storage. + set HTTPCookieAcceptPolicy(NSHTTPCookieAcceptPolicy value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setHTTPCookieAcceptPolicy:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_3q55ys( + object$.ref.pointer, + _sel_setHTTPCookieAcceptPolicy_, + value.value, + ); } - late final _setlocalePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Int, ffi.Pointer) - > - >('setlocale'); - late final _setlocale = _setlocalePtr - .asFunction Function(int, ffi.Pointer)>(); - - int __math_errhandling() { - return ___math_errhandling(); + /// The cookie storage object to use, or nil to indicate that no cookies should be handled + set HTTPCookieStorage(NSHTTPCookieStorage? value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setHTTPCookieStorage:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setHTTPCookieStorage_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final ___math_errhandlingPtr = - _lookup>('__math_errhandling'); - late final ___math_errhandling = ___math_errhandlingPtr - .asFunction(); - - int __fpclassifyf(double arg0) { - return ___fpclassifyf(arg0); + /// The maximum number of simultaneous persistent connections per host + set HTTPMaximumConnectionsPerHost(int value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setHTTPMaximumConnectionsPerHost:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_4sp4xj( + object$.ref.pointer, + _sel_setHTTPMaximumConnectionsPerHost_, + value, + ); } - late final ___fpclassifyfPtr = - _lookup>('__fpclassifyf'); - late final ___fpclassifyf = ___fpclassifyfPtr - .asFunction(); - - int __fpclassifyd(double arg0) { - return ___fpclassifyd(arg0); + /// Allow the session to set cookies on requests + set HTTPShouldSetCookies(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setHTTPShouldSetCookies:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setHTTPShouldSetCookies_, + value, + ); } - late final ___fpclassifydPtr = - _lookup>( - '__fpclassifyd', - ); - late final ___fpclassifyd = ___fpclassifydPtr - .asFunction(); - - double acosf(double arg0) { - return _acosf(arg0); + /// Allow the use of HTTP pipelining + set HTTPShouldUsePipelining(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setHTTPShouldUsePipelining:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setHTTPShouldUsePipelining_, + value, + ); } - late final _acosfPtr = - _lookup>('acosf'); - late final _acosf = _acosfPtr.asFunction(); - - double acos(double arg0) { - return _acos(arg0); + /// multipath service type to use for connections. The default is NSURLSessionMultipathServiceTypeNone + set multipathServiceType(NSURLSessionMultipathServiceType value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setMultipathServiceType:', + iOS: (false, (11, 0, 0)), + macOS: (true, null), + ); + _objc_msgSend_1hx005a( + object$.ref.pointer, + _sel_setMultipathServiceType_, + value.value, + ); } - late final _acosPtr = - _lookup>('acos'); - late final _acos = _acosPtr.asFunction(); - - double asinf(double arg0) { - return _asinf(arg0); + /// type of service for requests. + set networkServiceType(NSURLRequestNetworkServiceType value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setNetworkServiceType:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1mse4s1( + object$.ref.pointer, + _sel_setNetworkServiceType_, + value.value, + ); } - late final _asinfPtr = - _lookup>('asinf'); - late final _asinf = _asinfPtr.asFunction(); - - double asin(double arg0) { - return _asin(arg0); + /// An optional array of Class objects which subclass NSURLProtocol. + /// The Class will be sent +canInitWithRequest: when determining if + /// an instance of the class can be used for a given URL scheme. + /// You should not use +[NSURLProtocol registerClass:], as that + /// method will register your class with the default session rather + /// than with an instance of NSURLSession. + /// Custom NSURLProtocol subclasses are not available to background + /// sessions. + set protocolClasses(objc.NSArray? value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setProtocolClasses:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setProtocolClasses_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _asinPtr = - _lookup>('asin'); - late final _asin = _asinPtr.asFunction(); - - double atanf(double arg0) { - return _atanf(arg0); + /// default cache policy for requests + set requestCachePolicy(NSURLRequestCachePolicy value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setRequestCachePolicy:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1yjxuv2( + object$.ref.pointer, + _sel_setRequestCachePolicy_, + value.value, + ); } - late final _atanfPtr = - _lookup>('atanf'); - late final _atanf = _atanfPtr.asFunction(); - - double atan(double arg0) { - return _atan(arg0); + /// requires requests from the session to be made with DNSSEC validation enabled. Defaults to NO. + set requiresDNSSECValidation(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setRequiresDNSSECValidation:', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setRequiresDNSSECValidation_, + value, + ); } - late final _atanPtr = - _lookup>('atan'); - late final _atan = _atanPtr.asFunction(); - - double atan2f(double arg0, double arg1) { - return _atan2f(arg0, arg1); + /// Allows the app to be resumed or launched in the background when tasks in background sessions complete + /// or when auth is required. This only applies to configurations created with +backgroundSessionConfigurationWithIdentifier: + /// and the default value is YES. + /// + /// NOTE: macOS apps based on AppKit do not support background launch. + set sessionSendsLaunchEvents(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setSessionSendsLaunchEvents:', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setSessionSendsLaunchEvents_, + value, + ); } - late final _atan2fPtr = - _lookup>( - 'atan2f', - ); - late final _atan2f = _atan2fPtr.asFunction(); - - double atan2(double arg0, double arg1) { - return _atan2(arg0, arg1); + /// The identifier of the shared data container into which files in background sessions should be downloaded. + /// App extensions wishing to use background sessions *must* set this property to a valid container identifier, or + /// all transfers in that session will fail with NSURLErrorBackgroundSessionRequiresSharedContainer. + set sharedContainerIdentifier(objc.NSString? value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setSharedContainerIdentifier:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setSharedContainerIdentifier_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _atan2Ptr = - _lookup>( - 'atan2', - ); - late final _atan2 = _atan2Ptr.asFunction(); - - double cosf(double arg0) { - return _cosf(arg0); + /// setShouldUseExtendedBackgroundIdleMode: + set shouldUseExtendedBackgroundIdleMode(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setShouldUseExtendedBackgroundIdleMode:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setShouldUseExtendedBackgroundIdleMode_, + value, + ); } - late final _cosfPtr = - _lookup>('cosf'); - late final _cosf = _cosfPtr.asFunction(); - - double cos(double arg0) { - return _cos(arg0); + /// The maximum allowable versions of the TLS protocol, from + set TLSMaximumSupportedProtocol(SSLProtocol value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTLSMaximumSupportedProtocol:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_268k8x( + object$.ref.pointer, + _sel_setTLSMaximumSupportedProtocol_, + value.value, + ); } - late final _cosPtr = - _lookup>('cos'); - late final _cos = _cosPtr.asFunction(); - - double sinf(double arg0) { - return _sinf(arg0); + /// The maximum allowable versions of the TLS protocol, from + set TLSMaximumSupportedProtocolVersion(tls_protocol_version_t value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTLSMaximumSupportedProtocolVersion:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_1mvuct7( + object$.ref.pointer, + _sel_setTLSMaximumSupportedProtocolVersion_, + value.value, + ); } - late final _sinfPtr = - _lookup>('sinf'); - late final _sinf = _sinfPtr.asFunction(); - - double sin(double arg0) { - return _sin(arg0); + /// The minimum allowable versions of the TLS protocol, from + set TLSMinimumSupportedProtocol(SSLProtocol value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTLSMinimumSupportedProtocol:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_268k8x( + object$.ref.pointer, + _sel_setTLSMinimumSupportedProtocol_, + value.value, + ); } - late final _sinPtr = - _lookup>('sin'); - late final _sin = _sinPtr.asFunction(); - - double tanf(double arg0) { - return _tanf(arg0); + /// The minimum allowable versions of the TLS protocol, from + set TLSMinimumSupportedProtocolVersion(tls_protocol_version_t value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTLSMinimumSupportedProtocolVersion:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_1mvuct7( + object$.ref.pointer, + _sel_setTLSMinimumSupportedProtocolVersion_, + value.value, + ); } - late final _tanfPtr = - _lookup>('tanf'); - late final _tanf = _tanfPtr.asFunction(); - - double tan(double arg0) { - return _tan(arg0); + /// default timeout for requests. This will cause a timeout if no data is transmitted for the given timeout value, and is reset whenever data is transmitted. + set timeoutIntervalForRequest(double value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTimeoutIntervalForRequest:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_hwm8nu( + object$.ref.pointer, + _sel_setTimeoutIntervalForRequest_, + value, + ); } - late final _tanPtr = - _lookup>('tan'); - late final _tan = _tanPtr.asFunction(); - - double acoshf(double arg0) { - return _acoshf(arg0); + /// default timeout for requests. This will cause a timeout if a resource is not able to be retrieved within a given timeout. + set timeoutIntervalForResource(double value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTimeoutIntervalForResource:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_hwm8nu( + object$.ref.pointer, + _sel_setTimeoutIntervalForResource_, + value, + ); } - late final _acoshfPtr = - _lookup>('acoshf'); - late final _acoshf = _acoshfPtr.asFunction(); - - double acosh(double arg0) { - return _acosh(arg0); + /// The URL resource cache, or nil to indicate that no caching is to be performed + set URLCache(NSURLCache? value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setURLCache:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setURLCache_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _acoshPtr = - _lookup>('acosh'); - late final _acosh = _acoshPtr.asFunction(); - - double asinhf(double arg0) { - return _asinhf(arg0); + /// The credential storage object, or nil to indicate that no credential storage is to be used + set URLCredentialStorage(NSURLCredentialStorage? value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setURLCredentialStorage:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setURLCredentialStorage_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _asinhfPtr = - _lookup>('asinhf'); - late final _asinhf = _asinhfPtr.asFunction(); - - double asinh(double arg0) { - return _asinh(arg0); + /// Uses the classic network loader. + /// + /// NOTE: FTP and HTTP/1 pipelining are only supported in the classic loading mode. + /// + /// Defaults to YES. The default may be NO in a future OS update. + set usesClassicLoadingMode(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setUsesClassicLoadingMode:', + iOS: (false, (18, 4, 0)), + macOS: (false, (15, 4, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setUsesClassicLoadingMode_, + value, + ); } - late final _asinhPtr = - _lookup>('asinh'); - late final _asinh = _asinhPtr.asFunction(); - - double atanhf(double arg0) { - return _atanhf(arg0); + /// Causes tasks to wait for network connectivity to become available, rather + /// than immediately failing with an error (such as NSURLErrorNotConnectedToInternet) + /// when it is not. When waiting for connectivity, the timeoutIntervalForRequest + /// property does not apply, but the timeoutIntervalForResource property does. + /// + /// Unsatisfactory connectivity (that requires waiting) includes cases where the + /// device has limited or insufficient connectivity for a task (e.g., only has a + /// cellular connection but the allowsCellularAccess property is NO, or requires + /// a VPN connection in order to reach the desired host). + /// + /// Default value is NO. Ignored by background sessions, as background sessions + /// always wait for connectivity. + set waitsForConnectivity(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setWaitsForConnectivity:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setWaitsForConnectivity_, + value, + ); } - late final _atanhfPtr = - _lookup>('atanhf'); - late final _atanhf = _atanhfPtr.asFunction(); - - double atanh(double arg0) { - return _atanh(arg0); + /// The identifier of the shared data container into which files in background sessions should be downloaded. + /// App extensions wishing to use background sessions *must* set this property to a valid container identifier, or + /// all transfers in that session will fail with NSURLErrorBackgroundSessionRequiresSharedContainer. + objc.NSString? get sharedContainerIdentifier { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.sharedContainerIdentifier', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_sharedContainerIdentifier, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _atanhPtr = - _lookup>('atanh'); - late final _atanh = _atanhPtr.asFunction(); - - double coshf(double arg0) { - return _coshf(arg0); + /// shouldUseExtendedBackgroundIdleMode + bool get shouldUseExtendedBackgroundIdleMode { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.shouldUseExtendedBackgroundIdleMode', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_shouldUseExtendedBackgroundIdleMode, + ); } - late final _coshfPtr = - _lookup>('coshf'); - late final _coshf = _coshfPtr.asFunction(); - - double cosh(double arg0) { - return _cosh(arg0); - } - - late final _coshPtr = - _lookup>('cosh'); - late final _cosh = _coshPtr.asFunction(); - - double sinhf(double arg0) { - return _sinhf(arg0); - } - - late final _sinhfPtr = - _lookup>('sinhf'); - late final _sinhf = _sinhfPtr.asFunction(); - - double sinh(double arg0) { - return _sinh(arg0); - } - - late final _sinhPtr = - _lookup>('sinh'); - late final _sinh = _sinhPtr.asFunction(); - - double tanhf(double arg0) { - return _tanhf(arg0); - } - - late final _tanhfPtr = - _lookup>('tanhf'); - late final _tanhf = _tanhfPtr.asFunction(); - - double tanh(double arg0) { - return _tanh(arg0); - } - - late final _tanhPtr = - _lookup>('tanh'); - late final _tanh = _tanhPtr.asFunction(); - - double expf(double arg0) { - return _expf(arg0); - } - - late final _expfPtr = - _lookup>('expf'); - late final _expf = _expfPtr.asFunction(); - - double exp(double arg0) { - return _exp(arg0); - } - - late final _expPtr = - _lookup>('exp'); - late final _exp = _expPtr.asFunction(); - - double exp2f(double arg0) { - return _exp2f(arg0); - } - - late final _exp2fPtr = - _lookup>('exp2f'); - late final _exp2f = _exp2fPtr.asFunction(); - - double exp2(double arg0) { - return _exp2(arg0); - } - - late final _exp2Ptr = - _lookup>('exp2'); - late final _exp2 = _exp2Ptr.asFunction(); - - double expm1f(double arg0) { - return _expm1f(arg0); - } - - late final _expm1fPtr = - _lookup>('expm1f'); - late final _expm1f = _expm1fPtr.asFunction(); - - double expm1(double arg0) { - return _expm1(arg0); - } - - late final _expm1Ptr = - _lookup>('expm1'); - late final _expm1 = _expm1Ptr.asFunction(); - - double logf(double arg0) { - return _logf(arg0); - } - - late final _logfPtr = - _lookup>('logf'); - late final _logf = _logfPtr.asFunction(); - - double log(double arg0) { - return _log(arg0); - } - - late final _logPtr = - _lookup>('log'); - late final _log = _logPtr.asFunction(); - - double log10f(double arg0) { - return _log10f(arg0); - } - - late final _log10fPtr = - _lookup>('log10f'); - late final _log10f = _log10fPtr.asFunction(); - - double log10(double arg0) { - return _log10(arg0); - } - - late final _log10Ptr = - _lookup>('log10'); - late final _log10 = _log10Ptr.asFunction(); - - double log2f(double arg0) { - return _log2f(arg0); - } - - late final _log2fPtr = - _lookup>('log2f'); - late final _log2f = _log2fPtr.asFunction(); - - double log2(double arg0) { - return _log2(arg0); - } - - late final _log2Ptr = - _lookup>('log2'); - late final _log2 = _log2Ptr.asFunction(); - - double log1pf(double arg0) { - return _log1pf(arg0); - } - - late final _log1pfPtr = - _lookup>('log1pf'); - late final _log1pf = _log1pfPtr.asFunction(); - - double log1p(double arg0) { - return _log1p(arg0); - } - - late final _log1pPtr = - _lookup>('log1p'); - late final _log1p = _log1pPtr.asFunction(); - - double logbf(double arg0) { - return _logbf(arg0); + /// default timeout for requests. This will cause a timeout if no data is transmitted for the given timeout value, and is reset whenever data is transmitted. + double get timeoutIntervalForRequest { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.timeoutIntervalForRequest', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return objc.useMsgSendVariants + ? _objc_msgSend_1ukqyt8Fpret( + object$.ref.pointer, + _sel_timeoutIntervalForRequest, + ) + : _objc_msgSend_1ukqyt8( + object$.ref.pointer, + _sel_timeoutIntervalForRequest, + ); } - late final _logbfPtr = - _lookup>('logbf'); - late final _logbf = _logbfPtr.asFunction(); - - double logb(double arg0) { - return _logb(arg0); + /// default timeout for requests. This will cause a timeout if a resource is not able to be retrieved within a given timeout. + double get timeoutIntervalForResource { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.timeoutIntervalForResource', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return objc.useMsgSendVariants + ? _objc_msgSend_1ukqyt8Fpret( + object$.ref.pointer, + _sel_timeoutIntervalForResource, + ) + : _objc_msgSend_1ukqyt8( + object$.ref.pointer, + _sel_timeoutIntervalForResource, + ); } - late final _logbPtr = - _lookup>('logb'); - late final _logb = _logbPtr.asFunction(); - - double modff(double arg0, ffi.Pointer arg1) { - return _modff(arg0, arg1); + /// Uses the classic network loader. + /// + /// NOTE: FTP and HTTP/1 pipelining are only supported in the classic loading mode. + /// + /// Defaults to YES. The default may be NO in a future OS update. + bool get usesClassicLoadingMode { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.usesClassicLoadingMode', + iOS: (false, (18, 4, 0)), + macOS: (false, (15, 4, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_usesClassicLoadingMode, + ); } - late final _modffPtr = - _lookup< - ffi.NativeFunction< - ffi.Float Function(ffi.Float, ffi.Pointer) - > - >('modff'); - late final _modff = _modffPtr - .asFunction)>(); - - double modf(double arg0, ffi.Pointer arg1) { - return _modf(arg0, arg1); + /// Causes tasks to wait for network connectivity to become available, rather + /// than immediately failing with an error (such as NSURLErrorNotConnectedToInternet) + /// when it is not. When waiting for connectivity, the timeoutIntervalForRequest + /// property does not apply, but the timeoutIntervalForResource property does. + /// + /// Unsatisfactory connectivity (that requires waiting) includes cases where the + /// device has limited or insufficient connectivity for a task (e.g., only has a + /// cellular connection but the allowsCellularAccess property is NO, or requires + /// a VPN connection in order to reach the desired host). + /// + /// Default value is NO. Ignored by background sessions, as background sessions + /// always wait for connectivity. + bool get waitsForConnectivity { + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.waitsForConnectivity', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_waitsForConnectivity); } +} - late final _modfPtr = - _lookup< - ffi.NativeFunction< - ffi.Double Function(ffi.Double, ffi.Pointer) - > - >('modf'); - late final _modf = _modfPtr - .asFunction)>(); - - double ldexpf(double arg0, int arg1) { - return _ldexpf(arg0, arg1); - } +late final _sel_sessionWithConfiguration_ = objc.registerName( + "sessionWithConfiguration:", +); - late final _ldexpfPtr = - _lookup>( - 'ldexpf', - ); - late final _ldexpf = _ldexpfPtr.asFunction(); +/// WARNING: NSURLSessionDelegate is a stub. To generate bindings for this class, include +/// NSURLSessionDelegate in your config's objc-protocols list. +/// +/// Messages related to the URL session as a whole +extension type NSURLSessionDelegate._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol, objc.NSObjectProtocol { + /// Constructs a [NSURLSessionDelegate] that points to the same underlying object as [other]. + NSURLSessionDelegate.as(objc.ObjCObject other) : object$ = other; - double ldexp(double arg0, int arg1) { - return _ldexp(arg0, arg1); - } + /// Constructs a [NSURLSessionDelegate] that wraps the given raw object pointer. + NSURLSessionDelegate.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); +} - late final _ldexpPtr = - _lookup>( - 'ldexp', - ); - late final _ldexp = _ldexpPtr.asFunction(); +late final _class_NSOperationQueue = objc.getClass("NSOperationQueue"); +late final _sel_progress = objc.registerName("progress"); - double frexpf(double arg0, ffi.Pointer arg1) { - return _frexpf(arg0, arg1); - } +/// Construction methods for `objc.ObjCBlock)>`. +abstract final class ObjCBlock_NSProgress_ffiVoid { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock)> + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock)>( + pointer, + retain: retain, + release: release, + ); - late final _frexpfPtr = - _lookup< - ffi.NativeFunction)> - >('frexpf'); - late final _frexpf = _frexpfPtr - .asFunction)>(); + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock)> + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock)>( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - double frexp(double arg0, ffi.Pointer arg1) { - return _frexp(arg0, arg1); - } + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock)> + fromFunction( + objc.NSProgress Function(ffi.Pointer) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock)>( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn(arg0).ref.retainAndAutorelease(), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - late final _frexpPtr = - _lookup< + static ffi.Pointer _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Double Function(ffi.Double, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer arg0) > - >('frexp'); - late final _frexp = _frexpPtr - .asFunction)>(); - - int ilogbf(double arg0) { - return _ilogbf(arg0); - } - - late final _ilogbfPtr = - _lookup>('ilogbf'); - late final _ilogbf = _ilogbfPtr.asFunction(); - - int ilogb(double arg0) { - return _ilogb(arg0); - } - - late final _ilogbPtr = - _lookup>('ilogb'); - late final _ilogb = _ilogbPtr.asFunction(); - - double scalbnf(double arg0, int arg1) { - return _scalbnf(arg0, arg1); - } - - late final _scalbnfPtr = - _lookup>( - 'scalbnf', + >() + .asFunction< + ffi.Pointer Function(ffi.Pointer) + >()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static ffi.Pointer _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as ffi.Pointer Function(ffi.Pointer))( + arg0, ); - late final _scalbnf = _scalbnfPtr.asFunction(); - - double scalbn(double arg0, int arg1) { - return _scalbn(arg0, arg1); - } + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _scalbnPtr = - _lookup>( - 'scalbn', +/// Call operator for `objc.ObjCBlock)>`. +extension ObjCBlock_NSProgress_ffiVoid$CallExtension + on objc.ObjCBlock)> { + objc.NSProgress call(ffi.Pointer arg0) => + objc.NSProgress.fromPointer( + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0), + retain: true, + release: true, ); - late final _scalbn = _scalbnPtr.asFunction(); +} - double scalblnf(double arg0, int arg1) { - return _scalblnf(arg0, arg1); +/// WARNING: NSOperation is a stub. To generate bindings for this class, include +/// NSOperation in your config's objc-interfaces list. +/// +/// NSOperation +extension type NSOperation._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [NSOperation] that points to the same underlying object as [other]. + NSOperation.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSOperation', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); } - late final _scalblnfPtr = - _lookup>( - 'scalblnf', - ); - late final _scalblnf = _scalblnfPtr - .asFunction(); - - double scalbln(double arg0, int arg1) { - return _scalbln(arg0, arg1); + /// Constructs a [NSOperation] that wraps the given raw object pointer. + NSOperation.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSOperation', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); } +} - late final _scalblnPtr = - _lookup>( - 'scalbln', - ); - late final _scalbln = _scalblnPtr.asFunction(); - - double fabsf(double arg0) { - return _fabsf(arg0); - } +late final _sel_addOperation_ = objc.registerName("addOperation:"); +late final _sel_addOperations_waitUntilFinished_ = objc.registerName( + "addOperations:waitUntilFinished:", +); +final _objc_msgSend_6p7ndb = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + bool, + ) + >(); - late final _fabsfPtr = - _lookup>('fabsf'); - late final _fabsf = _fabsfPtr.asFunction(); +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); - double fabs(double arg0) { - return _fabs(arg0); - } + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer> ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _fabsPtr = - _lookup>('fabs'); - late final _fabs = _fabsPtr.asFunction(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function() fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock(_closureCallable, () => fn(), keepIsolateAlive), + retain: false, + release: true, + ); - double cbrtf(double arg0) { - return _cbrtf(arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function() fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + () => fn(), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1pl9qdv(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _cbrtfPtr = - _lookup>('cbrtf'); - late final _cbrtf = _cbrtfPtr.asFunction(); - - double cbrt(double arg0) { - return _cbrt(arg0); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function() fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + () => fn(), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + () => fn(), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1pl9qdv( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _cbrtPtr = - _lookup>('cbrt'); - late final _cbrt = _cbrtPtr.asFunction(); - - double hypotf(double arg0, double arg1) { - return _hypotf(arg0, arg1); + static void _listenerTrampoline(ffi.Pointer block) { + (objc.getBlockClosure(block) as void Function())(); + objc.objectRelease(block.cast()); } - late final _hypotfPtr = - _lookup>( - 'hypotf', - ); - late final _hypotf = _hypotfPtr.asFunction(); - - double hypot(double arg0, double arg1) { - return _hypot(arg0, arg1); + static ffi.NativeCallable)> + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function(ffi.Pointer) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ) { + try { + (objc.getBlockClosure(block) as void Function())(); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _hypotPtr = - _lookup>( - 'hypot', - ); - late final _hypot = _hypotPtr.asFunction(); - - double powf(double arg0, double arg1) { - return _powf(arg0, arg1); - } + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer, ffi.Pointer) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer, ffi.Pointer) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline(ffi.Pointer block) => block + .ref + .target + .cast>() + .asFunction()(); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline(ffi.Pointer block) => + (objc.getBlockClosure(block) as void Function())(); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer) + >(_closureTrampoline) + .cast(); +} - late final _powfPtr = - _lookup>( - 'powf', +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid$CallExtension + on objc.ObjCBlock { + void call() => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer block) + > + >() + .asFunction)>()( + ref.pointer, ); - late final _powf = _powfPtr.asFunction(); +} - double pow(double arg0, double arg1) { - return _pow(arg0, arg1); - } - - late final _powPtr = - _lookup>( - 'pow', - ); - late final _pow = _powPtr.asFunction(); - - double sqrtf(double arg0) { - return _sqrtf(arg0); - } - - late final _sqrtfPtr = - _lookup>('sqrtf'); - late final _sqrtf = _sqrtfPtr.asFunction(); - - double sqrt(double arg0) { - return _sqrt(arg0); - } - - late final _sqrtPtr = - _lookup>('sqrt'); - late final _sqrt = _sqrtPtr.asFunction(); - - double erff(double arg0) { - return _erff(arg0); - } - - late final _erffPtr = - _lookup>('erff'); - late final _erff = _erffPtr.asFunction(); - - double erf(double arg0) { - return _erf(arg0); - } - - late final _erfPtr = - _lookup>('erf'); - late final _erf = _erfPtr.asFunction(); +late final _sel_addOperationWithBlock_ = objc.registerName( + "addOperationWithBlock:", +); +final _objc_msgSend_f167m6 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_addBarrierBlock_ = objc.registerName("addBarrierBlock:"); +late final _sel_maxConcurrentOperationCount = objc.registerName( + "maxConcurrentOperationCount", +); +late final _sel_setMaxConcurrentOperationCount_ = objc.registerName( + "setMaxConcurrentOperationCount:", +); +late final _sel_isSuspended = objc.registerName("isSuspended"); +late final _sel_setSuspended_ = objc.registerName("setSuspended:"); +late final _sel_name = objc.registerName("name"); +late final _sel_setName_ = objc.registerName("setName:"); +late final _sel_qualityOfService = objc.registerName("qualityOfService"); +final _objc_msgSend_oi8iq9 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setQualityOfService_ = objc.registerName( + "setQualityOfService:", +); +final _objc_msgSend_n2da1l = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_underlyingQueue = objc.registerName("underlyingQueue"); +late final _sel_setUnderlyingQueue_ = objc.registerName("setUnderlyingQueue:"); +late final _sel_cancelAllOperations = objc.registerName("cancelAllOperations"); +late final _sel_waitUntilAllOperationsAreFinished = objc.registerName( + "waitUntilAllOperationsAreFinished", +); +late final _sel_currentQueue = objc.registerName("currentQueue"); +late final _sel_mainQueue = objc.registerName("mainQueue"); +late final _sel_operations = objc.registerName("operations"); +late final _sel_operationCount = objc.registerName("operationCount"); - double erfcf(double arg0) { - return _erfcf(arg0); +/// NSDeprecated +extension NSDeprecated on NSOperationQueue { + /// operationCount + int get operationCount { + objc.checkOsVersionInternal( + 'NSOperationQueue.operationCount', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_operationCount); } - late final _erfcfPtr = - _lookup>('erfcf'); - late final _erfcf = _erfcfPtr.asFunction(); - - double erfc(double arg0) { - return _erfc(arg0); + /// These two functions are inherently a race condition and should be avoided if possible + objc.NSArray get operations { + objc.checkOsVersionInternal( + 'NSOperationQueue.operations', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_operations); + return objc.NSArray.fromPointer($ret, retain: true, release: true); } +} - late final _erfcPtr = - _lookup>('erfc'); - late final _erfc = _erfcPtr.asFunction(); - - double lgammaf(double arg0) { - return _lgammaf(arg0); +/// NSOperationQueue +extension type NSOperationQueue._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject, NSProgressReporting { + /// Constructs a [NSOperationQueue] that points to the same underlying object as [other]. + NSOperationQueue.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); } - late final _lgammafPtr = - _lookup>('lgammaf'); - late final _lgammaf = _lgammafPtr.asFunction(); - - double lgamma(double arg0) { - return _lgamma(arg0); + /// Constructs a [NSOperationQueue] that wraps the given raw object pointer. + NSOperationQueue.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); } - late final _lgammaPtr = - _lookup>('lgamma'); - late final _lgamma = _lgammaPtr.asFunction(); + /// Returns whether [obj] is an instance of [NSOperationQueue]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSOperationQueue, + ); - double tgammaf(double arg0) { - return _tgammaf(arg0); + /// alloc + static NSOperationQueue alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSOperationQueue, _sel_alloc); + return NSOperationQueue.fromPointer($ret, retain: false, release: true); } - late final _tgammafPtr = - _lookup>('tgammaf'); - late final _tgammaf = _tgammafPtr.asFunction(); - - double tgamma(double arg0) { - return _tgamma(arg0); + /// allocWithZone: + static NSOperationQueue allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSOperationQueue, + _sel_allocWithZone_, + zone, + ); + return NSOperationQueue.fromPointer($ret, retain: false, release: true); } - late final _tgammaPtr = - _lookup>('tgamma'); - late final _tgamma = _tgammaPtr.asFunction(); - - double ceilf(double arg0) { - return _ceilf(arg0); + /// currentQueue + static NSOperationQueue? getCurrentQueue() { + objc.checkOsVersionInternal( + 'NSOperationQueue.currentQueue', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _class_NSOperationQueue, + _sel_currentQueue, + ); + return $ret.address == 0 + ? null + : NSOperationQueue.fromPointer($ret, retain: true, release: true); } - late final _ceilfPtr = - _lookup>('ceilf'); - late final _ceilf = _ceilfPtr.asFunction(); - - double ceil(double arg0) { - return _ceil(arg0); + /// mainQueue + static NSOperationQueue getMainQueue() { + objc.checkOsVersionInternal( + 'NSOperationQueue.mainQueue', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + final $ret = _objc_msgSend_151sglz(_class_NSOperationQueue, _sel_mainQueue); + return NSOperationQueue.fromPointer($ret, retain: true, release: true); } - late final _ceilPtr = - _lookup>('ceil'); - late final _ceil = _ceilPtr.asFunction(); - - double floorf(double arg0) { - return _floorf(arg0); + /// new + static NSOperationQueue new$() { + final $ret = _objc_msgSend_151sglz(_class_NSOperationQueue, _sel_new); + return NSOperationQueue.fromPointer($ret, retain: false, release: true); } - late final _floorfPtr = - _lookup>('floorf'); - late final _floorf = _floorfPtr.asFunction(); + /// Returns a new instance of NSOperationQueue constructed with the default `new` method. + NSOperationQueue() : this.as(new$().object$); +} - double floor(double arg0) { - return _floor(arg0); +extension NSOperationQueue$Methods on NSOperationQueue { + /// @method addBarrierBlock: + /// @param barrier A block to execute + /// @discussion The `addBarrierBlock:` method executes the block when the NSOperationQueue has finished all enqueued operations and + /// prevents any subsequent operations to be executed until the barrier has been completed. This acts similarly to the + /// `dispatch_barrier_async` function. + void addBarrierBlock(objc.ObjCBlock barrier) { + objc.checkOsVersionInternal( + 'NSOperationQueue.addBarrierBlock:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_addBarrierBlock_, + barrier.ref.pointer, + ); } - late final _floorPtr = - _lookup>('floor'); - late final _floor = _floorPtr.asFunction(); - - double nearbyintf(double arg0) { - return _nearbyintf(arg0); + /// addOperation: + void addOperation(NSOperation op) { + objc.checkOsVersionInternal( + 'NSOperationQueue.addOperation:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_addOperation_, + op.ref.pointer, + ); } - late final _nearbyintfPtr = - _lookup>('nearbyintf'); - late final _nearbyintf = _nearbyintfPtr.asFunction(); - - double nearbyint(double arg0) { - return _nearbyint(arg0); + /// addOperationWithBlock: + void addOperationWithBlock(objc.ObjCBlock block) { + objc.checkOsVersionInternal( + 'NSOperationQueue.addOperationWithBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_addOperationWithBlock_, + block.ref.pointer, + ); } - late final _nearbyintPtr = - _lookup>('nearbyint'); - late final _nearbyint = _nearbyintPtr.asFunction(); - - double rintf(double arg0) { - return _rintf(arg0); + /// addOperations:waitUntilFinished: + void addOperations(objc.NSArray ops, {required bool waitUntilFinished}) { + objc.checkOsVersionInternal( + 'NSOperationQueue.addOperations:waitUntilFinished:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + _objc_msgSend_6p7ndb( + object$.ref.pointer, + _sel_addOperations_waitUntilFinished_, + ops.ref.pointer, + waitUntilFinished, + ); } - late final _rintfPtr = - _lookup>('rintf'); - late final _rintf = _rintfPtr.asFunction(); - - double rint(double arg0) { - return _rint(arg0); + /// cancelAllOperations + void cancelAllOperations() { + objc.checkOsVersionInternal( + 'NSOperationQueue.cancelAllOperations', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_cancelAllOperations); } - late final _rintPtr = - _lookup>('rint'); - late final _rint = _rintPtr.asFunction(); - - int lrintf(double arg0) { - return _lrintf(arg0); + /// init + NSOperationQueue init() { + objc.checkOsVersionInternal( + 'NSOperationQueue.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSOperationQueue.fromPointer($ret, retain: false, release: true); } - late final _lrintfPtr = - _lookup>('lrintf'); - late final _lrintf = _lrintfPtr.asFunction(); - - int lrint(double arg0) { - return _lrint(arg0); + /// isSuspended + bool get isSuspended { + objc.checkOsVersionInternal( + 'NSOperationQueue.isSuspended', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + return _objc_msgSend_91o635(object$.ref.pointer, _sel_isSuspended); } - late final _lrintPtr = - _lookup>('lrint'); - late final _lrint = _lrintPtr.asFunction(); - - double roundf(double arg0) { - return _roundf(arg0); + /// maxConcurrentOperationCount + int get maxConcurrentOperationCount { + objc.checkOsVersionInternal( + 'NSOperationQueue.maxConcurrentOperationCount', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + return _objc_msgSend_1hz7y9r( + object$.ref.pointer, + _sel_maxConcurrentOperationCount, + ); } - late final _roundfPtr = - _lookup>('roundf'); - late final _roundf = _roundfPtr.asFunction(); - - double round(double arg0) { - return _round(arg0); + /// name + objc.NSString? get name { + objc.checkOsVersionInternal( + 'NSOperationQueue.name', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_name); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _roundPtr = - _lookup>('round'); - late final _round = _roundPtr.asFunction(); - - int lroundf(double arg0) { - return _lroundf(arg0); + /// progress + objc.NSProgress get progress { + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_progress); + return objc.NSProgress.fromPointer($ret, retain: true, release: true); } - late final _lroundfPtr = - _lookup>('lroundf'); - late final _lroundf = _lroundfPtr.asFunction(); - - int lround(double arg0) { - return _lround(arg0); + /// qualityOfService + objc.NSQualityOfService get qualityOfService { + objc.checkOsVersionInternal( + 'NSOperationQueue.qualityOfService', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + final $ret = _objc_msgSend_oi8iq9( + object$.ref.pointer, + _sel_qualityOfService, + ); + return objc.NSQualityOfService.fromValue($ret); } - late final _lroundPtr = - _lookup>('lround'); - late final _lround = _lroundPtr.asFunction(); - - int llrintf(double arg0) { - return _llrintf(arg0); + /// setMaxConcurrentOperationCount: + set maxConcurrentOperationCount(int value) { + objc.checkOsVersionInternal( + 'NSOperationQueue.setMaxConcurrentOperationCount:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_4sp4xj( + object$.ref.pointer, + _sel_setMaxConcurrentOperationCount_, + value, + ); } - late final _llrintfPtr = - _lookup>('llrintf'); - late final _llrintf = _llrintfPtr.asFunction(); - - int llrint(double arg0) { - return _llrint(arg0); + /// setName: + set name(objc.NSString? value) { + objc.checkOsVersionInternal( + 'NSOperationQueue.setName:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setName_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _llrintPtr = - _lookup>('llrint'); - late final _llrint = _llrintPtr.asFunction(); - - int llroundf(double arg0) { - return _llroundf(arg0); + /// setQualityOfService: + set qualityOfService(objc.NSQualityOfService value) { + objc.checkOsVersionInternal( + 'NSOperationQueue.setQualityOfService:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_n2da1l( + object$.ref.pointer, + _sel_setQualityOfService_, + value.value, + ); } - late final _llroundfPtr = - _lookup>('llroundf'); - late final _llroundf = _llroundfPtr.asFunction(); - - int llround(double arg0) { - return _llround(arg0); + /// setSuspended: + set isSuspended(bool value) { + objc.checkOsVersionInternal( + 'NSOperationQueue.setSuspended:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1s56lr9(object$.ref.pointer, _sel_setSuspended_, value); } - late final _llroundPtr = - _lookup>('llround'); - late final _llround = _llroundPtr.asFunction(); - - double truncf(double arg0) { - return _truncf(arg0); + /// actually retain + set underlyingQueue(objc.NSObject? value) { + objc.checkOsVersionInternal( + 'NSOperationQueue.setUnderlyingQueue:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setUnderlyingQueue_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _truncfPtr = - _lookup>('truncf'); - late final _truncf = _truncfPtr.asFunction(); - - double trunc(double arg0) { - return _trunc(arg0); + /// actually retain + objc.NSObject? get underlyingQueue { + objc.checkOsVersionInternal( + 'NSOperationQueue.underlyingQueue', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_underlyingQueue, + ); + return $ret.address == 0 + ? null + : objc.NSObject.fromPointer($ret, retain: true, release: true); } - late final _truncPtr = - _lookup>('trunc'); - late final _trunc = _truncPtr.asFunction(); - - double fmodf(double arg0, double arg1) { - return _fmodf(arg0, arg1); + /// waitUntilAllOperationsAreFinished + void waitUntilAllOperationsAreFinished() { + objc.checkOsVersionInternal( + 'NSOperationQueue.waitUntilAllOperationsAreFinished', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv( + object$.ref.pointer, + _sel_waitUntilAllOperationsAreFinished, + ); } +} - late final _fmodfPtr = - _lookup>( - 'fmodf', - ); - late final _fmodf = _fmodfPtr.asFunction(); +late final _sel_sessionWithConfiguration_delegate_delegateQueue_ = objc + .registerName("sessionWithConfiguration:delegate:delegateQueue:"); +final _objc_msgSend_11spmsz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_delegateQueue = objc.registerName("delegateQueue"); +late final _sel_delegate = objc.registerName("delegate"); +late final _sel_configuration = objc.registerName("configuration"); +late final _sel_sessionDescription = objc.registerName("sessionDescription"); +late final _sel_setSessionDescription_ = objc.registerName( + "setSessionDescription:", +); +late final _sel_finishTasksAndInvalidate = objc.registerName( + "finishTasksAndInvalidate", +); +late final _sel_invalidateAndCancel = objc.registerName("invalidateAndCancel"); +late final _sel_resetWithCompletionHandler_ = objc.registerName( + "resetWithCompletionHandler:", +); +late final _sel_flushWithCompletionHandler_ = objc.registerName( + "flushWithCompletionHandler:", +); - double fmod(double arg0, double arg1) { - return _fmod(arg0, arg1); - } +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSArray_NSArray_NSArray { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + >(pointer, retain: retain, release: release); - late final _fmodPtr = - _lookup>( - 'fmod', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _fmod = _fmodPtr.asFunction(); - - double remainderf(double arg0, double arg1) { - return _remainderf(arg0, arg1); - } - late final _remainderfPtr = - _lookup>( - 'remainderf', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + > + fromFunction( + void Function(objc.NSArray, objc.NSArray, objc.NSArray) fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + objc.NSArray.fromPointer(arg0, retain: true, release: true), + objc.NSArray.fromPointer(arg1, retain: true, release: true), + objc.NSArray.fromPointer(arg2, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _remainderf = _remainderfPtr - .asFunction(); - - double remainder(double arg0, double arg1) { - return _remainder(arg0, arg1); - } - late final _remainderPtr = - _lookup>( - 'remainder', - ); - late final _remainder = _remainderPtr - .asFunction(); - - double remquof(double arg0, double arg1, ffi.Pointer arg2) { - return _remquof(arg0, arg1, arg2); - } - - late final _remquofPtr = - _lookup< - ffi.NativeFunction< - ffi.Float Function(ffi.Float, ffi.Float, ffi.Pointer) - > - >('remquof'); - late final _remquof = _remquofPtr - .asFunction)>(); - - double remquo(double arg0, double arg1, ffi.Pointer arg2) { - return _remquo(arg0, arg1, arg2); - } - - late final _remquoPtr = - _lookup< - ffi.NativeFunction< - ffi.Double Function(ffi.Double, ffi.Double, ffi.Pointer) - > - >('remquo'); - late final _remquo = _remquoPtr - .asFunction)>(); - - double copysignf(double arg0, double arg1) { - return _copysignf(arg0, arg1); - } - - late final _copysignfPtr = - _lookup>( - 'copysignf', - ); - late final _copysignf = _copysignfPtr - .asFunction(); - - double copysign(double arg0, double arg1) { - return _copysign(arg0, arg1); - } - - late final _copysignPtr = - _lookup>( - 'copysign', - ); - late final _copysign = _copysignPtr - .asFunction(); - - double nanf(ffi.Pointer arg0) { - return _nanf(arg0); - } - - late final _nanfPtr = - _lookup)>>( - 'nanf', - ); - late final _nanf = _nanfPtr - .asFunction)>(); - - double nan(ffi.Pointer arg0) { - return _nan(arg0); - } - - late final _nanPtr = - _lookup)>>( - 'nan', - ); - late final _nan = _nanPtr - .asFunction)>(); - - double nextafterf(double arg0, double arg1) { - return _nextafterf(arg0, arg1); - } - - late final _nextafterfPtr = - _lookup>( - 'nextafterf', - ); - late final _nextafterf = _nextafterfPtr - .asFunction(); - - double nextafter(double arg0, double arg1) { - return _nextafter(arg0, arg1); - } - - late final _nextafterPtr = - _lookup>( - 'nextafter', - ); - late final _nextafter = _nextafterPtr - .asFunction(); - - double fdimf(double arg0, double arg1) { - return _fdimf(arg0, arg1); - } - - late final _fdimfPtr = - _lookup>( - 'fdimf', - ); - late final _fdimf = _fdimfPtr.asFunction(); - - double fdim(double arg0, double arg1) { - return _fdim(arg0, arg1); - } - - late final _fdimPtr = - _lookup>( - 'fdim', - ); - late final _fdim = _fdimPtr.asFunction(); - - double fmaxf(double arg0, double arg1) { - return _fmaxf(arg0, arg1); - } - - late final _fmaxfPtr = - _lookup>( - 'fmaxf', - ); - late final _fmaxf = _fmaxfPtr.asFunction(); - - double fmax(double arg0, double arg1) { - return _fmax(arg0, arg1); - } - - late final _fmaxPtr = - _lookup>( - 'fmax', - ); - late final _fmax = _fmaxPtr.asFunction(); - - double fminf(double arg0, double arg1) { - return _fminf(arg0, arg1); - } - - late final _fminfPtr = - _lookup>( - 'fminf', - ); - late final _fminf = _fminfPtr.asFunction(); - - double fmin(double arg0, double arg1) { - return _fmin(arg0, arg1); - } - - late final _fminPtr = - _lookup>( - 'fmin', - ); - late final _fmin = _fminPtr.asFunction(); - - double fmaf(double arg0, double arg1, double arg2) { - return _fmaf(arg0, arg1, arg2); - } - - late final _fmafPtr = - _lookup< - ffi.NativeFunction - >('fmaf'); - late final _fmaf = _fmafPtr - .asFunction(); - - double fma(double arg0, double arg1, double arg2) { - return _fma(arg0, arg1, arg2); - } - - late final _fmaPtr = - _lookup< - ffi.NativeFunction< - ffi.Double Function(ffi.Double, ffi.Double, ffi.Double) - > - >('fma'); - late final _fma = _fmaPtr - .asFunction(); - - double __exp10f(double arg0) { - return ___exp10f(arg0); - } - - late final ___exp10fPtr = - _lookup>('__exp10f'); - late final ___exp10f = ___exp10fPtr.asFunction(); - - double __exp10(double arg0) { - return ___exp10(arg0); - } - - late final ___exp10Ptr = - _lookup>('__exp10'); - late final ___exp10 = ___exp10Ptr.asFunction(); - - double __cospif(double arg0) { - return ___cospif(arg0); - } - - late final ___cospifPtr = - _lookup>('__cospif'); - late final ___cospif = ___cospifPtr.asFunction(); - - double __cospi(double arg0) { - return ___cospi(arg0); - } - - late final ___cospiPtr = - _lookup>('__cospi'); - late final ___cospi = ___cospiPtr.asFunction(); - - double __sinpif(double arg0) { - return ___sinpif(arg0); - } - - late final ___sinpifPtr = - _lookup>('__sinpif'); - late final ___sinpif = ___sinpifPtr.asFunction(); - - double __sinpi(double arg0) { - return ___sinpi(arg0); - } - - late final ___sinpiPtr = - _lookup>('__sinpi'); - late final ___sinpi = ___sinpiPtr.asFunction(); - - double __tanpif(double arg0) { - return ___tanpif(arg0); - } - - late final ___tanpifPtr = - _lookup>('__tanpif'); - late final ___tanpif = ___tanpifPtr.asFunction(); - - double __tanpi(double arg0) { - return ___tanpi(arg0); - } - - late final ___tanpiPtr = - _lookup>('__tanpi'); - late final ___tanpi = ___tanpiPtr.asFunction(); - - __float2 __sincosf_stret(double arg0) { - return ___sincosf_stret(arg0); - } - - late final ___sincosf_stretPtr = - _lookup>( - '__sincosf_stret', - ); - late final ___sincosf_stret = ___sincosf_stretPtr - .asFunction<__float2 Function(double)>(); - - __double2 __sincos_stret(double arg0) { - return ___sincos_stret(arg0); - } - - late final ___sincos_stretPtr = - _lookup>( - '__sincos_stret', - ); - late final ___sincos_stret = ___sincos_stretPtr - .asFunction<__double2 Function(double)>(); - - __float2 __sincospif_stret(double arg0) { - return ___sincospif_stret(arg0); - } - - late final ___sincospif_stretPtr = - _lookup>( - '__sincospif_stret', - ); - late final ___sincospif_stret = ___sincospif_stretPtr - .asFunction<__float2 Function(double)>(); - - __double2 __sincospi_stret(double arg0) { - return ___sincospi_stret(arg0); - } - - late final ___sincospi_stretPtr = - _lookup>( - '__sincospi_stret', - ); - late final ___sincospi_stret = ___sincospi_stretPtr - .asFunction<__double2 Function(double)>(); - - double j0(double arg0) { - return _j0(arg0); - } - - late final _j0Ptr = - _lookup>('j0'); - late final _j0 = _j0Ptr.asFunction(); - - double j1(double arg0) { - return _j1(arg0); - } - - late final _j1Ptr = - _lookup>('j1'); - late final _j1 = _j1Ptr.asFunction(); - - double jn(int arg0, double arg1) { - return _jn(arg0, arg1); - } - - late final _jnPtr = - _lookup>( - 'jn', - ); - late final _jn = _jnPtr.asFunction(); - - double y0(double arg0) { - return _y0(arg0); - } - - late final _y0Ptr = - _lookup>('y0'); - late final _y0 = _y0Ptr.asFunction(); - - double y1(double arg0) { - return _y1(arg0); - } - - late final _y1Ptr = - _lookup>('y1'); - late final _y1 = _y1Ptr.asFunction(); - - double yn(int arg0, double arg1) { - return _yn(arg0, arg1); - } - - late final _ynPtr = - _lookup>( - 'yn', - ); - late final _yn = _ynPtr.asFunction(); - - double scalb(double arg0, double arg1) { - return _scalb(arg0, arg1); - } - - late final _scalbPtr = - _lookup>( - 'scalb', - ); - late final _scalb = _scalbPtr.asFunction(); - - late final ffi.Pointer _signgam = _lookup('signgam'); - - int get signgam => _signgam.value; - - set signgam(int value) => _signgam.value = value; - - int setjmp(ffi.Pointer arg0) { - return _setjmp$1(arg0); - } - - late final _setjmpPtr = - _lookup)>>( - 'setjmp', - ); - late final _setjmp$1 = _setjmpPtr - .asFunction)>(); - - void longjmp(ffi.Pointer arg0, int arg1) { - return _longjmp$1(arg0, arg1); - } - - late final _longjmpPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('longjmp'); - late final _longjmp$1 = _longjmpPtr - .asFunction, int)>(); - - int _setjmp(ffi.Pointer arg0) { - return __setjmp(arg0); - } - - late final __setjmpPtr = - _lookup)>>( - '_setjmp', - ); - late final __setjmp = __setjmpPtr - .asFunction)>(); - - void _longjmp(ffi.Pointer arg0, int arg1) { - return __longjmp(arg0, arg1); - } - - late final __longjmpPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('_longjmp'); - late final __longjmp = __longjmpPtr - .asFunction, int)>(); - - int sigsetjmp(ffi.Pointer arg0, int arg1) { - return _sigsetjmp(arg0, arg1); - } - - late final _sigsetjmpPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sigsetjmp'); - late final _sigsetjmp = _sigsetjmpPtr - .asFunction, int)>(); - - void siglongjmp(ffi.Pointer arg0, int arg1) { - return _siglongjmp(arg0, arg1); - } - - late final _siglongjmpPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('siglongjmp'); - late final _siglongjmp = _siglongjmpPtr - .asFunction, int)>(); - - void longjmperror() { - return _longjmperror(); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + > + listener( + void Function(objc.NSArray, objc.NSArray, objc.NSArray) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + objc.NSArray.fromPointer(arg0, retain: false, release: true), + objc.NSArray.fromPointer(arg1, retain: false, release: true), + objc.NSArray.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + >(wrapper, retain: false, release: true); } - late final _longjmperrorPtr = - _lookup>('longjmperror'); - late final _longjmperror = _longjmperrorPtr.asFunction(); - - late final ffi.Pointer> _sys_signame = - _lookup>('sys_signame'); - - ffi.Pointer> get sys_signame => _sys_signame; - - late final ffi.Pointer> _sys_siglist = - _lookup>('sys_siglist'); - - ffi.Pointer> get sys_siglist => _sys_siglist; - - int raise(int arg0) { - return _raise(arg0); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + > + blocking( + void Function(objc.NSArray, objc.NSArray, objc.NSArray) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + objc.NSArray.fromPointer(arg0, retain: false, release: true), + objc.NSArray.fromPointer(arg1, retain: false, release: true), + objc.NSArray.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + objc.NSArray.fromPointer(arg0, retain: false, release: true), + objc.NSArray.fromPointer(arg1, retain: false, release: true), + objc.NSArray.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + >(wrapper, retain: false, release: true); } - late final _raisePtr = _lookup>( - 'raise', - ); - late final _raise = _raisePtr.asFunction(); - - ffi.Pointer> bsd_signal( - int arg0, - ffi.Pointer> arg1, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _bsd_signal(arg0, arg1); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); } - late final _bsd_signalPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer> Function( - ffi.Int, - ffi.Pointer>, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('bsd_signal'); - late final _bsd_signal = _bsd_signalPtr - .asFunction< - ffi.Pointer> Function( - int, - ffi.Pointer>, - ) - >(); - - int kill(int arg0, int arg1) { - return _kill(arg0, arg1); - } - - late final _killPtr = - _lookup>('kill'); - late final _kill = _killPtr.asFunction(); - - int killpg(int arg0, int arg1) { - return _killpg(arg0, arg1); - } - - late final _killpgPtr = - _lookup>('killpg'); - late final _killpg = _killpgPtr.asFunction(); - - int pthread_kill(pthread_t arg0, int arg1) { - return _pthread_kill(arg0, arg1); - } - - late final _pthread_killPtr = - _lookup>( - 'pthread_kill', - ); - late final _pthread_kill = _pthread_killPtr - .asFunction(); - - int pthread_sigmask( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _pthread_sigmask(arg0, arg1, arg2); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _pthread_sigmaskPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('pthread_sigmask'); - late final _pthread_sigmask = _pthread_sigmaskPtr - .asFunction< - int Function(int, ffi.Pointer, ffi.Pointer) - >(); - - int sigaction( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - return _sigaction(arg0, arg1, arg2); - } - - late final _sigactionPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('sigaction'); - late final _sigaction = _sigactionPtr - .asFunction< - int Function(int, ffi.Pointer, ffi.Pointer) - >(); - - int sigaddset(ffi.Pointer arg0, int arg1) { - return _sigaddset(arg0, arg1); - } - - late final _sigaddsetPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sigaddset'); - late final _sigaddset = _sigaddsetPtr - .asFunction, int)>(); - - int sigaltstack(ffi.Pointer arg0, ffi.Pointer arg1) { - return _sigaltstack(arg0, arg1); - } - - late final _sigaltstackPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sigaltstack'); - late final _sigaltstack = _sigaltstackPtr - .asFunction, ffi.Pointer)>(); - - int sigdelset(ffi.Pointer arg0, int arg1) { - return _sigdelset(arg0, arg1); - } - - late final _sigdelsetPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sigdelset'); - late final _sigdelset = _sigdelsetPtr - .asFunction, int)>(); - - int sigemptyset(ffi.Pointer arg0) { - return _sigemptyset(arg0); - } - - late final _sigemptysetPtr = - _lookup)>>( - 'sigemptyset', - ); - late final _sigemptyset = _sigemptysetPtr - .asFunction)>(); - - int sigfillset(ffi.Pointer arg0) { - return _sigfillset(arg0); - } - - late final _sigfillsetPtr = - _lookup)>>( - 'sigfillset', - ); - late final _sigfillset = _sigfillsetPtr - .asFunction)>(); - - int sighold(int arg0) { - return _sighold(arg0); - } - - late final _sigholdPtr = - _lookup>('sighold'); - late final _sighold = _sigholdPtr.asFunction(); - - int sigignore(int arg0) { - return _sigignore(arg0); - } - - late final _sigignorePtr = - _lookup>('sigignore'); - late final _sigignore = _sigignorePtr.asFunction(); - - int siginterrupt(int arg0, int arg1) { - return _siginterrupt(arg0, arg1); - } - - late final _siginterruptPtr = - _lookup>( - 'siginterrupt', - ); - late final _siginterrupt = _siginterruptPtr - .asFunction(); - - int sigismember(ffi.Pointer arg0, int arg1) { - return _sigismember(arg0, arg1); - } - - late final _sigismemberPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sigismember'); - late final _sigismember = _sigismemberPtr - .asFunction, int)>(); - - int sigpause(int arg0) { - return _sigpause(arg0); - } - - late final _sigpausePtr = - _lookup>('sigpause'); - late final _sigpause = _sigpausePtr.asFunction(); - - int sigpending(ffi.Pointer arg0) { - return _sigpending(arg0); - } - - late final _sigpendingPtr = - _lookup)>>( - 'sigpending', - ); - late final _sigpending = _sigpendingPtr - .asFunction)>(); - - int sigprocmask( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - return _sigprocmask(arg0, arg1, arg2); - } - - late final _sigprocmaskPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) > - >('sigprocmask'); - late final _sigprocmask = _sigprocmaskPtr + >() .asFunction< - int Function(int, ffi.Pointer, ffi.Pointer) - >(); - - int sigrelse(int arg0) { - return _sigrelse(arg0); - } - - late final _sigrelsePtr = - _lookup>('sigrelse'); - late final _sigrelse = _sigrelsePtr.asFunction(); - - ffi.Pointer> sigset( - int arg0, - ffi.Pointer> arg1, - ) { - return _sigset(arg0, arg1); - } + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _sigsetPtr = - _lookup< +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSArray_NSArray_NSArray$CallExtension + on + objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + > { + void call(objc.NSArray arg0, objc.NSArray arg1, objc.NSArray arg2) => ref + .pointer + .ref + .invoke + .cast< ffi.NativeFunction< - ffi.Pointer> Function( - ffi.Int, - ffi.Pointer>, + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) > - >('sigset'); - late final _sigset = _sigsetPtr + >() .asFunction< - ffi.Pointer> Function( - int, - ffi.Pointer>, + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - int sigsuspend(ffi.Pointer arg0) { - return _sigsuspend(arg0); - } - - late final _sigsuspendPtr = - _lookup)>>( - 'sigsuspend', - ); - late final _sigsuspend = _sigsuspendPtr - .asFunction)>(); + >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2.ref.pointer); +} - int sigwait(ffi.Pointer arg0, ffi.Pointer arg1) { - return _sigwait(arg0, arg1); - } +late final _sel_getTasksWithCompletionHandler_ = objc.registerName( + "getTasksWithCompletionHandler:", +); - late final _sigwaitPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sigwait'); - late final _sigwait = _sigwaitPtr - .asFunction, ffi.Pointer)>(); +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSArray { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); - void psignal(int arg0, ffi.Pointer arg1) { - return _psignal(arg0, arg1); - } - - late final _psignalPtr = - _lookup< - ffi.NativeFunction)> - >('psignal'); - late final _psignal = _psignalPtr - .asFunction)>(); - - int sigblock(int arg0) { - return _sigblock(arg0); - } + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _sigblockPtr = - _lookup>('sigblock'); - late final _sigblock = _sigblockPtr.asFunction(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(objc.NSArray) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => + fn(objc.NSArray.fromPointer(arg0, retain: true, release: true)), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - int sigsetmask(int arg0) { - return _sigsetmask(arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(objc.NSArray) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSArray.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _sigsetmaskPtr = - _lookup>('sigsetmask'); - late final _sigsetmask = _sigsetmaskPtr.asFunction(); - - int sigvec(int arg0, ffi.Pointer arg1, ffi.Pointer arg2) { - return _sigvec(arg0, arg1, arg2); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(objc.NSArray) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSArray.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSArray.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _sigvecPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) - > - >('sigvec'); - late final _sigvec = _sigvecPtr - .asFunction< - int Function(int, ffi.Pointer, ffi.Pointer) - >(); - - int renameat( - int arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer arg3, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, ) { - return _renameat(arg0, arg1, arg2, arg3); + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); } - late final _renameatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, ) - > - >('renameat'); - late final _renameat = _renameatPtr - .asFunction< - int Function(int, ffi.Pointer, int, ffi.Pointer) - >(); - - int renamex_np( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, ) { - return _renamex_np(arg0, arg1, arg2); + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _renamex_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) > - >('renamex_np'); - late final _renamex_np = _renamex_npPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int renameatx_np( - int arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer arg3, - int arg4, - ) { - return _renameatx_np(arg0, arg1, arg2, arg3, arg4); - } + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _renameatx_npPtr = - _lookup< +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSArray$CallExtension + on objc.ObjCBlock { + void call(objc.NSArray arg0) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.UnsignedInt, + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, ) > - >('renameatx_np'); - late final _renameatx_np = _renameatx_npPtr + >() .asFunction< - int Function( - int, - ffi.Pointer, - int, - ffi.Pointer, - int, + void Function( + ffi.Pointer, + ffi.Pointer, ) - >(); - - int printf(ffi.Pointer arg0) { - return _printf(arg0); - } - - late final _printfPtr = - _lookup)>>( - 'printf', - ); - late final _printf = _printfPtr - .asFunction)>(); - - late final ffi.Pointer> ___stdinp = - _lookup>('__stdinp'); - - ffi.Pointer get __stdinp => ___stdinp.value; - - set __stdinp(ffi.Pointer value) => ___stdinp.value = value; - - late final ffi.Pointer> ___stdoutp = - _lookup>('__stdoutp'); - - ffi.Pointer get __stdoutp => ___stdoutp.value; - - set __stdoutp(ffi.Pointer value) => ___stdoutp.value = value; - - late final ffi.Pointer> ___stderrp = - _lookup>('__stderrp'); - - ffi.Pointer get __stderrp => ___stderrp.value; - - set __stderrp(ffi.Pointer value) => ___stderrp.value = value; - - void clearerr(ffi.Pointer arg0) { - return _clearerr(arg0); - } + >()(ref.pointer, arg0.ref.pointer); +} - late final _clearerrPtr = - _lookup)>>( - 'clearerr', - ); - late final _clearerr = _clearerrPtr - .asFunction)>(); +late final _sel_getAllTasksWithCompletionHandler_ = objc.registerName( + "getAllTasksWithCompletionHandler:", +); +late final _sel_dataTaskWithRequest_ = objc.registerName( + "dataTaskWithRequest:", +); +late final _sel_dataTaskWithURL_ = objc.registerName("dataTaskWithURL:"); - int fclose(ffi.Pointer arg0) { - return _fclose(arg0); +/// WARNING: NSURLSessionUploadTask is a stub. To generate bindings for this class, include +/// NSURLSessionUploadTask in your config's objc-interfaces list. +/// +/// An NSURLSessionUploadTask does not currently provide any additional +/// functionality over an NSURLSessionDataTask. All delegate messages +/// that may be sent referencing an NSURLSessionDataTask equally apply +/// to NSURLSessionUploadTasks. +extension type NSURLSessionUploadTask._(objc.ObjCObject object$) + implements objc.ObjCObject, NSURLSessionDataTask { + /// Constructs a [NSURLSessionUploadTask] that points to the same underlying object as [other]. + NSURLSessionUploadTask.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSessionUploadTask', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); } - late final _fclosePtr = - _lookup)>>( - 'fclose', - ); - late final _fclose = _fclosePtr.asFunction)>(); - - int feof(ffi.Pointer arg0) { - return _feof(arg0); + /// Constructs a [NSURLSessionUploadTask] that wraps the given raw object pointer. + NSURLSessionUploadTask.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionUploadTask', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); } +} - late final _feofPtr = - _lookup)>>('feof'); - late final _feof = _feofPtr.asFunction)>(); - - int ferror(ffi.Pointer arg0) { - return _ferror(arg0); - } +late final _sel_uploadTaskWithRequest_fromFile_ = objc.registerName( + "uploadTaskWithRequest:fromFile:", +); +final _objc_msgSend_15qeuct = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_uploadTaskWithRequest_fromData_ = objc.registerName( + "uploadTaskWithRequest:fromData:", +); +late final _sel_uploadTaskWithResumeData_ = objc.registerName( + "uploadTaskWithResumeData:", +); +late final _sel_uploadTaskWithStreamedRequest_ = objc.registerName( + "uploadTaskWithStreamedRequest:", +); +late final _class_NSURLSessionDownloadTask = objc.getClass( + "NSURLSessionDownloadTask", +); - late final _ferrorPtr = - _lookup)>>( - 'ferror', - ); - late final _ferror = _ferrorPtr.asFunction)>(); +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSData { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); - int fflush(ffi.Pointer arg0) { - return _fflush(arg0); - } + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _fflushPtr = - _lookup)>>( - 'fflush', - ); - late final _fflush = _fflushPtr.asFunction)>(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(objc.NSData?) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSData.fromPointer(arg0, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - int fgetc(ffi.Pointer arg0) { - return _fgetc(arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(objc.NSData?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSData.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _fgetcPtr = - _lookup)>>('fgetc'); - late final _fgetc = _fgetcPtr.asFunction)>(); - - int fgetpos(ffi.Pointer arg0, ffi.Pointer arg1) { - return _fgetpos(arg0, arg1); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(objc.NSData?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSData.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSData.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _fgetposPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('fgetpos'); - late final _fgetpos = _fgetposPtr - .asFunction, ffi.Pointer)>(); - - ffi.Pointer fgets( - ffi.Pointer arg0, - int __size, - ffi.Pointer arg2, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, ) { - return _fgets(arg0, __size, arg2); + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); } - late final _fgetsPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, ) - > - >('fgets'); - late final _fgets = _fgetsPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - ffi.Pointer fopen( - ffi.Pointer __filename, - ffi.Pointer __mode, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, ) { - return _fopen(__filename, __mode); + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _fopenPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('fopen'); - late final _fopen = _fopenPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); - - int fprintf(ffi.Pointer arg0, ffi.Pointer arg1) { - return _fprintf(arg0, arg1); - } - - late final _fprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('fprintf'); - late final _fprintf = _fprintfPtr - .asFunction, ffi.Pointer)>(); - - int fputc(int arg0, ffi.Pointer arg1) { - return _fputc(arg0, arg1); - } - - late final _fputcPtr = - _lookup)>>( - 'fputc', - ); - late final _fputc = _fputcPtr - .asFunction)>(); - - int fputs(ffi.Pointer arg0, ffi.Pointer arg1) { - return _fputs(arg0, arg1); - } - - late final _fputsPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('fputs'); - late final _fputs = _fputsPtr - .asFunction, ffi.Pointer)>(); - - int fread( - ffi.Pointer __ptr, - int __size, - int __nitems, - ffi.Pointer __stream, - ) { - return _fread(__ptr, __size, __nitems, __stream); - } - - late final _freadPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLong Function( + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer, + ffi.Pointer, ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) > - >('fread'); - late final _fread = _freadPtr - .asFunction< - int Function(ffi.Pointer, int, int, ffi.Pointer) - >(); - - ffi.Pointer freopen( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - return _freopen(arg0, arg1, arg2); - } + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _freopenPtr = - _lookup< +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSData$CallExtension + on objc.ObjCBlock { + void call(objc.NSData? arg0) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, ) > - >('freopen'); - late final _freopen = _freopenPtr + >() .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + void Function( + ffi.Pointer, + ffi.Pointer, ) - >(); - - int fscanf(ffi.Pointer arg0, ffi.Pointer arg1) { - return _fscanf(arg0, arg1); - } - - late final _fscanfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('fscanf'); - late final _fscanf = _fscanfPtr - .asFunction, ffi.Pointer)>(); - - int fseek(ffi.Pointer arg0, int arg1, int arg2) { - return _fseek(arg0, arg1, arg2); - } - - late final _fseekPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Long, ffi.Int) - > - >('fseek'); - late final _fseek = _fseekPtr - .asFunction, int, int)>(); - - int fsetpos(ffi.Pointer arg0, ffi.Pointer arg1) { - return _fsetpos(arg0, arg1); - } - - late final _fsetposPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('fsetpos'); - late final _fsetpos = _fsetposPtr - .asFunction, ffi.Pointer)>(); - - int ftell(ffi.Pointer arg0) { - return _ftell(arg0); - } - - late final _ftellPtr = - _lookup)>>( - 'ftell', - ); - late final _ftell = _ftellPtr.asFunction)>(); - - int fwrite( - ffi.Pointer __ptr, - int __size, - int __nitems, - ffi.Pointer __stream, - ) { - return _fwrite(__ptr, __size, __nitems, __stream); - } + >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); +} - late final _fwritePtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Size, - ffi.Size, - ffi.Pointer, - ) - > - >('fwrite'); - late final _fwrite = _fwritePtr - .asFunction< - int Function(ffi.Pointer, int, int, ffi.Pointer) - >(); +late final _sel_cancelByProducingResumeData_ = objc.registerName( + "cancelByProducingResumeData:", +); +late final _class_NSURLSessionTask = objc.getClass("NSURLSessionTask"); +late final _sel_taskIdentifier = objc.registerName("taskIdentifier"); +late final _sel_originalRequest = objc.registerName("originalRequest"); +late final _sel_currentRequest = objc.registerName("currentRequest"); +late final _class_NSURLResponse = objc.getClass("NSURLResponse"); +late final _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_ = + objc.registerName( + "initWithURL:MIMEType:expectedContentLength:textEncodingName:", + ); +final _objc_msgSend_l9ppnx = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ) + >(); +late final _sel_MIMEType = objc.registerName("MIMEType"); +late final _sel_expectedContentLength = objc.registerName( + "expectedContentLength", +); +final _objc_msgSend_1k101e3 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.LongLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_textEncodingName = objc.registerName("textEncodingName"); +late final _sel_suggestedFilename = objc.registerName("suggestedFilename"); - int getc(ffi.Pointer arg0) { - return _getc(arg0); +/// NSURLResponse +extension type NSURLResponse._(objc.ObjCObject object$) + implements + objc.ObjCObject, + objc.NSObject, + objc.NSSecureCoding, + objc.NSCopying { + /// Constructs a [NSURLResponse] that points to the same underlying object as [other]. + NSURLResponse.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); } - late final _getcPtr = - _lookup)>>('getc'); - late final _getc = _getcPtr.asFunction)>(); - - int getchar() { - return _getchar(); + /// Constructs a [NSURLResponse] that wraps the given raw object pointer. + NSURLResponse.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); } - late final _getcharPtr = _lookup>( - 'getchar', + /// Returns whether [obj] is an instance of [NSURLResponse]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLResponse, ); - late final _getchar = _getcharPtr.asFunction(); - - ffi.Pointer gets(ffi.Pointer arg0) { - return _gets(arg0); - } - late final _getsPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('gets'); - late final _gets = _getsPtr - .asFunction Function(ffi.Pointer)>(); - - void perror(ffi.Pointer arg0) { - return _perror(arg0); + /// alloc + static NSURLResponse alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSURLResponse, _sel_alloc); + return NSURLResponse.fromPointer($ret, retain: false, release: true); } - late final _perrorPtr = - _lookup)>>( - 'perror', - ); - late final _perror = _perrorPtr - .asFunction)>(); - - int putc(int arg0, ffi.Pointer arg1) { - return _putc(arg0, arg1); + /// allocWithZone: + static NSURLResponse allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLResponse, + _sel_allocWithZone_, + zone, + ); + return NSURLResponse.fromPointer($ret, retain: false, release: true); } - late final _putcPtr = - _lookup)>>( - 'putc', - ); - late final _putc = _putcPtr - .asFunction)>(); - - int putchar(int arg0) { - return _putchar(arg0); + /// new + static NSURLResponse new$() { + final $ret = _objc_msgSend_151sglz(_class_NSURLResponse, _sel_new); + return NSURLResponse.fromPointer($ret, retain: false, release: true); } - late final _putcharPtr = - _lookup>('putchar'); - late final _putchar = _putcharPtr.asFunction(); - - int puts(ffi.Pointer arg0) { - return _puts(arg0); + /// supportsSecureCoding + static bool getSupportsSecureCoding() { + return _objc_msgSend_91o635( + _class_NSURLResponse, + _sel_supportsSecureCoding, + ); } - late final _putsPtr = - _lookup)>>( - 'puts', - ); - late final _puts = _putsPtr.asFunction)>(); + /// Returns a new instance of NSURLResponse constructed with the default `new` method. + NSURLResponse() : this.as(new$().object$); +} - int remove(ffi.Pointer arg0) { - return _remove(arg0); +extension NSURLResponse$Methods on NSURLResponse { + /// ! + /// @abstract Returns the MIME type of the receiver. + /// @discussion The MIME type is based on the information provided + /// from an origin source. However, that value may be changed or + /// corrected by a protocol implementation if it can be determined + /// that the origin server or source reported the information + /// incorrectly or imprecisely. An attempt to guess the MIME type may + /// be made if the origin source did not report any such information. + /// @result The MIME type of the receiver. + objc.NSString? get MIMEType { + objc.checkOsVersionInternal( + 'NSURLResponse.MIMEType', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_MIMEType); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _removePtr = - _lookup)>>( - 'remove', - ); - late final _remove = _removePtr - .asFunction)>(); - - int rename(ffi.Pointer __old, ffi.Pointer __new) { - return _rename(__old, __new); + /// ! + /// @abstract Returns the URL of the receiver. + /// @result The URL of the receiver. + objc.NSURL? get URL { + objc.checkOsVersionInternal( + 'NSURLResponse.URL', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URL); + return $ret.address == 0 + ? null + : objc.NSURL.fromPointer($ret, retain: true, release: true); } - late final _renamePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('rename'); - late final _rename = _renamePtr - .asFunction, ffi.Pointer)>(); - - void rewind(ffi.Pointer arg0) { - return _rewind(arg0); + /// encodeWithCoder: + void encodeWithCoder(objc.NSCoder coder) { + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_encodeWithCoder_, + coder.ref.pointer, + ); } - late final _rewindPtr = - _lookup)>>( - 'rewind', - ); - late final _rewind = _rewindPtr - .asFunction)>(); - - int scanf(ffi.Pointer arg0) { - return _scanf(arg0); + /// ! + /// @abstract Returns the expected content length of the receiver. + /// @discussion Some protocol implementations report a content length + /// as part of delivering load metadata, but not all protocols + /// guarantee the amount of data that will be delivered in actuality. + /// Hence, this method returns an expected amount. Clients should use + /// this value as an advisory, and should be prepared to deal with + /// either more or less data. + /// @result The expected content length of the receiver, or -1 if + /// there is no expectation that can be arrived at regarding expected + /// content length. + int get expectedContentLength { + objc.checkOsVersionInternal( + 'NSURLResponse.expectedContentLength', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_1k101e3( + object$.ref.pointer, + _sel_expectedContentLength, + ); } - late final _scanfPtr = - _lookup)>>( - 'scanf', - ); - late final _scanf = _scanfPtr - .asFunction)>(); - - void setbuf(ffi.Pointer arg0, ffi.Pointer arg1) { - return _setbuf(arg0, arg1); + /// init + NSURLResponse init() { + objc.checkOsVersionInternal( + 'NSURLResponse.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLResponse.fromPointer($ret, retain: false, release: true); } - late final _setbufPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - >('setbuf'); - late final _setbuf = _setbufPtr - .asFunction, ffi.Pointer)>(); - - int setvbuf( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - int __size, - ) { - return _setvbuf(arg0, arg1, arg2, __size); + /// initWithCoder: + NSURLResponse? initWithCoder(objc.NSCoder coder) { + final $ret = _objc_msgSend_1sotr3r( + object$.ref.retainAndReturnPointer(), + _sel_initWithCoder_, + coder.ref.pointer, + ); + return $ret.address == 0 + ? null + : NSURLResponse.fromPointer($ret, retain: false, release: true); } - late final _setvbufPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Size, - ) - > - >('setvbuf'); - late final _setvbuf = _setvbufPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, int) - >(); - - int sprintf(ffi.Pointer arg0, ffi.Pointer arg1) { - return _sprintf(arg0, arg1); + /// ! + /// @method initWithURL:MIMEType:expectedContentLength:textEncodingName: + /// @abstract Initialize an NSURLResponse with the provided values. + /// @param URL the URL + /// @param MIMEType the MIME content type of the response + /// @param length the expected content length of the associated data + /// @param name the name of the text encoding for the associated data, if applicable, else nil + /// @result The initialized NSURLResponse. + /// @discussion This is the designated initializer for NSURLResponse. + NSURLResponse initWithUrlAndMIMEType( + objc.NSURL URL, { + objc.NSString? MIMEType, + required int length, + objc.NSString? name, + }) { + objc.checkOsVersionInternal( + 'NSURLResponse.initWithURL:MIMEType:expectedContentLength:textEncodingName:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_l9ppnx( + object$.ref.retainAndReturnPointer(), + _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_, + URL.ref.pointer, + MIMEType?.ref.pointer ?? ffi.nullptr, + length, + name?.ref.pointer ?? ffi.nullptr, + ); + return NSURLResponse.fromPointer($ret, retain: false, release: true); } - late final _sprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sprintf'); - late final _sprintf = _sprintfPtr - .asFunction, ffi.Pointer)>(); - - int sscanf(ffi.Pointer arg0, ffi.Pointer arg1) { - return _sscanf(arg0, arg1); + /// ! + /// @abstract Returns a suggested filename if the resource were saved to disk. + /// @discussion The method first checks if the server has specified a filename using the + /// content disposition header. If no valid filename is specified using that mechanism, + /// this method checks the last path component of the URL. If no valid filename can be + /// obtained using the last path component, this method uses the URL's host as the filename. + /// If the URL's host can't be converted to a valid filename, the filename "unknown" is used. + /// In most cases, this method appends the proper file extension based on the MIME type. + /// This method always returns a valid filename. + /// @result A suggested filename to use if saving the resource to disk. + objc.NSString? get suggestedFilename { + objc.checkOsVersionInternal( + 'NSURLResponse.suggestedFilename', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_suggestedFilename, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _sscanfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sscanf'); - late final _sscanf = _sscanfPtr - .asFunction, ffi.Pointer)>(); - - ffi.Pointer tmpfile() { - return _tmpfile(); + /// ! + /// @abstract Returns the name of the text encoding of the receiver. + /// @discussion This name will be the actual string reported by the + /// origin source during the course of performing a protocol-specific + /// URL load. Clients can inspect this string and convert it to an + /// NSStringEncoding or CFStringEncoding using the methods and + /// functions made available in the appropriate framework. + /// @result The name of the text encoding of the receiver, or nil if no + /// text encoding was specified. + objc.NSString? get textEncodingName { + objc.checkOsVersionInternal( + 'NSURLResponse.textEncodingName', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_textEncodingName, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } +} - late final _tmpfilePtr = - _lookup Function()>>('tmpfile'); - late final _tmpfile = _tmpfilePtr.asFunction Function()>(); - - ffi.Pointer tmpnam(ffi.Pointer arg0) { - return _tmpnam(arg0); - } +late final _sel_response = objc.registerName("response"); - late final _tmpnamPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('tmpnam'); - late final _tmpnam = _tmpnamPtr - .asFunction Function(ffi.Pointer)>(); +/// WARNING: NSURLSessionTaskDelegate is a stub. To generate bindings for this class, include +/// NSURLSessionTaskDelegate in your config's objc-protocols list. +/// +/// Messages related to the operation of a specific task. +extension type NSURLSessionTaskDelegate._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol, NSURLSessionDelegate { + /// Constructs a [NSURLSessionTaskDelegate] that points to the same underlying object as [other]. + NSURLSessionTaskDelegate.as(objc.ObjCObject other) : object$ = other; - int ungetc(int arg0, ffi.Pointer arg1) { - return _ungetc(arg0, arg1); - } + /// Constructs a [NSURLSessionTaskDelegate] that wraps the given raw object pointer. + NSURLSessionTaskDelegate.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); +} - late final _ungetcPtr = - _lookup)>>( - 'ungetc', - ); - late final _ungetc = _ungetcPtr - .asFunction)>(); +late final _sel_setDelegate_ = objc.registerName("setDelegate:"); +late final _sel_earliestBeginDate = objc.registerName("earliestBeginDate"); +late final _sel_setEarliestBeginDate_ = objc.registerName( + "setEarliestBeginDate:", +); +late final _sel_countOfBytesClientExpectsToSend = objc.registerName( + "countOfBytesClientExpectsToSend", +); +final _objc_msgSend_pysgoz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setCountOfBytesClientExpectsToSend_ = objc.registerName( + "setCountOfBytesClientExpectsToSend:", +); +final _objc_msgSend_17gvxvj = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +late final _sel_countOfBytesClientExpectsToReceive = objc.registerName( + "countOfBytesClientExpectsToReceive", +); +late final _sel_setCountOfBytesClientExpectsToReceive_ = objc.registerName( + "setCountOfBytesClientExpectsToReceive:", +); +late final _sel_countOfBytesSent = objc.registerName("countOfBytesSent"); +late final _sel_countOfBytesReceived = objc.registerName( + "countOfBytesReceived", +); +late final _sel_countOfBytesExpectedToSend = objc.registerName( + "countOfBytesExpectedToSend", +); +late final _sel_countOfBytesExpectedToReceive = objc.registerName( + "countOfBytesExpectedToReceive", +); +late final _sel_taskDescription = objc.registerName("taskDescription"); +late final _sel_setTaskDescription_ = objc.registerName("setTaskDescription:"); +late final _sel_cancel = objc.registerName("cancel"); - int vfprintf( - ffi.Pointer arg0, - ffi.Pointer arg1, - va_list arg2, - ) { - return _vfprintf(arg0, arg1, arg2); - } +enum NSURLSessionTaskState { + /// The task is currently being serviced by the session + NSURLSessionTaskStateRunning(0), + NSURLSessionTaskStateSuspended(1), - late final _vfprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, va_list) - > - >('vfprintf'); - late final _vfprintf = _vfprintfPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list) - >(); + /// The task has been told to cancel. The session will receive a URLSession:task:didCompleteWithError: message. + NSURLSessionTaskStateCanceling(2), - int vprintf(ffi.Pointer arg0, va_list arg1) { - return _vprintf(arg0, arg1); - } + /// The task has completed and the session will receive no more delegate notifications + NSURLSessionTaskStateCompleted(3); - late final _vprintfPtr = - _lookup< - ffi.NativeFunction, va_list)> - >('vprintf'); - late final _vprintf = _vprintfPtr - .asFunction, va_list)>(); + final int value; + const NSURLSessionTaskState(this.value); - int vsprintf( - ffi.Pointer arg0, - ffi.Pointer arg1, - va_list arg2, - ) { - return _vsprintf(arg0, arg1, arg2); - } + static NSURLSessionTaskState fromValue(int value) => switch (value) { + 0 => NSURLSessionTaskStateRunning, + 1 => NSURLSessionTaskStateSuspended, + 2 => NSURLSessionTaskStateCanceling, + 3 => NSURLSessionTaskStateCompleted, + _ => throw ArgumentError('Unknown value for NSURLSessionTaskState: $value'), + }; +} - late final _vsprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - va_list, - ) - > - >('vsprintf'); - late final _vsprintf = _vsprintfPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list) - >(); +late final _sel_state = objc.registerName("state"); +final _objc_msgSend_1vze0g9 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_error = objc.registerName("error"); +late final _sel_suspend = objc.registerName("suspend"); +late final _sel_resume = objc.registerName("resume"); +late final _sel_priority = objc.registerName("priority"); +final _objc_msgSend_2cgrxl = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Float Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + double Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_2cgrxlFpret = objc.msgSendFpretPointer + .cast< + ffi.NativeFunction< + ffi.Float Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + double Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_setPriority_ = objc.registerName("setPriority:"); +final _objc_msgSend_v5hmet = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Float, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + double, + ) + >(); +late final _sel_prefersIncrementalDelivery = objc.registerName( + "prefersIncrementalDelivery", +); +late final _sel_setPrefersIncrementalDelivery_ = objc.registerName( + "setPrefersIncrementalDelivery:", +); - ffi.Pointer ctermid(ffi.Pointer arg0) { - return _ctermid(arg0); +/// NSURLSessionTask - a cancelable object that refers to the lifetime +/// of processing a given request. +extension type NSURLSessionTask._(objc.ObjCObject object$) + implements + objc.ObjCObject, + objc.NSObject, + objc.NSCopying, + NSProgressReporting { + /// Constructs a [NSURLSessionTask] that points to the same underlying object as [other]. + NSURLSessionTask.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSessionTask', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + assert(isA(object$)); } - late final _ctermidPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('ctermid'); - late final _ctermid = _ctermidPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer fdopen(int arg0, ffi.Pointer arg1) { - return _fdopen(arg0, arg1); + /// Constructs a [NSURLSessionTask] that wraps the given raw object pointer. + NSURLSessionTask.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionTask', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + assert(isA(object$)); } - late final _fdopenPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Int, ffi.Pointer) - > - >('fdopen'); - late final _fdopen = _fdopenPtr - .asFunction Function(int, ffi.Pointer)>(); + /// Returns whether [obj] is an instance of [NSURLSessionTask]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionTask, + ); - int fileno(ffi.Pointer arg0) { - return _fileno(arg0); + /// alloc + static NSURLSessionTask alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSURLSessionTask, _sel_alloc); + return NSURLSessionTask.fromPointer($ret, retain: false, release: true); } - late final _filenoPtr = - _lookup)>>( - 'fileno', - ); - late final _fileno = _filenoPtr.asFunction)>(); - - int pclose(ffi.Pointer arg0) { - return _pclose(arg0); + /// allocWithZone: + static NSURLSessionTask allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSessionTask, + _sel_allocWithZone_, + zone, + ); + return NSURLSessionTask.fromPointer($ret, retain: false, release: true); } - late final _pclosePtr = - _lookup)>>( - 'pclose', - ); - late final _pclose = _pclosePtr.asFunction)>(); - - ffi.Pointer popen( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _popen(arg0, arg1); + /// new + static NSURLSessionTask new$() { + final $ret = _objc_msgSend_151sglz(_class_NSURLSessionTask, _sel_new); + return NSURLSessionTask.fromPointer($ret, retain: false, release: true); } - late final _popenPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('popen'); - late final _popen = _popenPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + /// Returns a new instance of NSURLSessionTask constructed with the default `new` method. + NSURLSessionTask() : this.as(new$().object$); +} - int __srget(ffi.Pointer arg0) { - return ___srget(arg0); +extension NSURLSessionTask$Methods on NSURLSessionTask { + /// -cancel returns immediately, but marks a task as being canceled. + /// The task will signal -URLSession:task:didCompleteWithError: with an + /// error value of { NSURLErrorDomain, NSURLErrorCancelled }. In some + /// cases, the task may signal other work before it acknowledges the + /// cancelation. -cancel may be sent to a task that has been suspended. + void cancel() { + objc.checkOsVersionInternal( + 'NSURLSessionTask.cancel', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_cancel); } - late final ___srgetPtr = - _lookup)>>( - '__srget', - ); - late final ___srget = ___srgetPtr - .asFunction)>(); - - int __svfscanf( - ffi.Pointer arg0, - ffi.Pointer arg1, - va_list arg2, - ) { - return ___svfscanf(arg0, arg1, arg2); + /// countOfBytesClientExpectsToReceive + int get countOfBytesClientExpectsToReceive { + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesClientExpectsToReceive', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + return _objc_msgSend_pysgoz( + object$.ref.pointer, + _sel_countOfBytesClientExpectsToReceive, + ); } - late final ___svfscanfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, va_list) - > - >('__svfscanf'); - late final ___svfscanf = ___svfscanfPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list) - >(); - - int __swbuf(int arg0, ffi.Pointer arg1) { - return ___swbuf(arg0, arg1); + /// The number of bytes that the client expects (a best-guess upper-bound) will + /// be sent and received by this task. These values are used by system scheduling + /// policy. If unspecified, NSURLSessionTransferSizeUnknown is used. + int get countOfBytesClientExpectsToSend { + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesClientExpectsToSend', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + return _objc_msgSend_pysgoz( + object$.ref.pointer, + _sel_countOfBytesClientExpectsToSend, + ); } - late final ___swbufPtr = - _lookup)>>( - '__swbuf', - ); - late final ___swbuf = ___swbufPtr - .asFunction)>(); - - void flockfile(ffi.Pointer arg0) { - return _flockfile(arg0); + /// number of byte bytes we expect to receive, usually derived from the Content-Length header of an HTTP response. + int get countOfBytesExpectedToReceive { + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesExpectedToReceive', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_pysgoz( + object$.ref.pointer, + _sel_countOfBytesExpectedToReceive, + ); } - late final _flockfilePtr = - _lookup)>>( - 'flockfile', - ); - late final _flockfile = _flockfilePtr - .asFunction)>(); - - int ftrylockfile(ffi.Pointer arg0) { - return _ftrylockfile(arg0); + /// number of body bytes we expect to send, derived from the Content-Length of the HTTP request + int get countOfBytesExpectedToSend { + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesExpectedToSend', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_pysgoz( + object$.ref.pointer, + _sel_countOfBytesExpectedToSend, + ); } - late final _ftrylockfilePtr = - _lookup)>>( - 'ftrylockfile', - ); - late final _ftrylockfile = _ftrylockfilePtr - .asFunction)>(); - - void funlockfile(ffi.Pointer arg0) { - return _funlockfile(arg0); + /// number of body bytes already received + int get countOfBytesReceived { + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesReceived', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_pysgoz(object$.ref.pointer, _sel_countOfBytesReceived); } - late final _funlockfilePtr = - _lookup)>>( - 'funlockfile', - ); - late final _funlockfile = _funlockfilePtr - .asFunction)>(); - - int getc_unlocked(ffi.Pointer arg0) { - return _getc_unlocked(arg0); + /// number of body bytes already sent + int get countOfBytesSent { + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesSent', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_pysgoz(object$.ref.pointer, _sel_countOfBytesSent); } - late final _getc_unlockedPtr = - _lookup)>>( - 'getc_unlocked', - ); - late final _getc_unlocked = _getc_unlockedPtr - .asFunction)>(); - - int getchar_unlocked() { - return _getchar_unlocked(); + /// may differ from originalRequest due to http server redirection + NSURLRequest? get currentRequest { + objc.checkOsVersionInternal( + 'NSURLSessionTask.currentRequest', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_currentRequest, + ); + return $ret.address == 0 + ? null + : NSURLRequest.fromPointer($ret, retain: true, release: true); } - late final _getchar_unlockedPtr = - _lookup>('getchar_unlocked'); - late final _getchar_unlocked = _getchar_unlockedPtr - .asFunction(); - - int putc_unlocked(int arg0, ffi.Pointer arg1) { - return _putc_unlocked(arg0, arg1); + /// Sets a task-specific delegate. Methods not implemented on this delegate will + /// still be forwarded to the session delegate. + /// + /// Cannot be modified after task resumes. Not supported on background session. + /// + /// Delegate is strongly referenced until the task completes, after which it is + /// reset to `nil`. + NSURLSessionTaskDelegate? get delegate { + objc.checkOsVersionInternal( + 'NSURLSessionTask.delegate', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_delegate); + return $ret.address == 0 + ? null + : NSURLSessionTaskDelegate.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _putc_unlockedPtr = - _lookup)>>( - 'putc_unlocked', - ); - late final _putc_unlocked = _putc_unlockedPtr - .asFunction)>(); - - int putchar_unlocked(int arg0) { - return _putchar_unlocked(arg0); + /// Start the network load for this task no earlier than the specified date. If + /// not specified, no start delay is used. + /// + /// Only applies to tasks created from background NSURLSession instances; has no + /// effect for tasks created from other session types. + objc.NSDate? get earliestBeginDate { + objc.checkOsVersionInternal( + 'NSURLSessionTask.earliestBeginDate', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_earliestBeginDate, + ); + return $ret.address == 0 + ? null + : objc.NSDate.fromPointer($ret, retain: true, release: true); } - late final _putchar_unlockedPtr = - _lookup>( - 'putchar_unlocked', - ); - late final _putchar_unlocked = _putchar_unlockedPtr - .asFunction(); - - int getw(ffi.Pointer arg0) { - return _getw(arg0); + /// The error, if any, delivered via -URLSession:task:didCompleteWithError: + /// This property will be nil in the event that no error occurred. + objc.NSError? get error { + objc.checkOsVersionInternal( + 'NSURLSessionTask.error', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_error); + return $ret.address == 0 + ? null + : objc.NSError.fromPointer($ret, retain: true, release: true); } - late final _getwPtr = - _lookup)>>('getw'); - late final _getw = _getwPtr.asFunction)>(); - - int putw(int arg0, ffi.Pointer arg1) { - return _putw(arg0, arg1); + /// init + NSURLSessionTask init() { + objc.checkOsVersionInternal( + 'NSURLSessionTask.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLSessionTask.fromPointer($ret, retain: false, release: true); } - late final _putwPtr = - _lookup)>>( - 'putw', - ); - late final _putw = _putwPtr - .asFunction)>(); - - ffi.Pointer tempnam( - ffi.Pointer __dir, - ffi.Pointer __prefix, - ) { - return _tempnam(__dir, __prefix); + /// may be nil if this is a stream task + NSURLRequest? get originalRequest { + objc.checkOsVersionInternal( + 'NSURLSessionTask.originalRequest', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_originalRequest, + ); + return $ret.address == 0 + ? null + : NSURLRequest.fromPointer($ret, retain: true, release: true); } - late final _tempnamPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('tempnam'); - late final _tempnam = _tempnamPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int fseeko(ffi.Pointer __stream, int __offset, int __whence) { - return _fseeko(__stream, __offset, __whence); + /// Provides a hint indicating if incremental delivery of a partial response body + /// would be useful for the application, or if it cannot process the response + /// until it is complete. Indicating that incremental delivery is not desired may + /// improve task performance. For example, if a response cannot be decoded until + /// the entire content is received, set this property to false. + /// + /// Defaults to true unless this task is created with completion-handler based + /// convenience methods, or if it is a download task. + bool get prefersIncrementalDelivery { + objc.checkOsVersionInternal( + 'NSURLSessionTask.prefersIncrementalDelivery', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), + ); + return _objc_msgSend_91o635( + object$.ref.pointer, + _sel_prefersIncrementalDelivery, + ); } - late final _fseekoPtr = - _lookup< - ffi.NativeFunction, off_t, ffi.Int)> - >('fseeko'); - late final _fseeko = _fseekoPtr - .asFunction, int, int)>(); - - int ftello(ffi.Pointer __stream) { - return _ftello(__stream); + /// Sets a scaling factor for the priority of the task. The scaling factor is a + /// value between 0.0 and 1.0 (inclusive), where 0.0 is considered the lowest + /// priority and 1.0 is considered the highest. + /// + /// The priority is a hint and not a hard requirement of task performance. The + /// priority of a task may be changed using this API at any time, but not all + /// protocols support this; in these cases, the last priority that took effect + /// will be used. + /// + /// If no priority is specified, the task will operate with the default priority + /// as defined by the constant NSURLSessionTaskPriorityDefault. Two additional + /// priority levels are provided: NSURLSessionTaskPriorityLow and + /// NSURLSessionTaskPriorityHigh, but use is not restricted to these. + double get priority { + objc.checkOsVersionInternal( + 'NSURLSessionTask.priority', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + return objc.useMsgSendVariants + ? _objc_msgSend_2cgrxlFpret(object$.ref.pointer, _sel_priority) + : _objc_msgSend_2cgrxl(object$.ref.pointer, _sel_priority); } - late final _ftelloPtr = - _lookup)>>('ftello'); - late final _ftello = _ftelloPtr.asFunction)>(); - - int snprintf( - ffi.Pointer __str, - int __size, - ffi.Pointer __format, - ) { - return _snprintf(__str, __size, __format); + /// progress + objc.NSProgress get progress { + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_progress); + return objc.NSProgress.fromPointer($ret, retain: true, release: true); } - late final _snprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ) - > - >('snprintf'); - late final _snprintf = _snprintfPtr - .asFunction< - int Function(ffi.Pointer, int, ffi.Pointer) - >(); - - int vfscanf( - ffi.Pointer __stream, - ffi.Pointer __format, - va_list arg2, - ) { - return _vfscanf(__stream, __format, arg2); + /// may be nil if no response has been received + NSURLResponse? get response { + objc.checkOsVersionInternal( + 'NSURLSessionTask.response', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_response); + return $ret.address == 0 + ? null + : NSURLResponse.fromPointer($ret, retain: true, release: true); } - late final _vfscanfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, va_list) - > - >('vfscanf'); - late final _vfscanf = _vfscanfPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list) - >(); - - int vscanf(ffi.Pointer __format, va_list arg1) { - return _vscanf(__format, arg1); + /// resume + void resume() { + objc.checkOsVersionInternal( + 'NSURLSessionTask.resume', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_resume); } - late final _vscanfPtr = - _lookup< - ffi.NativeFunction, va_list)> - >('vscanf'); - late final _vscanf = _vscanfPtr - .asFunction, va_list)>(); - - int vsnprintf( - ffi.Pointer __str, - int __size, - ffi.Pointer __format, - va_list arg3, - ) { - return _vsnprintf(__str, __size, __format, arg3); + /// setCountOfBytesClientExpectsToReceive: + set countOfBytesClientExpectsToReceive(int value) { + objc.checkOsVersionInternal( + 'NSURLSessionTask.setCountOfBytesClientExpectsToReceive:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + _objc_msgSend_17gvxvj( + object$.ref.pointer, + _sel_setCountOfBytesClientExpectsToReceive_, + value, + ); } - late final _vsnprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - va_list, - ) - > - >('vsnprintf'); - late final _vsnprintf = _vsnprintfPtr - .asFunction< - int Function(ffi.Pointer, int, ffi.Pointer, va_list) - >(); - - int vsscanf( - ffi.Pointer __str, - ffi.Pointer __format, - va_list arg2, - ) { - return _vsscanf(__str, __format, arg2); + /// The number of bytes that the client expects (a best-guess upper-bound) will + /// be sent and received by this task. These values are used by system scheduling + /// policy. If unspecified, NSURLSessionTransferSizeUnknown is used. + set countOfBytesClientExpectsToSend(int value) { + objc.checkOsVersionInternal( + 'NSURLSessionTask.setCountOfBytesClientExpectsToSend:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + _objc_msgSend_17gvxvj( + object$.ref.pointer, + _sel_setCountOfBytesClientExpectsToSend_, + value, + ); } - late final _vsscanfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - va_list, - ) - > - >('vsscanf'); - late final _vsscanf = _vsscanfPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list) - >(); - - int dprintf(int arg0, ffi.Pointer arg1) { - return _dprintf(arg0, arg1); + /// Sets a task-specific delegate. Methods not implemented on this delegate will + /// still be forwarded to the session delegate. + /// + /// Cannot be modified after task resumes. Not supported on background session. + /// + /// Delegate is strongly referenced until the task completes, after which it is + /// reset to `nil`. + set delegate(NSURLSessionTaskDelegate? value) { + objc.checkOsVersionInternal( + 'NSURLSessionTask.setDelegate:', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setDelegate_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _dprintfPtr = - _lookup< - ffi.NativeFunction)> - >('dprintf'); - late final _dprintf = _dprintfPtr - .asFunction)>(); + /// Start the network load for this task no earlier than the specified date. If + /// not specified, no start delay is used. + /// + /// Only applies to tasks created from background NSURLSession instances; has no + /// effect for tasks created from other session types. + set earliestBeginDate(objc.NSDate? value) { + objc.checkOsVersionInternal( + 'NSURLSessionTask.setEarliestBeginDate:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setEarliestBeginDate_, + value?.ref.pointer ?? ffi.nullptr, + ); + } - int vdprintf(int arg0, ffi.Pointer arg1, va_list arg2) { - return _vdprintf(arg0, arg1, arg2); + /// Provides a hint indicating if incremental delivery of a partial response body + /// would be useful for the application, or if it cannot process the response + /// until it is complete. Indicating that incremental delivery is not desired may + /// improve task performance. For example, if a response cannot be decoded until + /// the entire content is received, set this property to false. + /// + /// Defaults to true unless this task is created with completion-handler based + /// convenience methods, or if it is a download task. + set prefersIncrementalDelivery(bool value) { + objc.checkOsVersionInternal( + 'NSURLSessionTask.setPrefersIncrementalDelivery:', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), + ); + _objc_msgSend_1s56lr9( + object$.ref.pointer, + _sel_setPrefersIncrementalDelivery_, + value, + ); } - late final _vdprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, va_list) - > - >('vdprintf'); - late final _vdprintf = _vdprintfPtr - .asFunction, va_list)>(); - - int getdelim( - ffi.Pointer> __linep, - ffi.Pointer __linecapp, - int __delimiter, - ffi.Pointer __stream, - ) { - return _getdelim(__linep, __linecapp, __delimiter, __stream); + /// Sets a scaling factor for the priority of the task. The scaling factor is a + /// value between 0.0 and 1.0 (inclusive), where 0.0 is considered the lowest + /// priority and 1.0 is considered the highest. + /// + /// The priority is a hint and not a hard requirement of task performance. The + /// priority of a task may be changed using this API at any time, but not all + /// protocols support this; in these cases, the last priority that took effect + /// will be used. + /// + /// If no priority is specified, the task will operate with the default priority + /// as defined by the constant NSURLSessionTaskPriorityDefault. Two additional + /// priority levels are provided: NSURLSessionTaskPriorityLow and + /// NSURLSessionTaskPriorityHigh, but use is not restricted to these. + set priority(double value) { + objc.checkOsVersionInternal( + 'NSURLSessionTask.setPriority:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_v5hmet(object$.ref.pointer, _sel_setPriority_, value); } - late final _getdelimPtr = - _lookup< - ffi.NativeFunction< - ssize_t Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >('getdelim'); - late final _getdelim = _getdelimPtr - .asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); + /// The taskDescription property is available for the developer to + /// provide a descriptive label for the task. + set taskDescription(objc.NSString? value) { + objc.checkOsVersionInternal( + 'NSURLSessionTask.setTaskDescription:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setTaskDescription_, + value?.ref.pointer ?? ffi.nullptr, + ); + } - int getline( - ffi.Pointer> __linep, - ffi.Pointer __linecapp, - ffi.Pointer __stream, - ) { - return _getline(__linep, __linecapp, __stream); + /// The current state of the task within the session. + NSURLSessionTaskState get state { + objc.checkOsVersionInternal( + 'NSURLSessionTask.state', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1vze0g9(object$.ref.pointer, _sel_state); + return NSURLSessionTaskState.fromValue($ret); } - late final _getlinePtr = - _lookup< - ffi.NativeFunction< - ssize_t Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ) - > - >('getline'); - late final _getline = _getlinePtr - .asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ) - >(); + /// Suspending a task will prevent the NSURLSession from continuing to + /// load data. There may still be delegate calls made on behalf of + /// this task (for instance, to report data received while suspending) + /// but no further transmissions will be made on behalf of the task + /// until -resume is sent. The timeout timer associated with the task + /// will be disabled while a task is suspended. -suspend and -resume are + /// nestable. + void suspend() { + objc.checkOsVersionInternal( + 'NSURLSessionTask.suspend', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_suspend); + } - ffi.Pointer fmemopen( - ffi.Pointer __buf, - int __size, - ffi.Pointer __mode, - ) { - return _fmemopen(__buf, __size, __mode); + /// The taskDescription property is available for the developer to + /// provide a descriptive label for the task. + objc.NSString? get taskDescription { + objc.checkOsVersionInternal( + 'NSURLSessionTask.taskDescription', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_taskDescription, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _fmemopenPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ) - > - >('fmemopen'); - late final _fmemopen = _fmemopenPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); + /// an identifier for this task, assigned by and unique to the owning session + int get taskIdentifier { + objc.checkOsVersionInternal( + 'NSURLSessionTask.taskIdentifier', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_taskIdentifier); + } +} - ffi.Pointer open_memstream( - ffi.Pointer> __bufp, - ffi.Pointer __sizep, - ) { - return _open_memstream(__bufp, __sizep); +/// NSURLSessionDownloadTask is a task that represents a download to +/// local storage. +extension type NSURLSessionDownloadTask._(objc.ObjCObject object$) + implements objc.ObjCObject, NSURLSessionTask { + /// Constructs a [NSURLSessionDownloadTask] that points to the same underlying object as [other]. + NSURLSessionDownloadTask.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadTask', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + assert(isA(object$)); } - late final _open_memstreamPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer>, - ffi.Pointer, - ) - > - >('open_memstream'); - late final _open_memstream = _open_memstreamPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer>, - ffi.Pointer, - ) - >(); + /// Constructs a [NSURLSessionDownloadTask] that wraps the given raw object pointer. + NSURLSessionDownloadTask.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadTask', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + assert(isA(object$)); + } - late final ffi.Pointer _sys_nerr = _lookup('sys_nerr'); + /// Returns whether [obj] is an instance of [NSURLSessionDownloadTask]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionDownloadTask, + ); - int get sys_nerr => _sys_nerr.value; + /// alloc + static NSURLSessionDownloadTask alloc() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionDownloadTask, + _sel_alloc, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: false, + release: true, + ); + } - late final ffi.Pointer>> _sys_errlist = - _lookup>>('sys_errlist'); + /// allocWithZone: + static NSURLSessionDownloadTask allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSessionDownloadTask, + _sel_allocWithZone_, + zone, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: false, + release: true, + ); + } - ffi.Pointer> get sys_errlist => _sys_errlist.value; + /// new + static NSURLSessionDownloadTask new$() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionDownloadTask, + _sel_new, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: false, + release: true, + ); + } - set sys_errlist(ffi.Pointer> value) => - _sys_errlist.value = value; + /// Returns a new instance of NSURLSessionDownloadTask constructed with the default `new` method. + NSURLSessionDownloadTask() : this.as(new$().object$); +} - int asprintf( - ffi.Pointer> arg0, - ffi.Pointer arg1, +extension NSURLSessionDownloadTask$Methods on NSURLSessionDownloadTask { + /// Cancel the download (and calls the superclass -cancel). If + /// conditions will allow for resuming the download in the future, the + /// callback will be called with an opaque data blob, which may be used + /// with -downloadTaskWithResumeData: to attempt to resume the download. + /// If resume data cannot be created, the completion handler will be + /// called with nil resumeData. + void cancelByProducingResumeData( + objc.ObjCBlock completionHandler, ) { - return _asprintf(arg0, arg1); + objc.checkOsVersionInternal( + 'NSURLSessionDownloadTask.cancelByProducingResumeData:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_cancelByProducingResumeData_, + completionHandler.ref.pointer, + ); } - late final _asprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Pointer, - ) - > - >('asprintf'); - late final _asprintf = _asprintfPtr - .asFunction< - int Function(ffi.Pointer>, ffi.Pointer) - >(); - - ffi.Pointer ctermid_r(ffi.Pointer arg0) { - return _ctermid_r(arg0); + /// init + NSURLSessionDownloadTask init() { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadTask.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: false, + release: true, + ); } +} - late final _ctermid_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('ctermid_r'); - late final _ctermid_r = _ctermid_rPtr - .asFunction Function(ffi.Pointer)>(); +late final _sel_downloadTaskWithRequest_ = objc.registerName( + "downloadTaskWithRequest:", +); +late final _sel_downloadTaskWithURL_ = objc.registerName( + "downloadTaskWithURL:", +); +late final _sel_downloadTaskWithResumeData_ = objc.registerName( + "downloadTaskWithResumeData:", +); - ffi.Pointer fgetln( - ffi.Pointer arg0, - ffi.Pointer __len, - ) { - return _fgetln(arg0, __len); +/// WARNING: NSURLSessionStreamTask is a stub. To generate bindings for this class, include +/// NSURLSessionStreamTask in your config's objc-interfaces list. +/// +/// An NSURLSessionStreamTask provides an interface to perform reads +/// and writes to a TCP/IP stream created via NSURLSession. This task +/// may be explicitly created from an NSURLSession, or created as a +/// result of the appropriate disposition response to a +/// -URLSession:dataTask:didReceiveResponse: delegate message. +/// +/// NSURLSessionStreamTask can be used to perform asynchronous reads +/// and writes. Reads and writes are enqueued and executed serially, +/// with the completion handler being invoked on the sessions delegate +/// queue. If an error occurs, or the task is canceled, all +/// outstanding read and write calls will have their completion +/// handlers invoked with an appropriate error. +/// +/// It is also possible to create NSInputStream and NSOutputStream +/// instances from an NSURLSessionTask by sending +/// -captureStreams to the task. All outstanding reads and writes are +/// completed before the streams are created. Once the streams are +/// delivered to the session delegate, the task is considered complete +/// and will receive no more messages. These streams are +/// disassociated from the underlying session. +extension type NSURLSessionStreamTask._(objc.ObjCObject object$) + implements objc.ObjCObject, NSURLSessionTask { + /// Constructs a [NSURLSessionStreamTask] that points to the same underlying object as [other]. + NSURLSessionStreamTask.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSessionStreamTask', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); } - late final _fgetlnPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('fgetln'); - late final _fgetln = _fgetlnPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); - - ffi.Pointer fmtcheck( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _fmtcheck(arg0, arg1); + /// Constructs a [NSURLSessionStreamTask] that wraps the given raw object pointer. + NSURLSessionStreamTask.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionStreamTask', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); } +} - late final _fmtcheckPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('fmtcheck'); - late final _fmtcheck = _fmtcheckPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, +late final _sel_streamTaskWithHostName_port_ = objc.registerName( + "streamTaskWithHostName:port:", +); +final _objc_msgSend_9slupp = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, ) - >(); - - int fpurge(ffi.Pointer arg0) { - return _fpurge(arg0); - } - - late final _fpurgePtr = - _lookup)>>( - 'fpurge', - ); - late final _fpurge = _fpurgePtr.asFunction)>(); + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); - void setbuffer( - ffi.Pointer arg0, - ffi.Pointer arg1, - int __size, - ) { - return _setbuffer(arg0, arg1, __size); - } +/// WARNING: NSNetService is a stub. To generate bindings for this class, include +/// NSNetService in your config's objc-interfaces list. +/// +/// NSNetService +extension type NSNetService._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [NSNetService] that points to the same underlying object as [other]. + NSNetService.as(objc.ObjCObject other) : object$ = other {} - late final _setbufferPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, ffi.Int) - > - >('setbuffer'); - late final _setbuffer = _setbufferPtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); + /// Constructs a [NSNetService] that wraps the given raw object pointer. + NSNetService.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} +} - int setlinebuf(ffi.Pointer arg0) { - return _setlinebuf(arg0); - } +late final _sel_streamTaskWithNetService_ = objc.registerName( + "streamTaskWithNetService:", +); +late final _class_NSURLSessionWebSocketTask = objc.getClass( + "NSURLSessionWebSocketTask", +); +late final _class_NSURLSessionWebSocketMessage = objc.getClass( + "NSURLSessionWebSocketMessage", +); +late final _sel_initWithData_ = objc.registerName("initWithData:"); +late final _sel_initWithString_ = objc.registerName("initWithString:"); - late final _setlinebufPtr = - _lookup)>>( - 'setlinebuf', - ); - late final _setlinebuf = _setlinebufPtr - .asFunction)>(); +enum NSURLSessionWebSocketMessageType { + NSURLSessionWebSocketMessageTypeData(0), + NSURLSessionWebSocketMessageTypeString(1); - int vasprintf( - ffi.Pointer> arg0, - ffi.Pointer arg1, - va_list arg2, - ) { - return _vasprintf(arg0, arg1, arg2); - } + final int value; + const NSURLSessionWebSocketMessageType(this.value); - late final _vasprintfPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Pointer, - va_list, - ) - > - >('vasprintf'); - late final _vasprintf = _vasprintfPtr - .asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer, - va_list, - ) - >(); + static NSURLSessionWebSocketMessageType fromValue(int value) => + switch (value) { + 0 => NSURLSessionWebSocketMessageTypeData, + 1 => NSURLSessionWebSocketMessageTypeString, + _ => throw ArgumentError( + 'Unknown value for NSURLSessionWebSocketMessageType: $value', + ), + }; +} - ffi.Pointer funopen( - ffi.Pointer arg0, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int) - > - > - arg1, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int) - > - > - arg2, - ffi.Pointer< +late final _sel_type = objc.registerName("type"); +final _objc_msgSend_1qouven = objc.msgSendPointer + .cast< ffi.NativeFunction< - fpos_t Function(ffi.Pointer, fpos_t, ffi.Int) - > - > - arg3, - ffi.Pointer)>> - arg4, - ) { - return _funopen(arg0, arg1, arg2, arg3, arg4); - } - - late final _funopenPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - fpos_t Function(ffi.Pointer, fpos_t, ffi.Int) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - > - >('funopen'); - late final _funopen = _funopenPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - fpos_t Function(ffi.Pointer, fpos_t, ffi.Int) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, ) - >(); + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_data = objc.registerName("data"); +late final _sel_string = objc.registerName("string"); - int __snprintf_chk( - ffi.Pointer arg0, - int __maxlen, - int arg2, - int arg3, - ffi.Pointer arg4, - ) { - return ___snprintf_chk(arg0, __maxlen, arg2, arg3, arg4); +/// The client can create a WebSocket message object that will be passed to the send calls +/// and will be delivered from the receive calls. The message can be initialized with data or string. +/// If initialized with data, the string property will be nil and vice versa. +extension type NSURLSessionWebSocketMessage._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [NSURLSessionWebSocketMessage] that points to the same underlying object as [other]. + NSURLSessionWebSocketMessage.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + assert(isA(object$)); } - late final ___snprintf_chkPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Int, - ffi.Size, - ffi.Pointer, - ) - > - >('__snprintf_chk'); - late final ___snprintf_chk = ___snprintf_chkPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - int, - ffi.Pointer, - ) - >(); - - int __vsnprintf_chk( - ffi.Pointer arg0, - int __maxlen, - int arg2, - int arg3, - ffi.Pointer arg4, - va_list arg5, - ) { - return ___vsnprintf_chk(arg0, __maxlen, arg2, arg3, arg4, arg5); + /// Constructs a [NSURLSessionWebSocketMessage] that wraps the given raw object pointer. + NSURLSessionWebSocketMessage.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + assert(isA(object$)); } - late final ___vsnprintf_chkPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Int, - ffi.Size, - ffi.Pointer, - va_list, - ) - > - >('__vsnprintf_chk'); - late final ___vsnprintf_chk = ___vsnprintf_chkPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - int, - ffi.Pointer, - va_list, - ) - >(); + /// Returns whether [obj] is an instance of [NSURLSessionWebSocketMessage]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionWebSocketMessage, + ); - int __sprintf_chk( - ffi.Pointer arg0, - int arg1, - int arg2, - ffi.Pointer arg3, - ) { - return ___sprintf_chk(arg0, arg1, arg2, arg3); + /// alloc + static NSURLSessionWebSocketMessage alloc() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionWebSocketMessage, + _sel_alloc, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final ___sprintf_chkPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Size, - ffi.Pointer, - ) - > - >('__sprintf_chk'); - late final ___sprintf_chk = ___sprintf_chkPtr - .asFunction< - int Function(ffi.Pointer, int, int, ffi.Pointer) - >(); - - int __vsprintf_chk( - ffi.Pointer arg0, - int arg1, - int arg2, - ffi.Pointer arg3, - va_list arg4, + /// allocWithZone: + static NSURLSessionWebSocketMessage allocWithZone( + ffi.Pointer zone, ) { - return ___vsprintf_chk(arg0, arg1, arg2, arg3, arg4); + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSessionWebSocketMessage, + _sel_allocWithZone_, + zone, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final ___vsprintf_chkPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Size, - ffi.Pointer, - va_list, - ) - > - >('__vsprintf_chk'); - late final ___vsprintf_chk = ___vsprintf_chkPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - ffi.Pointer, - va_list, - ) - >(); - - ffi.Pointer memchr(ffi.Pointer __s, int __c, int __n) { - return _memchr(__s, __c, __n); - } - - late final _memchrPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Int, - ffi.Size, - ) - > - >('memchr'); - late final _memchr = _memchrPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); - - int memcmp(ffi.Pointer __s1, ffi.Pointer __s2, int __n) { - return _memcmp(__s1, __s2, __n); - } - - late final _memcmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('memcmp'); - late final _memcmp = _memcmpPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - ffi.Pointer memcpy( - ffi.Pointer __dst, - ffi.Pointer __src, - int __n, - ) { - return _memcpy(__dst, __src, __n); - } - - late final _memcpyPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('memcpy'); - late final _memcpy = _memcpyPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - ffi.Pointer memmove( - ffi.Pointer __dst, - ffi.Pointer __src, - int __len, - ) { - return _memmove(__dst, __src, __len); - } - - late final _memmovePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('memmove'); - late final _memmove = _memmovePtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - ffi.Pointer memset(ffi.Pointer __b, int __c, int __len) { - return _memset(__b, __c, __len); - } - - late final _memsetPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Int, - ffi.Size, - ) - > - >('memset'); - late final _memset = _memsetPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); - - ffi.Pointer strcat( - ffi.Pointer __s1, - ffi.Pointer __s2, - ) { - return _strcat(__s1, __s2); + /// new + static NSURLSessionWebSocketMessage new$() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionWebSocketMessage, + _sel_new, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _strcatPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('strcat'); - late final _strcat = _strcatPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); + /// Returns a new instance of NSURLSessionWebSocketMessage constructed with the default `new` method. + NSURLSessionWebSocketMessage() : this.as(new$().object$); +} - ffi.Pointer strchr(ffi.Pointer __s, int __c) { - return _strchr(__s, __c); +extension NSURLSessionWebSocketMessage$Methods on NSURLSessionWebSocketMessage { + /// data + objc.NSData? get data { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.data', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_data); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); } - late final _strchrPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('strchr'); - late final _strchr = _strchrPtr - .asFunction Function(ffi.Pointer, int)>(); - - int strcmp(ffi.Pointer __s1, ffi.Pointer __s2) { - return _strcmp(__s1, __s2); + /// init + NSURLSessionWebSocketMessage init() { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _strcmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('strcmp'); - late final _strcmp = _strcmpPtr - .asFunction, ffi.Pointer)>(); - - int strcoll(ffi.Pointer __s1, ffi.Pointer __s2) { - return _strcoll(__s1, __s2); + /// Create a message with data type + NSURLSessionWebSocketMessage initWithData(objc.NSData data) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.initWithData:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.retainAndReturnPointer(), + _sel_initWithData_, + data.ref.pointer, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _strcollPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('strcoll'); - late final _strcoll = _strcollPtr - .asFunction, ffi.Pointer)>(); - - ffi.Pointer strcpy( - ffi.Pointer __dst, - ffi.Pointer __src, - ) { - return _strcpy(__dst, __src); + /// Create a message with string type + NSURLSessionWebSocketMessage initWithString(objc.NSString string) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.initWithString:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.retainAndReturnPointer(), + _sel_initWithString_, + string.ref.pointer, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _strcpyPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('strcpy'); - late final _strcpy = _strcpyPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int strcspn(ffi.Pointer __s, ffi.Pointer __charset) { - return _strcspn(__s, __charset); + /// string + objc.NSString? get string { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.string', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_string); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _strcspnPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('strcspn'); - late final _strcspn = _strcspnPtr - .asFunction, ffi.Pointer)>(); - - ffi.Pointer strerror(int __errnum) { - return _strerror(__errnum); + /// type + NSURLSessionWebSocketMessageType get type { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.type', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1qouven(object$.ref.pointer, _sel_type); + return NSURLSessionWebSocketMessageType.fromValue($ret); } +} - late final _strerrorPtr = - _lookup Function(ffi.Int)>>( - 'strerror', - ); - late final _strerror = _strerrorPtr - .asFunction Function(int)>(); +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); - int strlen(ffi.Pointer __s) { - return _strlen(__s); - } + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _strlenPtr = - _lookup< - ffi.NativeFunction)> - >('strlen'); - late final _strlen = _strlenPtr - .asFunction)>(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSError.fromPointer(arg0, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - ffi.Pointer strncat( - ffi.Pointer __s1, - ffi.Pointer __s2, - int __n, - ) { - return _strncat(__s1, __s2, __n); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSError.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _strncatPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('strncat'); - late final _strncat = _strncatPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - int strncmp(ffi.Pointer __s1, ffi.Pointer __s2, int __n) { - return _strncmp(__s1, __s2, __n); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSError.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSError.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _strncmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('strncmp'); - late final _strncmp = _strncmpPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - ffi.Pointer strncpy( - ffi.Pointer __dst, - ffi.Pointer __src, - int __n, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, ) { - return _strncpy(__dst, __src, __n); + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); } - late final _strncpyPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, ) - > - >('strncpy'); - late final _strncpy = _strncpyPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - ffi.Pointer strpbrk( - ffi.Pointer __s, - ffi.Pointer __charset, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, ) { - return _strpbrk(__s, __charset); + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _strpbrkPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('strpbrk'); - late final _strpbrk = _strpbrkPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - ffi.Pointer strrchr(ffi.Pointer __s, int __c) { - return _strrchr(__s, __c); - } - - late final _strrchrPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('strrchr'); - late final _strrchr = _strrchrPtr - .asFunction Function(ffi.Pointer, int)>(); - - int strspn(ffi.Pointer __s, ffi.Pointer __charset) { - return _strspn(__s, __charset); - } - - late final _strspnPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('strspn'); - late final _strspn = _strspnPtr - .asFunction, ffi.Pointer)>(); - - ffi.Pointer strstr( - ffi.Pointer __big, - ffi.Pointer __little, - ) { - return _strstr(__big, __little); - } - - late final _strstrPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) + ffi.Void Function(ffi.Pointer arg0) > - >('strstr'); - late final _strstr = _strstrPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - ffi.Pointer strtok( - ffi.Pointer __str, - ffi.Pointer __sep, - ) { - return _strtok(__str, __sep); - } + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _strtokPtr = - _lookup< +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSError$CallExtension + on objc.ObjCBlock { + void call(objc.NSError? arg0) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, ) > - >('strtok'); - late final _strtok = _strtokPtr + >() .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + void Function( + ffi.Pointer, + ffi.Pointer, ) - >(); - - int strxfrm(ffi.Pointer __s1, ffi.Pointer __s2, int __n) { - return _strxfrm(__s1, __s2, __n); - } + >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); +} - late final _strxfrmPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('strxfrm'); - late final _strxfrm = _strxfrmPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); +late final _sel_sendMessage_completionHandler_ = objc.registerName( + "sendMessage:completionHandler:", +); - ffi.Pointer strtok_r( - ffi.Pointer __str, - ffi.Pointer __sep, - ffi.Pointer> __lasts, - ) { - return _strtok_r(__str, __sep, __lasts); - } +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSURLSessionWebSocketMessage_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + >(pointer, retain: retain, release: release); - late final _strtok_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - > - >('strtok_r'); - late final _strtok_r = _strtok_rPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, ) - >(); + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - int strerror_r( - int __errnum, - ffi.Pointer __strerrbuf, - int __buflen, - ) { - return _strerror_r(__errnum, __strerrbuf, __buflen); - } - - late final _strerror_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Size) - > - >('strerror_r'); - late final _strerror_r = _strerror_rPtr - .asFunction, int)>(); - - ffi.Pointer strdup(ffi.Pointer __s1) { - return _strdup(__s1); - } - - late final _strdupPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('strdup'); - late final _strdup = _strdupPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer memccpy( - ffi.Pointer __dst, - ffi.Pointer __src, - int __c, - int __n, - ) { - return _memccpy(__dst, __src, __c, __n); - } - - late final _memccpyPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Size, - ) - > - >('memccpy'); - late final _memccpy = _memccpyPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >(); - - ffi.Pointer stpcpy( - ffi.Pointer __dst, - ffi.Pointer __src, - ) { - return _stpcpy(__dst, __src); - } - - late final _stpcpyPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('stpcpy'); - late final _stpcpy = _stpcpyPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - ffi.Pointer stpncpy( - ffi.Pointer __dst, - ffi.Pointer __src, - int __n, - ) { - return _stpncpy(__dst, __src, __n); - } - - late final _stpncpyPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('stpncpy'); - late final _stpncpy = _stpncpyPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - ffi.Pointer strndup(ffi.Pointer __s1, int __n) { - return _strndup(__s1, __n); - } - - late final _strndupPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Size) - > - >('strndup'); - late final _strndup = _strndupPtr - .asFunction Function(ffi.Pointer, int)>(); - - int strnlen(ffi.Pointer __s1, int __n) { - return _strnlen(__s1, __n); - } - - late final _strnlenPtr = - _lookup< - ffi.NativeFunction, ffi.Size)> - >('strnlen'); - late final _strnlen = _strnlenPtr - .asFunction, int)>(); - - ffi.Pointer strsignal(int __sig) { - return _strsignal(__sig); - } - - late final _strsignalPtr = - _lookup Function(ffi.Int)>>( - 'strsignal', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + > + fromFunction( + void Function(NSURLSessionWebSocketMessage?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => fn( + arg0.address == 0 + ? null + : NSURLSessionWebSocketMessage.fromPointer( + arg0, + retain: true, + release: true, + ), + arg1.address == 0 + ? null + : objc.NSError.fromPointer(arg1, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _strsignal = _strsignalPtr - .asFunction Function(int)>(); - int memset_s(ffi.Pointer __s, int __smax, int __c, int __n) { - return _memset_s(__s, __smax, __c, __n); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + > + listener( + void Function(NSURLSessionWebSocketMessage?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => fn( + arg0.address == 0 + ? null + : NSURLSessionWebSocketMessage.fromPointer( + arg0, + retain: false, + release: true, + ), + arg1.address == 0 + ? null + : objc.NSError.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_pfv6jd(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + >(wrapper, retain: false, release: true); } - late final _memset_sPtr = - _lookup< - ffi.NativeFunction< - errno_t Function(ffi.Pointer, rsize_t, ffi.Int, rsize_t) - > - >('memset_s'); - late final _memset_s = _memset_sPtr - .asFunction, int, int, int)>(); - - ffi.Pointer memmem( - ffi.Pointer __big, - int __big_len, - ffi.Pointer __little, - int __little_len, - ) { - return _memmem(__big, __big_len, __little, __little_len); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + > + blocking( + void Function(NSURLSessionWebSocketMessage?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => fn( + arg0.address == 0 + ? null + : NSURLSessionWebSocketMessage.fromPointer( + arg0, + retain: false, + release: true, + ), + arg1.address == 0 + ? null + : objc.NSError.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => fn( + arg0.address == 0 + ? null + : NSURLSessionWebSocketMessage.fromPointer( + arg0, + retain: false, + release: true, + ), + arg1.address == 0 + ? null + : objc.NSError.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + >(wrapper, retain: false, release: true); } - late final _memmemPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - > - >('memmem'); - late final _memmem = _memmemPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - int, - ffi.Pointer, - int, - ) - >(); - - void memset_pattern4( - ffi.Pointer __b, - ffi.Pointer __pattern4, - int __len, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _memset_pattern4(__b, __pattern4, __len); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + objc.objectRelease(block.cast()); } - late final _memset_pattern4Ptr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('memset_pattern4'); - late final _memset_pattern4 = _memset_pattern4Ptr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); - - void memset_pattern8( - ffi.Pointer __b, - ffi.Pointer __pattern8, - int __len, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _memset_pattern8(__b, __pattern8, __len); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _memset_pattern8Ptr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer, - ffi.Size, + ffi.Pointer, + ffi.Pointer, ) - > - >('memset_pattern8'); - late final _memset_pattern8 = _memset_pattern8Ptr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); - - void memset_pattern16( - ffi.Pointer __b, - ffi.Pointer __pattern16, - int __len, - ) { - return _memset_pattern16(__b, __pattern16, __len); - } - - late final _memset_pattern16Ptr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer, - ffi.Size, + ffi.Pointer, + ffi.Pointer, ) - > - >('memset_pattern16'); - late final _memset_pattern16 = _memset_pattern16Ptr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); - - ffi.Pointer strcasestr( - ffi.Pointer __big, - ffi.Pointer __little, - ) { - return _strcasestr(__big, __little); - } - - late final _strcasestrPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, ) > - >('strcasestr'); - late final _strcasestr = _strcasestrPtr + >() .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + void Function( + ffi.Pointer, + ffi.Pointer, ) - >(); + >()(arg0, arg1); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - ffi.Pointer strchrnul(ffi.Pointer __s, int __c) { - return _strchrnul(__s, __c); - } +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLSessionWebSocketMessage_NSError$CallExtension + on + objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + > { + void call(NSURLSessionWebSocketMessage? arg0, objc.NSError? arg1) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, + arg1?.ref.pointer ?? ffi.nullptr, + ); +} - late final _strchrnulPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('strchrnul'); - late final _strchrnul = _strchrnulPtr - .asFunction Function(ffi.Pointer, int)>(); - - ffi.Pointer strnstr( - ffi.Pointer __big, - ffi.Pointer __little, - int __len, - ) { - return _strnstr(__big, __little, __len); - } +late final _sel_receiveMessageWithCompletionHandler_ = objc.registerName( + "receiveMessageWithCompletionHandler:", +); +late final _sel_sendPingWithPongReceiveHandler_ = objc.registerName( + "sendPingWithPongReceiveHandler:", +); - late final _strnstrPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('strnstr'); - late final _strnstr = _strnstrPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, +/// The WebSocket close codes follow the close codes given in the RFC +sealed class NSURLSessionWebSocketCloseCode { + static const NSURLSessionWebSocketCloseCodeInvalid = 0; + static const NSURLSessionWebSocketCloseCodeNormalClosure = 1000; + static const NSURLSessionWebSocketCloseCodeGoingAway = 1001; + static const NSURLSessionWebSocketCloseCodeProtocolError = 1002; + static const NSURLSessionWebSocketCloseCodeUnsupportedData = 1003; + static const NSURLSessionWebSocketCloseCodeNoStatusReceived = 1005; + static const NSURLSessionWebSocketCloseCodeAbnormalClosure = 1006; + static const NSURLSessionWebSocketCloseCodeInvalidFramePayloadData = 1007; + static const NSURLSessionWebSocketCloseCodePolicyViolation = 1008; + static const NSURLSessionWebSocketCloseCodeMessageTooBig = 1009; + static const NSURLSessionWebSocketCloseCodeMandatoryExtensionMissing = 1010; + static const NSURLSessionWebSocketCloseCodeInternalServerError = 1011; + static const NSURLSessionWebSocketCloseCodeTLSHandshakeFailure = 1015; +} + +late final _sel_cancelWithCloseCode_reason_ = objc.registerName( + "cancelWithCloseCode:reason:", +); +final _objc_msgSend_tqzk0b = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ) + >(); +late final _sel_maximumMessageSize = objc.registerName("maximumMessageSize"); +late final _sel_setMaximumMessageSize_ = objc.registerName( + "setMaximumMessageSize:", +); +late final _sel_closeCode = objc.registerName("closeCode"); +final _objc_msgSend_1rhk8uh = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, ) - >(); + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_closeReason = objc.registerName("closeReason"); - int strlcat( - ffi.Pointer __dst, - ffi.Pointer __source, - int __size, - ) { - return _strlcat(__dst, __source, __size); +/// A WebSocket task can be created with a ws or wss url. A client can also provide +/// a list of protocols it wishes to advertise during the WebSocket handshake phase. +/// Once the handshake is successfully completed the client will be notified through an optional delegate. +/// All reads and writes enqueued before the completion of the handshake will be queued up and +/// executed once the handshake succeeds. Before the handshake completes, the client can be called to handle +/// redirection or authentication using the same delegates as NSURLSessionTask. WebSocket task will also provide +/// support for cookies and will store cookies to the cookie storage on the session and will attach cookies to +/// outgoing HTTP handshake requests. +extension type NSURLSessionWebSocketTask._(objc.ObjCObject object$) + implements objc.ObjCObject, NSURLSessionTask { + /// Constructs a [NSURLSessionWebSocketTask] that points to the same underlying object as [other]. + NSURLSessionWebSocketTask.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + assert(isA(object$)); } - late final _strlcatPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('strlcat'); - late final _strlcat = _strlcatPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int strlcpy( - ffi.Pointer __dst, - ffi.Pointer __source, - int __size, - ) { - return _strlcpy(__dst, __source, __size); + /// Constructs a [NSURLSessionWebSocketTask] that wraps the given raw object pointer. + NSURLSessionWebSocketTask.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + assert(isA(object$)); } - late final _strlcpyPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('strlcpy'); - late final _strlcpy = _strlcpyPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); + /// Returns whether [obj] is an instance of [NSURLSessionWebSocketTask]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionWebSocketTask, + ); - void strmode(int __mode, ffi.Pointer __bp) { - return _strmode(__mode, __bp); + /// alloc + static NSURLSessionWebSocketTask alloc() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionWebSocketTask, + _sel_alloc, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _strmodePtr = - _lookup< - ffi.NativeFunction)> - >('strmode'); - late final _strmode = _strmodePtr - .asFunction)>(); - - ffi.Pointer strsep( - ffi.Pointer> __stringp, - ffi.Pointer __delim, + /// allocWithZone: + static NSURLSessionWebSocketTask allocWithZone( + ffi.Pointer zone, ) { - return _strsep(__stringp, __delim); - } - - late final _strsepPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer>, - ffi.Pointer, - ) - > - >('strsep'); - late final _strsep = _strsepPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer>, - ffi.Pointer, - ) - >(); - - void swab(ffi.Pointer arg0, ffi.Pointer arg1, int __len) { - return _swab(arg0, arg1, __len); - } - - late final _swabPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ssize_t, - ) - > - >('swab'); - late final _swab = _swabPtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int timingsafe_bcmp( - ffi.Pointer __b1, - ffi.Pointer __b2, - int __len, - ) { - return _timingsafe_bcmp(__b1, __b2, __len); - } - - late final _timingsafe_bcmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('timingsafe_bcmp'); - late final _timingsafe_bcmp = _timingsafe_bcmpPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int strsignal_r( - int __sig, - ffi.Pointer __strsignalbuf, - int __buflen, - ) { - return _strsignal_r(__sig, __strsignalbuf, __buflen); - } - - late final _strsignal_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Size) - > - >('strsignal_r'); - late final _strsignal_r = _strsignal_rPtr - .asFunction, int)>(); - - int bcmp(ffi.Pointer arg0, ffi.Pointer arg1, int __n) { - return _bcmp(arg0, arg1, __n); + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSessionWebSocketTask, + _sel_allocWithZone_, + zone, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _bcmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('bcmp'); - late final _bcmp = _bcmpPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - void bcopy(ffi.Pointer arg0, ffi.Pointer arg1, int __n) { - return _bcopy(arg0, arg1, __n); + /// new + static NSURLSessionWebSocketTask new$() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionWebSocketTask, + _sel_new, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _bcopyPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('bcopy'); - late final _bcopy = _bcopyPtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); + /// Returns a new instance of NSURLSessionWebSocketTask constructed with the default `new` method. + NSURLSessionWebSocketTask() : this.as(new$().object$); +} - void bzero(ffi.Pointer arg0, int __n) { - return _bzero(arg0, __n); +extension NSURLSessionWebSocketTask$Methods on NSURLSessionWebSocketTask { + /// Sends a close frame with the given closeCode. An optional reason can be provided while sending the close frame. + /// Simply calling cancel on the task will result in a cancellation frame being sent without any reason. + void cancelWithCloseCode(int closeCode, {objc.NSData? reason}) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.cancelWithCloseCode:reason:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_tqzk0b( + object$.ref.pointer, + _sel_cancelWithCloseCode_reason_, + closeCode, + reason?.ref.pointer ?? ffi.nullptr, + ); } - late final _bzeroPtr = - _lookup< - ffi.NativeFunction, ffi.Size)> - >('bzero'); - late final _bzero = _bzeroPtr - .asFunction, int)>(); - - ffi.Pointer index(ffi.Pointer arg0, int arg1) { - return _index(arg0, arg1); + /// A task can be queried for it's close code at any point. When the task is not closed, it will be set to NSURLSessionWebSocketCloseCodeInvalid + int get closeCode { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.closeCode', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_1rhk8uh(object$.ref.pointer, _sel_closeCode); } - late final _indexPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('index'); - late final _index = _indexPtr - .asFunction Function(ffi.Pointer, int)>(); - - ffi.Pointer rindex(ffi.Pointer arg0, int arg1) { - return _rindex(arg0, arg1); + /// A task can be queried for it's close reason at any point. A nil value indicates no closeReason or that the task is still running + objc.NSData? get closeReason { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.closeReason', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_closeReason); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); } - late final _rindexPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('rindex'); - late final _rindex = _rindexPtr - .asFunction Function(ffi.Pointer, int)>(); - - int ffs(int arg0) { - return _ffs(arg0); + /// init + NSURLSessionWebSocketTask init() { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: false, + release: true, + ); } - late final _ffsPtr = _lookup>( - 'ffs', - ); - late final _ffs = _ffsPtr.asFunction(); - - int strcasecmp(ffi.Pointer arg0, ffi.Pointer arg1) { - return _strcasecmp(arg0, arg1); + /// The maximum number of bytes to be buffered before erroring out. This includes the sum of all bytes from continuation frames. Receive calls will error out if this value is reached + int get maximumMessageSize { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.maximumMessageSize', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_1hz7y9r(object$.ref.pointer, _sel_maximumMessageSize); } - late final _strcasecmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('strcasecmp'); - late final _strcasecmp = _strcasecmpPtr - .asFunction, ffi.Pointer)>(); - - int strncasecmp( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, + /// Reads a WebSocket message once all the frames of the message are available. + /// If the maximumMessage size is hit while buffering the frames, the receiveMessage call will error out + /// and all outstanding work will also fail resulting in the end of the task. + void receiveMessageWithCompletionHandler( + objc.ObjCBlock< + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + > + completionHandler, ) { - return _strncasecmp(arg0, arg1, arg2); - } - - late final _strncasecmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('strncasecmp'); - late final _strncasecmp = _strncasecmpPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int ffsl(int arg0) { - return _ffsl(arg0); - } - - late final _ffslPtr = _lookup>( - 'ffsl', - ); - late final _ffsl = _ffslPtr.asFunction(); - - int ffsll(int arg0) { - return _ffsll(arg0); - } - - late final _ffsllPtr = - _lookup>('ffsll'); - late final _ffsll = _ffsllPtr.asFunction(); - - int fls(int arg0) { - return _fls(arg0); - } - - late final _flsPtr = _lookup>( - 'fls', - ); - late final _fls = _flsPtr.asFunction(); - - int flsl(int arg0) { - return _flsl(arg0); - } - - late final _flslPtr = _lookup>( - 'flsl', - ); - late final _flsl = _flslPtr.asFunction(); - - int flsll(int arg0) { - return _flsll(arg0); + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.receiveMessageWithCompletionHandler:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_receiveMessageWithCompletionHandler_, + completionHandler.ref.pointer, + ); } - late final _flsllPtr = - _lookup>('flsll'); - late final _flsll = _flsllPtr.asFunction(); - - late final ffi.Pointer>> _tzname = - _lookup>>('tzname'); - - ffi.Pointer> get tzname => _tzname.value; - - set tzname(ffi.Pointer> value) => _tzname.value = value; - - late final ffi.Pointer _getdate_err = _lookup( - 'getdate_err', - ); - - int get getdate_err => _getdate_err.value; - - set getdate_err(int value) => _getdate_err.value = value; - - late final ffi.Pointer _timezone = _lookup('timezone'); - - int get timezone => _timezone.value; - - set timezone(int value) => _timezone.value = value; - - late final ffi.Pointer _daylight = _lookup('daylight'); - - int get daylight => _daylight.value; - - set daylight(int value) => _daylight.value = value; - - ffi.Pointer asctime(ffi.Pointer arg0) { - return _asctime(arg0); + /// Sends a WebSocket message. If an error occurs, any outstanding work will also fail. + /// Note that invocation of the completion handler does not + /// guarantee that the remote side has received all the bytes, only + /// that they have been written to the kernel. + void sendMessage( + NSURLSessionWebSocketMessage message, { + required objc.ObjCBlock completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.sendMessage:completionHandler:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_o762yo( + object$.ref.pointer, + _sel_sendMessage_completionHandler_, + message.ref.pointer, + completionHandler.ref.pointer, + ); } - late final _asctimePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('asctime'); - late final _asctime = _asctimePtr - .asFunction Function(ffi.Pointer)>(); - - int clock() { - return _clock(); + /// Sends a ping frame from the client side. The pongReceiveHandler is invoked when the client + /// receives a pong from the server endpoint. If a connection is lost or an error occurs before receiving + /// the pong from the endpoint, the pongReceiveHandler block will be invoked with an error. + /// Note - the pongReceiveHandler will always be called in the order in which the pings were sent. + void sendPingWithPongReceiveHandler( + objc.ObjCBlock pongReceiveHandler, + ) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.sendPingWithPongReceiveHandler:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_sendPingWithPongReceiveHandler_, + pongReceiveHandler.ref.pointer, + ); } - late final _clockPtr = _lookup>( - 'clock', - ); - late final _clock = _clockPtr.asFunction(); - - ffi.Pointer ctime(ffi.Pointer arg0) { - return _ctime(arg0); + /// The maximum number of bytes to be buffered before erroring out. This includes the sum of all bytes from continuation frames. Receive calls will error out if this value is reached + set maximumMessageSize(int value) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketTask.setMaximumMessageSize:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_4sp4xj( + object$.ref.pointer, + _sel_setMaximumMessageSize_, + value, + ); } +} - late final _ctimePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('ctime'); - late final _ctime = _ctimePtr - .asFunction Function(ffi.Pointer)>(); +late final _sel_webSocketTaskWithURL_ = objc.registerName( + "webSocketTaskWithURL:", +); +late final _sel_webSocketTaskWithURL_protocols_ = objc.registerName( + "webSocketTaskWithURL:protocols:", +); +late final _sel_webSocketTaskWithRequest_ = objc.registerName( + "webSocketTaskWithRequest:", +); - double difftime(int arg0, int arg1) { - return _difftime(arg0, arg1); - } +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSData_NSURLResponse_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + >(pointer, retain: retain, release: release); - late final _difftimePtr = - _lookup>( - 'difftime', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _difftime = _difftimePtr.asFunction(); - - ffi.Pointer getdate(ffi.Pointer arg0) { - return _getdate(arg0); - } - - late final _getdatePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('getdate'); - late final _getdate = _getdatePtr - .asFunction Function(ffi.Pointer)>(); - ffi.Pointer gmtime(ffi.Pointer arg0) { - return _gmtime(arg0); - } - - late final _gmtimePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('gmtime'); - late final _gmtime = _gmtimePtr - .asFunction Function(ffi.Pointer)>(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + fromFunction( + void Function(objc.NSData?, NSURLResponse?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0.address == 0 + ? null + : objc.NSData.fromPointer(arg0, retain: true, release: true), + arg1.address == 0 + ? null + : NSURLResponse.fromPointer(arg1, retain: true, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - ffi.Pointer localtime(ffi.Pointer arg0) { - return _localtime(arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + listener( + void Function(objc.NSData?, NSURLResponse?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0.address == 0 + ? null + : objc.NSData.fromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSURLResponse.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + >(wrapper, retain: false, release: true); } - late final _localtimePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('localtime'); - late final _localtime = _localtimePtr - .asFunction Function(ffi.Pointer)>(); - - int mktime(ffi.Pointer arg0) { - return _mktime(arg0); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + blocking( + void Function(objc.NSData?, NSURLResponse?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0.address == 0 + ? null + : objc.NSData.fromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSURLResponse.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0.address == 0 + ? null + : objc.NSData.fromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSURLResponse.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + >(wrapper, retain: false, release: true); } - late final _mktimePtr = - _lookup)>>('mktime'); - late final _mktime = _mktimePtr.asFunction)>(); - - int strftime( - ffi.Pointer arg0, - int __maxsize, - ffi.Pointer arg2, - ffi.Pointer arg3, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _strftime(arg0, __maxsize, arg2, arg3); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); } - late final _strftimePtr = - _lookup< - ffi.NativeFunction< - ffi.Size Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('strftime'); - late final _strftime = _strftimePtr - .asFunction< - int Function( - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - ffi.Pointer strptime( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _strptime(arg0, arg1, arg2); - } - - late final _strptimePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('strptime'); - late final _strptime = _strptimePtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int time(ffi.Pointer arg0) { - return _time(arg0); - } - - late final _timePtr = - _lookup)>>('time'); - late final _time = _timePtr.asFunction)>(); - - void tzset() { - return _tzset(); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _tzsetPtr = _lookup>( - 'tzset', - ); - late final _tzset = _tzsetPtr.asFunction(); - - ffi.Pointer asctime_r( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _asctime_r(arg0, arg1); - } - - late final _asctime_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - > - >('asctime_r'); - late final _asctime_r = _asctime_rPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); - - ffi.Pointer ctime_r( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _ctime_r(arg0, arg1); - } - - late final _ctime_rPtr = - _lookup< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) > - >('ctime_r'); - late final _ctime_r = _ctime_rPtr + >() .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - ffi.Pointer gmtime_r(ffi.Pointer arg0, ffi.Pointer arg1) { - return _gmtime_r(arg0, arg1); - } - - late final _gmtime_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - > - >('gmtime_r'); - late final _gmtime_r = _gmtime_rPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); - - ffi.Pointer localtime_r(ffi.Pointer arg0, ffi.Pointer arg1) { - return _localtime_r(arg0, arg1); - } - - late final _localtime_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - > - >('localtime_r'); - late final _localtime_r = _localtime_rPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); - - int posix2time(int arg0) { - return _posix2time(arg0); - } - - late final _posix2timePtr = - _lookup>('posix2time'); - late final _posix2time = _posix2timePtr.asFunction(); - - void tzsetwall() { - return _tzsetwall(); - } - - late final _tzsetwallPtr = _lookup>( - 'tzsetwall', - ); - late final _tzsetwall = _tzsetwallPtr.asFunction(); - - int time2posix(int arg0) { - return _time2posix(arg0); - } - - late final _time2posixPtr = - _lookup>('time2posix'); - late final _time2posix = _time2posixPtr.asFunction(); - - int timelocal(ffi.Pointer arg0) { - return _timelocal(arg0); - } + >()(arg0, arg1, arg2); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _timelocalPtr = - _lookup)>>( - 'timelocal', +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSData_NSURLResponse_NSError$CallExtension + on + objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > { + void call(objc.NSData? arg0, NSURLResponse? arg1, objc.NSError? arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, + arg1?.ref.pointer ?? ffi.nullptr, + arg2?.ref.pointer ?? ffi.nullptr, ); - late final _timelocal = _timelocalPtr - .asFunction)>(); - - int timegm(ffi.Pointer arg0) { - return _timegm(arg0); - } - - late final _timegmPtr = - _lookup)>>('timegm'); - late final _timegm = _timegmPtr.asFunction)>(); - - int nanosleep(ffi.Pointer __rqtp, ffi.Pointer __rmtp) { - return _nanosleep(__rqtp, __rmtp); - } - - late final _nanosleepPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('nanosleep'); - late final _nanosleep = _nanosleepPtr - .asFunction, ffi.Pointer)>(); - - int clock_getres(clockid_t __clock_id, ffi.Pointer __res) { - return _clock_getres(__clock_id.value, __res); - } - - late final _clock_getresPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.UnsignedInt, ffi.Pointer) - > - >('clock_getres'); - late final _clock_getres = _clock_getresPtr - .asFunction)>(); - - int clock_gettime(clockid_t __clock_id, ffi.Pointer __tp) { - return _clock_gettime(__clock_id.value, __tp); - } +} - late final _clock_gettimePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.UnsignedInt, ffi.Pointer) - > - >('clock_gettime'); - late final _clock_gettime = _clock_gettimePtr - .asFunction)>(); +late final _sel_dataTaskWithRequest_completionHandler_ = objc.registerName( + "dataTaskWithRequest:completionHandler:", +); +final _objc_msgSend_r0bo0s = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_dataTaskWithURL_completionHandler_ = objc.registerName( + "dataTaskWithURL:completionHandler:", +); +late final _sel_uploadTaskWithRequest_fromFile_completionHandler_ = objc + .registerName("uploadTaskWithRequest:fromFile:completionHandler:"); +final _objc_msgSend_2wiv66 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_uploadTaskWithRequest_fromData_completionHandler_ = objc + .registerName("uploadTaskWithRequest:fromData:completionHandler:"); +late final _sel_uploadTaskWithResumeData_completionHandler_ = objc.registerName( + "uploadTaskWithResumeData:completionHandler:", +); - Dart__uint64_t clock_gettime_nsec_np(clockid_t __clock_id) { - return _clock_gettime_nsec_np(__clock_id.value); - } +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSURL_NSURLResponse_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + >(pointer, retain: retain, release: release); - late final _clock_gettime_nsec_npPtr = - _lookup>( - 'clock_gettime_nsec_np', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _clock_gettime_nsec_np = _clock_gettime_nsec_npPtr - .asFunction(); - - int clock_settime(clockid_t __clock_id, ffi.Pointer __tp) { - return _clock_settime(__clock_id.value, __tp); - } - - late final _clock_settimePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.UnsignedInt, ffi.Pointer) - > - >('clock_settime'); - late final _clock_settime = _clock_settimePtr - .asFunction)>(); - - int timespec_get(ffi.Pointer ts, int base) { - return _timespec_get(ts, base); - } - late final _timespec_getPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('timespec_get'); - late final _timespec_get = _timespec_getPtr - .asFunction, int)>(); - - int imaxabs(int j) { - return _imaxabs(j); - } - - late final _imaxabsPtr = - _lookup>('imaxabs'); - late final _imaxabs = _imaxabsPtr.asFunction(); - - imaxdiv_t imaxdiv(int __numer, int __denom) { - return _imaxdiv(__numer, __denom); - } - - late final _imaxdivPtr = - _lookup>( - 'imaxdiv', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + fromFunction( + void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0.address == 0 + ? null + : objc.NSURL.fromPointer(arg0, retain: true, release: true), + arg1.address == 0 + ? null + : NSURLResponse.fromPointer(arg1, retain: true, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _imaxdiv = _imaxdivPtr.asFunction(); - int strtoimax( - ffi.Pointer __nptr, - ffi.Pointer> __endptr, - int __base, - ) { - return _strtoimax(__nptr, __endptr, __base); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + listener( + void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0.address == 0 + ? null + : objc.NSURL.fromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSURLResponse.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + >(wrapper, retain: false, release: true); } - late final _strtoimaxPtr = - _lookup< - ffi.NativeFunction< - intmax_t Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ) - > - >('strtoimax'); - late final _strtoimax = _strtoimaxPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - - int strtoumax( - ffi.Pointer __nptr, - ffi.Pointer> __endptr, - int __base, - ) { - return _strtoumax(__nptr, __endptr, __base); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + blocking( + void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0.address == 0 + ? null + : objc.NSURL.fromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSURLResponse.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0.address == 0 + ? null + : objc.NSURL.fromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSURLResponse.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + >(wrapper, retain: false, release: true); } - late final _strtoumaxPtr = - _lookup< - ffi.NativeFunction< - uintmax_t Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ) - > - >('strtoumax'); - late final _strtoumax = _strtoumaxPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - - int wcstoimax( - ffi.Pointer __nptr, - ffi.Pointer> __endptr, - int __base, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _wcstoimax(__nptr, __endptr, __base); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); } - late final _wcstoimaxPtr = - _lookup< - ffi.NativeFunction< - intmax_t Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('wcstoimax'); - late final _wcstoimax = _wcstoimaxPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - - int wcstoumax( - ffi.Pointer __nptr, - ffi.Pointer> __endptr, - int __base, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _wcstoumax(__nptr, __endptr, __base); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _wcstoumaxPtr = - _lookup< - ffi.NativeFunction< - uintmax_t Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('wcstoumax'); - late final _wcstoumax = _wcstoumaxPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - - late final ffi.Pointer _kCFTypeBagCallBacks = - _lookup('kCFTypeBagCallBacks'); - - CFBagCallBacks get kCFTypeBagCallBacks => _kCFTypeBagCallBacks.ref; - - late final ffi.Pointer _kCFCopyStringBagCallBacks = - _lookup('kCFCopyStringBagCallBacks'); - - CFBagCallBacks get kCFCopyStringBagCallBacks => - _kCFCopyStringBagCallBacks.ref; - - int CFBagGetTypeID() { - return _CFBagGetTypeID(); - } - - late final _CFBagGetTypeIDPtr = - _lookup>('CFBagGetTypeID'); - late final _CFBagGetTypeID = _CFBagGetTypeIDPtr.asFunction(); - - CFBagRef CFBagCreate( - CFAllocatorRef allocator, - ffi.Pointer> values, - int numValues, - ffi.Pointer callBacks, - ) { - return _CFBagCreate(allocator, values, numValues, callBacks); - } - - late final _CFBagCreatePtr = - _lookup< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => block.ref.target + .cast< ffi.NativeFunction< - CFBagRef Function( - CFAllocatorRef, - ffi.Pointer>, - CFIndex, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) > - >('CFBagCreate'); - late final _CFBagCreate = - _CFBagCreatePtr.asFunction< - CFBagRef Function( - CFAllocatorRef, - ffi.Pointer>, - int, - ffi.Pointer, + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - CFBagRef CFBagCreateCopy(CFAllocatorRef allocator, CFBagRef theBag) { - return _CFBagCreateCopy(allocator, theBag); - } + >()(arg0, arg1, arg2); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFBagCreateCopyPtr = - _lookup>( - 'CFBagCreateCopy', +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURL_NSURLResponse_NSError$CallExtension + on + objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > { + void call(objc.NSURL? arg0, NSURLResponse? arg1, objc.NSError? arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, + arg1?.ref.pointer ?? ffi.nullptr, + arg2?.ref.pointer ?? ffi.nullptr, ); - late final _CFBagCreateCopy = - _CFBagCreateCopyPtr.asFunction< - CFBagRef Function(CFAllocatorRef, CFBagRef) - >(); - - CFMutableBagRef CFBagCreateMutable( - CFAllocatorRef allocator, - int capacity, - ffi.Pointer callBacks, - ) { - return _CFBagCreateMutable(allocator, capacity, callBacks); - } +} - late final _CFBagCreateMutablePtr = - _lookup< - ffi.NativeFunction< - CFMutableBagRef Function( - CFAllocatorRef, - CFIndex, - ffi.Pointer, - ) - > - >('CFBagCreateMutable'); - late final _CFBagCreateMutable = - _CFBagCreateMutablePtr.asFunction< - CFMutableBagRef Function( - CFAllocatorRef, - int, - ffi.Pointer, - ) - >(); +late final _sel_downloadTaskWithRequest_completionHandler_ = objc.registerName( + "downloadTaskWithRequest:completionHandler:", +); +late final _sel_downloadTaskWithURL_completionHandler_ = objc.registerName( + "downloadTaskWithURL:completionHandler:", +); +late final _sel_downloadTaskWithResumeData_completionHandler_ = objc + .registerName("downloadTaskWithResumeData:completionHandler:"); - CFMutableBagRef CFBagCreateMutableCopy( - CFAllocatorRef allocator, - int capacity, - CFBagRef theBag, - ) { - return _CFBagCreateMutableCopy(allocator, capacity, theBag); +/// NSURLSession convenience routines deliver results to +/// a completion handler block. These convenience routines +/// are not available to NSURLSessions that are configured +/// as background sessions. +/// +/// Task objects are always created in a suspended state and +/// must be sent the -resume message before they will execute. +extension NSURLSessionAsynchronousConvenience on NSURLSession { + /// data task convenience methods. These methods create tasks that + /// bypass the normal delegate calls for response and data delivery, + /// and provide a simple cancelable asynchronous interface to receiving + /// data. Errors will be returned in the NSURLErrorDomain, + /// see . The delegate, if any, will still be + /// called for authentication challenges. + NSURLSessionDataTask dataTaskWithRequest$1( + NSURLRequest request, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.dataTaskWithRequest:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_r0bo0s( + object$.ref.pointer, + _sel_dataTaskWithRequest_completionHandler_, + request.ref.pointer, + completionHandler.ref.pointer, + ); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); } - late final _CFBagCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableBagRef Function(CFAllocatorRef, CFIndex, CFBagRef) - > - >('CFBagCreateMutableCopy'); - late final _CFBagCreateMutableCopy = - _CFBagCreateMutableCopyPtr.asFunction< - CFMutableBagRef Function(CFAllocatorRef, int, CFBagRef) - >(); - - int CFBagGetCount(CFBagRef theBag) { - return _CFBagGetCount(theBag); - } - - late final _CFBagGetCountPtr = - _lookup>('CFBagGetCount'); - late final _CFBagGetCount = - _CFBagGetCountPtr.asFunction(); - - int CFBagGetCountOfValue(CFBagRef theBag, ffi.Pointer value) { - return _CFBagGetCountOfValue(theBag, value); - } - - late final _CFBagGetCountOfValuePtr = - _lookup< - ffi.NativeFunction)> - >('CFBagGetCountOfValue'); - late final _CFBagGetCountOfValue = - _CFBagGetCountOfValuePtr.asFunction< - int Function(CFBagRef, ffi.Pointer) - >(); - - int CFBagContainsValue(CFBagRef theBag, ffi.Pointer value) { - return _CFBagContainsValue(theBag, value); - } - - late final _CFBagContainsValuePtr = - _lookup< - ffi.NativeFunction)> - >('CFBagContainsValue'); - late final _CFBagContainsValue = - _CFBagContainsValuePtr.asFunction< - int Function(CFBagRef, ffi.Pointer) - >(); - - ffi.Pointer CFBagGetValue( - CFBagRef theBag, - ffi.Pointer value, - ) { - return _CFBagGetValue(theBag, value); + /// dataTaskWithURL:completionHandler: + NSURLSessionDataTask dataTaskWithURL$1( + objc.NSURL url, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.dataTaskWithURL:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_r0bo0s( + object$.ref.pointer, + _sel_dataTaskWithURL_completionHandler_, + url.ref.pointer, + completionHandler.ref.pointer, + ); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); } - late final _CFBagGetValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFBagRef, ffi.Pointer) - > - >('CFBagGetValue'); - late final _CFBagGetValue = - _CFBagGetValuePtr.asFunction< - ffi.Pointer Function(CFBagRef, ffi.Pointer) - >(); - - int CFBagGetValueIfPresent( - CFBagRef theBag, - ffi.Pointer candidate, - ffi.Pointer> value, - ) { - return _CFBagGetValueIfPresent(theBag, candidate, value); + /// download task convenience methods. When a download successfully + /// completes, the NSURL will point to a file that must be read or + /// copied during the invocation of the completion routine. The file + /// will be removed automatically. + NSURLSessionDownloadTask downloadTaskWithRequest$1( + NSURLRequest request, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.downloadTaskWithRequest:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_r0bo0s( + object$.ref.pointer, + _sel_downloadTaskWithRequest_completionHandler_, + request.ref.pointer, + completionHandler.ref.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBagGetValueIfPresentPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFBagRef, - ffi.Pointer, - ffi.Pointer>, - ) - > - >('CFBagGetValueIfPresent'); - late final _CFBagGetValueIfPresent = - _CFBagGetValueIfPresentPtr.asFunction< - int Function( - CFBagRef, - ffi.Pointer, - ffi.Pointer>, - ) - >(); - - void CFBagGetValues( - CFBagRef theBag, - ffi.Pointer> values, - ) { - return _CFBagGetValues(theBag, values); + /// downloadTaskWithResumeData:completionHandler: + NSURLSessionDownloadTask downloadTaskWithResumeData$1( + objc.NSData resumeData, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.downloadTaskWithResumeData:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_r0bo0s( + object$.ref.pointer, + _sel_downloadTaskWithResumeData_completionHandler_, + resumeData.ref.pointer, + completionHandler.ref.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBagGetValuesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFBagRef, ffi.Pointer>) - > - >('CFBagGetValues'); - late final _CFBagGetValues = - _CFBagGetValuesPtr.asFunction< - void Function(CFBagRef, ffi.Pointer>) - >(); - - void CFBagApplyFunction( - CFBagRef theBag, - CFBagApplierFunction applier, - ffi.Pointer context, - ) { - return _CFBagApplyFunction(theBag, applier, context); + /// downloadTaskWithURL:completionHandler: + NSURLSessionDownloadTask downloadTaskWithURL$1( + objc.NSURL url, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.downloadTaskWithURL:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_r0bo0s( + object$.ref.pointer, + _sel_downloadTaskWithURL_completionHandler_, + url.ref.pointer, + completionHandler.ref.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBagApplyFunctionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFBagRef, - CFBagApplierFunction, - ffi.Pointer, - ) - > - >('CFBagApplyFunction'); - late final _CFBagApplyFunction = - _CFBagApplyFunctionPtr.asFunction< - void Function(CFBagRef, CFBagApplierFunction, ffi.Pointer) - >(); - - void CFBagAddValue(CFMutableBagRef theBag, ffi.Pointer value) { - return _CFBagAddValue(theBag, value); + /// uploadTaskWithRequest:fromData:completionHandler: + NSURLSessionUploadTask uploadTaskWithRequest$2( + NSURLRequest request, { + objc.NSData? fromData, + required objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.uploadTaskWithRequest:fromData:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_2wiv66( + object$.ref.pointer, + _sel_uploadTaskWithRequest_fromData_completionHandler_, + request.ref.pointer, + fromData?.ref.pointer ?? ffi.nullptr, + completionHandler.ref.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBagAddValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableBagRef, ffi.Pointer) - > - >('CFBagAddValue'); - late final _CFBagAddValue = - _CFBagAddValuePtr.asFunction< - void Function(CFMutableBagRef, ffi.Pointer) - >(); - - void CFBagReplaceValue(CFMutableBagRef theBag, ffi.Pointer value) { - return _CFBagReplaceValue(theBag, value); + /// upload convenience method. + NSURLSessionUploadTask uploadTaskWithRequest$3( + NSURLRequest request, { + required objc.NSURL fromFile, + required objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.uploadTaskWithRequest:fromFile:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_2wiv66( + object$.ref.pointer, + _sel_uploadTaskWithRequest_fromFile_completionHandler_, + request.ref.pointer, + fromFile.ref.pointer, + completionHandler.ref.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBagReplaceValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableBagRef, ffi.Pointer) - > - >('CFBagReplaceValue'); - late final _CFBagReplaceValue = - _CFBagReplaceValuePtr.asFunction< - void Function(CFMutableBagRef, ffi.Pointer) - >(); - - void CFBagSetValue(CFMutableBagRef theBag, ffi.Pointer value) { - return _CFBagSetValue(theBag, value); + /// Creates a URLSessionUploadTask from a resume data blob. If resuming from an upload + /// file, the file must still exist and be unmodified. + /// + /// - Parameter resumeData: Resume data blob from an incomplete upload, such as data returned by the cancelByProducingResumeData: method. + /// - Parameter completionHandler: The completion handler to call when the load request is complete. + /// - Returns: A new session upload task, or nil if the resumeData is invalid. + NSURLSessionUploadTask uploadTaskWithResumeData$1( + objc.NSData resumeData, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.uploadTaskWithResumeData:completionHandler:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + final $ret = _objc_msgSend_r0bo0s( + object$.ref.pointer, + _sel_uploadTaskWithResumeData_completionHandler_, + resumeData.ref.pointer, + completionHandler.ref.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } +} - late final _CFBagSetValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableBagRef, ffi.Pointer) - > - >('CFBagSetValue'); - late final _CFBagSetValue = - _CFBagSetValuePtr.asFunction< - void Function(CFMutableBagRef, ffi.Pointer) - >(); - - void CFBagRemoveValue(CFMutableBagRef theBag, ffi.Pointer value) { - return _CFBagRemoveValue(theBag, value); +/// NSURLSession is a replacement API for NSURLConnection. It provides +/// options that affect the policy of, and various aspects of the +/// mechanism by which NSURLRequest objects are retrieved from the +/// network. +/// +/// An NSURLSession may be bound to a delegate object. The delegate is +/// invoked for certain events during the lifetime of a session, such as +/// server authentication or determining whether a resource to be loaded +/// should be converted into a download. +/// +/// NSURLSession instances are thread-safe. +/// +/// The default NSURLSession uses a system provided delegate and is +/// appropriate to use in place of existing code that uses +/// +[NSURLConnection sendAsynchronousRequest:queue:completionHandler:] +/// +/// An NSURLSession creates NSURLSessionTask objects which represent the +/// action of a resource being loaded. These are analogous to +/// NSURLConnection objects but provide for more control and a unified +/// delegate model. +/// +/// NSURLSessionTask objects are always created in a suspended state and +/// must be sent the -resume message before they will execute. +/// +/// Subclasses of NSURLSessionTask are used to syntactically +/// differentiate between data and file downloads. +/// +/// An NSURLSessionDataTask receives the resource as a series of calls to +/// the URLSession:dataTask:didReceiveData: delegate method. This is type of +/// task most commonly associated with retrieving objects for immediate parsing +/// by the consumer. +/// +/// An NSURLSessionUploadTask differs from an NSURLSessionDataTask +/// in how its instance is constructed. Upload tasks are explicitly created +/// by referencing a file or data object to upload, or by utilizing the +/// -URLSession:task:needNewBodyStream: delegate message to supply an upload +/// body. +/// +/// An NSURLSessionDownloadTask will directly write the response data to +/// a temporary file. When completed, the delegate is sent +/// URLSession:downloadTask:didFinishDownloadingToURL: and given an opportunity +/// to move this file to a permanent location in its sandboxed container, or to +/// otherwise read the file. If canceled, an NSURLSessionDownloadTask can +/// produce a data blob that can be used to resume a download at a later +/// time. +/// +/// Beginning with iOS 9 and Mac OS X 10.11, NSURLSessionStream is +/// available as a task type. This allows for direct TCP/IP connection +/// to a given host and port with optional secure handshaking and +/// navigation of proxies. Data tasks may also be upgraded to a +/// NSURLSessionStream task via the HTTP Upgrade: header and appropriate +/// use of the pipelining option of NSURLSessionConfiguration. See RFC +/// 2817 and RFC 6455 for information about the Upgrade: header, and +/// comments below on turning data tasks into stream tasks. +/// +/// An NSURLSessionWebSocketTask is a task that allows clients to connect to servers supporting +/// WebSocket. The task will perform the HTTP handshake to upgrade the connection +/// and once the WebSocket handshake is successful, the client can read and write +/// messages that will be framed using the WebSocket protocol by the framework. +extension type NSURLSession._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [NSURLSession] that points to the same underlying object as [other]. + NSURLSession.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSession', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + assert(isA(object$)); } - late final _CFBagRemoveValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableBagRef, ffi.Pointer) - > - >('CFBagRemoveValue'); - late final _CFBagRemoveValue = - _CFBagRemoveValuePtr.asFunction< - void Function(CFMutableBagRef, ffi.Pointer) - >(); - - void CFBagRemoveAllValues(CFMutableBagRef theBag) { - return _CFBagRemoveAllValues(theBag); + /// Constructs a [NSURLSession] that wraps the given raw object pointer. + NSURLSession.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSession', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + assert(isA(object$)); } - late final _CFBagRemoveAllValuesPtr = - _lookup>( - 'CFBagRemoveAllValues', - ); - late final _CFBagRemoveAllValues = - _CFBagRemoveAllValuesPtr.asFunction(); - - late final ffi.Pointer _kCFStringBinaryHeapCallBacks = - _lookup('kCFStringBinaryHeapCallBacks'); - - CFBinaryHeapCallBacks get kCFStringBinaryHeapCallBacks => - _kCFStringBinaryHeapCallBacks.ref; + /// Returns whether [obj] is an instance of [NSURLSession]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSession, + ); - int CFBinaryHeapGetTypeID() { - return _CFBinaryHeapGetTypeID(); + /// alloc + static NSURLSession alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSURLSession, _sel_alloc); + return NSURLSession.fromPointer($ret, retain: false, release: true); } - late final _CFBinaryHeapGetTypeIDPtr = - _lookup>('CFBinaryHeapGetTypeID'); - late final _CFBinaryHeapGetTypeID = - _CFBinaryHeapGetTypeIDPtr.asFunction(); - - CFBinaryHeapRef CFBinaryHeapCreate( - CFAllocatorRef allocator, - int capacity, - ffi.Pointer callBacks, - ffi.Pointer compareContext, - ) { - return _CFBinaryHeapCreate(allocator, capacity, callBacks, compareContext); + /// allocWithZone: + static NSURLSession allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSession, + _sel_allocWithZone_, + zone, + ); + return NSURLSession.fromPointer($ret, retain: false, release: true); } - late final _CFBinaryHeapCreatePtr = - _lookup< - ffi.NativeFunction< - CFBinaryHeapRef Function( - CFAllocatorRef, - CFIndex, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFBinaryHeapCreate'); - late final _CFBinaryHeapCreate = - _CFBinaryHeapCreatePtr.asFunction< - CFBinaryHeapRef Function( - CFAllocatorRef, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); + /// new + static NSURLSession new$() { + final $ret = _objc_msgSend_151sglz(_class_NSURLSession, _sel_new); + return NSURLSession.fromPointer($ret, retain: false, release: true); + } - CFBinaryHeapRef CFBinaryHeapCreateCopy( - CFAllocatorRef allocator, - int capacity, - CFBinaryHeapRef heap, + /// Customization of NSURLSession occurs during creation of a new session. + /// If you only need to use the convenience routines with custom + /// configuration options it is not necessary to specify a delegate. + /// If you do specify a delegate, the delegate will be retained until after + /// the delegate has been sent the URLSession:didBecomeInvalidWithError: message. + static NSURLSession sessionWithConfiguration( + NSURLSessionConfiguration configuration, ) { - return _CFBinaryHeapCreateCopy(allocator, capacity, heap); + objc.checkOsVersionInternal( + 'NSURLSession.sessionWithConfiguration:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _class_NSURLSession, + _sel_sessionWithConfiguration_, + configuration.ref.pointer, + ); + return NSURLSession.fromPointer($ret, retain: true, release: true); } - late final _CFBinaryHeapCreateCopyPtr = - _lookup< - ffi.NativeFunction< - CFBinaryHeapRef Function(CFAllocatorRef, CFIndex, CFBinaryHeapRef) - > - >('CFBinaryHeapCreateCopy'); - late final _CFBinaryHeapCreateCopy = - _CFBinaryHeapCreateCopyPtr.asFunction< - CFBinaryHeapRef Function(CFAllocatorRef, int, CFBinaryHeapRef) - >(); - - int CFBinaryHeapGetCount(CFBinaryHeapRef heap) { - return _CFBinaryHeapGetCount(heap); + /// sessionWithConfiguration:delegate:delegateQueue: + static NSURLSession sessionWithConfiguration$1( + NSURLSessionConfiguration configuration, { + NSURLSessionDelegate? delegate, + NSOperationQueue? delegateQueue, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.sessionWithConfiguration:delegate:delegateQueue:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_11spmsz( + _class_NSURLSession, + _sel_sessionWithConfiguration_delegate_delegateQueue_, + configuration.ref.pointer, + delegate?.ref.pointer ?? ffi.nullptr, + delegateQueue?.ref.pointer ?? ffi.nullptr, + ); + return NSURLSession.fromPointer($ret, retain: true, release: true); } - late final _CFBinaryHeapGetCountPtr = - _lookup>( - 'CFBinaryHeapGetCount', - ); - late final _CFBinaryHeapGetCount = - _CFBinaryHeapGetCountPtr.asFunction(); - - int CFBinaryHeapGetCountOfValue( - CFBinaryHeapRef heap, - ffi.Pointer value, - ) { - return _CFBinaryHeapGetCountOfValue(heap, value); + /// The shared session uses the currently set global NSURLCache, + /// NSHTTPCookieStorage and NSURLCredentialStorage objects. + static NSURLSession getSharedSession() { + objc.checkOsVersionInternal( + 'NSURLSession.sharedSession', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(_class_NSURLSession, _sel_sharedSession); + return NSURLSession.fromPointer($ret, retain: true, release: true); } - late final _CFBinaryHeapGetCountOfValuePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFBinaryHeapRef, ffi.Pointer) - > - >('CFBinaryHeapGetCountOfValue'); - late final _CFBinaryHeapGetCountOfValue = - _CFBinaryHeapGetCountOfValuePtr.asFunction< - int Function(CFBinaryHeapRef, ffi.Pointer) - >(); - - int CFBinaryHeapContainsValue( - CFBinaryHeapRef heap, - ffi.Pointer value, - ) { - return _CFBinaryHeapContainsValue(heap, value); - } + /// Returns a new instance of NSURLSession constructed with the default `new` method. + NSURLSession() : this.as(new$().object$); +} - late final _CFBinaryHeapContainsValuePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFBinaryHeapRef, ffi.Pointer) - > - >('CFBinaryHeapContainsValue'); - late final _CFBinaryHeapContainsValue = - _CFBinaryHeapContainsValuePtr.asFunction< - int Function(CFBinaryHeapRef, ffi.Pointer) - >(); - - ffi.Pointer CFBinaryHeapGetMinimum(CFBinaryHeapRef heap) { - return _CFBinaryHeapGetMinimum(heap); - } - - late final _CFBinaryHeapGetMinimumPtr = - _lookup< - ffi.NativeFunction Function(CFBinaryHeapRef)> - >('CFBinaryHeapGetMinimum'); - late final _CFBinaryHeapGetMinimum = - _CFBinaryHeapGetMinimumPtr.asFunction< - ffi.Pointer Function(CFBinaryHeapRef) - >(); - - int CFBinaryHeapGetMinimumIfPresent( - CFBinaryHeapRef heap, - ffi.Pointer> value, - ) { - return _CFBinaryHeapGetMinimumIfPresent(heap, value); +extension NSURLSession$Methods on NSURLSession { + /// configuration + NSURLSessionConfiguration get configuration { + objc.checkOsVersionInternal( + 'NSURLSession.configuration', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_configuration); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBinaryHeapGetMinimumIfPresentPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFBinaryHeapRef, ffi.Pointer>) - > - >('CFBinaryHeapGetMinimumIfPresent'); - late final _CFBinaryHeapGetMinimumIfPresent = - _CFBinaryHeapGetMinimumIfPresentPtr.asFunction< - int Function(CFBinaryHeapRef, ffi.Pointer>) - >(); - - void CFBinaryHeapGetValues( - CFBinaryHeapRef heap, - ffi.Pointer> values, - ) { - return _CFBinaryHeapGetValues(heap, values); + /// Creates a data task with the given request. The request may have a body stream. + NSURLSessionDataTask dataTaskWithRequest(NSURLRequest request) { + objc.checkOsVersionInternal( + 'NSURLSession.dataTaskWithRequest:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_dataTaskWithRequest_, + request.ref.pointer, + ); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); } - late final _CFBinaryHeapGetValuesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFBinaryHeapRef, ffi.Pointer>) - > - >('CFBinaryHeapGetValues'); - late final _CFBinaryHeapGetValues = - _CFBinaryHeapGetValuesPtr.asFunction< - void Function(CFBinaryHeapRef, ffi.Pointer>) - >(); - - void CFBinaryHeapApplyFunction( - CFBinaryHeapRef heap, - CFBinaryHeapApplierFunction applier, - ffi.Pointer context, - ) { - return _CFBinaryHeapApplyFunction(heap, applier, context); + /// Creates a data task to retrieve the contents of the given URL. + NSURLSessionDataTask dataTaskWithURL(objc.NSURL url) { + objc.checkOsVersionInternal( + 'NSURLSession.dataTaskWithURL:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_dataTaskWithURL_, + url.ref.pointer, + ); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); } - late final _CFBinaryHeapApplyFunctionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFBinaryHeapRef, - CFBinaryHeapApplierFunction, - ffi.Pointer, - ) - > - >('CFBinaryHeapApplyFunction'); - late final _CFBinaryHeapApplyFunction = - _CFBinaryHeapApplyFunctionPtr.asFunction< - void Function( - CFBinaryHeapRef, - CFBinaryHeapApplierFunction, - ffi.Pointer, - ) - >(); - - void CFBinaryHeapAddValue(CFBinaryHeapRef heap, ffi.Pointer value) { - return _CFBinaryHeapAddValue(heap, value); + /// delegate + NSURLSessionDelegate? get delegate { + objc.checkOsVersionInternal( + 'NSURLSession.delegate', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_delegate); + return $ret.address == 0 + ? null + : NSURLSessionDelegate.fromPointer($ret, retain: true, release: true); } - late final _CFBinaryHeapAddValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFBinaryHeapRef, ffi.Pointer) - > - >('CFBinaryHeapAddValue'); - late final _CFBinaryHeapAddValue = - _CFBinaryHeapAddValuePtr.asFunction< - void Function(CFBinaryHeapRef, ffi.Pointer) - >(); - - void CFBinaryHeapRemoveMinimumValue(CFBinaryHeapRef heap) { - return _CFBinaryHeapRemoveMinimumValue(heap); + /// delegateQueue + NSOperationQueue get delegateQueue { + objc.checkOsVersionInternal( + 'NSURLSession.delegateQueue', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_delegateQueue); + return NSOperationQueue.fromPointer($ret, retain: true, release: true); } - late final _CFBinaryHeapRemoveMinimumValuePtr = - _lookup>( - 'CFBinaryHeapRemoveMinimumValue', - ); - late final _CFBinaryHeapRemoveMinimumValue = - _CFBinaryHeapRemoveMinimumValuePtr.asFunction< - void Function(CFBinaryHeapRef) - >(); - - void CFBinaryHeapRemoveAllValues(CFBinaryHeapRef heap) { - return _CFBinaryHeapRemoveAllValues(heap); + /// Creates a download task with the given request. + NSURLSessionDownloadTask downloadTaskWithRequest(NSURLRequest request) { + objc.checkOsVersionInternal( + 'NSURLSession.downloadTaskWithRequest:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_downloadTaskWithRequest_, + request.ref.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBinaryHeapRemoveAllValuesPtr = - _lookup>( - 'CFBinaryHeapRemoveAllValues', - ); - late final _CFBinaryHeapRemoveAllValues = - _CFBinaryHeapRemoveAllValuesPtr.asFunction< - void Function(CFBinaryHeapRef) - >(); - - int CFBitVectorGetTypeID() { - return _CFBitVectorGetTypeID(); + /// Creates a download task with the resume data. If the download cannot be successfully resumed, URLSession:task:didCompleteWithError: will be called. + NSURLSessionDownloadTask downloadTaskWithResumeData(objc.NSData resumeData) { + objc.checkOsVersionInternal( + 'NSURLSession.downloadTaskWithResumeData:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_downloadTaskWithResumeData_, + resumeData.ref.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBitVectorGetTypeIDPtr = - _lookup>('CFBitVectorGetTypeID'); - late final _CFBitVectorGetTypeID = - _CFBitVectorGetTypeIDPtr.asFunction(); - - CFBitVectorRef CFBitVectorCreate( - CFAllocatorRef allocator, - ffi.Pointer bytes, - int numBits, - ) { - return _CFBitVectorCreate(allocator, bytes, numBits); + /// Creates a download task to download the contents of the given URL. + NSURLSessionDownloadTask downloadTaskWithURL(objc.NSURL url) { + objc.checkOsVersionInternal( + 'NSURLSession.downloadTaskWithURL:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_downloadTaskWithURL_, + url.ref.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBitVectorCreatePtr = - _lookup< - ffi.NativeFunction< - CFBitVectorRef Function(CFAllocatorRef, ffi.Pointer, CFIndex) - > - >('CFBitVectorCreate'); - late final _CFBitVectorCreate = - _CFBitVectorCreatePtr.asFunction< - CFBitVectorRef Function(CFAllocatorRef, ffi.Pointer, int) - >(); - - CFBitVectorRef CFBitVectorCreateCopy( - CFAllocatorRef allocator, - CFBitVectorRef bv, - ) { - return _CFBitVectorCreateCopy(allocator, bv); + /// -finishTasksAndInvalidate returns immediately and existing tasks will be allowed + /// to run to completion. New tasks may not be created. The session + /// will continue to make delegate callbacks until URLSession:didBecomeInvalidWithError: + /// has been issued. + /// + /// -finishTasksAndInvalidate and -invalidateAndCancel do not + /// have any effect on the shared session instance. + /// + /// When invalidating a background session, it is not safe to create another background + /// session with the same identifier until URLSession:didBecomeInvalidWithError: has + /// been issued. + void finishTasksAndInvalidate() { + objc.checkOsVersionInternal( + 'NSURLSession.finishTasksAndInvalidate', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_finishTasksAndInvalidate); } - late final _CFBitVectorCreateCopyPtr = - _lookup< - ffi.NativeFunction< - CFBitVectorRef Function(CFAllocatorRef, CFBitVectorRef) - > - >('CFBitVectorCreateCopy'); - late final _CFBitVectorCreateCopy = - _CFBitVectorCreateCopyPtr.asFunction< - CFBitVectorRef Function(CFAllocatorRef, CFBitVectorRef) - >(); - - CFMutableBitVectorRef CFBitVectorCreateMutable( - CFAllocatorRef allocator, - int capacity, + /// flush storage to disk and clear transient network caches. Invokes completionHandler() on the delegate queue. + void flushWithCompletionHandler( + objc.ObjCBlock completionHandler, ) { - return _CFBitVectorCreateMutable(allocator, capacity); + objc.checkOsVersionInternal( + 'NSURLSession.flushWithCompletionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_flushWithCompletionHandler_, + completionHandler.ref.pointer, + ); } - late final _CFBitVectorCreateMutablePtr = - _lookup< - ffi.NativeFunction< - CFMutableBitVectorRef Function(CFAllocatorRef, CFIndex) - > - >('CFBitVectorCreateMutable'); - late final _CFBitVectorCreateMutable = - _CFBitVectorCreateMutablePtr.asFunction< - CFMutableBitVectorRef Function(CFAllocatorRef, int) - >(); - - CFMutableBitVectorRef CFBitVectorCreateMutableCopy( - CFAllocatorRef allocator, - int capacity, - CFBitVectorRef bv, + /// invokes completionHandler with all outstanding tasks. + void getAllTasksWithCompletionHandler( + objc.ObjCBlock completionHandler, ) { - return _CFBitVectorCreateMutableCopy(allocator, capacity, bv); - } - - late final _CFBitVectorCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableBitVectorRef Function( - CFAllocatorRef, - CFIndex, - CFBitVectorRef, - ) - > - >('CFBitVectorCreateMutableCopy'); - late final _CFBitVectorCreateMutableCopy = - _CFBitVectorCreateMutableCopyPtr.asFunction< - CFMutableBitVectorRef Function(CFAllocatorRef, int, CFBitVectorRef) - >(); - - int CFBitVectorGetCount(CFBitVectorRef bv) { - return _CFBitVectorGetCount(bv); + objc.checkOsVersionInternal( + 'NSURLSession.getAllTasksWithCompletionHandler:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_getAllTasksWithCompletionHandler_, + completionHandler.ref.pointer, + ); } - late final _CFBitVectorGetCountPtr = - _lookup>( - 'CFBitVectorGetCount', - ); - late final _CFBitVectorGetCount = - _CFBitVectorGetCountPtr.asFunction(); - - int CFBitVectorGetCountOfBit(CFBitVectorRef bv, CFRange range, int value) { - return _CFBitVectorGetCountOfBit(bv, range, value); + /// invokes completionHandler with outstanding data, upload and download tasks. + void getTasksWithCompletionHandler( + objc.ObjCBlock + completionHandler, + ) { + objc.checkOsVersionInternal( + 'NSURLSession.getTasksWithCompletionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_getTasksWithCompletionHandler_, + completionHandler.ref.pointer, + ); } - late final _CFBitVectorGetCountOfBitPtr = - _lookup< - ffi.NativeFunction - >('CFBitVectorGetCountOfBit'); - late final _CFBitVectorGetCountOfBit = - _CFBitVectorGetCountOfBitPtr.asFunction< - int Function(CFBitVectorRef, CFRange, int) - >(); - - int CFBitVectorContainsBit(CFBitVectorRef bv, CFRange range, int value) { - return _CFBitVectorContainsBit(bv, range, value); + /// init + NSURLSession init() { + objc.checkOsVersionInternal( + 'NSURLSession.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSURLSession.fromPointer($ret, retain: false, release: true); } - late final _CFBitVectorContainsBitPtr = - _lookup< - ffi.NativeFunction - >('CFBitVectorContainsBit'); - late final _CFBitVectorContainsBit = - _CFBitVectorContainsBitPtr.asFunction< - int Function(CFBitVectorRef, CFRange, int) - >(); - - int CFBitVectorGetBitAtIndex(CFBitVectorRef bv, int idx) { - return _CFBitVectorGetBitAtIndex(bv, idx); + /// -invalidateAndCancel acts as -finishTasksAndInvalidate, but issues + /// -cancel to all outstanding tasks for this session. Note task + /// cancellation is subject to the state of the task, and some tasks may + /// have already have completed at the time they are sent -cancel. + void invalidateAndCancel() { + objc.checkOsVersionInternal( + 'NSURLSession.invalidateAndCancel', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_invalidateAndCancel); } - late final _CFBitVectorGetBitAtIndexPtr = - _lookup>( - 'CFBitVectorGetBitAtIndex', - ); - late final _CFBitVectorGetBitAtIndex = - _CFBitVectorGetBitAtIndexPtr.asFunction< - int Function(CFBitVectorRef, int) - >(); - - void CFBitVectorGetBits( - CFBitVectorRef bv, - CFRange range, - ffi.Pointer bytes, + /// empty all cookies, cache and credential stores, removes disk files, issues -flushWithCompletionHandler:. Invokes completionHandler() on the delegate queue. + void resetWithCompletionHandler( + objc.ObjCBlock completionHandler, ) { - return _CFBitVectorGetBits(bv, range, bytes); + objc.checkOsVersionInternal( + 'NSURLSession.resetWithCompletionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_f167m6( + object$.ref.pointer, + _sel_resetWithCompletionHandler_, + completionHandler.ref.pointer, + ); } - late final _CFBitVectorGetBitsPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFBitVectorRef, CFRange, ffi.Pointer) - > - >('CFBitVectorGetBits'); - late final _CFBitVectorGetBits = - _CFBitVectorGetBitsPtr.asFunction< - void Function(CFBitVectorRef, CFRange, ffi.Pointer) - >(); - - int CFBitVectorGetFirstIndexOfBit( - CFBitVectorRef bv, - CFRange range, - int value, - ) { - return _CFBitVectorGetFirstIndexOfBit(bv, range, value); - } - - late final _CFBitVectorGetFirstIndexOfBitPtr = - _lookup< - ffi.NativeFunction - >('CFBitVectorGetFirstIndexOfBit'); - late final _CFBitVectorGetFirstIndexOfBit = - _CFBitVectorGetFirstIndexOfBitPtr.asFunction< - int Function(CFBitVectorRef, CFRange, int) - >(); - - int CFBitVectorGetLastIndexOfBit( - CFBitVectorRef bv, - CFRange range, - int value, - ) { - return _CFBitVectorGetLastIndexOfBit(bv, range, value); + /// The sessionDescription property is available for the developer to + /// provide a descriptive label for the session. + objc.NSString? get sessionDescription { + objc.checkOsVersionInternal( + 'NSURLSession.sessionDescription', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_sessionDescription, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _CFBitVectorGetLastIndexOfBitPtr = - _lookup< - ffi.NativeFunction - >('CFBitVectorGetLastIndexOfBit'); - late final _CFBitVectorGetLastIndexOfBit = - _CFBitVectorGetLastIndexOfBitPtr.asFunction< - int Function(CFBitVectorRef, CFRange, int) - >(); - - void CFBitVectorSetCount(CFMutableBitVectorRef bv, int count) { - return _CFBitVectorSetCount(bv, count); + /// The sessionDescription property is available for the developer to + /// provide a descriptive label for the session. + set sessionDescription(objc.NSString? value) { + objc.checkOsVersionInternal( + 'NSURLSession.setSessionDescription:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setSessionDescription_, + value?.ref.pointer ?? ffi.nullptr, + ); } - late final _CFBitVectorSetCountPtr = - _lookup< - ffi.NativeFunction - >('CFBitVectorSetCount'); - late final _CFBitVectorSetCount = - _CFBitVectorSetCountPtr.asFunction< - void Function(CFMutableBitVectorRef, int) - >(); - - void CFBitVectorFlipBitAtIndex(CFMutableBitVectorRef bv, int idx) { - return _CFBitVectorFlipBitAtIndex(bv, idx); + /// Creates a bidirectional stream task to a given host and port. + NSURLSessionStreamTask streamTaskWithHostName( + objc.NSString hostname, { + required int port, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.streamTaskWithHostName:port:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); + final $ret = _objc_msgSend_9slupp( + object$.ref.pointer, + _sel_streamTaskWithHostName_port_, + hostname.ref.pointer, + port, + ); + return NSURLSessionStreamTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBitVectorFlipBitAtIndexPtr = - _lookup< - ffi.NativeFunction - >('CFBitVectorFlipBitAtIndex'); - late final _CFBitVectorFlipBitAtIndex = - _CFBitVectorFlipBitAtIndexPtr.asFunction< - void Function(CFMutableBitVectorRef, int) - >(); - - void CFBitVectorFlipBits(CFMutableBitVectorRef bv, CFRange range) { - return _CFBitVectorFlipBits(bv, range); + /// Creates a bidirectional stream task with an NSNetService to identify the endpoint. + /// The NSNetService will be resolved before any IO completes. + NSURLSessionStreamTask streamTaskWithNetService(NSNetService service) { + objc.checkOsVersionInternal( + 'NSURLSession.streamTaskWithNetService:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_streamTaskWithNetService_, + service.ref.pointer, + ); + return NSURLSessionStreamTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBitVectorFlipBitsPtr = - _lookup< - ffi.NativeFunction - >('CFBitVectorFlipBits'); - late final _CFBitVectorFlipBits = - _CFBitVectorFlipBitsPtr.asFunction< - void Function(CFMutableBitVectorRef, CFRange) - >(); - - void CFBitVectorSetBitAtIndex(CFMutableBitVectorRef bv, int idx, int value) { - return _CFBitVectorSetBitAtIndex(bv, idx, value); + /// Creates an upload task with the given request. The body of the request is provided from the bodyData. + NSURLSessionUploadTask uploadTaskWithRequest( + NSURLRequest request, { + required objc.NSData fromData, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.uploadTaskWithRequest:fromData:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_15qeuct( + object$.ref.pointer, + _sel_uploadTaskWithRequest_fromData_, + request.ref.pointer, + fromData.ref.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBitVectorSetBitAtIndexPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableBitVectorRef, CFIndex, CFBit) - > - >('CFBitVectorSetBitAtIndex'); - late final _CFBitVectorSetBitAtIndex = - _CFBitVectorSetBitAtIndexPtr.asFunction< - void Function(CFMutableBitVectorRef, int, int) - >(); - - void CFBitVectorSetBits(CFMutableBitVectorRef bv, CFRange range, int value) { - return _CFBitVectorSetBits(bv, range, value); + /// Creates an upload task with the given request. The body of the request will be created from the file referenced by fileURL + NSURLSessionUploadTask uploadTaskWithRequest$1( + NSURLRequest request, { + required objc.NSURL fromFile, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.uploadTaskWithRequest:fromFile:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_15qeuct( + object$.ref.pointer, + _sel_uploadTaskWithRequest_fromFile_, + request.ref.pointer, + fromFile.ref.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFBitVectorSetBitsPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableBitVectorRef, CFRange, CFBit) - > - >('CFBitVectorSetBits'); - late final _CFBitVectorSetBits = - _CFBitVectorSetBitsPtr.asFunction< - void Function(CFMutableBitVectorRef, CFRange, int) - >(); - - void CFBitVectorSetAllBits(CFMutableBitVectorRef bv, int value) { - return _CFBitVectorSetAllBits(bv, value); - } - - late final _CFBitVectorSetAllBitsPtr = - _lookup< - ffi.NativeFunction - >('CFBitVectorSetAllBits'); - late final _CFBitVectorSetAllBits = - _CFBitVectorSetAllBitsPtr.asFunction< - void Function(CFMutableBitVectorRef, int) - >(); - - late final ffi.Pointer - _kCFTypeDictionaryKeyCallBacks = _lookup( - 'kCFTypeDictionaryKeyCallBacks', - ); - - CFDictionaryKeyCallBacks get kCFTypeDictionaryKeyCallBacks => - _kCFTypeDictionaryKeyCallBacks.ref; - - late final ffi.Pointer - _kCFCopyStringDictionaryKeyCallBacks = _lookup( - 'kCFCopyStringDictionaryKeyCallBacks', - ); - - CFDictionaryKeyCallBacks get kCFCopyStringDictionaryKeyCallBacks => - _kCFCopyStringDictionaryKeyCallBacks.ref; - - late final ffi.Pointer - _kCFTypeDictionaryValueCallBacks = _lookup( - 'kCFTypeDictionaryValueCallBacks', - ); - - CFDictionaryValueCallBacks get kCFTypeDictionaryValueCallBacks => - _kCFTypeDictionaryValueCallBacks.ref; - - int CFDictionaryGetTypeID() { - return _CFDictionaryGetTypeID(); + /// Creates an upload task from a resume data blob. Requires the server to support the latest resumable uploads + /// Internet-Draft from the HTTP Working Group, found at + /// https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/ + /// If resuming from an upload file, the file must still exist and be unmodified. If the upload cannot be successfully + /// resumed, URLSession:task:didCompleteWithError: will be called. + /// + /// - Parameter resumeData: Resume data blob from an incomplete upload, such as data returned by the cancelByProducingResumeData: method. + /// - Returns: A new session upload task, or nil if the resumeData is invalid. + NSURLSessionUploadTask uploadTaskWithResumeData(objc.NSData resumeData) { + objc.checkOsVersionInternal( + 'NSURLSession.uploadTaskWithResumeData:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_uploadTaskWithResumeData_, + resumeData.ref.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFDictionaryGetTypeIDPtr = - _lookup>('CFDictionaryGetTypeID'); - late final _CFDictionaryGetTypeID = - _CFDictionaryGetTypeIDPtr.asFunction(); - - CFDictionaryRef CFDictionaryCreate( - CFAllocatorRef allocator, - ffi.Pointer> keys, - ffi.Pointer> values, - int numValues, - ffi.Pointer keyCallBacks, - ffi.Pointer valueCallBacks, - ) { - return _CFDictionaryCreate( - allocator, - keys, - values, - numValues, - keyCallBacks, - valueCallBacks, + /// Creates an upload task with the given request. The previously set body stream of the request (if any) is ignored and the URLSession:task:needNewBodyStream: delegate will be called when the body payload is required. + NSURLSessionUploadTask uploadTaskWithStreamedRequest(NSURLRequest request) { + objc.checkOsVersionInternal( + 'NSURLSession.uploadTaskWithStreamedRequest:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_uploadTaskWithStreamedRequest_, + request.ref.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - late final _CFDictionaryCreatePtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function( - CFAllocatorRef, - ffi.Pointer>, - ffi.Pointer>, - CFIndex, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFDictionaryCreate'); - late final _CFDictionaryCreate = - _CFDictionaryCreatePtr.asFunction< - CFDictionaryRef Function( - CFAllocatorRef, - ffi.Pointer>, - ffi.Pointer>, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFDictionaryRef CFDictionaryCreateCopy( - CFAllocatorRef allocator, - CFDictionaryRef theDict, - ) { - return _CFDictionaryCreateCopy(allocator, theDict); + /// Creates a WebSocket task given the request. The request properties can be modified and will be used by the task during the HTTP handshake phase. + /// Clients who want to add custom protocols can do so by directly adding headers with the key Sec-WebSocket-Protocol + /// and a comma separated list of protocols they wish to negotiate with the server. The custom HTTP headers provided by the client will remain unchanged for the handshake with the server. + NSURLSessionWebSocketTask webSocketTaskWithRequest(NSURLRequest request) { + objc.checkOsVersionInternal( + 'NSURLSession.webSocketTaskWithRequest:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_webSocketTaskWithRequest_, + request.ref.pointer, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: true, + release: true, + ); } - late final _CFDictionaryCreateCopyPtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function(CFAllocatorRef, CFDictionaryRef) - > - >('CFDictionaryCreateCopy'); - late final _CFDictionaryCreateCopy = - _CFDictionaryCreateCopyPtr.asFunction< - CFDictionaryRef Function(CFAllocatorRef, CFDictionaryRef) - >(); - - CFMutableDictionaryRef CFDictionaryCreateMutable( - CFAllocatorRef allocator, - int capacity, - ffi.Pointer keyCallBacks, - ffi.Pointer valueCallBacks, - ) { - return _CFDictionaryCreateMutable( - allocator, - capacity, - keyCallBacks, - valueCallBacks, + /// Creates a WebSocket task given the url. The given url must have a ws or wss scheme. + NSURLSessionWebSocketTask webSocketTaskWithURL(objc.NSURL url) { + objc.checkOsVersionInternal( + 'NSURLSession.webSocketTaskWithURL:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_webSocketTaskWithURL_, + url.ref.pointer, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: true, + release: true, ); } - late final _CFDictionaryCreateMutablePtr = - _lookup< - ffi.NativeFunction< - CFMutableDictionaryRef Function( - CFAllocatorRef, - CFIndex, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFDictionaryCreateMutable'); - late final _CFDictionaryCreateMutable = - _CFDictionaryCreateMutablePtr.asFunction< - CFMutableDictionaryRef Function( - CFAllocatorRef, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFMutableDictionaryRef CFDictionaryCreateMutableCopy( - CFAllocatorRef allocator, - int capacity, - CFDictionaryRef theDict, - ) { - return _CFDictionaryCreateMutableCopy(allocator, capacity, theDict); - } - - late final _CFDictionaryCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableDictionaryRef Function( - CFAllocatorRef, - CFIndex, - CFDictionaryRef, - ) - > - >('CFDictionaryCreateMutableCopy'); - late final _CFDictionaryCreateMutableCopy = - _CFDictionaryCreateMutableCopyPtr.asFunction< - CFMutableDictionaryRef Function(CFAllocatorRef, int, CFDictionaryRef) - >(); - - int CFDictionaryGetCount(CFDictionaryRef theDict) { - return _CFDictionaryGetCount(theDict); + /// Creates a WebSocket task given the url and an array of protocols. The protocols will be used in the WebSocket handshake to + /// negotiate a preferred protocol with the server + /// Note - The protocol will not affect the WebSocket framing. More details on the protocol can be found by reading the WebSocket RFC + NSURLSessionWebSocketTask webSocketTaskWithURL$1( + objc.NSURL url, { + required objc.NSArray protocols, + }) { + objc.checkOsVersionInternal( + 'NSURLSession.webSocketTaskWithURL:protocols:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_15qeuct( + object$.ref.pointer, + _sel_webSocketTaskWithURL_protocols_, + url.ref.pointer, + protocols.ref.pointer, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: true, + release: true, + ); } +} - late final _CFDictionaryGetCountPtr = - _lookup>( - 'CFDictionaryGetCount', - ); - late final _CFDictionaryGetCount = - _CFDictionaryGetCountPtr.asFunction(); +/// Disposition options for various delegate messages +enum NSURLSessionDelayedRequestDisposition { + /// Use the original request provided when the task was created; the request parameter is ignored. + NSURLSessionDelayedRequestContinueLoading(0), - int CFDictionaryGetCountOfKey( - CFDictionaryRef theDict, - ffi.Pointer key, - ) { - return _CFDictionaryGetCountOfKey(theDict, key); - } + /// Use the specified request, which may not be nil. + NSURLSessionDelayedRequestUseNewRequest(1), - late final _CFDictionaryGetCountOfKeyPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFDictionaryRef, ffi.Pointer) - > - >('CFDictionaryGetCountOfKey'); - late final _CFDictionaryGetCountOfKey = - _CFDictionaryGetCountOfKeyPtr.asFunction< - int Function(CFDictionaryRef, ffi.Pointer) - >(); - - int CFDictionaryGetCountOfValue( - CFDictionaryRef theDict, - ffi.Pointer value, - ) { - return _CFDictionaryGetCountOfValue(theDict, value); - } + /// Cancel the task; the request parameter is ignored. + NSURLSessionDelayedRequestCancel(2); - late final _CFDictionaryGetCountOfValuePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFDictionaryRef, ffi.Pointer) - > - >('CFDictionaryGetCountOfValue'); - late final _CFDictionaryGetCountOfValue = - _CFDictionaryGetCountOfValuePtr.asFunction< - int Function(CFDictionaryRef, ffi.Pointer) - >(); - - int CFDictionaryContainsKey( - CFDictionaryRef theDict, - ffi.Pointer key, - ) { - return _CFDictionaryContainsKey(theDict, key); - } + final int value; + const NSURLSessionDelayedRequestDisposition(this.value); - late final _CFDictionaryContainsKeyPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFDictionaryRef, ffi.Pointer) - > - >('CFDictionaryContainsKey'); - late final _CFDictionaryContainsKey = - _CFDictionaryContainsKeyPtr.asFunction< - int Function(CFDictionaryRef, ffi.Pointer) - >(); - - int CFDictionaryContainsValue( - CFDictionaryRef theDict, - ffi.Pointer value, - ) { - return _CFDictionaryContainsValue(theDict, value); - } + static NSURLSessionDelayedRequestDisposition fromValue(int value) => + switch (value) { + 0 => NSURLSessionDelayedRequestContinueLoading, + 1 => NSURLSessionDelayedRequestUseNewRequest, + 2 => NSURLSessionDelayedRequestCancel, + _ => throw ArgumentError( + 'Unknown value for NSURLSessionDelayedRequestDisposition: $value', + ), + }; +} - late final _CFDictionaryContainsValuePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFDictionaryRef, ffi.Pointer) - > - >('CFDictionaryContainsValue'); - late final _CFDictionaryContainsValue = - _CFDictionaryContainsValuePtr.asFunction< - int Function(CFDictionaryRef, ffi.Pointer) - >(); - - ffi.Pointer CFDictionaryGetValue( - CFDictionaryRef theDict, - ffi.Pointer key, - ) { - return _CFDictionaryGetValue(theDict, key); - } +enum NSURLSessionAuthChallengeDisposition { + /// Use the specified credential, which may be nil + NSURLSessionAuthChallengeUseCredential(0), - late final _CFDictionaryGetValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFDictionaryRef, ffi.Pointer) - > - >('CFDictionaryGetValue'); - late final _CFDictionaryGetValue = - _CFDictionaryGetValuePtr.asFunction< - ffi.Pointer Function(CFDictionaryRef, ffi.Pointer) - >(); - - int CFDictionaryGetValueIfPresent( - CFDictionaryRef theDict, - ffi.Pointer key, - ffi.Pointer> value, - ) { - return _CFDictionaryGetValueIfPresent(theDict, key, value); - } + /// Default handling for the challenge - as if this delegate were not implemented; the credential parameter is ignored. + NSURLSessionAuthChallengePerformDefaultHandling(1), - late final _CFDictionaryGetValueIfPresentPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFDictionaryRef, - ffi.Pointer, - ffi.Pointer>, - ) - > - >('CFDictionaryGetValueIfPresent'); - late final _CFDictionaryGetValueIfPresent = - _CFDictionaryGetValueIfPresentPtr.asFunction< - int Function( - CFDictionaryRef, - ffi.Pointer, - ffi.Pointer>, - ) - >(); + /// The entire request will be canceled; the credential parameter is ignored. + NSURLSessionAuthChallengeCancelAuthenticationChallenge(2), - void CFDictionaryGetKeysAndValues( - CFDictionaryRef theDict, - ffi.Pointer> keys, - ffi.Pointer> values, - ) { - return _CFDictionaryGetKeysAndValues(theDict, keys, values); - } + /// This challenge is rejected and the next authentication protection space should be tried; the credential parameter is ignored. + NSURLSessionAuthChallengeRejectProtectionSpace(3); - late final _CFDictionaryGetKeysAndValuesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFDictionaryRef, - ffi.Pointer>, - ffi.Pointer>, - ) - > - >('CFDictionaryGetKeysAndValues'); - late final _CFDictionaryGetKeysAndValues = - _CFDictionaryGetKeysAndValuesPtr.asFunction< - void Function( - CFDictionaryRef, - ffi.Pointer>, - ffi.Pointer>, - ) - >(); + final int value; + const NSURLSessionAuthChallengeDisposition(this.value); - void CFDictionaryApplyFunction( - CFDictionaryRef theDict, - CFDictionaryApplierFunction applier, - ffi.Pointer context, - ) { - return _CFDictionaryApplyFunction(theDict, applier, context); - } + static NSURLSessionAuthChallengeDisposition fromValue(int value) => + switch (value) { + 0 => NSURLSessionAuthChallengeUseCredential, + 1 => NSURLSessionAuthChallengePerformDefaultHandling, + 2 => NSURLSessionAuthChallengeCancelAuthenticationChallenge, + 3 => NSURLSessionAuthChallengeRejectProtectionSpace, + _ => throw ArgumentError( + 'Unknown value for NSURLSessionAuthChallengeDisposition: $value', + ), + }; +} - late final _CFDictionaryApplyFunctionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFDictionaryRef, - CFDictionaryApplierFunction, - ffi.Pointer, - ) - > - >('CFDictionaryApplyFunction'); - late final _CFDictionaryApplyFunction = - _CFDictionaryApplyFunctionPtr.asFunction< - void Function( - CFDictionaryRef, - CFDictionaryApplierFunction, - ffi.Pointer, - ) - >(); +enum NSURLSessionResponseDisposition { + /// Cancel the load, this is the same as -[task cancel] + NSURLSessionResponseCancel(0), - void CFDictionaryAddValue( - CFMutableDictionaryRef theDict, - ffi.Pointer key, - ffi.Pointer value, - ) { - return _CFDictionaryAddValue(theDict, key, value); - } + /// Allow the load to continue + NSURLSessionResponseAllow(1), - late final _CFDictionaryAddValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableDictionaryRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFDictionaryAddValue'); - late final _CFDictionaryAddValue = - _CFDictionaryAddValuePtr.asFunction< - void Function( - CFMutableDictionaryRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); + /// Turn this request into a download + NSURLSessionResponseBecomeDownload(2), - void CFDictionarySetValue( - CFMutableDictionaryRef theDict, - ffi.Pointer key, - ffi.Pointer value, - ) { - return _CFDictionarySetValue(theDict, key, value); - } + /// Turn this task into a stream task + NSURLSessionResponseBecomeStream(3); - late final _CFDictionarySetValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableDictionaryRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFDictionarySetValue'); - late final _CFDictionarySetValue = - _CFDictionarySetValuePtr.asFunction< - void Function( - CFMutableDictionaryRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); + final int value; + const NSURLSessionResponseDisposition(this.value); - void CFDictionaryReplaceValue( - CFMutableDictionaryRef theDict, - ffi.Pointer key, - ffi.Pointer value, - ) { - return _CFDictionaryReplaceValue(theDict, key, value); - } + static NSURLSessionResponseDisposition fromValue(int value) => + switch (value) { + 0 => NSURLSessionResponseCancel, + 1 => NSURLSessionResponseAllow, + 2 => NSURLSessionResponseBecomeDownload, + 3 => NSURLSessionResponseBecomeStream, + _ => throw ArgumentError( + 'Unknown value for NSURLSessionResponseDisposition: $value', + ), + }; +} - late final _CFDictionaryReplaceValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableDictionaryRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFDictionaryReplaceValue'); - late final _CFDictionaryReplaceValue = - _CFDictionaryReplaceValuePtr.asFunction< - void Function( - CFMutableDictionaryRef, - ffi.Pointer, - ffi.Pointer, +late final _protocol_NSURLSessionDataDelegate = objc.getProtocol( + "NSURLSessionDataDelegate", +); +late final _sel_conformsToProtocol_ = objc.registerName("conformsToProtocol:"); +final _objc_msgSend_e3qsqz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - void CFDictionaryRemoveValue( - CFMutableDictionaryRef theDict, - ffi.Pointer key, - ) { - return _CFDictionaryRemoveValue(theDict, key); - } - - late final _CFDictionaryRemoveValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableDictionaryRef, ffi.Pointer) - > - >('CFDictionaryRemoveValue'); - late final _CFDictionaryRemoveValue = - _CFDictionaryRemoveValuePtr.asFunction< - void Function(CFMutableDictionaryRef, ffi.Pointer) - >(); - - void CFDictionaryRemoveAllValues(CFMutableDictionaryRef theDict) { - return _CFDictionaryRemoveAllValues(theDict); - } - - late final _CFDictionaryRemoveAllValuesPtr = - _lookup>( - 'CFDictionaryRemoveAllValues', - ); - late final _CFDictionaryRemoveAllValues = - _CFDictionaryRemoveAllValuesPtr.asFunction< - void Function(CFMutableDictionaryRef) - >(); - - int CFNotificationCenterGetTypeID() { - return _CFNotificationCenterGetTypeID(); - } - - late final _CFNotificationCenterGetTypeIDPtr = - _lookup>( - 'CFNotificationCenterGetTypeID', - ); - late final _CFNotificationCenterGetTypeID = - _CFNotificationCenterGetTypeIDPtr.asFunction(); - - CFNotificationCenterRef CFNotificationCenterGetLocalCenter() { - return _CFNotificationCenterGetLocalCenter(); - } - - late final _CFNotificationCenterGetLocalCenterPtr = - _lookup>( - 'CFNotificationCenterGetLocalCenter', - ); - late final _CFNotificationCenterGetLocalCenter = - _CFNotificationCenterGetLocalCenterPtr.asFunction< - CFNotificationCenterRef Function() - >(); + > + >() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - CFNotificationCenterRef CFNotificationCenterGetDistributedCenter() { - return _CFNotificationCenterGetDistributedCenter(); - } +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSURLSessionResponseDisposition { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); - late final _CFNotificationCenterGetDistributedCenterPtr = - _lookup>( - 'CFNotificationCenterGetDistributedCenter', - ); - late final _CFNotificationCenterGetDistributedCenter = - _CFNotificationCenterGetDistributedCenterPtr.asFunction< - CFNotificationCenterRef Function() - >(); + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer> ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - CFNotificationCenterRef CFNotificationCenterGetDarwinNotifyCenter() { - return _CFNotificationCenterGetDarwinNotifyCenter(); - } + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(NSURLSessionResponseDisposition) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - late final _CFNotificationCenterGetDarwinNotifyCenterPtr = - _lookup>( - 'CFNotificationCenterGetDarwinNotifyCenter', - ); - late final _CFNotificationCenterGetDarwinNotifyCenter = - _CFNotificationCenterGetDarwinNotifyCenterPtr.asFunction< - CFNotificationCenterRef Function() - >(); - - void CFNotificationCenterAddObserver( - CFNotificationCenterRef center, - ffi.Pointer observer, - CFNotificationCallback callBack, - CFStringRef name, - ffi.Pointer object, - CFNotificationSuspensionBehavior suspensionBehavior, - ) { - return _CFNotificationCenterAddObserver( - center, - observer, - callBack, - name, - object, - suspensionBehavior.value, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(NSURLSessionResponseDisposition) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_16sve1d(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, ); } - late final _CFNotificationCenterAddObserverPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFNotificationCenterRef, - ffi.Pointer, - CFNotificationCallback, - CFStringRef, - ffi.Pointer, - CFIndex, - ) - > - >('CFNotificationCenterAddObserver'); - late final _CFNotificationCenterAddObserver = - _CFNotificationCenterAddObserverPtr.asFunction< - void Function( - CFNotificationCenterRef, - ffi.Pointer, - CFNotificationCallback, - CFStringRef, - ffi.Pointer, - int, - ) - >(); - - void CFNotificationCenterRemoveObserver( - CFNotificationCenterRef center, - ffi.Pointer observer, - CFNotificationName name, - ffi.Pointer object, - ) { - return _CFNotificationCenterRemoveObserver(center, observer, name, object); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(NSURLSessionResponseDisposition) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_16sve1d( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _CFNotificationCenterRemoveObserverPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFNotificationCenterRef, - ffi.Pointer, - CFNotificationName, - ffi.Pointer, - ) - > - >('CFNotificationCenterRemoveObserver'); - late final _CFNotificationCenterRemoveObserver = - _CFNotificationCenterRemoveObserverPtr.asFunction< - void Function( - CFNotificationCenterRef, - ffi.Pointer, - CFNotificationName, - ffi.Pointer, - ) - >(); - - void CFNotificationCenterRemoveEveryObserver( - CFNotificationCenterRef center, - ffi.Pointer observer, + static void _listenerTrampoline( + ffi.Pointer block, + int arg0, ) { - return _CFNotificationCenterRemoveEveryObserver(center, observer); + (objc.getBlockClosure(block) as void Function(int))(arg0); + objc.objectRelease(block.cast()); } - late final _CFNotificationCenterRemoveEveryObserverPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFNotificationCenterRef, ffi.Pointer) - > - >('CFNotificationCenterRemoveEveryObserver'); - late final _CFNotificationCenterRemoveEveryObserver = - _CFNotificationCenterRemoveEveryObserverPtr.asFunction< - void Function(CFNotificationCenterRef, ffi.Pointer) - >(); - - void CFNotificationCenterPostNotification( - CFNotificationCenterRef center, - CFNotificationName name, - ffi.Pointer object, - CFDictionaryRef userInfo, - int deliverImmediately, + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer, ffi.Long) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function(ffi.Pointer, ffi.Long) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + int arg0, ) { - return _CFNotificationCenterPostNotification( - center, - name, - object, - userInfo, - deliverImmediately, - ); + try { + (objc.getBlockClosure(block) as void Function(int))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFNotificationCenterPostNotificationPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - CFNotificationCenterRef, - CFNotificationName, + ffi.Pointer, ffi.Pointer, - CFDictionaryRef, - Boolean, + ffi.Long, ) - > - >('CFNotificationCenterPostNotification'); - late final _CFNotificationCenterPostNotification = - _CFNotificationCenterPostNotificationPtr.asFunction< - void Function( - CFNotificationCenterRef, - CFNotificationName, - ffi.Pointer, - CFDictionaryRef, - int, - ) - >(); - - void CFNotificationCenterPostNotificationWithOptions( - CFNotificationCenterRef center, - CFNotificationName name, - ffi.Pointer object, - CFDictionaryRef userInfo, - int options, - ) { - return _CFNotificationCenterPostNotificationWithOptions( - center, - name, - object, - userInfo, - options, - ); - } - - late final _CFNotificationCenterPostNotificationWithOptionsPtr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( - CFNotificationCenterRef, - CFNotificationName, + ffi.Pointer, ffi.Pointer, - CFDictionaryRef, - CFOptionFlags, + ffi.Long, ) - > - >('CFNotificationCenterPostNotificationWithOptions'); - late final _CFNotificationCenterPostNotificationWithOptions = - _CFNotificationCenterPostNotificationWithOptionsPtr.asFunction< - void Function( - CFNotificationCenterRef, - CFNotificationName, - ffi.Pointer, - CFDictionaryRef, - int, - ) - >(); - - int CFLocaleGetTypeID() { - return _CFLocaleGetTypeID(); - } - - late final _CFLocaleGetTypeIDPtr = - _lookup>('CFLocaleGetTypeID'); - late final _CFLocaleGetTypeID = - _CFLocaleGetTypeIDPtr.asFunction(); - - CFLocaleRef CFLocaleGetSystem() { - return _CFLocaleGetSystem(); - } - - late final _CFLocaleGetSystemPtr = - _lookup>('CFLocaleGetSystem'); - late final _CFLocaleGetSystem = - _CFLocaleGetSystemPtr.asFunction(); - - CFLocaleRef CFLocaleCopyCurrent() { - return _CFLocaleCopyCurrent(); - } - - late final _CFLocaleCopyCurrentPtr = - _lookup>( - 'CFLocaleCopyCurrent', - ); - late final _CFLocaleCopyCurrent = - _CFLocaleCopyCurrentPtr.asFunction(); - - CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers() { - return _CFLocaleCopyAvailableLocaleIdentifiers(); - } - - late final _CFLocaleCopyAvailableLocaleIdentifiersPtr = - _lookup>( - 'CFLocaleCopyAvailableLocaleIdentifiers', - ); - late final _CFLocaleCopyAvailableLocaleIdentifiers = - _CFLocaleCopyAvailableLocaleIdentifiersPtr.asFunction< - CFArrayRef Function() - >(); - - CFArrayRef CFLocaleCopyISOLanguageCodes() { - return _CFLocaleCopyISOLanguageCodes(); - } - - late final _CFLocaleCopyISOLanguageCodesPtr = - _lookup>( - 'CFLocaleCopyISOLanguageCodes', - ); - late final _CFLocaleCopyISOLanguageCodes = - _CFLocaleCopyISOLanguageCodesPtr.asFunction(); - - CFArrayRef CFLocaleCopyISOCountryCodes() { - return _CFLocaleCopyISOCountryCodes(); - } - - late final _CFLocaleCopyISOCountryCodesPtr = - _lookup>( - 'CFLocaleCopyISOCountryCodes', - ); - late final _CFLocaleCopyISOCountryCodes = - _CFLocaleCopyISOCountryCodesPtr.asFunction(); - - CFArrayRef CFLocaleCopyISOCurrencyCodes() { - return _CFLocaleCopyISOCurrencyCodes(); - } + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + int arg0, + ) => block.ref.target + .cast>() + .asFunction()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer, ffi.Long) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + int arg0, + ) => (objc.getBlockClosure(block) as void Function(int))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer, ffi.Long) + >(_closureTrampoline) + .cast(); +} - late final _CFLocaleCopyISOCurrencyCodesPtr = - _lookup>( - 'CFLocaleCopyISOCurrencyCodes', +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLSessionResponseDisposition$CallExtension + on objc.ObjCBlock { + void call(NSURLSessionResponseDisposition arg0) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Long arg0, + ) + > + >() + .asFunction, int)>()( + ref.pointer, + arg0.value, ); - late final _CFLocaleCopyISOCurrencyCodes = - _CFLocaleCopyISOCurrencyCodesPtr.asFunction(); +} - CFArrayRef CFLocaleCopyCommonISOCurrencyCodes() { - return _CFLocaleCopyCommonISOCurrencyCodes(); - } +late final _sel_URLSession_dataTask_didReceiveResponse_completionHandler_ = objc + .registerName("URLSession:dataTask:didReceiveResponse:completionHandler:"); +final _objc_msgSend_m7tls4 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - late final _CFLocaleCopyCommonISOCurrencyCodesPtr = - _lookup>( - 'CFLocaleCopyCommonISOCurrencyCodes', - ); - late final _CFLocaleCopyCommonISOCurrencyCodes = - _CFLocaleCopyCommonISOCurrencyCodesPtr.asFunction< - CFArrayRef Function() - >(); +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); - CFArrayRef CFLocaleCopyPreferredLanguages() { - return _CFLocaleCopyPreferredLanguages(); - } + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Long arg0, ffi.Pointer arg1) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _CFLocaleCopyPreferredLanguagesPtr = - _lookup>( - 'CFLocaleCopyPreferredLanguages', - ); - late final _CFLocaleCopyPreferredLanguages = - _CFLocaleCopyPreferredLanguagesPtr.asFunction(); - - CFLocaleIdentifier CFLocaleCreateCanonicalLanguageIdentifierFromString( - CFAllocatorRef allocator, - CFStringRef localeIdentifier, - ) { - return _CFLocaleCreateCanonicalLanguageIdentifierFromString( - allocator, - localeIdentifier, - ); - } + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock + fromFunction( + void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (int arg0, ffi.Pointer arg1) => fn( + NSURLSessionDelayedRequestDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLRequest.fromPointer(arg1, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - late final _CFLocaleCreateCanonicalLanguageIdentifierFromStringPtr = - _lookup< - ffi.NativeFunction< - CFLocaleIdentifier Function(CFAllocatorRef, CFStringRef) - > - >('CFLocaleCreateCanonicalLanguageIdentifierFromString'); - late final _CFLocaleCreateCanonicalLanguageIdentifierFromString = - _CFLocaleCreateCanonicalLanguageIdentifierFromStringPtr.asFunction< - CFLocaleIdentifier Function(CFAllocatorRef, CFStringRef) - >(); - - CFLocaleIdentifier CFLocaleCreateCanonicalLocaleIdentifierFromString( - CFAllocatorRef allocator, - CFStringRef localeIdentifier, - ) { - return _CFLocaleCreateCanonicalLocaleIdentifierFromString( - allocator, - localeIdentifier, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (int arg0, ffi.Pointer arg1) => fn( + NSURLSessionDelayedRequestDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLRequest.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, ); - } - - late final _CFLocaleCreateCanonicalLocaleIdentifierFromStringPtr = - _lookup< - ffi.NativeFunction< - CFLocaleIdentifier Function(CFAllocatorRef, CFStringRef) - > - >('CFLocaleCreateCanonicalLocaleIdentifierFromString'); - late final _CFLocaleCreateCanonicalLocaleIdentifierFromString = - _CFLocaleCreateCanonicalLocaleIdentifierFromStringPtr.asFunction< - CFLocaleIdentifier Function(CFAllocatorRef, CFStringRef) - >(); - - CFLocaleIdentifier - CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes( - CFAllocatorRef allocator, - int lcode, - int rcode, - ) { - return _CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes( - allocator, - lcode, - rcode, + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1otpo83(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, ); } - late final _CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodesPtr = - _lookup< - ffi.NativeFunction< - CFLocaleIdentifier Function(CFAllocatorRef, LangCode, RegionCode) - > - >('CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes'); - late final _CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes = - _CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodesPtr.asFunction< - CFLocaleIdentifier Function(CFAllocatorRef, int, int) - >(); - - CFLocaleIdentifier CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode( - CFAllocatorRef allocator, - int lcid, - ) { - return _CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode( - allocator, - lcid, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (int arg0, ffi.Pointer arg1) => fn( + NSURLSessionDelayedRequestDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLRequest.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, ); - } - - late final _CFLocaleCreateLocaleIdentifierFromWindowsLocaleCodePtr = - _lookup< - ffi.NativeFunction< - CFLocaleIdentifier Function(CFAllocatorRef, ffi.Uint32) - > - >('CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode'); - late final _CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode = - _CFLocaleCreateLocaleIdentifierFromWindowsLocaleCodePtr.asFunction< - CFLocaleIdentifier Function(CFAllocatorRef, int) - >(); - - int CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier( - CFLocaleIdentifier localeIdentifier, - ) { - return _CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(localeIdentifier); - } - - late final _CFLocaleGetWindowsLocaleCodeFromLocaleIdentifierPtr = - _lookup>( - 'CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier', - ); - late final _CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier = - _CFLocaleGetWindowsLocaleCodeFromLocaleIdentifierPtr.asFunction< - int Function(CFLocaleIdentifier) - >(); - - CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection( - CFStringRef isoLangCode, - ) { - return CFLocaleLanguageDirection.fromValue( - _CFLocaleGetLanguageCharacterDirection(isoLangCode), + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (int arg0, ffi.Pointer arg1) => fn( + NSURLSessionDelayedRequestDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLRequest.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, ); - } - - late final _CFLocaleGetLanguageCharacterDirectionPtr = - _lookup>( - 'CFLocaleGetLanguageCharacterDirection', - ); - late final _CFLocaleGetLanguageCharacterDirection = - _CFLocaleGetLanguageCharacterDirectionPtr.asFunction< - int Function(CFStringRef) - >(); - - CFLocaleLanguageDirection CFLocaleGetLanguageLineDirection( - CFStringRef isoLangCode, - ) { - return CFLocaleLanguageDirection.fromValue( - _CFLocaleGetLanguageLineDirection(isoLangCode), + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1otpo83( + raw, + rawListener, + objc.objCContext, ); - } - - late final _CFLocaleGetLanguageLineDirectionPtr = - _lookup>( - 'CFLocaleGetLanguageLineDirection', - ); - late final _CFLocaleGetLanguageLineDirection = - _CFLocaleGetLanguageLineDirectionPtr.asFunction< - int Function(CFStringRef) - >(); - - CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier( - CFAllocatorRef allocator, - CFLocaleIdentifier localeID, - ) { - return _CFLocaleCreateComponentsFromLocaleIdentifier(allocator, localeID); - } - - late final _CFLocaleCreateComponentsFromLocaleIdentifierPtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function(CFAllocatorRef, CFLocaleIdentifier) - > - >('CFLocaleCreateComponentsFromLocaleIdentifier'); - late final _CFLocaleCreateComponentsFromLocaleIdentifier = - _CFLocaleCreateComponentsFromLocaleIdentifierPtr.asFunction< - CFDictionaryRef Function(CFAllocatorRef, CFLocaleIdentifier) - >(); - - CFLocaleIdentifier CFLocaleCreateLocaleIdentifierFromComponents( - CFAllocatorRef allocator, - CFDictionaryRef dictionary, - ) { - return _CFLocaleCreateLocaleIdentifierFromComponents(allocator, dictionary); - } - - late final _CFLocaleCreateLocaleIdentifierFromComponentsPtr = - _lookup< - ffi.NativeFunction< - CFLocaleIdentifier Function(CFAllocatorRef, CFDictionaryRef) - > - >('CFLocaleCreateLocaleIdentifierFromComponents'); - late final _CFLocaleCreateLocaleIdentifierFromComponents = - _CFLocaleCreateLocaleIdentifierFromComponentsPtr.asFunction< - CFLocaleIdentifier Function(CFAllocatorRef, CFDictionaryRef) - >(); - - CFLocaleRef CFLocaleCreate( - CFAllocatorRef allocator, - CFLocaleIdentifier localeIdentifier, - ) { - return _CFLocaleCreate(allocator, localeIdentifier); - } - - late final _CFLocaleCreatePtr = - _lookup< - ffi.NativeFunction< - CFLocaleRef Function(CFAllocatorRef, CFLocaleIdentifier) - > - >('CFLocaleCreate'); - late final _CFLocaleCreate = - _CFLocaleCreatePtr.asFunction< - CFLocaleRef Function(CFAllocatorRef, CFLocaleIdentifier) - >(); - - CFLocaleRef CFLocaleCreateCopy(CFAllocatorRef allocator, CFLocaleRef locale) { - return _CFLocaleCreateCopy(allocator, locale); - } - - late final _CFLocaleCreateCopyPtr = - _lookup< - ffi.NativeFunction - >('CFLocaleCreateCopy'); - late final _CFLocaleCreateCopy = - _CFLocaleCreateCopyPtr.asFunction< - CFLocaleRef Function(CFAllocatorRef, CFLocaleRef) - >(); - - CFLocaleIdentifier CFLocaleGetIdentifier(CFLocaleRef locale) { - return _CFLocaleGetIdentifier(locale); - } - - late final _CFLocaleGetIdentifierPtr = - _lookup>( - 'CFLocaleGetIdentifier', - ); - late final _CFLocaleGetIdentifier = - _CFLocaleGetIdentifierPtr.asFunction< - CFLocaleIdentifier Function(CFLocaleRef) - >(); - - CFTypeRef CFLocaleGetValue(CFLocaleRef locale, CFLocaleKey key) { - return _CFLocaleGetValue(locale, key); - } - - late final _CFLocaleGetValuePtr = - _lookup>( - 'CFLocaleGetValue', - ); - late final _CFLocaleGetValue = - _CFLocaleGetValuePtr.asFunction< - CFTypeRef Function(CFLocaleRef, CFLocaleKey) - >(); - - CFStringRef CFLocaleCopyDisplayNameForPropertyValue( - CFLocaleRef displayLocale, - CFLocaleKey key, - CFStringRef value, - ) { - return _CFLocaleCopyDisplayNameForPropertyValue(displayLocale, key, value); - } - - late final _CFLocaleCopyDisplayNameForPropertyValuePtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFLocaleRef, CFLocaleKey, CFStringRef) - > - >('CFLocaleCopyDisplayNameForPropertyValue'); - late final _CFLocaleCopyDisplayNameForPropertyValue = - _CFLocaleCopyDisplayNameForPropertyValuePtr.asFunction< - CFStringRef Function(CFLocaleRef, CFLocaleKey, CFStringRef) - >(); - - late final ffi.Pointer - _kCFLocaleCurrentLocaleDidChangeNotification = _lookup( - 'kCFLocaleCurrentLocaleDidChangeNotification', - ); - - CFNotificationName get kCFLocaleCurrentLocaleDidChangeNotification => - _kCFLocaleCurrentLocaleDidChangeNotification.value; - - late final ffi.Pointer _kCFLocaleIdentifier = - _lookup('kCFLocaleIdentifier'); - - CFLocaleKey get kCFLocaleIdentifier => _kCFLocaleIdentifier.value; - - late final ffi.Pointer _kCFLocaleLanguageCode = - _lookup('kCFLocaleLanguageCode'); - - CFLocaleKey get kCFLocaleLanguageCode => _kCFLocaleLanguageCode.value; - - late final ffi.Pointer _kCFLocaleCountryCode = - _lookup('kCFLocaleCountryCode'); - - CFLocaleKey get kCFLocaleCountryCode => _kCFLocaleCountryCode.value; - - late final ffi.Pointer _kCFLocaleScriptCode = - _lookup('kCFLocaleScriptCode'); - - CFLocaleKey get kCFLocaleScriptCode => _kCFLocaleScriptCode.value; - - late final ffi.Pointer _kCFLocaleVariantCode = - _lookup('kCFLocaleVariantCode'); - - CFLocaleKey get kCFLocaleVariantCode => _kCFLocaleVariantCode.value; - - late final ffi.Pointer _kCFLocaleExemplarCharacterSet = - _lookup('kCFLocaleExemplarCharacterSet'); - - CFLocaleKey get kCFLocaleExemplarCharacterSet => - _kCFLocaleExemplarCharacterSet.value; - - late final ffi.Pointer _kCFLocaleCalendarIdentifier = - _lookup('kCFLocaleCalendarIdentifier'); - - CFLocaleKey get kCFLocaleCalendarIdentifier => - _kCFLocaleCalendarIdentifier.value; - - late final ffi.Pointer _kCFLocaleCalendar = _lookup( - 'kCFLocaleCalendar', - ); - - CFLocaleKey get kCFLocaleCalendar => _kCFLocaleCalendar.value; - - late final ffi.Pointer _kCFLocaleCollationIdentifier = - _lookup('kCFLocaleCollationIdentifier'); - - CFLocaleKey get kCFLocaleCollationIdentifier => - _kCFLocaleCollationIdentifier.value; - - late final ffi.Pointer _kCFLocaleUsesMetricSystem = - _lookup('kCFLocaleUsesMetricSystem'); - - CFLocaleKey get kCFLocaleUsesMetricSystem => _kCFLocaleUsesMetricSystem.value; - - late final ffi.Pointer _kCFLocaleMeasurementSystem = - _lookup('kCFLocaleMeasurementSystem'); - - CFLocaleKey get kCFLocaleMeasurementSystem => - _kCFLocaleMeasurementSystem.value; - - late final ffi.Pointer _kCFLocaleDecimalSeparator = - _lookup('kCFLocaleDecimalSeparator'); - - CFLocaleKey get kCFLocaleDecimalSeparator => _kCFLocaleDecimalSeparator.value; - - late final ffi.Pointer _kCFLocaleGroupingSeparator = - _lookup('kCFLocaleGroupingSeparator'); - - CFLocaleKey get kCFLocaleGroupingSeparator => - _kCFLocaleGroupingSeparator.value; - - late final ffi.Pointer _kCFLocaleCurrencySymbol = - _lookup('kCFLocaleCurrencySymbol'); - - CFLocaleKey get kCFLocaleCurrencySymbol => _kCFLocaleCurrencySymbol.value; - - late final ffi.Pointer _kCFLocaleCurrencyCode = - _lookup('kCFLocaleCurrencyCode'); - - CFLocaleKey get kCFLocaleCurrencyCode => _kCFLocaleCurrencyCode.value; - - late final ffi.Pointer _kCFLocaleCollatorIdentifier = - _lookup('kCFLocaleCollatorIdentifier'); - - CFLocaleKey get kCFLocaleCollatorIdentifier => - _kCFLocaleCollatorIdentifier.value; - - late final ffi.Pointer _kCFLocaleQuotationBeginDelimiterKey = - _lookup('kCFLocaleQuotationBeginDelimiterKey'); - - CFLocaleKey get kCFLocaleQuotationBeginDelimiterKey => - _kCFLocaleQuotationBeginDelimiterKey.value; - - late final ffi.Pointer _kCFLocaleQuotationEndDelimiterKey = - _lookup('kCFLocaleQuotationEndDelimiterKey'); - - CFLocaleKey get kCFLocaleQuotationEndDelimiterKey => - _kCFLocaleQuotationEndDelimiterKey.value; - - late final ffi.Pointer - _kCFLocaleAlternateQuotationBeginDelimiterKey = _lookup( - 'kCFLocaleAlternateQuotationBeginDelimiterKey', - ); - - CFLocaleKey get kCFLocaleAlternateQuotationBeginDelimiterKey => - _kCFLocaleAlternateQuotationBeginDelimiterKey.value; - - late final ffi.Pointer - _kCFLocaleAlternateQuotationEndDelimiterKey = _lookup( - 'kCFLocaleAlternateQuotationEndDelimiterKey', - ); - - CFLocaleKey get kCFLocaleAlternateQuotationEndDelimiterKey => - _kCFLocaleAlternateQuotationEndDelimiterKey.value; - - late final ffi.Pointer _kCFGregorianCalendar = - _lookup('kCFGregorianCalendar'); - - CFCalendarIdentifier get kCFGregorianCalendar => _kCFGregorianCalendar.value; - - late final ffi.Pointer _kCFBuddhistCalendar = - _lookup('kCFBuddhistCalendar'); - - CFCalendarIdentifier get kCFBuddhistCalendar => _kCFBuddhistCalendar.value; - - late final ffi.Pointer _kCFChineseCalendar = - _lookup('kCFChineseCalendar'); - - CFCalendarIdentifier get kCFChineseCalendar => _kCFChineseCalendar.value; - - late final ffi.Pointer _kCFHebrewCalendar = - _lookup('kCFHebrewCalendar'); - - CFCalendarIdentifier get kCFHebrewCalendar => _kCFHebrewCalendar.value; - - late final ffi.Pointer _kCFIslamicCalendar = - _lookup('kCFIslamicCalendar'); - - CFCalendarIdentifier get kCFIslamicCalendar => _kCFIslamicCalendar.value; - - late final ffi.Pointer _kCFIslamicCivilCalendar = - _lookup('kCFIslamicCivilCalendar'); - - CFCalendarIdentifier get kCFIslamicCivilCalendar => - _kCFIslamicCivilCalendar.value; - - late final ffi.Pointer _kCFJapaneseCalendar = - _lookup('kCFJapaneseCalendar'); - - CFCalendarIdentifier get kCFJapaneseCalendar => _kCFJapaneseCalendar.value; - - late final ffi.Pointer _kCFRepublicOfChinaCalendar = - _lookup('kCFRepublicOfChinaCalendar'); - - CFCalendarIdentifier get kCFRepublicOfChinaCalendar => - _kCFRepublicOfChinaCalendar.value; - - late final ffi.Pointer _kCFPersianCalendar = - _lookup('kCFPersianCalendar'); - - CFCalendarIdentifier get kCFPersianCalendar => _kCFPersianCalendar.value; - - late final ffi.Pointer _kCFIndianCalendar = - _lookup('kCFIndianCalendar'); - - CFCalendarIdentifier get kCFIndianCalendar => _kCFIndianCalendar.value; - - late final ffi.Pointer _kCFISO8601Calendar = - _lookup('kCFISO8601Calendar'); - - CFCalendarIdentifier get kCFISO8601Calendar => _kCFISO8601Calendar.value; - - late final ffi.Pointer _kCFIslamicTabularCalendar = - _lookup('kCFIslamicTabularCalendar'); - - CFCalendarIdentifier get kCFIslamicTabularCalendar => - _kCFIslamicTabularCalendar.value; - - late final ffi.Pointer _kCFIslamicUmmAlQuraCalendar = - _lookup('kCFIslamicUmmAlQuraCalendar'); - - CFCalendarIdentifier get kCFIslamicUmmAlQuraCalendar => - _kCFIslamicUmmAlQuraCalendar.value; - - late final ffi.Pointer _kCFBanglaCalendar = - _lookup('kCFBanglaCalendar'); - - CFCalendarIdentifier get kCFBanglaCalendar => _kCFBanglaCalendar.value; - - late final ffi.Pointer _kCFGujaratiCalendar = - _lookup('kCFGujaratiCalendar'); - - CFCalendarIdentifier get kCFGujaratiCalendar => _kCFGujaratiCalendar.value; - - late final ffi.Pointer _kCFKannadaCalendar = - _lookup('kCFKannadaCalendar'); - - CFCalendarIdentifier get kCFKannadaCalendar => _kCFKannadaCalendar.value; - - late final ffi.Pointer _kCFMalayalamCalendar = - _lookup('kCFMalayalamCalendar'); - - CFCalendarIdentifier get kCFMalayalamCalendar => _kCFMalayalamCalendar.value; - - late final ffi.Pointer _kCFMarathiCalendar = - _lookup('kCFMarathiCalendar'); - - CFCalendarIdentifier get kCFMarathiCalendar => _kCFMarathiCalendar.value; - - late final ffi.Pointer _kCFOdiaCalendar = - _lookup('kCFOdiaCalendar'); - - CFCalendarIdentifier get kCFOdiaCalendar => _kCFOdiaCalendar.value; - - late final ffi.Pointer _kCFTamilCalendar = - _lookup('kCFTamilCalendar'); - - CFCalendarIdentifier get kCFTamilCalendar => _kCFTamilCalendar.value; - - late final ffi.Pointer _kCFTeluguCalendar = - _lookup('kCFTeluguCalendar'); - - CFCalendarIdentifier get kCFTeluguCalendar => _kCFTeluguCalendar.value; - - late final ffi.Pointer _kCFVikramCalendar = - _lookup('kCFVikramCalendar'); - - CFCalendarIdentifier get kCFVikramCalendar => _kCFVikramCalendar.value; - - late final ffi.Pointer _kCFDangiCalendar = - _lookup('kCFDangiCalendar'); - - CFCalendarIdentifier get kCFDangiCalendar => _kCFDangiCalendar.value; - - late final ffi.Pointer _kCFVietnameseCalendar = - _lookup('kCFVietnameseCalendar'); - - CFCalendarIdentifier get kCFVietnameseCalendar => - _kCFVietnameseCalendar.value; - - double CFAbsoluteTimeGetCurrent() { - return _CFAbsoluteTimeGetCurrent(); - } - - late final _CFAbsoluteTimeGetCurrentPtr = - _lookup>( - 'CFAbsoluteTimeGetCurrent', - ); - late final _CFAbsoluteTimeGetCurrent = - _CFAbsoluteTimeGetCurrentPtr.asFunction(); - - late final ffi.Pointer _kCFAbsoluteTimeIntervalSince1970 = - _lookup('kCFAbsoluteTimeIntervalSince1970'); - - DartCFTimeInterval get kCFAbsoluteTimeIntervalSince1970 => - _kCFAbsoluteTimeIntervalSince1970.value; - - late final ffi.Pointer _kCFAbsoluteTimeIntervalSince1904 = - _lookup('kCFAbsoluteTimeIntervalSince1904'); - - DartCFTimeInterval get kCFAbsoluteTimeIntervalSince1904 => - _kCFAbsoluteTimeIntervalSince1904.value; - - int CFDateGetTypeID() { - return _CFDateGetTypeID(); - } - - late final _CFDateGetTypeIDPtr = - _lookup>('CFDateGetTypeID'); - late final _CFDateGetTypeID = - _CFDateGetTypeIDPtr.asFunction(); - - CFDateRef CFDateCreate(CFAllocatorRef allocator, double at) { - return _CFDateCreate(allocator, at); - } - - late final _CFDateCreatePtr = - _lookup< - ffi.NativeFunction - >('CFDateCreate'); - late final _CFDateCreate = - _CFDateCreatePtr.asFunction(); - - double CFDateGetAbsoluteTime(CFDateRef theDate) { - return _CFDateGetAbsoluteTime(theDate); - } - - late final _CFDateGetAbsoluteTimePtr = - _lookup>( - 'CFDateGetAbsoluteTime', - ); - late final _CFDateGetAbsoluteTime = - _CFDateGetAbsoluteTimePtr.asFunction(); - - double CFDateGetTimeIntervalSinceDate( - CFDateRef theDate, - CFDateRef otherDate, - ) { - return _CFDateGetTimeIntervalSinceDate(theDate, otherDate); - } - - late final _CFDateGetTimeIntervalSinceDatePtr = - _lookup< - ffi.NativeFunction - >('CFDateGetTimeIntervalSinceDate'); - late final _CFDateGetTimeIntervalSinceDate = - _CFDateGetTimeIntervalSinceDatePtr.asFunction< - double Function(CFDateRef, CFDateRef) - >(); - - CFComparisonResult CFDateCompare( - CFDateRef theDate, - CFDateRef otherDate, - ffi.Pointer context, - ) { - return CFComparisonResult.fromValue( - _CFDateCompare(theDate, otherDate, context), + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, ); } - late final _CFDateComparePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFDateRef, CFDateRef, ffi.Pointer) - > - >('CFDateCompare'); - late final _CFDateCompare = - _CFDateComparePtr.asFunction< - int Function(CFDateRef, CFDateRef, ffi.Pointer) - >(); - - int CFGregorianDateIsValid(CFGregorianDate gdate, int unitFlags) { - return _CFGregorianDateIsValid(gdate, unitFlags); - } - - late final _CFGregorianDateIsValidPtr = - _lookup< - ffi.NativeFunction - >('CFGregorianDateIsValid'); - late final _CFGregorianDateIsValid = - _CFGregorianDateIsValidPtr.asFunction< - int Function(CFGregorianDate, int) - >(); - - double CFGregorianDateGetAbsoluteTime( - CFGregorianDate gdate, - CFTimeZoneRef tz, - ) { - return _CFGregorianDateGetAbsoluteTime(gdate, tz); - } - - late final _CFGregorianDateGetAbsoluteTimePtr = - _lookup< - ffi.NativeFunction< - CFAbsoluteTime Function(CFGregorianDate, CFTimeZoneRef) - > - >('CFGregorianDateGetAbsoluteTime'); - late final _CFGregorianDateGetAbsoluteTime = - _CFGregorianDateGetAbsoluteTimePtr.asFunction< - double Function(CFGregorianDate, CFTimeZoneRef) - >(); - - CFGregorianDate CFAbsoluteTimeGetGregorianDate(double at, CFTimeZoneRef tz) { - return _CFAbsoluteTimeGetGregorianDate(at, tz); - } - - late final _CFAbsoluteTimeGetGregorianDatePtr = - _lookup< - ffi.NativeFunction< - CFGregorianDate Function(CFAbsoluteTime, CFTimeZoneRef) - > - >('CFAbsoluteTimeGetGregorianDate'); - late final _CFAbsoluteTimeGetGregorianDate = - _CFAbsoluteTimeGetGregorianDatePtr.asFunction< - CFGregorianDate Function(double, CFTimeZoneRef) - >(); - - double CFAbsoluteTimeAddGregorianUnits( - double at, - CFTimeZoneRef tz, - CFGregorianUnits units, + static void _listenerTrampoline( + ffi.Pointer block, + int arg0, + ffi.Pointer arg1, ) { - return _CFAbsoluteTimeAddGregorianUnits(at, tz, units); + (objc.getBlockClosure(block) + as void Function(int, ffi.Pointer))(arg0, arg1); + objc.objectRelease(block.cast()); } - late final _CFAbsoluteTimeAddGregorianUnitsPtr = - _lookup< - ffi.NativeFunction< - CFAbsoluteTime Function( - CFAbsoluteTime, - CFTimeZoneRef, - CFGregorianUnits, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Long, + ffi.Pointer, ) - > - >('CFAbsoluteTimeAddGregorianUnits'); - late final _CFAbsoluteTimeAddGregorianUnits = - _CFAbsoluteTimeAddGregorianUnitsPtr.asFunction< - double Function(double, CFTimeZoneRef, CFGregorianUnits) - >(); - - CFGregorianUnits CFAbsoluteTimeGetDifferenceAsGregorianUnits( - double at1, - double at2, - CFTimeZoneRef tz, - int unitFlags, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + int arg0, + ffi.Pointer arg1, ) { - return _CFAbsoluteTimeGetDifferenceAsGregorianUnits( - at1, - at2, - tz, - unitFlags, - ); + try { + (objc.getBlockClosure(block) + as void Function(int, ffi.Pointer))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFAbsoluteTimeGetDifferenceAsGregorianUnitsPtr = - _lookup< - ffi.NativeFunction< - CFGregorianUnits Function( - CFAbsoluteTime, - CFAbsoluteTime, - CFTimeZoneRef, - CFOptionFlags, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, ) - > - >('CFAbsoluteTimeGetDifferenceAsGregorianUnits'); - late final _CFAbsoluteTimeGetDifferenceAsGregorianUnits = - _CFAbsoluteTimeGetDifferenceAsGregorianUnitsPtr.asFunction< - CFGregorianUnits Function(double, double, CFTimeZoneRef, int) - >(); - - int CFAbsoluteTimeGetDayOfWeek(double at, CFTimeZoneRef tz) { - return _CFAbsoluteTimeGetDayOfWeek(at, tz); - } - - late final _CFAbsoluteTimeGetDayOfWeekPtr = - _lookup< - ffi.NativeFunction - >('CFAbsoluteTimeGetDayOfWeek'); - late final _CFAbsoluteTimeGetDayOfWeek = - _CFAbsoluteTimeGetDayOfWeekPtr.asFunction< - int Function(double, CFTimeZoneRef) - >(); - - int CFAbsoluteTimeGetDayOfYear(double at, CFTimeZoneRef tz) { - return _CFAbsoluteTimeGetDayOfYear(at, tz); - } - - late final _CFAbsoluteTimeGetDayOfYearPtr = - _lookup< - ffi.NativeFunction - >('CFAbsoluteTimeGetDayOfYear'); - late final _CFAbsoluteTimeGetDayOfYear = - _CFAbsoluteTimeGetDayOfYearPtr.asFunction< - int Function(double, CFTimeZoneRef) - >(); - - int CFAbsoluteTimeGetWeekOfYear(double at, CFTimeZoneRef tz) { - return _CFAbsoluteTimeGetWeekOfYear(at, tz); - } - - late final _CFAbsoluteTimeGetWeekOfYearPtr = - _lookup< - ffi.NativeFunction - >('CFAbsoluteTimeGetWeekOfYear'); - late final _CFAbsoluteTimeGetWeekOfYear = - _CFAbsoluteTimeGetWeekOfYearPtr.asFunction< - int Function(double, CFTimeZoneRef) - >(); - - int CFDataGetTypeID() { - return _CFDataGetTypeID(); - } - - late final _CFDataGetTypeIDPtr = - _lookup>('CFDataGetTypeID'); - late final _CFDataGetTypeID = - _CFDataGetTypeIDPtr.asFunction(); - - CFDataRef CFDataCreate( - CFAllocatorRef allocator, - ffi.Pointer bytes, - int length, - ) { - return _CFDataCreate(allocator, bytes, length); - } - - late final _CFDataCreatePtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function(CFAllocatorRef, ffi.Pointer, CFIndex) - > - >('CFDataCreate'); - late final _CFDataCreate = - _CFDataCreatePtr.asFunction< - CFDataRef Function(CFAllocatorRef, ffi.Pointer, int) - >(); - - CFDataRef CFDataCreateWithBytesNoCopy( - CFAllocatorRef allocator, - ffi.Pointer bytes, - int length, - CFAllocatorRef bytesDeallocator, - ) { - return _CFDataCreateWithBytesNoCopy( - allocator, - bytes, - length, - bytesDeallocator, - ); - } - - late final _CFDataCreateWithBytesNoCopyPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFAllocatorRef, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, ) - > - >('CFDataCreateWithBytesNoCopy'); - late final _CFDataCreateWithBytesNoCopy = - _CFDataCreateWithBytesNoCopyPtr.asFunction< - CFDataRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - CFAllocatorRef, - ) - >(); - - CFDataRef CFDataCreateCopy(CFAllocatorRef allocator, CFDataRef theData) { - return _CFDataCreateCopy(allocator, theData); - } - - late final _CFDataCreateCopyPtr = - _lookup< - ffi.NativeFunction - >('CFDataCreateCopy'); - late final _CFDataCreateCopy = - _CFDataCreateCopyPtr.asFunction< - CFDataRef Function(CFAllocatorRef, CFDataRef) - >(); - - CFMutableDataRef CFDataCreateMutable(CFAllocatorRef allocator, int capacity) { - return _CFDataCreateMutable(allocator, capacity); - } - - late final _CFDataCreateMutablePtr = - _lookup< - ffi.NativeFunction - >('CFDataCreateMutable'); - late final _CFDataCreateMutable = - _CFDataCreateMutablePtr.asFunction< - CFMutableDataRef Function(CFAllocatorRef, int) - >(); - - CFMutableDataRef CFDataCreateMutableCopy( - CFAllocatorRef allocator, - int capacity, - CFDataRef theData, - ) { - return _CFDataCreateMutableCopy(allocator, capacity, theData); - } - - late final _CFDataCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableDataRef Function(CFAllocatorRef, CFIndex, CFDataRef) - > - >('CFDataCreateMutableCopy'); - late final _CFDataCreateMutableCopy = - _CFDataCreateMutableCopyPtr.asFunction< - CFMutableDataRef Function(CFAllocatorRef, int, CFDataRef) - >(); - - int CFDataGetLength(CFDataRef theData) { - return _CFDataGetLength(theData); - } - - late final _CFDataGetLengthPtr = - _lookup>( - 'CFDataGetLength', - ); - late final _CFDataGetLength = - _CFDataGetLengthPtr.asFunction(); - - ffi.Pointer CFDataGetBytePtr(CFDataRef theData) { - return _CFDataGetBytePtr(theData); - } - - late final _CFDataGetBytePtrPtr = - _lookup Function(CFDataRef)>>( - 'CFDataGetBytePtr', + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + int arg0, + ffi.Pointer arg1, + ) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Long arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction)>()( + arg0, + arg1, ); - late final _CFDataGetBytePtr = - _CFDataGetBytePtrPtr.asFunction Function(CFDataRef)>(); - - ffi.Pointer CFDataGetMutableBytePtr(CFMutableDataRef theData) { - return _CFDataGetMutableBytePtr(theData); - } - - late final _CFDataGetMutableBytePtrPtr = - _lookup< - ffi.NativeFunction Function(CFMutableDataRef)> - >('CFDataGetMutableBytePtr'); - late final _CFDataGetMutableBytePtr = - _CFDataGetMutableBytePtrPtr.asFunction< - ffi.Pointer Function(CFMutableDataRef) - >(); - - void CFDataGetBytes( - CFDataRef theData, - CFRange range, - ffi.Pointer buffer, - ) { - return _CFDataGetBytes(theData, range, buffer); - } - - late final _CFDataGetBytesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFDataRef, CFRange, ffi.Pointer) - > - >('CFDataGetBytes'); - late final _CFDataGetBytes = - _CFDataGetBytesPtr.asFunction< - void Function(CFDataRef, CFRange, ffi.Pointer) - >(); - - void CFDataSetLength(CFMutableDataRef theData, int length) { - return _CFDataSetLength(theData, length); - } + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + int arg0, + ffi.Pointer arg1, + ) => + (objc.getBlockClosure(block) + as void Function(int, ffi.Pointer))(arg0, arg1); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFDataSetLengthPtr = - _lookup>( - 'CFDataSetLength', - ); - late final _CFDataSetLength = - _CFDataSetLengthPtr.asFunction(); +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest$CallExtension + on objc.ObjCBlock { + void call(NSURLSessionDelayedRequestDisposition arg0, NSURLRequest? arg1) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Long arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + int, + ffi.Pointer, + ) + >()(ref.pointer, arg0.value, arg1?.ref.pointer ?? ffi.nullptr); +} - void CFDataIncreaseLength(CFMutableDataRef theData, int extraLength) { - return _CFDataIncreaseLength(theData, extraLength); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLResponse, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + >(pointer, retain: retain, release: release); - late final _CFDataIncreaseLengthPtr = - _lookup>( - 'CFDataIncreaseLength', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _CFDataIncreaseLength = - _CFDataIncreaseLengthPtr.asFunction< - void Function(CFMutableDataRef, int) - >(); - - void CFDataAppendBytes( - CFMutableDataRef theData, - ffi.Pointer bytes, - int length, - ) { - return _CFDataAppendBytes(theData, bytes, length); - } - - late final _CFDataAppendBytesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableDataRef, ffi.Pointer, CFIndex) - > - >('CFDataAppendBytes'); - late final _CFDataAppendBytes = - _CFDataAppendBytesPtr.asFunction< - void Function(CFMutableDataRef, ffi.Pointer, int) - >(); - - void CFDataReplaceBytes( - CFMutableDataRef theData, - CFRange range, - ffi.Pointer newBytes, - int newLength, - ) { - return _CFDataReplaceBytes(theData, range, newBytes, newLength); - } - late final _CFDataReplaceBytesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableDataRef, - CFRange, - ffi.Pointer, - CFIndex, - ) - > - >('CFDataReplaceBytes'); - late final _CFDataReplaceBytes = - _CFDataReplaceBytesPtr.asFunction< - void Function(CFMutableDataRef, CFRange, ffi.Pointer, int) - >(); - - void CFDataDeleteBytes(CFMutableDataRef theData, CFRange range) { - return _CFDataDeleteBytes(theData, range); - } - - late final _CFDataDeleteBytesPtr = - _lookup>( - 'CFDataDeleteBytes', - ); - late final _CFDataDeleteBytes = - _CFDataDeleteBytesPtr.asFunction< - void Function(CFMutableDataRef, CFRange) - >(); - - CFRange CFDataFind( - CFDataRef theData, - CFDataRef dataToFind, - CFRange searchRange, - int compareOptions, - ) { - return _CFDataFind(theData, dataToFind, searchRange, compareOptions); - } - - late final _CFDataFindPtr = - _lookup< - ffi.NativeFunction< - CFRange Function(CFDataRef, CFDataRef, CFRange, CFOptionFlags) - > - >('CFDataFind'); - late final _CFDataFind = - _CFDataFindPtr.asFunction< - CFRange Function(CFDataRef, CFDataRef, CFRange, int) - >(); - - int CFCharacterSetGetTypeID() { - return _CFCharacterSetGetTypeID(); - } - - late final _CFCharacterSetGetTypeIDPtr = - _lookup>( - 'CFCharacterSetGetTypeID', - ); - late final _CFCharacterSetGetTypeID = - _CFCharacterSetGetTypeIDPtr.asFunction(); - - CFCharacterSetRef CFCharacterSetGetPredefined( - CFCharacterSetPredefinedSet theSetIdentifier, - ) { - return _CFCharacterSetGetPredefined(theSetIdentifier.value); - } - - late final _CFCharacterSetGetPredefinedPtr = - _lookup>( - 'CFCharacterSetGetPredefined', - ); - late final _CFCharacterSetGetPredefined = - _CFCharacterSetGetPredefinedPtr.asFunction< - CFCharacterSetRef Function(int) - >(); - - CFCharacterSetRef CFCharacterSetCreateWithCharactersInRange( - CFAllocatorRef alloc, - CFRange theRange, - ) { - return _CFCharacterSetCreateWithCharactersInRange(alloc, theRange); - } - - late final _CFCharacterSetCreateWithCharactersInRangePtr = - _lookup< - ffi.NativeFunction - >('CFCharacterSetCreateWithCharactersInRange'); - late final _CFCharacterSetCreateWithCharactersInRange = - _CFCharacterSetCreateWithCharactersInRangePtr.asFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFRange) - >(); - - CFCharacterSetRef CFCharacterSetCreateWithCharactersInString( - CFAllocatorRef alloc, - CFStringRef theString, - ) { - return _CFCharacterSetCreateWithCharactersInString(alloc, theString); - } - - late final _CFCharacterSetCreateWithCharactersInStringPtr = - _lookup< - ffi.NativeFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFStringRef) - > - >('CFCharacterSetCreateWithCharactersInString'); - late final _CFCharacterSetCreateWithCharactersInString = - _CFCharacterSetCreateWithCharactersInStringPtr.asFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFStringRef) - >(); - - CFCharacterSetRef CFCharacterSetCreateWithBitmapRepresentation( - CFAllocatorRef alloc, - CFDataRef theData, - ) { - return _CFCharacterSetCreateWithBitmapRepresentation(alloc, theData); - } - - late final _CFCharacterSetCreateWithBitmapRepresentationPtr = - _lookup< - ffi.NativeFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFDataRef) - > - >('CFCharacterSetCreateWithBitmapRepresentation'); - late final _CFCharacterSetCreateWithBitmapRepresentation = - _CFCharacterSetCreateWithBitmapRepresentationPtr.asFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFDataRef) - >(); - - CFCharacterSetRef CFCharacterSetCreateInvertedSet( - CFAllocatorRef alloc, - CFCharacterSetRef theSet, - ) { - return _CFCharacterSetCreateInvertedSet(alloc, theSet); - } - - late final _CFCharacterSetCreateInvertedSetPtr = - _lookup< - ffi.NativeFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFCharacterSetRef) - > - >('CFCharacterSetCreateInvertedSet'); - late final _CFCharacterSetCreateInvertedSet = - _CFCharacterSetCreateInvertedSetPtr.asFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFCharacterSetRef) - >(); - - int CFCharacterSetIsSupersetOfSet( - CFCharacterSetRef theSet, - CFCharacterSetRef theOtherset, - ) { - return _CFCharacterSetIsSupersetOfSet(theSet, theOtherset); - } - - late final _CFCharacterSetIsSupersetOfSetPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFCharacterSetRef, CFCharacterSetRef) - > - >('CFCharacterSetIsSupersetOfSet'); - late final _CFCharacterSetIsSupersetOfSet = - _CFCharacterSetIsSupersetOfSetPtr.asFunction< - int Function(CFCharacterSetRef, CFCharacterSetRef) - >(); - - int CFCharacterSetHasMemberInPlane(CFCharacterSetRef theSet, int thePlane) { - return _CFCharacterSetHasMemberInPlane(theSet, thePlane); - } - - late final _CFCharacterSetHasMemberInPlanePtr = - _lookup>( - 'CFCharacterSetHasMemberInPlane', - ); - late final _CFCharacterSetHasMemberInPlane = - _CFCharacterSetHasMemberInPlanePtr.asFunction< - int Function(CFCharacterSetRef, int) - >(); - - CFMutableCharacterSetRef CFCharacterSetCreateMutable(CFAllocatorRef alloc) { - return _CFCharacterSetCreateMutable(alloc); - } - - late final _CFCharacterSetCreateMutablePtr = - _lookup< - ffi.NativeFunction - >('CFCharacterSetCreateMutable'); - late final _CFCharacterSetCreateMutable = - _CFCharacterSetCreateMutablePtr.asFunction< - CFMutableCharacterSetRef Function(CFAllocatorRef) - >(); - - CFCharacterSetRef CFCharacterSetCreateCopy( - CFAllocatorRef alloc, - CFCharacterSetRef theSet, - ) { - return _CFCharacterSetCreateCopy(alloc, theSet); - } - - late final _CFCharacterSetCreateCopyPtr = - _lookup< - ffi.NativeFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFCharacterSetRef) - > - >('CFCharacterSetCreateCopy'); - late final _CFCharacterSetCreateCopy = - _CFCharacterSetCreateCopyPtr.asFunction< - CFCharacterSetRef Function(CFAllocatorRef, CFCharacterSetRef) - >(); - - CFMutableCharacterSetRef CFCharacterSetCreateMutableCopy( - CFAllocatorRef alloc, - CFCharacterSetRef theSet, - ) { - return _CFCharacterSetCreateMutableCopy(alloc, theSet); - } - - late final _CFCharacterSetCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableCharacterSetRef Function(CFAllocatorRef, CFCharacterSetRef) - > - >('CFCharacterSetCreateMutableCopy'); - late final _CFCharacterSetCreateMutableCopy = - _CFCharacterSetCreateMutableCopyPtr.asFunction< - CFMutableCharacterSetRef Function(CFAllocatorRef, CFCharacterSetRef) - >(); - - int CFCharacterSetIsCharacterMember(CFCharacterSetRef theSet, int theChar) { - return _CFCharacterSetIsCharacterMember(theSet, theChar); - } - - late final _CFCharacterSetIsCharacterMemberPtr = - _lookup>( - 'CFCharacterSetIsCharacterMember', - ); - late final _CFCharacterSetIsCharacterMember = - _CFCharacterSetIsCharacterMemberPtr.asFunction< - int Function(CFCharacterSetRef, int) - >(); - - int CFCharacterSetIsLongCharacterMember( - CFCharacterSetRef theSet, - int theChar, - ) { - return _CFCharacterSetIsLongCharacterMember(theSet, theChar); - } - - late final _CFCharacterSetIsLongCharacterMemberPtr = - _lookup< - ffi.NativeFunction - >('CFCharacterSetIsLongCharacterMember'); - late final _CFCharacterSetIsLongCharacterMember = - _CFCharacterSetIsLongCharacterMemberPtr.asFunction< - int Function(CFCharacterSetRef, int) - >(); - - CFDataRef CFCharacterSetCreateBitmapRepresentation( - CFAllocatorRef alloc, - CFCharacterSetRef theSet, - ) { - return _CFCharacterSetCreateBitmapRepresentation(alloc, theSet); - } - - late final _CFCharacterSetCreateBitmapRepresentationPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function(CFAllocatorRef, CFCharacterSetRef) - > - >('CFCharacterSetCreateBitmapRepresentation'); - late final _CFCharacterSetCreateBitmapRepresentation = - _CFCharacterSetCreateBitmapRepresentationPtr.asFunction< - CFDataRef Function(CFAllocatorRef, CFCharacterSetRef) - >(); - - void CFCharacterSetAddCharactersInRange( - CFMutableCharacterSetRef theSet, - CFRange theRange, - ) { - return _CFCharacterSetAddCharactersInRange(theSet, theRange); - } - - late final _CFCharacterSetAddCharactersInRangePtr = - _lookup< - ffi.NativeFunction - >('CFCharacterSetAddCharactersInRange'); - late final _CFCharacterSetAddCharactersInRange = - _CFCharacterSetAddCharactersInRangePtr.asFunction< - void Function(CFMutableCharacterSetRef, CFRange) - >(); - - void CFCharacterSetRemoveCharactersInRange( - CFMutableCharacterSetRef theSet, - CFRange theRange, - ) { - return _CFCharacterSetRemoveCharactersInRange(theSet, theRange); - } - - late final _CFCharacterSetRemoveCharactersInRangePtr = - _lookup< - ffi.NativeFunction - >('CFCharacterSetRemoveCharactersInRange'); - late final _CFCharacterSetRemoveCharactersInRange = - _CFCharacterSetRemoveCharactersInRangePtr.asFunction< - void Function(CFMutableCharacterSetRef, CFRange) - >(); - - void CFCharacterSetAddCharactersInString( - CFMutableCharacterSetRef theSet, - CFStringRef theString, - ) { - return _CFCharacterSetAddCharactersInString(theSet, theString); - } - - late final _CFCharacterSetAddCharactersInStringPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableCharacterSetRef, CFStringRef) - > - >('CFCharacterSetAddCharactersInString'); - late final _CFCharacterSetAddCharactersInString = - _CFCharacterSetAddCharactersInStringPtr.asFunction< - void Function(CFMutableCharacterSetRef, CFStringRef) - >(); - - void CFCharacterSetRemoveCharactersInString( - CFMutableCharacterSetRef theSet, - CFStringRef theString, - ) { - return _CFCharacterSetRemoveCharactersInString(theSet, theString); - } - - late final _CFCharacterSetRemoveCharactersInStringPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableCharacterSetRef, CFStringRef) - > - >('CFCharacterSetRemoveCharactersInString'); - late final _CFCharacterSetRemoveCharactersInString = - _CFCharacterSetRemoveCharactersInStringPtr.asFunction< - void Function(CFMutableCharacterSetRef, CFStringRef) - >(); - - void CFCharacterSetUnion( - CFMutableCharacterSetRef theSet, - CFCharacterSetRef theOtherSet, - ) { - return _CFCharacterSetUnion(theSet, theOtherSet); - } - - late final _CFCharacterSetUnionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableCharacterSetRef, CFCharacterSetRef) - > - >('CFCharacterSetUnion'); - late final _CFCharacterSetUnion = - _CFCharacterSetUnionPtr.asFunction< - void Function(CFMutableCharacterSetRef, CFCharacterSetRef) - >(); - - void CFCharacterSetIntersect( - CFMutableCharacterSetRef theSet, - CFCharacterSetRef theOtherSet, - ) { - return _CFCharacterSetIntersect(theSet, theOtherSet); - } - - late final _CFCharacterSetIntersectPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableCharacterSetRef, CFCharacterSetRef) - > - >('CFCharacterSetIntersect'); - late final _CFCharacterSetIntersect = - _CFCharacterSetIntersectPtr.asFunction< - void Function(CFMutableCharacterSetRef, CFCharacterSetRef) - >(); - - void CFCharacterSetInvert(CFMutableCharacterSetRef theSet) { - return _CFCharacterSetInvert(theSet); - } - - late final _CFCharacterSetInvertPtr = - _lookup>( - 'CFCharacterSetInvert', - ); - late final _CFCharacterSetInvert = - _CFCharacterSetInvertPtr.asFunction< - void Function(CFMutableCharacterSetRef) - >(); - - int CFErrorGetTypeID() { - return _CFErrorGetTypeID(); - } - - late final _CFErrorGetTypeIDPtr = - _lookup>('CFErrorGetTypeID'); - late final _CFErrorGetTypeID = - _CFErrorGetTypeIDPtr.asFunction(); - - late final ffi.Pointer _kCFErrorDomainPOSIX = - _lookup('kCFErrorDomainPOSIX'); - - CFErrorDomain get kCFErrorDomainPOSIX => _kCFErrorDomainPOSIX.value; - - late final ffi.Pointer _kCFErrorDomainOSStatus = - _lookup('kCFErrorDomainOSStatus'); - - CFErrorDomain get kCFErrorDomainOSStatus => _kCFErrorDomainOSStatus.value; - - late final ffi.Pointer _kCFErrorDomainMach = - _lookup('kCFErrorDomainMach'); - - CFErrorDomain get kCFErrorDomainMach => _kCFErrorDomainMach.value; - - late final ffi.Pointer _kCFErrorDomainCocoa = - _lookup('kCFErrorDomainCocoa'); - - CFErrorDomain get kCFErrorDomainCocoa => _kCFErrorDomainCocoa.value; - - late final ffi.Pointer _kCFErrorLocalizedDescriptionKey = - _lookup('kCFErrorLocalizedDescriptionKey'); - - CFStringRef get kCFErrorLocalizedDescriptionKey => - _kCFErrorLocalizedDescriptionKey.value; - - late final ffi.Pointer _kCFErrorLocalizedFailureKey = - _lookup('kCFErrorLocalizedFailureKey'); - - CFStringRef get kCFErrorLocalizedFailureKey => - _kCFErrorLocalizedFailureKey.value; - - late final ffi.Pointer _kCFErrorLocalizedFailureReasonKey = - _lookup('kCFErrorLocalizedFailureReasonKey'); - - CFStringRef get kCFErrorLocalizedFailureReasonKey => - _kCFErrorLocalizedFailureReasonKey.value; - - late final ffi.Pointer _kCFErrorLocalizedRecoverySuggestionKey = - _lookup('kCFErrorLocalizedRecoverySuggestionKey'); - - CFStringRef get kCFErrorLocalizedRecoverySuggestionKey => - _kCFErrorLocalizedRecoverySuggestionKey.value; - - late final ffi.Pointer _kCFErrorDescriptionKey = - _lookup('kCFErrorDescriptionKey'); - - CFStringRef get kCFErrorDescriptionKey => _kCFErrorDescriptionKey.value; - - late final ffi.Pointer _kCFErrorUnderlyingErrorKey = - _lookup('kCFErrorUnderlyingErrorKey'); - - CFStringRef get kCFErrorUnderlyingErrorKey => - _kCFErrorUnderlyingErrorKey.value; - - late final ffi.Pointer _kCFErrorURLKey = _lookup( - 'kCFErrorURLKey', - ); - - CFStringRef get kCFErrorURLKey => _kCFErrorURLKey.value; - - late final ffi.Pointer _kCFErrorFilePathKey = - _lookup('kCFErrorFilePathKey'); - - CFStringRef get kCFErrorFilePathKey => _kCFErrorFilePathKey.value; - - CFErrorRef CFErrorCreate( - CFAllocatorRef allocator, - CFErrorDomain domain, - int code, - CFDictionaryRef userInfo, - ) { - return _CFErrorCreate(allocator, domain, code, userInfo); - } - - late final _CFErrorCreatePtr = - _lookup< - ffi.NativeFunction< - CFErrorRef Function( - CFAllocatorRef, - CFErrorDomain, - CFIndex, - CFDictionaryRef, - ) - > - >('CFErrorCreate'); - late final _CFErrorCreate = - _CFErrorCreatePtr.asFunction< - CFErrorRef Function(CFAllocatorRef, CFErrorDomain, int, CFDictionaryRef) - >(); - - CFErrorRef CFErrorCreateWithUserInfoKeysAndValues( - CFAllocatorRef allocator, - CFErrorDomain domain, - int code, - ffi.Pointer> userInfoKeys, - ffi.Pointer> userInfoValues, - int numUserInfoValues, - ) { - return _CFErrorCreateWithUserInfoKeysAndValues( - allocator, - domain, - code, - userInfoKeys, - userInfoValues, - numUserInfoValues, - ); - } - - late final _CFErrorCreateWithUserInfoKeysAndValuesPtr = - _lookup< - ffi.NativeFunction< - CFErrorRef Function( - CFAllocatorRef, - CFErrorDomain, - CFIndex, - ffi.Pointer>, - ffi.Pointer>, - CFIndex, - ) - > - >('CFErrorCreateWithUserInfoKeysAndValues'); - late final _CFErrorCreateWithUserInfoKeysAndValues = - _CFErrorCreateWithUserInfoKeysAndValuesPtr.asFunction< - CFErrorRef Function( - CFAllocatorRef, - CFErrorDomain, - int, - ffi.Pointer>, - ffi.Pointer>, - int, + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, ) - >(); - - CFErrorDomain CFErrorGetDomain(CFErrorRef err) { - return _CFErrorGetDomain(err); - } - - late final _CFErrorGetDomainPtr = - _lookup>( - 'CFErrorGetDomain', - ); - late final _CFErrorGetDomain = - _CFErrorGetDomainPtr.asFunction(); - - int CFErrorGetCode(CFErrorRef err) { - return _CFErrorGetCode(err); - } - - late final _CFErrorGetCodePtr = - _lookup>( - 'CFErrorGetCode', - ); - late final _CFErrorGetCode = - _CFErrorGetCodePtr.asFunction(); - - CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err) { - return _CFErrorCopyUserInfo(err); - } - - late final _CFErrorCopyUserInfoPtr = - _lookup>( - 'CFErrorCopyUserInfo', - ); - late final _CFErrorCopyUserInfo = - _CFErrorCopyUserInfoPtr.asFunction< - CFDictionaryRef Function(CFErrorRef) - >(); - - CFStringRef CFErrorCopyDescription(CFErrorRef err) { - return _CFErrorCopyDescription(err); - } - - late final _CFErrorCopyDescriptionPtr = - _lookup>( - 'CFErrorCopyDescription', - ); - late final _CFErrorCopyDescription = - _CFErrorCopyDescriptionPtr.asFunction(); - - CFStringRef CFErrorCopyFailureReason(CFErrorRef err) { - return _CFErrorCopyFailureReason(err); - } - - late final _CFErrorCopyFailureReasonPtr = - _lookup>( - 'CFErrorCopyFailureReason', + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), + NSURLResponse.fromPointer(arg3, retain: true, release: true), + ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( + arg4, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _CFErrorCopyFailureReason = - _CFErrorCopyFailureReasonPtr.asFunction< - CFStringRef Function(CFErrorRef) - >(); - CFStringRef CFErrorCopyRecoverySuggestion(CFErrorRef err) { - return _CFErrorCopyRecoverySuggestion(err); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLResponse.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xx612k(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _CFErrorCopyRecoverySuggestionPtr = - _lookup>( - 'CFErrorCopyRecoverySuggestion', - ); - late final _CFErrorCopyRecoverySuggestion = - _CFErrorCopyRecoverySuggestionPtr.asFunction< - CFStringRef Function(CFErrorRef) - >(); - - int CFStringGetTypeID() { - return _CFStringGetTypeID(); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLResponse.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLResponse.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _CFStringGetTypeIDPtr = - _lookup>('CFStringGetTypeID'); - late final _CFStringGetTypeID = - _CFStringGetTypeIDPtr.asFunction(); - - CFStringRef CFStringCreateWithPascalString( - CFAllocatorRef alloc, - ConstStr255Param pStr, - int encoding, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) { - return _CFStringCreateWithPascalString(alloc, pStr, encoding); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + objc.objectRelease(block.cast()); } - late final _CFStringCreateWithPascalStringPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - ConstStr255Param, - CFStringEncoding, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFStringCreateWithPascalString'); - late final _CFStringCreateWithPascalString = - _CFStringCreateWithPascalStringPtr.asFunction< - CFStringRef Function(CFAllocatorRef, ConstStr255Param, int) - >(); - - CFStringRef CFStringCreateWithCString( - CFAllocatorRef alloc, - ffi.Pointer cStr, - int encoding, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) { - return _CFStringCreateWithCString(alloc, cStr, encoding); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFStringCreateWithCStringPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - ffi.Pointer, - CFStringEncoding, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFStringCreateWithCString'); - late final _CFStringCreateWithCString = - _CFStringCreateWithCStringPtr.asFunction< - CFStringRef Function(CFAllocatorRef, ffi.Pointer, int) - >(); - - CFStringRef CFStringCreateWithBytes( - CFAllocatorRef alloc, - ffi.Pointer bytes, - int numBytes, - int encoding, - int isExternalRepresentation, - ) { - return _CFStringCreateWithBytes( - alloc, - bytes, - numBytes, - encoding, - isExternalRepresentation, - ); - } - - late final _CFStringCreateWithBytesPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFStringEncoding, - Boolean, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFStringCreateWithBytes'); - late final _CFStringCreateWithBytes = - _CFStringCreateWithBytesPtr.asFunction< - CFStringRef Function(CFAllocatorRef, ffi.Pointer, int, int, int) - >(); - - CFStringRef CFStringCreateWithCharacters( - CFAllocatorRef alloc, - ffi.Pointer chars, - int numChars, - ) { - return _CFStringCreateWithCharacters(alloc, chars, numChars); - } - - late final _CFStringCreateWithCharactersPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, ffi.Pointer, CFIndex) - > - >('CFStringCreateWithCharacters'); - late final _CFStringCreateWithCharacters = - _CFStringCreateWithCharactersPtr.asFunction< - CFStringRef Function(CFAllocatorRef, ffi.Pointer, int) - >(); - - CFStringRef CFStringCreateWithPascalStringNoCopy( - CFAllocatorRef alloc, - ConstStr255Param pStr, - int encoding, - CFAllocatorRef contentsDeallocator, - ) { - return _CFStringCreateWithPascalStringNoCopy( - alloc, - pStr, - encoding, - contentsDeallocator, - ); - } - - late final _CFStringCreateWithPascalStringNoCopyPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => block.ref.target + .cast< ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - ConstStr255Param, - CFStringEncoding, - CFAllocatorRef, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) > - >('CFStringCreateWithPascalStringNoCopy'); - late final _CFStringCreateWithPascalStringNoCopy = - _CFStringCreateWithPascalStringNoCopyPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - ConstStr255Param, - int, - CFAllocatorRef, - ) - >(); - - CFStringRef CFStringCreateWithCStringNoCopy( - CFAllocatorRef alloc, - ffi.Pointer cStr, - int encoding, - CFAllocatorRef contentsDeallocator, - ) { - return _CFStringCreateWithCStringNoCopy( - alloc, - cStr, - encoding, - contentsDeallocator, - ); - } - - late final _CFStringCreateWithCStringNoCopyPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - ffi.Pointer, - CFStringEncoding, - CFAllocatorRef, - ) - > - >('CFStringCreateWithCStringNoCopy'); - late final _CFStringCreateWithCStringNoCopy = - _CFStringCreateWithCStringNoCopyPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - CFAllocatorRef, - ) - >(); - - CFStringRef CFStringCreateWithBytesNoCopy( - CFAllocatorRef alloc, - ffi.Pointer bytes, - int numBytes, - int encoding, - int isExternalRepresentation, - CFAllocatorRef contentsDeallocator, - ) { - return _CFStringCreateWithBytesNoCopy( - alloc, - bytes, - numBytes, - encoding, - isExternalRepresentation, - contentsDeallocator, - ); - } - - late final _CFStringCreateWithBytesNoCopyPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFStringEncoding, - Boolean, - CFAllocatorRef, - ) - > - >('CFStringCreateWithBytesNoCopy'); - late final _CFStringCreateWithBytesNoCopy = - _CFStringCreateWithBytesNoCopyPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - int, - int, - CFAllocatorRef, - ) - >(); - - CFStringRef CFStringCreateWithCharactersNoCopy( - CFAllocatorRef alloc, - ffi.Pointer chars, - int numChars, - CFAllocatorRef contentsDeallocator, - ) { - return _CFStringCreateWithCharactersNoCopy( - alloc, - chars, - numChars, - contentsDeallocator, - ); - } - - late final _CFStringCreateWithCharactersNoCopyPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFAllocatorRef, - ) - > - >('CFStringCreateWithCharactersNoCopy'); - late final _CFStringCreateWithCharactersNoCopy = - _CFStringCreateWithCharactersNoCopyPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - CFAllocatorRef, + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - CFStringRef CFStringCreateWithSubstring( - CFAllocatorRef alloc, - CFStringRef str, - CFRange range, - ) { - return _CFStringCreateWithSubstring(alloc, str, range); - } - - late final _CFStringCreateWithSubstringPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFRange) - > - >('CFStringCreateWithSubstring'); - late final _CFStringCreateWithSubstring = - _CFStringCreateWithSubstringPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFRange) - >(); - - CFStringRef CFStringCreateCopy(CFAllocatorRef alloc, CFStringRef theString) { - return _CFStringCreateCopy(alloc, theString); - } - - late final _CFStringCreateCopyPtr = - _lookup< - ffi.NativeFunction - >('CFStringCreateCopy'); - late final _CFStringCreateCopy = - _CFStringCreateCopyPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef) - >(); - - CFStringRef CFStringCreateWithFormat( - CFAllocatorRef alloc, - CFDictionaryRef formatOptions, - CFStringRef format, - ) { - return _CFStringCreateWithFormat(alloc, formatOptions, format); - } - - late final _CFStringCreateWithFormatPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, CFDictionaryRef, CFStringRef) - > - >('CFStringCreateWithFormat'); - late final _CFStringCreateWithFormat = - _CFStringCreateWithFormatPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFDictionaryRef, CFStringRef) - >(); - - CFStringRef CFStringCreateWithFormatAndArguments( - CFAllocatorRef alloc, - CFDictionaryRef formatOptions, - CFStringRef format, - va_list arguments, - ) { - return _CFStringCreateWithFormatAndArguments( - alloc, - formatOptions, - format, - arguments, - ); - } + >()(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFStringCreateWithFormatAndArgumentsPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFDictionaryRef, - CFStringRef, - va_list, +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLResponse, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, ) - > - >('CFStringCreateWithFormatAndArguments'); - late final _CFStringCreateWithFormatAndArguments = - _CFStringCreateWithFormatAndArgumentsPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - CFDictionaryRef, - CFStringRef, - va_list, - ) - >(); - - CFStringRef CFStringCreateStringWithValidatedFormat( - CFAllocatorRef alloc, - CFDictionaryRef formatOptions, - CFStringRef validFormatSpecifiers, - CFStringRef format, - ffi.Pointer errorPtr, - ) { - return _CFStringCreateStringWithValidatedFormat( - alloc, - formatOptions, - validFormatSpecifiers, - format, - errorPtr, - ); - } + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLResponse arg3, + objc.ObjCBlock arg4, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, + arg4.ref.pointer, + ); +} - late final _CFStringCreateStringWithValidatedFormatPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFDictionaryRef, - CFStringRef, - CFStringRef, - ffi.Pointer, - ) - > - >('CFStringCreateStringWithValidatedFormat'); - late final _CFStringCreateStringWithValidatedFormat = - _CFStringCreateStringWithValidatedFormatPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - CFDictionaryRef, - CFStringRef, - CFStringRef, - ffi.Pointer, +late final _sel_URLSession_dataTask_didBecomeDownloadTask_ = objc.registerName( + "URLSession:dataTask:didBecomeDownloadTask:", +); +final _objc_msgSend_r8gdi7 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - CFStringRef CFStringCreateStringWithValidatedFormatAndArguments( - CFAllocatorRef alloc, - CFDictionaryRef formatOptions, - CFStringRef validFormatSpecifiers, - CFStringRef format, - va_list arguments, - ffi.Pointer errorPtr, - ) { - return _CFStringCreateStringWithValidatedFormatAndArguments( - alloc, - formatOptions, - validFormatSpecifiers, - format, - arguments, - errorPtr, - ); - } - - late final _CFStringCreateStringWithValidatedFormatAndArgumentsPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFDictionaryRef, - CFStringRef, - CFStringRef, - va_list, - ffi.Pointer, - ) - > - >('CFStringCreateStringWithValidatedFormatAndArguments'); - late final _CFStringCreateStringWithValidatedFormatAndArguments = - _CFStringCreateStringWithValidatedFormatAndArgumentsPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - CFDictionaryRef, - CFStringRef, - CFStringRef, - va_list, - ffi.Pointer, + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _class_NSHTTPURLResponse = objc.getClass("NSHTTPURLResponse"); +late final _sel_initWithURL_statusCode_HTTPVersion_headerFields_ = objc + .registerName("initWithURL:statusCode:HTTPVersion:headerFields:"); +final _objc_msgSend_xw7l5 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ffi.Pointer, ) - >(); - - CFMutableStringRef CFStringCreateMutable( - CFAllocatorRef alloc, - int maxLength, - ) { - return _CFStringCreateMutable(alloc, maxLength); - } - - late final _CFStringCreateMutablePtr = - _lookup< - ffi.NativeFunction - >('CFStringCreateMutable'); - late final _CFStringCreateMutable = - _CFStringCreateMutablePtr.asFunction< - CFMutableStringRef Function(CFAllocatorRef, int) - >(); - - CFMutableStringRef CFStringCreateMutableCopy( - CFAllocatorRef alloc, - int maxLength, - CFStringRef theString, - ) { - return _CFStringCreateMutableCopy(alloc, maxLength, theString); - } - - late final _CFStringCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableStringRef Function(CFAllocatorRef, CFIndex, CFStringRef) - > - >('CFStringCreateMutableCopy'); - late final _CFStringCreateMutableCopy = - _CFStringCreateMutableCopyPtr.asFunction< - CFMutableStringRef Function(CFAllocatorRef, int, CFStringRef) - >(); - - CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy( - CFAllocatorRef alloc, - ffi.Pointer chars, - int numChars, - int capacity, - CFAllocatorRef externalCharactersAllocator, - ) { - return _CFStringCreateMutableWithExternalCharactersNoCopy( - alloc, - chars, - numChars, - capacity, - externalCharactersAllocator, - ); - } - - late final _CFStringCreateMutableWithExternalCharactersNoCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableStringRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFIndex, - CFAllocatorRef, - ) - > - >('CFStringCreateMutableWithExternalCharactersNoCopy'); - late final _CFStringCreateMutableWithExternalCharactersNoCopy = - _CFStringCreateMutableWithExternalCharactersNoCopyPtr.asFunction< - CFMutableStringRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - int, - CFAllocatorRef, + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_statusCode = objc.registerName("statusCode"); +late final _sel_allHeaderFields = objc.registerName("allHeaderFields"); +late final _sel_localizedStringForStatusCode_ = objc.registerName( + "localizedStringForStatusCode:", +); +final _objc_msgSend_qugqlf = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, ) - >(); - - int CFStringGetLength(CFStringRef theString) { - return _CFStringGetLength(theString); - } - - late final _CFStringGetLengthPtr = - _lookup>( - 'CFStringGetLength', - ); - late final _CFStringGetLength = - _CFStringGetLengthPtr.asFunction(); - - int CFStringGetCharacterAtIndex(CFStringRef theString, int idx) { - return _CFStringGetCharacterAtIndex(theString, idx); - } - - late final _CFStringGetCharacterAtIndexPtr = - _lookup>( - 'CFStringGetCharacterAtIndex', - ); - late final _CFStringGetCharacterAtIndex = - _CFStringGetCharacterAtIndexPtr.asFunction< - int Function(CFStringRef, int) - >(); - - void CFStringGetCharacters( - CFStringRef theString, - CFRange range, - ffi.Pointer buffer, - ) { - return _CFStringGetCharacters(theString, range, buffer); - } - - late final _CFStringGetCharactersPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFStringRef, CFRange, ffi.Pointer) - > - >('CFStringGetCharacters'); - late final _CFStringGetCharacters = - _CFStringGetCharactersPtr.asFunction< - void Function(CFStringRef, CFRange, ffi.Pointer) - >(); - - int CFStringGetPascalString( - CFStringRef theString, - StringPtr buffer, - int bufferSize, - int encoding, - ) { - return _CFStringGetPascalString(theString, buffer, bufferSize, encoding); - } - - late final _CFStringGetPascalStringPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFStringRef, StringPtr, CFIndex, CFStringEncoding) - > - >('CFStringGetPascalString'); - late final _CFStringGetPascalString = - _CFStringGetPascalStringPtr.asFunction< - int Function(CFStringRef, StringPtr, int, int) - >(); - - int CFStringGetCString( - CFStringRef theString, - ffi.Pointer buffer, - int bufferSize, - int encoding, - ) { - return _CFStringGetCString(theString, buffer, bufferSize, encoding); - } + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); - late final _CFStringGetCStringPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFStringRef, - ffi.Pointer, - CFIndex, - CFStringEncoding, - ) - > - >('CFStringGetCString'); - late final _CFStringGetCString = - _CFStringGetCStringPtr.asFunction< - int Function(CFStringRef, ffi.Pointer, int, int) - >(); - - ConstStringPtr CFStringGetPascalStringPtr( - CFStringRef theString, - int encoding, - ) { - return _CFStringGetPascalStringPtr$1(theString, encoding); +/// NSHTTPURLResponse +extension type NSHTTPURLResponse._(objc.ObjCObject object$) + implements objc.ObjCObject, NSURLResponse { + /// Constructs a [NSHTTPURLResponse] that points to the same underlying object as [other]. + NSHTTPURLResponse.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); } - late final _CFStringGetPascalStringPtrPtr = - _lookup< - ffi.NativeFunction< - ConstStringPtr Function(CFStringRef, CFStringEncoding) - > - >('CFStringGetPascalStringPtr'); - late final _CFStringGetPascalStringPtr$1 = - _CFStringGetPascalStringPtrPtr.asFunction< - ConstStringPtr Function(CFStringRef, int) - >(); - - ffi.Pointer CFStringGetCStringPtr( - CFStringRef theString, - int encoding, - ) { - return _CFStringGetCStringPtr$1(theString, encoding); + /// Constructs a [NSHTTPURLResponse] that wraps the given raw object pointer. + NSHTTPURLResponse.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); } - late final _CFStringGetCStringPtrPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFStringRef, CFStringEncoding) - > - >('CFStringGetCStringPtr'); - late final _CFStringGetCStringPtr$1 = - _CFStringGetCStringPtrPtr.asFunction< - ffi.Pointer Function(CFStringRef, int) - >(); + /// Returns whether [obj] is an instance of [NSHTTPURLResponse]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSHTTPURLResponse, + ); - ffi.Pointer CFStringGetCharactersPtr(CFStringRef theString) { - return _CFStringGetCharactersPtr$1(theString); + /// alloc + static NSHTTPURLResponse alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSHTTPURLResponse, _sel_alloc); + return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } - late final _CFStringGetCharactersPtrPtr = - _lookup Function(CFStringRef)>>( - 'CFStringGetCharactersPtr', - ); - late final _CFStringGetCharactersPtr$1 = - _CFStringGetCharactersPtrPtr.asFunction< - ffi.Pointer Function(CFStringRef) - >(); - - int CFStringGetBytes( - CFStringRef theString, - CFRange range, - int encoding, - int lossByte, - int isExternalRepresentation, - ffi.Pointer buffer, - int maxBufLen, - ffi.Pointer usedBufLen, - ) { - return _CFStringGetBytes( - theString, - range, - encoding, - lossByte, - isExternalRepresentation, - buffer, - maxBufLen, - usedBufLen, + /// allocWithZone: + static NSHTTPURLResponse allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSHTTPURLResponse, + _sel_allocWithZone_, + zone, ); + return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } - late final _CFStringGetBytesPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFStringRef, - CFRange, - CFStringEncoding, - UInt8, - Boolean, - ffi.Pointer, - CFIndex, - ffi.Pointer, - ) - > - >('CFStringGetBytes'); - late final _CFStringGetBytes = - _CFStringGetBytesPtr.asFunction< - int Function( - CFStringRef, - CFRange, - int, - int, - int, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - CFStringRef CFStringCreateFromExternalRepresentation( - CFAllocatorRef alloc, - CFDataRef data, - int encoding, - ) { - return _CFStringCreateFromExternalRepresentation(alloc, data, encoding); - } - - late final _CFStringCreateFromExternalRepresentationPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, CFDataRef, CFStringEncoding) - > - >('CFStringCreateFromExternalRepresentation'); - late final _CFStringCreateFromExternalRepresentation = - _CFStringCreateFromExternalRepresentationPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFDataRef, int) - >(); - - CFDataRef CFStringCreateExternalRepresentation( - CFAllocatorRef alloc, - CFStringRef theString, - int encoding, - int lossByte, - ) { - return _CFStringCreateExternalRepresentation( - alloc, - theString, - encoding, - lossByte, + /// ! + /// @method localizedStringForStatusCode: + /// @abstract Convenience method which returns a localized string + /// corresponding to the status code for this response. + /// @param statusCode the status code to use to produce a localized string. + /// @result A localized string corresponding to the given status code. + static objc.NSString localizedStringForStatusCode(int statusCode) { + objc.checkOsVersionInternal( + 'NSHTTPURLResponse.localizedStringForStatusCode:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); + final $ret = _objc_msgSend_qugqlf( + _class_NSHTTPURLResponse, + _sel_localizedStringForStatusCode_, + statusCode, + ); + return objc.NSString.fromPointer($ret, retain: true, release: true); } - late final _CFStringCreateExternalRepresentationPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function( - CFAllocatorRef, - CFStringRef, - CFStringEncoding, - UInt8, - ) - > - >('CFStringCreateExternalRepresentation'); - late final _CFStringCreateExternalRepresentation = - _CFStringCreateExternalRepresentationPtr.asFunction< - CFDataRef Function(CFAllocatorRef, CFStringRef, int, int) - >(); - - int CFStringGetSmallestEncoding(CFStringRef theString) { - return _CFStringGetSmallestEncoding(theString); - } - - late final _CFStringGetSmallestEncodingPtr = - _lookup>( - 'CFStringGetSmallestEncoding', - ); - late final _CFStringGetSmallestEncoding = - _CFStringGetSmallestEncodingPtr.asFunction(); - - int CFStringGetFastestEncoding(CFStringRef theString) { - return _CFStringGetFastestEncoding(theString); - } - - late final _CFStringGetFastestEncodingPtr = - _lookup>( - 'CFStringGetFastestEncoding', - ); - late final _CFStringGetFastestEncoding = - _CFStringGetFastestEncodingPtr.asFunction(); - - int CFStringGetSystemEncoding() { - return _CFStringGetSystemEncoding(); - } - - late final _CFStringGetSystemEncodingPtr = - _lookup>( - 'CFStringGetSystemEncoding', - ); - late final _CFStringGetSystemEncoding = - _CFStringGetSystemEncodingPtr.asFunction(); - - int CFStringGetMaximumSizeForEncoding(int length, int encoding) { - return _CFStringGetMaximumSizeForEncoding(length, encoding); - } - - late final _CFStringGetMaximumSizeForEncodingPtr = - _lookup>( - 'CFStringGetMaximumSizeForEncoding', - ); - late final _CFStringGetMaximumSizeForEncoding = - _CFStringGetMaximumSizeForEncodingPtr.asFunction< - int Function(int, int) - >(); - - int CFStringGetFileSystemRepresentation( - CFStringRef string, - ffi.Pointer buffer, - int maxBufLen, - ) { - return _CFStringGetFileSystemRepresentation(string, buffer, maxBufLen); + /// new + static NSHTTPURLResponse new$() { + final $ret = _objc_msgSend_151sglz(_class_NSHTTPURLResponse, _sel_new); + return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } - late final _CFStringGetFileSystemRepresentationPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFStringRef, ffi.Pointer, CFIndex) - > - >('CFStringGetFileSystemRepresentation'); - late final _CFStringGetFileSystemRepresentation = - _CFStringGetFileSystemRepresentationPtr.asFunction< - int Function(CFStringRef, ffi.Pointer, int) - >(); - - int CFStringGetMaximumSizeOfFileSystemRepresentation(CFStringRef string) { - return _CFStringGetMaximumSizeOfFileSystemRepresentation(string); + /// supportsSecureCoding + static bool getSupportsSecureCoding() { + return _objc_msgSend_91o635( + _class_NSHTTPURLResponse, + _sel_supportsSecureCoding, + ); } - late final _CFStringGetMaximumSizeOfFileSystemRepresentationPtr = - _lookup>( - 'CFStringGetMaximumSizeOfFileSystemRepresentation', - ); - late final _CFStringGetMaximumSizeOfFileSystemRepresentation = - _CFStringGetMaximumSizeOfFileSystemRepresentationPtr.asFunction< - int Function(CFStringRef) - >(); - - CFStringRef CFStringCreateWithFileSystemRepresentation( - CFAllocatorRef alloc, - ffi.Pointer buffer, - ) { - return _CFStringCreateWithFileSystemRepresentation(alloc, buffer); - } + /// Returns a new instance of NSHTTPURLResponse constructed with the default `new` method. + NSHTTPURLResponse() : this.as(new$().object$); +} - late final _CFStringCreateWithFileSystemRepresentationPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, ffi.Pointer) - > - >('CFStringCreateWithFileSystemRepresentation'); - late final _CFStringCreateWithFileSystemRepresentation = - _CFStringCreateWithFileSystemRepresentationPtr.asFunction< - CFStringRef Function(CFAllocatorRef, ffi.Pointer) - >(); - - CFComparisonResult CFStringCompareWithOptionsAndLocale( - CFStringRef theString1, - CFStringRef theString2, - CFRange rangeToCompare, - DartCFOptionFlags compareOptions, - CFLocaleRef locale, - ) { - return CFComparisonResult.fromValue( - _CFStringCompareWithOptionsAndLocale( - theString1, - theString2, - rangeToCompare, - compareOptions, - locale, - ), +extension NSHTTPURLResponse$Methods on NSHTTPURLResponse { + /// ! + /// @abstract Returns a dictionary containing all the HTTP header fields + /// of the receiver. + /// @discussion By examining this header dictionary, clients can see + /// the "raw" header information which was reported to the protocol + /// implementation by the HTTP server. This may be of use to + /// sophisticated or special-purpose HTTP clients. + /// @result A dictionary containing all the HTTP header fields of the + /// receiver. + objc.NSDictionary get allHeaderFields { + objc.checkOsVersionInternal( + 'NSHTTPURLResponse.allHeaderFields', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - } - - late final _CFStringCompareWithOptionsAndLocalePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFStringRef, - CFStringRef, - CFRange, - CFOptionFlags, - CFLocaleRef, - ) - > - >('CFStringCompareWithOptionsAndLocale'); - late final _CFStringCompareWithOptionsAndLocale = - _CFStringCompareWithOptionsAndLocalePtr.asFunction< - int Function(CFStringRef, CFStringRef, CFRange, int, CFLocaleRef) - >(); - - CFComparisonResult CFStringCompareWithOptions( - CFStringRef theString1, - CFStringRef theString2, - CFRange rangeToCompare, - DartCFOptionFlags compareOptions, - ) { - return CFComparisonResult.fromValue( - _CFStringCompareWithOptions( - theString1, - theString2, - rangeToCompare, - compareOptions, - ), + final $ret = _objc_msgSend_151sglz( + object$.ref.pointer, + _sel_allHeaderFields, ); + return objc.NSDictionary.fromPointer($ret, retain: true, release: true); } - late final _CFStringCompareWithOptionsPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFStringRef, CFStringRef, CFRange, CFOptionFlags) - > - >('CFStringCompareWithOptions'); - late final _CFStringCompareWithOptions = - _CFStringCompareWithOptionsPtr.asFunction< - int Function(CFStringRef, CFStringRef, CFRange, int) - >(); - - CFComparisonResult CFStringCompare( - CFStringRef theString1, - CFStringRef theString2, - DartCFOptionFlags compareOptions, - ) { - return CFComparisonResult.fromValue( - _CFStringCompare(theString1, theString2, compareOptions), + /// init + NSHTTPURLResponse init() { + objc.checkOsVersionInternal( + 'NSHTTPURLResponse.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } - late final _CFStringComparePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFStringRef, CFStringRef, CFOptionFlags) - > - >('CFStringCompare'); - late final _CFStringCompare = - _CFStringComparePtr.asFunction< - int Function(CFStringRef, CFStringRef, int) - >(); - - int CFStringFindWithOptionsAndLocale( - CFStringRef theString, - CFStringRef stringToFind, - CFRange rangeToSearch, - int searchOptions, - CFLocaleRef locale, - ffi.Pointer result, - ) { - return _CFStringFindWithOptionsAndLocale( - theString, - stringToFind, - rangeToSearch, - searchOptions, - locale, - result, + /// initWithCoder: + NSHTTPURLResponse? initWithCoder(objc.NSCoder coder) { + final $ret = _objc_msgSend_1sotr3r( + object$.ref.retainAndReturnPointer(), + _sel_initWithCoder_, + coder.ref.pointer, ); + return $ret.address == 0 + ? null + : NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } - late final _CFStringFindWithOptionsAndLocalePtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFStringRef, - CFStringRef, - CFRange, - CFOptionFlags, - CFLocaleRef, - ffi.Pointer, - ) - > - >('CFStringFindWithOptionsAndLocale'); - late final _CFStringFindWithOptionsAndLocale = - _CFStringFindWithOptionsAndLocalePtr.asFunction< - int Function( - CFStringRef, - CFStringRef, - CFRange, - int, - CFLocaleRef, - ffi.Pointer, - ) - >(); - - int CFStringFindWithOptions( - CFStringRef theString, - CFStringRef stringToFind, - CFRange rangeToSearch, - int searchOptions, - ffi.Pointer result, - ) { - return _CFStringFindWithOptions( - theString, - stringToFind, - rangeToSearch, - searchOptions, - result, + /// ! + /// @method initWithURL:MIMEType:expectedContentLength:textEncodingName: + /// @abstract Initialize an NSURLResponse with the provided values. + /// @param URL the URL + /// @param MIMEType the MIME content type of the response + /// @param length the expected content length of the associated data + /// @param name the name of the text encoding for the associated data, if applicable, else nil + /// @result The initialized NSURLResponse. + /// @discussion This is the designated initializer for NSURLResponse. + NSHTTPURLResponse initWithUrlAndMIMEType( + objc.NSURL URL, { + objc.NSString? MIMEType, + required int length, + objc.NSString? name, + }) { + objc.checkOsVersionInternal( + 'NSHTTPURLResponse.initWithURL:MIMEType:expectedContentLength:textEncodingName:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_l9ppnx( + object$.ref.retainAndReturnPointer(), + _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_, + URL.ref.pointer, + MIMEType?.ref.pointer ?? ffi.nullptr, + length, + name?.ref.pointer ?? ffi.nullptr, ); + return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } - late final _CFStringFindWithOptionsPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFStringRef, - CFStringRef, - CFRange, - CFOptionFlags, - ffi.Pointer, - ) - > - >('CFStringFindWithOptions'); - late final _CFStringFindWithOptions = - _CFStringFindWithOptionsPtr.asFunction< - int Function( - CFStringRef, - CFStringRef, - CFRange, - int, - ffi.Pointer, - ) - >(); - - CFArrayRef CFStringCreateArrayWithFindResults( - CFAllocatorRef alloc, - CFStringRef theString, - CFStringRef stringToFind, - CFRange rangeToSearch, - int compareOptions, - ) { - return _CFStringCreateArrayWithFindResults( - alloc, - theString, - stringToFind, - rangeToSearch, - compareOptions, + /// ! + /// @method initWithURL:statusCode:HTTPVersion:headerFields: + /// @abstract initializer for NSHTTPURLResponse objects. + /// @param url the URL from which the response was generated. + /// @param statusCode an HTTP status code. + /// @param HTTPVersion The version of the HTTP response as represented by the server. This is typically represented as "HTTP/1.1". + /// @param headerFields A dictionary representing the header keys and values of the server response. + /// @result the instance of the object, or NULL if an error occurred during initialization. + /// @discussion This API was introduced in Mac OS X 10.7.2 and iOS 5.0 and is not available prior to those releases. + NSHTTPURLResponse? initWithURLAndStatusCode( + objc.NSURL url, { + required int statusCode, + objc.NSString? HTTPVersion, + objc.NSDictionary? headerFields, + }) { + objc.checkOsVersionInternal( + 'NSHTTPURLResponse.initWithURL:statusCode:HTTPVersion:headerFields:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + final $ret = _objc_msgSend_xw7l5( + object$.ref.retainAndReturnPointer(), + _sel_initWithURL_statusCode_HTTPVersion_headerFields_, + url.ref.pointer, + statusCode, + HTTPVersion?.ref.pointer ?? ffi.nullptr, + headerFields?.ref.pointer ?? ffi.nullptr, ); + return $ret.address == 0 + ? null + : NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } - late final _CFStringCreateArrayWithFindResultsPtr = - _lookup< - ffi.NativeFunction< - CFArrayRef Function( - CFAllocatorRef, - CFStringRef, - CFStringRef, - CFRange, - CFOptionFlags, - ) - > - >('CFStringCreateArrayWithFindResults'); - late final _CFStringCreateArrayWithFindResults = - _CFStringCreateArrayWithFindResultsPtr.asFunction< - CFArrayRef Function( - CFAllocatorRef, - CFStringRef, - CFStringRef, - CFRange, - int, - ) - >(); - - CFRange CFStringFind( - CFStringRef theString, - CFStringRef stringToFind, - int compareOptions, - ) { - return _CFStringFind(theString, stringToFind, compareOptions); + /// ! + /// @abstract Returns the HTTP status code of the receiver. + /// @result The HTTP status code of the receiver. + int get statusCode { + objc.checkOsVersionInternal( + 'NSHTTPURLResponse.statusCode', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_1hz7y9r(object$.ref.pointer, _sel_statusCode); } - late final _CFStringFindPtr = - _lookup< - ffi.NativeFunction< - CFRange Function(CFStringRef, CFStringRef, CFOptionFlags) - > - >('CFStringFind'); - late final _CFStringFind = - _CFStringFindPtr.asFunction< - CFRange Function(CFStringRef, CFStringRef, int) - >(); - - int CFStringHasPrefix(CFStringRef theString, CFStringRef prefix) { - return _CFStringHasPrefix(theString, prefix); - } - - late final _CFStringHasPrefixPtr = - _lookup>( - 'CFStringHasPrefix', - ); - late final _CFStringHasPrefix = - _CFStringHasPrefixPtr.asFunction< - int Function(CFStringRef, CFStringRef) - >(); - - int CFStringHasSuffix(CFStringRef theString, CFStringRef suffix) { - return _CFStringHasSuffix(theString, suffix); - } - - late final _CFStringHasSuffixPtr = - _lookup>( - 'CFStringHasSuffix', - ); - late final _CFStringHasSuffix = - _CFStringHasSuffixPtr.asFunction< - int Function(CFStringRef, CFStringRef) - >(); - - CFRange CFStringGetRangeOfComposedCharactersAtIndex( - CFStringRef theString, - int theIndex, - ) { - return _CFStringGetRangeOfComposedCharactersAtIndex(theString, theIndex); - } - - late final _CFStringGetRangeOfComposedCharactersAtIndexPtr = - _lookup>( - 'CFStringGetRangeOfComposedCharactersAtIndex', - ); - late final _CFStringGetRangeOfComposedCharactersAtIndex = - _CFStringGetRangeOfComposedCharactersAtIndexPtr.asFunction< - CFRange Function(CFStringRef, int) - >(); - - int CFStringFindCharacterFromSet( - CFStringRef theString, - CFCharacterSetRef theSet, - CFRange rangeToSearch, - int searchOptions, - ffi.Pointer result, - ) { - return _CFStringFindCharacterFromSet( - theString, - theSet, - rangeToSearch, - searchOptions, - result, + /// ! + /// @method valueForHTTPHeaderField: + /// @abstract Returns the value which corresponds to the given header + /// field. Note that, in keeping with the HTTP RFC, HTTP header field + /// names are case-insensitive. + /// @param field the header field name to use for the lookup + /// (case-insensitive). + /// @result the value associated with the given header field, or nil if + /// there is no value associated with the given header field. + objc.NSString? valueForHTTPHeaderField(objc.NSString field) { + objc.checkOsVersionInternal( + 'NSHTTPURLResponse.valueForHTTPHeaderField:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - } - - late final _CFStringFindCharacterFromSetPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFStringRef, - CFCharacterSetRef, - CFRange, - CFOptionFlags, - ffi.Pointer, - ) - > - >('CFStringFindCharacterFromSet'); - late final _CFStringFindCharacterFromSet = - _CFStringFindCharacterFromSetPtr.asFunction< - int Function( - CFStringRef, - CFCharacterSetRef, - CFRange, - int, - ffi.Pointer, - ) - >(); - - void CFStringGetLineBounds( - CFStringRef theString, - CFRange range, - ffi.Pointer lineBeginIndex, - ffi.Pointer lineEndIndex, - ffi.Pointer contentsEndIndex, - ) { - return _CFStringGetLineBounds( - theString, - range, - lineBeginIndex, - lineEndIndex, - contentsEndIndex, + final $ret = _objc_msgSend_1sotr3r( + object$.ref.pointer, + _sel_valueForHTTPHeaderField_, + field.ref.pointer, ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } +} - late final _CFStringGetLineBoundsPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFStringRef, - CFRange, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFStringGetLineBounds'); - late final _CFStringGetLineBounds = - _CFStringGetLineBoundsPtr.asFunction< - void Function( - CFStringRef, - CFRange, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, ) - >(); - - void CFStringGetParagraphBounds( - CFStringRef string, - CFRange range, - ffi.Pointer parBeginIndex, - ffi.Pointer parEndIndex, - ffi.Pointer contentsEndIndex, - ) { - return _CFStringGetParagraphBounds( - string, - range, - parBeginIndex, - parEndIndex, - contentsEndIndex, - ); - } + >(pointer, retain: retain, release: release); - late final _CFStringGetParagraphBoundsPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFStringRef, - CFRange, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFStringGetParagraphBounds'); - late final _CFStringGetParagraphBounds = - _CFStringGetParagraphBoundsPtr.asFunction< - void Function( - CFStringRef, - CFRange, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) - >(); - - int CFStringGetHyphenationLocationBeforeIndex( - CFStringRef string, - int location, - CFRange limitRange, - int options, - CFLocaleRef locale, - ffi.Pointer character, - ) { - return _CFStringGetHyphenationLocationBeforeIndex( - string, - location, - limitRange, - options, - locale, - character, - ); - } - - late final _CFStringGetHyphenationLocationBeforeIndexPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFStringRef, - CFIndex, - CFRange, - CFOptionFlags, - CFLocaleRef, - ffi.Pointer, - ) - > - >('CFStringGetHyphenationLocationBeforeIndex'); - late final _CFStringGetHyphenationLocationBeforeIndex = - _CFStringGetHyphenationLocationBeforeIndexPtr.asFunction< - int Function( - CFStringRef, - int, - CFRange, - int, - CFLocaleRef, - ffi.Pointer, + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, ) - >(); - - int CFStringIsHyphenationAvailableForLocale(CFLocaleRef locale) { - return _CFStringIsHyphenationAvailableForLocale(locale); - } - - late final _CFStringIsHyphenationAvailableForLocalePtr = - _lookup>( - 'CFStringIsHyphenationAvailableForLocale', + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _CFStringIsHyphenationAvailableForLocale = - _CFStringIsHyphenationAvailableForLocalePtr.asFunction< - int Function(CFLocaleRef) - >(); - - CFStringRef CFStringCreateByCombiningStrings( - CFAllocatorRef alloc, - CFArrayRef theArray, - CFStringRef separatorString, - ) { - return _CFStringCreateByCombiningStrings(alloc, theArray, separatorString); - } - - late final _CFStringCreateByCombiningStringsPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, CFArrayRef, CFStringRef) - > - >('CFStringCreateByCombiningStrings'); - late final _CFStringCreateByCombiningStrings = - _CFStringCreateByCombiningStringsPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFArrayRef, CFStringRef) - >(); - - CFArrayRef CFStringCreateArrayBySeparatingStrings( - CFAllocatorRef alloc, - CFStringRef theString, - CFStringRef separatorString, - ) { - return _CFStringCreateArrayBySeparatingStrings( - alloc, - theString, - separatorString, - ); - } - - late final _CFStringCreateArrayBySeparatingStringsPtr = - _lookup< - ffi.NativeFunction< - CFArrayRef Function(CFAllocatorRef, CFStringRef, CFStringRef) - > - >('CFStringCreateArrayBySeparatingStrings'); - late final _CFStringCreateArrayBySeparatingStrings = - _CFStringCreateArrayBySeparatingStringsPtr.asFunction< - CFArrayRef Function(CFAllocatorRef, CFStringRef, CFStringRef) - >(); - int CFStringGetIntValue(CFStringRef str) { - return _CFStringGetIntValue(str); - } - - late final _CFStringGetIntValuePtr = - _lookup>( - 'CFStringGetIntValue', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), + NSURLSessionDownloadTask.fromPointer( + arg3, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _CFStringGetIntValue = - _CFStringGetIntValuePtr.asFunction(); - double CFStringGetDoubleValue(CFStringRef str) { - return _CFStringGetDoubleValue(str); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + >(wrapper, retain: false, release: true); } - late final _CFStringGetDoubleValuePtr = - _lookup>( - 'CFStringGetDoubleValue', - ); - late final _CFStringGetDoubleValue = - _CFStringGetDoubleValuePtr.asFunction(); - - void CFStringAppend( - CFMutableStringRef theString, - CFStringRef appendedString, - ) { - return _CFStringAppend(theString, appendedString); - } - - late final _CFStringAppendPtr = - _lookup< - ffi.NativeFunction - >('CFStringAppend'); - late final _CFStringAppend = - _CFStringAppendPtr.asFunction< - void Function(CFMutableStringRef, CFStringRef) - >(); - - void CFStringAppendCharacters( - CFMutableStringRef theString, - ffi.Pointer chars, - int numChars, - ) { - return _CFStringAppendCharacters(theString, chars, numChars); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + >(wrapper, retain: false, release: true); } - late final _CFStringAppendCharactersPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableStringRef, ffi.Pointer, CFIndex) - > - >('CFStringAppendCharacters'); - late final _CFStringAppendCharacters = - _CFStringAppendCharactersPtr.asFunction< - void Function(CFMutableStringRef, ffi.Pointer, int) - >(); - - void CFStringAppendPascalString( - CFMutableStringRef theString, - ConstStr255Param pStr, - int encoding, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _CFStringAppendPascalString(theString, pStr, encoding); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _CFStringAppendPascalStringPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< ffi.Void Function( - CFMutableStringRef, - ConstStr255Param, - CFStringEncoding, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFStringAppendPascalString'); - late final _CFStringAppendPascalString = - _CFStringAppendPascalStringPtr.asFunction< - void Function(CFMutableStringRef, ConstStr255Param, int) - >(); - - void CFStringAppendCString( - CFMutableStringRef theString, - ffi.Pointer cStr, - int encoding, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _CFStringAppendCString(theString, cStr, encoding); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFStringAppendCStringPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - CFMutableStringRef, - ffi.Pointer, - CFStringEncoding, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFStringAppendCString'); - late final _CFStringAppendCString = - _CFStringAppendCStringPtr.asFunction< - void Function(CFMutableStringRef, ffi.Pointer, int) - >(); - - void CFStringAppendFormat( - CFMutableStringRef theString, - CFDictionaryRef formatOptions, - CFStringRef format, - ) { - return _CFStringAppendFormat(theString, formatOptions, format); - } - - late final _CFStringAppendFormatPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableStringRef, CFDictionaryRef, CFStringRef) - > - >('CFStringAppendFormat'); - late final _CFStringAppendFormat = - _CFStringAppendFormatPtr.asFunction< - void Function(CFMutableStringRef, CFDictionaryRef, CFStringRef) - >(); - - void CFStringAppendFormatAndArguments( - CFMutableStringRef theString, - CFDictionaryRef formatOptions, - CFStringRef format, - va_list arguments, - ) { - return _CFStringAppendFormatAndArguments( - theString, - formatOptions, - format, - arguments, - ); - } - - late final _CFStringAppendFormatAndArgumentsPtr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( - CFMutableStringRef, - CFDictionaryRef, - CFStringRef, - va_list, - ) - > - >('CFStringAppendFormatAndArguments'); - late final _CFStringAppendFormatAndArguments = - _CFStringAppendFormatAndArgumentsPtr.asFunction< - void Function(CFMutableStringRef, CFDictionaryRef, CFStringRef, va_list) - >(); - - void CFStringInsert( - CFMutableStringRef str, - int idx, - CFStringRef insertedStr, - ) { - return _CFStringInsert(str, idx, insertedStr); - } - - late final _CFStringInsertPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableStringRef, CFIndex, CFStringRef) - > - >('CFStringInsert'); - late final _CFStringInsert = - _CFStringInsertPtr.asFunction< - void Function(CFMutableStringRef, int, CFStringRef) - >(); - - void CFStringDelete(CFMutableStringRef theString, CFRange range) { - return _CFStringDelete(theString, range); - } - - late final _CFStringDeletePtr = - _lookup< - ffi.NativeFunction - >('CFStringDelete'); - late final _CFStringDelete = - _CFStringDeletePtr.asFunction< - void Function(CFMutableStringRef, CFRange) - >(); - - void CFStringReplace( - CFMutableStringRef theString, - CFRange range, - CFStringRef replacement, - ) { - return _CFStringReplace(theString, range, replacement); - } - - late final _CFStringReplacePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableStringRef, CFRange, CFStringRef) - > - >('CFStringReplace'); - late final _CFStringReplace = - _CFStringReplacePtr.asFunction< - void Function(CFMutableStringRef, CFRange, CFStringRef) - >(); - - void CFStringReplaceAll( - CFMutableStringRef theString, - CFStringRef replacement, - ) { - return _CFStringReplaceAll(theString, replacement); - } - - late final _CFStringReplaceAllPtr = - _lookup< - ffi.NativeFunction - >('CFStringReplaceAll'); - late final _CFStringReplaceAll = - _CFStringReplaceAllPtr.asFunction< - void Function(CFMutableStringRef, CFStringRef) - >(); - - int CFStringFindAndReplace( - CFMutableStringRef theString, - CFStringRef stringToFind, - CFStringRef replacementString, - CFRange rangeToSearch, - int compareOptions, - ) { - return _CFStringFindAndReplace( - theString, - stringToFind, - replacementString, - rangeToSearch, - compareOptions, - ); - } - - late final _CFStringFindAndReplacePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFMutableStringRef, - CFStringRef, - CFStringRef, - CFRange, - CFOptionFlags, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFStringFindAndReplace'); - late final _CFStringFindAndReplace = - _CFStringFindAndReplacePtr.asFunction< - int Function(CFMutableStringRef, CFStringRef, CFStringRef, CFRange, int) - >(); - - void CFStringSetExternalCharactersNoCopy( - CFMutableStringRef theString, - ffi.Pointer chars, - int length, - int capacity, - ) { - return _CFStringSetExternalCharactersNoCopy( - theString, - chars, - length, - capacity, - ); - } - - late final _CFStringSetExternalCharactersNoCopyPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - CFMutableStringRef, - ffi.Pointer, - CFIndex, - CFIndex, - ) - > - >('CFStringSetExternalCharactersNoCopy'); - late final _CFStringSetExternalCharactersNoCopy = - _CFStringSetExternalCharactersNoCopyPtr.asFunction< - void Function(CFMutableStringRef, ffi.Pointer, int, int) - >(); - - void CFStringPad( - CFMutableStringRef theString, - CFStringRef padString, - int length, - int indexIntoPad, - ) { - return _CFStringPad(theString, padString, length, indexIntoPad); - } - - late final _CFStringPadPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableStringRef, CFStringRef, CFIndex, CFIndex) - > - >('CFStringPad'); - late final _CFStringPad = - _CFStringPadPtr.asFunction< - void Function(CFMutableStringRef, CFStringRef, int, int) - >(); - - void CFStringTrim(CFMutableStringRef theString, CFStringRef trimString) { - return _CFStringTrim(theString, trimString); - } - - late final _CFStringTrimPtr = - _lookup< - ffi.NativeFunction - >('CFStringTrim'); - late final _CFStringTrim = - _CFStringTrimPtr.asFunction< - void Function(CFMutableStringRef, CFStringRef) - >(); - - void CFStringTrimWhitespace(CFMutableStringRef theString) { - return _CFStringTrimWhitespace(theString); - } - - late final _CFStringTrimWhitespacePtr = - _lookup>( - 'CFStringTrimWhitespace', - ); - late final _CFStringTrimWhitespace = - _CFStringTrimWhitespacePtr.asFunction< - void Function(CFMutableStringRef) - >(); - - void CFStringLowercase(CFMutableStringRef theString, CFLocaleRef locale) { - return _CFStringLowercase(theString, locale); - } - - late final _CFStringLowercasePtr = - _lookup< - ffi.NativeFunction - >('CFStringLowercase'); - late final _CFStringLowercase = - _CFStringLowercasePtr.asFunction< - void Function(CFMutableStringRef, CFLocaleRef) - >(); - - void CFStringUppercase(CFMutableStringRef theString, CFLocaleRef locale) { - return _CFStringUppercase(theString, locale); - } - - late final _CFStringUppercasePtr = - _lookup< - ffi.NativeFunction - >('CFStringUppercase'); - late final _CFStringUppercase = - _CFStringUppercasePtr.asFunction< - void Function(CFMutableStringRef, CFLocaleRef) - >(); - - void CFStringCapitalize(CFMutableStringRef theString, CFLocaleRef locale) { - return _CFStringCapitalize(theString, locale); - } - - late final _CFStringCapitalizePtr = - _lookup< - ffi.NativeFunction - >('CFStringCapitalize'); - late final _CFStringCapitalize = - _CFStringCapitalizePtr.asFunction< - void Function(CFMutableStringRef, CFLocaleRef) - >(); - - void CFStringNormalize( - CFMutableStringRef theString, - CFStringNormalizationForm theForm, - ) { - return _CFStringNormalize(theString, theForm.value); - } - - late final _CFStringNormalizePtr = - _lookup< - ffi.NativeFunction - >('CFStringNormalize'); - late final _CFStringNormalize = - _CFStringNormalizePtr.asFunction< - void Function(CFMutableStringRef, int) - >(); - - void CFStringFold( - CFMutableStringRef theString, - int theFlags, - CFLocaleRef theLocale, - ) { - return _CFStringFold(theString, theFlags, theLocale); - } - - late final _CFStringFoldPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableStringRef, CFOptionFlags, CFLocaleRef) - > - >('CFStringFold'); - late final _CFStringFold = - _CFStringFoldPtr.asFunction< - void Function(CFMutableStringRef, int, CFLocaleRef) - >(); - - int CFStringTransform( - CFMutableStringRef string, - ffi.Pointer range, - CFStringRef transform, - int reverse, - ) { - return _CFStringTransform(string, range, transform, reverse); - } - - late final _CFStringTransformPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFMutableStringRef, - ffi.Pointer, - CFStringRef, - Boolean, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) > - >('CFStringTransform'); - late final _CFStringTransform = - _CFStringTransformPtr.asFunction< - int Function(CFMutableStringRef, ffi.Pointer, CFStringRef, int) - >(); - - late final ffi.Pointer _kCFStringTransformStripCombiningMarks = - _lookup('kCFStringTransformStripCombiningMarks'); - - CFStringRef get kCFStringTransformStripCombiningMarks => - _kCFStringTransformStripCombiningMarks.value; - - late final ffi.Pointer _kCFStringTransformToLatin = - _lookup('kCFStringTransformToLatin'); - - CFStringRef get kCFStringTransformToLatin => _kCFStringTransformToLatin.value; - - late final ffi.Pointer _kCFStringTransformFullwidthHalfwidth = - _lookup('kCFStringTransformFullwidthHalfwidth'); - - CFStringRef get kCFStringTransformFullwidthHalfwidth => - _kCFStringTransformFullwidthHalfwidth.value; - - late final ffi.Pointer _kCFStringTransformLatinKatakana = - _lookup('kCFStringTransformLatinKatakana'); - - CFStringRef get kCFStringTransformLatinKatakana => - _kCFStringTransformLatinKatakana.value; - - late final ffi.Pointer _kCFStringTransformLatinHiragana = - _lookup('kCFStringTransformLatinHiragana'); - - CFStringRef get kCFStringTransformLatinHiragana => - _kCFStringTransformLatinHiragana.value; - - late final ffi.Pointer _kCFStringTransformHiraganaKatakana = - _lookup('kCFStringTransformHiraganaKatakana'); - - CFStringRef get kCFStringTransformHiraganaKatakana => - _kCFStringTransformHiraganaKatakana.value; - - late final ffi.Pointer _kCFStringTransformMandarinLatin = - _lookup('kCFStringTransformMandarinLatin'); - - CFStringRef get kCFStringTransformMandarinLatin => - _kCFStringTransformMandarinLatin.value; - - late final ffi.Pointer _kCFStringTransformLatinHangul = - _lookup('kCFStringTransformLatinHangul'); - - CFStringRef get kCFStringTransformLatinHangul => - _kCFStringTransformLatinHangul.value; - - late final ffi.Pointer _kCFStringTransformLatinArabic = - _lookup('kCFStringTransformLatinArabic'); - - CFStringRef get kCFStringTransformLatinArabic => - _kCFStringTransformLatinArabic.value; - - late final ffi.Pointer _kCFStringTransformLatinHebrew = - _lookup('kCFStringTransformLatinHebrew'); - - CFStringRef get kCFStringTransformLatinHebrew => - _kCFStringTransformLatinHebrew.value; - - late final ffi.Pointer _kCFStringTransformLatinThai = - _lookup('kCFStringTransformLatinThai'); - - CFStringRef get kCFStringTransformLatinThai => - _kCFStringTransformLatinThai.value; - - late final ffi.Pointer _kCFStringTransformLatinCyrillic = - _lookup('kCFStringTransformLatinCyrillic'); - - CFStringRef get kCFStringTransformLatinCyrillic => - _kCFStringTransformLatinCyrillic.value; - - late final ffi.Pointer _kCFStringTransformLatinGreek = - _lookup('kCFStringTransformLatinGreek'); - - CFStringRef get kCFStringTransformLatinGreek => - _kCFStringTransformLatinGreek.value; - - late final ffi.Pointer _kCFStringTransformToXMLHex = - _lookup('kCFStringTransformToXMLHex'); - - CFStringRef get kCFStringTransformToXMLHex => - _kCFStringTransformToXMLHex.value; - - late final ffi.Pointer _kCFStringTransformToUnicodeName = - _lookup('kCFStringTransformToUnicodeName'); - - CFStringRef get kCFStringTransformToUnicodeName => - _kCFStringTransformToUnicodeName.value; - - late final ffi.Pointer _kCFStringTransformStripDiacritics = - _lookup('kCFStringTransformStripDiacritics'); - - CFStringRef get kCFStringTransformStripDiacritics => - _kCFStringTransformStripDiacritics.value; - - int CFStringIsEncodingAvailable(int encoding) { - return _CFStringIsEncodingAvailable(encoding); - } - - late final _CFStringIsEncodingAvailablePtr = - _lookup>( - 'CFStringIsEncodingAvailable', - ); - late final _CFStringIsEncodingAvailable = - _CFStringIsEncodingAvailablePtr.asFunction(); - - ffi.Pointer CFStringGetListOfAvailableEncodings() { - return _CFStringGetListOfAvailableEncodings(); - } - - late final _CFStringGetListOfAvailableEncodingsPtr = - _lookup Function()>>( - 'CFStringGetListOfAvailableEncodings', - ); - late final _CFStringGetListOfAvailableEncodings = - _CFStringGetListOfAvailableEncodingsPtr.asFunction< - ffi.Pointer Function() - >(); - - CFStringRef CFStringGetNameOfEncoding(int encoding) { - return _CFStringGetNameOfEncoding(encoding); - } - - late final _CFStringGetNameOfEncodingPtr = - _lookup>( - 'CFStringGetNameOfEncoding', - ); - late final _CFStringGetNameOfEncoding = - _CFStringGetNameOfEncodingPtr.asFunction(); - - int CFStringConvertEncodingToNSStringEncoding(int encoding) { - return _CFStringConvertEncodingToNSStringEncoding(encoding); - } - - late final _CFStringConvertEncodingToNSStringEncodingPtr = - _lookup>( - 'CFStringConvertEncodingToNSStringEncoding', - ); - late final _CFStringConvertEncodingToNSStringEncoding = - _CFStringConvertEncodingToNSStringEncodingPtr.asFunction< - int Function(int) - >(); - - int CFStringConvertNSStringEncodingToEncoding(int encoding) { - return _CFStringConvertNSStringEncodingToEncoding(encoding); - } - - late final _CFStringConvertNSStringEncodingToEncodingPtr = - _lookup>( - 'CFStringConvertNSStringEncodingToEncoding', - ); - late final _CFStringConvertNSStringEncodingToEncoding = - _CFStringConvertNSStringEncodingToEncodingPtr.asFunction< - int Function(int) - >(); - - int CFStringConvertEncodingToWindowsCodepage(int encoding) { - return _CFStringConvertEncodingToWindowsCodepage(encoding); - } - - late final _CFStringConvertEncodingToWindowsCodepagePtr = - _lookup>( - 'CFStringConvertEncodingToWindowsCodepage', - ); - late final _CFStringConvertEncodingToWindowsCodepage = - _CFStringConvertEncodingToWindowsCodepagePtr.asFunction< - int Function(int) - >(); - - int CFStringConvertWindowsCodepageToEncoding(int codepage) { - return _CFStringConvertWindowsCodepageToEncoding(codepage); - } - - late final _CFStringConvertWindowsCodepageToEncodingPtr = - _lookup>( - 'CFStringConvertWindowsCodepageToEncoding', - ); - late final _CFStringConvertWindowsCodepageToEncoding = - _CFStringConvertWindowsCodepageToEncodingPtr.asFunction< - int Function(int) - >(); - - int CFStringConvertIANACharSetNameToEncoding(CFStringRef theString) { - return _CFStringConvertIANACharSetNameToEncoding(theString); - } - - late final _CFStringConvertIANACharSetNameToEncodingPtr = - _lookup>( - 'CFStringConvertIANACharSetNameToEncoding', - ); - late final _CFStringConvertIANACharSetNameToEncoding = - _CFStringConvertIANACharSetNameToEncodingPtr.asFunction< - int Function(CFStringRef) - >(); - - CFStringRef CFStringConvertEncodingToIANACharSetName(int encoding) { - return _CFStringConvertEncodingToIANACharSetName(encoding); - } - - late final _CFStringConvertEncodingToIANACharSetNamePtr = - _lookup>( - 'CFStringConvertEncodingToIANACharSetName', - ); - late final _CFStringConvertEncodingToIANACharSetName = - _CFStringConvertEncodingToIANACharSetNamePtr.asFunction< - CFStringRef Function(int) - >(); - - int CFStringGetMostCompatibleMacStringEncoding(int encoding) { - return _CFStringGetMostCompatibleMacStringEncoding(encoding); - } - - late final _CFStringGetMostCompatibleMacStringEncodingPtr = - _lookup>( - 'CFStringGetMostCompatibleMacStringEncoding', - ); - late final _CFStringGetMostCompatibleMacStringEncoding = - _CFStringGetMostCompatibleMacStringEncodingPtr.asFunction< - int Function(int) - >(); - - void CFShow(CFTypeRef obj) { - return _CFShow(obj); - } - - late final _CFShowPtr = - _lookup>('CFShow'); - late final _CFShow = _CFShowPtr.asFunction(); - - void CFShowStr(CFStringRef str) { - return _CFShowStr(str); - } - - late final _CFShowStrPtr = - _lookup>('CFShowStr'); - late final _CFShowStr = - _CFShowStrPtr.asFunction(); - - CFStringRef __CFStringMakeConstantString(ffi.Pointer cStr) { - return ___CFStringMakeConstantString(cStr); - } - - late final ___CFStringMakeConstantStringPtr = - _lookup)>>( - '__CFStringMakeConstantString', - ); - late final ___CFStringMakeConstantString = ___CFStringMakeConstantStringPtr - .asFunction)>(); - - int CFTimeZoneGetTypeID() { - return _CFTimeZoneGetTypeID(); - } - - late final _CFTimeZoneGetTypeIDPtr = - _lookup>('CFTimeZoneGetTypeID'); - late final _CFTimeZoneGetTypeID = - _CFTimeZoneGetTypeIDPtr.asFunction(); - - CFTimeZoneRef CFTimeZoneCopySystem() { - return _CFTimeZoneCopySystem(); - } - - late final _CFTimeZoneCopySystemPtr = - _lookup>( - 'CFTimeZoneCopySystem', - ); - late final _CFTimeZoneCopySystem = - _CFTimeZoneCopySystemPtr.asFunction(); - - void CFTimeZoneResetSystem() { - return _CFTimeZoneResetSystem(); - } - - late final _CFTimeZoneResetSystemPtr = - _lookup>('CFTimeZoneResetSystem'); - late final _CFTimeZoneResetSystem = - _CFTimeZoneResetSystemPtr.asFunction(); - - CFTimeZoneRef CFTimeZoneCopyDefault() { - return _CFTimeZoneCopyDefault(); - } + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFTimeZoneCopyDefaultPtr = - _lookup>( - 'CFTimeZoneCopyDefault', +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionDownloadTask arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, ); - late final _CFTimeZoneCopyDefault = - _CFTimeZoneCopyDefaultPtr.asFunction(); - - void CFTimeZoneSetDefault(CFTimeZoneRef tz) { - return _CFTimeZoneSetDefault(tz); - } +} - late final _CFTimeZoneSetDefaultPtr = - _lookup>( - 'CFTimeZoneSetDefault', - ); - late final _CFTimeZoneSetDefault = - _CFTimeZoneSetDefaultPtr.asFunction(); +late final _sel_URLSession_dataTask_didBecomeStreamTask_ = objc.registerName( + "URLSession:dataTask:didBecomeStreamTask:", +); - CFArrayRef CFTimeZoneCopyKnownNames() { - return _CFTimeZoneCopyKnownNames(); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + >(pointer, retain: retain, release: release); - late final _CFTimeZoneCopyKnownNamesPtr = - _lookup>( - 'CFTimeZoneCopyKnownNames', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _CFTimeZoneCopyKnownNames = - _CFTimeZoneCopyKnownNamesPtr.asFunction(); - - CFDictionaryRef CFTimeZoneCopyAbbreviationDictionary() { - return _CFTimeZoneCopyAbbreviationDictionary(); - } - late final _CFTimeZoneCopyAbbreviationDictionaryPtr = - _lookup>( - 'CFTimeZoneCopyAbbreviationDictionary', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), + NSURLSessionStreamTask.fromPointer( + arg3, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _CFTimeZoneCopyAbbreviationDictionary = - _CFTimeZoneCopyAbbreviationDictionaryPtr.asFunction< - CFDictionaryRef Function() - >(); - void CFTimeZoneSetAbbreviationDictionary(CFDictionaryRef dict) { - return _CFTimeZoneSetAbbreviationDictionary(dict); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionStreamTask.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + >(wrapper, retain: false, release: true); } - late final _CFTimeZoneSetAbbreviationDictionaryPtr = - _lookup>( - 'CFTimeZoneSetAbbreviationDictionary', - ); - late final _CFTimeZoneSetAbbreviationDictionary = - _CFTimeZoneSetAbbreviationDictionaryPtr.asFunction< - void Function(CFDictionaryRef) - >(); - - CFTimeZoneRef CFTimeZoneCreate( - CFAllocatorRef allocator, - CFStringRef name, - CFDataRef data, - ) { - return _CFTimeZoneCreate(allocator, name, data); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionStreamTask.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionStreamTask.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + >(wrapper, retain: false, release: true); } - late final _CFTimeZoneCreatePtr = - _lookup< - ffi.NativeFunction< - CFTimeZoneRef Function(CFAllocatorRef, CFStringRef, CFDataRef) - > - >('CFTimeZoneCreate'); - late final _CFTimeZoneCreate = - _CFTimeZoneCreatePtr.asFunction< - CFTimeZoneRef Function(CFAllocatorRef, CFStringRef, CFDataRef) - >(); - - CFTimeZoneRef CFTimeZoneCreateWithTimeIntervalFromGMT( - CFAllocatorRef allocator, - double ti, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _CFTimeZoneCreateWithTimeIntervalFromGMT(allocator, ti); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _CFTimeZoneCreateWithTimeIntervalFromGMTPtr = - _lookup< - ffi.NativeFunction< - CFTimeZoneRef Function(CFAllocatorRef, CFTimeInterval) - > - >('CFTimeZoneCreateWithTimeIntervalFromGMT'); - late final _CFTimeZoneCreateWithTimeIntervalFromGMT = - _CFTimeZoneCreateWithTimeIntervalFromGMTPtr.asFunction< - CFTimeZoneRef Function(CFAllocatorRef, double) - >(); - - CFTimeZoneRef CFTimeZoneCreateWithName( - CFAllocatorRef allocator, - CFStringRef name, - int tryAbbrev, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _CFTimeZoneCreateWithName(allocator, name, tryAbbrev); - } - - late final _CFTimeZoneCreateWithNamePtr = - _lookup< - ffi.NativeFunction< - CFTimeZoneRef Function(CFAllocatorRef, CFStringRef, Boolean) - > - >('CFTimeZoneCreateWithName'); - late final _CFTimeZoneCreateWithName = - _CFTimeZoneCreateWithNamePtr.asFunction< - CFTimeZoneRef Function(CFAllocatorRef, CFStringRef, int) - >(); - - CFStringRef CFTimeZoneGetName(CFTimeZoneRef tz) { - return _CFTimeZoneGetName(tz); - } - - late final _CFTimeZoneGetNamePtr = - _lookup>( - 'CFTimeZoneGetName', - ); - late final _CFTimeZoneGetName = - _CFTimeZoneGetNamePtr.asFunction(); - - CFDataRef CFTimeZoneGetData(CFTimeZoneRef tz) { - return _CFTimeZoneGetData(tz); - } - - late final _CFTimeZoneGetDataPtr = - _lookup>( - 'CFTimeZoneGetData', - ); - late final _CFTimeZoneGetData = - _CFTimeZoneGetDataPtr.asFunction(); - - double CFTimeZoneGetSecondsFromGMT(CFTimeZoneRef tz, double at) { - return _CFTimeZoneGetSecondsFromGMT(tz, at); - } - - late final _CFTimeZoneGetSecondsFromGMTPtr = - _lookup< - ffi.NativeFunction< - CFTimeInterval Function(CFTimeZoneRef, CFAbsoluteTime) - > - >('CFTimeZoneGetSecondsFromGMT'); - late final _CFTimeZoneGetSecondsFromGMT = - _CFTimeZoneGetSecondsFromGMTPtr.asFunction< - double Function(CFTimeZoneRef, double) - >(); - - CFStringRef CFTimeZoneCopyAbbreviation(CFTimeZoneRef tz, double at) { - return _CFTimeZoneCopyAbbreviation(tz, at); - } - - late final _CFTimeZoneCopyAbbreviationPtr = - _lookup< - ffi.NativeFunction - >('CFTimeZoneCopyAbbreviation'); - late final _CFTimeZoneCopyAbbreviation = - _CFTimeZoneCopyAbbreviationPtr.asFunction< - CFStringRef Function(CFTimeZoneRef, double) - >(); - - int CFTimeZoneIsDaylightSavingTime(CFTimeZoneRef tz, double at) { - return _CFTimeZoneIsDaylightSavingTime(tz, at); - } - - late final _CFTimeZoneIsDaylightSavingTimePtr = - _lookup< - ffi.NativeFunction - >('CFTimeZoneIsDaylightSavingTime'); - late final _CFTimeZoneIsDaylightSavingTime = - _CFTimeZoneIsDaylightSavingTimePtr.asFunction< - int Function(CFTimeZoneRef, double) - >(); - - double CFTimeZoneGetDaylightSavingTimeOffset(CFTimeZoneRef tz, double at) { - return _CFTimeZoneGetDaylightSavingTimeOffset(tz, at); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFTimeZoneGetDaylightSavingTimeOffsetPtr = - _lookup< - ffi.NativeFunction< - CFTimeInterval Function(CFTimeZoneRef, CFAbsoluteTime) - > - >('CFTimeZoneGetDaylightSavingTimeOffset'); - late final _CFTimeZoneGetDaylightSavingTimeOffset = - _CFTimeZoneGetDaylightSavingTimeOffsetPtr.asFunction< - double Function(CFTimeZoneRef, double) - >(); - - double CFTimeZoneGetNextDaylightSavingTimeTransition( - CFTimeZoneRef tz, - double at, - ) { - return _CFTimeZoneGetNextDaylightSavingTimeTransition(tz, at); - } - - late final _CFTimeZoneGetNextDaylightSavingTimeTransitionPtr = - _lookup< - ffi.NativeFunction< - CFAbsoluteTime Function(CFTimeZoneRef, CFAbsoluteTime) - > - >('CFTimeZoneGetNextDaylightSavingTimeTransition'); - late final _CFTimeZoneGetNextDaylightSavingTimeTransition = - _CFTimeZoneGetNextDaylightSavingTimeTransitionPtr.asFunction< - double Function(CFTimeZoneRef, double) - >(); - - CFStringRef CFTimeZoneCopyLocalizedName( - CFTimeZoneRef tz, - CFTimeZoneNameStyle style, - CFLocaleRef locale, - ) { - return _CFTimeZoneCopyLocalizedName(tz, style.value, locale); - } - - late final _CFTimeZoneCopyLocalizedNamePtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFTimeZoneRef, CFIndex, CFLocaleRef) - > - >('CFTimeZoneCopyLocalizedName'); - late final _CFTimeZoneCopyLocalizedName = - _CFTimeZoneCopyLocalizedNamePtr.asFunction< - CFStringRef Function(CFTimeZoneRef, int, CFLocaleRef) - >(); - - late final ffi.Pointer - _kCFTimeZoneSystemTimeZoneDidChangeNotification = _lookup( - 'kCFTimeZoneSystemTimeZoneDidChangeNotification', - ); - - CFNotificationName get kCFTimeZoneSystemTimeZoneDidChangeNotification => - _kCFTimeZoneSystemTimeZoneDidChangeNotification.value; - - int CFCalendarGetTypeID() { - return _CFCalendarGetTypeID(); - } - - late final _CFCalendarGetTypeIDPtr = - _lookup>('CFCalendarGetTypeID'); - late final _CFCalendarGetTypeID = - _CFCalendarGetTypeIDPtr.asFunction(); - - CFCalendarRef CFCalendarCopyCurrent() { - return _CFCalendarCopyCurrent(); - } - - late final _CFCalendarCopyCurrentPtr = - _lookup>( - 'CFCalendarCopyCurrent', - ); - late final _CFCalendarCopyCurrent = - _CFCalendarCopyCurrentPtr.asFunction(); - - CFCalendarRef CFCalendarCreateWithIdentifier( - CFAllocatorRef allocator, - CFCalendarIdentifier identifier, - ) { - return _CFCalendarCreateWithIdentifier(allocator, identifier); - } - - late final _CFCalendarCreateWithIdentifierPtr = - _lookup< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< - CFCalendarRef Function(CFAllocatorRef, CFCalendarIdentifier) + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) > - >('CFCalendarCreateWithIdentifier'); - late final _CFCalendarCreateWithIdentifier = - _CFCalendarCreateWithIdentifierPtr.asFunction< - CFCalendarRef Function(CFAllocatorRef, CFCalendarIdentifier) - >(); - - CFCalendarIdentifier CFCalendarGetIdentifier(CFCalendarRef calendar) { - return _CFCalendarGetIdentifier(calendar); - } - - late final _CFCalendarGetIdentifierPtr = - _lookup>( - 'CFCalendarGetIdentifier', - ); - late final _CFCalendarGetIdentifier = - _CFCalendarGetIdentifierPtr.asFunction< - CFCalendarIdentifier Function(CFCalendarRef) - >(); - - CFLocaleRef CFCalendarCopyLocale(CFCalendarRef calendar) { - return _CFCalendarCopyLocale(calendar); - } - - late final _CFCalendarCopyLocalePtr = - _lookup>( - 'CFCalendarCopyLocale', - ); - late final _CFCalendarCopyLocale = - _CFCalendarCopyLocalePtr.asFunction< - CFLocaleRef Function(CFCalendarRef) - >(); - - void CFCalendarSetLocale(CFCalendarRef calendar, CFLocaleRef locale) { - return _CFCalendarSetLocale(calendar, locale); - } - - late final _CFCalendarSetLocalePtr = - _lookup< - ffi.NativeFunction - >('CFCalendarSetLocale'); - late final _CFCalendarSetLocale = - _CFCalendarSetLocalePtr.asFunction< - void Function(CFCalendarRef, CFLocaleRef) - >(); - - CFTimeZoneRef CFCalendarCopyTimeZone(CFCalendarRef calendar) { - return _CFCalendarCopyTimeZone(calendar); - } - - late final _CFCalendarCopyTimeZonePtr = - _lookup>( - 'CFCalendarCopyTimeZone', - ); - late final _CFCalendarCopyTimeZone = - _CFCalendarCopyTimeZonePtr.asFunction< - CFTimeZoneRef Function(CFCalendarRef) - >(); - - void CFCalendarSetTimeZone(CFCalendarRef calendar, CFTimeZoneRef tz) { - return _CFCalendarSetTimeZone(calendar, tz); - } - - late final _CFCalendarSetTimeZonePtr = - _lookup< - ffi.NativeFunction - >('CFCalendarSetTimeZone'); - late final _CFCalendarSetTimeZone = - _CFCalendarSetTimeZonePtr.asFunction< - void Function(CFCalendarRef, CFTimeZoneRef) - >(); - - int CFCalendarGetFirstWeekday(CFCalendarRef calendar) { - return _CFCalendarGetFirstWeekday(calendar); - } + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFCalendarGetFirstWeekdayPtr = - _lookup>( - 'CFCalendarGetFirstWeekday', +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionStreamTask arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, ); - late final _CFCalendarGetFirstWeekday = - _CFCalendarGetFirstWeekdayPtr.asFunction(); - - void CFCalendarSetFirstWeekday(CFCalendarRef calendar, int wkdy) { - return _CFCalendarSetFirstWeekday(calendar, wkdy); - } +} - late final _CFCalendarSetFirstWeekdayPtr = - _lookup>( - 'CFCalendarSetFirstWeekday', - ); - late final _CFCalendarSetFirstWeekday = - _CFCalendarSetFirstWeekdayPtr.asFunction< - void Function(CFCalendarRef, int) - >(); +late final _sel_URLSession_dataTask_didReceiveData_ = objc.registerName( + "URLSession:dataTask:didReceiveData:", +); - int CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar) { - return _CFCalendarGetMinimumDaysInFirstWeek(calendar); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, objc.NSData)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + >(pointer, retain: retain, release: release); - late final _CFCalendarGetMinimumDaysInFirstWeekPtr = - _lookup>( - 'CFCalendarGetMinimumDaysInFirstWeek', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _CFCalendarGetMinimumDaysInFirstWeek = - _CFCalendarGetMinimumDaysInFirstWeekPtr.asFunction< - int Function(CFCalendarRef) - >(); - - void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar, int mwd) { - return _CFCalendarSetMinimumDaysInFirstWeek(calendar, mwd); - } - late final _CFCalendarSetMinimumDaysInFirstWeekPtr = - _lookup>( - 'CFCalendarSetMinimumDaysInFirstWeek', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), + objc.NSData.fromPointer(arg3, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _CFCalendarSetMinimumDaysInFirstWeek = - _CFCalendarSetMinimumDaysInFirstWeekPtr.asFunction< - void Function(CFCalendarRef, int) - >(); - - CFRange CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar, int unit) { - return _CFCalendarGetMinimumRangeOfUnit(calendar, unit); - } - - late final _CFCalendarGetMinimumRangeOfUnitPtr = - _lookup< - ffi.NativeFunction - >('CFCalendarGetMinimumRangeOfUnit'); - late final _CFCalendarGetMinimumRangeOfUnit = - _CFCalendarGetMinimumRangeOfUnitPtr.asFunction< - CFRange Function(CFCalendarRef, int) - >(); - - CFRange CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar, int unit) { - return _CFCalendarGetMaximumRangeOfUnit(calendar, unit); - } - - late final _CFCalendarGetMaximumRangeOfUnitPtr = - _lookup< - ffi.NativeFunction - >('CFCalendarGetMaximumRangeOfUnit'); - late final _CFCalendarGetMaximumRangeOfUnit = - _CFCalendarGetMaximumRangeOfUnitPtr.asFunction< - CFRange Function(CFCalendarRef, int) - >(); - - CFRange CFCalendarGetRangeOfUnit( - CFCalendarRef calendar, - int smallerUnit, - int biggerUnit, - double at, - ) { - return _CFCalendarGetRangeOfUnit(calendar, smallerUnit, biggerUnit, at); - } - late final _CFCalendarGetRangeOfUnitPtr = - _lookup< - ffi.NativeFunction< - CFRange Function( - CFCalendarRef, - CFOptionFlags, - CFOptionFlags, - CFAbsoluteTime, - ) - > - >('CFCalendarGetRangeOfUnit'); - late final _CFCalendarGetRangeOfUnit = - _CFCalendarGetRangeOfUnitPtr.asFunction< - CFRange Function(CFCalendarRef, int, int, double) - >(); - - int CFCalendarGetOrdinalityOfUnit( - CFCalendarRef calendar, - int smallerUnit, - int biggerUnit, - double at, - ) { - return _CFCalendarGetOrdinalityOfUnit( - calendar, - smallerUnit, - biggerUnit, - at, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + objc.NSData.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + >(wrapper, retain: false, release: true); } - late final _CFCalendarGetOrdinalityOfUnitPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFCalendarRef, - CFOptionFlags, - CFOptionFlags, - CFAbsoluteTime, - ) - > - >('CFCalendarGetOrdinalityOfUnit'); - late final _CFCalendarGetOrdinalityOfUnit = - _CFCalendarGetOrdinalityOfUnitPtr.asFunction< - int Function(CFCalendarRef, int, int, double) - >(); - - int CFCalendarGetTimeRangeOfUnit( - CFCalendarRef calendar, - int unit, - double at, - ffi.Pointer startp, - ffi.Pointer tip, - ) { - return _CFCalendarGetTimeRangeOfUnit(calendar, unit, at, startp, tip); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + objc.NSData.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + objc.NSData.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + >(wrapper, retain: false, release: true); } - late final _CFCalendarGetTimeRangeOfUnitPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFCalendarRef, - CFOptionFlags, - CFAbsoluteTime, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFCalendarGetTimeRangeOfUnit'); - late final _CFCalendarGetTimeRangeOfUnit = - _CFCalendarGetTimeRangeOfUnitPtr.asFunction< - int Function( - CFCalendarRef, - int, - double, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int CFCalendarComposeAbsoluteTime( - CFCalendarRef calendar, - ffi.Pointer at, - ffi.Pointer componentDesc, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _CFCalendarComposeAbsoluteTime(calendar, at, componentDesc); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _CFCalendarComposeAbsoluteTimePtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFCalendarRef, - ffi.Pointer, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFCalendarComposeAbsoluteTime'); - late final _CFCalendarComposeAbsoluteTime = - _CFCalendarComposeAbsoluteTimePtr.asFunction< - int Function( - CFCalendarRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int CFCalendarDecomposeAbsoluteTime( - CFCalendarRef calendar, - double at, - ffi.Pointer componentDesc, - ) { - return _CFCalendarDecomposeAbsoluteTime(calendar, at, componentDesc); - } - - late final _CFCalendarDecomposeAbsoluteTimePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFCalendarRef, CFAbsoluteTime, ffi.Pointer) - > - >('CFCalendarDecomposeAbsoluteTime'); - late final _CFCalendarDecomposeAbsoluteTime = - _CFCalendarDecomposeAbsoluteTimePtr.asFunction< - int Function(CFCalendarRef, double, ffi.Pointer) - >(); - - int CFCalendarAddComponents( - CFCalendarRef calendar, - ffi.Pointer at, - int options, - ffi.Pointer componentDesc, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _CFCalendarAddComponents(calendar, at, options, componentDesc); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFCalendarAddComponentsPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFCalendarRef, - ffi.Pointer, - CFOptionFlags, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFCalendarAddComponents'); - late final _CFCalendarAddComponents = - _CFCalendarAddComponentsPtr.asFunction< - int Function( - CFCalendarRef, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - int CFCalendarGetComponentDifference( - CFCalendarRef calendar, - double startingAT, - double resultAT, - int options, - ffi.Pointer componentDesc, - ) { - return _CFCalendarGetComponentDifference( - calendar, - startingAT, - resultAT, - options, - componentDesc, - ); - } - - late final _CFCalendarGetComponentDifferencePtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFCalendarRef, - CFAbsoluteTime, - CFAbsoluteTime, - CFOptionFlags, - ffi.Pointer, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFCalendarGetComponentDifference'); - late final _CFCalendarGetComponentDifference = - _CFCalendarGetComponentDifferencePtr.asFunction< - int Function(CFCalendarRef, double, double, int, ffi.Pointer) - >(); - - CFStringRef CFDateFormatterCreateDateFormatFromTemplate( - CFAllocatorRef allocator, - CFStringRef tmplate, - int options, - CFLocaleRef locale, - ) { - return _CFDateFormatterCreateDateFormatFromTemplate( - allocator, - tmplate, - options, - locale, - ); - } - - late final _CFDateFormatterCreateDateFormatFromTemplatePtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFStringRef, - CFOptionFlags, - CFLocaleRef, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) > - >('CFDateFormatterCreateDateFormatFromTemplate'); - late final _CFDateFormatterCreateDateFormatFromTemplate = - _CFDateFormatterCreateDateFormatFromTemplatePtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, int, CFLocaleRef) - >(); - - int CFDateFormatterGetTypeID() { - return _CFDateFormatterGetTypeID(); - } - - late final _CFDateFormatterGetTypeIDPtr = - _lookup>( - 'CFDateFormatterGetTypeID', - ); - late final _CFDateFormatterGetTypeID = - _CFDateFormatterGetTypeIDPtr.asFunction(); - - CFDateFormatterRef CFDateFormatterCreateISO8601Formatter( - CFAllocatorRef allocator, - int formatOptions, - ) { - return _CFDateFormatterCreateISO8601Formatter(allocator, formatOptions); - } - - late final _CFDateFormatterCreateISO8601FormatterPtr = - _lookup< - ffi.NativeFunction< - CFDateFormatterRef Function(CFAllocatorRef, CFOptionFlags) - > - >('CFDateFormatterCreateISO8601Formatter'); - late final _CFDateFormatterCreateISO8601Formatter = - _CFDateFormatterCreateISO8601FormatterPtr.asFunction< - CFDateFormatterRef Function(CFAllocatorRef, int) - >(); - - CFDateFormatterRef CFDateFormatterCreate( - CFAllocatorRef allocator, - CFLocaleRef locale, - CFDateFormatterStyle dateStyle, - CFDateFormatterStyle timeStyle, - ) { - return _CFDateFormatterCreate( - allocator, - locale, - dateStyle.value, - timeStyle.value, - ); - } + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFDateFormatterCreatePtr = - _lookup< - ffi.NativeFunction< - CFDateFormatterRef Function( - CFAllocatorRef, - CFLocaleRef, - CFIndex, - CFIndex, +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, objc.NSData)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, ) - > - >('CFDateFormatterCreate'); - late final _CFDateFormatterCreate = - _CFDateFormatterCreatePtr.asFunction< - CFDateFormatterRef Function(CFAllocatorRef, CFLocaleRef, int, int) - >(); - - CFLocaleRef CFDateFormatterGetLocale(CFDateFormatterRef formatter) { - return _CFDateFormatterGetLocale(formatter); - } - - late final _CFDateFormatterGetLocalePtr = - _lookup>( - 'CFDateFormatterGetLocale', + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDataTask arg2, + objc.NSData arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, ); - late final _CFDateFormatterGetLocale = - _CFDateFormatterGetLocalePtr.asFunction< - CFLocaleRef Function(CFDateFormatterRef) - >(); - - CFDateFormatterStyle CFDateFormatterGetDateStyle( - CFDateFormatterRef formatter, - ) { - return CFDateFormatterStyle.fromValue( - _CFDateFormatterGetDateStyle(formatter), - ); - } +} - late final _CFDateFormatterGetDateStylePtr = - _lookup>( - 'CFDateFormatterGetDateStyle', - ); - late final _CFDateFormatterGetDateStyle = - _CFDateFormatterGetDateStylePtr.asFunction< - int Function(CFDateFormatterRef) - >(); +late final _sel_URLSession_dataTask_willCacheResponse_completionHandler_ = objc + .registerName("URLSession:dataTask:willCacheResponse:completionHandler:"); - CFDateFormatterStyle CFDateFormatterGetTimeStyle( - CFDateFormatterRef formatter, - ) { - return CFDateFormatterStyle.fromValue( - _CFDateFormatterGetTimeStyle(formatter), - ); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSCachedURLResponse, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + >(pointer, retain: retain, release: release); - late final _CFDateFormatterGetTimeStylePtr = - _lookup>( - 'CFDateFormatterGetTimeStyle', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _CFDateFormatterGetTimeStyle = - _CFDateFormatterGetTimeStylePtr.asFunction< - int Function(CFDateFormatterRef) - >(); - CFStringRef CFDateFormatterGetFormat(CFDateFormatterRef formatter) { - return _CFDateFormatterGetFormat(formatter); - } - - late final _CFDateFormatterGetFormatPtr = - _lookup>( - 'CFDateFormatterGetFormat', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), + NSCachedURLResponse.fromPointer(arg3, retain: true, release: true), + ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( + arg4, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _CFDateFormatterGetFormat = - _CFDateFormatterGetFormatPtr.asFunction< - CFStringRef Function(CFDateFormatterRef) - >(); - - void CFDateFormatterSetFormat( - CFDateFormatterRef formatter, - CFStringRef formatString, - ) { - return _CFDateFormatterSetFormat(formatter, formatString); - } - - late final _CFDateFormatterSetFormatPtr = - _lookup< - ffi.NativeFunction - >('CFDateFormatterSetFormat'); - late final _CFDateFormatterSetFormat = - _CFDateFormatterSetFormatPtr.asFunction< - void Function(CFDateFormatterRef, CFStringRef) - >(); - - CFStringRef CFDateFormatterCreateStringWithDate( - CFAllocatorRef allocator, - CFDateFormatterRef formatter, - CFDateRef date, - ) { - return _CFDateFormatterCreateStringWithDate(allocator, formatter, date); - } - late final _CFDateFormatterCreateStringWithDatePtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, CFDateFormatterRef, CFDateRef) - > - >('CFDateFormatterCreateStringWithDate'); - late final _CFDateFormatterCreateStringWithDate = - _CFDateFormatterCreateStringWithDatePtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFDateFormatterRef, CFDateRef) - >(); - - CFStringRef CFDateFormatterCreateStringWithAbsoluteTime( - CFAllocatorRef allocator, - CFDateFormatterRef formatter, - double at, - ) { - return _CFDateFormatterCreateStringWithAbsoluteTime( - allocator, - formatter, - at, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSCachedURLResponse.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xx612k(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _CFDateFormatterCreateStringWithAbsoluteTimePtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFDateFormatterRef, - CFAbsoluteTime, - ) - > - >('CFDateFormatterCreateStringWithAbsoluteTime'); - late final _CFDateFormatterCreateStringWithAbsoluteTime = - _CFDateFormatterCreateStringWithAbsoluteTimePtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFDateFormatterRef, double) - >(); - - CFDateRef CFDateFormatterCreateDateFromString( - CFAllocatorRef allocator, - CFDateFormatterRef formatter, - CFStringRef string, - ffi.Pointer rangep, - ) { - return _CFDateFormatterCreateDateFromString( - allocator, - formatter, - string, - rangep, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSCachedURLResponse.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); - } - - late final _CFDateFormatterCreateDateFromStringPtr = - _lookup< - ffi.NativeFunction< - CFDateRef Function( - CFAllocatorRef, - CFDateFormatterRef, - CFStringRef, - ffi.Pointer, - ) - > - >('CFDateFormatterCreateDateFromString'); - late final _CFDateFormatterCreateDateFromString = - _CFDateFormatterCreateDateFromStringPtr.asFunction< - CFDateRef Function( - CFAllocatorRef, - CFDateFormatterRef, - CFStringRef, - ffi.Pointer, - ) - >(); - - int CFDateFormatterGetAbsoluteTimeFromString( - CFDateFormatterRef formatter, - CFStringRef string, - ffi.Pointer rangep, - ffi.Pointer atp, - ) { - return _CFDateFormatterGetAbsoluteTimeFromString( - formatter, - string, - rangep, - atp, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), + NSCachedURLResponse.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _CFDateFormatterGetAbsoluteTimeFromStringPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFDateFormatterRef, - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFDateFormatterGetAbsoluteTimeFromString'); - late final _CFDateFormatterGetAbsoluteTimeFromString = - _CFDateFormatterGetAbsoluteTimeFromStringPtr.asFunction< - int Function( - CFDateFormatterRef, - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - void CFDateFormatterSetProperty( - CFDateFormatterRef formatter, - CFStringRef key, - CFTypeRef value, - ) { - return _CFDateFormatterSetProperty(formatter, key, value); - } - - late final _CFDateFormatterSetPropertyPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFDateFormatterRef, CFStringRef, CFTypeRef) - > - >('CFDateFormatterSetProperty'); - late final _CFDateFormatterSetProperty = - _CFDateFormatterSetPropertyPtr.asFunction< - void Function(CFDateFormatterRef, CFStringRef, CFTypeRef) - >(); - - CFTypeRef CFDateFormatterCopyProperty( - CFDateFormatterRef formatter, - CFDateFormatterKey key, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) { - return _CFDateFormatterCopyProperty(formatter, key); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + objc.objectRelease(block.cast()); } - late final _CFDateFormatterCopyPropertyPtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function(CFDateFormatterRef, CFDateFormatterKey) - > - >('CFDateFormatterCopyProperty'); - late final _CFDateFormatterCopyProperty = - _CFDateFormatterCopyPropertyPtr.asFunction< - CFTypeRef Function(CFDateFormatterRef, CFDateFormatterKey) - >(); - - late final ffi.Pointer _kCFDateFormatterIsLenient = - _lookup('kCFDateFormatterIsLenient'); - - CFDateFormatterKey get kCFDateFormatterIsLenient => - _kCFDateFormatterIsLenient.value; - - late final ffi.Pointer _kCFDateFormatterTimeZone = - _lookup('kCFDateFormatterTimeZone'); - - CFDateFormatterKey get kCFDateFormatterTimeZone => - _kCFDateFormatterTimeZone.value; - - late final ffi.Pointer _kCFDateFormatterCalendarName = - _lookup('kCFDateFormatterCalendarName'); - - CFDateFormatterKey get kCFDateFormatterCalendarName => - _kCFDateFormatterCalendarName.value; - - late final ffi.Pointer _kCFDateFormatterDefaultFormat = - _lookup('kCFDateFormatterDefaultFormat'); - - CFDateFormatterKey get kCFDateFormatterDefaultFormat => - _kCFDateFormatterDefaultFormat.value; - - late final ffi.Pointer - _kCFDateFormatterTwoDigitStartDate = _lookup( - 'kCFDateFormatterTwoDigitStartDate', - ); - - CFDateFormatterKey get kCFDateFormatterTwoDigitStartDate => - _kCFDateFormatterTwoDigitStartDate.value; - - late final ffi.Pointer _kCFDateFormatterDefaultDate = - _lookup('kCFDateFormatterDefaultDate'); - - CFDateFormatterKey get kCFDateFormatterDefaultDate => - _kCFDateFormatterDefaultDate.value; - - late final ffi.Pointer _kCFDateFormatterCalendar = - _lookup('kCFDateFormatterCalendar'); - - CFDateFormatterKey get kCFDateFormatterCalendar => - _kCFDateFormatterCalendar.value; - - late final ffi.Pointer _kCFDateFormatterEraSymbols = - _lookup('kCFDateFormatterEraSymbols'); - - CFDateFormatterKey get kCFDateFormatterEraSymbols => - _kCFDateFormatterEraSymbols.value; - - late final ffi.Pointer _kCFDateFormatterMonthSymbols = - _lookup('kCFDateFormatterMonthSymbols'); - - CFDateFormatterKey get kCFDateFormatterMonthSymbols => - _kCFDateFormatterMonthSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterShortMonthSymbols = _lookup( - 'kCFDateFormatterShortMonthSymbols', - ); - - CFDateFormatterKey get kCFDateFormatterShortMonthSymbols => - _kCFDateFormatterShortMonthSymbols.value; - - late final ffi.Pointer _kCFDateFormatterWeekdaySymbols = - _lookup('kCFDateFormatterWeekdaySymbols'); - - CFDateFormatterKey get kCFDateFormatterWeekdaySymbols => - _kCFDateFormatterWeekdaySymbols.value; - - late final ffi.Pointer - _kCFDateFormatterShortWeekdaySymbols = _lookup( - 'kCFDateFormatterShortWeekdaySymbols', - ); - - CFDateFormatterKey get kCFDateFormatterShortWeekdaySymbols => - _kCFDateFormatterShortWeekdaySymbols.value; - - late final ffi.Pointer _kCFDateFormatterAMSymbol = - _lookup('kCFDateFormatterAMSymbol'); - - CFDateFormatterKey get kCFDateFormatterAMSymbol => - _kCFDateFormatterAMSymbol.value; - - late final ffi.Pointer _kCFDateFormatterPMSymbol = - _lookup('kCFDateFormatterPMSymbol'); - - CFDateFormatterKey get kCFDateFormatterPMSymbol => - _kCFDateFormatterPMSymbol.value; - - late final ffi.Pointer _kCFDateFormatterLongEraSymbols = - _lookup('kCFDateFormatterLongEraSymbols'); - - CFDateFormatterKey get kCFDateFormatterLongEraSymbols => - _kCFDateFormatterLongEraSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterVeryShortMonthSymbols = _lookup( - 'kCFDateFormatterVeryShortMonthSymbols', - ); - - CFDateFormatterKey get kCFDateFormatterVeryShortMonthSymbols => - _kCFDateFormatterVeryShortMonthSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterStandaloneMonthSymbols = _lookup( - 'kCFDateFormatterStandaloneMonthSymbols', - ); - - CFDateFormatterKey get kCFDateFormatterStandaloneMonthSymbols => - _kCFDateFormatterStandaloneMonthSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterShortStandaloneMonthSymbols = _lookup( - 'kCFDateFormatterShortStandaloneMonthSymbols', - ); - - CFDateFormatterKey get kCFDateFormatterShortStandaloneMonthSymbols => - _kCFDateFormatterShortStandaloneMonthSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterVeryShortStandaloneMonthSymbols = - _lookup( - 'kCFDateFormatterVeryShortStandaloneMonthSymbols', - ); - - CFDateFormatterKey get kCFDateFormatterVeryShortStandaloneMonthSymbols => - _kCFDateFormatterVeryShortStandaloneMonthSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterVeryShortWeekdaySymbols = _lookup( - 'kCFDateFormatterVeryShortWeekdaySymbols', - ); - - CFDateFormatterKey get kCFDateFormatterVeryShortWeekdaySymbols => - _kCFDateFormatterVeryShortWeekdaySymbols.value; - - late final ffi.Pointer - _kCFDateFormatterStandaloneWeekdaySymbols = _lookup( - 'kCFDateFormatterStandaloneWeekdaySymbols', - ); - - CFDateFormatterKey get kCFDateFormatterStandaloneWeekdaySymbols => - _kCFDateFormatterStandaloneWeekdaySymbols.value; - - late final ffi.Pointer - _kCFDateFormatterShortStandaloneWeekdaySymbols = _lookup( - 'kCFDateFormatterShortStandaloneWeekdaySymbols', - ); - - CFDateFormatterKey get kCFDateFormatterShortStandaloneWeekdaySymbols => - _kCFDateFormatterShortStandaloneWeekdaySymbols.value; - - late final ffi.Pointer - _kCFDateFormatterVeryShortStandaloneWeekdaySymbols = - _lookup( - 'kCFDateFormatterVeryShortStandaloneWeekdaySymbols', - ); - - CFDateFormatterKey get kCFDateFormatterVeryShortStandaloneWeekdaySymbols => - _kCFDateFormatterVeryShortStandaloneWeekdaySymbols.value; - - late final ffi.Pointer _kCFDateFormatterQuarterSymbols = - _lookup('kCFDateFormatterQuarterSymbols'); - - CFDateFormatterKey get kCFDateFormatterQuarterSymbols => - _kCFDateFormatterQuarterSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterShortQuarterSymbols = _lookup( - 'kCFDateFormatterShortQuarterSymbols', - ); - - CFDateFormatterKey get kCFDateFormatterShortQuarterSymbols => - _kCFDateFormatterShortQuarterSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterStandaloneQuarterSymbols = _lookup( - 'kCFDateFormatterStandaloneQuarterSymbols', - ); - - CFDateFormatterKey get kCFDateFormatterStandaloneQuarterSymbols => - _kCFDateFormatterStandaloneQuarterSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterShortStandaloneQuarterSymbols = _lookup( - 'kCFDateFormatterShortStandaloneQuarterSymbols', - ); - - CFDateFormatterKey get kCFDateFormatterShortStandaloneQuarterSymbols => - _kCFDateFormatterShortStandaloneQuarterSymbols.value; - - late final ffi.Pointer - _kCFDateFormatterGregorianStartDate = _lookup( - 'kCFDateFormatterGregorianStartDate', - ); - - CFDateFormatterKey get kCFDateFormatterGregorianStartDate => - _kCFDateFormatterGregorianStartDate.value; - - late final ffi.Pointer - _kCFDateFormatterDoesRelativeDateFormattingKey = _lookup( - 'kCFDateFormatterDoesRelativeDateFormattingKey', - ); - - CFDateFormatterKey get kCFDateFormatterDoesRelativeDateFormattingKey => - _kCFDateFormatterDoesRelativeDateFormattingKey.value; - - late final ffi.Pointer _kCFBooleanTrue = _lookup( - 'kCFBooleanTrue', - ); - - CFBooleanRef get kCFBooleanTrue => _kCFBooleanTrue.value; - - late final ffi.Pointer _kCFBooleanFalse = _lookup( - 'kCFBooleanFalse', - ); - - CFBooleanRef get kCFBooleanFalse => _kCFBooleanFalse.value; - - int CFBooleanGetTypeID() { - return _CFBooleanGetTypeID(); - } - - late final _CFBooleanGetTypeIDPtr = - _lookup>('CFBooleanGetTypeID'); - late final _CFBooleanGetTypeID = - _CFBooleanGetTypeIDPtr.asFunction(); - - int CFBooleanGetValue(CFBooleanRef boolean) { - return _CFBooleanGetValue(boolean); - } - - late final _CFBooleanGetValuePtr = - _lookup>( - 'CFBooleanGetValue', - ); - late final _CFBooleanGetValue = - _CFBooleanGetValuePtr.asFunction(); - - late final ffi.Pointer _kCFNumberPositiveInfinity = - _lookup('kCFNumberPositiveInfinity'); - - CFNumberRef get kCFNumberPositiveInfinity => _kCFNumberPositiveInfinity.value; - - late final ffi.Pointer _kCFNumberNegativeInfinity = - _lookup('kCFNumberNegativeInfinity'); - - CFNumberRef get kCFNumberNegativeInfinity => _kCFNumberNegativeInfinity.value; - - late final ffi.Pointer _kCFNumberNaN = _lookup( - 'kCFNumberNaN', - ); - - CFNumberRef get kCFNumberNaN => _kCFNumberNaN.value; - - int CFNumberGetTypeID() { - return _CFNumberGetTypeID(); - } - - late final _CFNumberGetTypeIDPtr = - _lookup>('CFNumberGetTypeID'); - late final _CFNumberGetTypeID = - _CFNumberGetTypeIDPtr.asFunction(); - - CFNumberRef CFNumberCreate( - CFAllocatorRef allocator, - CFNumberType theType, - ffi.Pointer valuePtr, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) { - return _CFNumberCreate(allocator, theType.value, valuePtr); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFNumberCreatePtr = - _lookup< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => block.ref.target + .cast< ffi.NativeFunction< - CFNumberRef Function(CFAllocatorRef, CFIndex, ffi.Pointer) + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) > - >('CFNumberCreate'); - late final _CFNumberCreate = - _CFNumberCreatePtr.asFunction< - CFNumberRef Function(CFAllocatorRef, int, ffi.Pointer) - >(); - - CFNumberType CFNumberGetType(CFNumberRef number) { - return CFNumberType.fromValue(_CFNumberGetType(number)); - } - - late final _CFNumberGetTypePtr = - _lookup>( - 'CFNumberGetType', - ); - late final _CFNumberGetType = - _CFNumberGetTypePtr.asFunction(); - - int CFNumberGetByteSize(CFNumberRef number) { - return _CFNumberGetByteSize(number); - } - - late final _CFNumberGetByteSizePtr = - _lookup>( - 'CFNumberGetByteSize', - ); - late final _CFNumberGetByteSize = - _CFNumberGetByteSizePtr.asFunction(); - - int CFNumberIsFloatType(CFNumberRef number) { - return _CFNumberIsFloatType(number); - } + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFNumberIsFloatTypePtr = - _lookup>( - 'CFNumberIsFloatType', +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSCachedURLResponse, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSCachedURLResponse arg3, + objc.ObjCBlock arg4, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, + arg4.ref.pointer, ); - late final _CFNumberIsFloatType = - _CFNumberIsFloatTypePtr.asFunction(); - - DartBoolean CFNumberGetValue( - CFNumberRef number, - CFNumberType theType, - ffi.Pointer valuePtr, - ) { - return _CFNumberGetValue(number, theType.value, valuePtr); - } - - late final _CFNumberGetValuePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFNumberRef, CFIndex, ffi.Pointer) - > - >('CFNumberGetValue'); - late final _CFNumberGetValue = - _CFNumberGetValuePtr.asFunction< - int Function(CFNumberRef, int, ffi.Pointer) - >(); - - CFComparisonResult CFNumberCompare( - CFNumberRef number, - CFNumberRef otherNumber, - ffi.Pointer context, - ) { - return CFComparisonResult.fromValue( - _CFNumberCompare(number, otherNumber, context), - ); - } +} - late final _CFNumberComparePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFNumberRef, CFNumberRef, ffi.Pointer) - > - >('CFNumberCompare'); - late final _CFNumberCompare = - _CFNumberComparePtr.asFunction< - int Function(CFNumberRef, CFNumberRef, ffi.Pointer) - >(); +late final _sel_URLSession_didCreateTask_ = objc.registerName( + "URLSession:didCreateTask:", +); - int CFNumberFormatterGetTypeID() { - return _CFNumberFormatterGetTypeID(); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + >(pointer, retain: retain, release: release); - late final _CFNumberFormatterGetTypeIDPtr = - _lookup>( - 'CFNumberFormatterGetTypeID', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _CFNumberFormatterGetTypeID = - _CFNumberFormatterGetTypeIDPtr.asFunction(); - - CFNumberFormatterRef CFNumberFormatterCreate( - CFAllocatorRef allocator, - CFLocaleRef locale, - CFNumberFormatterStyle style, - ) { - return _CFNumberFormatterCreate(allocator, locale, style.value); - } - late final _CFNumberFormatterCreatePtr = - _lookup< - ffi.NativeFunction< - CFNumberFormatterRef Function(CFAllocatorRef, CFLocaleRef, CFIndex) - > - >('CFNumberFormatterCreate'); - late final _CFNumberFormatterCreate = - _CFNumberFormatterCreatePtr.asFunction< - CFNumberFormatterRef Function(CFAllocatorRef, CFLocaleRef, int) - >(); - - CFLocaleRef CFNumberFormatterGetLocale(CFNumberFormatterRef formatter) { - return _CFNumberFormatterGetLocale(formatter); - } - - late final _CFNumberFormatterGetLocalePtr = - _lookup>( - 'CFNumberFormatterGetLocale', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + > + fromFunction( + void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _CFNumberFormatterGetLocale = - _CFNumberFormatterGetLocalePtr.asFunction< - CFLocaleRef Function(CFNumberFormatterRef) - >(); - CFNumberFormatterStyle CFNumberFormatterGetStyle( - CFNumberFormatterRef formatter, - ) { - return CFNumberFormatterStyle.fromValue( - _CFNumberFormatterGetStyle(formatter), + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + > + listener( + void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_fjrv01(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + >(wrapper, retain: false, release: true); } - late final _CFNumberFormatterGetStylePtr = - _lookup>( - 'CFNumberFormatterGetStyle', - ); - late final _CFNumberFormatterGetStyle = - _CFNumberFormatterGetStylePtr.asFunction< - int Function(CFNumberFormatterRef) - >(); - - CFStringRef CFNumberFormatterGetFormat(CFNumberFormatterRef formatter) { - return _CFNumberFormatterGetFormat(formatter); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + > + blocking( + void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_fjrv01( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + >(wrapper, retain: false, release: true); } - late final _CFNumberFormatterGetFormatPtr = - _lookup>( - 'CFNumberFormatterGetFormat', - ); - late final _CFNumberFormatterGetFormat = - _CFNumberFormatterGetFormatPtr.asFunction< - CFStringRef Function(CFNumberFormatterRef) - >(); - - void CFNumberFormatterSetFormat( - CFNumberFormatterRef formatter, - CFStringRef formatString, - ) { - return _CFNumberFormatterSetFormat(formatter, formatString); - } - - late final _CFNumberFormatterSetFormatPtr = - _lookup< - ffi.NativeFunction - >('CFNumberFormatterSetFormat'); - late final _CFNumberFormatterSetFormat = - _CFNumberFormatterSetFormatPtr.asFunction< - void Function(CFNumberFormatterRef, CFStringRef) - >(); - - CFStringRef CFNumberFormatterCreateStringWithNumber( - CFAllocatorRef allocator, - CFNumberFormatterRef formatter, - CFNumberRef number, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _CFNumberFormatterCreateStringWithNumber( - allocator, - formatter, - number, - ); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); } - late final _CFNumberFormatterCreateStringWithNumberPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFNumberFormatterRef, - CFNumberRef, - ) - > - >('CFNumberFormatterCreateStringWithNumber'); - late final _CFNumberFormatterCreateStringWithNumber = - _CFNumberFormatterCreateStringWithNumberPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFNumberFormatterRef, CFNumberRef) - >(); - - CFStringRef CFNumberFormatterCreateStringWithValue( - CFAllocatorRef allocator, - CFNumberFormatterRef formatter, - CFNumberType numberType, - ffi.Pointer valuePtr, - ) { - return _CFNumberFormatterCreateStringWithValue( - allocator, - formatter, - numberType.value, - valuePtr, - ); - } - - late final _CFNumberFormatterCreateStringWithValuePtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFNumberFormatterRef, - CFIndex, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFNumberFormatterCreateStringWithValue'); - late final _CFNumberFormatterCreateStringWithValue = - _CFNumberFormatterCreateStringWithValuePtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - CFNumberFormatterRef, - int, - ffi.Pointer, - ) - >(); - - CFNumberRef CFNumberFormatterCreateNumberFromString( - CFAllocatorRef allocator, - CFNumberFormatterRef formatter, - CFStringRef string, - ffi.Pointer rangep, - int options, - ) { - return _CFNumberFormatterCreateNumberFromString( - allocator, - formatter, - string, - rangep, - options, - ); - } - - late final _CFNumberFormatterCreateNumberFromStringPtr = - _lookup< - ffi.NativeFunction< - CFNumberRef Function( - CFAllocatorRef, - CFNumberFormatterRef, - CFStringRef, - ffi.Pointer, - CFOptionFlags, - ) - > - >('CFNumberFormatterCreateNumberFromString'); - late final _CFNumberFormatterCreateNumberFromString = - _CFNumberFormatterCreateNumberFromStringPtr.asFunction< - CFNumberRef Function( - CFAllocatorRef, - CFNumberFormatterRef, - CFStringRef, - ffi.Pointer, - int, - ) - >(); - - DartBoolean CFNumberFormatterGetValueFromString( - CFNumberFormatterRef formatter, - CFStringRef string, - ffi.Pointer rangep, - CFNumberType numberType, - ffi.Pointer valuePtr, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _CFNumberFormatterGetValueFromString( - formatter, - string, - rangep, - numberType.value, - valuePtr, - ); - } - - late final _CFNumberFormatterGetValueFromStringPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFNumberFormatterRef, - CFStringRef, - ffi.Pointer, - CFIndex, + try { + (objc.getBlockClosure(block) + as void Function( ffi.Pointer, - ) - > - >('CFNumberFormatterGetValueFromString'); - late final _CFNumberFormatterGetValueFromString = - _CFNumberFormatterGetValueFromStringPtr.asFunction< - int Function( - CFNumberFormatterRef, - CFStringRef, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - void CFNumberFormatterSetProperty( - CFNumberFormatterRef formatter, - CFNumberFormatterKey key, - CFTypeRef value, - ) { - return _CFNumberFormatterSetProperty(formatter, key, value); + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFNumberFormatterSetPropertyPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - CFNumberFormatterRef, - CFNumberFormatterKey, - CFTypeRef, - ) - > - >('CFNumberFormatterSetProperty'); - late final _CFNumberFormatterSetProperty = - _CFNumberFormatterSetPropertyPtr.asFunction< - void Function(CFNumberFormatterRef, CFNumberFormatterKey, CFTypeRef) - >(); - - CFTypeRef CFNumberFormatterCopyProperty( - CFNumberFormatterRef formatter, - CFNumberFormatterKey key, - ) { - return _CFNumberFormatterCopyProperty(formatter, key); - } - - late final _CFNumberFormatterCopyPropertyPtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function(CFNumberFormatterRef, CFNumberFormatterKey) - > - >('CFNumberFormatterCopyProperty'); - late final _CFNumberFormatterCopyProperty = - _CFNumberFormatterCopyPropertyPtr.asFunction< - CFTypeRef Function(CFNumberFormatterRef, CFNumberFormatterKey) - >(); - - late final ffi.Pointer _kCFNumberFormatterCurrencyCode = - _lookup('kCFNumberFormatterCurrencyCode'); - - CFNumberFormatterKey get kCFNumberFormatterCurrencyCode => - _kCFNumberFormatterCurrencyCode.value; - - late final ffi.Pointer - _kCFNumberFormatterDecimalSeparator = _lookup( - 'kCFNumberFormatterDecimalSeparator', - ); - - CFNumberFormatterKey get kCFNumberFormatterDecimalSeparator => - _kCFNumberFormatterDecimalSeparator.value; - - late final ffi.Pointer - _kCFNumberFormatterCurrencyDecimalSeparator = _lookup( - 'kCFNumberFormatterCurrencyDecimalSeparator', - ); - - CFNumberFormatterKey get kCFNumberFormatterCurrencyDecimalSeparator => - _kCFNumberFormatterCurrencyDecimalSeparator.value; - - late final ffi.Pointer - _kCFNumberFormatterAlwaysShowDecimalSeparator = _lookup( - 'kCFNumberFormatterAlwaysShowDecimalSeparator', - ); - - CFNumberFormatterKey get kCFNumberFormatterAlwaysShowDecimalSeparator => - _kCFNumberFormatterAlwaysShowDecimalSeparator.value; - - late final ffi.Pointer - _kCFNumberFormatterGroupingSeparator = _lookup( - 'kCFNumberFormatterGroupingSeparator', - ); - - CFNumberFormatterKey get kCFNumberFormatterGroupingSeparator => - _kCFNumberFormatterGroupingSeparator.value; - - late final ffi.Pointer - _kCFNumberFormatterUseGroupingSeparator = _lookup( - 'kCFNumberFormatterUseGroupingSeparator', - ); - - CFNumberFormatterKey get kCFNumberFormatterUseGroupingSeparator => - _kCFNumberFormatterUseGroupingSeparator.value; - - late final ffi.Pointer - _kCFNumberFormatterPercentSymbol = _lookup( - 'kCFNumberFormatterPercentSymbol', - ); - - CFNumberFormatterKey get kCFNumberFormatterPercentSymbol => - _kCFNumberFormatterPercentSymbol.value; - - late final ffi.Pointer _kCFNumberFormatterZeroSymbol = - _lookup('kCFNumberFormatterZeroSymbol'); - - CFNumberFormatterKey get kCFNumberFormatterZeroSymbol => - _kCFNumberFormatterZeroSymbol.value; - - late final ffi.Pointer _kCFNumberFormatterNaNSymbol = - _lookup('kCFNumberFormatterNaNSymbol'); - - CFNumberFormatterKey get kCFNumberFormatterNaNSymbol => - _kCFNumberFormatterNaNSymbol.value; - - late final ffi.Pointer - _kCFNumberFormatterInfinitySymbol = _lookup( - 'kCFNumberFormatterInfinitySymbol', - ); - - CFNumberFormatterKey get kCFNumberFormatterInfinitySymbol => - _kCFNumberFormatterInfinitySymbol.value; - - late final ffi.Pointer _kCFNumberFormatterMinusSign = - _lookup('kCFNumberFormatterMinusSign'); - - CFNumberFormatterKey get kCFNumberFormatterMinusSign => - _kCFNumberFormatterMinusSign.value; - - late final ffi.Pointer _kCFNumberFormatterPlusSign = - _lookup('kCFNumberFormatterPlusSign'); - - CFNumberFormatterKey get kCFNumberFormatterPlusSign => - _kCFNumberFormatterPlusSign.value; - - late final ffi.Pointer - _kCFNumberFormatterCurrencySymbol = _lookup( - 'kCFNumberFormatterCurrencySymbol', - ); - - CFNumberFormatterKey get kCFNumberFormatterCurrencySymbol => - _kCFNumberFormatterCurrencySymbol.value; - - late final ffi.Pointer - _kCFNumberFormatterExponentSymbol = _lookup( - 'kCFNumberFormatterExponentSymbol', - ); - - CFNumberFormatterKey get kCFNumberFormatterExponentSymbol => - _kCFNumberFormatterExponentSymbol.value; - - late final ffi.Pointer - _kCFNumberFormatterMinIntegerDigits = _lookup( - 'kCFNumberFormatterMinIntegerDigits', - ); - - CFNumberFormatterKey get kCFNumberFormatterMinIntegerDigits => - _kCFNumberFormatterMinIntegerDigits.value; - - late final ffi.Pointer - _kCFNumberFormatterMaxIntegerDigits = _lookup( - 'kCFNumberFormatterMaxIntegerDigits', - ); - - CFNumberFormatterKey get kCFNumberFormatterMaxIntegerDigits => - _kCFNumberFormatterMaxIntegerDigits.value; - - late final ffi.Pointer - _kCFNumberFormatterMinFractionDigits = _lookup( - 'kCFNumberFormatterMinFractionDigits', - ); - - CFNumberFormatterKey get kCFNumberFormatterMinFractionDigits => - _kCFNumberFormatterMinFractionDigits.value; - - late final ffi.Pointer - _kCFNumberFormatterMaxFractionDigits = _lookup( - 'kCFNumberFormatterMaxFractionDigits', - ); - - CFNumberFormatterKey get kCFNumberFormatterMaxFractionDigits => - _kCFNumberFormatterMaxFractionDigits.value; - - late final ffi.Pointer _kCFNumberFormatterGroupingSize = - _lookup('kCFNumberFormatterGroupingSize'); - - CFNumberFormatterKey get kCFNumberFormatterGroupingSize => - _kCFNumberFormatterGroupingSize.value; - - late final ffi.Pointer - _kCFNumberFormatterSecondaryGroupingSize = _lookup( - 'kCFNumberFormatterSecondaryGroupingSize', - ); - - CFNumberFormatterKey get kCFNumberFormatterSecondaryGroupingSize => - _kCFNumberFormatterSecondaryGroupingSize.value; - - late final ffi.Pointer _kCFNumberFormatterRoundingMode = - _lookup('kCFNumberFormatterRoundingMode'); - - CFNumberFormatterKey get kCFNumberFormatterRoundingMode => - _kCFNumberFormatterRoundingMode.value; - - late final ffi.Pointer - _kCFNumberFormatterRoundingIncrement = _lookup( - 'kCFNumberFormatterRoundingIncrement', - ); - - CFNumberFormatterKey get kCFNumberFormatterRoundingIncrement => - _kCFNumberFormatterRoundingIncrement.value; - - late final ffi.Pointer _kCFNumberFormatterFormatWidth = - _lookup('kCFNumberFormatterFormatWidth'); - - CFNumberFormatterKey get kCFNumberFormatterFormatWidth => - _kCFNumberFormatterFormatWidth.value; - - late final ffi.Pointer - _kCFNumberFormatterPaddingPosition = _lookup( - 'kCFNumberFormatterPaddingPosition', - ); - - CFNumberFormatterKey get kCFNumberFormatterPaddingPosition => - _kCFNumberFormatterPaddingPosition.value; - - late final ffi.Pointer - _kCFNumberFormatterPaddingCharacter = _lookup( - 'kCFNumberFormatterPaddingCharacter', - ); - - CFNumberFormatterKey get kCFNumberFormatterPaddingCharacter => - _kCFNumberFormatterPaddingCharacter.value; - - late final ffi.Pointer - _kCFNumberFormatterDefaultFormat = _lookup( - 'kCFNumberFormatterDefaultFormat', - ); - - CFNumberFormatterKey get kCFNumberFormatterDefaultFormat => - _kCFNumberFormatterDefaultFormat.value; - - late final ffi.Pointer _kCFNumberFormatterMultiplier = - _lookup('kCFNumberFormatterMultiplier'); - - CFNumberFormatterKey get kCFNumberFormatterMultiplier => - _kCFNumberFormatterMultiplier.value; - - late final ffi.Pointer - _kCFNumberFormatterPositivePrefix = _lookup( - 'kCFNumberFormatterPositivePrefix', - ); - - CFNumberFormatterKey get kCFNumberFormatterPositivePrefix => - _kCFNumberFormatterPositivePrefix.value; - - late final ffi.Pointer - _kCFNumberFormatterPositiveSuffix = _lookup( - 'kCFNumberFormatterPositiveSuffix', - ); - - CFNumberFormatterKey get kCFNumberFormatterPositiveSuffix => - _kCFNumberFormatterPositiveSuffix.value; - - late final ffi.Pointer - _kCFNumberFormatterNegativePrefix = _lookup( - 'kCFNumberFormatterNegativePrefix', - ); - - CFNumberFormatterKey get kCFNumberFormatterNegativePrefix => - _kCFNumberFormatterNegativePrefix.value; - - late final ffi.Pointer - _kCFNumberFormatterNegativeSuffix = _lookup( - 'kCFNumberFormatterNegativeSuffix', - ); - - CFNumberFormatterKey get kCFNumberFormatterNegativeSuffix => - _kCFNumberFormatterNegativeSuffix.value; - - late final ffi.Pointer - _kCFNumberFormatterPerMillSymbol = _lookup( - 'kCFNumberFormatterPerMillSymbol', - ); - - CFNumberFormatterKey get kCFNumberFormatterPerMillSymbol => - _kCFNumberFormatterPerMillSymbol.value; - - late final ffi.Pointer - _kCFNumberFormatterInternationalCurrencySymbol = - _lookup( - 'kCFNumberFormatterInternationalCurrencySymbol', - ); - - CFNumberFormatterKey get kCFNumberFormatterInternationalCurrencySymbol => - _kCFNumberFormatterInternationalCurrencySymbol.value; - - late final ffi.Pointer - _kCFNumberFormatterCurrencyGroupingSeparator = _lookup( - 'kCFNumberFormatterCurrencyGroupingSeparator', - ); - - CFNumberFormatterKey get kCFNumberFormatterCurrencyGroupingSeparator => - _kCFNumberFormatterCurrencyGroupingSeparator.value; - - late final ffi.Pointer _kCFNumberFormatterIsLenient = - _lookup('kCFNumberFormatterIsLenient'); - - CFNumberFormatterKey get kCFNumberFormatterIsLenient => - _kCFNumberFormatterIsLenient.value; - - late final ffi.Pointer - _kCFNumberFormatterUseSignificantDigits = _lookup( - 'kCFNumberFormatterUseSignificantDigits', - ); - - CFNumberFormatterKey get kCFNumberFormatterUseSignificantDigits => - _kCFNumberFormatterUseSignificantDigits.value; - - late final ffi.Pointer - _kCFNumberFormatterMinSignificantDigits = _lookup( - 'kCFNumberFormatterMinSignificantDigits', - ); - - CFNumberFormatterKey get kCFNumberFormatterMinSignificantDigits => - _kCFNumberFormatterMinSignificantDigits.value; - - late final ffi.Pointer - _kCFNumberFormatterMaxSignificantDigits = _lookup( - 'kCFNumberFormatterMaxSignificantDigits', - ); - - CFNumberFormatterKey get kCFNumberFormatterMaxSignificantDigits => - _kCFNumberFormatterMaxSignificantDigits.value; - - late final ffi.Pointer - _kCFNumberFormatterMinGroupingDigits = _lookup( - 'kCFNumberFormatterMinGroupingDigits', - ); - - CFNumberFormatterKey get kCFNumberFormatterMinGroupingDigits => - _kCFNumberFormatterMinGroupingDigits.value; - - int CFNumberFormatterGetDecimalInfoForCurrencyCode( - CFStringRef currencyCode, - ffi.Pointer defaultFractionDigits, - ffi.Pointer roundingIncrement, - ) { - return _CFNumberFormatterGetDecimalInfoForCurrencyCode( - currencyCode, - defaultFractionDigits, - roundingIncrement, - ); - } - - late final _CFNumberFormatterGetDecimalInfoForCurrencyCodePtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFNumberFormatterGetDecimalInfoForCurrencyCode'); - late final _CFNumberFormatterGetDecimalInfoForCurrencyCode = - _CFNumberFormatterGetDecimalInfoForCurrencyCodePtr.asFunction< - int Function( - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - late final ffi.Pointer _kCFPreferencesAnyApplication = - _lookup('kCFPreferencesAnyApplication'); - - CFStringRef get kCFPreferencesAnyApplication => - _kCFPreferencesAnyApplication.value; - - set kCFPreferencesAnyApplication(CFStringRef value) => - _kCFPreferencesAnyApplication.value = value; - - late final ffi.Pointer _kCFPreferencesCurrentApplication = - _lookup('kCFPreferencesCurrentApplication'); - - CFStringRef get kCFPreferencesCurrentApplication => - _kCFPreferencesCurrentApplication.value; - - set kCFPreferencesCurrentApplication(CFStringRef value) => - _kCFPreferencesCurrentApplication.value = value; - - late final ffi.Pointer _kCFPreferencesAnyHost = - _lookup('kCFPreferencesAnyHost'); - - CFStringRef get kCFPreferencesAnyHost => _kCFPreferencesAnyHost.value; - - set kCFPreferencesAnyHost(CFStringRef value) => - _kCFPreferencesAnyHost.value = value; - - late final ffi.Pointer _kCFPreferencesCurrentHost = - _lookup('kCFPreferencesCurrentHost'); - - CFStringRef get kCFPreferencesCurrentHost => _kCFPreferencesCurrentHost.value; - - set kCFPreferencesCurrentHost(CFStringRef value) => - _kCFPreferencesCurrentHost.value = value; - - late final ffi.Pointer _kCFPreferencesAnyUser = - _lookup('kCFPreferencesAnyUser'); - - CFStringRef get kCFPreferencesAnyUser => _kCFPreferencesAnyUser.value; - - set kCFPreferencesAnyUser(CFStringRef value) => - _kCFPreferencesAnyUser.value = value; - - late final ffi.Pointer _kCFPreferencesCurrentUser = - _lookup('kCFPreferencesCurrentUser'); - - CFStringRef get kCFPreferencesCurrentUser => _kCFPreferencesCurrentUser.value; - - set kCFPreferencesCurrentUser(CFStringRef value) => - _kCFPreferencesCurrentUser.value = value; - - CFPropertyListRef CFPreferencesCopyAppValue( - CFStringRef key, - CFStringRef applicationID, - ) { - return _CFPreferencesCopyAppValue(key, applicationID); - } - - late final _CFPreferencesCopyAppValuePtr = - _lookup< - ffi.NativeFunction - >('CFPreferencesCopyAppValue'); - late final _CFPreferencesCopyAppValue = - _CFPreferencesCopyAppValuePtr.asFunction< - CFPropertyListRef Function(CFStringRef, CFStringRef) - >(); - - int CFPreferencesGetAppBooleanValue( - CFStringRef key, - CFStringRef applicationID, - ffi.Pointer keyExistsAndHasValidFormat, - ) { - return _CFPreferencesGetAppBooleanValue( - key, - applicationID, - keyExistsAndHasValidFormat, - ); - } - - late final _CFPreferencesGetAppBooleanValuePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFStringRef, CFStringRef, ffi.Pointer) - > - >('CFPreferencesGetAppBooleanValue'); - late final _CFPreferencesGetAppBooleanValue = - _CFPreferencesGetAppBooleanValuePtr.asFunction< - int Function(CFStringRef, CFStringRef, ffi.Pointer) - >(); - - int CFPreferencesGetAppIntegerValue( - CFStringRef key, - CFStringRef applicationID, - ffi.Pointer keyExistsAndHasValidFormat, - ) { - return _CFPreferencesGetAppIntegerValue( - key, - applicationID, - keyExistsAndHasValidFormat, - ); - } - - late final _CFPreferencesGetAppIntegerValuePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFStringRef, CFStringRef, ffi.Pointer) - > - >('CFPreferencesGetAppIntegerValue'); - late final _CFPreferencesGetAppIntegerValue = - _CFPreferencesGetAppIntegerValuePtr.asFunction< - int Function(CFStringRef, CFStringRef, ffi.Pointer) - >(); - - void CFPreferencesSetAppValue( - CFStringRef key, - CFPropertyListRef value, - CFStringRef applicationID, - ) { - return _CFPreferencesSetAppValue(key, value, applicationID); - } - - late final _CFPreferencesSetAppValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFStringRef, CFPropertyListRef, CFStringRef) - > - >('CFPreferencesSetAppValue'); - late final _CFPreferencesSetAppValue = - _CFPreferencesSetAppValuePtr.asFunction< - void Function(CFStringRef, CFPropertyListRef, CFStringRef) - >(); - - void CFPreferencesAddSuitePreferencesToApp( - CFStringRef applicationID, - CFStringRef suiteID, - ) { - return _CFPreferencesAddSuitePreferencesToApp(applicationID, suiteID); - } - - late final _CFPreferencesAddSuitePreferencesToAppPtr = - _lookup>( - 'CFPreferencesAddSuitePreferencesToApp', - ); - late final _CFPreferencesAddSuitePreferencesToApp = - _CFPreferencesAddSuitePreferencesToAppPtr.asFunction< - void Function(CFStringRef, CFStringRef) - >(); - - void CFPreferencesRemoveSuitePreferencesFromApp( - CFStringRef applicationID, - CFStringRef suiteID, - ) { - return _CFPreferencesRemoveSuitePreferencesFromApp(applicationID, suiteID); - } - - late final _CFPreferencesRemoveSuitePreferencesFromAppPtr = - _lookup>( - 'CFPreferencesRemoveSuitePreferencesFromApp', - ); - late final _CFPreferencesRemoveSuitePreferencesFromApp = - _CFPreferencesRemoveSuitePreferencesFromAppPtr.asFunction< - void Function(CFStringRef, CFStringRef) - >(); - - int CFPreferencesAppSynchronize(CFStringRef applicationID) { - return _CFPreferencesAppSynchronize(applicationID); - } - - late final _CFPreferencesAppSynchronizePtr = - _lookup>( - 'CFPreferencesAppSynchronize', - ); - late final _CFPreferencesAppSynchronize = - _CFPreferencesAppSynchronizePtr.asFunction(); - - CFPropertyListRef CFPreferencesCopyValue( - CFStringRef key, - CFStringRef applicationID, - CFStringRef userName, - CFStringRef hostName, - ) { - return _CFPreferencesCopyValue(key, applicationID, userName, hostName); - } - - late final _CFPreferencesCopyValuePtr = - _lookup< - ffi.NativeFunction< - CFPropertyListRef Function( - CFStringRef, - CFStringRef, - CFStringRef, - CFStringRef, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFPreferencesCopyValue'); - late final _CFPreferencesCopyValue = - _CFPreferencesCopyValuePtr.asFunction< - CFPropertyListRef Function( - CFStringRef, - CFStringRef, - CFStringRef, - CFStringRef, - ) - >(); - - CFDictionaryRef CFPreferencesCopyMultiple( - CFArrayRef keysToFetch, - CFStringRef applicationID, - CFStringRef userName, - CFStringRef hostName, - ) { - return _CFPreferencesCopyMultiple( - keysToFetch, - applicationID, - userName, - hostName, - ); - } - - late final _CFPreferencesCopyMultiplePtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function( - CFArrayRef, - CFStringRef, - CFStringRef, - CFStringRef, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFPreferencesCopyMultiple'); - late final _CFPreferencesCopyMultiple = - _CFPreferencesCopyMultiplePtr.asFunction< - CFDictionaryRef Function( - CFArrayRef, - CFStringRef, - CFStringRef, - CFStringRef, - ) - >(); - - void CFPreferencesSetValue( - CFStringRef key, - CFPropertyListRef value, - CFStringRef applicationID, - CFStringRef userName, - CFStringRef hostName, - ) { - return _CFPreferencesSetValue( - key, - value, - applicationID, - userName, - hostName, - ); - } - - late final _CFPreferencesSetValuePtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - CFStringRef, - CFPropertyListRef, - CFStringRef, - CFStringRef, - CFStringRef, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) > - >('CFPreferencesSetValue'); - late final _CFPreferencesSetValue = - _CFPreferencesSetValuePtr.asFunction< + >() + .asFunction< void Function( - CFStringRef, - CFPropertyListRef, - CFStringRef, - CFStringRef, - CFStringRef, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - void CFPreferencesSetMultiple( - CFDictionaryRef keysToSet, - CFArrayRef keysToRemove, - CFStringRef applicationID, - CFStringRef userName, - CFStringRef hostName, - ) { - return _CFPreferencesSetMultiple( - keysToSet, - keysToRemove, - applicationID, - userName, - hostName, - ); - } + >()(arg0, arg1, arg2); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFPreferencesSetMultiplePtr = - _lookup< +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< ffi.Void Function( - CFDictionaryRef, - CFArrayRef, - CFStringRef, - CFStringRef, - CFStringRef, + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) > - >('CFPreferencesSetMultiple'); - late final _CFPreferencesSetMultiple = - _CFPreferencesSetMultiplePtr.asFunction< + >() + .asFunction< void Function( - CFDictionaryRef, - CFArrayRef, - CFStringRef, - CFStringRef, - CFStringRef, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - int CFPreferencesSynchronize( - CFStringRef applicationID, - CFStringRef userName, - CFStringRef hostName, - ) { - return _CFPreferencesSynchronize(applicationID, userName, hostName); - } - - late final _CFPreferencesSynchronizePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFStringRef, CFStringRef, CFStringRef) - > - >('CFPreferencesSynchronize'); - late final _CFPreferencesSynchronize = - _CFPreferencesSynchronizePtr.asFunction< - int Function(CFStringRef, CFStringRef, CFStringRef) - >(); - - CFArrayRef CFPreferencesCopyApplicationList( - CFStringRef userName, - CFStringRef hostName, - ) { - return _CFPreferencesCopyApplicationList(userName, hostName); - } - - late final _CFPreferencesCopyApplicationListPtr = - _lookup< - ffi.NativeFunction - >('CFPreferencesCopyApplicationList'); - late final _CFPreferencesCopyApplicationList = - _CFPreferencesCopyApplicationListPtr.asFunction< - CFArrayRef Function(CFStringRef, CFStringRef) - >(); - - CFArrayRef CFPreferencesCopyKeyList( - CFStringRef applicationID, - CFStringRef userName, - CFStringRef hostName, - ) { - return _CFPreferencesCopyKeyList(applicationID, userName, hostName); - } - - late final _CFPreferencesCopyKeyListPtr = - _lookup< - ffi.NativeFunction< - CFArrayRef Function(CFStringRef, CFStringRef, CFStringRef) - > - >('CFPreferencesCopyKeyList'); - late final _CFPreferencesCopyKeyList = - _CFPreferencesCopyKeyListPtr.asFunction< - CFArrayRef Function(CFStringRef, CFStringRef, CFStringRef) - >(); - - int CFPreferencesAppValueIsForced( - CFStringRef key, - CFStringRef applicationID, - ) { - return _CFPreferencesAppValueIsForced(key, applicationID); - } - - late final _CFPreferencesAppValueIsForcedPtr = - _lookup>( - 'CFPreferencesAppValueIsForced', - ); - late final _CFPreferencesAppValueIsForced = - _CFPreferencesAppValueIsForcedPtr.asFunction< - int Function(CFStringRef, CFStringRef) - >(); - - int CFURLGetTypeID() { - return _CFURLGetTypeID(); - } - - late final _CFURLGetTypeIDPtr = - _lookup>('CFURLGetTypeID'); - late final _CFURLGetTypeID = _CFURLGetTypeIDPtr.asFunction(); + >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer); +} - CFURLRef CFURLCreateWithBytes( - CFAllocatorRef allocator, - ffi.Pointer URLBytes, - int length, - int encoding, - CFURLRef baseURL, - ) { - return _CFURLCreateWithBytes( - allocator, - URLBytes, - length, - encoding, - baseURL, +late final _sel_URLSession_task_willBeginDelayedRequest_completionHandler_ = + objc.registerName( + "URLSession:task:willBeginDelayedRequest:completionHandler:", ); - } - late final _CFURLCreateWithBytesPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFStringEncoding, - CFURLRef, - ) - > - >('CFURLCreateWithBytes'); - late final _CFURLCreateWithBytes = - _CFURLCreateWithBytesPtr.asFunction< - CFURLRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - int, - CFURLRef, +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLRequest, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, ) - >(); - - CFDataRef CFURLCreateData( - CFAllocatorRef allocator, - CFURLRef url, - int encoding, - int escapeWhitespace, - ) { - return _CFURLCreateData(allocator, url, encoding, escapeWhitespace); - } - - late final _CFURLCreateDataPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function( - CFAllocatorRef, - CFURLRef, - CFStringEncoding, - Boolean, - ) - > - >('CFURLCreateData'); - late final _CFURLCreateData = - _CFURLCreateDataPtr.asFunction< - CFDataRef Function(CFAllocatorRef, CFURLRef, int, int) - >(); - - CFURLRef CFURLCreateWithString( - CFAllocatorRef allocator, - CFStringRef URLString, - CFURLRef baseURL, - ) { - return _CFURLCreateWithString(allocator, URLString, baseURL); - } - - late final _CFURLCreateWithStringPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFAllocatorRef, CFStringRef, CFURLRef) - > - >('CFURLCreateWithString'); - late final _CFURLCreateWithString = - _CFURLCreateWithStringPtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFStringRef, CFURLRef) - >(); - - CFURLRef CFURLCreateAbsoluteURLWithBytes( - CFAllocatorRef alloc, - ffi.Pointer relativeURLBytes, - int length, - int encoding, - CFURLRef baseURL, - int useCompatibilityMode, - ) { - return _CFURLCreateAbsoluteURLWithBytes( - alloc, - relativeURLBytes, - length, - encoding, - baseURL, - useCompatibilityMode, - ); - } + >(pointer, retain: retain, release: release); - late final _CFURLCreateAbsoluteURLWithBytesPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFStringEncoding, - CFURLRef, - Boolean, - ) - > - >('CFURLCreateAbsoluteURLWithBytes'); - late final _CFURLCreateAbsoluteURLWithBytes = - _CFURLCreateAbsoluteURLWithBytesPtr.asFunction< - CFURLRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - int, - CFURLRef, - int, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) - >(); - - CFURLRef CFURLCreateWithFileSystemPath( - CFAllocatorRef allocator, - CFStringRef filePath, - CFURLPathStyle pathStyle, - DartBoolean isDirectory, - ) { - return _CFURLCreateWithFileSystemPath( - allocator, - filePath, - pathStyle.value, - isDirectory, - ); - } - - late final _CFURLCreateWithFileSystemPathPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFAllocatorRef, CFStringRef, CFIndex, Boolean) - > - >('CFURLCreateWithFileSystemPath'); - late final _CFURLCreateWithFileSystemPath = - _CFURLCreateWithFileSystemPathPtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFStringRef, int, int) - >(); - - CFURLRef CFURLCreateFromFileSystemRepresentation( - CFAllocatorRef allocator, - ffi.Pointer buffer, - int bufLen, - int isDirectory, - ) { - return _CFURLCreateFromFileSystemRepresentation( - allocator, - buffer, - bufLen, - isDirectory, - ); - } - - late final _CFURLCreateFromFileSystemRepresentationPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - Boolean, - ) - > - >('CFURLCreateFromFileSystemRepresentation'); - late final _CFURLCreateFromFileSystemRepresentation = - _CFURLCreateFromFileSystemRepresentationPtr.asFunction< - CFURLRef Function(CFAllocatorRef, ffi.Pointer, int, int) - >(); - - CFURLRef CFURLCreateWithFileSystemPathRelativeToBase( - CFAllocatorRef allocator, - CFStringRef filePath, - CFURLPathStyle pathStyle, - DartBoolean isDirectory, - CFURLRef baseURL, - ) { - return _CFURLCreateWithFileSystemPathRelativeToBase( - allocator, - filePath, - pathStyle.value, - isDirectory, - baseURL, - ); - } - - late final _CFURLCreateWithFileSystemPathRelativeToBasePtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function( - CFAllocatorRef, - CFStringRef, - CFIndex, - Boolean, - CFURLRef, - ) - > - >('CFURLCreateWithFileSystemPathRelativeToBase'); - late final _CFURLCreateWithFileSystemPathRelativeToBase = - _CFURLCreateWithFileSystemPathRelativeToBasePtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFStringRef, int, int, CFURLRef) - >(); - - CFURLRef CFURLCreateFromFileSystemRepresentationRelativeToBase( - CFAllocatorRef allocator, - ffi.Pointer buffer, - int bufLen, - int isDirectory, - CFURLRef baseURL, - ) { - return _CFURLCreateFromFileSystemRepresentationRelativeToBase( - allocator, - buffer, - bufLen, - isDirectory, - baseURL, - ); - } - - late final _CFURLCreateFromFileSystemRepresentationRelativeToBasePtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - Boolean, - CFURLRef, - ) - > - >('CFURLCreateFromFileSystemRepresentationRelativeToBase'); - late final _CFURLCreateFromFileSystemRepresentationRelativeToBase = - _CFURLCreateFromFileSystemRepresentationRelativeToBasePtr.asFunction< - CFURLRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - int, - CFURLRef, + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, ) - >(); - - int CFURLGetFileSystemRepresentation( - CFURLRef url, - int resolveAgainstBase, - ffi.Pointer buffer, - int maxBufLen, - ) { - return _CFURLGetFileSystemRepresentation( - url, - resolveAgainstBase, - buffer, - maxBufLen, - ); - } - - late final _CFURLGetFileSystemRepresentationPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFURLRef, Boolean, ffi.Pointer, CFIndex) - > - >('CFURLGetFileSystemRepresentation'); - late final _CFURLGetFileSystemRepresentation = - _CFURLGetFileSystemRepresentationPtr.asFunction< - int Function(CFURLRef, int, ffi.Pointer, int) - >(); - - CFURLRef CFURLCopyAbsoluteURL(CFURLRef relativeURL) { - return _CFURLCopyAbsoluteURL(relativeURL); - } - - late final _CFURLCopyAbsoluteURLPtr = - _lookup>( - 'CFURLCopyAbsoluteURL', - ); - late final _CFURLCopyAbsoluteURL = - _CFURLCopyAbsoluteURLPtr.asFunction(); - - CFStringRef CFURLGetString(CFURLRef anURL) { - return _CFURLGetString(anURL); - } - - late final _CFURLGetStringPtr = - _lookup>( - 'CFURLGetString', - ); - late final _CFURLGetString = - _CFURLGetStringPtr.asFunction(); - - CFURLRef CFURLGetBaseURL(CFURLRef anURL) { - return _CFURLGetBaseURL(anURL); - } - - late final _CFURLGetBaseURLPtr = - _lookup>( - 'CFURLGetBaseURL', - ); - late final _CFURLGetBaseURL = - _CFURLGetBaseURLPtr.asFunction(); - - int CFURLCanBeDecomposed(CFURLRef anURL) { - return _CFURLCanBeDecomposed(anURL); - } - - late final _CFURLCanBeDecomposedPtr = - _lookup>( - 'CFURLCanBeDecomposed', - ); - late final _CFURLCanBeDecomposed = - _CFURLCanBeDecomposedPtr.asFunction(); - - CFStringRef CFURLCopyScheme(CFURLRef anURL) { - return _CFURLCopyScheme(anURL); - } - - late final _CFURLCopySchemePtr = - _lookup>( - 'CFURLCopyScheme', - ); - late final _CFURLCopyScheme = - _CFURLCopySchemePtr.asFunction(); - - CFStringRef CFURLCopyNetLocation(CFURLRef anURL) { - return _CFURLCopyNetLocation(anURL); - } - - late final _CFURLCopyNetLocationPtr = - _lookup>( - 'CFURLCopyNetLocation', - ); - late final _CFURLCopyNetLocation = - _CFURLCopyNetLocationPtr.asFunction(); - - CFStringRef CFURLCopyPath(CFURLRef anURL) { - return _CFURLCopyPath(anURL); - } - - late final _CFURLCopyPathPtr = - _lookup>( - 'CFURLCopyPath', - ); - late final _CFURLCopyPath = - _CFURLCopyPathPtr.asFunction(); - - CFStringRef CFURLCopyStrictPath( - CFURLRef anURL, - ffi.Pointer isAbsolute, - ) { - return _CFURLCopyStrictPath(anURL, isAbsolute); - } - - late final _CFURLCopyStrictPathPtr = - _lookup< - ffi.NativeFunction)> - >('CFURLCopyStrictPath'); - late final _CFURLCopyStrictPath = - _CFURLCopyStrictPathPtr.asFunction< - CFStringRef Function(CFURLRef, ffi.Pointer) - >(); - - CFStringRef CFURLCopyFileSystemPath( - CFURLRef anURL, - CFURLPathStyle pathStyle, - ) { - return _CFURLCopyFileSystemPath(anURL, pathStyle.value); - } - - late final _CFURLCopyFileSystemPathPtr = - _lookup>( - 'CFURLCopyFileSystemPath', - ); - late final _CFURLCopyFileSystemPath = - _CFURLCopyFileSystemPathPtr.asFunction< - CFStringRef Function(CFURLRef, int) - >(); - - int CFURLHasDirectoryPath(CFURLRef anURL) { - return _CFURLHasDirectoryPath(anURL); - } - - late final _CFURLHasDirectoryPathPtr = - _lookup>( - 'CFURLHasDirectoryPath', - ); - late final _CFURLHasDirectoryPath = - _CFURLHasDirectoryPathPtr.asFunction(); - - CFStringRef CFURLCopyResourceSpecifier(CFURLRef anURL) { - return _CFURLCopyResourceSpecifier(anURL); - } - - late final _CFURLCopyResourceSpecifierPtr = - _lookup>( - 'CFURLCopyResourceSpecifier', - ); - late final _CFURLCopyResourceSpecifier = - _CFURLCopyResourceSpecifierPtr.asFunction< - CFStringRef Function(CFURLRef) - >(); - - CFStringRef CFURLCopyHostName(CFURLRef anURL) { - return _CFURLCopyHostName(anURL); - } - - late final _CFURLCopyHostNamePtr = - _lookup>( - 'CFURLCopyHostName', - ); - late final _CFURLCopyHostName = - _CFURLCopyHostNamePtr.asFunction(); - - int CFURLGetPortNumber(CFURLRef anURL) { - return _CFURLGetPortNumber(anURL); - } - - late final _CFURLGetPortNumberPtr = - _lookup>( - 'CFURLGetPortNumber', - ); - late final _CFURLGetPortNumber = - _CFURLGetPortNumberPtr.asFunction(); - - CFStringRef CFURLCopyUserName(CFURLRef anURL) { - return _CFURLCopyUserName(anURL); - } - - late final _CFURLCopyUserNamePtr = - _lookup>( - 'CFURLCopyUserName', - ); - late final _CFURLCopyUserName = - _CFURLCopyUserNamePtr.asFunction(); - - CFStringRef CFURLCopyPassword(CFURLRef anURL) { - return _CFURLCopyPassword(anURL); - } - - late final _CFURLCopyPasswordPtr = - _lookup>( - 'CFURLCopyPassword', - ); - late final _CFURLCopyPassword = - _CFURLCopyPasswordPtr.asFunction(); - - CFStringRef CFURLCopyParameterString( - CFURLRef anURL, - CFStringRef charactersToLeaveEscaped, - ) { - return _CFURLCopyParameterString(anURL, charactersToLeaveEscaped); - } - - late final _CFURLCopyParameterStringPtr = - _lookup>( - 'CFURLCopyParameterString', - ); - late final _CFURLCopyParameterString = - _CFURLCopyParameterStringPtr.asFunction< - CFStringRef Function(CFURLRef, CFStringRef) - >(); - - CFStringRef CFURLCopyQueryString( - CFURLRef anURL, - CFStringRef charactersToLeaveEscaped, - ) { - return _CFURLCopyQueryString(anURL, charactersToLeaveEscaped); - } - - late final _CFURLCopyQueryStringPtr = - _lookup>( - 'CFURLCopyQueryString', - ); - late final _CFURLCopyQueryString = - _CFURLCopyQueryStringPtr.asFunction< - CFStringRef Function(CFURLRef, CFStringRef) - >(); - - CFStringRef CFURLCopyFragment( - CFURLRef anURL, - CFStringRef charactersToLeaveEscaped, - ) { - return _CFURLCopyFragment(anURL, charactersToLeaveEscaped); - } - - late final _CFURLCopyFragmentPtr = - _lookup>( - 'CFURLCopyFragment', + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _CFURLCopyFragment = - _CFURLCopyFragmentPtr.asFunction< - CFStringRef Function(CFURLRef, CFStringRef) - >(); - CFStringRef CFURLCopyLastPathComponent(CFURLRef url) { - return _CFURLCopyLastPathComponent(url); - } - - late final _CFURLCopyLastPathComponentPtr = - _lookup>( - 'CFURLCopyLastPathComponent', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + NSURLRequest.fromPointer(arg3, retain: true, release: true), + ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( + arg4, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _CFURLCopyLastPathComponent = - _CFURLCopyLastPathComponentPtr.asFunction< - CFStringRef Function(CFURLRef) - >(); - - CFStringRef CFURLCopyPathExtension(CFURLRef url) { - return _CFURLCopyPathExtension(url); - } - late final _CFURLCopyPathExtensionPtr = - _lookup>( - 'CFURLCopyPathExtension', - ); - late final _CFURLCopyPathExtension = - _CFURLCopyPathExtensionPtr.asFunction(); - - CFURLRef CFURLCreateCopyAppendingPathComponent( - CFAllocatorRef allocator, - CFURLRef url, - CFStringRef pathComponent, - int isDirectory, - ) { - return _CFURLCreateCopyAppendingPathComponent( - allocator, - url, - pathComponent, - isDirectory, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLRequest.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xx612k(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _CFURLCreateCopyAppendingPathComponentPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef, CFStringRef, Boolean) - > - >('CFURLCreateCopyAppendingPathComponent'); - late final _CFURLCreateCopyAppendingPathComponent = - _CFURLCreateCopyAppendingPathComponentPtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef, CFStringRef, int) - >(); - - CFURLRef CFURLCreateCopyDeletingLastPathComponent( - CFAllocatorRef allocator, - CFURLRef url, - ) { - return _CFURLCreateCopyDeletingLastPathComponent(allocator, url); - } - - late final _CFURLCreateCopyDeletingLastPathComponentPtr = - _lookup>( - 'CFURLCreateCopyDeletingLastPathComponent', - ); - late final _CFURLCreateCopyDeletingLastPathComponent = - _CFURLCreateCopyDeletingLastPathComponentPtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef) - >(); - - CFURLRef CFURLCreateCopyAppendingPathExtension( - CFAllocatorRef allocator, - CFURLRef url, - CFStringRef extension, - ) { - return _CFURLCreateCopyAppendingPathExtension(allocator, url, extension); - } - - late final _CFURLCreateCopyAppendingPathExtensionPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef, CFStringRef) - > - >('CFURLCreateCopyAppendingPathExtension'); - late final _CFURLCreateCopyAppendingPathExtension = - _CFURLCreateCopyAppendingPathExtensionPtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef, CFStringRef) - >(); - - CFURLRef CFURLCreateCopyDeletingPathExtension( - CFAllocatorRef allocator, - CFURLRef url, - ) { - return _CFURLCreateCopyDeletingPathExtension(allocator, url); - } - - late final _CFURLCreateCopyDeletingPathExtensionPtr = - _lookup>( - 'CFURLCreateCopyDeletingPathExtension', - ); - late final _CFURLCreateCopyDeletingPathExtension = - _CFURLCreateCopyDeletingPathExtensionPtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef) - >(); - - int CFURLGetBytes(CFURLRef url, ffi.Pointer buffer, int bufferLength) { - return _CFURLGetBytes(url, buffer, bufferLength); - } - - late final _CFURLGetBytesPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFURLRef, ffi.Pointer, CFIndex) - > - >('CFURLGetBytes'); - late final _CFURLGetBytes = - _CFURLGetBytesPtr.asFunction< - int Function(CFURLRef, ffi.Pointer, int) - >(); - - CFRange CFURLGetByteRangeForComponent( - CFURLRef url, - CFURLComponentType component, - ffi.Pointer rangeIncludingSeparators, - ) { - return _CFURLGetByteRangeForComponent( - url, - component.value, - rangeIncludingSeparators, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLRequest.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); - } - - late final _CFURLGetByteRangeForComponentPtr = - _lookup< - ffi.NativeFunction< - CFRange Function(CFURLRef, CFIndex, ffi.Pointer) - > - >('CFURLGetByteRangeForComponent'); - late final _CFURLGetByteRangeForComponent = - _CFURLGetByteRangeForComponentPtr.asFunction< - CFRange Function(CFURLRef, int, ffi.Pointer) - >(); - - CFStringRef CFURLCreateStringByReplacingPercentEscapes( - CFAllocatorRef allocator, - CFStringRef originalString, - CFStringRef charactersToLeaveEscaped, - ) { - return _CFURLCreateStringByReplacingPercentEscapes( - allocator, - originalString, - charactersToLeaveEscaped, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLRequest.fromPointer(arg3, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); - } - - late final _CFURLCreateStringByReplacingPercentEscapesPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFStringRef) - > - >('CFURLCreateStringByReplacingPercentEscapes'); - late final _CFURLCreateStringByReplacingPercentEscapes = - _CFURLCreateStringByReplacingPercentEscapesPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFStringRef) - >(); - - CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding( - CFAllocatorRef allocator, - CFStringRef origString, - CFStringRef charsToLeaveEscaped, - int encoding, - ) { - return _CFURLCreateStringByReplacingPercentEscapesUsingEncoding( - allocator, - origString, - charsToLeaveEscaped, - encoding, + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( + raw, + rawListener, + objc.objCContext, ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _CFURLCreateStringByReplacingPercentEscapesUsingEncodingPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFStringRef, - CFStringRef, - CFStringEncoding, - ) - > - >('CFURLCreateStringByReplacingPercentEscapesUsingEncoding'); - late final _CFURLCreateStringByReplacingPercentEscapesUsingEncoding = - _CFURLCreateStringByReplacingPercentEscapesUsingEncodingPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFStringRef, int) - >(); - - CFStringRef CFURLCreateStringByAddingPercentEscapes( - CFAllocatorRef allocator, - CFStringRef originalString, - CFStringRef charactersToLeaveUnescaped, - CFStringRef legalURLCharactersToBeEscaped, - int encoding, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) { - return _CFURLCreateStringByAddingPercentEscapes( - allocator, - originalString, - charactersToLeaveUnescaped, - legalURLCharactersToBeEscaped, - encoding, - ); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + objc.objectRelease(block.cast()); } - late final _CFURLCreateStringByAddingPercentEscapesPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFStringEncoding, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFURLCreateStringByAddingPercentEscapes'); - late final _CFURLCreateStringByAddingPercentEscapes = - _CFURLCreateStringByAddingPercentEscapesPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - CFStringRef, - CFStringRef, - CFStringRef, - int, - ) - >(); - - int CFURLIsFileReferenceURL(CFURLRef url) { - return _CFURLIsFileReferenceURL(url); - } - - late final _CFURLIsFileReferenceURLPtr = - _lookup>( - 'CFURLIsFileReferenceURL', - ); - late final _CFURLIsFileReferenceURL = - _CFURLIsFileReferenceURLPtr.asFunction(); - - CFURLRef CFURLCreateFileReferenceURL( - CFAllocatorRef allocator, - CFURLRef url, - ffi.Pointer error, - ) { - return _CFURLCreateFileReferenceURL(allocator, url, error); - } - - late final _CFURLCreateFileReferenceURLPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef, ffi.Pointer) - > - >('CFURLCreateFileReferenceURL'); - late final _CFURLCreateFileReferenceURL = - _CFURLCreateFileReferenceURLPtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef, ffi.Pointer) - >(); - - CFURLRef CFURLCreateFilePathURL( - CFAllocatorRef allocator, - CFURLRef url, - ffi.Pointer error, - ) { - return _CFURLCreateFilePathURL(allocator, url, error); - } - - late final _CFURLCreateFilePathURLPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef, ffi.Pointer) - > - >('CFURLCreateFilePathURL'); - late final _CFURLCreateFilePathURL = - _CFURLCreateFilePathURLPtr.asFunction< - CFURLRef Function(CFAllocatorRef, CFURLRef, ffi.Pointer) - >(); - - CFURLRef CFURLCreateFromFSRef( - CFAllocatorRef allocator, - ffi.Pointer fsRef, - ) { - return _CFURLCreateFromFSRef(allocator, fsRef); - } - - late final _CFURLCreateFromFSRefPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFAllocatorRef, ffi.Pointer) - > - >('CFURLCreateFromFSRef'); - late final _CFURLCreateFromFSRef = - _CFURLCreateFromFSRefPtr.asFunction< - CFURLRef Function(CFAllocatorRef, ffi.Pointer) - >(); - - int CFURLGetFSRef(CFURLRef url, ffi.Pointer fsRef) { - return _CFURLGetFSRef(url, fsRef); - } - - late final _CFURLGetFSRefPtr = - _lookup< - ffi.NativeFunction)> - >('CFURLGetFSRef'); - late final _CFURLGetFSRef = - _CFURLGetFSRefPtr.asFunction< - int Function(CFURLRef, ffi.Pointer) - >(); - - int CFURLCopyResourcePropertyForKey( - CFURLRef url, - CFStringRef key, - ffi.Pointer propertyValueTypeRefPtr, - ffi.Pointer error, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) { - return _CFURLCopyResourcePropertyForKey( - url, - key, - propertyValueTypeRefPtr, - error, - ); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFURLCopyResourcePropertyForKeyPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFURLRef, - CFStringRef, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFURLCopyResourcePropertyForKey'); - late final _CFURLCopyResourcePropertyForKey = - _CFURLCopyResourcePropertyForKeyPtr.asFunction< - int Function( - CFURLRef, - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFDictionaryRef CFURLCopyResourcePropertiesForKeys( - CFURLRef url, - CFArrayRef keys, - ffi.Pointer error, - ) { - return _CFURLCopyResourcePropertiesForKeys(url, keys, error); - } - - late final _CFURLCopyResourcePropertiesForKeysPtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function( - CFURLRef, - CFArrayRef, - ffi.Pointer, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFURLCopyResourcePropertiesForKeys'); - late final _CFURLCopyResourcePropertiesForKeys = - _CFURLCopyResourcePropertiesForKeysPtr.asFunction< - CFDictionaryRef Function(CFURLRef, CFArrayRef, ffi.Pointer) - >(); - - int CFURLSetResourcePropertyForKey( - CFURLRef url, - CFStringRef key, - CFTypeRef propertyValue, - ffi.Pointer error, - ) { - return _CFURLSetResourcePropertyForKey(url, key, propertyValue, error); - } - - late final _CFURLSetResourcePropertyForKeyPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => block.ref.target + .cast< ffi.NativeFunction< - Boolean Function( - CFURLRef, - CFStringRef, - CFTypeRef, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) > - >('CFURLSetResourcePropertyForKey'); - late final _CFURLSetResourcePropertyForKey = - _CFURLSetResourcePropertyForKeyPtr.asFunction< - int Function(CFURLRef, CFStringRef, CFTypeRef, ffi.Pointer) - >(); - - int CFURLSetResourcePropertiesForKeys( - CFURLRef url, - CFDictionaryRef keyedPropertyValues, - ffi.Pointer error, - ) { - return _CFURLSetResourcePropertiesForKeys(url, keyedPropertyValues, error); - } - - late final _CFURLSetResourcePropertiesForKeysPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFURLRef, CFDictionaryRef, ffi.Pointer) - > - >('CFURLSetResourcePropertiesForKeys'); - late final _CFURLSetResourcePropertiesForKeys = - _CFURLSetResourcePropertiesForKeysPtr.asFunction< - int Function(CFURLRef, CFDictionaryRef, ffi.Pointer) - >(); - - late final ffi.Pointer _kCFURLKeysOfUnsetValuesKey = - _lookup('kCFURLKeysOfUnsetValuesKey'); - - CFStringRef get kCFURLKeysOfUnsetValuesKey => - _kCFURLKeysOfUnsetValuesKey.value; - - void CFURLClearResourcePropertyCacheForKey(CFURLRef url, CFStringRef key) { - return _CFURLClearResourcePropertyCacheForKey(url, key); - } - - late final _CFURLClearResourcePropertyCacheForKeyPtr = - _lookup>( - 'CFURLClearResourcePropertyCacheForKey', - ); - late final _CFURLClearResourcePropertyCacheForKey = - _CFURLClearResourcePropertyCacheForKeyPtr.asFunction< - void Function(CFURLRef, CFStringRef) - >(); - - void CFURLClearResourcePropertyCache(CFURLRef url) { - return _CFURLClearResourcePropertyCache(url); - } - - late final _CFURLClearResourcePropertyCachePtr = - _lookup>( - 'CFURLClearResourcePropertyCache', - ); - late final _CFURLClearResourcePropertyCache = - _CFURLClearResourcePropertyCachePtr.asFunction(); - - void CFURLSetTemporaryResourcePropertyForKey( - CFURLRef url, - CFStringRef key, - CFTypeRef propertyValue, - ) { - return _CFURLSetTemporaryResourcePropertyForKey(url, key, propertyValue); - } - - late final _CFURLSetTemporaryResourcePropertyForKeyPtr = - _lookup< - ffi.NativeFunction - >('CFURLSetTemporaryResourcePropertyForKey'); - late final _CFURLSetTemporaryResourcePropertyForKey = - _CFURLSetTemporaryResourcePropertyForKeyPtr.asFunction< - void Function(CFURLRef, CFStringRef, CFTypeRef) - >(); - - int CFURLResourceIsReachable(CFURLRef url, ffi.Pointer error) { - return _CFURLResourceIsReachable(url, error); - } - - late final _CFURLResourceIsReachablePtr = - _lookup< - ffi.NativeFunction)> - >('CFURLResourceIsReachable'); - late final _CFURLResourceIsReachable = - _CFURLResourceIsReachablePtr.asFunction< - int Function(CFURLRef, ffi.Pointer) - >(); - - late final ffi.Pointer _kCFURLNameKey = _lookup( - 'kCFURLNameKey', - ); - - CFStringRef get kCFURLNameKey => _kCFURLNameKey.value; - - late final ffi.Pointer _kCFURLLocalizedNameKey = - _lookup('kCFURLLocalizedNameKey'); - - CFStringRef get kCFURLLocalizedNameKey => _kCFURLLocalizedNameKey.value; - - late final ffi.Pointer _kCFURLIsRegularFileKey = - _lookup('kCFURLIsRegularFileKey'); - - CFStringRef get kCFURLIsRegularFileKey => _kCFURLIsRegularFileKey.value; - - late final ffi.Pointer _kCFURLIsDirectoryKey = - _lookup('kCFURLIsDirectoryKey'); - - CFStringRef get kCFURLIsDirectoryKey => _kCFURLIsDirectoryKey.value; - - late final ffi.Pointer _kCFURLIsSymbolicLinkKey = - _lookup('kCFURLIsSymbolicLinkKey'); - - CFStringRef get kCFURLIsSymbolicLinkKey => _kCFURLIsSymbolicLinkKey.value; - - late final ffi.Pointer _kCFURLIsVolumeKey = _lookup( - 'kCFURLIsVolumeKey', - ); - - CFStringRef get kCFURLIsVolumeKey => _kCFURLIsVolumeKey.value; - - late final ffi.Pointer _kCFURLIsPackageKey = - _lookup('kCFURLIsPackageKey'); - - CFStringRef get kCFURLIsPackageKey => _kCFURLIsPackageKey.value; - - late final ffi.Pointer _kCFURLIsApplicationKey = - _lookup('kCFURLIsApplicationKey'); - - CFStringRef get kCFURLIsApplicationKey => _kCFURLIsApplicationKey.value; - - late final ffi.Pointer _kCFURLApplicationIsScriptableKey = - _lookup('kCFURLApplicationIsScriptableKey'); - - CFStringRef get kCFURLApplicationIsScriptableKey => - _kCFURLApplicationIsScriptableKey.value; - - late final ffi.Pointer _kCFURLIsSystemImmutableKey = - _lookup('kCFURLIsSystemImmutableKey'); - - CFStringRef get kCFURLIsSystemImmutableKey => - _kCFURLIsSystemImmutableKey.value; - - late final ffi.Pointer _kCFURLIsUserImmutableKey = - _lookup('kCFURLIsUserImmutableKey'); - - CFStringRef get kCFURLIsUserImmutableKey => _kCFURLIsUserImmutableKey.value; - - late final ffi.Pointer _kCFURLIsHiddenKey = _lookup( - 'kCFURLIsHiddenKey', - ); - - CFStringRef get kCFURLIsHiddenKey => _kCFURLIsHiddenKey.value; - - late final ffi.Pointer _kCFURLHasHiddenExtensionKey = - _lookup('kCFURLHasHiddenExtensionKey'); - - CFStringRef get kCFURLHasHiddenExtensionKey => - _kCFURLHasHiddenExtensionKey.value; - - late final ffi.Pointer _kCFURLCreationDateKey = - _lookup('kCFURLCreationDateKey'); - - CFStringRef get kCFURLCreationDateKey => _kCFURLCreationDateKey.value; - - late final ffi.Pointer _kCFURLContentAccessDateKey = - _lookup('kCFURLContentAccessDateKey'); - - CFStringRef get kCFURLContentAccessDateKey => - _kCFURLContentAccessDateKey.value; - - late final ffi.Pointer _kCFURLContentModificationDateKey = - _lookup('kCFURLContentModificationDateKey'); - - CFStringRef get kCFURLContentModificationDateKey => - _kCFURLContentModificationDateKey.value; - - late final ffi.Pointer _kCFURLAttributeModificationDateKey = - _lookup('kCFURLAttributeModificationDateKey'); - - CFStringRef get kCFURLAttributeModificationDateKey => - _kCFURLAttributeModificationDateKey.value; - - late final ffi.Pointer _kCFURLFileIdentifierKey = - _lookup('kCFURLFileIdentifierKey'); - - CFStringRef get kCFURLFileIdentifierKey => _kCFURLFileIdentifierKey.value; - - late final ffi.Pointer _kCFURLFileContentIdentifierKey = - _lookup('kCFURLFileContentIdentifierKey'); - - CFStringRef get kCFURLFileContentIdentifierKey => - _kCFURLFileContentIdentifierKey.value; - - late final ffi.Pointer _kCFURLMayShareFileContentKey = - _lookup('kCFURLMayShareFileContentKey'); - - CFStringRef get kCFURLMayShareFileContentKey => - _kCFURLMayShareFileContentKey.value; - - late final ffi.Pointer _kCFURLMayHaveExtendedAttributesKey = - _lookup('kCFURLMayHaveExtendedAttributesKey'); - - CFStringRef get kCFURLMayHaveExtendedAttributesKey => - _kCFURLMayHaveExtendedAttributesKey.value; - - late final ffi.Pointer _kCFURLIsPurgeableKey = - _lookup('kCFURLIsPurgeableKey'); - - CFStringRef get kCFURLIsPurgeableKey => _kCFURLIsPurgeableKey.value; - - late final ffi.Pointer _kCFURLIsSparseKey = _lookup( - 'kCFURLIsSparseKey', - ); - - CFStringRef get kCFURLIsSparseKey => _kCFURLIsSparseKey.value; - - late final ffi.Pointer _kCFURLLinkCountKey = - _lookup('kCFURLLinkCountKey'); - - CFStringRef get kCFURLLinkCountKey => _kCFURLLinkCountKey.value; - - late final ffi.Pointer _kCFURLParentDirectoryURLKey = - _lookup('kCFURLParentDirectoryURLKey'); - - CFStringRef get kCFURLParentDirectoryURLKey => - _kCFURLParentDirectoryURLKey.value; - - late final ffi.Pointer _kCFURLVolumeURLKey = - _lookup('kCFURLVolumeURLKey'); - - CFStringRef get kCFURLVolumeURLKey => _kCFURLVolumeURLKey.value; - - late final ffi.Pointer _kCFURLTypeIdentifierKey = - _lookup('kCFURLTypeIdentifierKey'); - - CFStringRef get kCFURLTypeIdentifierKey => _kCFURLTypeIdentifierKey.value; - - late final ffi.Pointer _kCFURLLocalizedTypeDescriptionKey = - _lookup('kCFURLLocalizedTypeDescriptionKey'); - - CFStringRef get kCFURLLocalizedTypeDescriptionKey => - _kCFURLLocalizedTypeDescriptionKey.value; - - late final ffi.Pointer _kCFURLLabelNumberKey = - _lookup('kCFURLLabelNumberKey'); - - CFStringRef get kCFURLLabelNumberKey => _kCFURLLabelNumberKey.value; - - late final ffi.Pointer _kCFURLLabelColorKey = - _lookup('kCFURLLabelColorKey'); - - CFStringRef get kCFURLLabelColorKey => _kCFURLLabelColorKey.value; - - late final ffi.Pointer _kCFURLLocalizedLabelKey = - _lookup('kCFURLLocalizedLabelKey'); - - CFStringRef get kCFURLLocalizedLabelKey => _kCFURLLocalizedLabelKey.value; - - late final ffi.Pointer _kCFURLEffectiveIconKey = - _lookup('kCFURLEffectiveIconKey'); - - CFStringRef get kCFURLEffectiveIconKey => _kCFURLEffectiveIconKey.value; - - late final ffi.Pointer _kCFURLCustomIconKey = - _lookup('kCFURLCustomIconKey'); - - CFStringRef get kCFURLCustomIconKey => _kCFURLCustomIconKey.value; - - late final ffi.Pointer _kCFURLFileResourceIdentifierKey = - _lookup('kCFURLFileResourceIdentifierKey'); - - CFStringRef get kCFURLFileResourceIdentifierKey => - _kCFURLFileResourceIdentifierKey.value; - - late final ffi.Pointer _kCFURLVolumeIdentifierKey = - _lookup('kCFURLVolumeIdentifierKey'); - - CFStringRef get kCFURLVolumeIdentifierKey => _kCFURLVolumeIdentifierKey.value; - - late final ffi.Pointer _kCFURLPreferredIOBlockSizeKey = - _lookup('kCFURLPreferredIOBlockSizeKey'); - - CFStringRef get kCFURLPreferredIOBlockSizeKey => - _kCFURLPreferredIOBlockSizeKey.value; - - late final ffi.Pointer _kCFURLIsReadableKey = - _lookup('kCFURLIsReadableKey'); - - CFStringRef get kCFURLIsReadableKey => _kCFURLIsReadableKey.value; - - late final ffi.Pointer _kCFURLIsWritableKey = - _lookup('kCFURLIsWritableKey'); - - CFStringRef get kCFURLIsWritableKey => _kCFURLIsWritableKey.value; - - late final ffi.Pointer _kCFURLIsExecutableKey = - _lookup('kCFURLIsExecutableKey'); - - CFStringRef get kCFURLIsExecutableKey => _kCFURLIsExecutableKey.value; - - late final ffi.Pointer _kCFURLFileSecurityKey = - _lookup('kCFURLFileSecurityKey'); - - CFStringRef get kCFURLFileSecurityKey => _kCFURLFileSecurityKey.value; - - late final ffi.Pointer _kCFURLIsExcludedFromBackupKey = - _lookup('kCFURLIsExcludedFromBackupKey'); - - CFStringRef get kCFURLIsExcludedFromBackupKey => - _kCFURLIsExcludedFromBackupKey.value; - - late final ffi.Pointer _kCFURLTagNamesKey = _lookup( - 'kCFURLTagNamesKey', - ); - - CFStringRef get kCFURLTagNamesKey => _kCFURLTagNamesKey.value; - - late final ffi.Pointer _kCFURLPathKey = _lookup( - 'kCFURLPathKey', - ); - - CFStringRef get kCFURLPathKey => _kCFURLPathKey.value; - - late final ffi.Pointer _kCFURLCanonicalPathKey = - _lookup('kCFURLCanonicalPathKey'); - - CFStringRef get kCFURLCanonicalPathKey => _kCFURLCanonicalPathKey.value; - - late final ffi.Pointer _kCFURLIsMountTriggerKey = - _lookup('kCFURLIsMountTriggerKey'); - - CFStringRef get kCFURLIsMountTriggerKey => _kCFURLIsMountTriggerKey.value; - - late final ffi.Pointer _kCFURLGenerationIdentifierKey = - _lookup('kCFURLGenerationIdentifierKey'); - - CFStringRef get kCFURLGenerationIdentifierKey => - _kCFURLGenerationIdentifierKey.value; - - late final ffi.Pointer _kCFURLDocumentIdentifierKey = - _lookup('kCFURLDocumentIdentifierKey'); - - CFStringRef get kCFURLDocumentIdentifierKey => - _kCFURLDocumentIdentifierKey.value; - - late final ffi.Pointer _kCFURLAddedToDirectoryDateKey = - _lookup('kCFURLAddedToDirectoryDateKey'); - - CFStringRef get kCFURLAddedToDirectoryDateKey => - _kCFURLAddedToDirectoryDateKey.value; - - late final ffi.Pointer _kCFURLQuarantinePropertiesKey = - _lookup('kCFURLQuarantinePropertiesKey'); - - CFStringRef get kCFURLQuarantinePropertiesKey => - _kCFURLQuarantinePropertiesKey.value; - - late final ffi.Pointer _kCFURLFileResourceTypeKey = - _lookup('kCFURLFileResourceTypeKey'); - - CFStringRef get kCFURLFileResourceTypeKey => _kCFURLFileResourceTypeKey.value; - - late final ffi.Pointer _kCFURLFileResourceTypeNamedPipe = - _lookup('kCFURLFileResourceTypeNamedPipe'); - - CFStringRef get kCFURLFileResourceTypeNamedPipe => - _kCFURLFileResourceTypeNamedPipe.value; - - late final ffi.Pointer _kCFURLFileResourceTypeCharacterSpecial = - _lookup('kCFURLFileResourceTypeCharacterSpecial'); - - CFStringRef get kCFURLFileResourceTypeCharacterSpecial => - _kCFURLFileResourceTypeCharacterSpecial.value; - - late final ffi.Pointer _kCFURLFileResourceTypeDirectory = - _lookup('kCFURLFileResourceTypeDirectory'); - - CFStringRef get kCFURLFileResourceTypeDirectory => - _kCFURLFileResourceTypeDirectory.value; - - late final ffi.Pointer _kCFURLFileResourceTypeBlockSpecial = - _lookup('kCFURLFileResourceTypeBlockSpecial'); - - CFStringRef get kCFURLFileResourceTypeBlockSpecial => - _kCFURLFileResourceTypeBlockSpecial.value; - - late final ffi.Pointer _kCFURLFileResourceTypeRegular = - _lookup('kCFURLFileResourceTypeRegular'); - - CFStringRef get kCFURLFileResourceTypeRegular => - _kCFURLFileResourceTypeRegular.value; - - late final ffi.Pointer _kCFURLFileResourceTypeSymbolicLink = - _lookup('kCFURLFileResourceTypeSymbolicLink'); - - CFStringRef get kCFURLFileResourceTypeSymbolicLink => - _kCFURLFileResourceTypeSymbolicLink.value; - - late final ffi.Pointer _kCFURLFileResourceTypeSocket = - _lookup('kCFURLFileResourceTypeSocket'); - - CFStringRef get kCFURLFileResourceTypeSocket => - _kCFURLFileResourceTypeSocket.value; - - late final ffi.Pointer _kCFURLFileResourceTypeUnknown = - _lookup('kCFURLFileResourceTypeUnknown'); - - CFStringRef get kCFURLFileResourceTypeUnknown => - _kCFURLFileResourceTypeUnknown.value; - - late final ffi.Pointer _kCFURLFileSizeKey = _lookup( - 'kCFURLFileSizeKey', - ); - - CFStringRef get kCFURLFileSizeKey => _kCFURLFileSizeKey.value; - - late final ffi.Pointer _kCFURLFileAllocatedSizeKey = - _lookup('kCFURLFileAllocatedSizeKey'); - - CFStringRef get kCFURLFileAllocatedSizeKey => - _kCFURLFileAllocatedSizeKey.value; - - late final ffi.Pointer _kCFURLTotalFileSizeKey = - _lookup('kCFURLTotalFileSizeKey'); - - CFStringRef get kCFURLTotalFileSizeKey => _kCFURLTotalFileSizeKey.value; - - late final ffi.Pointer _kCFURLTotalFileAllocatedSizeKey = - _lookup('kCFURLTotalFileAllocatedSizeKey'); - - CFStringRef get kCFURLTotalFileAllocatedSizeKey => - _kCFURLTotalFileAllocatedSizeKey.value; - - late final ffi.Pointer _kCFURLIsAliasFileKey = - _lookup('kCFURLIsAliasFileKey'); - - CFStringRef get kCFURLIsAliasFileKey => _kCFURLIsAliasFileKey.value; - - late final ffi.Pointer _kCFURLFileProtectionKey = - _lookup('kCFURLFileProtectionKey'); - - CFStringRef get kCFURLFileProtectionKey => _kCFURLFileProtectionKey.value; - - late final ffi.Pointer _kCFURLFileProtectionNone = - _lookup('kCFURLFileProtectionNone'); - - CFStringRef get kCFURLFileProtectionNone => _kCFURLFileProtectionNone.value; - - late final ffi.Pointer _kCFURLFileProtectionComplete = - _lookup('kCFURLFileProtectionComplete'); - - CFStringRef get kCFURLFileProtectionComplete => - _kCFURLFileProtectionComplete.value; - - late final ffi.Pointer _kCFURLFileProtectionCompleteUnlessOpen = - _lookup('kCFURLFileProtectionCompleteUnlessOpen'); - - CFStringRef get kCFURLFileProtectionCompleteUnlessOpen => - _kCFURLFileProtectionCompleteUnlessOpen.value; + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final ffi.Pointer - _kCFURLFileProtectionCompleteUntilFirstUserAuthentication = - _lookup( - 'kCFURLFileProtectionCompleteUntilFirstUserAuthentication', +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLRequest, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, + arg4.ref.pointer, ); +} - CFStringRef get kCFURLFileProtectionCompleteUntilFirstUserAuthentication => - _kCFURLFileProtectionCompleteUntilFirstUserAuthentication.value; - - late final ffi.Pointer - _kCFURLFileProtectionCompleteWhenUserInactive = _lookup( - 'kCFURLFileProtectionCompleteWhenUserInactive', - ); - - CFStringRef get kCFURLFileProtectionCompleteWhenUserInactive => - _kCFURLFileProtectionCompleteWhenUserInactive.value; - - late final ffi.Pointer _kCFURLDirectoryEntryCountKey = - _lookup('kCFURLDirectoryEntryCountKey'); - - CFStringRef get kCFURLDirectoryEntryCountKey => - _kCFURLDirectoryEntryCountKey.value; - - late final ffi.Pointer - _kCFURLVolumeLocalizedFormatDescriptionKey = _lookup( - 'kCFURLVolumeLocalizedFormatDescriptionKey', - ); - - CFStringRef get kCFURLVolumeLocalizedFormatDescriptionKey => - _kCFURLVolumeLocalizedFormatDescriptionKey.value; - - late final ffi.Pointer _kCFURLVolumeTotalCapacityKey = - _lookup('kCFURLVolumeTotalCapacityKey'); - - CFStringRef get kCFURLVolumeTotalCapacityKey => - _kCFURLVolumeTotalCapacityKey.value; - - late final ffi.Pointer _kCFURLVolumeAvailableCapacityKey = - _lookup('kCFURLVolumeAvailableCapacityKey'); - - CFStringRef get kCFURLVolumeAvailableCapacityKey => - _kCFURLVolumeAvailableCapacityKey.value; - - late final ffi.Pointer - _kCFURLVolumeAvailableCapacityForImportantUsageKey = _lookup( - 'kCFURLVolumeAvailableCapacityForImportantUsageKey', - ); - - CFStringRef get kCFURLVolumeAvailableCapacityForImportantUsageKey => - _kCFURLVolumeAvailableCapacityForImportantUsageKey.value; - - late final ffi.Pointer - _kCFURLVolumeAvailableCapacityForOpportunisticUsageKey = _lookup( - 'kCFURLVolumeAvailableCapacityForOpportunisticUsageKey', - ); - - CFStringRef get kCFURLVolumeAvailableCapacityForOpportunisticUsageKey => - _kCFURLVolumeAvailableCapacityForOpportunisticUsageKey.value; - - late final ffi.Pointer _kCFURLVolumeResourceCountKey = - _lookup('kCFURLVolumeResourceCountKey'); - - CFStringRef get kCFURLVolumeResourceCountKey => - _kCFURLVolumeResourceCountKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsPersistentIDsKey = - _lookup('kCFURLVolumeSupportsPersistentIDsKey'); - - CFStringRef get kCFURLVolumeSupportsPersistentIDsKey => - _kCFURLVolumeSupportsPersistentIDsKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsSymbolicLinksKey = - _lookup('kCFURLVolumeSupportsSymbolicLinksKey'); - - CFStringRef get kCFURLVolumeSupportsSymbolicLinksKey => - _kCFURLVolumeSupportsSymbolicLinksKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsHardLinksKey = - _lookup('kCFURLVolumeSupportsHardLinksKey'); - - CFStringRef get kCFURLVolumeSupportsHardLinksKey => - _kCFURLVolumeSupportsHardLinksKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsJournalingKey = - _lookup('kCFURLVolumeSupportsJournalingKey'); - - CFStringRef get kCFURLVolumeSupportsJournalingKey => - _kCFURLVolumeSupportsJournalingKey.value; - - late final ffi.Pointer _kCFURLVolumeIsJournalingKey = - _lookup('kCFURLVolumeIsJournalingKey'); - - CFStringRef get kCFURLVolumeIsJournalingKey => - _kCFURLVolumeIsJournalingKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsSparseFilesKey = - _lookup('kCFURLVolumeSupportsSparseFilesKey'); - - CFStringRef get kCFURLVolumeSupportsSparseFilesKey => - _kCFURLVolumeSupportsSparseFilesKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsZeroRunsKey = - _lookup('kCFURLVolumeSupportsZeroRunsKey'); - - CFStringRef get kCFURLVolumeSupportsZeroRunsKey => - _kCFURLVolumeSupportsZeroRunsKey.value; - - late final ffi.Pointer - _kCFURLVolumeSupportsCaseSensitiveNamesKey = _lookup( - 'kCFURLVolumeSupportsCaseSensitiveNamesKey', - ); - - CFStringRef get kCFURLVolumeSupportsCaseSensitiveNamesKey => - _kCFURLVolumeSupportsCaseSensitiveNamesKey.value; - - late final ffi.Pointer - _kCFURLVolumeSupportsCasePreservedNamesKey = _lookup( - 'kCFURLVolumeSupportsCasePreservedNamesKey', - ); - - CFStringRef get kCFURLVolumeSupportsCasePreservedNamesKey => - _kCFURLVolumeSupportsCasePreservedNamesKey.value; - - late final ffi.Pointer - _kCFURLVolumeSupportsRootDirectoryDatesKey = _lookup( - 'kCFURLVolumeSupportsRootDirectoryDatesKey', - ); - - CFStringRef get kCFURLVolumeSupportsRootDirectoryDatesKey => - _kCFURLVolumeSupportsRootDirectoryDatesKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsVolumeSizesKey = - _lookup('kCFURLVolumeSupportsVolumeSizesKey'); - - CFStringRef get kCFURLVolumeSupportsVolumeSizesKey => - _kCFURLVolumeSupportsVolumeSizesKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsRenamingKey = - _lookup('kCFURLVolumeSupportsRenamingKey'); - - CFStringRef get kCFURLVolumeSupportsRenamingKey => - _kCFURLVolumeSupportsRenamingKey.value; - - late final ffi.Pointer - _kCFURLVolumeSupportsAdvisoryFileLockingKey = _lookup( - 'kCFURLVolumeSupportsAdvisoryFileLockingKey', - ); - - CFStringRef get kCFURLVolumeSupportsAdvisoryFileLockingKey => - _kCFURLVolumeSupportsAdvisoryFileLockingKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsExtendedSecurityKey = - _lookup('kCFURLVolumeSupportsExtendedSecurityKey'); - - CFStringRef get kCFURLVolumeSupportsExtendedSecurityKey => - _kCFURLVolumeSupportsExtendedSecurityKey.value; - - late final ffi.Pointer _kCFURLVolumeIsBrowsableKey = - _lookup('kCFURLVolumeIsBrowsableKey'); - - CFStringRef get kCFURLVolumeIsBrowsableKey => - _kCFURLVolumeIsBrowsableKey.value; - - late final ffi.Pointer _kCFURLVolumeMaximumFileSizeKey = - _lookup('kCFURLVolumeMaximumFileSizeKey'); - - CFStringRef get kCFURLVolumeMaximumFileSizeKey => - _kCFURLVolumeMaximumFileSizeKey.value; - - late final ffi.Pointer _kCFURLVolumeIsEjectableKey = - _lookup('kCFURLVolumeIsEjectableKey'); - - CFStringRef get kCFURLVolumeIsEjectableKey => - _kCFURLVolumeIsEjectableKey.value; - - late final ffi.Pointer _kCFURLVolumeIsRemovableKey = - _lookup('kCFURLVolumeIsRemovableKey'); - - CFStringRef get kCFURLVolumeIsRemovableKey => - _kCFURLVolumeIsRemovableKey.value; - - late final ffi.Pointer _kCFURLVolumeIsInternalKey = - _lookup('kCFURLVolumeIsInternalKey'); - - CFStringRef get kCFURLVolumeIsInternalKey => _kCFURLVolumeIsInternalKey.value; - - late final ffi.Pointer _kCFURLVolumeIsAutomountedKey = - _lookup('kCFURLVolumeIsAutomountedKey'); - - CFStringRef get kCFURLVolumeIsAutomountedKey => - _kCFURLVolumeIsAutomountedKey.value; - - late final ffi.Pointer _kCFURLVolumeIsLocalKey = - _lookup('kCFURLVolumeIsLocalKey'); - - CFStringRef get kCFURLVolumeIsLocalKey => _kCFURLVolumeIsLocalKey.value; - - late final ffi.Pointer _kCFURLVolumeIsReadOnlyKey = - _lookup('kCFURLVolumeIsReadOnlyKey'); - - CFStringRef get kCFURLVolumeIsReadOnlyKey => _kCFURLVolumeIsReadOnlyKey.value; - - late final ffi.Pointer _kCFURLVolumeCreationDateKey = - _lookup('kCFURLVolumeCreationDateKey'); - - CFStringRef get kCFURLVolumeCreationDateKey => - _kCFURLVolumeCreationDateKey.value; - - late final ffi.Pointer _kCFURLVolumeURLForRemountingKey = - _lookup('kCFURLVolumeURLForRemountingKey'); - - CFStringRef get kCFURLVolumeURLForRemountingKey => - _kCFURLVolumeURLForRemountingKey.value; - - late final ffi.Pointer _kCFURLVolumeUUIDStringKey = - _lookup('kCFURLVolumeUUIDStringKey'); - - CFStringRef get kCFURLVolumeUUIDStringKey => _kCFURLVolumeUUIDStringKey.value; - - late final ffi.Pointer _kCFURLVolumeNameKey = - _lookup('kCFURLVolumeNameKey'); - - CFStringRef get kCFURLVolumeNameKey => _kCFURLVolumeNameKey.value; - - late final ffi.Pointer _kCFURLVolumeLocalizedNameKey = - _lookup('kCFURLVolumeLocalizedNameKey'); - - CFStringRef get kCFURLVolumeLocalizedNameKey => - _kCFURLVolumeLocalizedNameKey.value; - - late final ffi.Pointer _kCFURLVolumeIsEncryptedKey = - _lookup('kCFURLVolumeIsEncryptedKey'); - - CFStringRef get kCFURLVolumeIsEncryptedKey => - _kCFURLVolumeIsEncryptedKey.value; - - late final ffi.Pointer _kCFURLVolumeIsRootFileSystemKey = - _lookup('kCFURLVolumeIsRootFileSystemKey'); - - CFStringRef get kCFURLVolumeIsRootFileSystemKey => - _kCFURLVolumeIsRootFileSystemKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsCompressionKey = - _lookup('kCFURLVolumeSupportsCompressionKey'); - - CFStringRef get kCFURLVolumeSupportsCompressionKey => - _kCFURLVolumeSupportsCompressionKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsFileCloningKey = - _lookup('kCFURLVolumeSupportsFileCloningKey'); - - CFStringRef get kCFURLVolumeSupportsFileCloningKey => - _kCFURLVolumeSupportsFileCloningKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsSwapRenamingKey = - _lookup('kCFURLVolumeSupportsSwapRenamingKey'); - - CFStringRef get kCFURLVolumeSupportsSwapRenamingKey => - _kCFURLVolumeSupportsSwapRenamingKey.value; - - late final ffi.Pointer - _kCFURLVolumeSupportsExclusiveRenamingKey = _lookup( - 'kCFURLVolumeSupportsExclusiveRenamingKey', - ); - - CFStringRef get kCFURLVolumeSupportsExclusiveRenamingKey => - _kCFURLVolumeSupportsExclusiveRenamingKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsImmutableFilesKey = - _lookup('kCFURLVolumeSupportsImmutableFilesKey'); - - CFStringRef get kCFURLVolumeSupportsImmutableFilesKey => - _kCFURLVolumeSupportsImmutableFilesKey.value; - - late final ffi.Pointer - _kCFURLVolumeSupportsAccessPermissionsKey = _lookup( - 'kCFURLVolumeSupportsAccessPermissionsKey', - ); - - CFStringRef get kCFURLVolumeSupportsAccessPermissionsKey => - _kCFURLVolumeSupportsAccessPermissionsKey.value; - - late final ffi.Pointer _kCFURLVolumeSupportsFileProtectionKey = - _lookup('kCFURLVolumeSupportsFileProtectionKey'); - - CFStringRef get kCFURLVolumeSupportsFileProtectionKey => - _kCFURLVolumeSupportsFileProtectionKey.value; - - late final ffi.Pointer _kCFURLVolumeTypeNameKey = - _lookup('kCFURLVolumeTypeNameKey'); - - CFStringRef get kCFURLVolumeTypeNameKey => _kCFURLVolumeTypeNameKey.value; - - late final ffi.Pointer _kCFURLVolumeSubtypeKey = - _lookup('kCFURLVolumeSubtypeKey'); - - CFStringRef get kCFURLVolumeSubtypeKey => _kCFURLVolumeSubtypeKey.value; - - late final ffi.Pointer _kCFURLVolumeMountFromLocationKey = - _lookup('kCFURLVolumeMountFromLocationKey'); - - CFStringRef get kCFURLVolumeMountFromLocationKey => - _kCFURLVolumeMountFromLocationKey.value; - - late final ffi.Pointer _kCFURLIsUbiquitousItemKey = - _lookup('kCFURLIsUbiquitousItemKey'); - - CFStringRef get kCFURLIsUbiquitousItemKey => _kCFURLIsUbiquitousItemKey.value; - - late final ffi.Pointer - _kCFURLUbiquitousItemHasUnresolvedConflictsKey = _lookup( - 'kCFURLUbiquitousItemHasUnresolvedConflictsKey', - ); - - CFStringRef get kCFURLUbiquitousItemHasUnresolvedConflictsKey => - _kCFURLUbiquitousItemHasUnresolvedConflictsKey.value; - - late final ffi.Pointer _kCFURLUbiquitousItemIsDownloadedKey = - _lookup('kCFURLUbiquitousItemIsDownloadedKey'); - - CFStringRef get kCFURLUbiquitousItemIsDownloadedKey => - _kCFURLUbiquitousItemIsDownloadedKey.value; - - late final ffi.Pointer _kCFURLUbiquitousItemIsDownloadingKey = - _lookup('kCFURLUbiquitousItemIsDownloadingKey'); - - CFStringRef get kCFURLUbiquitousItemIsDownloadingKey => - _kCFURLUbiquitousItemIsDownloadingKey.value; - - late final ffi.Pointer _kCFURLUbiquitousItemIsUploadedKey = - _lookup('kCFURLUbiquitousItemIsUploadedKey'); - - CFStringRef get kCFURLUbiquitousItemIsUploadedKey => - _kCFURLUbiquitousItemIsUploadedKey.value; - - late final ffi.Pointer _kCFURLUbiquitousItemIsUploadingKey = - _lookup('kCFURLUbiquitousItemIsUploadingKey'); - - CFStringRef get kCFURLUbiquitousItemIsUploadingKey => - _kCFURLUbiquitousItemIsUploadingKey.value; - - late final ffi.Pointer - _kCFURLUbiquitousItemPercentDownloadedKey = _lookup( - 'kCFURLUbiquitousItemPercentDownloadedKey', - ); - - CFStringRef get kCFURLUbiquitousItemPercentDownloadedKey => - _kCFURLUbiquitousItemPercentDownloadedKey.value; - - late final ffi.Pointer _kCFURLUbiquitousItemPercentUploadedKey = - _lookup('kCFURLUbiquitousItemPercentUploadedKey'); - - CFStringRef get kCFURLUbiquitousItemPercentUploadedKey => - _kCFURLUbiquitousItemPercentUploadedKey.value; - - late final ffi.Pointer - _kCFURLUbiquitousItemDownloadingStatusKey = _lookup( - 'kCFURLUbiquitousItemDownloadingStatusKey', - ); - - CFStringRef get kCFURLUbiquitousItemDownloadingStatusKey => - _kCFURLUbiquitousItemDownloadingStatusKey.value; - - late final ffi.Pointer _kCFURLUbiquitousItemDownloadingErrorKey = - _lookup('kCFURLUbiquitousItemDownloadingErrorKey'); - - CFStringRef get kCFURLUbiquitousItemDownloadingErrorKey => - _kCFURLUbiquitousItemDownloadingErrorKey.value; - - late final ffi.Pointer _kCFURLUbiquitousItemUploadingErrorKey = - _lookup('kCFURLUbiquitousItemUploadingErrorKey'); - - CFStringRef get kCFURLUbiquitousItemUploadingErrorKey => - _kCFURLUbiquitousItemUploadingErrorKey.value; - - late final ffi.Pointer - _kCFURLUbiquitousItemIsExcludedFromSyncKey = _lookup( - 'kCFURLUbiquitousItemIsExcludedFromSyncKey', - ); - - CFStringRef get kCFURLUbiquitousItemIsExcludedFromSyncKey => - _kCFURLUbiquitousItemIsExcludedFromSyncKey.value; - - late final ffi.Pointer - _kCFURLUbiquitousItemDownloadingStatusNotDownloaded = _lookup( - 'kCFURLUbiquitousItemDownloadingStatusNotDownloaded', - ); - - CFStringRef get kCFURLUbiquitousItemDownloadingStatusNotDownloaded => - _kCFURLUbiquitousItemDownloadingStatusNotDownloaded.value; +late final _sel_URLSession_taskIsWaitingForConnectivity_ = objc.registerName( + "URLSession:taskIsWaitingForConnectivity:", +); - late final ffi.Pointer - _kCFURLUbiquitousItemDownloadingStatusDownloaded = _lookup( - 'kCFURLUbiquitousItemDownloadingStatusDownloaded', +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSURLRequest { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, ); - CFStringRef get kCFURLUbiquitousItemDownloadingStatusDownloaded => - _kCFURLUbiquitousItemDownloadingStatusDownloaded.value; - - late final ffi.Pointer - _kCFURLUbiquitousItemDownloadingStatusCurrent = _lookup( - 'kCFURLUbiquitousItemDownloadingStatusCurrent', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - CFStringRef get kCFURLUbiquitousItemDownloadingStatusCurrent => - _kCFURLUbiquitousItemDownloadingStatusCurrent.value; - - late final ffi.Pointer - _kCFURLUbiquitousItemSupportedSyncControlsKey = _lookup( - 'kCFURLUbiquitousItemSupportedSyncControlsKey', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(NSURLRequest?) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : NSURLRequest.fromPointer(arg0, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - CFStringRef get kCFURLUbiquitousItemSupportedSyncControlsKey => - _kCFURLUbiquitousItemSupportedSyncControlsKey.value; - - late final ffi.Pointer _kCFURLUbiquitousItemIsSyncPausedKey = - _lookup('kCFURLUbiquitousItemIsSyncPausedKey'); - - CFStringRef get kCFURLUbiquitousItemIsSyncPausedKey => - _kCFURLUbiquitousItemIsSyncPausedKey.value; - - CFDataRef CFURLCreateBookmarkData( - CFAllocatorRef allocator, - CFURLRef url, - int options, - CFArrayRef resourcePropertiesToInclude, - CFURLRef relativeToURL, - ffi.Pointer error, - ) { - return _CFURLCreateBookmarkData( - allocator, - url, - options, - resourcePropertiesToInclude, - relativeToURL, - error, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(NSURLRequest?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : NSURLRequest.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, ); - } - - late final _CFURLCreateBookmarkDataPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function( - CFAllocatorRef, - CFURLRef, - CFOptionFlags, - CFArrayRef, - CFURLRef, - ffi.Pointer, - ) - > - >('CFURLCreateBookmarkData'); - late final _CFURLCreateBookmarkData = - _CFURLCreateBookmarkDataPtr.asFunction< - CFDataRef Function( - CFAllocatorRef, - CFURLRef, - int, - CFArrayRef, - CFURLRef, - ffi.Pointer, - ) - >(); - - CFURLRef CFURLCreateByResolvingBookmarkData( - CFAllocatorRef allocator, - CFDataRef bookmark, - int options, - CFURLRef relativeToURL, - CFArrayRef resourcePropertiesToInclude, - ffi.Pointer isStale, - ffi.Pointer error, - ) { - return _CFURLCreateByResolvingBookmarkData( - allocator, - bookmark, - options, - relativeToURL, - resourcePropertiesToInclude, - isStale, - error, + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, ); } - late final _CFURLCreateByResolvingBookmarkDataPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function( - CFAllocatorRef, - CFDataRef, - CFOptionFlags, - CFURLRef, - CFArrayRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFURLCreateByResolvingBookmarkData'); - late final _CFURLCreateByResolvingBookmarkData = - _CFURLCreateByResolvingBookmarkDataPtr.asFunction< - CFURLRef Function( - CFAllocatorRef, - CFDataRef, - int, - CFURLRef, - CFArrayRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFDictionaryRef CFURLCreateResourcePropertiesForKeysFromBookmarkData( - CFAllocatorRef allocator, - CFArrayRef resourcePropertiesToReturn, - CFDataRef bookmark, - ) { - return _CFURLCreateResourcePropertiesForKeysFromBookmarkData( - allocator, - resourcePropertiesToReturn, - bookmark, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(NSURLRequest?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : NSURLRequest.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : NSURLRequest.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, ); } - late final _CFURLCreateResourcePropertiesForKeysFromBookmarkDataPtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function(CFAllocatorRef, CFArrayRef, CFDataRef) - > - >('CFURLCreateResourcePropertiesForKeysFromBookmarkData'); - late final _CFURLCreateResourcePropertiesForKeysFromBookmarkData = - _CFURLCreateResourcePropertiesForKeysFromBookmarkDataPtr.asFunction< - CFDictionaryRef Function(CFAllocatorRef, CFArrayRef, CFDataRef) - >(); - - CFTypeRef CFURLCreateResourcePropertyForKeyFromBookmarkData( - CFAllocatorRef allocator, - CFStringRef resourcePropertyKey, - CFDataRef bookmark, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, ) { - return _CFURLCreateResourcePropertyForKeyFromBookmarkData( - allocator, - resourcePropertyKey, - bookmark, - ); + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); } - late final _CFURLCreateResourcePropertyForKeyFromBookmarkDataPtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function(CFAllocatorRef, CFStringRef, CFDataRef) - > - >('CFURLCreateResourcePropertyForKeyFromBookmarkData'); - late final _CFURLCreateResourcePropertyForKeyFromBookmarkData = - _CFURLCreateResourcePropertyForKeyFromBookmarkDataPtr.asFunction< - CFTypeRef Function(CFAllocatorRef, CFStringRef, CFDataRef) - >(); - - CFDataRef CFURLCreateBookmarkDataFromFile( - CFAllocatorRef allocator, - CFURLRef fileURL, - ffi.Pointer errorRef, - ) { - return _CFURLCreateBookmarkDataFromFile(allocator, fileURL, errorRef); - } - - late final _CFURLCreateBookmarkDataFromFilePtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function(CFAllocatorRef, CFURLRef, ffi.Pointer) - > - >('CFURLCreateBookmarkDataFromFile'); - late final _CFURLCreateBookmarkDataFromFile = - _CFURLCreateBookmarkDataFromFilePtr.asFunction< - CFDataRef Function(CFAllocatorRef, CFURLRef, ffi.Pointer) - >(); - - int CFURLWriteBookmarkDataToFile( - CFDataRef bookmarkRef, - CFURLRef fileURL, - int options, - ffi.Pointer errorRef, - ) { - return _CFURLWriteBookmarkDataToFile( - bookmarkRef, - fileURL, - options, - errorRef, - ); - } - - late final _CFURLWriteBookmarkDataToFilePtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFDataRef, - CFURLRef, - CFURLBookmarkFileCreationOptions, - ffi.Pointer, - ) - > - >('CFURLWriteBookmarkDataToFile'); - late final _CFURLWriteBookmarkDataToFile = - _CFURLWriteBookmarkDataToFilePtr.asFunction< - int Function(CFDataRef, CFURLRef, int, ffi.Pointer) - >(); - - CFDataRef CFURLCreateBookmarkDataFromAliasRecord( - CFAllocatorRef allocatorRef, - CFDataRef aliasRecordDataRef, - ) { - return _CFURLCreateBookmarkDataFromAliasRecord( - allocatorRef, - aliasRecordDataRef, - ); - } - - late final _CFURLCreateBookmarkDataFromAliasRecordPtr = - _lookup< - ffi.NativeFunction - >('CFURLCreateBookmarkDataFromAliasRecord'); - late final _CFURLCreateBookmarkDataFromAliasRecord = - _CFURLCreateBookmarkDataFromAliasRecordPtr.asFunction< - CFDataRef Function(CFAllocatorRef, CFDataRef) - >(); - - int CFURLStartAccessingSecurityScopedResource(CFURLRef url) { - return _CFURLStartAccessingSecurityScopedResource(url); - } - - late final _CFURLStartAccessingSecurityScopedResourcePtr = - _lookup>( - 'CFURLStartAccessingSecurityScopedResource', - ); - late final _CFURLStartAccessingSecurityScopedResource = - _CFURLStartAccessingSecurityScopedResourcePtr.asFunction< - int Function(CFURLRef) - >(); - - void CFURLStopAccessingSecurityScopedResource(CFURLRef url) { - return _CFURLStopAccessingSecurityScopedResource(url); - } - - late final _CFURLStopAccessingSecurityScopedResourcePtr = - _lookup>( - 'CFURLStopAccessingSecurityScopedResource', - ); - late final _CFURLStopAccessingSecurityScopedResource = - _CFURLStopAccessingSecurityScopedResourcePtr.asFunction< - void Function(CFURLRef) - >(); - - late final ffi.Pointer _kCFRunLoopDefaultMode = - _lookup('kCFRunLoopDefaultMode'); - - CFRunLoopMode get kCFRunLoopDefaultMode => _kCFRunLoopDefaultMode.value; - - late final ffi.Pointer _kCFRunLoopCommonModes = - _lookup('kCFRunLoopCommonModes'); - - CFRunLoopMode get kCFRunLoopCommonModes => _kCFRunLoopCommonModes.value; - - int CFRunLoopGetTypeID() { - return _CFRunLoopGetTypeID(); - } - - late final _CFRunLoopGetTypeIDPtr = - _lookup>('CFRunLoopGetTypeID'); - late final _CFRunLoopGetTypeID = - _CFRunLoopGetTypeIDPtr.asFunction(); - - CFRunLoopRef CFRunLoopGetCurrent() { - return _CFRunLoopGetCurrent(); - } - - late final _CFRunLoopGetCurrentPtr = - _lookup>( - 'CFRunLoopGetCurrent', - ); - late final _CFRunLoopGetCurrent = - _CFRunLoopGetCurrentPtr.asFunction(); - - CFRunLoopRef CFRunLoopGetMain() { - return _CFRunLoopGetMain(); - } - - late final _CFRunLoopGetMainPtr = - _lookup>('CFRunLoopGetMain'); - late final _CFRunLoopGetMain = - _CFRunLoopGetMainPtr.asFunction(); - - CFRunLoopMode CFRunLoopCopyCurrentMode(CFRunLoopRef rl) { - return _CFRunLoopCopyCurrentMode(rl); - } - - late final _CFRunLoopCopyCurrentModePtr = - _lookup>( - 'CFRunLoopCopyCurrentMode', - ); - late final _CFRunLoopCopyCurrentMode = - _CFRunLoopCopyCurrentModePtr.asFunction< - CFRunLoopMode Function(CFRunLoopRef) - >(); - - CFArrayRef CFRunLoopCopyAllModes(CFRunLoopRef rl) { - return _CFRunLoopCopyAllModes(rl); - } - - late final _CFRunLoopCopyAllModesPtr = - _lookup>( - 'CFRunLoopCopyAllModes', - ); - late final _CFRunLoopCopyAllModes = - _CFRunLoopCopyAllModesPtr.asFunction(); - - void CFRunLoopAddCommonMode(CFRunLoopRef rl, CFRunLoopMode mode) { - return _CFRunLoopAddCommonMode(rl, mode); - } - - late final _CFRunLoopAddCommonModePtr = - _lookup< - ffi.NativeFunction - >('CFRunLoopAddCommonMode'); - late final _CFRunLoopAddCommonMode = - _CFRunLoopAddCommonModePtr.asFunction< - void Function(CFRunLoopRef, CFRunLoopMode) - >(); - - double CFRunLoopGetNextTimerFireDate(CFRunLoopRef rl, CFRunLoopMode mode) { - return _CFRunLoopGetNextTimerFireDate(rl, mode); - } - - late final _CFRunLoopGetNextTimerFireDatePtr = - _lookup< - ffi.NativeFunction - >('CFRunLoopGetNextTimerFireDate'); - late final _CFRunLoopGetNextTimerFireDate = - _CFRunLoopGetNextTimerFireDatePtr.asFunction< - double Function(CFRunLoopRef, CFRunLoopMode) - >(); - - void CFRunLoopRun() { - return _CFRunLoopRun(); - } - - late final _CFRunLoopRunPtr = - _lookup>('CFRunLoopRun'); - late final _CFRunLoopRun = _CFRunLoopRunPtr.asFunction(); - - CFRunLoopRunResult CFRunLoopRunInMode( - CFRunLoopMode mode, - DartCFTimeInterval seconds, - DartBoolean returnAfterSourceHandled, - ) { - return CFRunLoopRunResult.fromValue( - _CFRunLoopRunInMode(mode, seconds, returnAfterSourceHandled), - ); - } - - late final _CFRunLoopRunInModePtr = - _lookup< - ffi.NativeFunction< - SInt32 Function(CFRunLoopMode, CFTimeInterval, Boolean) - > - >('CFRunLoopRunInMode'); - late final _CFRunLoopRunInMode = - _CFRunLoopRunInModePtr.asFunction< - int Function(CFRunLoopMode, double, int) - >(); - - int CFRunLoopIsWaiting(CFRunLoopRef rl) { - return _CFRunLoopIsWaiting(rl); - } - - late final _CFRunLoopIsWaitingPtr = - _lookup>( - 'CFRunLoopIsWaiting', - ); - late final _CFRunLoopIsWaiting = - _CFRunLoopIsWaitingPtr.asFunction(); - - void CFRunLoopWakeUp(CFRunLoopRef rl) { - return _CFRunLoopWakeUp(rl); - } - - late final _CFRunLoopWakeUpPtr = - _lookup>( - 'CFRunLoopWakeUp', - ); - late final _CFRunLoopWakeUp = - _CFRunLoopWakeUpPtr.asFunction(); - - void CFRunLoopStop(CFRunLoopRef rl) { - return _CFRunLoopStop(rl); - } - - late final _CFRunLoopStopPtr = - _lookup>( - 'CFRunLoopStop', - ); - late final _CFRunLoopStop = - _CFRunLoopStopPtr.asFunction(); - - void CFRunLoopPerformBlock( - CFRunLoopRef rl, - CFTypeRef mode, - objc.ObjCBlock block, - ) { - return _CFRunLoopPerformBlock(rl, mode, block.ref.pointer); - } - - late final _CFRunLoopPerformBlockPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< ffi.Void Function( - CFRunLoopRef, - CFTypeRef, ffi.Pointer, + ffi.Pointer, ) - > - >('CFRunLoopPerformBlock'); - late final _CFRunLoopPerformBlock = - _CFRunLoopPerformBlockPtr.asFunction< - void Function(CFRunLoopRef, CFTypeRef, ffi.Pointer) - >(); - - int CFRunLoopContainsSource( - CFRunLoopRef rl, - CFRunLoopSourceRef source, - CFRunLoopMode mode, - ) { - return _CFRunLoopContainsSource(rl, source, mode); - } - - late final _CFRunLoopContainsSourcePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFRunLoopRef, CFRunLoopSourceRef, CFRunLoopMode) - > - >('CFRunLoopContainsSource'); - late final _CFRunLoopContainsSource = - _CFRunLoopContainsSourcePtr.asFunction< - int Function(CFRunLoopRef, CFRunLoopSourceRef, CFRunLoopMode) - >(); - - void CFRunLoopAddSource( - CFRunLoopRef rl, - CFRunLoopSourceRef source, - CFRunLoopMode mode, - ) { - return _CFRunLoopAddSource(rl, source, mode); - } - - late final _CFRunLoopAddSourcePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFRunLoopRef, CFRunLoopSourceRef, CFRunLoopMode) - > - >('CFRunLoopAddSource'); - late final _CFRunLoopAddSource = - _CFRunLoopAddSourcePtr.asFunction< - void Function(CFRunLoopRef, CFRunLoopSourceRef, CFRunLoopMode) - >(); - - void CFRunLoopRemoveSource( - CFRunLoopRef rl, - CFRunLoopSourceRef source, - CFRunLoopMode mode, - ) { - return _CFRunLoopRemoveSource(rl, source, mode); - } - - late final _CFRunLoopRemoveSourcePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFRunLoopRef, CFRunLoopSourceRef, CFRunLoopMode) - > - >('CFRunLoopRemoveSource'); - late final _CFRunLoopRemoveSource = - _CFRunLoopRemoveSourcePtr.asFunction< - void Function(CFRunLoopRef, CFRunLoopSourceRef, CFRunLoopMode) - >(); - - int CFRunLoopContainsObserver( - CFRunLoopRef rl, - CFRunLoopObserverRef observer, - CFRunLoopMode mode, - ) { - return _CFRunLoopContainsObserver(rl, observer, mode); - } - - late final _CFRunLoopContainsObserverPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFRunLoopRef, CFRunLoopObserverRef, CFRunLoopMode) - > - >('CFRunLoopContainsObserver'); - late final _CFRunLoopContainsObserver = - _CFRunLoopContainsObserverPtr.asFunction< - int Function(CFRunLoopRef, CFRunLoopObserverRef, CFRunLoopMode) - >(); - - void CFRunLoopAddObserver( - CFRunLoopRef rl, - CFRunLoopObserverRef observer, - CFRunLoopMode mode, - ) { - return _CFRunLoopAddObserver(rl, observer, mode); - } - - late final _CFRunLoopAddObserverPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFRunLoopRef, CFRunLoopObserverRef, CFRunLoopMode) - > - >('CFRunLoopAddObserver'); - late final _CFRunLoopAddObserver = - _CFRunLoopAddObserverPtr.asFunction< - void Function(CFRunLoopRef, CFRunLoopObserverRef, CFRunLoopMode) - >(); - - void CFRunLoopRemoveObserver( - CFRunLoopRef rl, - CFRunLoopObserverRef observer, - CFRunLoopMode mode, - ) { - return _CFRunLoopRemoveObserver(rl, observer, mode); - } - - late final _CFRunLoopRemoveObserverPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFRunLoopRef, CFRunLoopObserverRef, CFRunLoopMode) - > - >('CFRunLoopRemoveObserver'); - late final _CFRunLoopRemoveObserver = - _CFRunLoopRemoveObserverPtr.asFunction< - void Function(CFRunLoopRef, CFRunLoopObserverRef, CFRunLoopMode) - >(); - - int CFRunLoopContainsTimer( - CFRunLoopRef rl, - CFRunLoopTimerRef timer, - CFRunLoopMode mode, - ) { - return _CFRunLoopContainsTimer(rl, timer, mode); - } - - late final _CFRunLoopContainsTimerPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFRunLoopRef, CFRunLoopTimerRef, CFRunLoopMode) - > - >('CFRunLoopContainsTimer'); - late final _CFRunLoopContainsTimer = - _CFRunLoopContainsTimerPtr.asFunction< - int Function(CFRunLoopRef, CFRunLoopTimerRef, CFRunLoopMode) - >(); - - void CFRunLoopAddTimer( - CFRunLoopRef rl, - CFRunLoopTimerRef timer, - CFRunLoopMode mode, - ) { - return _CFRunLoopAddTimer(rl, timer, mode); - } - - late final _CFRunLoopAddTimerPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFRunLoopRef, CFRunLoopTimerRef, CFRunLoopMode) - > - >('CFRunLoopAddTimer'); - late final _CFRunLoopAddTimer = - _CFRunLoopAddTimerPtr.asFunction< - void Function(CFRunLoopRef, CFRunLoopTimerRef, CFRunLoopMode) - >(); - - void CFRunLoopRemoveTimer( - CFRunLoopRef rl, - CFRunLoopTimerRef timer, - CFRunLoopMode mode, - ) { - return _CFRunLoopRemoveTimer(rl, timer, mode); - } - - late final _CFRunLoopRemoveTimerPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFRunLoopRef, CFRunLoopTimerRef, CFRunLoopMode) - > - >('CFRunLoopRemoveTimer'); - late final _CFRunLoopRemoveTimer = - _CFRunLoopRemoveTimerPtr.asFunction< - void Function(CFRunLoopRef, CFRunLoopTimerRef, CFRunLoopMode) - >(); - - int CFRunLoopSourceGetTypeID() { - return _CFRunLoopSourceGetTypeID(); - } - - late final _CFRunLoopSourceGetTypeIDPtr = - _lookup>( - 'CFRunLoopSourceGetTypeID', - ); - late final _CFRunLoopSourceGetTypeID = - _CFRunLoopSourceGetTypeIDPtr.asFunction(); - - CFRunLoopSourceRef CFRunLoopSourceCreate( - CFAllocatorRef allocator, - int order, - ffi.Pointer context, - ) { - return _CFRunLoopSourceCreate(allocator, order, context); - } - - late final _CFRunLoopSourceCreatePtr = - _lookup< - ffi.NativeFunction< - CFRunLoopSourceRef Function( - CFAllocatorRef, - CFIndex, - ffi.Pointer, - ) - > - >('CFRunLoopSourceCreate'); - late final _CFRunLoopSourceCreate = - _CFRunLoopSourceCreatePtr.asFunction< - CFRunLoopSourceRef Function( - CFAllocatorRef, - int, - ffi.Pointer, - ) - >(); - - int CFRunLoopSourceGetOrder(CFRunLoopSourceRef source) { - return _CFRunLoopSourceGetOrder(source); - } - - late final _CFRunLoopSourceGetOrderPtr = - _lookup>( - 'CFRunLoopSourceGetOrder', - ); - late final _CFRunLoopSourceGetOrder = - _CFRunLoopSourceGetOrderPtr.asFunction< - int Function(CFRunLoopSourceRef) - >(); - - void CFRunLoopSourceInvalidate(CFRunLoopSourceRef source) { - return _CFRunLoopSourceInvalidate(source); - } - - late final _CFRunLoopSourceInvalidatePtr = - _lookup>( - 'CFRunLoopSourceInvalidate', - ); - late final _CFRunLoopSourceInvalidate = - _CFRunLoopSourceInvalidatePtr.asFunction< - void Function(CFRunLoopSourceRef) - >(); - - int CFRunLoopSourceIsValid(CFRunLoopSourceRef source) { - return _CFRunLoopSourceIsValid(source); - } - - late final _CFRunLoopSourceIsValidPtr = - _lookup>( - 'CFRunLoopSourceIsValid', - ); - late final _CFRunLoopSourceIsValid = - _CFRunLoopSourceIsValidPtr.asFunction(); - - void CFRunLoopSourceGetContext( - CFRunLoopSourceRef source, - ffi.Pointer context, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, ) { - return _CFRunLoopSourceGetContext(source, context); + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFRunLoopSourceGetContextPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - CFRunLoopSourceRef, - ffi.Pointer, - ) - > - >('CFRunLoopSourceGetContext'); - late final _CFRunLoopSourceGetContext = - _CFRunLoopSourceGetContextPtr.asFunction< - void Function(CFRunLoopSourceRef, ffi.Pointer) - >(); - - void CFRunLoopSourceSignal(CFRunLoopSourceRef source) { - return _CFRunLoopSourceSignal(source); - } - - late final _CFRunLoopSourceSignalPtr = - _lookup>( - 'CFRunLoopSourceSignal', - ); - late final _CFRunLoopSourceSignal = - _CFRunLoopSourceSignalPtr.asFunction(); - - int CFRunLoopObserverGetTypeID() { - return _CFRunLoopObserverGetTypeID(); - } - - late final _CFRunLoopObserverGetTypeIDPtr = - _lookup>( - 'CFRunLoopObserverGetTypeID', - ); - late final _CFRunLoopObserverGetTypeID = - _CFRunLoopObserverGetTypeIDPtr.asFunction(); - - CFRunLoopObserverRef CFRunLoopObserverCreate( - CFAllocatorRef allocator, - int activities, - int repeats, - int order, - CFRunLoopObserverCallBack callout, - ffi.Pointer context, - ) { - return _CFRunLoopObserverCreate( - allocator, - activities, - repeats, - order, - callout, - context, - ); - } - - late final _CFRunLoopObserverCreatePtr = - _lookup< - ffi.NativeFunction< - CFRunLoopObserverRef Function( - CFAllocatorRef, - CFOptionFlags, - Boolean, - CFIndex, - CFRunLoopObserverCallBack, - ffi.Pointer, - ) - > - >('CFRunLoopObserverCreate'); - late final _CFRunLoopObserverCreate = - _CFRunLoopObserverCreatePtr.asFunction< - CFRunLoopObserverRef Function( - CFAllocatorRef, - int, - int, - int, - CFRunLoopObserverCallBack, - ffi.Pointer, - ) - >(); - - CFRunLoopObserverRef CFRunLoopObserverCreateWithHandler( - CFAllocatorRef allocator, - DartCFOptionFlags activities, - DartBoolean repeats, - DartCFIndex order, - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - > - block, - ) { - return _CFRunLoopObserverCreateWithHandler( - allocator, - activities, - repeats, - order, - block.ref.pointer, - ); - } - - late final _CFRunLoopObserverCreateWithHandlerPtr = - _lookup< - ffi.NativeFunction< - CFRunLoopObserverRef Function( - CFAllocatorRef, - CFOptionFlags, - Boolean, - CFIndex, ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFRunLoopObserverCreateWithHandler'); - late final _CFRunLoopObserverCreateWithHandler = - _CFRunLoopObserverCreateWithHandlerPtr.asFunction< - CFRunLoopObserverRef Function( - CFAllocatorRef, - int, - int, - int, - ffi.Pointer, - ) - >(); - - int CFRunLoopObserverGetActivities(CFRunLoopObserverRef observer) { - return _CFRunLoopObserverGetActivities(observer); - } - - late final _CFRunLoopObserverGetActivitiesPtr = - _lookup>( - 'CFRunLoopObserverGetActivities', - ); - late final _CFRunLoopObserverGetActivities = - _CFRunLoopObserverGetActivitiesPtr.asFunction< - int Function(CFRunLoopObserverRef) - >(); - - int CFRunLoopObserverDoesRepeat(CFRunLoopObserverRef observer) { - return _CFRunLoopObserverDoesRepeat(observer); - } - - late final _CFRunLoopObserverDoesRepeatPtr = - _lookup>( - 'CFRunLoopObserverDoesRepeat', - ); - late final _CFRunLoopObserverDoesRepeat = - _CFRunLoopObserverDoesRepeatPtr.asFunction< - int Function(CFRunLoopObserverRef) - >(); - - int CFRunLoopObserverGetOrder(CFRunLoopObserverRef observer) { - return _CFRunLoopObserverGetOrder(observer); - } - - late final _CFRunLoopObserverGetOrderPtr = - _lookup>( - 'CFRunLoopObserverGetOrder', - ); - late final _CFRunLoopObserverGetOrder = - _CFRunLoopObserverGetOrderPtr.asFunction< - int Function(CFRunLoopObserverRef) - >(); - - void CFRunLoopObserverInvalidate(CFRunLoopObserverRef observer) { - return _CFRunLoopObserverInvalidate(observer); - } - - late final _CFRunLoopObserverInvalidatePtr = - _lookup>( - 'CFRunLoopObserverInvalidate', - ); - late final _CFRunLoopObserverInvalidate = - _CFRunLoopObserverInvalidatePtr.asFunction< - void Function(CFRunLoopObserverRef) - >(); - - int CFRunLoopObserverIsValid(CFRunLoopObserverRef observer) { - return _CFRunLoopObserverIsValid(observer); - } - - late final _CFRunLoopObserverIsValidPtr = - _lookup>( - 'CFRunLoopObserverIsValid', - ); - late final _CFRunLoopObserverIsValid = - _CFRunLoopObserverIsValidPtr.asFunction< - int Function(CFRunLoopObserverRef) - >(); - - void CFRunLoopObserverGetContext( - CFRunLoopObserverRef observer, - ffi.Pointer context, - ) { - return _CFRunLoopObserverGetContext(observer, context); - } - - late final _CFRunLoopObserverGetContextPtr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( - CFRunLoopObserverRef, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFRunLoopObserverGetContext'); - late final _CFRunLoopObserverGetContext = - _CFRunLoopObserverGetContextPtr.asFunction< - void Function( - CFRunLoopObserverRef, - ffi.Pointer, - ) - >(); - - int CFRunLoopTimerGetTypeID() { - return _CFRunLoopTimerGetTypeID(); - } - - late final _CFRunLoopTimerGetTypeIDPtr = - _lookup>( - 'CFRunLoopTimerGetTypeID', - ); - late final _CFRunLoopTimerGetTypeID = - _CFRunLoopTimerGetTypeIDPtr.asFunction(); - - CFRunLoopTimerRef CFRunLoopTimerCreate( - CFAllocatorRef allocator, - double fireDate, - double interval, - int flags, - int order, - CFRunLoopTimerCallBack callout, - ffi.Pointer context, - ) { - return _CFRunLoopTimerCreate( - allocator, - fireDate, - interval, - flags, - order, - callout, - context, - ); - } - - late final _CFRunLoopTimerCreatePtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< ffi.NativeFunction< - CFRunLoopTimerRef Function( - CFAllocatorRef, - CFAbsoluteTime, - CFTimeInterval, - CFOptionFlags, - CFIndex, - CFRunLoopTimerCallBack, - ffi.Pointer, - ) + ffi.Void Function(ffi.Pointer arg0) > - >('CFRunLoopTimerCreate'); - late final _CFRunLoopTimerCreate = - _CFRunLoopTimerCreatePtr.asFunction< - CFRunLoopTimerRef Function( - CFAllocatorRef, - double, - double, - int, - int, - CFRunLoopTimerCallBack, - ffi.Pointer, - ) - >(); - - CFRunLoopTimerRef CFRunLoopTimerCreateWithHandler( - CFAllocatorRef allocator, - DartCFTimeInterval fireDate, - DartCFTimeInterval interval, - DartCFOptionFlags flags, - DartCFIndex order, - objc.ObjCBlock)> block, - ) { - return _CFRunLoopTimerCreateWithHandler( - allocator, - fireDate, - interval, - flags, - order, - block.ref.pointer, - ); - } + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFRunLoopTimerCreateWithHandlerPtr = - _lookup< +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLRequest$CallExtension + on objc.ObjCBlock { + void call(NSURLRequest? arg0) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< - CFRunLoopTimerRef Function( - CFAllocatorRef, - CFAbsoluteTime, - CFTimeInterval, - CFOptionFlags, - CFIndex, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, ) > - >('CFRunLoopTimerCreateWithHandler'); - late final _CFRunLoopTimerCreateWithHandler = - _CFRunLoopTimerCreateWithHandlerPtr.asFunction< - CFRunLoopTimerRef Function( - CFAllocatorRef, - double, - double, - int, - int, + >() + .asFunction< + void Function( ffi.Pointer, + ffi.Pointer, ) - >(); - - double CFRunLoopTimerGetNextFireDate(CFRunLoopTimerRef timer) { - return _CFRunLoopTimerGetNextFireDate(timer); - } - - late final _CFRunLoopTimerGetNextFireDatePtr = - _lookup>( - 'CFRunLoopTimerGetNextFireDate', - ); - late final _CFRunLoopTimerGetNextFireDate = - _CFRunLoopTimerGetNextFireDatePtr.asFunction< - double Function(CFRunLoopTimerRef) - >(); - - void CFRunLoopTimerSetNextFireDate(CFRunLoopTimerRef timer, double fireDate) { - return _CFRunLoopTimerSetNextFireDate(timer, fireDate); - } - - late final _CFRunLoopTimerSetNextFireDatePtr = - _lookup< - ffi.NativeFunction - >('CFRunLoopTimerSetNextFireDate'); - late final _CFRunLoopTimerSetNextFireDate = - _CFRunLoopTimerSetNextFireDatePtr.asFunction< - void Function(CFRunLoopTimerRef, double) - >(); - - double CFRunLoopTimerGetInterval(CFRunLoopTimerRef timer) { - return _CFRunLoopTimerGetInterval(timer); - } - - late final _CFRunLoopTimerGetIntervalPtr = - _lookup>( - 'CFRunLoopTimerGetInterval', - ); - late final _CFRunLoopTimerGetInterval = - _CFRunLoopTimerGetIntervalPtr.asFunction< - double Function(CFRunLoopTimerRef) - >(); - - int CFRunLoopTimerDoesRepeat(CFRunLoopTimerRef timer) { - return _CFRunLoopTimerDoesRepeat(timer); - } - - late final _CFRunLoopTimerDoesRepeatPtr = - _lookup>( - 'CFRunLoopTimerDoesRepeat', - ); - late final _CFRunLoopTimerDoesRepeat = - _CFRunLoopTimerDoesRepeatPtr.asFunction< - int Function(CFRunLoopTimerRef) - >(); - - int CFRunLoopTimerGetOrder(CFRunLoopTimerRef timer) { - return _CFRunLoopTimerGetOrder(timer); - } - - late final _CFRunLoopTimerGetOrderPtr = - _lookup>( - 'CFRunLoopTimerGetOrder', - ); - late final _CFRunLoopTimerGetOrder = - _CFRunLoopTimerGetOrderPtr.asFunction(); - - void CFRunLoopTimerInvalidate(CFRunLoopTimerRef timer) { - return _CFRunLoopTimerInvalidate(timer); - } - - late final _CFRunLoopTimerInvalidatePtr = - _lookup>( - 'CFRunLoopTimerInvalidate', - ); - late final _CFRunLoopTimerInvalidate = - _CFRunLoopTimerInvalidatePtr.asFunction< - void Function(CFRunLoopTimerRef) - >(); - - int CFRunLoopTimerIsValid(CFRunLoopTimerRef timer) { - return _CFRunLoopTimerIsValid(timer); - } - - late final _CFRunLoopTimerIsValidPtr = - _lookup>( - 'CFRunLoopTimerIsValid', - ); - late final _CFRunLoopTimerIsValid = - _CFRunLoopTimerIsValidPtr.asFunction(); - - void CFRunLoopTimerGetContext( - CFRunLoopTimerRef timer, - ffi.Pointer context, - ) { - return _CFRunLoopTimerGetContext(timer, context); - } - - late final _CFRunLoopTimerGetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFRunLoopTimerRef, - ffi.Pointer, - ) - > - >('CFRunLoopTimerGetContext'); - late final _CFRunLoopTimerGetContext = - _CFRunLoopTimerGetContextPtr.asFunction< - void Function(CFRunLoopTimerRef, ffi.Pointer) - >(); - - double CFRunLoopTimerGetTolerance(CFRunLoopTimerRef timer) { - return _CFRunLoopTimerGetTolerance(timer); - } + >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); +} - late final _CFRunLoopTimerGetTolerancePtr = - _lookup>( - 'CFRunLoopTimerGetTolerance', - ); - late final _CFRunLoopTimerGetTolerance = - _CFRunLoopTimerGetTolerancePtr.asFunction< - double Function(CFRunLoopTimerRef) - >(); - - void CFRunLoopTimerSetTolerance(CFRunLoopTimerRef timer, double tolerance) { - return _CFRunLoopTimerSetTolerance(timer, tolerance); - } - - late final _CFRunLoopTimerSetTolerancePtr = - _lookup< - ffi.NativeFunction - >('CFRunLoopTimerSetTolerance'); - late final _CFRunLoopTimerSetTolerance = - _CFRunLoopTimerSetTolerancePtr.asFunction< - void Function(CFRunLoopTimerRef, double) - >(); - - int CFSocketGetTypeID() { - return _CFSocketGetTypeID(); - } - - late final _CFSocketGetTypeIDPtr = - _lookup>('CFSocketGetTypeID'); - late final _CFSocketGetTypeID = - _CFSocketGetTypeIDPtr.asFunction(); - - CFSocketRef CFSocketCreate( - CFAllocatorRef allocator, - int protocolFamily, - int socketType, - int protocol, - int callBackTypes, - CFSocketCallBack callout, - ffi.Pointer context, - ) { - return _CFSocketCreate( - allocator, - protocolFamily, - socketType, - protocol, - callBackTypes, - callout, - context, +late final _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = + objc.registerName( + "URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:", ); - } - - late final _CFSocketCreatePtr = - _lookup< - ffi.NativeFunction< - CFSocketRef Function( - CFAllocatorRef, - SInt32, - SInt32, - SInt32, - CFOptionFlags, - CFSocketCallBack, - ffi.Pointer, - ) - > - >('CFSocketCreate'); - late final _CFSocketCreate = - _CFSocketCreatePtr.asFunction< - CFSocketRef Function( - CFAllocatorRef, - int, - int, - int, - int, - CFSocketCallBack, - ffi.Pointer, +final _objc_msgSend_e1wgee = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - CFSocketRef CFSocketCreateWithNative( - CFAllocatorRef allocator, - int sock, - int callBackTypes, - CFSocketCallBack callout, - ffi.Pointer context, - ) { - return _CFSocketCreateWithNative( - allocator, - sock, - callBackTypes, - callout, - context, - ); - } + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - late final _CFSocketCreateWithNativePtr = - _lookup< - ffi.NativeFunction< - CFSocketRef Function( - CFAllocatorRef, - CFSocketNativeHandle, - CFOptionFlags, - CFSocketCallBack, - ffi.Pointer, - ) - > - >('CFSocketCreateWithNative'); - late final _CFSocketCreateWithNative = - _CFSocketCreateWithNativePtr.asFunction< - CFSocketRef Function( - CFAllocatorRef, - int, - int, - CFSocketCallBack, - ffi.Pointer, +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, ) - >(); - - CFSocketRef CFSocketCreateWithSocketSignature( - CFAllocatorRef allocator, - ffi.Pointer signature, - int callBackTypes, - CFSocketCallBack callout, - ffi.Pointer context, - ) { - return _CFSocketCreateWithSocketSignature( - allocator, - signature, - callBackTypes, - callout, - context, - ); - } + >(pointer, retain: retain, release: release); - late final _CFSocketCreateWithSocketSignaturePtr = - _lookup< - ffi.NativeFunction< - CFSocketRef Function( - CFAllocatorRef, - ffi.Pointer, - CFOptionFlags, - CFSocketCallBack, - ffi.Pointer, - ) - > - >('CFSocketCreateWithSocketSignature'); - late final _CFSocketCreateWithSocketSignature = - _CFSocketCreateWithSocketSignaturePtr.asFunction< - CFSocketRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - CFSocketCallBack, - ffi.Pointer, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, ) - >(); - - CFSocketRef CFSocketCreateConnectedToSocketSignature( - CFAllocatorRef allocator, - ffi.Pointer signature, - int callBackTypes, - CFSocketCallBack callout, - ffi.Pointer context, - double timeout, - ) { - return _CFSocketCreateConnectedToSocketSignature( - allocator, - signature, - callBackTypes, - callout, - context, - timeout, - ); - } - - late final _CFSocketCreateConnectedToSocketSignaturePtr = - _lookup< - ffi.NativeFunction< - CFSocketRef Function( - CFAllocatorRef, - ffi.Pointer, - CFOptionFlags, - CFSocketCallBack, - ffi.Pointer, - CFTimeInterval, - ) - > - >('CFSocketCreateConnectedToSocketSignature'); - late final _CFSocketCreateConnectedToSocketSignature = - _CFSocketCreateConnectedToSocketSignaturePtr.asFunction< - CFSocketRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - CFSocketCallBack, - ffi.Pointer, - double, + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, ) - >(); - - CFSocketError CFSocketSetAddress(CFSocketRef s, CFDataRef address) { - return CFSocketError.fromValue(_CFSocketSetAddress(s, address)); - } - - late final _CFSocketSetAddressPtr = - _lookup>( - 'CFSocketSetAddress', - ); - late final _CFSocketSetAddress = - _CFSocketSetAddressPtr.asFunction(); - - CFSocketError CFSocketConnectToAddress( - CFSocketRef s, - CFDataRef address, - DartCFTimeInterval timeout, - ) { - return CFSocketError.fromValue( - _CFSocketConnectToAddress(s, address, timeout), - ); - } - - late final _CFSocketConnectToAddressPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFSocketRef, CFDataRef, CFTimeInterval) - > - >('CFSocketConnectToAddress'); - late final _CFSocketConnectToAddress = - _CFSocketConnectToAddressPtr.asFunction< - int Function(CFSocketRef, CFDataRef, double) - >(); - - void CFSocketInvalidate(CFSocketRef s) { - return _CFSocketInvalidate(s); - } - - late final _CFSocketInvalidatePtr = - _lookup>( - 'CFSocketInvalidate', + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _CFSocketInvalidate = - _CFSocketInvalidatePtr.asFunction(); - - int CFSocketIsValid(CFSocketRef s) { - return _CFSocketIsValid(s); - } - late final _CFSocketIsValidPtr = - _lookup>( - 'CFSocketIsValid', - ); - late final _CFSocketIsValid = - _CFSocketIsValidPtr.asFunction(); - - CFDataRef CFSocketCopyAddress(CFSocketRef s) { - return _CFSocketCopyAddress(s); - } - - late final _CFSocketCopyAddressPtr = - _lookup>( - 'CFSocketCopyAddress', - ); - late final _CFSocketCopyAddress = - _CFSocketCopyAddressPtr.asFunction(); - - CFDataRef CFSocketCopyPeerAddress(CFSocketRef s) { - return _CFSocketCopyPeerAddress(s); - } - - late final _CFSocketCopyPeerAddressPtr = - _lookup>( - 'CFSocketCopyPeerAddress', - ); - late final _CFSocketCopyPeerAddress = - _CFSocketCopyPeerAddressPtr.asFunction(); - - void CFSocketGetContext(CFSocketRef s, ffi.Pointer context) { - return _CFSocketGetContext(s, context); - } - - late final _CFSocketGetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFSocketRef, ffi.Pointer) - > - >('CFSocketGetContext'); - late final _CFSocketGetContext = - _CFSocketGetContextPtr.asFunction< - void Function(CFSocketRef, ffi.Pointer) - >(); - - int CFSocketGetNative(CFSocketRef s) { - return _CFSocketGetNative(s); - } - - late final _CFSocketGetNativePtr = - _lookup>( - 'CFSocketGetNative', - ); - late final _CFSocketGetNative = - _CFSocketGetNativePtr.asFunction(); - - CFRunLoopSourceRef CFSocketCreateRunLoopSource( - CFAllocatorRef allocator, - CFSocketRef s, - int order, - ) { - return _CFSocketCreateRunLoopSource(allocator, s, order); - } - - late final _CFSocketCreateRunLoopSourcePtr = - _lookup< - ffi.NativeFunction< - CFRunLoopSourceRef Function(CFAllocatorRef, CFSocketRef, CFIndex) - > - >('CFSocketCreateRunLoopSource'); - late final _CFSocketCreateRunLoopSource = - _CFSocketCreateRunLoopSourcePtr.asFunction< - CFRunLoopSourceRef Function(CFAllocatorRef, CFSocketRef, int) - >(); - - int CFSocketGetSocketFlags(CFSocketRef s) { - return _CFSocketGetSocketFlags(s); - } - - late final _CFSocketGetSocketFlagsPtr = - _lookup>( - 'CFSocketGetSocketFlags', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + NSHTTPURLResponse.fromPointer(arg3, retain: true, release: true), + NSURLRequest.fromPointer(arg4, retain: true, release: true), + ObjCBlock_ffiVoid_NSURLRequest.fromPointer( + arg5, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _CFSocketGetSocketFlags = - _CFSocketGetSocketFlagsPtr.asFunction(); - - void CFSocketSetSocketFlags(CFSocketRef s, int flags) { - return _CFSocketSetSocketFlags(s, flags); - } - - late final _CFSocketSetSocketFlagsPtr = - _lookup< - ffi.NativeFunction - >('CFSocketSetSocketFlags'); - late final _CFSocketSetSocketFlags = - _CFSocketSetSocketFlagsPtr.asFunction(); - - void CFSocketDisableCallBacks(CFSocketRef s, int callBackTypes) { - return _CFSocketDisableCallBacks(s, callBackTypes); - } - late final _CFSocketDisableCallBacksPtr = - _lookup< - ffi.NativeFunction - >('CFSocketDisableCallBacks'); - late final _CFSocketDisableCallBacks = - _CFSocketDisableCallBacksPtr.asFunction< - void Function(CFSocketRef, int) - >(); - - void CFSocketEnableCallBacks(CFSocketRef s, int callBackTypes) { - return _CFSocketEnableCallBacks(s, callBackTypes); - } - - late final _CFSocketEnableCallBacksPtr = - _lookup< - ffi.NativeFunction - >('CFSocketEnableCallBacks'); - late final _CFSocketEnableCallBacks = - _CFSocketEnableCallBacksPtr.asFunction(); - - CFSocketError CFSocketSendData( - CFSocketRef s, - CFDataRef address, - CFDataRef data, - DartCFTimeInterval timeout, - ) { - return CFSocketError.fromValue( - _CFSocketSendData(s, address, data, timeout), - ); - } - - late final _CFSocketSendDataPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFSocketRef, CFDataRef, CFDataRef, CFTimeInterval) - > - >('CFSocketSendData'); - late final _CFSocketSendData = - _CFSocketSendDataPtr.asFunction< - int Function(CFSocketRef, CFDataRef, CFDataRef, double) - >(); - - CFSocketError CFSocketRegisterValue( - ffi.Pointer nameServerSignature, - DartCFTimeInterval timeout, - CFStringRef name, - CFPropertyListRef value, - ) { - return CFSocketError.fromValue( - _CFSocketRegisterValue(nameServerSignature, timeout, name, value), - ); - } - - late final _CFSocketRegisterValuePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - ffi.Pointer, - CFTimeInterval, - CFStringRef, - CFPropertyListRef, - ) - > - >('CFSocketRegisterValue'); - late final _CFSocketRegisterValue = - _CFSocketRegisterValuePtr.asFunction< - int Function( - ffi.Pointer, - double, - CFStringRef, - CFPropertyListRef, - ) - >(); - - CFSocketError CFSocketCopyRegisteredValue( - ffi.Pointer nameServerSignature, - DartCFTimeInterval timeout, - CFStringRef name, - ffi.Pointer value, - ffi.Pointer nameServerAddress, - ) { - return CFSocketError.fromValue( - _CFSocketCopyRegisteredValue( - nameServerSignature, - timeout, - name, - value, - nameServerAddress, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), + NSURLRequest.fromPointer(arg4, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLRequest.fromPointer( + arg5, + retain: false, + release: true, + ), ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_l2g8ke(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _CFSocketCopyRegisteredValuePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - ffi.Pointer, - CFTimeInterval, - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFSocketCopyRegisteredValue'); - late final _CFSocketCopyRegisteredValue = - _CFSocketCopyRegisteredValuePtr.asFunction< - int Function( - ffi.Pointer, - double, - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFSocketError CFSocketRegisterSocketSignature( - ffi.Pointer nameServerSignature, - DartCFTimeInterval timeout, - CFStringRef name, - ffi.Pointer signature, - ) { - return CFSocketError.fromValue( - _CFSocketRegisterSocketSignature( - nameServerSignature, - timeout, - name, - signature, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), + NSURLRequest.fromPointer(arg4, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLRequest.fromPointer( + arg5, + retain: false, + release: true, + ), ), + keepIsolateAlive, ); - } - - late final _CFSocketRegisterSocketSignaturePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - ffi.Pointer, - CFTimeInterval, - CFStringRef, - ffi.Pointer, - ) - > - >('CFSocketRegisterSocketSignature'); - late final _CFSocketRegisterSocketSignature = - _CFSocketRegisterSocketSignaturePtr.asFunction< - int Function( - ffi.Pointer, - double, - CFStringRef, - ffi.Pointer, - ) - >(); - - CFSocketError CFSocketCopyRegisteredSocketSignature( - ffi.Pointer nameServerSignature, - DartCFTimeInterval timeout, - CFStringRef name, - ffi.Pointer signature, - ffi.Pointer nameServerAddress, - ) { - return CFSocketError.fromValue( - _CFSocketCopyRegisteredSocketSignature( - nameServerSignature, - timeout, - name, - signature, - nameServerAddress, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), + NSURLRequest.fromPointer(arg4, retain: false, release: true), + ObjCBlock_ffiVoid_NSURLRequest.fromPointer( + arg5, + retain: false, + release: true, + ), ), + keepIsolateAlive, ); - } - - late final _CFSocketCopyRegisteredSocketSignaturePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - ffi.Pointer, - CFTimeInterval, - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFSocketCopyRegisteredSocketSignature'); - late final _CFSocketCopyRegisteredSocketSignature = - _CFSocketCopyRegisteredSocketSignaturePtr.asFunction< - int Function( - ffi.Pointer, - double, - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFSocketError CFSocketUnregister( - ffi.Pointer nameServerSignature, - DartCFTimeInterval timeout, - CFStringRef name, - ) { - return CFSocketError.fromValue( - _CFSocketUnregister(nameServerSignature, timeout, name), + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_l2g8ke( + raw, + rawListener, + objc.objCContext, ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _CFSocketUnregisterPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - ffi.Pointer, - CFTimeInterval, - CFStringRef, - ) - > - >('CFSocketUnregister'); - late final _CFSocketUnregister = - _CFSocketUnregisterPtr.asFunction< - int Function(ffi.Pointer, double, CFStringRef) - >(); - - void CFSocketSetDefaultNameRegistryPortNumber(int port) { - return _CFSocketSetDefaultNameRegistryPortNumber(port); - } - - late final _CFSocketSetDefaultNameRegistryPortNumberPtr = - _lookup>( - 'CFSocketSetDefaultNameRegistryPortNumber', - ); - late final _CFSocketSetDefaultNameRegistryPortNumber = - _CFSocketSetDefaultNameRegistryPortNumberPtr.asFunction< - void Function(int) - >(); - - int CFSocketGetDefaultNameRegistryPortNumber() { - return _CFSocketGetDefaultNameRegistryPortNumber(); - } - - late final _CFSocketGetDefaultNameRegistryPortNumberPtr = - _lookup>( - 'CFSocketGetDefaultNameRegistryPortNumber', - ); - late final _CFSocketGetDefaultNameRegistryPortNumber = - _CFSocketGetDefaultNameRegistryPortNumberPtr.asFunction(); - - late final ffi.Pointer _kCFSocketCommandKey = - _lookup('kCFSocketCommandKey'); - - CFStringRef get kCFSocketCommandKey => _kCFSocketCommandKey.value; - - late final ffi.Pointer _kCFSocketNameKey = _lookup( - 'kCFSocketNameKey', - ); - - CFStringRef get kCFSocketNameKey => _kCFSocketNameKey.value; - - late final ffi.Pointer _kCFSocketValueKey = _lookup( - 'kCFSocketValueKey', - ); - - CFStringRef get kCFSocketValueKey => _kCFSocketValueKey.value; - - late final ffi.Pointer _kCFSocketResultKey = - _lookup('kCFSocketResultKey'); - - CFStringRef get kCFSocketResultKey => _kCFSocketResultKey.value; - - late final ffi.Pointer _kCFSocketErrorKey = _lookup( - 'kCFSocketErrorKey', - ); - - CFStringRef get kCFSocketErrorKey => _kCFSocketErrorKey.value; - - late final ffi.Pointer _kCFSocketRegisterCommand = - _lookup('kCFSocketRegisterCommand'); - - CFStringRef get kCFSocketRegisterCommand => _kCFSocketRegisterCommand.value; - - late final ffi.Pointer _kCFSocketRetrieveCommand = - _lookup('kCFSocketRetrieveCommand'); - - CFStringRef get kCFSocketRetrieveCommand => _kCFSocketRetrieveCommand.value; - - int getattrlistbulk( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, ) { - return _getattrlistbulk(arg0, arg1, arg2, arg3, arg4); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + objc.objectRelease(block.cast()); } - late final _getattrlistbulkPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, - ffi.Size, - ffi.Uint64, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('getattrlistbulk'); - late final _getattrlistbulk = _getattrlistbulkPtr - .asFunction< - int Function( - int, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >(); - - int getattrlistat( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - int arg4, - int arg5, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, ) { - return _getattrlistat(arg0, arg1, arg2, arg3, arg4, arg5); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _getattrlistatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Size, - ffi.UnsignedLong, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('getattrlistat'); - late final _getattrlistat = _getattrlistatPtr - .asFunction< - int Function( - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >(); - - int setattrlistat( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - int arg4, - int arg5, - ) { - return _setattrlistat(arg0, arg1, arg2, arg3, arg4, arg5); - } - - late final _setattrlistatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Size, - ffi.Uint32, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, ) > - >('setattrlistat'); - late final _setattrlistat = _setattrlistatPtr + >() .asFunction< - int Function( - int, - ffi.Pointer, - ffi.Pointer, + void Function( ffi.Pointer, - int, - int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - int freadlink(int arg0, ffi.Pointer arg1, int arg2) { - return _freadlink(arg0, arg1, arg2); - } - - late final _freadlinkPtr = - _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Int, ffi.Pointer, ffi.Size) - > - >('freadlink'); - late final _freadlink = _freadlinkPtr - .asFunction, int)>(); - - int faccessat(int arg0, ffi.Pointer arg1, int arg2, int arg3) { - return _faccessat(arg0, arg1, arg2, arg3); - } - - late final _faccessatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int, ffi.Int) - > - >('faccessat'); - late final _faccessat = _faccessatPtr - .asFunction, int, int)>(); - - int fchownat( - int arg0, - ffi.Pointer arg1, - int arg2, - int arg3, - int arg4, - ) { - return _fchownat(arg0, arg1, arg2, arg3, arg4); - } - - late final _fchownatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - uid_t, - gid_t, - ffi.Int, - ) - > - >('fchownat'); - late final _fchownat = _fchownatPtr - .asFunction, int, int, int)>(); - - int linkat( - int arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer arg3, - int arg4, - ) { - return _linkat(arg0, arg1, arg2, arg3, arg4); - } - - late final _linkatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ) - > - >('linkat'); - late final _linkat = _linkatPtr - .asFunction< - int Function( - int, - ffi.Pointer, - int, - ffi.Pointer, - int, - ) - >(); - - int readlinkat( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ) { - return _readlinkat(arg0, arg1, arg2, arg3); - } - - late final _readlinkatPtr = - _lookup< - ffi.NativeFunction< - ssize_t Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('readlinkat'); - late final _readlinkat = _readlinkatPtr - .asFunction< - int Function(int, ffi.Pointer, ffi.Pointer, int) - >(); - - int symlinkat( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) { - return _symlinkat(arg0, arg1, arg2); - } + >()(arg0, arg1, arg2, arg3, arg4, arg5); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _symlinkatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, ) - > - >('symlinkat'); - late final _symlinkat = _symlinkatPtr - .asFunction< - int Function(ffi.Pointer, int, ffi.Pointer) - >(); - - int unlinkat(int arg0, ffi.Pointer arg1, int arg2) { - return _unlinkat(arg0, arg1, arg2); - } - - late final _unlinkatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int) - > - >('unlinkat'); - late final _unlinkat = _unlinkatPtr - .asFunction, int)>(); - - void _exit(int arg0) { - return __exit(arg0); - } - - late final __exitPtr = - _lookup>('_exit'); - late final __exit = __exitPtr.asFunction(); - - int access(ffi.Pointer arg0, int arg1) { - return _access(arg0, arg1); - } - - late final _accessPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('access'); - late final _access = _accessPtr - .asFunction, int)>(); - - int alarm(int arg0) { - return _alarm(arg0); - } - - late final _alarmPtr = - _lookup>( - 'alarm', + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, + arg4.ref.pointer, + arg5.ref.pointer, ); - late final _alarm = _alarmPtr.asFunction(); - - int chdir(ffi.Pointer arg0) { - return _chdir(arg0); - } +} - late final _chdirPtr = - _lookup)>>( - 'chdir', - ); - late final _chdir = _chdirPtr - .asFunction)>(); +/// WARNING: NSURLAuthenticationChallenge is a stub. To generate bindings for this class, include +/// NSURLAuthenticationChallenge in your config's objc-interfaces list. +/// +/// NSURLAuthenticationChallenge +extension type NSURLAuthenticationChallenge._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [NSURLAuthenticationChallenge] that points to the same underlying object as [other]. + NSURLAuthenticationChallenge.as(objc.ObjCObject other) : object$ = other {} - int chown(ffi.Pointer arg0, int arg1, int arg2) { - return _chown(arg0, arg1, arg2); - } + /// Constructs a [NSURLAuthenticationChallenge] that wraps the given raw object pointer. + NSURLAuthenticationChallenge.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} +} - late final _chownPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, uid_t, gid_t) - > - >('chown'); - late final _chown = _chownPtr - .asFunction, int, int)>(); +/// WARNING: NSURLCredential is a stub. To generate bindings for this class, include +/// NSURLCredential in your config's objc-interfaces list. +/// +/// NSURLCredential +extension type NSURLCredential._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [NSURLCredential] that points to the same underlying object as [other]. + NSURLCredential.as(objc.ObjCObject other) : object$ = other {} - int close(int arg0) { - return _close(arg0); - } + /// Constructs a [NSURLCredential] that wraps the given raw object pointer. + NSURLCredential.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} +} - late final _closePtr = _lookup>( - 'close', +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, ); - late final _close = _closePtr.asFunction(); - - int dup(int arg0) { - return _dup(arg0); - } - late final _dupPtr = _lookup>( - 'dup', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Long arg0, ffi.Pointer arg1) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _dup = _dupPtr.asFunction(); - - int dup2(int arg0, int arg1) { - return _dup2(arg0, arg1); - } - late final _dup2Ptr = - _lookup>('dup2'); - late final _dup2 = _dup2Ptr.asFunction(); - - int execl(ffi.Pointer __path, ffi.Pointer __arg0) { - return _execl(__path, __arg0); - } - - late final _execlPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('execl'); - late final _execl = _execlPtr - .asFunction, ffi.Pointer)>(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock + fromFunction( + void Function(NSURLSessionAuthChallengeDisposition, NSURLCredential?) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (int arg0, ffi.Pointer arg1) => fn( + NSURLSessionAuthChallengeDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLCredential.fromPointer(arg1, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - int execle(ffi.Pointer __path, ffi.Pointer __arg0) { - return _execle(__path, __arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(NSURLSessionAuthChallengeDisposition, NSURLCredential?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (int arg0, ffi.Pointer arg1) => fn( + NSURLSessionAuthChallengeDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLCredential.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_n8yd09(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _execlePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('execle'); - late final _execle = _execlePtr - .asFunction, ffi.Pointer)>(); - - int execlp(ffi.Pointer __file, ffi.Pointer __arg0) { - return _execlp(__file, __arg0); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(NSURLSessionAuthChallengeDisposition, NSURLCredential?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (int arg0, ffi.Pointer arg1) => fn( + NSURLSessionAuthChallengeDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLCredential.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (int arg0, ffi.Pointer arg1) => fn( + NSURLSessionAuthChallengeDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLCredential.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_n8yd09( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _execlpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('execlp'); - late final _execlp = _execlpPtr - .asFunction, ffi.Pointer)>(); - - int execv( - ffi.Pointer __path, - ffi.Pointer> __argv, + static void _listenerTrampoline( + ffi.Pointer block, + int arg0, + ffi.Pointer arg1, ) { - return _execv(__path, __argv); + (objc.getBlockClosure(block) + as void Function(int, ffi.Pointer))(arg0, arg1); + objc.objectRelease(block.cast()); } - late final _execvPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer>, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Long, + ffi.Pointer, ) - > - >('execv'); - late final _execv = _execvPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer>) - >(); - - int execve( - ffi.Pointer __file, - ffi.Pointer> __argv, - ffi.Pointer> __envp, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + int arg0, + ffi.Pointer arg1, ) { - return _execve(__file, __argv, __envp); + try { + (objc.getBlockClosure(block) + as void Function(int, ffi.Pointer))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _execvePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer>, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, ) - > - >('execve'); - late final _execve = _execvePtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer>, - ) - >(); - - int execvp( - ffi.Pointer __file, - ffi.Pointer> __argv, - ) { - return _execvp(__file, __argv); - } - - late final _execvpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer>, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, ) - > - >('execvp'); - late final _execvp = _execvpPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer>) - >(); - - int fork() { - return _fork(); - } - - late final _forkPtr = _lookup>('fork'); - late final _fork = _forkPtr.asFunction(); - - int fpathconf(int arg0, int arg1) { - return _fpathconf(arg0, arg1); - } - - late final _fpathconfPtr = - _lookup>( - 'fpathconf', + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + int arg0, + ffi.Pointer arg1, + ) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Long arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction)>()( + arg0, + arg1, ); - late final _fpathconf = _fpathconfPtr.asFunction(); - - ffi.Pointer getcwd(ffi.Pointer arg0, int __size) { - return _getcwd(arg0, __size); - } - - late final _getcwdPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Size) - > - >('getcwd'); - late final _getcwd = _getcwdPtr - .asFunction Function(ffi.Pointer, int)>(); - - int getegid() { - return _getegid(); - } - - late final _getegidPtr = _lookup>( - 'getegid', - ); - late final _getegid = _getegidPtr.asFunction(); - - int geteuid() { - return _geteuid(); - } - - late final _geteuidPtr = _lookup>( - 'geteuid', - ); - late final _geteuid = _geteuidPtr.asFunction(); - - int getgid() { - return _getgid(); - } - - late final _getgidPtr = _lookup>( - 'getgid', - ); - late final _getgid = _getgidPtr.asFunction(); - - int getgroups(int __gidsetsize, ffi.Pointer arg1) { - return _getgroups(__gidsetsize, arg1); - } - - late final _getgroupsPtr = - _lookup< - ffi.NativeFunction)> - >('getgroups'); - late final _getgroups = _getgroupsPtr - .asFunction)>(); - - ffi.Pointer getlogin() { - return _getlogin(); - } - - late final _getloginPtr = - _lookup Function()>>('getlogin'); - late final _getlogin = _getloginPtr - .asFunction Function()>(); - - int getpgrp() { - return _getpgrp(); - } + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + int arg0, + ffi.Pointer arg1, + ) => + (objc.getBlockClosure(block) + as void Function(int, ffi.Pointer))(arg0, arg1); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _getpgrpPtr = _lookup>( - 'getpgrp', - ); - late final _getpgrp = _getpgrpPtr.asFunction(); +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential$CallExtension + on objc.ObjCBlock { + void call(NSURLSessionAuthChallengeDisposition arg0, NSURLCredential? arg1) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Long arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + int, + ffi.Pointer, + ) + >()(ref.pointer, arg0.value, arg1?.ref.pointer ?? ffi.nullptr); +} - int getpid() { - return _getpid(); - } +late final _sel_URLSession_task_didReceiveChallenge_completionHandler_ = objc + .registerName("URLSession:task:didReceiveChallenge:completionHandler:"); - late final _getpidPtr = _lookup>( - 'getpid', - ); - late final _getpid = _getpidPtr.asFunction(); +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLAuthenticationChallenge, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >(pointer, retain: retain, release: release); - int getppid() { - return _getppid(); - } - - late final _getppidPtr = _lookup>( - 'getppid', - ); - late final _getppid = _getppidPtr.asFunction(); - - int getuid() { - return _getuid(); - } - - late final _getuidPtr = _lookup>( - 'getuid', - ); - late final _getuid = _getuidPtr.asFunction(); - - int isatty(int arg0) { - return _isatty(arg0); - } - - late final _isattyPtr = - _lookup>('isatty'); - late final _isatty = _isattyPtr.asFunction(); - - int link(ffi.Pointer arg0, ffi.Pointer arg1) { - return _link(arg0, arg1); - } - - late final _linkPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('link'); - late final _link = _linkPtr - .asFunction, ffi.Pointer)>(); - - int lseek(int arg0, int arg1, int arg2) { - return _lseek(arg0, arg1, arg2); - } - - late final _lseekPtr = - _lookup>( - 'lseek', - ); - late final _lseek = _lseekPtr.asFunction(); - - int pathconf(ffi.Pointer arg0, int arg1) { - return _pathconf(arg0, arg1); - } - - late final _pathconfPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('pathconf'); - late final _pathconf = _pathconfPtr - .asFunction, int)>(); - - int pause() { - return _pause(); - } - - late final _pausePtr = _lookup>( - 'pause', - ); - late final _pause = _pausePtr.asFunction(); - - int pipe(ffi.Pointer arg0) { - return _pipe(arg0); - } - - late final _pipePtr = - _lookup)>>( - 'pipe', - ); - late final _pipe = _pipePtr.asFunction)>(); - - int read(int arg0, ffi.Pointer arg1, int __nbyte) { - return _read(arg0, arg1, __nbyte); - } - - late final _readPtr = - _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Int, ffi.Pointer, ffi.Size) - > - >('read'); - late final _read = _readPtr - .asFunction, int)>(); - - int rmdir(ffi.Pointer arg0) { - return _rmdir(arg0); - } - - late final _rmdirPtr = - _lookup)>>( - 'rmdir', - ); - late final _rmdir = _rmdirPtr - .asFunction)>(); - - int setgid(int arg0) { - return _setgid(arg0); - } - - late final _setgidPtr = _lookup>( - 'setgid', - ); - late final _setgid = _setgidPtr.asFunction(); - - int setpgid(int arg0, int arg1) { - return _setpgid(arg0, arg1); - } - - late final _setpgidPtr = - _lookup>('setpgid'); - late final _setpgid = _setpgidPtr.asFunction(); - - int setsid() { - return _setsid(); - } - - late final _setsidPtr = _lookup>( - 'setsid', - ); - late final _setsid = _setsidPtr.asFunction(); - - int setuid(int arg0) { - return _setuid(arg0); - } - - late final _setuidPtr = _lookup>( - 'setuid', - ); - late final _setuid = _setuidPtr.asFunction(); - - int sleep(int arg0) { - return _sleep(arg0); - } - - late final _sleepPtr = - _lookup>( - 'sleep', - ); - late final _sleep = _sleepPtr.asFunction(); - - int sysconf(int arg0) { - return _sysconf(arg0); - } - - late final _sysconfPtr = - _lookup>('sysconf'); - late final _sysconf = _sysconfPtr.asFunction(); - - int tcgetpgrp(int arg0) { - return _tcgetpgrp(arg0); - } - - late final _tcgetpgrpPtr = - _lookup>('tcgetpgrp'); - late final _tcgetpgrp = _tcgetpgrpPtr.asFunction(); - - int tcsetpgrp(int arg0, int arg1) { - return _tcsetpgrp(arg0, arg1); - } - - late final _tcsetpgrpPtr = - _lookup>( - 'tcsetpgrp', - ); - late final _tcsetpgrp = _tcsetpgrpPtr.asFunction(); - - ffi.Pointer ttyname(int arg0) { - return _ttyname(arg0); - } - - late final _ttynamePtr = - _lookup Function(ffi.Int)>>( - 'ttyname', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _ttyname = _ttynamePtr - .asFunction Function(int)>(); - - int ttyname_r(int arg0, ffi.Pointer arg1, int __len) { - return _ttyname_r(arg0, arg1, __len); - } - - late final _ttyname_rPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Size) - > - >('ttyname_r'); - late final _ttyname_r = _ttyname_rPtr - .asFunction, int)>(); - - int unlink(ffi.Pointer arg0) { - return _unlink(arg0); - } - late final _unlinkPtr = - _lookup)>>( - 'unlink', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg3, + retain: true, + release: true, + ), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg4, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _unlink = _unlinkPtr - .asFunction)>(); - int write(int __fd, ffi.Pointer __buf, int __nbyte) { - return _write(__fd, __buf, __nbyte); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg3, + retain: false, + release: true, + ), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xx612k(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _writePtr = - _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Int, ffi.Pointer, ffi.Size) - > - >('write'); - late final _write = _writePtr - .asFunction, int)>(); - - int confstr(int arg0, ffi.Pointer arg1, int __len) { - return _confstr(arg0, arg1, __len); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg3, + retain: false, + release: true, + ), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg3, + retain: false, + release: true, + ), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _confstrPtr = - _lookup< - ffi.NativeFunction< - ffi.Size Function(ffi.Int, ffi.Pointer, ffi.Size) - > - >('confstr'); - late final _confstr = _confstrPtr - .asFunction, int)>(); - - int getopt( - int __argc, - ffi.Pointer> arg1, - ffi.Pointer arg2, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) { - return _getopt(__argc, arg1, arg2); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + objc.objectRelease(block.cast()); } - late final _getoptPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer>, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('getopt'); - late final _getopt = _getoptPtr - .asFunction< - int Function( - int, - ffi.Pointer>, - ffi.Pointer, - ) - >(); - - late final ffi.Pointer> _optarg = - _lookup>('optarg'); - - ffi.Pointer get optarg => _optarg.value; - - set optarg(ffi.Pointer value) => _optarg.value = value; - - late final ffi.Pointer _optind = _lookup('optind'); - - int get optind => _optind.value; - - set optind(int value) => _optind.value = value; - - late final ffi.Pointer _opterr = _lookup('opterr'); - - int get opterr => _opterr.value; - - set opterr(int value) => _opterr.value = value; - - late final ffi.Pointer _optopt = _lookup('optopt'); - - int get optopt => _optopt.value; - - set optopt(int value) => _optopt.value = value; - - ffi.Pointer brk(ffi.Pointer arg0) { - return _brk(arg0); - } - - late final _brkPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('brk'); - late final _brk = _brkPtr - .asFunction Function(ffi.Pointer)>(); - - int chroot(ffi.Pointer arg0) { - return _chroot(arg0); - } - - late final _chrootPtr = - _lookup)>>( - 'chroot', - ); - late final _chroot = _chrootPtr - .asFunction)>(); - - ffi.Pointer crypt( - ffi.Pointer arg0, - ffi.Pointer arg1, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) { - return _crypt(arg0, arg1); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _cryptPtr = - _lookup< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) > - >('crypt'); - late final _crypt = _cryptPtr + >() .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - void encrypt(ffi.Pointer arg0, int arg1) { - return _encrypt(arg0, arg1); - } - - late final _encryptPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('encrypt'); - late final _encrypt = _encryptPtr - .asFunction, int)>(); - - int fchdir(int arg0) { - return _fchdir(arg0); - } - - late final _fchdirPtr = - _lookup>('fchdir'); - late final _fchdir = _fchdirPtr.asFunction(); - - int gethostid() { - return _gethostid(); - } - - late final _gethostidPtr = _lookup>( - 'gethostid', - ); - late final _gethostid = _gethostidPtr.asFunction(); - - int getpgid(int arg0) { - return _getpgid(arg0); - } - - late final _getpgidPtr = _lookup>( - 'getpgid', - ); - late final _getpgid = _getpgidPtr.asFunction(); - - int getsid(int arg0) { - return _getsid(arg0); - } - - late final _getsidPtr = _lookup>( - 'getsid', - ); - late final _getsid = _getsidPtr.asFunction(); - - int getdtablesize() { - return _getdtablesize(); - } - - late final _getdtablesizePtr = - _lookup>('getdtablesize'); - late final _getdtablesize = _getdtablesizePtr.asFunction(); - - int getpagesize() { - return _getpagesize(); - } - - late final _getpagesizePtr = _lookup>( - 'getpagesize', - ); - late final _getpagesize = _getpagesizePtr.asFunction(); - - ffi.Pointer getpass(ffi.Pointer arg0) { - return _getpass(arg0); - } - - late final _getpassPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('getpass'); - late final _getpass = _getpassPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer getwd(ffi.Pointer arg0) { - return _getwd(arg0); - } - - late final _getwdPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('getwd'); - late final _getwd = _getwdPtr - .asFunction Function(ffi.Pointer)>(); - - int lchown(ffi.Pointer arg0, int arg1, int arg2) { - return _lchown(arg0, arg1, arg2); - } - - late final _lchownPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, uid_t, gid_t) - > - >('lchown'); - late final _lchown = _lchownPtr - .asFunction, int, int)>(); - - int lockf(int arg0, int arg1, int arg2) { - return _lockf(arg0, arg1, arg2); - } - - late final _lockfPtr = - _lookup>( - 'lockf', - ); - late final _lockf = _lockfPtr.asFunction(); - - int nice(int arg0) { - return _nice(arg0); - } - - late final _nicePtr = _lookup>( - 'nice', - ); - late final _nice = _nicePtr.asFunction(); - - int pread(int __fd, ffi.Pointer __buf, int __nbyte, int __offset) { - return _pread(__fd, __buf, __nbyte, __offset); - } - - late final _preadPtr = - _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Int, ffi.Pointer, ffi.Size, off_t) - > - >('pread'); - late final _pread = _preadPtr - .asFunction, int, int)>(); - - int pwrite(int __fd, ffi.Pointer __buf, int __nbyte, int __offset) { - return _pwrite(__fd, __buf, __nbyte, __offset); - } - - late final _pwritePtr = - _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Int, ffi.Pointer, ffi.Size, off_t) - > - >('pwrite'); - late final _pwrite = _pwritePtr - .asFunction, int, int)>(); - - ffi.Pointer sbrk(int arg0) { - return _sbrk(arg0); - } - - late final _sbrkPtr = - _lookup Function(ffi.Int)>>( - 'sbrk', - ); - late final _sbrk = _sbrkPtr.asFunction Function(int)>(); - - int setpgrp() { - return _setpgrp(); - } - - late final _setpgrpPtr = _lookup>( - 'setpgrp', - ); - late final _setpgrp = _setpgrpPtr.asFunction(); - - int setregid(int arg0, int arg1) { - return _setregid(arg0, arg1); - } - - late final _setregidPtr = - _lookup>('setregid'); - late final _setregid = _setregidPtr.asFunction(); - - int setreuid(int arg0, int arg1) { - return _setreuid(arg0, arg1); - } - - late final _setreuidPtr = - _lookup>('setreuid'); - late final _setreuid = _setreuidPtr.asFunction(); - - void sync() { - return _sync(); - } - - late final _syncPtr = _lookup>( - 'sync', - ); - late final _sync = _syncPtr.asFunction(); - - int truncate(ffi.Pointer arg0, int arg1) { - return _truncate(arg0, arg1); - } - - late final _truncatePtr = - _lookup< - ffi.NativeFunction, off_t)> - >('truncate'); - late final _truncate = _truncatePtr - .asFunction, int)>(); - - int ualarm(int arg0, int arg1) { - return _ualarm(arg0, arg1); - } + >()(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _ualarmPtr = - _lookup>( - 'ualarm', +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLAuthenticationChallenge, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock arg4, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, + arg4.ref.pointer, ); - late final _ualarm = _ualarmPtr.asFunction(); - - int usleep(int arg0) { - return _usleep(arg0); - } - - late final _usleepPtr = - _lookup>('usleep'); - late final _usleep = _usleepPtr.asFunction(); - - int vfork() { - return _vfork(); - } +} - late final _vforkPtr = _lookup>( - 'vfork', +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSInputStream { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, ); - late final _vfork = _vforkPtr.asFunction(); - - int fsync(int arg0) { - return _fsync(arg0); - } - late final _fsyncPtr = _lookup>( - 'fsync', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _fsync = _fsyncPtr.asFunction(); - - int ftruncate(int arg0, int arg1) { - return _ftruncate(arg0, arg1); - } - - late final _ftruncatePtr = - _lookup>( - 'ftruncate', - ); - late final _ftruncate = _ftruncatePtr.asFunction(); - - int getlogin_r(ffi.Pointer arg0, int __namelen) { - return _getlogin_r(arg0, __namelen); - } - - late final _getlogin_rPtr = - _lookup< - ffi.NativeFunction, ffi.Size)> - >('getlogin_r'); - late final _getlogin_r = _getlogin_rPtr - .asFunction, int)>(); - - int fchown(int arg0, int arg1, int arg2) { - return _fchown(arg0, arg1, arg2); - } - - late final _fchownPtr = - _lookup>( - 'fchown', - ); - late final _fchown = _fchownPtr.asFunction(); - - int gethostname(ffi.Pointer arg0, int __namelen) { - return _gethostname(arg0, __namelen); - } - - late final _gethostnamePtr = - _lookup< - ffi.NativeFunction, ffi.Size)> - >('gethostname'); - late final _gethostname = _gethostnamePtr - .asFunction, int)>(); - - int readlink( - ffi.Pointer arg0, - ffi.Pointer arg1, - int __bufsize, - ) { - return _readlink(arg0, arg1, __bufsize); - } - - late final _readlinkPtr = - _lookup< - ffi.NativeFunction< - ssize_t Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - >('readlink'); - late final _readlink = _readlinkPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int setegid(int arg0) { - return _setegid(arg0); - } - late final _setegidPtr = _lookup>( - 'setegid', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(objc.NSInputStream?) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSInputStream.fromPointer(arg0, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _setegid = _setegidPtr.asFunction(); - int seteuid(int arg0) { - return _seteuid(arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(objc.NSInputStream?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSInputStream.fromPointer( + arg0, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _seteuidPtr = _lookup>( - 'seteuid', - ); - late final _seteuid = _seteuidPtr.asFunction(); - - int symlink(ffi.Pointer arg0, ffi.Pointer arg1) { - return _symlink(arg0, arg1); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(objc.NSInputStream?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSInputStream.fromPointer( + arg0, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSInputStream.fromPointer( + arg0, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); } - late final _symlinkPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('symlink'); - late final _symlink = _symlinkPtr - .asFunction, ffi.Pointer)>(); - - int pselect( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, ) { - return _pselect(arg0, arg1, arg2, arg3, arg4, arg5); + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); } - late final _pselectPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, ) - > - >('pselect'); - late final _pselect = _pselectPtr - .asFunction< - int Function( - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int select( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, ) { - return _select(arg0, arg1, arg2, arg3, arg4); + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _selectPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('select'); - late final _select = _selectPtr - .asFunction< - int Function( - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int accessx_np( - ffi.Pointer arg0, - int __sz, - ffi.Pointer arg2, - int arg3, - ) { - return _accessx_np(arg0, __sz, arg2, arg3); - } - - late final _accessx_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.Pointer, - uid_t, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('accessx_np'); - late final _accessx_np = _accessx_npPtr - .asFunction< - int Function( - ffi.Pointer, - int, - ffi.Pointer, - int, - ) - >(); - - int acct(ffi.Pointer arg0) { - return _acct(arg0); - } - - late final _acctPtr = - _lookup)>>( - 'acct', - ); - late final _acct = _acctPtr.asFunction)>(); - - int add_profil(ffi.Pointer arg0, int __bufsiz, int arg2, int arg3) { - return _add_profil(arg0, __bufsiz, arg2, arg3); - } - - late final _add_profilPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.UnsignedLong, - ffi.UnsignedInt, - ) + ffi.Void Function(ffi.Pointer arg0) > - >('add_profil'); - late final _add_profil = _add_profilPtr - .asFunction, int, int, int)>(); - - void endusershell() { - return _endusershell(); - } - - late final _endusershellPtr = - _lookup>('endusershell'); - late final _endusershell = _endusershellPtr.asFunction(); - - int execvP( - ffi.Pointer __file, - ffi.Pointer __searchpath, - ffi.Pointer> __argv, - ) { - return _execvP(__file, __searchpath, __argv); - } + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _execvPPtr = - _lookup< +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSInputStream$CallExtension + on objc.ObjCBlock { + void call(objc.NSInputStream? arg0) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, ) > - >('execvP'); - late final _execvP = _execvPPtr + >() .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + void Function( + ffi.Pointer, + ffi.Pointer, ) - >(); - - ffi.Pointer fflagstostr(int arg0) { - return _fflagstostr(arg0); - } - - late final _fflagstostrPtr = - _lookup< - ffi.NativeFunction Function(ffi.UnsignedLong)> - >('fflagstostr'); - late final _fflagstostr = _fflagstostrPtr - .asFunction Function(int)>(); - - int getdomainname(ffi.Pointer arg0, int __namelen) { - return _getdomainname(arg0, __namelen); - } - - late final _getdomainnamePtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('getdomainname'); - late final _getdomainname = _getdomainnamePtr - .asFunction, int)>(); - - int getgrouplist( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ffi.Pointer __ngroups, - ) { - return _getgrouplist(arg0, arg1, arg2, __ngroups); - } + >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); +} - late final _getgrouplistPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) - > - >('getgrouplist'); - late final _getgrouplist = _getgrouplistPtr - .asFunction< - int Function( - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, +late final _sel_URLSession_task_needNewBodyStream_ = objc.registerName( + "URLSession:task:needNewBodyStream:", +); +final _objc_msgSend_18qun1e = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - int gethostuuid( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _gethostuuid(arg0, arg1); - } - - late final _gethostuuidPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('gethostuuid'); - late final _gethostuuid = _gethostuuidPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer) - >(); - - int getmode(ffi.Pointer arg0, int arg1) { - return _getmode(arg0, arg1); - } - - late final _getmodePtr = - _lookup< - ffi.NativeFunction, mode_t)> - >('getmode'); - late final _getmode = _getmodePtr - .asFunction, int)>(); + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - int getpeereid(int arg0, ffi.Pointer arg1, ffi.Pointer arg2) { - return _getpeereid(arg0, arg1, arg2); - } - - late final _getpeereidPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Pointer) - > - >('getpeereid'); - late final _getpeereid = _getpeereidPtr - .asFunction, ffi.Pointer)>(); - - int getsgroups_np( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _getsgroups_np(arg0, arg1); - } - - late final _getsgroups_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('getsgroups_np'); - late final _getsgroups_np = _getsgroups_npPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer) - >(); - - ffi.Pointer getusershell() { - return _getusershell(); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >(pointer, retain: retain, release: release); - late final _getusershellPtr = - _lookup Function()>>( - 'getusershell', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _getusershell = _getusershellPtr - .asFunction Function()>(); - - int getwgroups_np( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _getwgroups_np(arg0, arg1); - } - - late final _getwgroups_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('getwgroups_np'); - late final _getwgroups_np = _getwgroups_npPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer) - >(); - - int initgroups(ffi.Pointer arg0, int arg1) { - return _initgroups(arg0, arg1); - } - - late final _initgroupsPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('initgroups'); - late final _initgroups = _initgroupsPtr - .asFunction, int)>(); - - int issetugid() { - return _issetugid(); - } - - late final _issetugidPtr = _lookup>( - 'issetugid', - ); - late final _issetugid = _issetugidPtr.asFunction(); - - ffi.Pointer mkdtemp(ffi.Pointer arg0) { - return _mkdtemp(arg0); - } - - late final _mkdtempPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('mkdtemp'); - late final _mkdtemp = _mkdtempPtr - .asFunction Function(ffi.Pointer)>(); - - int mknod(ffi.Pointer arg0, int arg1, int arg2) { - return _mknod(arg0, arg1, arg2); - } - - late final _mknodPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, mode_t, dev_t) - > - >('mknod'); - late final _mknod = _mknodPtr - .asFunction, int, int)>(); - - int mkpath_np(ffi.Pointer path, int omode) { - return _mkpath_np(path, omode); - } - - late final _mkpath_npPtr = - _lookup< - ffi.NativeFunction, mode_t)> - >('mkpath_np'); - late final _mkpath_np = _mkpath_npPtr - .asFunction, int)>(); - - int mkpathat_np(int dfd, ffi.Pointer path, int omode) { - return _mkpathat_np(dfd, path, omode); - } - - late final _mkpathat_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, mode_t) - > - >('mkpathat_np'); - late final _mkpathat_np = _mkpathat_npPtr - .asFunction, int)>(); - - int mkstemps(ffi.Pointer arg0, int arg1) { - return _mkstemps(arg0, arg1); - } - - late final _mkstempsPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('mkstemps'); - late final _mkstemps = _mkstempsPtr - .asFunction, int)>(); - - int mkostemp(ffi.Pointer path, int oflags) { - return _mkostemp(path, oflags); - } - - late final _mkostempPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('mkostemp'); - late final _mkostemp = _mkostempPtr - .asFunction, int)>(); - - int mkostemps(ffi.Pointer path, int slen, int oflags) { - return _mkostemps(path, slen, oflags); - } - - late final _mkostempsPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int) - > - >('mkostemps'); - late final _mkostemps = _mkostempsPtr - .asFunction, int, int)>(); - - int mkstemp_dprotected_np( - ffi.Pointer path, - int dpclass, - int dpflags, - ) { - return _mkstemp_dprotected_np(path, dpclass, dpflags); - } - - late final _mkstemp_dprotected_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int) - > - >('mkstemp_dprotected_np'); - late final _mkstemp_dprotected_np = _mkstemp_dprotected_npPtr - .asFunction, int, int)>(); - - ffi.Pointer mkdtempat_np(int dfd, ffi.Pointer path) { - return _mkdtempat_np(dfd, path); - } - - late final _mkdtempat_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Int, ffi.Pointer) - > - >('mkdtempat_np'); - late final _mkdtempat_np = _mkdtempat_npPtr - .asFunction Function(int, ffi.Pointer)>(); - - int mkstempsat_np(int dfd, ffi.Pointer path, int slen) { - return _mkstempsat_np(dfd, path, slen); - } - - late final _mkstempsat_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int) - > - >('mkstempsat_np'); - late final _mkstempsat_np = _mkstempsat_npPtr - .asFunction, int)>(); - - int mkostempsat_np( - int dfd, - ffi.Pointer path, - int slen, - int oflags, - ) { - return _mkostempsat_np(dfd, path, slen, oflags); - } - - late final _mkostempsat_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int, ffi.Int) - > - >('mkostempsat_np'); - late final _mkostempsat_np = _mkostempsat_npPtr - .asFunction, int, int)>(); - - int nfssvc(int arg0, ffi.Pointer arg1) { - return _nfssvc(arg0, arg1); - } - - late final _nfssvcPtr = - _lookup< - ffi.NativeFunction)> - >('nfssvc'); - late final _nfssvc = _nfssvcPtr - .asFunction)>(); - - int profil(ffi.Pointer arg0, int __bufsiz, int arg2, int arg3) { - return _profil(arg0, __bufsiz, arg2, arg3); - } - - late final _profilPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Size, - ffi.UnsignedLong, - ffi.UnsignedInt, - ) - > - >('profil'); - late final _profil = _profilPtr - .asFunction, int, int, int)>(); - - int pthread_setugid_np(int arg0, int arg1) { - return _pthread_setugid_np(arg0, arg1); - } - late final _pthread_setugid_npPtr = - _lookup>( - 'pthread_setugid_np', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + ObjCBlock_ffiVoid_NSInputStream.fromPointer( + arg3, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _pthread_setugid_np = _pthread_setugid_npPtr - .asFunction(); - - int pthread_getugid_np(ffi.Pointer arg0, ffi.Pointer arg1) { - return _pthread_getugid_np(arg0, arg1); - } - - late final _pthread_getugid_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('pthread_getugid_np'); - late final _pthread_getugid_np = _pthread_getugid_npPtr - .asFunction, ffi.Pointer)>(); - int reboot(int arg0) { - return _reboot(arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + ObjCBlock_ffiVoid_NSInputStream.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_bklti2(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _rebootPtr = - _lookup>('reboot'); - late final _reboot = _rebootPtr.asFunction(); - - int revoke(ffi.Pointer arg0) { - return _revoke(arg0); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + ObjCBlock_ffiVoid_NSInputStream.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + ObjCBlock_ffiVoid_NSInputStream.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_bklti2( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _revokePtr = - _lookup)>>( - 'revoke', - ); - late final _revoke = _revokePtr - .asFunction)>(); - - int rcmd( - ffi.Pointer> arg0, - int arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _rcmd(arg0, arg1, arg2, arg3, arg4, arg5); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _rcmdPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('rcmd'); - late final _rcmd = _rcmdPtr - .asFunction< - int Function( - ffi.Pointer>, - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int rcmd_af( - ffi.Pointer> arg0, - int arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - int arg6, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _rcmd_af(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _rcmd_afPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('rcmd_af'); - late final _rcmd_af = _rcmd_afPtr - .asFunction< - int Function( - ffi.Pointer>, - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - int rresvport(ffi.Pointer arg0) { - return _rresvport(arg0); - } - - late final _rresvportPtr = - _lookup)>>( - 'rresvport', - ); - late final _rresvport = _rresvportPtr - .asFunction)>(); - - int rresvport_af(ffi.Pointer arg0, int arg1) { - return _rresvport_af(arg0, arg1); - } - - late final _rresvport_afPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('rresvport_af'); - late final _rresvport_af = _rresvport_afPtr - .asFunction, int)>(); - - int iruserok( - int arg0, - int arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - return _iruserok(arg0, arg1, arg2, arg3); - } - - late final _iruserokPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.UnsignedLong, - ffi.Int, - ffi.Pointer, - ffi.Pointer, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('iruserok'); - late final _iruserok = _iruserokPtr - .asFunction< - int Function(int, int, ffi.Pointer, ffi.Pointer) - >(); - - int iruserok_sa( + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, ffi.Pointer arg0, - int arg1, - int arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - return _iruserok_sa(arg0, arg1, arg2, arg3, arg4); - } - - late final _iruserok_saPtr = - _lookup< + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) > - >('iruserok_sa'); - late final _iruserok_sa = _iruserok_saPtr + >() .asFunction< - int Function( + void Function( ffi.Pointer, - int, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int ruserok( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - return _ruserok(arg0, arg1, arg2, arg3); - } - - late final _ruserokPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) - > - >('ruserok'); - late final _ruserok = _ruserokPtr - .asFunction< - int Function( - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - int setdomainname(ffi.Pointer arg0, int __namelen) { - return _setdomainname(arg0, __namelen); - } - - late final _setdomainnamePtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('setdomainname'); - late final _setdomainname = _setdomainnamePtr - .asFunction, int)>(); - - int setgroups(int arg0, ffi.Pointer arg1) { - return _setgroups(arg0, arg1); - } - - late final _setgroupsPtr = - _lookup< - ffi.NativeFunction)> - >('setgroups'); - late final _setgroups = _setgroupsPtr - .asFunction)>(); - - void sethostid(int arg0) { - return _sethostid(arg0); - } - - late final _sethostidPtr = - _lookup>('sethostid'); - late final _sethostid = _sethostidPtr.asFunction(); - - int sethostname(ffi.Pointer arg0, int __namelen) { - return _sethostname(arg0, __namelen); - } - - late final _sethostnamePtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sethostname'); - late final _sethostname = _sethostnamePtr - .asFunction, int)>(); - - int setlogin(ffi.Pointer arg0) { - return _setlogin(arg0); - } + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _setloginPtr = - _lookup)>>( - 'setlogin', +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, ); - late final _setlogin = _setloginPtr - .asFunction)>(); - - ffi.Pointer setmode(ffi.Pointer arg0) { - return _setmode(arg0); - } - - late final _setmodePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('setmode'); - late final _setmode = _setmodePtr - .asFunction Function(ffi.Pointer)>(); - - int setrgid(int arg0) { - return _setrgid(arg0); - } - - late final _setrgidPtr = _lookup>( - 'setrgid', - ); - late final _setrgid = _setrgidPtr.asFunction(); - - int setruid(int arg0) { - return _setruid(arg0); - } - - late final _setruidPtr = _lookup>( - 'setruid', - ); - late final _setruid = _setruidPtr.asFunction(); - - int setsgroups_np(int arg0, ffi.Pointer arg1) { - return _setsgroups_np(arg0, arg1); - } - - late final _setsgroups_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer) - > - >('setsgroups_np'); - late final _setsgroups_np = _setsgroups_npPtr - .asFunction)>(); - - void setusershell() { - return _setusershell(); - } - - late final _setusershellPtr = - _lookup>('setusershell'); - late final _setusershell = _setusershellPtr.asFunction(); - - int setwgroups_np(int arg0, ffi.Pointer arg1) { - return _setwgroups_np(arg0, arg1); - } - - late final _setwgroups_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer) - > - >('setwgroups_np'); - late final _setwgroups_np = _setwgroups_npPtr - .asFunction)>(); - - int strtofflags( - ffi.Pointer> arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - return _strtofflags(arg0, arg1, arg2); - } +} - late final _strtofflagsPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ) - > - >('strtofflags'); - late final _strtofflags = _strtofflagsPtr - .asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, +late final _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = + objc.registerName( + "URLSession:task:needNewBodyStreamFromOffset:completionHandler:", + ); +final _objc_msgSend_9cddqw = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, ) - >(); + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ) + >(); - int swapon(ffi.Pointer arg0) { - return _swapon(arg0); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, ffi.Int64, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + >(pointer, retain: retain, release: release); - late final _swaponPtr = - _lookup)>>( - 'swapon', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Pointer arg4, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _swapon = _swaponPtr - .asFunction)>(); - - int ttyslot() { - return _ttyslot(); - } - - late final _ttyslotPtr = _lookup>( - 'ttyslot', - ); - late final _ttyslot = _ttyslotPtr.asFunction(); - - int undelete(ffi.Pointer arg0) { - return _undelete(arg0); - } - late final _undeletePtr = - _lookup)>>( - 'undelete', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + arg3, + ObjCBlock_ffiVoid_NSInputStream.fromPointer( + arg4, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _undelete = _undeletePtr - .asFunction)>(); - int unwhiteout(ffi.Pointer arg0) { - return _unwhiteout(arg0); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3, + ObjCBlock_ffiVoid_NSInputStream.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_jyim80(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _unwhiteoutPtr = - _lookup)>>( - 'unwhiteout', - ); - late final _unwhiteout = _unwhiteoutPtr - .asFunction)>(); - - int syscall(int arg0) { - return _syscall(arg0); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3, + ObjCBlock_ffiVoid_NSInputStream.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3, + ObjCBlock_ffiVoid_NSInputStream.fromPointer( + arg4, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_jyim80( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _syscallPtr = - _lookup>('syscall'); - late final _syscall = _syscallPtr.asFunction(); - - int fgetattrlist( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int __attrBufSize, - int arg4, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, ) { - return _fgetattrlist(arg0, arg1, arg2, __attrBufSize, arg4); - } - - late final _fgetattrlistPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.UnsignedInt, - ) - > - >('fgetattrlist'); - late final _fgetattrlist = _fgetattrlistPtr - .asFunction< - int Function( - int, - ffi.Pointer, + (objc.getBlockClosure(block) + as void Function( ffi.Pointer, + ffi.Pointer, + ffi.Pointer, int, - int, - ) - >(); - - int fsetattrlist( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int __attrBufSize, - int arg4, - ) { - return _fsetattrlist(arg0, arg1, arg2, __attrBufSize, arg4); + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + objc.objectRelease(block.cast()); } - late final _fsetattrlistPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, - ffi.Size, - ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, ) - > - >('fsetattrlist'); - late final _fsetattrlist = _fsetattrlistPtr - .asFunction< - int Function( - int, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >(); - - int getattrlist( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int __attrBufSize, - int arg4, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, ) { - return _getattrlist(arg0, arg1, arg2, __attrBufSize, arg4); - } - - late final _getattrlistPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, + try { + (objc.getBlockClosure(block) + as void Function( ffi.Pointer, - ffi.Size, - ffi.UnsignedInt, - ) - > - >('getattrlist'); - late final _getattrlist = _getattrlistPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >(); - - int setattrlist( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int __attrBufSize, - int arg4, - ) { - return _setattrlist(arg0, arg1, arg2, __attrBufSize, arg4); + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _setattrlistPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Size, - ffi.UnsignedInt, - ) - > - >('setattrlist'); - late final _setattrlist = _setattrlistPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >(); - - int exchangedata( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ) { - return _exchangedata(arg0, arg1, arg2); - } - - late final _exchangedataPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, ) - > - >('exchangedata'); - late final _exchangedata = _exchangedataPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int getdirentriesattr( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int __attrBufSize, - ffi.Pointer arg4, - ffi.Pointer arg5, - ffi.Pointer arg6, - int arg7, - ) { - return _getdirentriesattr( - arg0, - arg1, - arg2, - __attrBufSize, - arg4, - arg5, - arg6, - arg7, - ); - } - - late final _getdirentriesattrPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, ) - > - >('getdirentriesattr'); - late final _getdirentriesattr = _getdirentriesattrPtr - .asFunction< - int Function( - int, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - - int searchfs( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, int arg3, - int arg4, - ffi.Pointer arg5, - ) { - return _searchfs(arg0, arg1, arg2, arg3, arg4, arg5); - } - - late final _searchfsPtr = - _lookup< + ffi.Pointer arg4, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Pointer arg4, ) > - >('searchfs'); - late final _searchfs = _searchfsPtr + >() .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, int, - ffi.Pointer, + ffi.Pointer, ) - >(); - - int fsctl( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, + >()(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, int arg3, - ) { - return _fsctl(arg0, arg1, arg2, arg3); - } - - late final _fsctlPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.UnsignedLong, + ffi.Pointer arg4, + ) => + (objc.getBlockClosure(block) + as void Function( ffi.Pointer, - ffi.UnsignedInt, - ) - > - >('fsctl'); - late final _fsctl = _fsctlPtr - .asFunction< - int Function(ffi.Pointer, int, ffi.Pointer, int) - >(); - - int ffsctl(int arg0, int arg1, ffi.Pointer arg2, int arg3) { - return _ffsctl(arg0, arg1, arg2, arg3); - } + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _ffsctlPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.UnsignedLong, +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, ffi.Int64, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( ffi.Pointer, - ffi.UnsignedInt, - ) - > - >('ffsctl'); - late final _ffsctl = _ffsctlPtr - .asFunction, int)>(); - - int fsync_volume_np(int arg0, int arg1) { - return _fsync_volume_np(arg0, arg1); - } - - late final _fsync_volume_npPtr = - _lookup>( - 'fsync_volume_np', - ); - late final _fsync_volume_np = _fsync_volume_npPtr - .asFunction(); - - int sync_volume_np(ffi.Pointer arg0, int arg1) { - return _sync_volume_np(arg0, arg1); - } - - late final _sync_volume_npPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sync_volume_np'); - late final _sync_volume_np = _sync_volume_npPtr - .asFunction, int)>(); - - late final ffi.Pointer _optreset = _lookup('optreset'); - - int get optreset => _optreset.value; - - set optreset(int value) => _optreset.value = value; - - int open(ffi.Pointer arg0, int arg1) { - return _open(arg0, arg1); - } - - late final _openPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('open'); - late final _open = _openPtr - .asFunction, int)>(); - - int openat(int arg0, ffi.Pointer arg1, int arg2) { - return _openat(arg0, arg1, arg2); - } - - late final _openatPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int) - > - >('openat'); - late final _openat = _openatPtr - .asFunction, int)>(); - - int creat(ffi.Pointer arg0, int arg1) { - return _creat(arg0, arg1); - } - - late final _creatPtr = - _lookup< - ffi.NativeFunction, mode_t)> - >('creat'); - late final _creat = _creatPtr - .asFunction, int)>(); - - int fcntl(int arg0, int arg1) { - return _fcntl(arg0, arg1); - } - - late final _fcntlPtr = - _lookup>('fcntl'); - late final _fcntl = _fcntlPtr.asFunction(); - - int openx_np(ffi.Pointer arg0, int arg1, filesec_t arg2) { - return _openx_np(arg0, arg1, arg2); - } - - late final _openx_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, filesec_t) - > - >('openx_np'); - late final _openx_np = _openx_npPtr - .asFunction, int, filesec_t)>(); - - int open_dprotected_np( - ffi.Pointer arg0, - int arg1, - int arg2, - int arg3, - ) { - return _open_dprotected_np(arg0, arg1, arg2, arg3); - } - - late final _open_dprotected_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int, ffi.Int) - > - >('open_dprotected_np'); - late final _open_dprotected_np = _open_dprotected_npPtr - .asFunction, int, int, int)>(); - - int openat_dprotected_np( - int arg0, - ffi.Pointer arg1, - int arg2, - int arg3, - int arg4, - ) { - return _openat_dprotected_np(arg0, arg1, arg2, arg3, arg4); - } - - late final _openat_dprotected_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Int, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, ) - > - >('openat_dprotected_np'); - late final _openat_dprotected_np = _openat_dprotected_npPtr - .asFunction, int, int, int)>(); - - int openat_authenticated_np( - int arg0, - ffi.Pointer arg1, - int arg2, + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, int arg3, - ) { - return _openat_authenticated_np(arg0, arg1, arg2, arg3); - } - - late final _openat_authenticated_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int, ffi.Int) - > - >('openat_authenticated_np'); - late final _openat_authenticated_np = _openat_authenticated_npPtr - .asFunction, int, int)>(); - - int flock(int arg0, int arg1) { - return _flock(arg0, arg1); - } - - late final _flockPtr = - _lookup>('flock'); - late final _flock = _flockPtr.asFunction(); - - filesec_t filesec_init() { - return _filesec_init(); - } - - late final _filesec_initPtr = - _lookup>('filesec_init'); - late final _filesec_init = _filesec_initPtr - .asFunction(); - - filesec_t filesec_dup(filesec_t arg0) { - return _filesec_dup(arg0); - } - - late final _filesec_dupPtr = - _lookup>('filesec_dup'); - late final _filesec_dup = _filesec_dupPtr - .asFunction(); - - void filesec_free(filesec_t arg0) { - return _filesec_free(arg0); - } - - late final _filesec_freePtr = - _lookup>('filesec_free'); - late final _filesec_free = _filesec_freePtr - .asFunction(); - - int filesec_get_property( - filesec_t arg0, - filesec_property_t arg1, - ffi.Pointer arg2, - ) { - return _filesec_get_property(arg0, arg1.value, arg2); - } - - late final _filesec_get_propertyPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(filesec_t, ffi.UnsignedInt, ffi.Pointer) - > - >('filesec_get_property'); - late final _filesec_get_property = _filesec_get_propertyPtr - .asFunction)>(); - - int filesec_query_property( - filesec_t arg0, - filesec_property_t arg1, - ffi.Pointer arg2, - ) { - return _filesec_query_property(arg0, arg1.value, arg2); - } - - late final _filesec_query_propertyPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(filesec_t, ffi.UnsignedInt, ffi.Pointer) - > - >('filesec_query_property'); - late final _filesec_query_property = _filesec_query_propertyPtr - .asFunction)>(); - - int filesec_set_property( - filesec_t arg0, - filesec_property_t arg1, - ffi.Pointer arg2, - ) { - return _filesec_set_property(arg0, arg1.value, arg2); - } - - late final _filesec_set_propertyPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(filesec_t, ffi.UnsignedInt, ffi.Pointer) - > - >('filesec_set_property'); - late final _filesec_set_property = _filesec_set_propertyPtr - .asFunction)>(); - - int filesec_unset_property(filesec_t arg0, filesec_property_t arg1) { - return _filesec_unset_property(arg0, arg1.value); - } - - late final _filesec_unset_propertyPtr = - _lookup>( - 'filesec_unset_property', - ); - late final _filesec_unset_property = _filesec_unset_propertyPtr - .asFunction(); - - int os_workgroup_copy_port( - Dartos_workgroup_t wg, - ffi.Pointer mach_port_out, - ) { - return _os_workgroup_copy_port(wg.ref.pointer, mach_port_out); - } - - late final _os_workgroup_copy_portPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(os_workgroup_t, ffi.Pointer) - > - >('os_workgroup_copy_port'); - late final _os_workgroup_copy_port = _os_workgroup_copy_portPtr - .asFunction)>(); - - Dartos_workgroup_t? os_workgroup_create_with_port( - ffi.Pointer name, - Dart__darwin_natural_t mach_port, - ) { - return _os_workgroup_create_with_port(name, mach_port).address == 0 - ? null - : OS_os_workgroup.fromPointer( - _os_workgroup_create_with_port(name, mach_port), - retain: false, - release: true, - ); - } - - late final _os_workgroup_create_with_portPtr = - _lookup< - ffi.NativeFunction< - os_workgroup_t Function(ffi.Pointer, mach_port_t) - > - >('os_workgroup_create_with_port'); - late final _os_workgroup_create_with_port = _os_workgroup_create_with_portPtr - .asFunction, int)>(); - - Dartos_workgroup_t? os_workgroup_create_with_workgroup( - ffi.Pointer name, - Dartos_workgroup_t wg, - ) { - return _os_workgroup_create_with_workgroup(name, wg.ref.pointer).address == - 0 - ? null - : OS_os_workgroup.fromPointer( - _os_workgroup_create_with_workgroup(name, wg.ref.pointer), - retain: false, - release: true, - ); - } - - late final _os_workgroup_create_with_workgroupPtr = - _lookup< - ffi.NativeFunction< - os_workgroup_t Function(ffi.Pointer, os_workgroup_t) - > - >('os_workgroup_create_with_workgroup'); - late final _os_workgroup_create_with_workgroup = - _os_workgroup_create_with_workgroupPtr - .asFunction< - os_workgroup_t Function(ffi.Pointer, os_workgroup_t) - >(); - - int os_workgroup_join( - Dartos_workgroup_t wg, - os_workgroup_join_token_t token_out, - ) { - return _os_workgroup_join(wg.ref.pointer, token_out); - } - - late final _os_workgroup_joinPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(os_workgroup_t, os_workgroup_join_token_t) - > - >('os_workgroup_join'); - late final _os_workgroup_join = _os_workgroup_joinPtr - .asFunction(); - - void os_workgroup_leave( - Dartos_workgroup_t wg, - os_workgroup_join_token_t token, - ) { - return _os_workgroup_leave(wg.ref.pointer, token); - } - - late final _os_workgroup_leavePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(os_workgroup_t, os_workgroup_join_token_t) - > - >('os_workgroup_leave'); - late final _os_workgroup_leave = _os_workgroup_leavePtr - .asFunction(); - - int os_workgroup_set_working_arena( - Dartos_workgroup_t wg, - ffi.Pointer arena, - int max_workers, - os_workgroup_working_arena_destructor_t destructor, - ) { - return _os_workgroup_set_working_arena( - wg.ref.pointer, - arena, - max_workers, - destructor, - ); - } - - late final _os_workgroup_set_working_arenaPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - os_workgroup_t, - ffi.Pointer, - ffi.Uint32, - os_workgroup_working_arena_destructor_t, - ) - > - >('os_workgroup_set_working_arena'); - late final _os_workgroup_set_working_arena = - _os_workgroup_set_working_arenaPtr + objc.ObjCBlock arg4, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Pointer arg4, + ) + > + >() .asFunction< - int Function( - os_workgroup_t, + void Function( + ffi.Pointer, ffi.Pointer, + ffi.Pointer, + ffi.Pointer, int, - os_workgroup_working_arena_destructor_t, - ) - >(); - - ffi.Pointer os_workgroup_get_working_arena( - Dartos_workgroup_t wg, - ffi.Pointer index_out, - ) { - return _os_workgroup_get_working_arena(wg.ref.pointer, index_out); - } - - late final _os_workgroup_get_working_arenaPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - os_workgroup_t, - ffi.Pointer, - ) - > - >('os_workgroup_get_working_arena'); - late final _os_workgroup_get_working_arena = - _os_workgroup_get_working_arenaPtr - .asFunction< - ffi.Pointer Function( - os_workgroup_t, - ffi.Pointer, + ffi.Pointer, ) - >(); - - void os_workgroup_cancel(Dartos_workgroup_t wg) { - return _os_workgroup_cancel(wg.ref.pointer); - } - - late final _os_workgroup_cancelPtr = - _lookup>( - 'os_workgroup_cancel', - ); - late final _os_workgroup_cancel = _os_workgroup_cancelPtr - .asFunction(); - - bool os_workgroup_testcancel(Dartos_workgroup_t wg) { - return _os_workgroup_testcancel(wg.ref.pointer); - } - - late final _os_workgroup_testcancelPtr = - _lookup>( - 'os_workgroup_testcancel', + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3, + arg4.ref.pointer, ); - late final _os_workgroup_testcancel = _os_workgroup_testcancelPtr - .asFunction(); - - int os_workgroup_max_parallel_threads( - Dartos_workgroup_t wg, - os_workgroup_mpt_attr_t attr, - ) { - return _os_workgroup_max_parallel_threads(wg.ref.pointer, attr); - } - - late final _os_workgroup_max_parallel_threadsPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(os_workgroup_t, os_workgroup_mpt_attr_t) - > - >('os_workgroup_max_parallel_threads'); - late final _os_workgroup_max_parallel_threads = - _os_workgroup_max_parallel_threadsPtr - .asFunction(); - - int os_workgroup_interval_start( - Dartos_workgroup_interval_t wg, - int start, - int deadline, - os_workgroup_interval_data_t data, - ) { - return _os_workgroup_interval_start(wg.ref.pointer, start, deadline, data); - } +} - late final _os_workgroup_interval_startPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - os_workgroup_interval_t, - ffi.Uint64, - ffi.Uint64, - os_workgroup_interval_data_t, - ) - > - >('os_workgroup_interval_start'); - late final _os_workgroup_interval_start = _os_workgroup_interval_startPtr - .asFunction< - int Function( - os_workgroup_interval_t, - int, - int, - os_workgroup_interval_data_t, +late final _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = + objc.registerName( + "URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:", + ); +final _objc_msgSend_1modw1b = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - >(); - - int os_workgroup_interval_update( - Dartos_workgroup_interval_t wg, - int deadline, - os_workgroup_interval_data_t data, - ) { - return _os_workgroup_interval_update(wg.ref.pointer, deadline, data); - } - - late final _os_workgroup_interval_updatePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - os_workgroup_interval_t, - ffi.Uint64, - os_workgroup_interval_data_t, - ) - > - >('os_workgroup_interval_update'); - late final _os_workgroup_interval_update = _os_workgroup_interval_updatePtr - .asFunction< - int Function(os_workgroup_interval_t, int, os_workgroup_interval_data_t) - >(); - - int os_workgroup_interval_finish( - Dartos_workgroup_interval_t wg, - os_workgroup_interval_data_t data, - ) { - return _os_workgroup_interval_finish(wg.ref.pointer, data); - } - - late final _os_workgroup_interval_finishPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - os_workgroup_interval_t, - os_workgroup_interval_data_t, - ) - > - >('os_workgroup_interval_finish'); - late final _os_workgroup_interval_finish = _os_workgroup_interval_finishPtr - .asFunction< - int Function(os_workgroup_interval_t, os_workgroup_interval_data_t) - >(); - - Dartos_workgroup_parallel_t? os_workgroup_parallel_create( - ffi.Pointer name, - os_workgroup_attr_t attr, - ) { - return _os_workgroup_parallel_create(name, attr).address == 0 - ? null - : OS_os_workgroup.fromPointer( - _os_workgroup_parallel_create(name, attr), - retain: false, - release: true, - ); - } + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ) + >(); - late final _os_workgroup_parallel_createPtr = - _lookup< - ffi.NativeFunction< - os_workgroup_parallel_t Function( - ffi.Pointer, - os_workgroup_attr_t, - ) - > - >('os_workgroup_parallel_create'); - late final _os_workgroup_parallel_create = _os_workgroup_parallel_createPtr - .asFunction< - os_workgroup_parallel_t Function( - ffi.Pointer, - os_workgroup_attr_t, +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64 { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - >(); - - int dispatch_time(int when, int delta) { - return _dispatch_time(when, delta); - } - - late final _dispatch_timePtr = - _lookup< - ffi.NativeFunction - >('dispatch_time'); - late final _dispatch_time = _dispatch_timePtr - .asFunction(); - - int dispatch_walltime(ffi.Pointer when, int delta) { - return _dispatch_walltime(when, delta); - } - - late final _dispatch_walltimePtr = - _lookup< - ffi.NativeFunction< - dispatch_time_t Function(ffi.Pointer, ffi.Int64) - > - >('dispatch_walltime'); - late final _dispatch_walltime = _dispatch_walltimePtr - .asFunction, int)>(); - - qos_class_t qos_class_self() { - return qos_class_t.fromValue(_qos_class_self()); - } - - late final _qos_class_selfPtr = - _lookup>('qos_class_self'); - late final _qos_class_self = _qos_class_selfPtr.asFunction(); - - qos_class_t qos_class_main() { - return qos_class_t.fromValue(_qos_class_main()); - } - - late final _qos_class_mainPtr = - _lookup>('qos_class_main'); - late final _qos_class_main = _qos_class_mainPtr.asFunction(); - - void dispatch_retain(Dartdispatch_object_t object) { - return _dispatch_retain(object.ref.pointer); - } + >(pointer, retain: retain, release: release); - late final _dispatch_retainPtr = - _lookup>( - 'dispatch_retain', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ffi.Int64 arg5, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _dispatch_retain = _dispatch_retainPtr - .asFunction(); - - void dispatch_release(Dartdispatch_object_t object) { - return _dispatch_release(object.ref.pointer); - } - late final _dispatch_releasePtr = - _lookup>( - 'dispatch_release', - ); - late final _dispatch_release = _dispatch_releasePtr - .asFunction(); - - ffi.Pointer dispatch_get_context(Dartdispatch_object_t object) { - return _dispatch_get_context(object.ref.pointer); - } - - late final _dispatch_get_contextPtr = - _lookup< - ffi.NativeFunction Function(dispatch_object_t)> - >('dispatch_get_context'); - late final _dispatch_get_context = _dispatch_get_contextPtr - .asFunction Function(dispatch_object_t)>(); - - void dispatch_set_context( - Dartdispatch_object_t object, - ffi.Pointer context, - ) { - return _dispatch_set_context(object.ref.pointer, context); - } - - late final _dispatch_set_contextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_object_t, ffi.Pointer) - > - >('dispatch_set_context'); - late final _dispatch_set_context = _dispatch_set_contextPtr - .asFunction)>(); - - void dispatch_set_finalizer_f( - Dartdispatch_object_t object, - dispatch_function_t finalizer, - ) { - return _dispatch_set_finalizer_f(object.ref.pointer, finalizer); - } - - late final _dispatch_set_finalizer_fPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_object_t, dispatch_function_t) - > - >('dispatch_set_finalizer_f'); - late final _dispatch_set_finalizer_f = _dispatch_set_finalizer_fPtr - .asFunction(); - - void dispatch_activate(Dartdispatch_object_t object) { - return _dispatch_activate(object.ref.pointer); - } - - late final _dispatch_activatePtr = - _lookup>( - 'dispatch_activate', - ); - late final _dispatch_activate = _dispatch_activatePtr - .asFunction(); - - void dispatch_suspend(Dartdispatch_object_t object) { - return _dispatch_suspend(object.ref.pointer); - } - - late final _dispatch_suspendPtr = - _lookup>( - 'dispatch_suspend', - ); - late final _dispatch_suspend = _dispatch_suspendPtr - .asFunction(); - - void dispatch_resume(Dartdispatch_object_t object) { - return _dispatch_resume(object.ref.pointer); - } - - late final _dispatch_resumePtr = - _lookup>( - 'dispatch_resume', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + int, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + arg3, + arg4, + arg5, + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _dispatch_resume = _dispatch_resumePtr - .asFunction(); - void dispatch_set_qos_class_floor( - Dartdispatch_object_t object, - qos_class_t qos_class, - int relative_priority, - ) { - return _dispatch_set_qos_class_floor( - object.ref.pointer, - qos_class.value, - relative_priority, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + int, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3, + arg4, + arg5, + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_h68abb(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_set_qos_class_floorPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_object_t, ffi.UnsignedInt, ffi.Int) - > - >('dispatch_set_qos_class_floor'); - late final _dispatch_set_qos_class_floor = _dispatch_set_qos_class_floorPtr - .asFunction(); - - int dispatch_wait(ffi.Pointer object, int timeout) { - return _dispatch_wait(object, timeout); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + int, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3, + arg4, + arg5, + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3, + arg4, + arg5, + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_h68abb( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_waitPtr = - _lookup< - ffi.NativeFunction< - ffi.IntPtr Function(ffi.Pointer, dispatch_time_t) - > - >('dispatch_wait'); - late final _dispatch_wait = _dispatch_waitPtr - .asFunction, int)>(); - - void dispatch_notify( - ffi.Pointer object, - Dartdispatch_object_t queue, - Dartdispatch_block_t notification_block, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, ) { - return _dispatch_notify( - object, - queue.ref.pointer, - notification_block.ref.pointer, - ); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + objc.objectRelease(block.cast()); } - late final _dispatch_notifyPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + _listenerCallable = + ffi.NativeCallable< ffi.Void Function( + ffi.Pointer, ffi.Pointer, - dispatch_object_t, - dispatch_block_t, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - > - >('dispatch_notify'); - late final _dispatch_notify = _dispatch_notifyPtr - .asFunction< - void Function( - ffi.Pointer, - dispatch_object_t, - dispatch_block_t, - ) - >(); - - void dispatch_cancel(ffi.Pointer object) { - return _dispatch_cancel(object); - } - - late final _dispatch_cancelPtr = - _lookup)>>( - 'dispatch_cancel', - ); - late final _dispatch_cancel = _dispatch_cancelPtr - .asFunction)>(); - - int dispatch_testcancel(ffi.Pointer object) { - return _dispatch_testcancel(object); - } - - late final _dispatch_testcancelPtr = - _lookup)>>( - 'dispatch_testcancel', - ); - late final _dispatch_testcancel = _dispatch_testcancelPtr - .asFunction)>(); - - void dispatch_debug( - Dartdispatch_object_t object, - ffi.Pointer message, - ) { - return _dispatch_debug(object.ref.pointer, message); - } - - late final _dispatch_debugPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_object_t, ffi.Pointer) - > - >('dispatch_debug'); - late final _dispatch_debug = _dispatch_debugPtr - .asFunction)>(); - - void dispatch_debugv( - Dartdispatch_object_t object, - ffi.Pointer message, - va_list ap, - ) { - return _dispatch_debugv(object.ref.pointer, message, ap); - } - - late final _dispatch_debugvPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_object_t, ffi.Pointer, va_list) - > - >('dispatch_debugv'); - late final _dispatch_debugv = _dispatch_debugvPtr - .asFunction< - void Function(dispatch_object_t, ffi.Pointer, va_list) - >(); - - void dispatch_async(Dartdispatch_queue_t queue, Dartdispatch_block_t block) { - return _dispatch_async(queue.ref.pointer, block.ref.pointer); - } - - late final _dispatch_asyncPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_queue_t, dispatch_block_t) - > - >('dispatch_async'); - late final _dispatch_async = _dispatch_asyncPtr - .asFunction(); - - void dispatch_async_f( - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, ) { - return _dispatch_async_f(queue.ref.pointer, context, work); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _dispatch_async_fPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_queue_t, + ffi.Pointer, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - > - >('dispatch_async_f'); - late final _dispatch_async_f = _dispatch_async_fPtr - .asFunction< - void Function( - dispatch_queue_t, - ffi.Pointer, - dispatch_function_t, - ) - >(); - - void dispatch_sync(Dartdispatch_queue_t queue, Dartdispatch_block_t block) { - return _dispatch_sync(queue.ref.pointer, block.ref.pointer); - } - - late final _dispatch_syncPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_queue_t, dispatch_block_t) - > - >('dispatch_sync'); - late final _dispatch_sync = _dispatch_syncPtr - .asFunction(); - - void dispatch_sync_f( - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, - ) { - return _dispatch_sync_f(queue.ref.pointer, context, work); - } - - late final _dispatch_sync_fPtr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_queue_t, + ffi.Pointer, + ffi.Pointer, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - > - >('dispatch_sync_f'); - late final _dispatch_sync_f = _dispatch_sync_fPtr - .asFunction< - void Function( - dispatch_queue_t, - ffi.Pointer, - dispatch_function_t, - ) - >(); - - void dispatch_async_and_wait( - Dartdispatch_queue_t queue, - Dartdispatch_block_t block, - ) { - return _dispatch_async_and_wait(queue.ref.pointer, block.ref.pointer); - } - - late final _dispatch_async_and_waitPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_queue_t, dispatch_block_t) - > - >('dispatch_async_and_wait'); - late final _dispatch_async_and_wait = _dispatch_async_and_waitPtr - .asFunction(); - - void dispatch_async_and_wait_f( - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, - ) { - return _dispatch_async_and_wait_f(queue.ref.pointer, context, work); - } - - late final _dispatch_async_and_wait_fPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - dispatch_queue_t, - ffi.Pointer, - dispatch_function_t, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ffi.Int64 arg5, ) > - >('dispatch_async_and_wait_f'); - late final _dispatch_async_and_wait_f = _dispatch_async_and_wait_fPtr + >() .asFunction< void Function( - dispatch_queue_t, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, ) - >(); - - void dispatch_apply( - int iterations, - Dartdispatch_queue_t? queue, - objc.ObjCBlock block, - ) { - return _dispatch_apply( - iterations, - queue?.ref.pointer ?? ffi.nullptr, - block.ref.pointer, - ); - } - - late final _dispatch_applyPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Size, - dispatch_queue_t, - ffi.Pointer, - ) - > - >('dispatch_apply'); - late final _dispatch_apply = _dispatch_applyPtr - .asFunction< - void Function(int, dispatch_queue_t, ffi.Pointer) - >(); - - void dispatch_apply_f( - int iterations, - Dartdispatch_queue_t? queue, - ffi.Pointer context, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer context, ffi.Size iteration) - > - > - work, - ) { - return _dispatch_apply_f( - iterations, - queue?.ref.pointer ?? ffi.nullptr, - context, - work, - ); - } + >()(arg0, arg1, arg2, arg3, arg4, arg5); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >(_closureTrampoline) + .cast(); +} - late final _dispatch_apply_fPtr = - _lookup< - ffi.NativeFunction< +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64$CallExtension + on + objc.ObjCBlock< ffi.Void Function( - ffi.Size, - dispatch_queue_t, ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer context, - ffi.Size iteration, - ) - > - >, - ) - > - >('dispatch_apply_f'); - late final _dispatch_apply_f = _dispatch_apply_fPtr - .asFunction< - void Function( - int, - dispatch_queue_t, - ffi.Pointer, - ffi.Pointer< + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => + ref.pointer.ref.invoke + .cast< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer context, - ffi.Size iteration, + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ffi.Int64 arg5, ) > - >, - ) - >(); - - Dartdispatch_queue_t dispatch_get_current_queue() { - return objc.NSObject.fromPointer( - _dispatch_get_current_queue(), - retain: true, - release: true, - ); - } - - late final _dispatch_get_current_queuePtr = - _lookup>( - 'dispatch_get_current_queue', + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3, + arg4, + arg5, ); - late final _dispatch_get_current_queue = _dispatch_get_current_queuePtr - .asFunction(); - - late final ffi.Pointer __dispatch_main_q = - _lookup('_dispatch_main_q'); - - ffi.Pointer get _dispatch_main_q => __dispatch_main_q; +} - Dartdispatch_queue_global_t dispatch_get_global_queue( - int identifier, - int flags, - ) { - return objc.NSObject.fromPointer( - _dispatch_get_global_queue(identifier, flags), - retain: true, - release: true, - ); - } +late final _sel_URLSession_task_didReceiveInformationalResponse_ = objc + .registerName("URLSession:task:didReceiveInformationalResponse:"); - late final _dispatch_get_global_queuePtr = - _lookup< - ffi.NativeFunction< - dispatch_queue_global_t Function(ffi.IntPtr, ffi.UintPtr) - > - >('dispatch_get_global_queue'); - late final _dispatch_get_global_queue = _dispatch_get_global_queuePtr - .asFunction(); +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSHTTPURLResponse)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + >(pointer, retain: retain, release: release); - late final ffi.Pointer - __dispatch_queue_attr_concurrent = _lookup( - '_dispatch_queue_attr_concurrent', - ); + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - ffi.Pointer get _dispatch_queue_attr_concurrent => - __dispatch_queue_attr_concurrent; + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + NSHTTPURLResponse.fromPointer(arg3, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - Dartdispatch_queue_attr_t dispatch_queue_attr_make_initially_inactive( - Dartdispatch_queue_attr_t? attr, - ) { - return objc.NSObject.fromPointer( - _dispatch_queue_attr_make_initially_inactive( - attr?.ref.pointer ?? ffi.nullptr, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), ), - retain: true, - release: true, + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_queue_attr_make_initially_inactivePtr = - _lookup< - ffi.NativeFunction< - dispatch_queue_attr_t Function(dispatch_queue_attr_t) - > - >('dispatch_queue_attr_make_initially_inactive'); - late final _dispatch_queue_attr_make_initially_inactive = - _dispatch_queue_attr_make_initially_inactivePtr - .asFunction(); - - Dartdispatch_queue_attr_t dispatch_queue_attr_make_with_autorelease_frequency( - Dartdispatch_queue_attr_t? attr, - dispatch_autorelease_frequency_t frequency, - ) { - return objc.NSObject.fromPointer( - _dispatch_queue_attr_make_with_autorelease_frequency( - attr?.ref.pointer ?? ffi.nullptr, - frequency.value, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), ), - retain: true, - release: true, + keepIsolateAlive, ); - } - - late final _dispatch_queue_attr_make_with_autorelease_frequencyPtr = - _lookup< - ffi.NativeFunction< - dispatch_queue_attr_t Function( - dispatch_queue_attr_t, - ffi.UnsignedLong, - ) - > - >('dispatch_queue_attr_make_with_autorelease_frequency'); - late final _dispatch_queue_attr_make_with_autorelease_frequency = - _dispatch_queue_attr_make_with_autorelease_frequencyPtr - .asFunction< - dispatch_queue_attr_t Function(dispatch_queue_attr_t, int) - >(); - - Dartdispatch_queue_attr_t dispatch_queue_attr_make_with_qos_class( - Dartdispatch_queue_attr_t? attr, - qos_class_t qos_class, - int relative_priority, - ) { - return objc.NSObject.fromPointer( - _dispatch_queue_attr_make_with_qos_class( - attr?.ref.pointer ?? ffi.nullptr, - qos_class.value, - relative_priority, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), ), - retain: true, - release: true, + keepIsolateAlive, ); - } - - late final _dispatch_queue_attr_make_with_qos_classPtr = - _lookup< - ffi.NativeFunction< - dispatch_queue_attr_t Function( - dispatch_queue_attr_t, - ffi.UnsignedInt, - ffi.Int, - ) - > - >('dispatch_queue_attr_make_with_qos_class'); - late final _dispatch_queue_attr_make_with_qos_class = - _dispatch_queue_attr_make_with_qos_classPtr - .asFunction< - dispatch_queue_attr_t Function(dispatch_queue_attr_t, int, int) - >(); - - Dartdispatch_queue_t dispatch_queue_create_with_target( - ffi.Pointer label, - Dartdispatch_queue_attr_t? attr, - Dartdispatch_queue_t? target, - ) { - return objc.NSObject.fromPointer( - _dispatch_queue_create_with_target( - label, - attr?.ref.pointer ?? ffi.nullptr, - target?.ref.pointer ?? ffi.nullptr, - ), - retain: false, - release: true, + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + raw, + rawListener, + objc.objCContext, ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_queue_create_with_targetPtr = - _lookup< - ffi.NativeFunction< - dispatch_queue_t Function( - ffi.Pointer, - dispatch_queue_attr_t, - dispatch_queue_t, - ) - > - >('dispatch_queue_create_with_target'); - late final _dispatch_queue_create_with_target = - _dispatch_queue_create_with_targetPtr - .asFunction< - dispatch_queue_t Function( - ffi.Pointer, - dispatch_queue_attr_t, - dispatch_queue_t, - ) - >(); - - Dartdispatch_queue_t dispatch_queue_create( - ffi.Pointer label, - Dartdispatch_queue_attr_t? attr, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return objc.NSObject.fromPointer( - _dispatch_queue_create(label, attr?.ref.pointer ?? ffi.nullptr), - retain: false, - release: true, - ); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _dispatch_queue_createPtr = - _lookup< - ffi.NativeFunction< - dispatch_queue_t Function( - ffi.Pointer, - dispatch_queue_attr_t, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_queue_create'); - late final _dispatch_queue_create = _dispatch_queue_createPtr - .asFunction< - dispatch_queue_t Function(ffi.Pointer, dispatch_queue_attr_t) - >(); - - ffi.Pointer dispatch_queue_get_label(Dartdispatch_queue_t? queue) { - return _dispatch_queue_get_label(queue?.ref.pointer ?? ffi.nullptr); - } - - late final _dispatch_queue_get_labelPtr = - _lookup< - ffi.NativeFunction Function(dispatch_queue_t)> - >('dispatch_queue_get_label'); - late final _dispatch_queue_get_label = _dispatch_queue_get_labelPtr - .asFunction Function(dispatch_queue_t)>(); - - qos_class_t dispatch_queue_get_qos_class( - Dartdispatch_queue_t queue, - ffi.Pointer relative_priority_ptr, - ) { - return qos_class_t.fromValue( - _dispatch_queue_get_qos_class(queue.ref.pointer, relative_priority_ptr), - ); - } - - late final _dispatch_queue_get_qos_classPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(dispatch_queue_t, ffi.Pointer) - > - >('dispatch_queue_get_qos_class'); - late final _dispatch_queue_get_qos_class = _dispatch_queue_get_qos_classPtr - .asFunction)>(); - - void dispatch_set_target_queue( - Dartdispatch_object_t object, - Dartdispatch_queue_t? queue, - ) { - return _dispatch_set_target_queue( - object.ref.pointer, - queue?.ref.pointer ?? ffi.nullptr, - ); - } - - late final _dispatch_set_target_queuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_object_t, dispatch_queue_t) - > - >('dispatch_set_target_queue'); - late final _dispatch_set_target_queue = _dispatch_set_target_queuePtr - .asFunction(); - - void dispatch_main() { - return _dispatch_main(); - } - - late final _dispatch_mainPtr = - _lookup>('dispatch_main'); - late final _dispatch_main = _dispatch_mainPtr.asFunction(); - - void dispatch_after( - Dartdispatch_time_t when, - Dartdispatch_queue_t queue, - Dartdispatch_block_t block, - ) { - return _dispatch_after(when, queue.ref.pointer, block.ref.pointer); - } - - late final _dispatch_afterPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_time_t, dispatch_queue_t, dispatch_block_t) - > - >('dispatch_after'); - late final _dispatch_after = _dispatch_afterPtr - .asFunction(); - - void dispatch_after_f( - Dartdispatch_time_t when, - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _dispatch_after_f(when, queue.ref.pointer, context, work); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _dispatch_after_fPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_time_t, - dispatch_queue_t, + ffi.Pointer, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_after_f'); - late final _dispatch_after_f = _dispatch_after_fPtr - .asFunction< - void Function( - int, - dispatch_queue_t, - ffi.Pointer, - dispatch_function_t, - ) - >(); - - void dispatch_barrier_async( - Dartdispatch_queue_t queue, - Dartdispatch_block_t block, - ) { - return _dispatch_barrier_async(queue.ref.pointer, block.ref.pointer); - } - - late final _dispatch_barrier_asyncPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_queue_t, dispatch_block_t) - > - >('dispatch_barrier_async'); - late final _dispatch_barrier_async = _dispatch_barrier_asyncPtr - .asFunction(); - - void dispatch_barrier_async_f( - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, - ) { - return _dispatch_barrier_async_f(queue.ref.pointer, context, work); - } - - late final _dispatch_barrier_async_fPtr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_queue_t, + ffi.Pointer, + ffi.Pointer, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_barrier_async_f'); - late final _dispatch_barrier_async_f = _dispatch_barrier_async_fPtr - .asFunction< - void Function( - dispatch_queue_t, - ffi.Pointer, - dispatch_function_t, - ) - >(); - - void dispatch_barrier_sync( - Dartdispatch_queue_t queue, - Dartdispatch_block_t block, - ) { - return _dispatch_barrier_sync(queue.ref.pointer, block.ref.pointer); - } - - late final _dispatch_barrier_syncPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_queue_t, dispatch_block_t) - > - >('dispatch_barrier_sync'); - late final _dispatch_barrier_sync = _dispatch_barrier_syncPtr - .asFunction(); - - void dispatch_barrier_sync_f( - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, - ) { - return _dispatch_barrier_sync_f(queue.ref.pointer, context, work); - } - - late final _dispatch_barrier_sync_fPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - dispatch_queue_t, - ffi.Pointer, - dispatch_function_t, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) > - >('dispatch_barrier_sync_f'); - late final _dispatch_barrier_sync_f = _dispatch_barrier_sync_fPtr + >() .asFunction< void Function( - dispatch_queue_t, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - void dispatch_barrier_async_and_wait( - Dartdispatch_queue_t queue, - Dartdispatch_block_t block, - ) { - return _dispatch_barrier_async_and_wait( - queue.ref.pointer, - block.ref.pointer, - ); - } - - late final _dispatch_barrier_async_and_waitPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_queue_t, dispatch_block_t) - > - >('dispatch_barrier_async_and_wait'); - late final _dispatch_barrier_async_and_wait = - _dispatch_barrier_async_and_waitPtr - .asFunction(); - - void dispatch_barrier_async_and_wait_f( - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, - ) { - return _dispatch_barrier_async_and_wait_f(queue.ref.pointer, context, work); - } + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _dispatch_barrier_async_and_wait_fPtr = - _lookup< - ffi.NativeFunction< +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSHTTPURLResponse)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse$CallExtension + on + objc.ObjCBlock< ffi.Void Function( - dispatch_queue_t, ffi.Pointer, - dispatch_function_t, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, ) - > - >('dispatch_barrier_async_and_wait_f'); - late final _dispatch_barrier_async_and_wait_f = - _dispatch_barrier_async_and_wait_fPtr + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() .asFunction< void Function( - dispatch_queue_t, + ffi.Pointer, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, + ); +} - void dispatch_queue_set_specific( - Dartdispatch_queue_t queue, - ffi.Pointer key, - ffi.Pointer context, - dispatch_function_t destructor, - ) { - return _dispatch_queue_set_specific( - queue.ref.pointer, - key, - context, - destructor, +/// WARNING: NSURLSessionTaskMetrics is a stub. To generate bindings for this class, include +/// NSURLSessionTaskMetrics in your config's objc-interfaces list. +/// +/// NSURLSessionTaskMetrics +extension type NSURLSessionTaskMetrics._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [NSURLSessionTaskMetrics] that points to the same underlying object as [other]. + NSURLSessionTaskMetrics.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSURLSessionTaskMetrics', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0)), ); } - late final _dispatch_queue_set_specificPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - dispatch_queue_t, - ffi.Pointer, - ffi.Pointer, - dispatch_function_t, - ) - > - >('dispatch_queue_set_specific'); - late final _dispatch_queue_set_specific = _dispatch_queue_set_specificPtr - .asFunction< - void Function( - dispatch_queue_t, - ffi.Pointer, - ffi.Pointer, - dispatch_function_t, - ) - >(); - - ffi.Pointer dispatch_queue_get_specific( - Dartdispatch_queue_t queue, - ffi.Pointer key, - ) { - return _dispatch_queue_get_specific(queue.ref.pointer, key); - } - - late final _dispatch_queue_get_specificPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - dispatch_queue_t, - ffi.Pointer, - ) - > - >('dispatch_queue_get_specific'); - late final _dispatch_queue_get_specific = _dispatch_queue_get_specificPtr - .asFunction< - ffi.Pointer Function(dispatch_queue_t, ffi.Pointer) - >(); - - ffi.Pointer dispatch_get_specific(ffi.Pointer key) { - return _dispatch_get_specific(key); - } - - late final _dispatch_get_specificPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('dispatch_get_specific'); - late final _dispatch_get_specific = _dispatch_get_specificPtr - .asFunction Function(ffi.Pointer)>(); - - void dispatch_assert_queue(Dartdispatch_queue_t queue) { - return _dispatch_assert_queue(queue.ref.pointer); - } - - late final _dispatch_assert_queuePtr = - _lookup>( - 'dispatch_assert_queue', - ); - late final _dispatch_assert_queue = _dispatch_assert_queuePtr - .asFunction(); - - void dispatch_assert_queue_barrier(Dartdispatch_queue_t queue) { - return _dispatch_assert_queue_barrier(queue.ref.pointer); + /// Constructs a [NSURLSessionTaskMetrics] that wraps the given raw object pointer. + NSURLSessionTaskMetrics.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionTaskMetrics', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0)), + ); } +} - late final _dispatch_assert_queue_barrierPtr = - _lookup>( - 'dispatch_assert_queue_barrier', - ); - late final _dispatch_assert_queue_barrier = _dispatch_assert_queue_barrierPtr - .asFunction(); +late final _sel_URLSession_task_didFinishCollectingMetrics_ = objc.registerName( + "URLSession:task:didFinishCollectingMetrics:", +); - void dispatch_assert_queue_not(Dartdispatch_queue_t queue) { - return _dispatch_assert_queue_not(queue.ref.pointer); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + >(pointer, retain: retain, release: release); - late final _dispatch_assert_queue_notPtr = - _lookup>( - 'dispatch_assert_queue_not', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _dispatch_assert_queue_not = _dispatch_assert_queue_notPtr - .asFunction(); - - int dispatch_allow_send_signals(int preserve_signum) { - return _dispatch_allow_send_signals(preserve_signum); - } - late final _dispatch_allow_send_signalsPtr = - _lookup>( - 'dispatch_allow_send_signals', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + NSURLSessionTaskMetrics.fromPointer( + arg3, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _dispatch_allow_send_signals = _dispatch_allow_send_signalsPtr - .asFunction(); - Dartdispatch_block_t dispatch_block_create( - int flags, - Dartdispatch_block_t block, - ) { - return ObjCBlock_ffiVoid.fromPointer( - _dispatch_block_create(flags, block.ref.pointer), - retain: false, - release: true, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionTaskMetrics.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_block_createPtr = - _lookup< - ffi.NativeFunction< - dispatch_block_t Function(ffi.UnsignedLong, dispatch_block_t) - > - >('dispatch_block_create'); - late final _dispatch_block_create = _dispatch_block_createPtr - .asFunction(); - - Dartdispatch_block_t dispatch_block_create_with_qos_class( - int flags, - qos_class_t qos_class, - int relative_priority, - Dartdispatch_block_t block, - ) { - return ObjCBlock_ffiVoid.fromPointer( - _dispatch_block_create_with_qos_class( - flags, - qos_class.value, - relative_priority, - block.ref.pointer, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionTaskMetrics.fromPointer(arg3, retain: false, release: true), ), - retain: false, - release: true, + keepIsolateAlive, ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + NSURLSessionTaskMetrics.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_block_create_with_qos_classPtr = - _lookup< - ffi.NativeFunction< - dispatch_block_t Function( - ffi.UnsignedLong, - ffi.UnsignedInt, - ffi.Int, - dispatch_block_t, - ) - > - >('dispatch_block_create_with_qos_class'); - late final _dispatch_block_create_with_qos_class = - _dispatch_block_create_with_qos_classPtr - .asFunction< - dispatch_block_t Function(int, int, int, dispatch_block_t) - >(); - - void dispatch_block_perform(int flags, Dartdispatch_block_t block) { - return _dispatch_block_perform(flags, block.ref.pointer); - } - - late final _dispatch_block_performPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.UnsignedLong, dispatch_block_t) - > - >('dispatch_block_perform'); - late final _dispatch_block_perform = _dispatch_block_performPtr - .asFunction(); - - int dispatch_block_wait( - Dartdispatch_block_t block, - Dartdispatch_time_t timeout, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _dispatch_block_wait(block.ref.pointer, timeout); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _dispatch_block_waitPtr = - _lookup< - ffi.NativeFunction< - ffi.IntPtr Function(dispatch_block_t, dispatch_time_t) - > - >('dispatch_block_wait'); - late final _dispatch_block_wait = _dispatch_block_waitPtr - .asFunction(); - - void dispatch_block_notify( - Dartdispatch_block_t block, - Dartdispatch_queue_t queue, - Dartdispatch_block_t notification_block, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _dispatch_block_notify( - block.ref.pointer, - queue.ref.pointer, - notification_block.ref.pointer, - ); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _dispatch_block_notifyPtr = - _lookup< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - dispatch_block_t, - dispatch_queue_t, - dispatch_block_t, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) > - >('dispatch_block_notify'); - late final _dispatch_block_notify = _dispatch_block_notifyPtr + >() .asFunction< - void Function(dispatch_block_t, dispatch_queue_t, dispatch_block_t) - >(); - - void dispatch_block_cancel(Dartdispatch_block_t block) { - return _dispatch_block_cancel(block.ref.pointer); - } - - late final _dispatch_block_cancelPtr = - _lookup>( - 'dispatch_block_cancel', - ); - late final _dispatch_block_cancel = _dispatch_block_cancelPtr - .asFunction(); - - int dispatch_block_testcancel(Dartdispatch_block_t block) { - return _dispatch_block_testcancel(block.ref.pointer); - } + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _dispatch_block_testcancelPtr = - _lookup>( - 'dispatch_block_testcancel', +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, ); - late final _dispatch_block_testcancel = _dispatch_block_testcancelPtr - .asFunction(); - - late final ffi.Pointer _KERNEL_SECURITY_TOKEN = - _lookup('KERNEL_SECURITY_TOKEN'); - - security_token_t get KERNEL_SECURITY_TOKEN => _KERNEL_SECURITY_TOKEN.ref; - - late final ffi.Pointer _KERNEL_AUDIT_TOKEN = - _lookup('KERNEL_AUDIT_TOKEN'); - - audit_token_t get KERNEL_AUDIT_TOKEN => _KERNEL_AUDIT_TOKEN.ref; +} - int mach_msg_overwrite( - ffi.Pointer msg, - int option, - int send_size, - int rcv_size, - int rcv_name, - int timeout, - int notify, - ffi.Pointer rcv_msg, - int rcv_limit, - ) { - return _mach_msg_overwrite( - msg, - option, - send_size, - rcv_size, - rcv_name, - timeout, - notify, - rcv_msg, - rcv_limit, - ); - } +late final _sel_URLSession_task_didCompleteWithError_ = objc.registerName( + "URLSession:task:didCompleteWithError:", +); - late final _mach_msg_overwritePtr = - _lookup< - ffi.NativeFunction< - mach_msg_return_t Function( - ffi.Pointer, - mach_msg_option_t, - mach_msg_size_t, - mach_msg_size_t, - mach_port_name_t, - mach_msg_timeout_t, - mach_port_name_t, - ffi.Pointer, - mach_msg_size_t, - ) - > - >('mach_msg_overwrite'); - late final _mach_msg_overwrite = _mach_msg_overwritePtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - int, - int, - int, - int, - ffi.Pointer, - int, +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, objc.NSError?)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, ) - >(); - - int mach_msg( - ffi.Pointer msg, - int option, - int send_size, - int rcv_size, - int rcv_name, - int timeout, - int notify, - ) { - return _mach_msg( - msg, - option, - send_size, - rcv_size, - rcv_name, - timeout, - notify, - ); - } + >(pointer, retain: retain, release: release); - late final _mach_msgPtr = - _lookup< - ffi.NativeFunction< - mach_msg_return_t Function( - ffi.Pointer, - mach_msg_option_t, - mach_msg_size_t, - mach_msg_size_t, - mach_port_name_t, - mach_msg_timeout_t, - mach_port_name_t, - ) - > - >('mach_msg'); - late final _mach_msg = _mach_msgPtr - .asFunction< - int Function( - ffi.Pointer, - int, - int, - int, - int, - int, - int, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) - >(); - - int mach_voucher_deallocate(int voucher) { - return _mach_voucher_deallocate(voucher); - } - - late final _mach_voucher_deallocatePtr = - _lookup>( - 'mach_voucher_deallocate', + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _mach_voucher_deallocate = _mach_voucher_deallocatePtr - .asFunction(); - - late final ffi.Pointer - __dispatch_source_type_data_add = _lookup( - '_dispatch_source_type_data_add', - ); - - ffi.Pointer get _dispatch_source_type_data_add => - __dispatch_source_type_data_add; - - late final ffi.Pointer - __dispatch_source_type_data_or = _lookup( - '_dispatch_source_type_data_or', - ); - - ffi.Pointer get _dispatch_source_type_data_or => - __dispatch_source_type_data_or; - - late final ffi.Pointer - __dispatch_source_type_data_replace = _lookup( - '_dispatch_source_type_data_replace', - ); - - ffi.Pointer get _dispatch_source_type_data_replace => - __dispatch_source_type_data_replace; - - late final ffi.Pointer - __dispatch_source_type_mach_send = _lookup( - '_dispatch_source_type_mach_send', - ); - - ffi.Pointer get _dispatch_source_type_mach_send => - __dispatch_source_type_mach_send; - - late final ffi.Pointer - __dispatch_source_type_mach_recv = _lookup( - '_dispatch_source_type_mach_recv', - ); - - ffi.Pointer get _dispatch_source_type_mach_recv => - __dispatch_source_type_mach_recv; - - late final ffi.Pointer - __dispatch_source_type_memorypressure = _lookup( - '_dispatch_source_type_memorypressure', - ); - ffi.Pointer - get _dispatch_source_type_memorypressure => - __dispatch_source_type_memorypressure; - - late final ffi.Pointer __dispatch_source_type_proc = - _lookup('_dispatch_source_type_proc'); - - ffi.Pointer get _dispatch_source_type_proc => - __dispatch_source_type_proc; - - late final ffi.Pointer __dispatch_source_type_read = - _lookup('_dispatch_source_type_read'); - - ffi.Pointer get _dispatch_source_type_read => - __dispatch_source_type_read; - - late final ffi.Pointer __dispatch_source_type_signal = - _lookup('_dispatch_source_type_signal'); - - ffi.Pointer get _dispatch_source_type_signal => - __dispatch_source_type_signal; - - late final ffi.Pointer __dispatch_source_type_timer = - _lookup('_dispatch_source_type_timer'); - - ffi.Pointer get _dispatch_source_type_timer => - __dispatch_source_type_timer; - - late final ffi.Pointer __dispatch_source_type_vnode = - _lookup('_dispatch_source_type_vnode'); - - ffi.Pointer get _dispatch_source_type_vnode => - __dispatch_source_type_vnode; - - late final ffi.Pointer __dispatch_source_type_write = - _lookup('_dispatch_source_type_write'); - - ffi.Pointer get _dispatch_source_type_write => - __dispatch_source_type_write; + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + arg3.address == 0 + ? null + : objc.NSError.fromPointer(arg3, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - Dartdispatch_source_t dispatch_source_create( - dispatch_source_type_t type, - int handle, - int mask, - Dartdispatch_queue_t? queue, - ) { - return objc.NSObject.fromPointer( - _dispatch_source_create( - type, - handle, - mask, - queue?.ref.pointer ?? ffi.nullptr, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3.address == 0 + ? null + : objc.NSError.fromPointer(arg3, retain: false, release: true), ), - retain: false, - release: true, + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_source_createPtr = - _lookup< - ffi.NativeFunction< - dispatch_source_t Function( - dispatch_source_type_t, - ffi.UintPtr, - ffi.UintPtr, - dispatch_queue_t, - ) - > - >('dispatch_source_create'); - late final _dispatch_source_create = _dispatch_source_createPtr - .asFunction< - dispatch_source_t Function( - dispatch_source_type_t, - int, - int, - dispatch_queue_t, - ) - >(); - - void dispatch_source_set_event_handler( - Dartdispatch_source_t source, - Dartdispatch_block_t? handler, - ) { - return _dispatch_source_set_event_handler( - source.ref.pointer, - handler?.ref.pointer ?? ffi.nullptr, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3.address == 0 + ? null + : objc.NSError.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, ); - } - - late final _dispatch_source_set_event_handlerPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_source_t, dispatch_block_t) - > - >('dispatch_source_set_event_handler'); - late final _dispatch_source_set_event_handler = - _dispatch_source_set_event_handlerPtr - .asFunction(); - - void dispatch_source_set_event_handler_f( - Dartdispatch_source_t source, - dispatch_function_t handler, - ) { - return _dispatch_source_set_event_handler_f(source.ref.pointer, handler); - } - - late final _dispatch_source_set_event_handler_fPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_source_t, dispatch_function_t) - > - >('dispatch_source_set_event_handler_f'); - late final _dispatch_source_set_event_handler_f = - _dispatch_source_set_event_handler_fPtr - .asFunction(); - - void dispatch_source_set_cancel_handler( - Dartdispatch_source_t source, - Dartdispatch_block_t? handler, - ) { - return _dispatch_source_set_cancel_handler( - source.ref.pointer, - handler?.ref.pointer ?? ffi.nullptr, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionTask.fromPointer(arg2, retain: false, release: true), + arg3.address == 0 + ? null + : objc.NSError.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_source_set_cancel_handlerPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_source_t, dispatch_block_t) - > - >('dispatch_source_set_cancel_handler'); - late final _dispatch_source_set_cancel_handler = - _dispatch_source_set_cancel_handlerPtr - .asFunction(); - - void dispatch_source_set_cancel_handler_f( - Dartdispatch_source_t source, - dispatch_function_t handler, - ) { - return _dispatch_source_set_cancel_handler_f(source.ref.pointer, handler); - } - - late final _dispatch_source_set_cancel_handler_fPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_source_t, dispatch_function_t) - > - >('dispatch_source_set_cancel_handler_f'); - late final _dispatch_source_set_cancel_handler_f = - _dispatch_source_set_cancel_handler_fPtr - .asFunction(); - - void dispatch_source_cancel(Dartdispatch_source_t source) { - return _dispatch_source_cancel(source.ref.pointer); - } - - late final _dispatch_source_cancelPtr = - _lookup>( - 'dispatch_source_cancel', - ); - late final _dispatch_source_cancel = _dispatch_source_cancelPtr - .asFunction(); - - int dispatch_source_testcancel(Dartdispatch_source_t source) { - return _dispatch_source_testcancel(source.ref.pointer); - } - - late final _dispatch_source_testcancelPtr = - _lookup>( - 'dispatch_source_testcancel', - ); - late final _dispatch_source_testcancel = _dispatch_source_testcancelPtr - .asFunction(); - - int dispatch_source_get_handle(Dartdispatch_source_t source) { - return _dispatch_source_get_handle(source.ref.pointer); - } - - late final _dispatch_source_get_handlePtr = - _lookup>( - 'dispatch_source_get_handle', - ); - late final _dispatch_source_get_handle = _dispatch_source_get_handlePtr - .asFunction(); - - int dispatch_source_get_mask(Dartdispatch_source_t source) { - return _dispatch_source_get_mask(source.ref.pointer); - } - - late final _dispatch_source_get_maskPtr = - _lookup>( - 'dispatch_source_get_mask', - ); - late final _dispatch_source_get_mask = _dispatch_source_get_maskPtr - .asFunction(); - - int dispatch_source_get_data(Dartdispatch_source_t source) { - return _dispatch_source_get_data(source.ref.pointer); - } - - late final _dispatch_source_get_dataPtr = - _lookup>( - 'dispatch_source_get_data', - ); - late final _dispatch_source_get_data = _dispatch_source_get_dataPtr - .asFunction(); - - void dispatch_source_merge_data(Dartdispatch_source_t source, int value) { - return _dispatch_source_merge_data(source.ref.pointer, value); - } - - late final _dispatch_source_merge_dataPtr = - _lookup< - ffi.NativeFunction - >('dispatch_source_merge_data'); - late final _dispatch_source_merge_data = _dispatch_source_merge_dataPtr - .asFunction(); - - void dispatch_source_set_timer( - Dartdispatch_source_t source, - Dartdispatch_time_t start, - int interval, - int leeway, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _dispatch_source_set_timer( - source.ref.pointer, - start, - interval, - leeway, - ); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _dispatch_source_set_timerPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_source_t, - dispatch_time_t, - ffi.Uint64, - ffi.Uint64, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_source_set_timer'); - late final _dispatch_source_set_timer = _dispatch_source_set_timerPtr - .asFunction(); - - void dispatch_source_set_registration_handler( - Dartdispatch_source_t source, - Dartdispatch_block_t? handler, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _dispatch_source_set_registration_handler( - source.ref.pointer, - handler?.ref.pointer ?? ffi.nullptr, - ); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _dispatch_source_set_registration_handlerPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_source_t, dispatch_block_t) - > - >('dispatch_source_set_registration_handler'); - late final _dispatch_source_set_registration_handler = - _dispatch_source_set_registration_handlerPtr - .asFunction(); - - void dispatch_source_set_registration_handler_f( - Dartdispatch_source_t source, - dispatch_function_t handler, - ) { - return _dispatch_source_set_registration_handler_f( - source.ref.pointer, - handler, - ); - } - - late final _dispatch_source_set_registration_handler_fPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_source_t, dispatch_function_t) - > - >('dispatch_source_set_registration_handler_f'); - late final _dispatch_source_set_registration_handler_f = - _dispatch_source_set_registration_handler_fPtr - .asFunction(); - - Dartdispatch_group_t dispatch_group_create() { - return objc.NSObject.fromPointer( - _dispatch_group_create(), - retain: false, - release: true, - ); - } - - late final _dispatch_group_createPtr = - _lookup>( - 'dispatch_group_create', - ); - late final _dispatch_group_create = _dispatch_group_createPtr - .asFunction(); - - void dispatch_group_async( - Dartdispatch_group_t group, - Dartdispatch_queue_t queue, - Dartdispatch_block_t block, - ) { - return _dispatch_group_async( - group.ref.pointer, - queue.ref.pointer, - block.ref.pointer, - ); - } - - late final _dispatch_group_asyncPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - dispatch_group_t, - dispatch_queue_t, - dispatch_block_t, - ) - > - >('dispatch_group_async'); - late final _dispatch_group_async = _dispatch_group_asyncPtr - .asFunction< - void Function(dispatch_group_t, dispatch_queue_t, dispatch_block_t) - >(); - - void dispatch_group_async_f( - Dartdispatch_group_t group, - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, - ) { - return _dispatch_group_async_f( - group.ref.pointer, - queue.ref.pointer, - context, - work, - ); - } - - late final _dispatch_group_async_fPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_group_t, - dispatch_queue_t, + ffi.Pointer, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_group_async_f'); - late final _dispatch_group_async_f = _dispatch_group_async_fPtr - .asFunction< - void Function( - dispatch_group_t, - dispatch_queue_t, - ffi.Pointer, - dispatch_function_t, - ) - >(); - - int dispatch_group_wait( - Dartdispatch_group_t group, - Dartdispatch_time_t timeout, - ) { - return _dispatch_group_wait(group.ref.pointer, timeout); - } - - late final _dispatch_group_waitPtr = - _lookup< - ffi.NativeFunction< - ffi.IntPtr Function(dispatch_group_t, dispatch_time_t) - > - >('dispatch_group_wait'); - late final _dispatch_group_wait = _dispatch_group_waitPtr - .asFunction(); - - void dispatch_group_notify( - Dartdispatch_group_t group, - Dartdispatch_queue_t queue, - Dartdispatch_block_t block, - ) { - return _dispatch_group_notify( - group.ref.pointer, - queue.ref.pointer, - block.ref.pointer, - ); - } - - late final _dispatch_group_notifyPtr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_group_t, - dispatch_queue_t, - dispatch_block_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_group_notify'); - late final _dispatch_group_notify = _dispatch_group_notifyPtr - .asFunction< - void Function(dispatch_group_t, dispatch_queue_t, dispatch_block_t) - >(); - - void dispatch_group_notify_f( - Dartdispatch_group_t group, - Dartdispatch_queue_t queue, - ffi.Pointer context, - dispatch_function_t work, - ) { - return _dispatch_group_notify_f( - group.ref.pointer, - queue.ref.pointer, - context, - work, - ); - } - - late final _dispatch_group_notify_fPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - dispatch_group_t, - dispatch_queue_t, - ffi.Pointer, - dispatch_function_t, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) > - >('dispatch_group_notify_f'); - late final _dispatch_group_notify_f = _dispatch_group_notify_fPtr + >() .asFunction< void Function( - dispatch_group_t, - dispatch_queue_t, ffi.Pointer, - dispatch_function_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - void dispatch_group_enter(Dartdispatch_group_t group) { - return _dispatch_group_enter(group.ref.pointer); - } - - late final _dispatch_group_enterPtr = - _lookup>( - 'dispatch_group_enter', - ); - late final _dispatch_group_enter = _dispatch_group_enterPtr - .asFunction(); - - void dispatch_group_leave(Dartdispatch_group_t group) { - return _dispatch_group_leave(group.ref.pointer); - } - - late final _dispatch_group_leavePtr = - _lookup>( - 'dispatch_group_leave', - ); - late final _dispatch_group_leave = _dispatch_group_leavePtr - .asFunction(); - - Dartdispatch_semaphore_t dispatch_semaphore_create(int value) { - return objc.NSObject.fromPointer( - _dispatch_semaphore_create(value), - retain: false, - release: true, - ); - } - - late final _dispatch_semaphore_createPtr = - _lookup>( - 'dispatch_semaphore_create', - ); - late final _dispatch_semaphore_create = _dispatch_semaphore_createPtr - .asFunction(); - - int dispatch_semaphore_wait( - Dartdispatch_semaphore_t dsema, - Dartdispatch_time_t timeout, - ) { - return _dispatch_semaphore_wait(dsema.ref.pointer, timeout); - } - - late final _dispatch_semaphore_waitPtr = - _lookup< - ffi.NativeFunction< - ffi.IntPtr Function(dispatch_semaphore_t, dispatch_time_t) - > - >('dispatch_semaphore_wait'); - late final _dispatch_semaphore_wait = _dispatch_semaphore_waitPtr - .asFunction(); - - int dispatch_semaphore_signal(Dartdispatch_semaphore_t dsema) { - return _dispatch_semaphore_signal(dsema.ref.pointer); - } - - late final _dispatch_semaphore_signalPtr = - _lookup>( - 'dispatch_semaphore_signal', - ); - late final _dispatch_semaphore_signal = _dispatch_semaphore_signalPtr - .asFunction(); - - void dispatch_once( - ffi.Pointer predicate, - Dartdispatch_block_t block, - ) { - return _dispatch_once(predicate, block.ref.pointer); - } - - late final _dispatch_oncePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, dispatch_block_t) - > - >('dispatch_once'); - late final _dispatch_once = _dispatch_oncePtr - .asFunction< - void Function(ffi.Pointer, dispatch_block_t) - >(); - - void dispatch_once_f( - ffi.Pointer predicate, - ffi.Pointer context, - dispatch_function_t function, - ) { - return _dispatch_once_f(predicate, context, function); - } + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _dispatch_once_fPtr = - _lookup< - ffi.NativeFunction< +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, objc.NSError?)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError$CallExtension + on + objc.ObjCBlock< ffi.Void Function( - ffi.Pointer, ffi.Pointer, - dispatch_function_t, + NSURLSession, + NSURLSessionTask, + objc.NSError?, ) - > - >('dispatch_once_f'); - late final _dispatch_once_f = _dispatch_once_fPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_function_t, - ) - >(); - - late final ffi.Pointer __dispatch_data_empty = - _lookup('_dispatch_data_empty'); + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3?.ref.pointer ?? ffi.nullptr, + ); +} - ffi.Pointer get _dispatch_data_empty => - __dispatch_data_empty; +late final _sel_URLSession_didBecomeInvalidWithError_ = objc.registerName( + "URLSession:didBecomeInvalidWithError:", +); - late final ffi.Pointer __dispatch_data_destructor_free = - _lookup('_dispatch_data_destructor_free'); +/// Construction methods for `objc.ObjCBlock, NSURLSession, objc.NSError?)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + >(pointer, retain: retain, release: release); - Dartdispatch_block_t get _dispatch_data_destructor_free => - ObjCBlock_ffiVoid.fromPointer( - __dispatch_data_destructor_free.value, - retain: true, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, release: true, ); - set _dispatch_data_destructor_free(Dartdispatch_block_t value) { - ObjCBlock_ffiVoid.fromPointer( - __dispatch_data_destructor_free.value, - retain: false, - release: true, - ).ref.release(); - __dispatch_data_destructor_free.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer __dispatch_data_destructor_munmap = - _lookup('_dispatch_data_destructor_munmap'); - - Dartdispatch_block_t get _dispatch_data_destructor_munmap => - ObjCBlock_ffiVoid.fromPointer( - __dispatch_data_destructor_munmap.value, - retain: true, + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + > + fromFunction( + void Function(ffi.Pointer, NSURLSession, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, release: true, ); - set _dispatch_data_destructor_munmap(Dartdispatch_block_t value) { - ObjCBlock_ffiVoid.fromPointer( - __dispatch_data_destructor_munmap.value, - retain: false, - release: true, - ).ref.release(); - __dispatch_data_destructor_munmap.value = value.ref - .retainAndReturnPointer(); - } - - Dartdispatch_data_t dispatch_data_create( - ffi.Pointer buffer, - int size, - Dartdispatch_queue_t? queue, - Dartdispatch_block_t? destructor, - ) { - return objc.NSObject.fromPointer( - _dispatch_data_create( - buffer, - size, - queue?.ref.pointer ?? ffi.nullptr, - destructor?.ref.pointer ?? ffi.nullptr, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + > + listener( + void Function(ffi.Pointer, NSURLSession, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), ), - retain: false, - release: true, - ); - } - - late final _dispatch_data_createPtr = - _lookup< - ffi.NativeFunction< - dispatch_data_t Function( - ffi.Pointer, - ffi.Size, - dispatch_queue_t, - dispatch_block_t, - ) - > - >('dispatch_data_create'); - late final _dispatch_data_create = _dispatch_data_createPtr - .asFunction< - dispatch_data_t Function( - ffi.Pointer, - int, - dispatch_queue_t, - dispatch_block_t, - ) - >(); - - int dispatch_data_get_size(Dartdispatch_data_t data) { - return _dispatch_data_get_size(data.ref.pointer); - } - - late final _dispatch_data_get_sizePtr = - _lookup>( - 'dispatch_data_get_size', - ); - late final _dispatch_data_get_size = _dispatch_data_get_sizePtr - .asFunction(); - - Dartdispatch_data_t dispatch_data_create_map( - Dartdispatch_data_t data, - ffi.Pointer> buffer_ptr, - ffi.Pointer size_ptr, - ) { - return objc.NSObject.fromPointer( - _dispatch_data_create_map(data.ref.pointer, buffer_ptr, size_ptr), - retain: false, - release: true, + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_fjrv01(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + >(wrapper, retain: false, release: true); } - late final _dispatch_data_create_mapPtr = - _lookup< - ffi.NativeFunction< - dispatch_data_t Function( - dispatch_data_t, - ffi.Pointer>, - ffi.Pointer, - ) - > - >('dispatch_data_create_map'); - late final _dispatch_data_create_map = _dispatch_data_create_mapPtr - .asFunction< - dispatch_data_t Function( - dispatch_data_t, - ffi.Pointer>, - ffi.Pointer, - ) - >(); - - Dartdispatch_data_t dispatch_data_create_concat( - Dartdispatch_data_t data1, - Dartdispatch_data_t data2, - ) { - return objc.NSObject.fromPointer( - _dispatch_data_create_concat(data1.ref.pointer, data2.ref.pointer), - retain: false, - release: true, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + > + blocking( + void Function(ffi.Pointer, NSURLSession, objc.NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, ); - } - - late final _dispatch_data_create_concatPtr = - _lookup< - ffi.NativeFunction< - dispatch_data_t Function(dispatch_data_t, dispatch_data_t) - > - >('dispatch_data_create_concat'); - late final _dispatch_data_create_concat = _dispatch_data_create_concatPtr - .asFunction(); - - Dartdispatch_data_t dispatch_data_create_subrange( - Dartdispatch_data_t data, - int offset, - int length, - ) { - return objc.NSObject.fromPointer( - _dispatch_data_create_subrange(data.ref.pointer, offset, length), - retain: false, - release: true, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + arg2.address == 0 + ? null + : objc.NSError.fromPointer(arg2, retain: false, release: true), + ), + keepIsolateAlive, ); - } - - late final _dispatch_data_create_subrangePtr = - _lookup< - ffi.NativeFunction< - dispatch_data_t Function(dispatch_data_t, ffi.Size, ffi.Size) - > - >('dispatch_data_create_subrange'); - late final _dispatch_data_create_subrange = _dispatch_data_create_subrangePtr - .asFunction(); - - bool dispatch_data_apply( - Dartdispatch_data_t data, - Dartdispatch_data_applier_t applier, - ) { - return _dispatch_data_apply(data.ref.pointer, applier.ref.pointer); - } - - late final _dispatch_data_applyPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function(dispatch_data_t, dispatch_data_applier_t) - > - >('dispatch_data_apply'); - late final _dispatch_data_apply = _dispatch_data_applyPtr - .asFunction(); - - Dartdispatch_data_t dispatch_data_copy_region( - Dartdispatch_data_t data, - int location, - ffi.Pointer offset_ptr, - ) { - return objc.NSObject.fromPointer( - _dispatch_data_copy_region(data.ref.pointer, location, offset_ptr), - retain: false, - release: true, + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_fjrv01( + raw, + rawListener, + objc.objCContext, ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + >(wrapper, retain: false, release: true); } - late final _dispatch_data_copy_regionPtr = - _lookup< - ffi.NativeFunction< - dispatch_data_t Function( - dispatch_data_t, - ffi.Size, - ffi.Pointer, - ) - > - >('dispatch_data_copy_region'); - late final _dispatch_data_copy_region = _dispatch_data_copy_regionPtr - .asFunction< - dispatch_data_t Function(dispatch_data_t, int, ffi.Pointer) - >(); - - void dispatch_read( - Dartdispatch_fd_t fd, - int length, - Dartdispatch_queue_t queue, - objc.ObjCBlock handler, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _dispatch_read(fd, length, queue.ref.pointer, handler.ref.pointer); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); } - late final _dispatch_readPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_fd_t, - ffi.Size, - dispatch_queue_t, ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_read'); - late final _dispatch_read = _dispatch_readPtr - .asFunction< - void Function( - int, - int, - dispatch_queue_t, - ffi.Pointer, - ) - >(); - - void dispatch_write( - Dartdispatch_fd_t fd, - Dartdispatch_data_t data, - Dartdispatch_queue_t queue, - objc.ObjCBlock handler, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _dispatch_write( - fd, - data.ref.pointer, - queue.ref.pointer, - handler.ref.pointer, - ); - } - - late final _dispatch_writePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - dispatch_fd_t, - dispatch_data_t, - dispatch_queue_t, - ffi.Pointer, - ) - > - >('dispatch_write'); - late final _dispatch_write = _dispatch_writePtr - .asFunction< - void Function( - int, - dispatch_data_t, - dispatch_queue_t, - ffi.Pointer, - ) - >(); - - Dartdispatch_io_t dispatch_io_create( - Dartdispatch_io_type_t type, - Dartdispatch_fd_t fd, - Dartdispatch_queue_t queue, - objc.ObjCBlock cleanup_handler, - ) { - return objc.NSObject.fromPointer( - _dispatch_io_create( - type, - fd, - queue.ref.pointer, - cleanup_handler.ref.pointer, - ), - retain: false, - release: true, - ); - } - - late final _dispatch_io_createPtr = - _lookup< - ffi.NativeFunction< - dispatch_io_t Function( - dispatch_io_type_t, - dispatch_fd_t, - dispatch_queue_t, - ffi.Pointer, - ) - > - >('dispatch_io_create'); - late final _dispatch_io_create = _dispatch_io_createPtr - .asFunction< - dispatch_io_t Function( - int, - int, - dispatch_queue_t, - ffi.Pointer, - ) - >(); - - Dartdispatch_io_t dispatch_io_create_with_path( - Dartdispatch_io_type_t type, - ffi.Pointer path, - int oflag, - Dart__uint16_t mode, - Dartdispatch_queue_t queue, - objc.ObjCBlock cleanup_handler, - ) { - return objc.NSObject.fromPointer( - _dispatch_io_create_with_path( - type, - path, - oflag, - mode, - queue.ref.pointer, - cleanup_handler.ref.pointer, - ), - retain: false, - release: true, - ); - } - - late final _dispatch_io_create_with_pathPtr = - _lookup< - ffi.NativeFunction< - dispatch_io_t Function( - dispatch_io_type_t, - ffi.Pointer, - ffi.Int, - mode_t, - dispatch_queue_t, - ffi.Pointer, - ) - > - >('dispatch_io_create_with_path'); - late final _dispatch_io_create_with_path = _dispatch_io_create_with_pathPtr - .asFunction< - dispatch_io_t Function( - int, - ffi.Pointer, - int, - int, - dispatch_queue_t, - ffi.Pointer, - ) - >(); - - Dartdispatch_io_t dispatch_io_create_with_io( - Dartdispatch_io_type_t type, - Dartdispatch_io_t io, - Dartdispatch_queue_t queue, - objc.ObjCBlock cleanup_handler, - ) { - return objc.NSObject.fromPointer( - _dispatch_io_create_with_io( - type, - io.ref.pointer, - queue.ref.pointer, - cleanup_handler.ref.pointer, - ), - retain: false, - release: true, - ); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _dispatch_io_create_with_ioPtr = - _lookup< - ffi.NativeFunction< - dispatch_io_t Function( - dispatch_io_type_t, - dispatch_io_t, - dispatch_queue_t, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_io_create_with_io'); - late final _dispatch_io_create_with_io = _dispatch_io_create_with_ioPtr - .asFunction< - dispatch_io_t Function( - int, - dispatch_io_t, - dispatch_queue_t, - ffi.Pointer, - ) - >(); - - void dispatch_io_read( - Dartdispatch_io_t channel, - Dart__int64_t offset, - int length, - Dartdispatch_queue_t queue, - Dartdispatch_io_handler_t io_handler, - ) { - return _dispatch_io_read( - channel.ref.pointer, - offset, - length, - queue.ref.pointer, - io_handler.ref.pointer, - ); - } - - late final _dispatch_io_readPtr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( - dispatch_io_t, - off_t, - ffi.Size, - dispatch_queue_t, - dispatch_io_handler_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('dispatch_io_read'); - late final _dispatch_io_read = _dispatch_io_readPtr - .asFunction< - void Function( - dispatch_io_t, - int, - int, - dispatch_queue_t, - dispatch_io_handler_t, - ) - >(); - - void dispatch_io_write( - Dartdispatch_io_t channel, - Dart__int64_t offset, - Dartdispatch_data_t data, - Dartdispatch_queue_t queue, - Dartdispatch_io_handler_t io_handler, - ) { - return _dispatch_io_write( - channel.ref.pointer, - offset, - data.ref.pointer, - queue.ref.pointer, - io_handler.ref.pointer, - ); - } - - late final _dispatch_io_writePtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - dispatch_io_t, - off_t, - dispatch_data_t, - dispatch_queue_t, - dispatch_io_handler_t, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) > - >('dispatch_io_write'); - late final _dispatch_io_write = _dispatch_io_writePtr + >() .asFunction< void Function( - dispatch_io_t, - int, - dispatch_data_t, - dispatch_queue_t, - dispatch_io_handler_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - void dispatch_io_close( - Dartdispatch_io_t channel, - Dartdispatch_io_close_flags_t flags, - ) { - return _dispatch_io_close(channel.ref.pointer, flags); - } - - late final _dispatch_io_closePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_io_t, dispatch_io_close_flags_t) - > - >('dispatch_io_close'); - late final _dispatch_io_close = _dispatch_io_closePtr - .asFunction(); - - void dispatch_io_barrier( - Dartdispatch_io_t channel, - Dartdispatch_block_t barrier, - ) { - return _dispatch_io_barrier(channel.ref.pointer, barrier.ref.pointer); - } - - late final _dispatch_io_barrierPtr = - _lookup< - ffi.NativeFunction - >('dispatch_io_barrier'); - late final _dispatch_io_barrier = _dispatch_io_barrierPtr - .asFunction(); - - Dartdispatch_fd_t dispatch_io_get_descriptor(Dartdispatch_io_t channel) { - return _dispatch_io_get_descriptor(channel.ref.pointer); - } + >()(arg0, arg1, arg2); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _dispatch_io_get_descriptorPtr = - _lookup>( - 'dispatch_io_get_descriptor', +/// Call operator for `objc.ObjCBlock, NSURLSession, objc.NSError?)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError$CallExtension + on + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + objc.NSError? arg2, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2?.ref.pointer ?? ffi.nullptr, ); - late final _dispatch_io_get_descriptor = _dispatch_io_get_descriptorPtr - .asFunction(); - - void dispatch_io_set_high_water(Dartdispatch_io_t channel, int high_water) { - return _dispatch_io_set_high_water(channel.ref.pointer, high_water); - } +} - late final _dispatch_io_set_high_waterPtr = - _lookup>( - 'dispatch_io_set_high_water', - ); - late final _dispatch_io_set_high_water = _dispatch_io_set_high_waterPtr - .asFunction(); +late final _sel_URLSession_didReceiveChallenge_completionHandler_ = objc + .registerName("URLSession:didReceiveChallenge:completionHandler:"); - void dispatch_io_set_low_water(Dartdispatch_io_t channel, int low_water) { - return _dispatch_io_set_low_water(channel.ref.pointer, low_water); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLAuthenticationChallenge, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >(pointer, retain: retain, release: release); - late final _dispatch_io_set_low_waterPtr = - _lookup>( - 'dispatch_io_set_low_water', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - late final _dispatch_io_set_low_water = _dispatch_io_set_low_waterPtr - .asFunction(); - - void dispatch_io_set_interval( - Dartdispatch_io_t channel, - int interval, - Dartdispatch_io_interval_flags_t flags, - ) { - return _dispatch_io_set_interval(channel.ref.pointer, interval, flags); - } - late final _dispatch_io_set_intervalPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - dispatch_io_t, - ffi.Uint64, - dispatch_io_interval_flags_t, - ) - > - >('dispatch_io_set_interval'); - late final _dispatch_io_set_interval = _dispatch_io_set_intervalPtr - .asFunction(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg2, + retain: true, + release: true, + ), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg3, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - Dartdispatch_workloop_t dispatch_workloop_create( - ffi.Pointer label, - ) { - return objc.NSObject.fromPointer( - _dispatch_workloop_create(label), - retain: false, - release: true, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg2, + retain: false, + release: true, + ), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_bklti2(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_workloop_createPtr = - _lookup< - ffi.NativeFunction)> - >('dispatch_workloop_create'); - late final _dispatch_workloop_create = _dispatch_workloop_createPtr - .asFunction)>(); - - Dartdispatch_workloop_t dispatch_workloop_create_inactive( - ffi.Pointer label, - ) { - return objc.NSObject.fromPointer( - _dispatch_workloop_create_inactive(label), - retain: false, - release: true, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg2, + retain: false, + release: true, + ), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); - } - - late final _dispatch_workloop_create_inactivePtr = - _lookup< - ffi.NativeFunction)> - >('dispatch_workloop_create_inactive'); - late final _dispatch_workloop_create_inactive = - _dispatch_workloop_create_inactivePtr - .asFunction)>(); - - void dispatch_workloop_set_autorelease_frequency( - Dartdispatch_workloop_t workloop, - dispatch_autorelease_frequency_t frequency, - ) { - return _dispatch_workloop_set_autorelease_frequency( - workloop.ref.pointer, - frequency.value, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg2, + retain: false, + release: true, + ), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg3, + retain: false, + release: true, + ), + ), + keepIsolateAlive, ); - } - - late final _dispatch_workloop_set_autorelease_frequencyPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_workloop_t, ffi.UnsignedLong) - > - >('dispatch_workloop_set_autorelease_frequency'); - late final _dispatch_workloop_set_autorelease_frequency = - _dispatch_workloop_set_autorelease_frequencyPtr - .asFunction(); - - void dispatch_workloop_set_os_workgroup( - Dartdispatch_workloop_t workloop, - Dartos_workgroup_t workgroup, - ) { - return _dispatch_workloop_set_os_workgroup( - workloop.ref.pointer, - workgroup.ref.pointer, + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_bklti2( + raw, + rawListener, + objc.objCContext, ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); } - late final _dispatch_workloop_set_os_workgroupPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(dispatch_workloop_t, os_workgroup_t) - > - >('dispatch_workloop_set_os_workgroup'); - late final _dispatch_workloop_set_os_workgroup = - _dispatch_workloop_set_os_workgroupPtr - .asFunction(); - - int CFReadStreamGetTypeID() { - return _CFReadStreamGetTypeID(); + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _CFReadStreamGetTypeIDPtr = - _lookup>('CFReadStreamGetTypeID'); - late final _CFReadStreamGetTypeID = - _CFReadStreamGetTypeIDPtr.asFunction(); - - int CFWriteStreamGetTypeID() { - return _CFWriteStreamGetTypeID(); - } - - late final _CFWriteStreamGetTypeIDPtr = - _lookup>( - 'CFWriteStreamGetTypeID', - ); - late final _CFWriteStreamGetTypeID = - _CFWriteStreamGetTypeIDPtr.asFunction(); - - late final ffi.Pointer _kCFStreamPropertyDataWritten = - _lookup('kCFStreamPropertyDataWritten'); - - CFStreamPropertyKey get kCFStreamPropertyDataWritten => - _kCFStreamPropertyDataWritten.value; - - CFReadStreamRef CFReadStreamCreateWithBytesNoCopy( - CFAllocatorRef alloc, - ffi.Pointer bytes, - int length, - CFAllocatorRef bytesDeallocator, - ) { - return _CFReadStreamCreateWithBytesNoCopy( - alloc, - bytes, - length, - bytesDeallocator, - ); - } - - late final _CFReadStreamCreateWithBytesNoCopyPtr = - _lookup< - ffi.NativeFunction< - CFReadStreamRef Function( - CFAllocatorRef, - ffi.Pointer, - CFIndex, - CFAllocatorRef, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFReadStreamCreateWithBytesNoCopy'); - late final _CFReadStreamCreateWithBytesNoCopy = - _CFReadStreamCreateWithBytesNoCopyPtr.asFunction< - CFReadStreamRef Function( - CFAllocatorRef, - ffi.Pointer, - int, - CFAllocatorRef, - ) - >(); - - CFWriteStreamRef CFWriteStreamCreateWithBuffer( - CFAllocatorRef alloc, - ffi.Pointer buffer, - int bufferCapacity, - ) { - return _CFWriteStreamCreateWithBuffer(alloc, buffer, bufferCapacity); - } - - late final _CFWriteStreamCreateWithBufferPtr = - _lookup< - ffi.NativeFunction< - CFWriteStreamRef Function(CFAllocatorRef, ffi.Pointer, CFIndex) - > - >('CFWriteStreamCreateWithBuffer'); - late final _CFWriteStreamCreateWithBuffer = - _CFWriteStreamCreateWithBufferPtr.asFunction< - CFWriteStreamRef Function(CFAllocatorRef, ffi.Pointer, int) - >(); - - CFWriteStreamRef CFWriteStreamCreateWithAllocatedBuffers( - CFAllocatorRef alloc, - CFAllocatorRef bufferAllocator, - ) { - return _CFWriteStreamCreateWithAllocatedBuffers(alloc, bufferAllocator); - } - - late final _CFWriteStreamCreateWithAllocatedBuffersPtr = - _lookup< - ffi.NativeFunction< - CFWriteStreamRef Function(CFAllocatorRef, CFAllocatorRef) - > - >('CFWriteStreamCreateWithAllocatedBuffers'); - late final _CFWriteStreamCreateWithAllocatedBuffers = - _CFWriteStreamCreateWithAllocatedBuffersPtr.asFunction< - CFWriteStreamRef Function(CFAllocatorRef, CFAllocatorRef) - >(); - - CFReadStreamRef CFReadStreamCreateWithFile( - CFAllocatorRef alloc, - CFURLRef fileURL, - ) { - return _CFReadStreamCreateWithFile(alloc, fileURL); - } - - late final _CFReadStreamCreateWithFilePtr = - _lookup< - ffi.NativeFunction - >('CFReadStreamCreateWithFile'); - late final _CFReadStreamCreateWithFile = - _CFReadStreamCreateWithFilePtr.asFunction< - CFReadStreamRef Function(CFAllocatorRef, CFURLRef) - >(); - - CFWriteStreamRef CFWriteStreamCreateWithFile( - CFAllocatorRef alloc, - CFURLRef fileURL, - ) { - return _CFWriteStreamCreateWithFile(alloc, fileURL); - } - - late final _CFWriteStreamCreateWithFilePtr = - _lookup< - ffi.NativeFunction - >('CFWriteStreamCreateWithFile'); - late final _CFWriteStreamCreateWithFile = - _CFWriteStreamCreateWithFilePtr.asFunction< - CFWriteStreamRef Function(CFAllocatorRef, CFURLRef) - >(); - - void CFStreamCreateBoundPair( - CFAllocatorRef alloc, - ffi.Pointer readStream, - ffi.Pointer writeStream, - int transferBufferSize, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _CFStreamCreateBoundPair( - alloc, - readStream, - writeStream, - transferBufferSize, - ); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFStreamCreateBoundPairPtr = - _lookup< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - CFAllocatorRef, - ffi.Pointer, - ffi.Pointer, - CFIndex, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) > - >('CFStreamCreateBoundPair'); - late final _CFStreamCreateBoundPair = - _CFStreamCreateBoundPairPtr.asFunction< + >() + .asFunction< void Function( - CFAllocatorRef, - ffi.Pointer, - ffi.Pointer, - int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - late final ffi.Pointer _kCFStreamPropertyAppendToFile = - _lookup('kCFStreamPropertyAppendToFile'); - - CFStreamPropertyKey get kCFStreamPropertyAppendToFile => - _kCFStreamPropertyAppendToFile.value; - - late final ffi.Pointer - _kCFStreamPropertyFileCurrentOffset = _lookup( - 'kCFStreamPropertyFileCurrentOffset', - ); - - CFStreamPropertyKey get kCFStreamPropertyFileCurrentOffset => - _kCFStreamPropertyFileCurrentOffset.value; - - late final ffi.Pointer - _kCFStreamPropertySocketNativeHandle = _lookup( - 'kCFStreamPropertySocketNativeHandle', - ); - - CFStreamPropertyKey get kCFStreamPropertySocketNativeHandle => - _kCFStreamPropertySocketNativeHandle.value; - - late final ffi.Pointer - _kCFStreamPropertySocketRemoteHostName = _lookup( - 'kCFStreamPropertySocketRemoteHostName', - ); - - CFStreamPropertyKey get kCFStreamPropertySocketRemoteHostName => - _kCFStreamPropertySocketRemoteHostName.value; - - late final ffi.Pointer - _kCFStreamPropertySocketRemotePortNumber = _lookup( - 'kCFStreamPropertySocketRemotePortNumber', - ); - - CFStreamPropertyKey get kCFStreamPropertySocketRemotePortNumber => - _kCFStreamPropertySocketRemotePortNumber.value; - - late final ffi.Pointer _kCFStreamErrorDomainSOCKS = _lookup( - 'kCFStreamErrorDomainSOCKS', - ); - - int get kCFStreamErrorDomainSOCKS => _kCFStreamErrorDomainSOCKS.value; - - late final ffi.Pointer _kCFStreamPropertySOCKSProxy = - _lookup('kCFStreamPropertySOCKSProxy'); - - CFStringRef get kCFStreamPropertySOCKSProxy => - _kCFStreamPropertySOCKSProxy.value; - - set kCFStreamPropertySOCKSProxy(CFStringRef value) => - _kCFStreamPropertySOCKSProxy.value = value; - - late final ffi.Pointer _kCFStreamPropertySOCKSProxyHost = - _lookup('kCFStreamPropertySOCKSProxyHost'); - - CFStringRef get kCFStreamPropertySOCKSProxyHost => - _kCFStreamPropertySOCKSProxyHost.value; - - set kCFStreamPropertySOCKSProxyHost(CFStringRef value) => - _kCFStreamPropertySOCKSProxyHost.value = value; - - late final ffi.Pointer _kCFStreamPropertySOCKSProxyPort = - _lookup('kCFStreamPropertySOCKSProxyPort'); - - CFStringRef get kCFStreamPropertySOCKSProxyPort => - _kCFStreamPropertySOCKSProxyPort.value; - - set kCFStreamPropertySOCKSProxyPort(CFStringRef value) => - _kCFStreamPropertySOCKSProxyPort.value = value; - - late final ffi.Pointer _kCFStreamPropertySOCKSVersion = - _lookup('kCFStreamPropertySOCKSVersion'); - - CFStringRef get kCFStreamPropertySOCKSVersion => - _kCFStreamPropertySOCKSVersion.value; - - set kCFStreamPropertySOCKSVersion(CFStringRef value) => - _kCFStreamPropertySOCKSVersion.value = value; - - late final ffi.Pointer _kCFStreamSocketSOCKSVersion4 = - _lookup('kCFStreamSocketSOCKSVersion4'); - - CFStringRef get kCFStreamSocketSOCKSVersion4 => - _kCFStreamSocketSOCKSVersion4.value; - - set kCFStreamSocketSOCKSVersion4(CFStringRef value) => - _kCFStreamSocketSOCKSVersion4.value = value; - - late final ffi.Pointer _kCFStreamSocketSOCKSVersion5 = - _lookup('kCFStreamSocketSOCKSVersion5'); - - CFStringRef get kCFStreamSocketSOCKSVersion5 => - _kCFStreamSocketSOCKSVersion5.value; - - set kCFStreamSocketSOCKSVersion5(CFStringRef value) => - _kCFStreamSocketSOCKSVersion5.value = value; - - late final ffi.Pointer _kCFStreamPropertySOCKSUser = - _lookup('kCFStreamPropertySOCKSUser'); - - CFStringRef get kCFStreamPropertySOCKSUser => - _kCFStreamPropertySOCKSUser.value; - - set kCFStreamPropertySOCKSUser(CFStringRef value) => - _kCFStreamPropertySOCKSUser.value = value; - - late final ffi.Pointer _kCFStreamPropertySOCKSPassword = - _lookup('kCFStreamPropertySOCKSPassword'); + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - CFStringRef get kCFStreamPropertySOCKSPassword => - _kCFStreamPropertySOCKSPassword.value; +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLAuthenticationChallenge, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, + ); +} - set kCFStreamPropertySOCKSPassword(CFStringRef value) => - _kCFStreamPropertySOCKSPassword.value = value; +late final _sel_URLSessionDidFinishEventsForBackgroundURLSession_ = objc + .registerName("URLSessionDidFinishEventsForBackgroundURLSession:"); - late final ffi.Pointer _kCFStreamErrorDomainSSL = _lookup( - 'kCFStreamErrorDomainSSL', +/// Construction methods for `objc.ObjCBlock, NSURLSession)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock, NSURLSession)> + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock, NSURLSession)>( + pointer, + retain: retain, + release: release, ); - int get kCFStreamErrorDomainSSL => _kCFStreamErrorDomainSSL.value; - - late final ffi.Pointer _kCFStreamPropertySocketSecurityLevel = - _lookup('kCFStreamPropertySocketSecurityLevel'); - - CFStringRef get kCFStreamPropertySocketSecurityLevel => - _kCFStreamPropertySocketSecurityLevel.value; - - set kCFStreamPropertySocketSecurityLevel(CFStringRef value) => - _kCFStreamPropertySocketSecurityLevel.value = value; - - late final ffi.Pointer _kCFStreamSocketSecurityLevelNone = - _lookup('kCFStreamSocketSecurityLevelNone'); - - CFStringRef get kCFStreamSocketSecurityLevelNone => - _kCFStreamSocketSecurityLevelNone.value; - - set kCFStreamSocketSecurityLevelNone(CFStringRef value) => - _kCFStreamSocketSecurityLevelNone.value = value; - - late final ffi.Pointer _kCFStreamSocketSecurityLevelSSLv2 = - _lookup('kCFStreamSocketSecurityLevelSSLv2'); - - CFStringRef get kCFStreamSocketSecurityLevelSSLv2 => - _kCFStreamSocketSecurityLevelSSLv2.value; - - set kCFStreamSocketSecurityLevelSSLv2(CFStringRef value) => - _kCFStreamSocketSecurityLevelSSLv2.value = value; - - late final ffi.Pointer _kCFStreamSocketSecurityLevelSSLv3 = - _lookup('kCFStreamSocketSecurityLevelSSLv3'); - - CFStringRef get kCFStreamSocketSecurityLevelSSLv3 => - _kCFStreamSocketSecurityLevelSSLv3.value; - - set kCFStreamSocketSecurityLevelSSLv3(CFStringRef value) => - _kCFStreamSocketSecurityLevelSSLv3.value = value; - - late final ffi.Pointer _kCFStreamSocketSecurityLevelTLSv1 = - _lookup('kCFStreamSocketSecurityLevelTLSv1'); - - CFStringRef get kCFStreamSocketSecurityLevelTLSv1 => - _kCFStreamSocketSecurityLevelTLSv1.value; - - set kCFStreamSocketSecurityLevelTLSv1(CFStringRef value) => - _kCFStreamSocketSecurityLevelTLSv1.value = value; - - late final ffi.Pointer - _kCFStreamSocketSecurityLevelNegotiatedSSL = _lookup( - 'kCFStreamSocketSecurityLevelNegotiatedSSL', + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock, NSURLSession)> + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + > + ptr, + ) => objc.ObjCBlock, NSURLSession)>( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - CFStringRef get kCFStreamSocketSecurityLevelNegotiatedSSL => - _kCFStreamSocketSecurityLevelNegotiatedSSL.value; - - set kCFStreamSocketSecurityLevelNegotiatedSSL(CFStringRef value) => - _kCFStreamSocketSecurityLevelNegotiatedSSL.value = value; - - late final ffi.Pointer - _kCFStreamPropertyShouldCloseNativeSocket = _lookup( - 'kCFStreamPropertyShouldCloseNativeSocket', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock, NSURLSession)> + fromFunction( + void Function(ffi.Pointer, NSURLSession) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock, NSURLSession)>( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0, ffi.Pointer arg1) => + fn(arg0, NSURLSession.fromPointer(arg1, retain: true, release: true)), + keepIsolateAlive, + ), + retain: false, + release: true, ); - CFStringRef get kCFStreamPropertyShouldCloseNativeSocket => - _kCFStreamPropertyShouldCloseNativeSocket.value; + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock, NSURLSession)> + listener( + void Function(ffi.Pointer, NSURLSession) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_18v1jvf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession) + >(wrapper, retain: false, release: true); + } - set kCFStreamPropertyShouldCloseNativeSocket(CFStringRef value) => - _kCFStreamPropertyShouldCloseNativeSocket.value = value; + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock, NSURLSession)> + blocking( + void Function(ffi.Pointer, NSURLSession) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession) + >(wrapper, retain: false, release: true); + } - void CFStreamCreatePairWithSocket( - CFAllocatorRef alloc, - int sock, - ffi.Pointer readStream, - ffi.Pointer writeStream, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _CFStreamCreatePairWithSocket(alloc, sock, readStream, writeStream); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + objc.objectRelease(block.cast()); } - late final _CFStreamCreatePairWithSocketPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< ffi.Void Function( - CFAllocatorRef, - CFSocketNativeHandle, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFStreamCreatePairWithSocket'); - late final _CFStreamCreatePairWithSocket = - _CFStreamCreatePairWithSocketPtr.asFunction< - void Function( - CFAllocatorRef, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - void CFStreamCreatePairWithSocketToHost( - CFAllocatorRef alloc, - CFStringRef host, - int port, - ffi.Pointer readStream, - ffi.Pointer writeStream, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _CFStreamCreatePairWithSocketToHost( - alloc, - host, - port, - readStream, - writeStream, - ); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _CFStreamCreatePairWithSocketToHostPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - CFAllocatorRef, - CFStringRef, - UInt32, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('CFStreamCreatePairWithSocketToHost'); - late final _CFStreamCreatePairWithSocketToHost = - _CFStreamCreatePairWithSocketToHostPtr.asFunction< - void Function( - CFAllocatorRef, - CFStringRef, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - void CFStreamCreatePairWithPeerSocketSignature( - CFAllocatorRef alloc, - ffi.Pointer signature, - ffi.Pointer readStream, - ffi.Pointer writeStream, - ) { - return _CFStreamCreatePairWithPeerSocketSignature( - alloc, - signature, - readStream, - writeStream, - ); - } - - late final _CFStreamCreatePairWithPeerSocketSignaturePtr = - _lookup< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - CFAllocatorRef, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer arg0, + ffi.Pointer arg1, ) > - >('CFStreamCreatePairWithPeerSocketSignature'); - late final _CFStreamCreatePairWithPeerSocketSignature = - _CFStreamCreatePairWithPeerSocketSignaturePtr.asFunction< - void Function( - CFAllocatorRef, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFStreamStatus CFReadStreamGetStatus(CFReadStreamRef stream) { - return CFStreamStatus.fromValue(_CFReadStreamGetStatus(stream)); - } - - late final _CFReadStreamGetStatusPtr = - _lookup>( - 'CFReadStreamGetStatus', - ); - late final _CFReadStreamGetStatus = - _CFReadStreamGetStatusPtr.asFunction(); - - CFStreamStatus CFWriteStreamGetStatus(CFWriteStreamRef stream) { - return CFStreamStatus.fromValue(_CFWriteStreamGetStatus(stream)); - } - - late final _CFWriteStreamGetStatusPtr = - _lookup>( - 'CFWriteStreamGetStatus', - ); - late final _CFWriteStreamGetStatus = - _CFWriteStreamGetStatusPtr.asFunction(); - - CFErrorRef CFReadStreamCopyError(CFReadStreamRef stream) { - return _CFReadStreamCopyError(stream); - } - - late final _CFReadStreamCopyErrorPtr = - _lookup>( - 'CFReadStreamCopyError', - ); - late final _CFReadStreamCopyError = - _CFReadStreamCopyErrorPtr.asFunction< - CFErrorRef Function(CFReadStreamRef) - >(); - - CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef stream) { - return _CFWriteStreamCopyError(stream); - } - - late final _CFWriteStreamCopyErrorPtr = - _lookup>( - 'CFWriteStreamCopyError', - ); - late final _CFWriteStreamCopyError = - _CFWriteStreamCopyErrorPtr.asFunction< - CFErrorRef Function(CFWriteStreamRef) - >(); - - int CFReadStreamOpen(CFReadStreamRef stream) { - return _CFReadStreamOpen(stream); - } - - late final _CFReadStreamOpenPtr = - _lookup>( - 'CFReadStreamOpen', - ); - late final _CFReadStreamOpen = - _CFReadStreamOpenPtr.asFunction(); - - int CFWriteStreamOpen(CFWriteStreamRef stream) { - return _CFWriteStreamOpen(stream); - } - - late final _CFWriteStreamOpenPtr = - _lookup>( - 'CFWriteStreamOpen', - ); - late final _CFWriteStreamOpen = - _CFWriteStreamOpenPtr.asFunction(); - - void CFReadStreamClose(CFReadStreamRef stream) { - return _CFReadStreamClose(stream); - } - - late final _CFReadStreamClosePtr = - _lookup>( - 'CFReadStreamClose', - ); - late final _CFReadStreamClose = - _CFReadStreamClosePtr.asFunction(); - - void CFWriteStreamClose(CFWriteStreamRef stream) { - return _CFWriteStreamClose(stream); - } - - late final _CFWriteStreamClosePtr = - _lookup>( - 'CFWriteStreamClose', - ); - late final _CFWriteStreamClose = - _CFWriteStreamClosePtr.asFunction(); - - int CFReadStreamHasBytesAvailable(CFReadStreamRef stream) { - return _CFReadStreamHasBytesAvailable(stream); - } - - late final _CFReadStreamHasBytesAvailablePtr = - _lookup>( - 'CFReadStreamHasBytesAvailable', - ); - late final _CFReadStreamHasBytesAvailable = - _CFReadStreamHasBytesAvailablePtr.asFunction< - int Function(CFReadStreamRef) - >(); - - int CFReadStreamRead( - CFReadStreamRef stream, - ffi.Pointer buffer, - int bufferLength, - ) { - return _CFReadStreamRead(stream, buffer, bufferLength); - } - - late final _CFReadStreamReadPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFReadStreamRef, ffi.Pointer, CFIndex) - > - >('CFReadStreamRead'); - late final _CFReadStreamRead = - _CFReadStreamReadPtr.asFunction< - int Function(CFReadStreamRef, ffi.Pointer, int) - >(); - - ffi.Pointer CFReadStreamGetBuffer( - CFReadStreamRef stream, - int maxBytesToRead, - ffi.Pointer numBytesRead, - ) { - return _CFReadStreamGetBuffer(stream, maxBytesToRead, numBytesRead); - } + >() + .asFunction< + void Function(ffi.Pointer, ffi.Pointer) + >()(arg0, arg1); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _CFReadStreamGetBufferPtr = - _lookup< +/// Call operator for `objc.ObjCBlock, NSURLSession)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession$CallExtension + on objc.ObjCBlock, NSURLSession)> { + void call(ffi.Pointer arg0, NSURLSession arg1) => ref + .pointer + .ref + .invoke + .cast< ffi.NativeFunction< - ffi.Pointer Function( - CFReadStreamRef, - CFIndex, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, ) > - >('CFReadStreamGetBuffer'); - late final _CFReadStreamGetBuffer = - _CFReadStreamGetBufferPtr.asFunction< - ffi.Pointer Function(CFReadStreamRef, int, ffi.Pointer) - >(); - - int CFWriteStreamCanAcceptBytes(CFWriteStreamRef stream) { - return _CFWriteStreamCanAcceptBytes(stream); - } - - late final _CFWriteStreamCanAcceptBytesPtr = - _lookup>( - 'CFWriteStreamCanAcceptBytes', - ); - late final _CFWriteStreamCanAcceptBytes = - _CFWriteStreamCanAcceptBytesPtr.asFunction< - int Function(CFWriteStreamRef) - >(); - - int CFWriteStreamWrite( - CFWriteStreamRef stream, - ffi.Pointer buffer, - int bufferLength, - ) { - return _CFWriteStreamWrite(stream, buffer, bufferLength); - } - - late final _CFWriteStreamWritePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function(CFWriteStreamRef, ffi.Pointer, CFIndex) - > - >('CFWriteStreamWrite'); - late final _CFWriteStreamWrite = - _CFWriteStreamWritePtr.asFunction< - int Function(CFWriteStreamRef, ffi.Pointer, int) - >(); - - CFTypeRef CFReadStreamCopyProperty( - CFReadStreamRef stream, - CFStreamPropertyKey propertyName, - ) { - return _CFReadStreamCopyProperty(stream, propertyName); - } - - late final _CFReadStreamCopyPropertyPtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function(CFReadStreamRef, CFStreamPropertyKey) - > - >('CFReadStreamCopyProperty'); - late final _CFReadStreamCopyProperty = - _CFReadStreamCopyPropertyPtr.asFunction< - CFTypeRef Function(CFReadStreamRef, CFStreamPropertyKey) - >(); - - CFTypeRef CFWriteStreamCopyProperty( - CFWriteStreamRef stream, - CFStreamPropertyKey propertyName, - ) { - return _CFWriteStreamCopyProperty(stream, propertyName); - } + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0, arg1.ref.pointer); +} - late final _CFWriteStreamCopyPropertyPtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function(CFWriteStreamRef, CFStreamPropertyKey) - > - >('CFWriteStreamCopyProperty'); - late final _CFWriteStreamCopyProperty = - _CFWriteStreamCopyPropertyPtr.asFunction< - CFTypeRef Function(CFWriteStreamRef, CFStreamPropertyKey) - >(); - - int CFReadStreamSetProperty( - CFReadStreamRef stream, - CFStreamPropertyKey propertyName, - CFTypeRef propertyValue, - ) { - return _CFReadStreamSetProperty(stream, propertyName, propertyValue); - } +/// Messages related to the operation of a task that delivers data +/// directly to the delegate. +extension type NSURLSessionDataDelegate._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol, NSURLSessionTaskDelegate { + /// Constructs a [NSURLSessionDataDelegate] that points to the same underlying object as [other]. + NSURLSessionDataDelegate.as(objc.ObjCObject other) : object$ = other; - late final _CFReadStreamSetPropertyPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFReadStreamRef, CFStreamPropertyKey, CFTypeRef) - > - >('CFReadStreamSetProperty'); - late final _CFReadStreamSetProperty = - _CFReadStreamSetPropertyPtr.asFunction< - int Function(CFReadStreamRef, CFStreamPropertyKey, CFTypeRef) - >(); - - int CFWriteStreamSetProperty( - CFWriteStreamRef stream, - CFStreamPropertyKey propertyName, - CFTypeRef propertyValue, - ) { - return _CFWriteStreamSetProperty(stream, propertyName, propertyValue); - } + /// Constructs a [NSURLSessionDataDelegate] that wraps the given raw object pointer. + NSURLSessionDataDelegate.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); - late final _CFWriteStreamSetPropertyPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFWriteStreamRef, CFStreamPropertyKey, CFTypeRef) - > - >('CFWriteStreamSetProperty'); - late final _CFWriteStreamSetProperty = - _CFWriteStreamSetPropertyPtr.asFunction< - int Function(CFWriteStreamRef, CFStreamPropertyKey, CFTypeRef) - >(); - - int CFReadStreamSetClient( - CFReadStreamRef stream, - int streamEvents, - CFReadStreamClientCallBack clientCB, - ffi.Pointer clientContext, - ) { - return _CFReadStreamSetClient( - stream, - streamEvents, - clientCB, - clientContext, + /// Returns whether [obj] is an instance of [NSURLSessionDataDelegate]. + static bool conformsTo(objc.ObjCObject obj) { + return _objc_msgSend_e3qsqz( + obj.ref.pointer, + _sel_conformsToProtocol_, + _protocol_NSURLSessionDataDelegate, ); } +} - late final _CFReadStreamSetClientPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFReadStreamRef, - CFOptionFlags, - CFReadStreamClientCallBack, - ffi.Pointer, - ) - > - >('CFReadStreamSetClient'); - late final _CFReadStreamSetClient = - _CFReadStreamSetClientPtr.asFunction< - int Function( - CFReadStreamRef, - int, - CFReadStreamClientCallBack, - ffi.Pointer, - ) - >(); - - int CFWriteStreamSetClient( - CFWriteStreamRef stream, - int streamEvents, - CFWriteStreamClientCallBack clientCB, - ffi.Pointer clientContext, - ) { - return _CFWriteStreamSetClient( - stream, - streamEvents, - clientCB, - clientContext, +extension NSURLSessionDataDelegate$Methods on NSURLSessionDataDelegate { + /// Notification that a data task has become a download task. No + /// future messages will be sent to the data task. + void URLSession( + NSURLSession session, { + required NSURLSessionDataTask dataTask, + required NSURLSessionDownloadTask didBecomeDownloadTask, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:dataTask:didBecomeDownloadTask:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - } - - late final _CFWriteStreamSetClientPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFWriteStreamRef, - CFOptionFlags, - CFWriteStreamClientCallBack, - ffi.Pointer, - ) - > - >('CFWriteStreamSetClient'); - late final _CFWriteStreamSetClient = - _CFWriteStreamSetClientPtr.asFunction< - int Function( - CFWriteStreamRef, - int, - CFWriteStreamClientCallBack, - ffi.Pointer, - ) - >(); - - void CFReadStreamScheduleWithRunLoop( - CFReadStreamRef stream, - CFRunLoopRef runLoop, - CFRunLoopMode runLoopMode, - ) { - return _CFReadStreamScheduleWithRunLoop(stream, runLoop, runLoopMode); - } - - late final _CFReadStreamScheduleWithRunLoopPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFReadStreamRef, CFRunLoopRef, CFRunLoopMode) - > - >('CFReadStreamScheduleWithRunLoop'); - late final _CFReadStreamScheduleWithRunLoop = - _CFReadStreamScheduleWithRunLoopPtr.asFunction< - void Function(CFReadStreamRef, CFRunLoopRef, CFRunLoopMode) - >(); - - void CFWriteStreamScheduleWithRunLoop( - CFWriteStreamRef stream, - CFRunLoopRef runLoop, - CFRunLoopMode runLoopMode, - ) { - return _CFWriteStreamScheduleWithRunLoop(stream, runLoop, runLoopMode); - } - - late final _CFWriteStreamScheduleWithRunLoopPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFWriteStreamRef, CFRunLoopRef, CFRunLoopMode) - > - >('CFWriteStreamScheduleWithRunLoop'); - late final _CFWriteStreamScheduleWithRunLoop = - _CFWriteStreamScheduleWithRunLoopPtr.asFunction< - void Function(CFWriteStreamRef, CFRunLoopRef, CFRunLoopMode) - >(); - - void CFReadStreamUnscheduleFromRunLoop( - CFReadStreamRef stream, - CFRunLoopRef runLoop, - CFRunLoopMode runLoopMode, - ) { - return _CFReadStreamUnscheduleFromRunLoop(stream, runLoop, runLoopMode); - } - - late final _CFReadStreamUnscheduleFromRunLoopPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFReadStreamRef, CFRunLoopRef, CFRunLoopMode) - > - >('CFReadStreamUnscheduleFromRunLoop'); - late final _CFReadStreamUnscheduleFromRunLoop = - _CFReadStreamUnscheduleFromRunLoopPtr.asFunction< - void Function(CFReadStreamRef, CFRunLoopRef, CFRunLoopMode) - >(); - - void CFWriteStreamUnscheduleFromRunLoop( - CFWriteStreamRef stream, - CFRunLoopRef runLoop, - CFRunLoopMode runLoopMode, - ) { - return _CFWriteStreamUnscheduleFromRunLoop(stream, runLoop, runLoopMode); - } - - late final _CFWriteStreamUnscheduleFromRunLoopPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFWriteStreamRef, CFRunLoopRef, CFRunLoopMode) - > - >('CFWriteStreamUnscheduleFromRunLoop'); - late final _CFWriteStreamUnscheduleFromRunLoop = - _CFWriteStreamUnscheduleFromRunLoopPtr.asFunction< - void Function(CFWriteStreamRef, CFRunLoopRef, CFRunLoopMode) - >(); - - void CFReadStreamSetDispatchQueue( - CFReadStreamRef stream, - Dartdispatch_queue_t q, - ) { - return _CFReadStreamSetDispatchQueue(stream, q.ref.pointer); - } - - late final _CFReadStreamSetDispatchQueuePtr = - _lookup< - ffi.NativeFunction - >('CFReadStreamSetDispatchQueue'); - late final _CFReadStreamSetDispatchQueue = - _CFReadStreamSetDispatchQueuePtr.asFunction< - void Function(CFReadStreamRef, dispatch_queue_t) - >(); - - void CFWriteStreamSetDispatchQueue( - CFWriteStreamRef stream, - Dartdispatch_queue_t q, - ) { - return _CFWriteStreamSetDispatchQueue(stream, q.ref.pointer); - } - - late final _CFWriteStreamSetDispatchQueuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFWriteStreamRef, dispatch_queue_t) - > - >('CFWriteStreamSetDispatchQueue'); - late final _CFWriteStreamSetDispatchQueue = - _CFWriteStreamSetDispatchQueuePtr.asFunction< - void Function(CFWriteStreamRef, dispatch_queue_t) - >(); - - Dartdispatch_queue_t CFReadStreamCopyDispatchQueue(CFReadStreamRef stream) { - return objc.NSObject.fromPointer( - _CFReadStreamCopyDispatchQueue(stream), - retain: true, - release: true, + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_dataTask_didBecomeDownloadTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:didBecomeDownloadTask:', + ); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_dataTask_didBecomeDownloadTask_, + session.ref.pointer, + dataTask.ref.pointer, + didBecomeDownloadTask.ref.pointer, ); } - late final _CFReadStreamCopyDispatchQueuePtr = - _lookup>( - 'CFReadStreamCopyDispatchQueue', + /// Notification that a data task has become a bidirectional stream + /// task. No future messages will be sent to the data task. The newly + /// created streamTask will carry the original request and response as + /// properties. + /// + /// For requests that were pipelined, the stream object will only allow + /// reading, and the object will immediately issue a + /// -URLSession:writeClosedForStream:. Pipelining can be disabled for + /// all requests in a session, or by the NSURLRequest + /// HTTPShouldUsePipelining property. + /// + /// The underlying connection is no longer considered part of the HTTP + /// connection cache and won't count against the total number of + /// connections per host. + void URLSession$1( + NSURLSession session, { + required NSURLSessionDataTask dataTask, + required NSURLSessionStreamTask didBecomeStreamTask, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:dataTask:didBecomeStreamTask:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_dataTask_didBecomeStreamTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:didBecomeStreamTask:', ); - late final _CFReadStreamCopyDispatchQueue = - _CFReadStreamCopyDispatchQueuePtr.asFunction< - dispatch_queue_t Function(CFReadStreamRef) - >(); - - Dartdispatch_queue_t CFWriteStreamCopyDispatchQueue(CFWriteStreamRef stream) { - return objc.NSObject.fromPointer( - _CFWriteStreamCopyDispatchQueue(stream), - retain: true, - release: true, + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_dataTask_didBecomeStreamTask_, + session.ref.pointer, + dataTask.ref.pointer, + didBecomeStreamTask.ref.pointer, ); } - late final _CFWriteStreamCopyDispatchQueuePtr = - _lookup>( - 'CFWriteStreamCopyDispatchQueue', + /// Sent when data is available for the delegate to consume. As the + /// data may be discontiguous, you should use + /// [NSData enumerateByteRangesUsingBlock:] to access it. + void URLSession$2( + NSURLSession session, { + required NSURLSessionDataTask dataTask, + required objc.NSData didReceiveData, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:dataTask:didReceiveData:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_dataTask_didReceiveData_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:didReceiveData:', ); - late final _CFWriteStreamCopyDispatchQueue = - _CFWriteStreamCopyDispatchQueuePtr.asFunction< - dispatch_queue_t Function(CFWriteStreamRef) - >(); - - CFStreamError CFReadStreamGetError(CFReadStreamRef stream) { - return _CFReadStreamGetError(stream); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_dataTask_didReceiveData_, + session.ref.pointer, + dataTask.ref.pointer, + didReceiveData.ref.pointer, + ); } - late final _CFReadStreamGetErrorPtr = - _lookup>( - 'CFReadStreamGetError', + /// The task has received a response and no further messages will be + /// received until the completion block is called. The disposition + /// allows you to cancel a request or to turn a data task into a + /// download task. This delegate message is optional - if you do not + /// implement it, you can get the response as a property of the task. + /// + /// This method will not be called for background upload tasks (which cannot be converted to download tasks). + void URLSession$3( + NSURLSession session, { + required NSURLSessionDataTask dataTask, + required NSURLResponse didReceiveResponse, + required objc.ObjCBlock completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:dataTask:didReceiveResponse:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:didReceiveResponse:completionHandler:', ); - late final _CFReadStreamGetError = - _CFReadStreamGetErrorPtr.asFunction< - CFStreamError Function(CFReadStreamRef) - >(); - - CFStreamError CFWriteStreamGetError(CFWriteStreamRef stream) { - return _CFWriteStreamGetError(stream); + } + _objc_msgSend_m7tls4( + object$.ref.pointer, + _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, + session.ref.pointer, + dataTask.ref.pointer, + didReceiveResponse.ref.pointer, + completionHandler.ref.pointer, + ); } - late final _CFWriteStreamGetErrorPtr = - _lookup>( - 'CFWriteStreamGetError', + /// Invoke the completion routine with a valid NSCachedURLResponse to + /// allow the resulting data to be cached, or pass nil to prevent + /// caching. Note that there is no guarantee that caching will be + /// attempted for a given resource, and you should not rely on this + /// message to receive the resource data. + void URLSession$4( + NSURLSession session, { + required NSURLSessionDataTask dataTask, + required NSCachedURLResponse willCacheResponse, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:dataTask:willCacheResponse:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_dataTask_willCacheResponse_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:willCacheResponse:completionHandler:', ); - late final _CFWriteStreamGetError = - _CFWriteStreamGetErrorPtr.asFunction< - CFStreamError Function(CFWriteStreamRef) - >(); - - CFPropertyListRef CFPropertyListCreateFromXMLData( - CFAllocatorRef allocator, - CFDataRef xmlData, - int mutabilityOption, - ffi.Pointer errorString, - ) { - return _CFPropertyListCreateFromXMLData( - allocator, - xmlData, - mutabilityOption, - errorString, + } + _objc_msgSend_m7tls4( + object$.ref.pointer, + _sel_URLSession_dataTask_willCacheResponse_completionHandler_, + session.ref.pointer, + dataTask.ref.pointer, + willCacheResponse.ref.pointer, + completionHandler.ref.pointer, ); } - late final _CFPropertyListCreateFromXMLDataPtr = - _lookup< - ffi.NativeFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFDataRef, - CFOptionFlags, - ffi.Pointer, - ) - > - >('CFPropertyListCreateFromXMLData'); - late final _CFPropertyListCreateFromXMLData = - _CFPropertyListCreateFromXMLDataPtr.asFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFDataRef, - int, - ffi.Pointer, - ) - >(); - - CFDataRef CFPropertyListCreateXMLData( - CFAllocatorRef allocator, - CFPropertyListRef propertyList, - ) { - return _CFPropertyListCreateXMLData(allocator, propertyList); - } - - late final _CFPropertyListCreateXMLDataPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function(CFAllocatorRef, CFPropertyListRef) - > - >('CFPropertyListCreateXMLData'); - late final _CFPropertyListCreateXMLData = - _CFPropertyListCreateXMLDataPtr.asFunction< - CFDataRef Function(CFAllocatorRef, CFPropertyListRef) - >(); - - CFPropertyListRef CFPropertyListCreateDeepCopy( - CFAllocatorRef allocator, - CFPropertyListRef propertyList, - int mutabilityOption, - ) { - return _CFPropertyListCreateDeepCopy( - allocator, - propertyList, - mutabilityOption, + /// The last message a session receives. A session will only become + /// invalid because of a systemic error or when it has been + /// explicitly invalidated, in which case the error parameter will be nil. + void URLSession$5( + NSURLSession session, { + objc.NSError? didBecomeInvalidWithError, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:didBecomeInvalidWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - } - - late final _CFPropertyListCreateDeepCopyPtr = - _lookup< - ffi.NativeFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFPropertyListRef, - CFOptionFlags, - ) - > - >('CFPropertyListCreateDeepCopy'); - late final _CFPropertyListCreateDeepCopy = - _CFPropertyListCreateDeepCopyPtr.asFunction< - CFPropertyListRef Function(CFAllocatorRef, CFPropertyListRef, int) - >(); - - DartBoolean CFPropertyListIsValid( - CFPropertyListRef plist, - CFPropertyListFormat format, - ) { - return _CFPropertyListIsValid(plist, format.value); - } - - late final _CFPropertyListIsValidPtr = - _lookup>( - 'CFPropertyListIsValid', + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:didBecomeInvalidWithError:', ); - late final _CFPropertyListIsValid = - _CFPropertyListIsValidPtr.asFunction< - int Function(CFPropertyListRef, int) - >(); - - DartCFIndex CFPropertyListWriteToStream( - CFPropertyListRef propertyList, - CFWriteStreamRef stream, - CFPropertyListFormat format, - ffi.Pointer errorString, - ) { - return _CFPropertyListWriteToStream( - propertyList, - stream, - format.value, - errorString, + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + session.ref.pointer, + didBecomeInvalidWithError?.ref.pointer ?? ffi.nullptr, ); } - late final _CFPropertyListWriteToStreamPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFPropertyListRef, - CFWriteStreamRef, - CFIndex, - ffi.Pointer, - ) - > - >('CFPropertyListWriteToStream'); - late final _CFPropertyListWriteToStream = - _CFPropertyListWriteToStreamPtr.asFunction< - int Function( - CFPropertyListRef, - CFWriteStreamRef, - int, - ffi.Pointer, - ) - >(); - - CFPropertyListRef CFPropertyListCreateFromStream( - CFAllocatorRef allocator, - CFReadStreamRef stream, - int streamLength, - int mutabilityOption, - ffi.Pointer format, - ffi.Pointer errorString, - ) { - return _CFPropertyListCreateFromStream( - allocator, - stream, - streamLength, - mutabilityOption, - format, - errorString, + /// Notification that a task has been created. This method is the first message + /// a task sends, providing a place to configure the task before it is resumed. + /// + /// This delegate callback is *NOT* dispatched to the delegate queue. It is + /// invoked synchronously before the task creation method returns. + void URLSession$6( + NSURLSession session, { + required NSURLSessionTask didCreateTask, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:didCreateTask:', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), ); - } - - late final _CFPropertyListCreateFromStreamPtr = - _lookup< - ffi.NativeFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFReadStreamRef, - CFIndex, - CFOptionFlags, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFPropertyListCreateFromStream'); - late final _CFPropertyListCreateFromStream = - _CFPropertyListCreateFromStreamPtr.asFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFReadStreamRef, - int, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFPropertyListRef CFPropertyListCreateWithData( - CFAllocatorRef allocator, - CFDataRef data, - int options, - ffi.Pointer format, - ffi.Pointer error, - ) { - return _CFPropertyListCreateWithData( - allocator, - data, - options, - format, - error, + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didCreateTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:didCreateTask:', + ); + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_didCreateTask_, + session.ref.pointer, + didCreateTask.ref.pointer, ); } - late final _CFPropertyListCreateWithDataPtr = - _lookup< - ffi.NativeFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFDataRef, - CFOptionFlags, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFPropertyListCreateWithData'); - late final _CFPropertyListCreateWithData = - _CFPropertyListCreateWithDataPtr.asFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFDataRef, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFPropertyListRef CFPropertyListCreateWithStream( - CFAllocatorRef allocator, - CFReadStreamRef stream, - int streamLength, - int options, - ffi.Pointer format, - ffi.Pointer error, - ) { - return _CFPropertyListCreateWithStream( - allocator, - stream, - streamLength, - options, - format, - error, + /// If implemented, when a connection level authentication challenge + /// has occurred, this delegate will be given the opportunity to + /// provide authentication credentials to the underlying + /// connection. Some types of authentication will apply to more than + /// one request on a given connection to a server (SSL Server Trust + /// challenges). If this delegate message is not implemented, the + /// behavior will be to use the default handling, which may involve user + /// interaction. + void URLSession$7( + NSURLSession session, { + required NSURLAuthenticationChallenge didReceiveChallenge, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - } - - late final _CFPropertyListCreateWithStreamPtr = - _lookup< - ffi.NativeFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFReadStreamRef, - CFIndex, - CFOptionFlags, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFPropertyListCreateWithStream'); - late final _CFPropertyListCreateWithStream = - _CFPropertyListCreateWithStreamPtr.asFunction< - CFPropertyListRef Function( - CFAllocatorRef, - CFReadStreamRef, - int, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - DartCFIndex CFPropertyListWrite( - CFPropertyListRef propertyList, - CFWriteStreamRef stream, - CFPropertyListFormat format, - DartCFOptionFlags options, - ffi.Pointer error, - ) { - return _CFPropertyListWrite( - propertyList, - stream, - format.value, - options, - error, + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:didReceiveChallenge:completionHandler:', + ); + } + _objc_msgSend_18qun1e( + object$.ref.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + session.ref.pointer, + didReceiveChallenge.ref.pointer, + completionHandler.ref.pointer, ); } - late final _CFPropertyListWritePtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFPropertyListRef, - CFWriteStreamRef, - CFIndex, - CFOptionFlags, - ffi.Pointer, - ) - > - >('CFPropertyListWrite'); - late final _CFPropertyListWrite = - _CFPropertyListWritePtr.asFunction< - int Function( - CFPropertyListRef, - CFWriteStreamRef, - int, - int, - ffi.Pointer, - ) - >(); - - CFDataRef CFPropertyListCreateData( - CFAllocatorRef allocator, - CFPropertyListRef propertyList, - CFPropertyListFormat format, - DartCFOptionFlags options, - ffi.Pointer error, - ) { - return _CFPropertyListCreateData( - allocator, - propertyList, - format.value, - options, - error, + /// Sent as the last message related to a specific task. Error may be + /// nil, which implies that no error occurred and this task is complete. + void URLSession$8( + NSURLSession session, { + required NSURLSessionTask task, + objc.NSError? didCompleteWithError, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didCompleteWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didCompleteWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didCompleteWithError:', + ); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didCompleteWithError_, + session.ref.pointer, + task.ref.pointer, + didCompleteWithError?.ref.pointer ?? ffi.nullptr, ); } - late final _CFPropertyListCreateDataPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function( - CFAllocatorRef, - CFPropertyListRef, - CFIndex, - CFOptionFlags, - ffi.Pointer, - ) - > - >('CFPropertyListCreateData'); - late final _CFPropertyListCreateData = - _CFPropertyListCreateDataPtr.asFunction< - CFDataRef Function( - CFAllocatorRef, - CFPropertyListRef, - int, - int, - ffi.Pointer, - ) - >(); - - late final ffi.Pointer _kCFTypeSetCallBacks = - _lookup('kCFTypeSetCallBacks'); - - CFSetCallBacks get kCFTypeSetCallBacks => _kCFTypeSetCallBacks.ref; - - late final ffi.Pointer _kCFCopyStringSetCallBacks = - _lookup('kCFCopyStringSetCallBacks'); - - CFSetCallBacks get kCFCopyStringSetCallBacks => - _kCFCopyStringSetCallBacks.ref; - - int CFSetGetTypeID() { - return _CFSetGetTypeID(); - } - - late final _CFSetGetTypeIDPtr = - _lookup>('CFSetGetTypeID'); - late final _CFSetGetTypeID = _CFSetGetTypeIDPtr.asFunction(); - - CFSetRef CFSetCreate( - CFAllocatorRef allocator, - ffi.Pointer> values, - int numValues, - ffi.Pointer callBacks, - ) { - return _CFSetCreate(allocator, values, numValues, callBacks); - } - - late final _CFSetCreatePtr = - _lookup< - ffi.NativeFunction< - CFSetRef Function( - CFAllocatorRef, - ffi.Pointer>, - CFIndex, - ffi.Pointer, - ) - > - >('CFSetCreate'); - late final _CFSetCreate = - _CFSetCreatePtr.asFunction< - CFSetRef Function( - CFAllocatorRef, - ffi.Pointer>, - int, - ffi.Pointer, - ) - >(); - - CFSetRef CFSetCreateCopy(CFAllocatorRef allocator, CFSetRef theSet) { - return _CFSetCreateCopy(allocator, theSet); - } - - late final _CFSetCreateCopyPtr = - _lookup>( - 'CFSetCreateCopy', - ); - late final _CFSetCreateCopy = - _CFSetCreateCopyPtr.asFunction< - CFSetRef Function(CFAllocatorRef, CFSetRef) - >(); - - CFMutableSetRef CFSetCreateMutable( - CFAllocatorRef allocator, - int capacity, - ffi.Pointer callBacks, - ) { - return _CFSetCreateMutable(allocator, capacity, callBacks); - } - - late final _CFSetCreateMutablePtr = - _lookup< - ffi.NativeFunction< - CFMutableSetRef Function( - CFAllocatorRef, - CFIndex, - ffi.Pointer, - ) - > - >('CFSetCreateMutable'); - late final _CFSetCreateMutable = - _CFSetCreateMutablePtr.asFunction< - CFMutableSetRef Function( - CFAllocatorRef, - int, - ffi.Pointer, - ) - >(); - - CFMutableSetRef CFSetCreateMutableCopy( - CFAllocatorRef allocator, - int capacity, - CFSetRef theSet, - ) { - return _CFSetCreateMutableCopy(allocator, capacity, theSet); - } - - late final _CFSetCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableSetRef Function(CFAllocatorRef, CFIndex, CFSetRef) - > - >('CFSetCreateMutableCopy'); - late final _CFSetCreateMutableCopy = - _CFSetCreateMutableCopyPtr.asFunction< - CFMutableSetRef Function(CFAllocatorRef, int, CFSetRef) - >(); - - int CFSetGetCount(CFSetRef theSet) { - return _CFSetGetCount(theSet); - } - - late final _CFSetGetCountPtr = - _lookup>('CFSetGetCount'); - late final _CFSetGetCount = - _CFSetGetCountPtr.asFunction(); - - int CFSetGetCountOfValue(CFSetRef theSet, ffi.Pointer value) { - return _CFSetGetCountOfValue(theSet, value); - } - - late final _CFSetGetCountOfValuePtr = - _lookup< - ffi.NativeFunction)> - >('CFSetGetCountOfValue'); - late final _CFSetGetCountOfValue = - _CFSetGetCountOfValuePtr.asFunction< - int Function(CFSetRef, ffi.Pointer) - >(); - - int CFSetContainsValue(CFSetRef theSet, ffi.Pointer value) { - return _CFSetContainsValue(theSet, value); - } - - late final _CFSetContainsValuePtr = - _lookup< - ffi.NativeFunction)> - >('CFSetContainsValue'); - late final _CFSetContainsValue = - _CFSetContainsValuePtr.asFunction< - int Function(CFSetRef, ffi.Pointer) - >(); - - ffi.Pointer CFSetGetValue( - CFSetRef theSet, - ffi.Pointer value, - ) { - return _CFSetGetValue(theSet, value); - } - - late final _CFSetGetValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFSetRef, ffi.Pointer) - > - >('CFSetGetValue'); - late final _CFSetGetValue = - _CFSetGetValuePtr.asFunction< - ffi.Pointer Function(CFSetRef, ffi.Pointer) - >(); - - int CFSetGetValueIfPresent( - CFSetRef theSet, - ffi.Pointer candidate, - ffi.Pointer> value, - ) { - return _CFSetGetValueIfPresent(theSet, candidate, value); - } - - late final _CFSetGetValueIfPresentPtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFSetRef, - ffi.Pointer, - ffi.Pointer>, - ) - > - >('CFSetGetValueIfPresent'); - late final _CFSetGetValueIfPresent = - _CFSetGetValueIfPresentPtr.asFunction< - int Function( - CFSetRef, - ffi.Pointer, - ffi.Pointer>, - ) - >(); - - void CFSetGetValues( - CFSetRef theSet, - ffi.Pointer> values, - ) { - return _CFSetGetValues(theSet, values); - } - - late final _CFSetGetValuesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFSetRef, ffi.Pointer>) - > - >('CFSetGetValues'); - late final _CFSetGetValues = - _CFSetGetValuesPtr.asFunction< - void Function(CFSetRef, ffi.Pointer>) - >(); - - void CFSetApplyFunction( - CFSetRef theSet, - CFSetApplierFunction applier, - ffi.Pointer context, - ) { - return _CFSetApplyFunction(theSet, applier, context); - } - - late final _CFSetApplyFunctionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFSetRef, - CFSetApplierFunction, - ffi.Pointer, - ) - > - >('CFSetApplyFunction'); - late final _CFSetApplyFunction = - _CFSetApplyFunctionPtr.asFunction< - void Function(CFSetRef, CFSetApplierFunction, ffi.Pointer) - >(); - - void CFSetAddValue(CFMutableSetRef theSet, ffi.Pointer value) { - return _CFSetAddValue(theSet, value); - } - - late final _CFSetAddValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableSetRef, ffi.Pointer) - > - >('CFSetAddValue'); - late final _CFSetAddValue = - _CFSetAddValuePtr.asFunction< - void Function(CFMutableSetRef, ffi.Pointer) - >(); - - void CFSetReplaceValue(CFMutableSetRef theSet, ffi.Pointer value) { - return _CFSetReplaceValue(theSet, value); - } - - late final _CFSetReplaceValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableSetRef, ffi.Pointer) - > - >('CFSetReplaceValue'); - late final _CFSetReplaceValue = - _CFSetReplaceValuePtr.asFunction< - void Function(CFMutableSetRef, ffi.Pointer) - >(); - - void CFSetSetValue(CFMutableSetRef theSet, ffi.Pointer value) { - return _CFSetSetValue(theSet, value); - } - - late final _CFSetSetValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableSetRef, ffi.Pointer) - > - >('CFSetSetValue'); - late final _CFSetSetValue = - _CFSetSetValuePtr.asFunction< - void Function(CFMutableSetRef, ffi.Pointer) - >(); - - void CFSetRemoveValue(CFMutableSetRef theSet, ffi.Pointer value) { - return _CFSetRemoveValue(theSet, value); - } - - late final _CFSetRemoveValuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableSetRef, ffi.Pointer) - > - >('CFSetRemoveValue'); - late final _CFSetRemoveValue = - _CFSetRemoveValuePtr.asFunction< - void Function(CFMutableSetRef, ffi.Pointer) - >(); - - void CFSetRemoveAllValues(CFMutableSetRef theSet) { - return _CFSetRemoveAllValues(theSet); - } - - late final _CFSetRemoveAllValuesPtr = - _lookup>( - 'CFSetRemoveAllValues', - ); - late final _CFSetRemoveAllValues = - _CFSetRemoveAllValuesPtr.asFunction(); - - int CFTreeGetTypeID() { - return _CFTreeGetTypeID(); - } - - late final _CFTreeGetTypeIDPtr = - _lookup>('CFTreeGetTypeID'); - late final _CFTreeGetTypeID = - _CFTreeGetTypeIDPtr.asFunction(); - - CFTreeRef CFTreeCreate( - CFAllocatorRef allocator, - ffi.Pointer context, - ) { - return _CFTreeCreate(allocator, context); - } - - late final _CFTreeCreatePtr = - _lookup< - ffi.NativeFunction< - CFTreeRef Function(CFAllocatorRef, ffi.Pointer) - > - >('CFTreeCreate'); - late final _CFTreeCreate = - _CFTreeCreatePtr.asFunction< - CFTreeRef Function(CFAllocatorRef, ffi.Pointer) - >(); - - CFTreeRef CFTreeGetParent(CFTreeRef tree) { - return _CFTreeGetParent(tree); - } - - late final _CFTreeGetParentPtr = - _lookup>( - 'CFTreeGetParent', - ); - late final _CFTreeGetParent = - _CFTreeGetParentPtr.asFunction(); - - CFTreeRef CFTreeGetNextSibling(CFTreeRef tree) { - return _CFTreeGetNextSibling(tree); - } - - late final _CFTreeGetNextSiblingPtr = - _lookup>( - 'CFTreeGetNextSibling', + /// Sent when complete statistics information has been collected for the task. + void URLSession$9( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLSessionTaskMetrics didFinishCollectingMetrics, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didFinishCollectingMetrics:', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didFinishCollectingMetrics:', ); - late final _CFTreeGetNextSibling = - _CFTreeGetNextSiblingPtr.asFunction(); - - CFTreeRef CFTreeGetFirstChild(CFTreeRef tree) { - return _CFTreeGetFirstChild(tree); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + session.ref.pointer, + task.ref.pointer, + didFinishCollectingMetrics.ref.pointer, + ); } - late final _CFTreeGetFirstChildPtr = - _lookup>( - 'CFTreeGetFirstChild', + /// The task has received a request specific authentication challenge. + /// If this delegate is not implemented, the session specific authentication challenge + /// will *NOT* be called and the behavior will be the same as using the default handling + /// disposition. + void URLSession$10( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLAuthenticationChallenge didReceiveChallenge, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didReceiveChallenge:completionHandler:', ); - late final _CFTreeGetFirstChild = - _CFTreeGetFirstChildPtr.asFunction(); - - void CFTreeGetContext(CFTreeRef tree, ffi.Pointer context) { - return _CFTreeGetContext(tree, context); - } - - late final _CFTreeGetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFTreeRef, ffi.Pointer) - > - >('CFTreeGetContext'); - late final _CFTreeGetContext = - _CFTreeGetContextPtr.asFunction< - void Function(CFTreeRef, ffi.Pointer) - >(); - - int CFTreeGetChildCount(CFTreeRef tree) { - return _CFTreeGetChildCount(tree); + } + _objc_msgSend_m7tls4( + object$.ref.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + session.ref.pointer, + task.ref.pointer, + didReceiveChallenge.ref.pointer, + completionHandler.ref.pointer, + ); } - late final _CFTreeGetChildCountPtr = - _lookup>( - 'CFTreeGetChildCount', + /// Sent for each informational response received except 101 switching protocols. + void URLSession$11( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse didReceiveInformationalResponse, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didReceiveInformationalResponse:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didReceiveInformationalResponse:', ); - late final _CFTreeGetChildCount = - _CFTreeGetChildCountPtr.asFunction(); - - CFTreeRef CFTreeGetChildAtIndex(CFTreeRef tree, int idx) { - return _CFTreeGetChildAtIndex(tree, idx); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + session.ref.pointer, + task.ref.pointer, + didReceiveInformationalResponse.ref.pointer, + ); } - late final _CFTreeGetChildAtIndexPtr = - _lookup>( - 'CFTreeGetChildAtIndex', + /// Sent periodically to notify the delegate of upload progress. This + /// information is also available as properties of the task. + void URLSession$12( + NSURLSession session, { + required NSURLSessionTask task, + required int didSendBodyData, + required int totalBytesSent, + required int totalBytesExpectedToSend, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', ); - late final _CFTreeGetChildAtIndex = - _CFTreeGetChildAtIndexPtr.asFunction< - CFTreeRef Function(CFTreeRef, int) - >(); - - void CFTreeGetChildren(CFTreeRef tree, ffi.Pointer children) { - return _CFTreeGetChildren(tree, children); - } - - late final _CFTreeGetChildrenPtr = - _lookup< - ffi.NativeFunction)> - >('CFTreeGetChildren'); - late final _CFTreeGetChildren = - _CFTreeGetChildrenPtr.asFunction< - void Function(CFTreeRef, ffi.Pointer) - >(); - - void CFTreeApplyFunctionToChildren( - CFTreeRef tree, - CFTreeApplierFunction applier, - ffi.Pointer context, - ) { - return _CFTreeApplyFunctionToChildren(tree, applier, context); - } - - late final _CFTreeApplyFunctionToChildrenPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFTreeRef, - CFTreeApplierFunction, - ffi.Pointer, - ) - > - >('CFTreeApplyFunctionToChildren'); - late final _CFTreeApplyFunctionToChildren = - _CFTreeApplyFunctionToChildrenPtr.asFunction< - void Function(CFTreeRef, CFTreeApplierFunction, ffi.Pointer) - >(); - - CFTreeRef CFTreeFindRoot(CFTreeRef tree) { - return _CFTreeFindRoot(tree); + } + _objc_msgSend_1modw1b( + object$.ref.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + session.ref.pointer, + task.ref.pointer, + didSendBodyData, + totalBytesSent, + totalBytesExpectedToSend, + ); } - late final _CFTreeFindRootPtr = - _lookup>( - 'CFTreeFindRoot', + /// Sent if a task requires a new, unopened body stream. This may be + /// necessary when authentication has failed for any request that + /// involves a body stream. + void URLSession$13( + NSURLSession session, { + required NSURLSessionTask task, + required objc.ObjCBlock + needNewBodyStream, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:needNewBodyStream:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStream_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:needNewBodyStream:', ); - late final _CFTreeFindRoot = - _CFTreeFindRootPtr.asFunction(); - - void CFTreeSetContext(CFTreeRef tree, ffi.Pointer context) { - return _CFTreeSetContext(tree, context); - } - - late final _CFTreeSetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFTreeRef, ffi.Pointer) - > - >('CFTreeSetContext'); - late final _CFTreeSetContext = - _CFTreeSetContextPtr.asFunction< - void Function(CFTreeRef, ffi.Pointer) - >(); - - void CFTreePrependChild(CFTreeRef tree, CFTreeRef newChild) { - return _CFTreePrependChild(tree, newChild); + } + _objc_msgSend_18qun1e( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStream_, + session.ref.pointer, + task.ref.pointer, + needNewBodyStream.ref.pointer, + ); } - late final _CFTreePrependChildPtr = - _lookup>( - 'CFTreePrependChild', + /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be + /// necessary when resuming a failed upload task. + /// + /// - Parameter session: The session containing the task that needs a new body stream from the given offset. + /// - Parameter task: The task that needs a new body stream. + /// - Parameter offset: The starting offset required for the body stream. + /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. + void URLSession$14( + NSURLSession session, { + required NSURLSessionTask task, + required int needNewBodyStreamFromOffset, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', ); - late final _CFTreePrependChild = - _CFTreePrependChildPtr.asFunction(); - - void CFTreeAppendChild(CFTreeRef tree, CFTreeRef newChild) { - return _CFTreeAppendChild(tree, newChild); + } + _objc_msgSend_9cddqw( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + session.ref.pointer, + task.ref.pointer, + needNewBodyStreamFromOffset, + completionHandler.ref.pointer, + ); } - late final _CFTreeAppendChildPtr = - _lookup>( - 'CFTreeAppendChild', + /// Sent when the system is ready to begin work for a task with a delayed start + /// time set (using the earliestBeginDate property). The completionHandler must + /// be invoked in order for loading to proceed. The disposition provided to the + /// completion handler continues the load with the original request provided to + /// the task, replaces the request with the specified task, or cancels the task. + /// If this delegate is not implemented, loading will proceed with the original + /// request. + /// + /// Recommendation: only implement this delegate if tasks that have the + /// earliestBeginDate property set may become stale and require alteration prior + /// to starting the network load. + /// + /// If a new request is specified, the allowsExpensiveNetworkAccess, + /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties + /// from the new request will not be used; the properties from the + /// original request will continue to be used. + /// + /// Canceling the task is equivalent to calling the task's cancel method; the + /// URLSession:task:didCompleteWithError: task delegate will be called with error + /// NSURLErrorCancelled. + void URLSession$15( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLRequest willBeginDelayedRequest, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:willBeginDelayedRequest:completionHandler:', ); - late final _CFTreeAppendChild = - _CFTreeAppendChildPtr.asFunction(); - - void CFTreeInsertSibling(CFTreeRef tree, CFTreeRef newSibling) { - return _CFTreeInsertSibling(tree, newSibling); + } + _objc_msgSend_m7tls4( + object$.ref.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + session.ref.pointer, + task.ref.pointer, + willBeginDelayedRequest.ref.pointer, + completionHandler.ref.pointer, + ); } - late final _CFTreeInsertSiblingPtr = - _lookup>( - 'CFTreeInsertSibling', + /// An HTTP request is attempting to perform a redirection to a different + /// URL. You must invoke the completion routine to allow the + /// redirection, allow the redirection with a modified request, or + /// pass nil to the completionHandler to cause the body of the redirection + /// response to be delivered as the payload of this request. The default + /// is to follow redirections. + /// + /// For tasks in background sessions, redirections will always be followed and this method will not be called. + void URLSession$16( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse willPerformHTTPRedirection, + required NSURLRequest newRequest, + required objc.ObjCBlock completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', ); - late final _CFTreeInsertSibling = - _CFTreeInsertSiblingPtr.asFunction(); - - void CFTreeRemove(CFTreeRef tree) { - return _CFTreeRemove(tree); - } - - late final _CFTreeRemovePtr = - _lookup>('CFTreeRemove'); - late final _CFTreeRemove = - _CFTreeRemovePtr.asFunction(); - - void CFTreeRemoveAllChildren(CFTreeRef tree) { - return _CFTreeRemoveAllChildren(tree); + } + _objc_msgSend_e1wgee( + object$.ref.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + session.ref.pointer, + task.ref.pointer, + willPerformHTTPRedirection.ref.pointer, + newRequest.ref.pointer, + completionHandler.ref.pointer, + ); } - late final _CFTreeRemoveAllChildrenPtr = - _lookup>( - 'CFTreeRemoveAllChildren', + /// Sent when a task cannot start the network loading process because the current + /// network connectivity is not available or sufficient for the task's request. + /// + /// This delegate will be called at most one time per task, and is only called if + /// the waitsForConnectivity property in the NSURLSessionConfiguration has been + /// set to YES. + /// + /// This delegate callback will never be called for background sessions, because + /// the waitForConnectivity property is ignored by those sessions. + void URLSession$17( + NSURLSession session, { + required NSURLSessionTask taskIsWaitingForConnectivity, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:taskIsWaitingForConnectivity:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:taskIsWaitingForConnectivity:', ); - late final _CFTreeRemoveAllChildren = - _CFTreeRemoveAllChildrenPtr.asFunction(); - - void CFTreeSortChildren( - CFTreeRef tree, - CFComparatorFunction comparator, - ffi.Pointer context, - ) { - return _CFTreeSortChildren(tree, comparator, context); - } - - late final _CFTreeSortChildrenPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFTreeRef, - CFComparatorFunction, - ffi.Pointer, - ) - > - >('CFTreeSortChildren'); - late final _CFTreeSortChildren = - _CFTreeSortChildrenPtr.asFunction< - void Function(CFTreeRef, CFComparatorFunction, ffi.Pointer) - >(); - - int CFURLCreateDataAndPropertiesFromResource( - CFAllocatorRef alloc, - CFURLRef url, - ffi.Pointer resourceData, - ffi.Pointer properties, - CFArrayRef desiredProperties, - ffi.Pointer errorCode, - ) { - return _CFURLCreateDataAndPropertiesFromResource( - alloc, - url, - resourceData, - properties, - desiredProperties, - errorCode, + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + session.ref.pointer, + taskIsWaitingForConnectivity.ref.pointer, ); } - late final _CFURLCreateDataAndPropertiesFromResourcePtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFAllocatorRef, - CFURLRef, - ffi.Pointer, - ffi.Pointer, - CFArrayRef, - ffi.Pointer, - ) - > - >('CFURLCreateDataAndPropertiesFromResource'); - late final _CFURLCreateDataAndPropertiesFromResource = - _CFURLCreateDataAndPropertiesFromResourcePtr.asFunction< - int Function( - CFAllocatorRef, - CFURLRef, - ffi.Pointer, - ffi.Pointer, - CFArrayRef, - ffi.Pointer, - ) - >(); - - int CFURLWriteDataAndPropertiesToResource( - CFURLRef url, - CFDataRef dataToWrite, - CFDictionaryRef propertiesToWrite, - ffi.Pointer errorCode, - ) { - return _CFURLWriteDataAndPropertiesToResource( - url, - dataToWrite, - propertiesToWrite, - errorCode, + /// If an application has received an + /// -application:handleEventsForBackgroundURLSession:completionHandler: + /// message, the session delegate will receive this message to indicate + /// that all messages previously enqueued for this session have been + /// delivered. At this time it is safe to invoke the previously stored + /// completion handler, or to begin any internal updates that will + /// result in invoking the completion handler. + void URLSessionDidFinishEventsForBackgroundURLSession(NSURLSession session) { + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSessionDidFinishEventsForBackgroundURLSession:', + ); + } + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + session.ref.pointer, ); } +} - late final _CFURLWriteDataAndPropertiesToResourcePtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFURLRef, - CFDataRef, - CFDictionaryRef, - ffi.Pointer, - ) - > - >('CFURLWriteDataAndPropertiesToResource'); - late final _CFURLWriteDataAndPropertiesToResource = - _CFURLWriteDataAndPropertiesToResourcePtr.asFunction< - int Function(CFURLRef, CFDataRef, CFDictionaryRef, ffi.Pointer) - >(); - - int CFURLDestroyResource(CFURLRef url, ffi.Pointer errorCode) { - return _CFURLDestroyResource(url, errorCode); - } - - late final _CFURLDestroyResourcePtr = - _lookup< - ffi.NativeFunction)> - >('CFURLDestroyResource'); - late final _CFURLDestroyResource = - _CFURLDestroyResourcePtr.asFunction< - int Function(CFURLRef, ffi.Pointer) - >(); - - CFTypeRef CFURLCreatePropertyFromResource( - CFAllocatorRef alloc, - CFURLRef url, - CFStringRef property, - ffi.Pointer errorCode, - ) { - return _CFURLCreatePropertyFromResource(alloc, url, property, errorCode); - } - - late final _CFURLCreatePropertyFromResourcePtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function( - CFAllocatorRef, - CFURLRef, - CFStringRef, - ffi.Pointer, - ) - > - >('CFURLCreatePropertyFromResource'); - late final _CFURLCreatePropertyFromResource = - _CFURLCreatePropertyFromResourcePtr.asFunction< - CFTypeRef Function( - CFAllocatorRef, - CFURLRef, - CFStringRef, - ffi.Pointer, - ) - >(); - - late final ffi.Pointer _kCFURLFileExists = _lookup( - 'kCFURLFileExists', - ); - - CFStringRef get kCFURLFileExists => _kCFURLFileExists.value; - - late final ffi.Pointer _kCFURLFileDirectoryContents = - _lookup('kCFURLFileDirectoryContents'); - - CFStringRef get kCFURLFileDirectoryContents => - _kCFURLFileDirectoryContents.value; - - late final ffi.Pointer _kCFURLFileLength = _lookup( - 'kCFURLFileLength', - ); - - CFStringRef get kCFURLFileLength => _kCFURLFileLength.value; - - late final ffi.Pointer _kCFURLFileLastModificationTime = - _lookup('kCFURLFileLastModificationTime'); - - CFStringRef get kCFURLFileLastModificationTime => - _kCFURLFileLastModificationTime.value; - - late final ffi.Pointer _kCFURLFilePOSIXMode = - _lookup('kCFURLFilePOSIXMode'); - - CFStringRef get kCFURLFilePOSIXMode => _kCFURLFilePOSIXMode.value; - - late final ffi.Pointer _kCFURLFileOwnerID = _lookup( - 'kCFURLFileOwnerID', - ); - - CFStringRef get kCFURLFileOwnerID => _kCFURLFileOwnerID.value; - - late final ffi.Pointer _kCFURLHTTPStatusCode = - _lookup('kCFURLHTTPStatusCode'); - - CFStringRef get kCFURLHTTPStatusCode => _kCFURLHTTPStatusCode.value; - - late final ffi.Pointer _kCFURLHTTPStatusLine = - _lookup('kCFURLHTTPStatusLine'); - - CFStringRef get kCFURLHTTPStatusLine => _kCFURLHTTPStatusLine.value; - - int CFUUIDGetTypeID() { - return _CFUUIDGetTypeID(); - } - - late final _CFUUIDGetTypeIDPtr = - _lookup>('CFUUIDGetTypeID'); - late final _CFUUIDGetTypeID = - _CFUUIDGetTypeIDPtr.asFunction(); - - CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc) { - return _CFUUIDCreate(alloc); - } +interface class NSURLSessionDataDelegate$Builder { + /// Returns the [objc.Protocol] object for this protocol. + static objc.Protocol get $protocol => + objc.Protocol.fromPointer(_protocol_NSURLSessionDataDelegate.cast()); - late final _CFUUIDCreatePtr = - _lookup>( - 'CFUUIDCreate', - ); - late final _CFUUIDCreate = - _CFUUIDCreatePtr.asFunction(); - - CFUUIDRef CFUUIDCreateWithBytes( - CFAllocatorRef alloc, - int byte0, - int byte1, - int byte2, - int byte3, - int byte4, - int byte5, - int byte6, - int byte7, - int byte8, - int byte9, - int byte10, - int byte11, - int byte12, - int byte13, - int byte14, - int byte15, - ) { - return _CFUUIDCreateWithBytes( - alloc, - byte0, - byte1, - byte2, - byte3, - byte4, - byte5, - byte6, - byte7, - byte8, - byte9, - byte10, - byte11, - byte12, - byte13, - byte14, - byte15, - ); - } - - late final _CFUUIDCreateWithBytesPtr = - _lookup< - ffi.NativeFunction< - CFUUIDRef Function( - CFAllocatorRef, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - ) - > - >('CFUUIDCreateWithBytes'); - late final _CFUUIDCreateWithBytes = - _CFUUIDCreateWithBytesPtr.asFunction< - CFUUIDRef Function( - CFAllocatorRef, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - ) - >(); - - CFUUIDRef CFUUIDCreateFromString(CFAllocatorRef alloc, CFStringRef uuidStr) { - return _CFUUIDCreateFromString(alloc, uuidStr); - } - - late final _CFUUIDCreateFromStringPtr = - _lookup< - ffi.NativeFunction - >('CFUUIDCreateFromString'); - late final _CFUUIDCreateFromString = - _CFUUIDCreateFromStringPtr.asFunction< - CFUUIDRef Function(CFAllocatorRef, CFStringRef) - >(); - - CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid) { - return _CFUUIDCreateString(alloc, uuid); - } - - late final _CFUUIDCreateStringPtr = - _lookup< - ffi.NativeFunction - >('CFUUIDCreateString'); - late final _CFUUIDCreateString = - _CFUUIDCreateStringPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFUUIDRef) - >(); - - CFUUIDRef CFUUIDGetConstantUUIDWithBytes( - CFAllocatorRef alloc, - int byte0, - int byte1, - int byte2, - int byte3, - int byte4, - int byte5, - int byte6, - int byte7, - int byte8, - int byte9, - int byte10, - int byte11, - int byte12, - int byte13, - int byte14, - int byte15, - ) { - return _CFUUIDGetConstantUUIDWithBytes( - alloc, - byte0, - byte1, - byte2, - byte3, - byte4, - byte5, - byte6, - byte7, - byte8, - byte9, - byte10, - byte11, - byte12, - byte13, - byte14, - byte15, - ); - } - - late final _CFUUIDGetConstantUUIDWithBytesPtr = - _lookup< - ffi.NativeFunction< - CFUUIDRef Function( - CFAllocatorRef, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - UInt8, - ) - > - >('CFUUIDGetConstantUUIDWithBytes'); - late final _CFUUIDGetConstantUUIDWithBytes = - _CFUUIDGetConstantUUIDWithBytesPtr.asFunction< - CFUUIDRef Function( - CFAllocatorRef, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - int, - ) - >(); - - CFUUIDBytes CFUUIDGetUUIDBytes(CFUUIDRef uuid) { - return _CFUUIDGetUUIDBytes(uuid); - } - - late final _CFUUIDGetUUIDBytesPtr = - _lookup>( - 'CFUUIDGetUUIDBytes', - ); - late final _CFUUIDGetUUIDBytes = - _CFUUIDGetUUIDBytesPtr.asFunction(); - - CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef alloc, CFUUIDBytes bytes) { - return _CFUUIDCreateFromUUIDBytes(alloc, bytes); - } - - late final _CFUUIDCreateFromUUIDBytesPtr = - _lookup< - ffi.NativeFunction - >('CFUUIDCreateFromUUIDBytes'); - late final _CFUUIDCreateFromUUIDBytes = - _CFUUIDCreateFromUUIDBytesPtr.asFunction< - CFUUIDRef Function(CFAllocatorRef, CFUUIDBytes) - >(); - - CFURLRef CFCopyHomeDirectoryURL() { - return _CFCopyHomeDirectoryURL(); - } - - late final _CFCopyHomeDirectoryURLPtr = - _lookup>( - 'CFCopyHomeDirectoryURL', - ); - late final _CFCopyHomeDirectoryURL = - _CFCopyHomeDirectoryURLPtr.asFunction(); - - late final ffi.Pointer _kCFBundleInfoDictionaryVersionKey = - _lookup('kCFBundleInfoDictionaryVersionKey'); - - CFStringRef get kCFBundleInfoDictionaryVersionKey => - _kCFBundleInfoDictionaryVersionKey.value; - - late final ffi.Pointer _kCFBundleExecutableKey = - _lookup('kCFBundleExecutableKey'); - - CFStringRef get kCFBundleExecutableKey => _kCFBundleExecutableKey.value; - - late final ffi.Pointer _kCFBundleIdentifierKey = - _lookup('kCFBundleIdentifierKey'); - - CFStringRef get kCFBundleIdentifierKey => _kCFBundleIdentifierKey.value; - - late final ffi.Pointer _kCFBundleVersionKey = - _lookup('kCFBundleVersionKey'); - - CFStringRef get kCFBundleVersionKey => _kCFBundleVersionKey.value; - - late final ffi.Pointer _kCFBundleDevelopmentRegionKey = - _lookup('kCFBundleDevelopmentRegionKey'); - - CFStringRef get kCFBundleDevelopmentRegionKey => - _kCFBundleDevelopmentRegionKey.value; - - late final ffi.Pointer _kCFBundleNameKey = _lookup( - 'kCFBundleNameKey', - ); - - CFStringRef get kCFBundleNameKey => _kCFBundleNameKey.value; - - late final ffi.Pointer _kCFBundleLocalizationsKey = - _lookup('kCFBundleLocalizationsKey'); - - CFStringRef get kCFBundleLocalizationsKey => _kCFBundleLocalizationsKey.value; - - CFBundleRef CFBundleGetMainBundle() { - return _CFBundleGetMainBundle(); - } - - late final _CFBundleGetMainBundlePtr = - _lookup>( - 'CFBundleGetMainBundle', - ); - late final _CFBundleGetMainBundle = - _CFBundleGetMainBundlePtr.asFunction(); - - CFBundleRef CFBundleGetBundleWithIdentifier(CFStringRef bundleID) { - return _CFBundleGetBundleWithIdentifier(bundleID); - } - - late final _CFBundleGetBundleWithIdentifierPtr = - _lookup>( - 'CFBundleGetBundleWithIdentifier', - ); - late final _CFBundleGetBundleWithIdentifier = - _CFBundleGetBundleWithIdentifierPtr.asFunction< - CFBundleRef Function(CFStringRef) - >(); - - CFArrayRef CFBundleGetAllBundles() { - return _CFBundleGetAllBundles(); - } - - late final _CFBundleGetAllBundlesPtr = - _lookup>( - 'CFBundleGetAllBundles', - ); - late final _CFBundleGetAllBundles = - _CFBundleGetAllBundlesPtr.asFunction(); - - int CFBundleGetTypeID() { - return _CFBundleGetTypeID(); - } - - late final _CFBundleGetTypeIDPtr = - _lookup>('CFBundleGetTypeID'); - late final _CFBundleGetTypeID = - _CFBundleGetTypeIDPtr.asFunction(); - - CFBundleRef CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL) { - return _CFBundleCreate(allocator, bundleURL); - } - - late final _CFBundleCreatePtr = - _lookup< - ffi.NativeFunction - >('CFBundleCreate'); - late final _CFBundleCreate = - _CFBundleCreatePtr.asFunction< - CFBundleRef Function(CFAllocatorRef, CFURLRef) - >(); - - CFArrayRef CFBundleCreateBundlesFromDirectory( - CFAllocatorRef allocator, - CFURLRef directoryURL, - CFStringRef bundleType, - ) { - return _CFBundleCreateBundlesFromDirectory( - allocator, - directoryURL, - bundleType, + /// Builds an object that implements the NSURLSessionDataDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionDataDelegate implement({ + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? + URLSession_dataTask_didBecomeDownloadTask_, + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? + URLSession_dataTask_didBecomeStreamTask_, + void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? + URLSession_dataTask_didReceiveData_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_didReceiveResponse_completionHandler_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_willCacheResponse_completionHandler_, + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionDataDelegate', ); - } - - late final _CFBundleCreateBundlesFromDirectoryPtr = - _lookup< - ffi.NativeFunction< - CFArrayRef Function(CFAllocatorRef, CFURLRef, CFStringRef) - > - >('CFBundleCreateBundlesFromDirectory'); - late final _CFBundleCreateBundlesFromDirectory = - _CFBundleCreateBundlesFromDirectoryPtr.asFunction< - CFArrayRef Function(CFAllocatorRef, CFURLRef, CFStringRef) - >(); - - CFURLRef CFBundleCopyBundleURL(CFBundleRef bundle) { - return _CFBundleCopyBundleURL(bundle); - } - - late final _CFBundleCopyBundleURLPtr = - _lookup>( - 'CFBundleCopyBundleURL', - ); - late final _CFBundleCopyBundleURL = - _CFBundleCopyBundleURLPtr.asFunction(); - - CFTypeRef CFBundleGetValueForInfoDictionaryKey( - CFBundleRef bundle, - CFStringRef key, - ) { - return _CFBundleGetValueForInfoDictionaryKey(bundle, key); - } - - late final _CFBundleGetValueForInfoDictionaryKeyPtr = - _lookup>( - 'CFBundleGetValueForInfoDictionaryKey', - ); - late final _CFBundleGetValueForInfoDictionaryKey = - _CFBundleGetValueForInfoDictionaryKeyPtr.asFunction< - CFTypeRef Function(CFBundleRef, CFStringRef) - >(); - - CFDictionaryRef CFBundleGetInfoDictionary(CFBundleRef bundle) { - return _CFBundleGetInfoDictionary(bundle); - } - - late final _CFBundleGetInfoDictionaryPtr = - _lookup>( - 'CFBundleGetInfoDictionary', - ); - late final _CFBundleGetInfoDictionary = - _CFBundleGetInfoDictionaryPtr.asFunction< - CFDictionaryRef Function(CFBundleRef) - >(); - - CFDictionaryRef CFBundleGetLocalInfoDictionary(CFBundleRef bundle) { - return _CFBundleGetLocalInfoDictionary(bundle); - } - - late final _CFBundleGetLocalInfoDictionaryPtr = - _lookup>( - 'CFBundleGetLocalInfoDictionary', - ); - late final _CFBundleGetLocalInfoDictionary = - _CFBundleGetLocalInfoDictionaryPtr.asFunction< - CFDictionaryRef Function(CFBundleRef) - >(); - - void CFBundleGetPackageInfo( - CFBundleRef bundle, - ffi.Pointer packageType, - ffi.Pointer packageCreator, - ) { - return _CFBundleGetPackageInfo(bundle, packageType, packageCreator); - } - - late final _CFBundleGetPackageInfoPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFBundleRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFBundleGetPackageInfo'); - late final _CFBundleGetPackageInfo = - _CFBundleGetPackageInfoPtr.asFunction< - void Function(CFBundleRef, ffi.Pointer, ffi.Pointer) - >(); - - CFStringRef CFBundleGetIdentifier(CFBundleRef bundle) { - return _CFBundleGetIdentifier(bundle); - } - - late final _CFBundleGetIdentifierPtr = - _lookup>( - 'CFBundleGetIdentifier', - ); - late final _CFBundleGetIdentifier = - _CFBundleGetIdentifierPtr.asFunction(); - - int CFBundleGetVersionNumber(CFBundleRef bundle) { - return _CFBundleGetVersionNumber(bundle); - } - - late final _CFBundleGetVersionNumberPtr = - _lookup>( - 'CFBundleGetVersionNumber', - ); - late final _CFBundleGetVersionNumber = - _CFBundleGetVersionNumberPtr.asFunction(); - - CFStringRef CFBundleGetDevelopmentRegion(CFBundleRef bundle) { - return _CFBundleGetDevelopmentRegion(bundle); - } - - late final _CFBundleGetDevelopmentRegionPtr = - _lookup>( - 'CFBundleGetDevelopmentRegion', - ); - late final _CFBundleGetDevelopmentRegion = - _CFBundleGetDevelopmentRegionPtr.asFunction< - CFStringRef Function(CFBundleRef) - >(); - - CFURLRef CFBundleCopySupportFilesDirectoryURL(CFBundleRef bundle) { - return _CFBundleCopySupportFilesDirectoryURL(bundle); - } - - late final _CFBundleCopySupportFilesDirectoryURLPtr = - _lookup>( - 'CFBundleCopySupportFilesDirectoryURL', - ); - late final _CFBundleCopySupportFilesDirectoryURL = - _CFBundleCopySupportFilesDirectoryURLPtr.asFunction< - CFURLRef Function(CFBundleRef) - >(); - - CFURLRef CFBundleCopyResourcesDirectoryURL(CFBundleRef bundle) { - return _CFBundleCopyResourcesDirectoryURL(bundle); - } - - late final _CFBundleCopyResourcesDirectoryURLPtr = - _lookup>( - 'CFBundleCopyResourcesDirectoryURL', - ); - late final _CFBundleCopyResourcesDirectoryURL = - _CFBundleCopyResourcesDirectoryURLPtr.asFunction< - CFURLRef Function(CFBundleRef) - >(); - - CFURLRef CFBundleCopyPrivateFrameworksURL(CFBundleRef bundle) { - return _CFBundleCopyPrivateFrameworksURL(bundle); - } - - late final _CFBundleCopyPrivateFrameworksURLPtr = - _lookup>( - 'CFBundleCopyPrivateFrameworksURL', - ); - late final _CFBundleCopyPrivateFrameworksURL = - _CFBundleCopyPrivateFrameworksURLPtr.asFunction< - CFURLRef Function(CFBundleRef) - >(); - - CFURLRef CFBundleCopySharedFrameworksURL(CFBundleRef bundle) { - return _CFBundleCopySharedFrameworksURL(bundle); - } - - late final _CFBundleCopySharedFrameworksURLPtr = - _lookup>( - 'CFBundleCopySharedFrameworksURL', - ); - late final _CFBundleCopySharedFrameworksURL = - _CFBundleCopySharedFrameworksURLPtr.asFunction< - CFURLRef Function(CFBundleRef) - >(); - - CFURLRef CFBundleCopySharedSupportURL(CFBundleRef bundle) { - return _CFBundleCopySharedSupportURL(bundle); - } - - late final _CFBundleCopySharedSupportURLPtr = - _lookup>( - 'CFBundleCopySharedSupportURL', - ); - late final _CFBundleCopySharedSupportURL = - _CFBundleCopySharedSupportURLPtr.asFunction< - CFURLRef Function(CFBundleRef) - >(); - - CFURLRef CFBundleCopyBuiltInPlugInsURL(CFBundleRef bundle) { - return _CFBundleCopyBuiltInPlugInsURL(bundle); - } - - late final _CFBundleCopyBuiltInPlugInsURLPtr = - _lookup>( - 'CFBundleCopyBuiltInPlugInsURL', - ); - late final _CFBundleCopyBuiltInPlugInsURL = - _CFBundleCopyBuiltInPlugInsURLPtr.asFunction< - CFURLRef Function(CFBundleRef) - >(); - - CFDictionaryRef CFBundleCopyInfoDictionaryInDirectory(CFURLRef bundleURL) { - return _CFBundleCopyInfoDictionaryInDirectory(bundleURL); - } - - late final _CFBundleCopyInfoDictionaryInDirectoryPtr = - _lookup>( - 'CFBundleCopyInfoDictionaryInDirectory', - ); - late final _CFBundleCopyInfoDictionaryInDirectory = - _CFBundleCopyInfoDictionaryInDirectoryPtr.asFunction< - CFDictionaryRef Function(CFURLRef) - >(); - - int CFBundleGetPackageInfoInDirectory( - CFURLRef url, - ffi.Pointer packageType, - ffi.Pointer packageCreator, - ) { - return _CFBundleGetPackageInfoInDirectory(url, packageType, packageCreator); - } - - late final _CFBundleGetPackageInfoInDirectoryPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFURLRef, ffi.Pointer, ffi.Pointer) - > - >('CFBundleGetPackageInfoInDirectory'); - late final _CFBundleGetPackageInfoInDirectory = - _CFBundleGetPackageInfoInDirectoryPtr.asFunction< - int Function(CFURLRef, ffi.Pointer, ffi.Pointer) - >(); - - CFURLRef CFBundleCopyResourceURL( - CFBundleRef bundle, - CFStringRef resourceName, - CFStringRef resourceType, - CFStringRef subDirName, - ) { - return _CFBundleCopyResourceURL( - bundle, - resourceName, - resourceType, - subDirName, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implement( + builder, + URLSession_dataTask_didBecomeDownloadTask_, ); - } - - late final _CFBundleCopyResourceURLPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFBundleRef, CFStringRef, CFStringRef, CFStringRef) - > - >('CFBundleCopyResourceURL'); - late final _CFBundleCopyResourceURL = - _CFBundleCopyResourceURLPtr.asFunction< - CFURLRef Function(CFBundleRef, CFStringRef, CFStringRef, CFStringRef) - >(); - - CFArrayRef CFBundleCopyResourceURLsOfType( - CFBundleRef bundle, - CFStringRef resourceType, - CFStringRef subDirName, - ) { - return _CFBundleCopyResourceURLsOfType(bundle, resourceType, subDirName); - } - - late final _CFBundleCopyResourceURLsOfTypePtr = - _lookup< - ffi.NativeFunction< - CFArrayRef Function(CFBundleRef, CFStringRef, CFStringRef) - > - >('CFBundleCopyResourceURLsOfType'); - late final _CFBundleCopyResourceURLsOfType = - _CFBundleCopyResourceURLsOfTypePtr.asFunction< - CFArrayRef Function(CFBundleRef, CFStringRef, CFStringRef) - >(); - - CFStringRef CFBundleCopyLocalizedString( - CFBundleRef bundle, - CFStringRef key, - CFStringRef value, - CFStringRef tableName, - ) { - return _CFBundleCopyLocalizedString(bundle, key, value, tableName); - } - - late final _CFBundleCopyLocalizedStringPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFBundleRef, - CFStringRef, - CFStringRef, - CFStringRef, - ) - > - >('CFBundleCopyLocalizedString'); - late final _CFBundleCopyLocalizedString = - _CFBundleCopyLocalizedStringPtr.asFunction< - CFStringRef Function(CFBundleRef, CFStringRef, CFStringRef, CFStringRef) - >(); - - CFStringRef CFBundleCopyLocalizedStringForLocalizations( - CFBundleRef bundle, - CFStringRef key, - CFStringRef value, - CFStringRef tableName, - CFArrayRef localizations, - ) { - return _CFBundleCopyLocalizedStringForLocalizations( - bundle, - key, - value, - tableName, - localizations, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implement( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - } - - late final _CFBundleCopyLocalizedStringForLocalizationsPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFBundleRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFArrayRef, - ) - > - >('CFBundleCopyLocalizedStringForLocalizations'); - late final _CFBundleCopyLocalizedStringForLocalizations = - _CFBundleCopyLocalizedStringForLocalizationsPtr.asFunction< - CFStringRef Function( - CFBundleRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFArrayRef, - ) - >(); - - CFURLRef CFBundleCopyResourceURLInDirectory( - CFURLRef bundleURL, - CFStringRef resourceName, - CFStringRef resourceType, - CFStringRef subDirName, - ) { - return _CFBundleCopyResourceURLInDirectory( - bundleURL, - resourceName, - resourceType, - subDirName, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implement( + builder, + URLSession_dataTask_didReceiveData_, ); - } - - late final _CFBundleCopyResourceURLInDirectoryPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function(CFURLRef, CFStringRef, CFStringRef, CFStringRef) - > - >('CFBundleCopyResourceURLInDirectory'); - late final _CFBundleCopyResourceURLInDirectory = - _CFBundleCopyResourceURLInDirectoryPtr.asFunction< - CFURLRef Function(CFURLRef, CFStringRef, CFStringRef, CFStringRef) - >(); - - CFArrayRef CFBundleCopyResourceURLsOfTypeInDirectory( - CFURLRef bundleURL, - CFStringRef resourceType, - CFStringRef subDirName, - ) { - return _CFBundleCopyResourceURLsOfTypeInDirectory( - bundleURL, - resourceType, - subDirName, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implement( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - } - - late final _CFBundleCopyResourceURLsOfTypeInDirectoryPtr = - _lookup< - ffi.NativeFunction< - CFArrayRef Function(CFURLRef, CFStringRef, CFStringRef) - > - >('CFBundleCopyResourceURLsOfTypeInDirectory'); - late final _CFBundleCopyResourceURLsOfTypeInDirectory = - _CFBundleCopyResourceURLsOfTypeInDirectoryPtr.asFunction< - CFArrayRef Function(CFURLRef, CFStringRef, CFStringRef) - >(); - - CFArrayRef CFBundleCopyBundleLocalizations(CFBundleRef bundle) { - return _CFBundleCopyBundleLocalizations(bundle); - } - - late final _CFBundleCopyBundleLocalizationsPtr = - _lookup>( - 'CFBundleCopyBundleLocalizations', - ); - late final _CFBundleCopyBundleLocalizations = - _CFBundleCopyBundleLocalizationsPtr.asFunction< - CFArrayRef Function(CFBundleRef) - >(); - - CFArrayRef CFBundleCopyPreferredLocalizationsFromArray(CFArrayRef locArray) { - return _CFBundleCopyPreferredLocalizationsFromArray(locArray); - } - - late final _CFBundleCopyPreferredLocalizationsFromArrayPtr = - _lookup>( - 'CFBundleCopyPreferredLocalizationsFromArray', - ); - late final _CFBundleCopyPreferredLocalizationsFromArray = - _CFBundleCopyPreferredLocalizationsFromArrayPtr.asFunction< - CFArrayRef Function(CFArrayRef) - >(); - - CFArrayRef CFBundleCopyLocalizationsForPreferences( - CFArrayRef locArray, - CFArrayRef prefArray, - ) { - return _CFBundleCopyLocalizationsForPreferences(locArray, prefArray); - } - - late final _CFBundleCopyLocalizationsForPreferencesPtr = - _lookup>( - 'CFBundleCopyLocalizationsForPreferences', - ); - late final _CFBundleCopyLocalizationsForPreferences = - _CFBundleCopyLocalizationsForPreferencesPtr.asFunction< - CFArrayRef Function(CFArrayRef, CFArrayRef) - >(); - - CFURLRef CFBundleCopyResourceURLForLocalization( - CFBundleRef bundle, - CFStringRef resourceName, - CFStringRef resourceType, - CFStringRef subDirName, - CFStringRef localizationName, - ) { - return _CFBundleCopyResourceURLForLocalization( - bundle, - resourceName, - resourceType, - subDirName, - localizationName, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implement( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - } - - late final _CFBundleCopyResourceURLForLocalizationPtr = - _lookup< - ffi.NativeFunction< - CFURLRef Function( - CFBundleRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFStringRef, - ) - > - >('CFBundleCopyResourceURLForLocalization'); - late final _CFBundleCopyResourceURLForLocalization = - _CFBundleCopyResourceURLForLocalizationPtr.asFunction< - CFURLRef Function( - CFBundleRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFStringRef, - ) - >(); - - CFArrayRef CFBundleCopyResourceURLsOfTypeForLocalization( - CFBundleRef bundle, - CFStringRef resourceType, - CFStringRef subDirName, - CFStringRef localizationName, - ) { - return _CFBundleCopyResourceURLsOfTypeForLocalization( - bundle, - resourceType, - subDirName, - localizationName, + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, ); - } - - late final _CFBundleCopyResourceURLsOfTypeForLocalizationPtr = - _lookup< - ffi.NativeFunction< - CFArrayRef Function( - CFBundleRef, - CFStringRef, - CFStringRef, - CFStringRef, - ) - > - >('CFBundleCopyResourceURLsOfTypeForLocalization'); - late final _CFBundleCopyResourceURLsOfTypeForLocalization = - _CFBundleCopyResourceURLsOfTypeForLocalizationPtr.asFunction< - CFArrayRef Function(CFBundleRef, CFStringRef, CFStringRef, CFStringRef) - >(); - - CFDictionaryRef CFBundleCopyInfoDictionaryForURL(CFURLRef url) { - return _CFBundleCopyInfoDictionaryForURL(url); - } - - late final _CFBundleCopyInfoDictionaryForURLPtr = - _lookup>( - 'CFBundleCopyInfoDictionaryForURL', - ); - late final _CFBundleCopyInfoDictionaryForURL = - _CFBundleCopyInfoDictionaryForURLPtr.asFunction< - CFDictionaryRef Function(CFURLRef) - >(); - - CFArrayRef CFBundleCopyLocalizationsForURL(CFURLRef url) { - return _CFBundleCopyLocalizationsForURL(url); - } - - late final _CFBundleCopyLocalizationsForURLPtr = - _lookup>( - 'CFBundleCopyLocalizationsForURL', - ); - late final _CFBundleCopyLocalizationsForURL = - _CFBundleCopyLocalizationsForURLPtr.asFunction< - CFArrayRef Function(CFURLRef) - >(); - - CFArrayRef CFBundleCopyExecutableArchitecturesForURL(CFURLRef url) { - return _CFBundleCopyExecutableArchitecturesForURL(url); - } - - late final _CFBundleCopyExecutableArchitecturesForURLPtr = - _lookup>( - 'CFBundleCopyExecutableArchitecturesForURL', - ); - late final _CFBundleCopyExecutableArchitecturesForURL = - _CFBundleCopyExecutableArchitecturesForURLPtr.asFunction< - CFArrayRef Function(CFURLRef) - >(); - - CFURLRef CFBundleCopyExecutableURL(CFBundleRef bundle) { - return _CFBundleCopyExecutableURL(bundle); - } - - late final _CFBundleCopyExecutableURLPtr = - _lookup>( - 'CFBundleCopyExecutableURL', - ); - late final _CFBundleCopyExecutableURL = - _CFBundleCopyExecutableURLPtr.asFunction< - CFURLRef Function(CFBundleRef) - >(); - - CFArrayRef CFBundleCopyExecutableArchitectures(CFBundleRef bundle) { - return _CFBundleCopyExecutableArchitectures(bundle); - } - - late final _CFBundleCopyExecutableArchitecturesPtr = - _lookup>( - 'CFBundleCopyExecutableArchitectures', - ); - late final _CFBundleCopyExecutableArchitectures = - _CFBundleCopyExecutableArchitecturesPtr.asFunction< - CFArrayRef Function(CFBundleRef) - >(); - - int CFBundlePreflightExecutable( - CFBundleRef bundle, - ffi.Pointer error, - ) { - return _CFBundlePreflightExecutable(bundle, error); - } - - late final _CFBundlePreflightExecutablePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFBundleRef, ffi.Pointer) - > - >('CFBundlePreflightExecutable'); - late final _CFBundlePreflightExecutable = - _CFBundlePreflightExecutablePtr.asFunction< - int Function(CFBundleRef, ffi.Pointer) - >(); - - int CFBundleLoadExecutableAndReturnError( - CFBundleRef bundle, - ffi.Pointer error, - ) { - return _CFBundleLoadExecutableAndReturnError(bundle, error); - } - - late final _CFBundleLoadExecutableAndReturnErrorPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFBundleRef, ffi.Pointer) - > - >('CFBundleLoadExecutableAndReturnError'); - late final _CFBundleLoadExecutableAndReturnError = - _CFBundleLoadExecutableAndReturnErrorPtr.asFunction< - int Function(CFBundleRef, ffi.Pointer) - >(); - - int CFBundleLoadExecutable(CFBundleRef bundle) { - return _CFBundleLoadExecutable(bundle); - } - - late final _CFBundleLoadExecutablePtr = - _lookup>( - 'CFBundleLoadExecutable', - ); - late final _CFBundleLoadExecutable = - _CFBundleLoadExecutablePtr.asFunction(); - - int CFBundleIsExecutableLoaded(CFBundleRef bundle) { - return _CFBundleIsExecutableLoaded(bundle); - } - - late final _CFBundleIsExecutableLoadedPtr = - _lookup>( - 'CFBundleIsExecutableLoaded', - ); - late final _CFBundleIsExecutableLoaded = - _CFBundleIsExecutableLoadedPtr.asFunction(); - - void CFBundleUnloadExecutable(CFBundleRef bundle) { - return _CFBundleUnloadExecutable(bundle); - } - - late final _CFBundleUnloadExecutablePtr = - _lookup>( - 'CFBundleUnloadExecutable', - ); - late final _CFBundleUnloadExecutable = - _CFBundleUnloadExecutablePtr.asFunction(); - - ffi.Pointer CFBundleGetFunctionPointerForName( - CFBundleRef bundle, - CFStringRef functionName, - ) { - return _CFBundleGetFunctionPointerForName(bundle, functionName); - } - - late final _CFBundleGetFunctionPointerForNamePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFBundleRef, CFStringRef) - > - >('CFBundleGetFunctionPointerForName'); - late final _CFBundleGetFunctionPointerForName = - _CFBundleGetFunctionPointerForNamePtr.asFunction< - ffi.Pointer Function(CFBundleRef, CFStringRef) - >(); - - void CFBundleGetFunctionPointersForNames( - CFBundleRef bundle, - CFArrayRef functionNames, - ffi.Pointer> ftbl, - ) { - return _CFBundleGetFunctionPointersForNames(bundle, functionNames, ftbl); - } - - late final _CFBundleGetFunctionPointersForNamesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFBundleRef, - CFArrayRef, - ffi.Pointer>, - ) - > - >('CFBundleGetFunctionPointersForNames'); - late final _CFBundleGetFunctionPointersForNames = - _CFBundleGetFunctionPointersForNamesPtr.asFunction< - void Function( - CFBundleRef, - CFArrayRef, - ffi.Pointer>, - ) - >(); - - ffi.Pointer CFBundleGetDataPointerForName( - CFBundleRef bundle, - CFStringRef symbolName, - ) { - return _CFBundleGetDataPointerForName(bundle, symbolName); - } - - late final _CFBundleGetDataPointerForNamePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFBundleRef, CFStringRef) - > - >('CFBundleGetDataPointerForName'); - late final _CFBundleGetDataPointerForName = - _CFBundleGetDataPointerForNamePtr.asFunction< - ffi.Pointer Function(CFBundleRef, CFStringRef) - >(); - - void CFBundleGetDataPointersForNames( - CFBundleRef bundle, - CFArrayRef symbolNames, - ffi.Pointer> stbl, - ) { - return _CFBundleGetDataPointersForNames(bundle, symbolNames, stbl); - } - - late final _CFBundleGetDataPointersForNamesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFBundleRef, - CFArrayRef, - ffi.Pointer>, - ) - > - >('CFBundleGetDataPointersForNames'); - late final _CFBundleGetDataPointersForNames = - _CFBundleGetDataPointersForNamesPtr.asFunction< - void Function( - CFBundleRef, - CFArrayRef, - ffi.Pointer>, - ) - >(); - - CFURLRef CFBundleCopyAuxiliaryExecutableURL( - CFBundleRef bundle, - CFStringRef executableName, - ) { - return _CFBundleCopyAuxiliaryExecutableURL(bundle, executableName); - } - - late final _CFBundleCopyAuxiliaryExecutableURLPtr = - _lookup>( - 'CFBundleCopyAuxiliaryExecutableURL', - ); - late final _CFBundleCopyAuxiliaryExecutableURL = - _CFBundleCopyAuxiliaryExecutableURLPtr.asFunction< - CFURLRef Function(CFBundleRef, CFStringRef) - >(); - - int CFBundleIsExecutableLoadable(CFBundleRef bundle) { - return _CFBundleIsExecutableLoadable(bundle); - } - - late final _CFBundleIsExecutableLoadablePtr = - _lookup>( - 'CFBundleIsExecutableLoadable', - ); - late final _CFBundleIsExecutableLoadable = - _CFBundleIsExecutableLoadablePtr.asFunction(); - - int CFBundleIsExecutableLoadableForURL(CFURLRef url) { - return _CFBundleIsExecutableLoadableForURL(url); - } - - late final _CFBundleIsExecutableLoadableForURLPtr = - _lookup>( - 'CFBundleIsExecutableLoadableForURL', - ); - late final _CFBundleIsExecutableLoadableForURL = - _CFBundleIsExecutableLoadableForURLPtr.asFunction< - int Function(CFURLRef) - >(); - - int CFBundleIsArchitectureLoadable(int arch) { - return _CFBundleIsArchitectureLoadable(arch); - } - - late final _CFBundleIsArchitectureLoadablePtr = - _lookup>( - 'CFBundleIsArchitectureLoadable', - ); - late final _CFBundleIsArchitectureLoadable = - _CFBundleIsArchitectureLoadablePtr.asFunction(); - - CFPlugInRef CFBundleGetPlugIn(CFBundleRef bundle) { - return _CFBundleGetPlugIn(bundle); - } - - late final _CFBundleGetPlugInPtr = - _lookup>( - 'CFBundleGetPlugIn', - ); - late final _CFBundleGetPlugIn = - _CFBundleGetPlugInPtr.asFunction(); - - int CFBundleOpenBundleResourceMap(CFBundleRef bundle) { - return _CFBundleOpenBundleResourceMap(bundle); - } - - late final _CFBundleOpenBundleResourceMapPtr = - _lookup>( - 'CFBundleOpenBundleResourceMap', - ); - late final _CFBundleOpenBundleResourceMap = - _CFBundleOpenBundleResourceMapPtr.asFunction(); - - int CFBundleOpenBundleResourceFiles( - CFBundleRef bundle, - ffi.Pointer refNum, - ffi.Pointer localizedRefNum, - ) { - return _CFBundleOpenBundleResourceFiles(bundle, refNum, localizedRefNum); - } - - late final _CFBundleOpenBundleResourceFilesPtr = - _lookup< - ffi.NativeFunction< - SInt32 Function( - CFBundleRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFBundleOpenBundleResourceFiles'); - late final _CFBundleOpenBundleResourceFiles = - _CFBundleOpenBundleResourceFilesPtr.asFunction< - int Function( - CFBundleRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - void CFBundleCloseBundleResourceMap(CFBundleRef bundle, int refNum) { - return _CFBundleCloseBundleResourceMap(bundle, refNum); - } - - late final _CFBundleCloseBundleResourceMapPtr = - _lookup< - ffi.NativeFunction - >('CFBundleCloseBundleResourceMap'); - late final _CFBundleCloseBundleResourceMap = - _CFBundleCloseBundleResourceMapPtr.asFunction< - void Function(CFBundleRef, int) - >(); - - int CFMessagePortGetTypeID() { - return _CFMessagePortGetTypeID(); - } - - late final _CFMessagePortGetTypeIDPtr = - _lookup>( - 'CFMessagePortGetTypeID', - ); - late final _CFMessagePortGetTypeID = - _CFMessagePortGetTypeIDPtr.asFunction(); - - CFMessagePortRef CFMessagePortCreateLocal( - CFAllocatorRef allocator, - CFStringRef name, - CFMessagePortCallBack callout, - ffi.Pointer context, - ffi.Pointer shouldFreeInfo, - ) { - return _CFMessagePortCreateLocal( - allocator, - name, - callout, - context, - shouldFreeInfo, + NSURLSessionDataDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implement( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implement( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implement( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implement( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implement( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implement( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionDataDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), ); } - late final _CFMessagePortCreateLocalPtr = - _lookup< - ffi.NativeFunction< - CFMessagePortRef Function( - CFAllocatorRef, - CFStringRef, - CFMessagePortCallBack, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFMessagePortCreateLocal'); - late final _CFMessagePortCreateLocal = - _CFMessagePortCreateLocalPtr.asFunction< - CFMessagePortRef Function( - CFAllocatorRef, - CFStringRef, - CFMessagePortCallBack, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFMessagePortRef CFMessagePortCreateRemote( - CFAllocatorRef allocator, - CFStringRef name, - ) { - return _CFMessagePortCreateRemote(allocator, name); - } - - late final _CFMessagePortCreateRemotePtr = - _lookup< - ffi.NativeFunction< - CFMessagePortRef Function(CFAllocatorRef, CFStringRef) - > - >('CFMessagePortCreateRemote'); - late final _CFMessagePortCreateRemote = - _CFMessagePortCreateRemotePtr.asFunction< - CFMessagePortRef Function(CFAllocatorRef, CFStringRef) - >(); - - int CFMessagePortIsRemote(CFMessagePortRef ms) { - return _CFMessagePortIsRemote(ms); - } - - late final _CFMessagePortIsRemotePtr = - _lookup>( - 'CFMessagePortIsRemote', - ); - late final _CFMessagePortIsRemote = - _CFMessagePortIsRemotePtr.asFunction(); - - CFStringRef CFMessagePortGetName(CFMessagePortRef ms) { - return _CFMessagePortGetName(ms); - } - - late final _CFMessagePortGetNamePtr = - _lookup>( - 'CFMessagePortGetName', - ); - late final _CFMessagePortGetName = - _CFMessagePortGetNamePtr.asFunction< - CFStringRef Function(CFMessagePortRef) - >(); - - int CFMessagePortSetName(CFMessagePortRef ms, CFStringRef newName) { - return _CFMessagePortSetName(ms, newName); - } - - late final _CFMessagePortSetNamePtr = - _lookup< - ffi.NativeFunction - >('CFMessagePortSetName'); - late final _CFMessagePortSetName = - _CFMessagePortSetNamePtr.asFunction< - int Function(CFMessagePortRef, CFStringRef) - >(); - - void CFMessagePortGetContext( - CFMessagePortRef ms, - ffi.Pointer context, - ) { - return _CFMessagePortGetContext(ms, context); - } - - late final _CFMessagePortGetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMessagePortRef, ffi.Pointer) - > - >('CFMessagePortGetContext'); - late final _CFMessagePortGetContext = - _CFMessagePortGetContextPtr.asFunction< - void Function(CFMessagePortRef, ffi.Pointer) - >(); - - void CFMessagePortInvalidate(CFMessagePortRef ms) { - return _CFMessagePortInvalidate(ms); - } - - late final _CFMessagePortInvalidatePtr = - _lookup>( - 'CFMessagePortInvalidate', - ); - late final _CFMessagePortInvalidate = - _CFMessagePortInvalidatePtr.asFunction(); - - int CFMessagePortIsValid(CFMessagePortRef ms) { - return _CFMessagePortIsValid(ms); - } - - late final _CFMessagePortIsValidPtr = - _lookup>( - 'CFMessagePortIsValid', - ); - late final _CFMessagePortIsValid = - _CFMessagePortIsValidPtr.asFunction(); - - CFMessagePortInvalidationCallBack CFMessagePortGetInvalidationCallBack( - CFMessagePortRef ms, - ) { - return _CFMessagePortGetInvalidationCallBack(ms); - } - - late final _CFMessagePortGetInvalidationCallBackPtr = - _lookup< - ffi.NativeFunction< - CFMessagePortInvalidationCallBack Function(CFMessagePortRef) - > - >('CFMessagePortGetInvalidationCallBack'); - late final _CFMessagePortGetInvalidationCallBack = - _CFMessagePortGetInvalidationCallBackPtr.asFunction< - CFMessagePortInvalidationCallBack Function(CFMessagePortRef) - >(); - - void CFMessagePortSetInvalidationCallBack( - CFMessagePortRef ms, - CFMessagePortInvalidationCallBack callout, - ) { - return _CFMessagePortSetInvalidationCallBack(ms, callout); - } - - late final _CFMessagePortSetInvalidationCallBackPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMessagePortRef, CFMessagePortInvalidationCallBack) - > - >('CFMessagePortSetInvalidationCallBack'); - late final _CFMessagePortSetInvalidationCallBack = - _CFMessagePortSetInvalidationCallBackPtr.asFunction< - void Function(CFMessagePortRef, CFMessagePortInvalidationCallBack) - >(); - - int CFMessagePortSendRequest( - CFMessagePortRef remote, - int msgid, - CFDataRef data, - double sendTimeout, - double rcvTimeout, - CFStringRef replyMode, - ffi.Pointer returnData, - ) { - return _CFMessagePortSendRequest( - remote, - msgid, - data, - sendTimeout, - rcvTimeout, - replyMode, - returnData, + /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilder( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? + URLSession_dataTask_didBecomeDownloadTask_, + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? + URLSession_dataTask_didBecomeStreamTask_, + void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? + URLSession_dataTask_didReceiveData_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_didReceiveResponse_completionHandler_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_willCacheResponse_completionHandler_, + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implement( + builder, + URLSession_dataTask_didBecomeDownloadTask_, ); - } - - late final _CFMessagePortSendRequestPtr = - _lookup< - ffi.NativeFunction< - SInt32 Function( - CFMessagePortRef, - SInt32, - CFDataRef, - CFTimeInterval, - CFTimeInterval, - CFStringRef, - ffi.Pointer, - ) - > - >('CFMessagePortSendRequest'); - late final _CFMessagePortSendRequest = - _CFMessagePortSendRequestPtr.asFunction< - int Function( - CFMessagePortRef, - int, - CFDataRef, - double, - double, - CFStringRef, - ffi.Pointer, - ) - >(); - - CFRunLoopSourceRef CFMessagePortCreateRunLoopSource( - CFAllocatorRef allocator, - CFMessagePortRef local, - int order, - ) { - return _CFMessagePortCreateRunLoopSource(allocator, local, order); - } - - late final _CFMessagePortCreateRunLoopSourcePtr = - _lookup< - ffi.NativeFunction< - CFRunLoopSourceRef Function(CFAllocatorRef, CFMessagePortRef, CFIndex) - > - >('CFMessagePortCreateRunLoopSource'); - late final _CFMessagePortCreateRunLoopSource = - _CFMessagePortCreateRunLoopSourcePtr.asFunction< - CFRunLoopSourceRef Function(CFAllocatorRef, CFMessagePortRef, int) - >(); - - void CFMessagePortSetDispatchQueue( - CFMessagePortRef ms, - Dartdispatch_queue_t queue, - ) { - return _CFMessagePortSetDispatchQueue(ms, queue.ref.pointer); - } - - late final _CFMessagePortSetDispatchQueuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMessagePortRef, dispatch_queue_t) - > - >('CFMessagePortSetDispatchQueue'); - late final _CFMessagePortSetDispatchQueue = - _CFMessagePortSetDispatchQueuePtr.asFunction< - void Function(CFMessagePortRef, dispatch_queue_t) - >(); - - late final ffi.Pointer _kCFPlugInDynamicRegistrationKey = - _lookup('kCFPlugInDynamicRegistrationKey'); - - CFStringRef get kCFPlugInDynamicRegistrationKey => - _kCFPlugInDynamicRegistrationKey.value; - - late final ffi.Pointer _kCFPlugInDynamicRegisterFunctionKey = - _lookup('kCFPlugInDynamicRegisterFunctionKey'); - - CFStringRef get kCFPlugInDynamicRegisterFunctionKey => - _kCFPlugInDynamicRegisterFunctionKey.value; - - late final ffi.Pointer _kCFPlugInUnloadFunctionKey = - _lookup('kCFPlugInUnloadFunctionKey'); - - CFStringRef get kCFPlugInUnloadFunctionKey => - _kCFPlugInUnloadFunctionKey.value; - - late final ffi.Pointer _kCFPlugInFactoriesKey = - _lookup('kCFPlugInFactoriesKey'); - - CFStringRef get kCFPlugInFactoriesKey => _kCFPlugInFactoriesKey.value; - - late final ffi.Pointer _kCFPlugInTypesKey = _lookup( - 'kCFPlugInTypesKey', - ); - - CFStringRef get kCFPlugInTypesKey => _kCFPlugInTypesKey.value; - - int CFPlugInGetTypeID() { - return _CFPlugInGetTypeID(); - } - - late final _CFPlugInGetTypeIDPtr = - _lookup>('CFPlugInGetTypeID'); - late final _CFPlugInGetTypeID = - _CFPlugInGetTypeIDPtr.asFunction(); - - CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL) { - return _CFPlugInCreate(allocator, plugInURL); - } - - late final _CFPlugInCreatePtr = - _lookup< - ffi.NativeFunction - >('CFPlugInCreate'); - late final _CFPlugInCreate = - _CFPlugInCreatePtr.asFunction< - CFPlugInRef Function(CFAllocatorRef, CFURLRef) - >(); - - CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn) { - return _CFPlugInGetBundle(plugIn); - } - - late final _CFPlugInGetBundlePtr = - _lookup>( - 'CFPlugInGetBundle', - ); - late final _CFPlugInGetBundle = - _CFPlugInGetBundlePtr.asFunction(); - - void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, int flag) { - return _CFPlugInSetLoadOnDemand(plugIn, flag); - } - - late final _CFPlugInSetLoadOnDemandPtr = - _lookup>( - 'CFPlugInSetLoadOnDemand', - ); - late final _CFPlugInSetLoadOnDemand = - _CFPlugInSetLoadOnDemandPtr.asFunction(); - - int CFPlugInIsLoadOnDemand(CFPlugInRef plugIn) { - return _CFPlugInIsLoadOnDemand(plugIn); - } - - late final _CFPlugInIsLoadOnDemandPtr = - _lookup>( - 'CFPlugInIsLoadOnDemand', - ); - late final _CFPlugInIsLoadOnDemand = - _CFPlugInIsLoadOnDemandPtr.asFunction(); - - CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeUUID) { - return _CFPlugInFindFactoriesForPlugInType(typeUUID); - } - - late final _CFPlugInFindFactoriesForPlugInTypePtr = - _lookup>( - 'CFPlugInFindFactoriesForPlugInType', - ); - late final _CFPlugInFindFactoriesForPlugInType = - _CFPlugInFindFactoriesForPlugInTypePtr.asFunction< - CFArrayRef Function(CFUUIDRef) - >(); - - CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn( - CFUUIDRef typeUUID, - CFPlugInRef plugIn, - ) { - return _CFPlugInFindFactoriesForPlugInTypeInPlugIn(typeUUID, plugIn); - } - - late final _CFPlugInFindFactoriesForPlugInTypeInPlugInPtr = - _lookup>( - 'CFPlugInFindFactoriesForPlugInTypeInPlugIn', - ); - late final _CFPlugInFindFactoriesForPlugInTypeInPlugIn = - _CFPlugInFindFactoriesForPlugInTypeInPlugInPtr.asFunction< - CFArrayRef Function(CFUUIDRef, CFPlugInRef) - >(); - - ffi.Pointer CFPlugInInstanceCreate( - CFAllocatorRef allocator, - CFUUIDRef factoryUUID, - CFUUIDRef typeUUID, - ) { - return _CFPlugInInstanceCreate(allocator, factoryUUID, typeUUID); - } - - late final _CFPlugInInstanceCreatePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CFAllocatorRef, CFUUIDRef, CFUUIDRef) - > - >('CFPlugInInstanceCreate'); - late final _CFPlugInInstanceCreate = - _CFPlugInInstanceCreatePtr.asFunction< - ffi.Pointer Function(CFAllocatorRef, CFUUIDRef, CFUUIDRef) - >(); - - int CFPlugInRegisterFactoryFunction( - CFUUIDRef factoryUUID, - CFPlugInFactoryFunction func, - ) { - return _CFPlugInRegisterFactoryFunction(factoryUUID, func); - } - - late final _CFPlugInRegisterFactoryFunctionPtr = - _lookup< - ffi.NativeFunction - >('CFPlugInRegisterFactoryFunction'); - late final _CFPlugInRegisterFactoryFunction = - _CFPlugInRegisterFactoryFunctionPtr.asFunction< - int Function(CFUUIDRef, CFPlugInFactoryFunction) - >(); - - int CFPlugInRegisterFactoryFunctionByName( - CFUUIDRef factoryUUID, - CFPlugInRef plugIn, - CFStringRef functionName, - ) { - return _CFPlugInRegisterFactoryFunctionByName( - factoryUUID, - plugIn, - functionName, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implement( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - } - - late final _CFPlugInRegisterFactoryFunctionByNamePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFUUIDRef, CFPlugInRef, CFStringRef) - > - >('CFPlugInRegisterFactoryFunctionByName'); - late final _CFPlugInRegisterFactoryFunctionByName = - _CFPlugInRegisterFactoryFunctionByNamePtr.asFunction< - int Function(CFUUIDRef, CFPlugInRef, CFStringRef) - >(); - - int CFPlugInUnregisterFactory(CFUUIDRef factoryUUID) { - return _CFPlugInUnregisterFactory(factoryUUID); - } - - late final _CFPlugInUnregisterFactoryPtr = - _lookup>( - 'CFPlugInUnregisterFactory', - ); - late final _CFPlugInUnregisterFactory = - _CFPlugInUnregisterFactoryPtr.asFunction(); - - int CFPlugInRegisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) { - return _CFPlugInRegisterPlugInType(factoryUUID, typeUUID); - } - - late final _CFPlugInRegisterPlugInTypePtr = - _lookup>( - 'CFPlugInRegisterPlugInType', - ); - late final _CFPlugInRegisterPlugInType = - _CFPlugInRegisterPlugInTypePtr.asFunction< - int Function(CFUUIDRef, CFUUIDRef) - >(); - - int CFPlugInUnregisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) { - return _CFPlugInUnregisterPlugInType(factoryUUID, typeUUID); - } - - late final _CFPlugInUnregisterPlugInTypePtr = - _lookup>( - 'CFPlugInUnregisterPlugInType', - ); - late final _CFPlugInUnregisterPlugInType = - _CFPlugInUnregisterPlugInTypePtr.asFunction< - int Function(CFUUIDRef, CFUUIDRef) - >(); - - void CFPlugInAddInstanceForFactory(CFUUIDRef factoryID) { - return _CFPlugInAddInstanceForFactory(factoryID); - } - - late final _CFPlugInAddInstanceForFactoryPtr = - _lookup>( - 'CFPlugInAddInstanceForFactory', - ); - late final _CFPlugInAddInstanceForFactory = - _CFPlugInAddInstanceForFactoryPtr.asFunction(); - - void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID) { - return _CFPlugInRemoveInstanceForFactory(factoryID); - } - - late final _CFPlugInRemoveInstanceForFactoryPtr = - _lookup>( - 'CFPlugInRemoveInstanceForFactory', - ); - late final _CFPlugInRemoveInstanceForFactory = - _CFPlugInRemoveInstanceForFactoryPtr.asFunction< - void Function(CFUUIDRef) - >(); - - int CFPlugInInstanceGetInterfaceFunctionTable( - CFPlugInInstanceRef instance, - CFStringRef interfaceName, - ffi.Pointer> ftbl, - ) { - return _CFPlugInInstanceGetInterfaceFunctionTable( - instance, - interfaceName, - ftbl, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implement( + builder, + URLSession_dataTask_didReceiveData_, ); - } - - late final _CFPlugInInstanceGetInterfaceFunctionTablePtr = - _lookup< - ffi.NativeFunction< - Boolean Function( - CFPlugInInstanceRef, - CFStringRef, - ffi.Pointer>, - ) - > - >('CFPlugInInstanceGetInterfaceFunctionTable'); - late final _CFPlugInInstanceGetInterfaceFunctionTable = - _CFPlugInInstanceGetInterfaceFunctionTablePtr.asFunction< - int Function( - CFPlugInInstanceRef, - CFStringRef, - ffi.Pointer>, - ) - >(); - - CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance) { - return _CFPlugInInstanceGetFactoryName(instance); - } - - late final _CFPlugInInstanceGetFactoryNamePtr = - _lookup>( - 'CFPlugInInstanceGetFactoryName', - ); - late final _CFPlugInInstanceGetFactoryName = - _CFPlugInInstanceGetFactoryNamePtr.asFunction< - CFStringRef Function(CFPlugInInstanceRef) - >(); - - ffi.Pointer CFPlugInInstanceGetInstanceData( - CFPlugInInstanceRef instance, - ) { - return _CFPlugInInstanceGetInstanceData(instance); - } - - late final _CFPlugInInstanceGetInstanceDataPtr = - _lookup< - ffi.NativeFunction Function(CFPlugInInstanceRef)> - >('CFPlugInInstanceGetInstanceData'); - late final _CFPlugInInstanceGetInstanceData = - _CFPlugInInstanceGetInstanceDataPtr.asFunction< - ffi.Pointer Function(CFPlugInInstanceRef) - >(); - - int CFPlugInInstanceGetTypeID() { - return _CFPlugInInstanceGetTypeID(); - } - - late final _CFPlugInInstanceGetTypeIDPtr = - _lookup>( - 'CFPlugInInstanceGetTypeID', - ); - late final _CFPlugInInstanceGetTypeID = - _CFPlugInInstanceGetTypeIDPtr.asFunction(); - - CFPlugInInstanceRef CFPlugInInstanceCreateWithInstanceDataSize( - CFAllocatorRef allocator, - int instanceDataSize, - CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceFunction, - CFStringRef factoryName, - CFPlugInInstanceGetInterfaceFunction getInterfaceFunction, - ) { - return _CFPlugInInstanceCreateWithInstanceDataSize( - allocator, - instanceDataSize, - deallocateInstanceFunction, - factoryName, - getInterfaceFunction, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implement( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - } - - late final _CFPlugInInstanceCreateWithInstanceDataSizePtr = - _lookup< - ffi.NativeFunction< - CFPlugInInstanceRef Function( - CFAllocatorRef, - CFIndex, - CFPlugInInstanceDeallocateInstanceDataFunction, - CFStringRef, - CFPlugInInstanceGetInterfaceFunction, - ) - > - >('CFPlugInInstanceCreateWithInstanceDataSize'); - late final _CFPlugInInstanceCreateWithInstanceDataSize = - _CFPlugInInstanceCreateWithInstanceDataSizePtr.asFunction< - CFPlugInInstanceRef Function( - CFAllocatorRef, - int, - CFPlugInInstanceDeallocateInstanceDataFunction, - CFStringRef, - CFPlugInInstanceGetInterfaceFunction, - ) - >(); - - int CFMachPortGetTypeID() { - return _CFMachPortGetTypeID(); - } - - late final _CFMachPortGetTypeIDPtr = - _lookup>('CFMachPortGetTypeID'); - late final _CFMachPortGetTypeID = - _CFMachPortGetTypeIDPtr.asFunction(); - - CFMachPortRef CFMachPortCreate( - CFAllocatorRef allocator, - CFMachPortCallBack callout, - ffi.Pointer context, - ffi.Pointer shouldFreeInfo, - ) { - return _CFMachPortCreate(allocator, callout, context, shouldFreeInfo); - } - - late final _CFMachPortCreatePtr = - _lookup< - ffi.NativeFunction< - CFMachPortRef Function( - CFAllocatorRef, - CFMachPortCallBack, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFMachPortCreate'); - late final _CFMachPortCreate = - _CFMachPortCreatePtr.asFunction< - CFMachPortRef Function( - CFAllocatorRef, - CFMachPortCallBack, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFMachPortRef CFMachPortCreateWithPort( - CFAllocatorRef allocator, - int portNum, - CFMachPortCallBack callout, - ffi.Pointer context, - ffi.Pointer shouldFreeInfo, - ) { - return _CFMachPortCreateWithPort( - allocator, - portNum, - callout, - context, - shouldFreeInfo, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implement( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - } - - late final _CFMachPortCreateWithPortPtr = - _lookup< - ffi.NativeFunction< - CFMachPortRef Function( - CFAllocatorRef, - mach_port_t, - CFMachPortCallBack, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFMachPortCreateWithPort'); - late final _CFMachPortCreateWithPort = - _CFMachPortCreateWithPortPtr.asFunction< - CFMachPortRef Function( - CFAllocatorRef, - int, - CFMachPortCallBack, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int CFMachPortGetPort(CFMachPortRef port) { - return _CFMachPortGetPort(port); - } - - late final _CFMachPortGetPortPtr = - _lookup>( - 'CFMachPortGetPort', - ); - late final _CFMachPortGetPort = - _CFMachPortGetPortPtr.asFunction(); - - void CFMachPortGetContext( - CFMachPortRef port, - ffi.Pointer context, - ) { - return _CFMachPortGetContext(port, context); - } - - late final _CFMachPortGetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMachPortRef, ffi.Pointer) - > - >('CFMachPortGetContext'); - late final _CFMachPortGetContext = - _CFMachPortGetContextPtr.asFunction< - void Function(CFMachPortRef, ffi.Pointer) - >(); - - void CFMachPortInvalidate(CFMachPortRef port) { - return _CFMachPortInvalidate(port); - } - - late final _CFMachPortInvalidatePtr = - _lookup>( - 'CFMachPortInvalidate', - ); - late final _CFMachPortInvalidate = - _CFMachPortInvalidatePtr.asFunction(); - - int CFMachPortIsValid(CFMachPortRef port) { - return _CFMachPortIsValid(port); - } - - late final _CFMachPortIsValidPtr = - _lookup>( - 'CFMachPortIsValid', - ); - late final _CFMachPortIsValid = - _CFMachPortIsValidPtr.asFunction(); - - CFMachPortInvalidationCallBack CFMachPortGetInvalidationCallBack( - CFMachPortRef port, - ) { - return _CFMachPortGetInvalidationCallBack(port); - } - - late final _CFMachPortGetInvalidationCallBackPtr = - _lookup< - ffi.NativeFunction< - CFMachPortInvalidationCallBack Function(CFMachPortRef) - > - >('CFMachPortGetInvalidationCallBack'); - late final _CFMachPortGetInvalidationCallBack = - _CFMachPortGetInvalidationCallBackPtr.asFunction< - CFMachPortInvalidationCallBack Function(CFMachPortRef) - >(); - - void CFMachPortSetInvalidationCallBack( - CFMachPortRef port, - CFMachPortInvalidationCallBack callout, - ) { - return _CFMachPortSetInvalidationCallBack(port, callout); - } - - late final _CFMachPortSetInvalidationCallBackPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMachPortRef, CFMachPortInvalidationCallBack) - > - >('CFMachPortSetInvalidationCallBack'); - late final _CFMachPortSetInvalidationCallBack = - _CFMachPortSetInvalidationCallBackPtr.asFunction< - void Function(CFMachPortRef, CFMachPortInvalidationCallBack) - >(); - - CFRunLoopSourceRef CFMachPortCreateRunLoopSource( - CFAllocatorRef allocator, - CFMachPortRef port, - int order, - ) { - return _CFMachPortCreateRunLoopSource(allocator, port, order); - } - - late final _CFMachPortCreateRunLoopSourcePtr = - _lookup< - ffi.NativeFunction< - CFRunLoopSourceRef Function(CFAllocatorRef, CFMachPortRef, CFIndex) - > - >('CFMachPortCreateRunLoopSource'); - late final _CFMachPortCreateRunLoopSource = - _CFMachPortCreateRunLoopSourcePtr.asFunction< - CFRunLoopSourceRef Function(CFAllocatorRef, CFMachPortRef, int) - >(); - - int CFAttributedStringGetTypeID() { - return _CFAttributedStringGetTypeID(); - } - - late final _CFAttributedStringGetTypeIDPtr = - _lookup>( - 'CFAttributedStringGetTypeID', - ); - late final _CFAttributedStringGetTypeID = - _CFAttributedStringGetTypeIDPtr.asFunction(); - - CFAttributedStringRef CFAttributedStringCreate( - CFAllocatorRef alloc, - CFStringRef str, - CFDictionaryRef attributes, - ) { - return _CFAttributedStringCreate(alloc, str, attributes); - } - - late final _CFAttributedStringCreatePtr = - _lookup< - ffi.NativeFunction< - CFAttributedStringRef Function( - CFAllocatorRef, - CFStringRef, - CFDictionaryRef, - ) - > - >('CFAttributedStringCreate'); - late final _CFAttributedStringCreate = - _CFAttributedStringCreatePtr.asFunction< - CFAttributedStringRef Function( - CFAllocatorRef, - CFStringRef, - CFDictionaryRef, - ) - >(); - - CFAttributedStringRef CFAttributedStringCreateWithSubstring( - CFAllocatorRef alloc, - CFAttributedStringRef aStr, - CFRange range, - ) { - return _CFAttributedStringCreateWithSubstring(alloc, aStr, range); - } - - late final _CFAttributedStringCreateWithSubstringPtr = - _lookup< - ffi.NativeFunction< - CFAttributedStringRef Function( - CFAllocatorRef, - CFAttributedStringRef, - CFRange, - ) - > - >('CFAttributedStringCreateWithSubstring'); - late final _CFAttributedStringCreateWithSubstring = - _CFAttributedStringCreateWithSubstringPtr.asFunction< - CFAttributedStringRef Function( - CFAllocatorRef, - CFAttributedStringRef, - CFRange, - ) - >(); - - CFAttributedStringRef CFAttributedStringCreateCopy( - CFAllocatorRef alloc, - CFAttributedStringRef aStr, - ) { - return _CFAttributedStringCreateCopy(alloc, aStr); - } - - late final _CFAttributedStringCreateCopyPtr = - _lookup< - ffi.NativeFunction< - CFAttributedStringRef Function(CFAllocatorRef, CFAttributedStringRef) - > - >('CFAttributedStringCreateCopy'); - late final _CFAttributedStringCreateCopy = - _CFAttributedStringCreateCopyPtr.asFunction< - CFAttributedStringRef Function(CFAllocatorRef, CFAttributedStringRef) - >(); - - CFStringRef CFAttributedStringGetString(CFAttributedStringRef aStr) { - return _CFAttributedStringGetString(aStr); - } - - late final _CFAttributedStringGetStringPtr = - _lookup>( - 'CFAttributedStringGetString', - ); - late final _CFAttributedStringGetString = - _CFAttributedStringGetStringPtr.asFunction< - CFStringRef Function(CFAttributedStringRef) - >(); - - int CFAttributedStringGetLength(CFAttributedStringRef aStr) { - return _CFAttributedStringGetLength(aStr); - } - - late final _CFAttributedStringGetLengthPtr = - _lookup>( - 'CFAttributedStringGetLength', - ); - late final _CFAttributedStringGetLength = - _CFAttributedStringGetLengthPtr.asFunction< - int Function(CFAttributedStringRef) - >(); - - CFDictionaryRef CFAttributedStringGetAttributes( - CFAttributedStringRef aStr, - int loc, - ffi.Pointer effectiveRange, - ) { - return _CFAttributedStringGetAttributes(aStr, loc, effectiveRange); - } - - late final _CFAttributedStringGetAttributesPtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function( - CFAttributedStringRef, - CFIndex, - ffi.Pointer, - ) - > - >('CFAttributedStringGetAttributes'); - late final _CFAttributedStringGetAttributes = - _CFAttributedStringGetAttributesPtr.asFunction< - CFDictionaryRef Function( - CFAttributedStringRef, - int, - ffi.Pointer, - ) - >(); - - CFTypeRef CFAttributedStringGetAttribute( - CFAttributedStringRef aStr, - int loc, - CFStringRef attrName, - ffi.Pointer effectiveRange, - ) { - return _CFAttributedStringGetAttribute(aStr, loc, attrName, effectiveRange); - } - - late final _CFAttributedStringGetAttributePtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function( - CFAttributedStringRef, - CFIndex, - CFStringRef, - ffi.Pointer, - ) - > - >('CFAttributedStringGetAttribute'); - late final _CFAttributedStringGetAttribute = - _CFAttributedStringGetAttributePtr.asFunction< - CFTypeRef Function( - CFAttributedStringRef, - int, - CFStringRef, - ffi.Pointer, - ) - >(); - - CFDictionaryRef CFAttributedStringGetAttributesAndLongestEffectiveRange( - CFAttributedStringRef aStr, - int loc, - CFRange inRange, - ffi.Pointer longestEffectiveRange, - ) { - return _CFAttributedStringGetAttributesAndLongestEffectiveRange( - aStr, - loc, - inRange, - longestEffectiveRange, + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, ); - } - - late final _CFAttributedStringGetAttributesAndLongestEffectiveRangePtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function( - CFAttributedStringRef, - CFIndex, - CFRange, - ffi.Pointer, - ) - > - >('CFAttributedStringGetAttributesAndLongestEffectiveRange'); - late final _CFAttributedStringGetAttributesAndLongestEffectiveRange = - _CFAttributedStringGetAttributesAndLongestEffectiveRangePtr.asFunction< - CFDictionaryRef Function( - CFAttributedStringRef, - int, - CFRange, - ffi.Pointer, - ) - >(); - - CFTypeRef CFAttributedStringGetAttributeAndLongestEffectiveRange( - CFAttributedStringRef aStr, - int loc, - CFStringRef attrName, - CFRange inRange, - ffi.Pointer longestEffectiveRange, - ) { - return _CFAttributedStringGetAttributeAndLongestEffectiveRange( - aStr, - loc, - attrName, - inRange, - longestEffectiveRange, + NSURLSessionDataDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, ); - } - - late final _CFAttributedStringGetAttributeAndLongestEffectiveRangePtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function( - CFAttributedStringRef, - CFIndex, - CFStringRef, - CFRange, - ffi.Pointer, - ) - > - >('CFAttributedStringGetAttributeAndLongestEffectiveRange'); - late final _CFAttributedStringGetAttributeAndLongestEffectiveRange = - _CFAttributedStringGetAttributeAndLongestEffectiveRangePtr.asFunction< - CFTypeRef Function( - CFAttributedStringRef, - int, - CFStringRef, - CFRange, - ffi.Pointer, - ) - >(); - - CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy( - CFAllocatorRef alloc, - int maxLength, - CFAttributedStringRef aStr, - ) { - return _CFAttributedStringCreateMutableCopy(alloc, maxLength, aStr); - } - - late final _CFAttributedStringCreateMutableCopyPtr = - _lookup< - ffi.NativeFunction< - CFMutableAttributedStringRef Function( - CFAllocatorRef, - CFIndex, - CFAttributedStringRef, - ) - > - >('CFAttributedStringCreateMutableCopy'); - late final _CFAttributedStringCreateMutableCopy = - _CFAttributedStringCreateMutableCopyPtr.asFunction< - CFMutableAttributedStringRef Function( - CFAllocatorRef, - int, - CFAttributedStringRef, - ) - >(); - - CFMutableAttributedStringRef CFAttributedStringCreateMutable( - CFAllocatorRef alloc, - int maxLength, - ) { - return _CFAttributedStringCreateMutable(alloc, maxLength); - } - - late final _CFAttributedStringCreateMutablePtr = - _lookup< - ffi.NativeFunction< - CFMutableAttributedStringRef Function(CFAllocatorRef, CFIndex) - > - >('CFAttributedStringCreateMutable'); - late final _CFAttributedStringCreateMutable = - _CFAttributedStringCreateMutablePtr.asFunction< - CFMutableAttributedStringRef Function(CFAllocatorRef, int) - >(); - - void CFAttributedStringReplaceString( - CFMutableAttributedStringRef aStr, - CFRange range, - CFStringRef replacement, - ) { - return _CFAttributedStringReplaceString(aStr, range, replacement); - } - - late final _CFAttributedStringReplaceStringPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableAttributedStringRef, CFRange, CFStringRef) - > - >('CFAttributedStringReplaceString'); - late final _CFAttributedStringReplaceString = - _CFAttributedStringReplaceStringPtr.asFunction< - void Function(CFMutableAttributedStringRef, CFRange, CFStringRef) - >(); - - CFMutableStringRef CFAttributedStringGetMutableString( - CFMutableAttributedStringRef aStr, - ) { - return _CFAttributedStringGetMutableString(aStr); - } - - late final _CFAttributedStringGetMutableStringPtr = - _lookup< - ffi.NativeFunction< - CFMutableStringRef Function(CFMutableAttributedStringRef) - > - >('CFAttributedStringGetMutableString'); - late final _CFAttributedStringGetMutableString = - _CFAttributedStringGetMutableStringPtr.asFunction< - CFMutableStringRef Function(CFMutableAttributedStringRef) - >(); - - void CFAttributedStringSetAttributes( - CFMutableAttributedStringRef aStr, - CFRange range, - CFDictionaryRef replacement, - int clearOtherAttributes, - ) { - return _CFAttributedStringSetAttributes( - aStr, - range, - replacement, - clearOtherAttributes, + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - } - - late final _CFAttributedStringSetAttributesPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableAttributedStringRef, - CFRange, - CFDictionaryRef, - Boolean, - ) - > - >('CFAttributedStringSetAttributes'); - late final _CFAttributedStringSetAttributes = - _CFAttributedStringSetAttributesPtr.asFunction< - void Function( - CFMutableAttributedStringRef, - CFRange, - CFDictionaryRef, - int, - ) - >(); - - void CFAttributedStringSetAttribute( - CFMutableAttributedStringRef aStr, - CFRange range, - CFStringRef attrName, - CFTypeRef value, - ) { - return _CFAttributedStringSetAttribute(aStr, range, attrName, value); - } - - late final _CFAttributedStringSetAttributePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableAttributedStringRef, - CFRange, - CFStringRef, - CFTypeRef, - ) - > - >('CFAttributedStringSetAttribute'); - late final _CFAttributedStringSetAttribute = - _CFAttributedStringSetAttributePtr.asFunction< - void Function( - CFMutableAttributedStringRef, - CFRange, - CFStringRef, - CFTypeRef, - ) - >(); - - void CFAttributedStringRemoveAttribute( - CFMutableAttributedStringRef aStr, - CFRange range, - CFStringRef attrName, - ) { - return _CFAttributedStringRemoveAttribute(aStr, range, attrName); - } - - late final _CFAttributedStringRemoveAttributePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFMutableAttributedStringRef, CFRange, CFStringRef) - > - >('CFAttributedStringRemoveAttribute'); - late final _CFAttributedStringRemoveAttribute = - _CFAttributedStringRemoveAttributePtr.asFunction< - void Function(CFMutableAttributedStringRef, CFRange, CFStringRef) - >(); - - void CFAttributedStringReplaceAttributedString( - CFMutableAttributedStringRef aStr, - CFRange range, - CFAttributedStringRef replacement, - ) { - return _CFAttributedStringReplaceAttributedString(aStr, range, replacement); - } - - late final _CFAttributedStringReplaceAttributedStringPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFMutableAttributedStringRef, - CFRange, - CFAttributedStringRef, - ) - > - >('CFAttributedStringReplaceAttributedString'); - late final _CFAttributedStringReplaceAttributedString = - _CFAttributedStringReplaceAttributedStringPtr.asFunction< - void Function( - CFMutableAttributedStringRef, - CFRange, - CFAttributedStringRef, - ) - >(); - - void CFAttributedStringBeginEditing(CFMutableAttributedStringRef aStr) { - return _CFAttributedStringBeginEditing(aStr); - } - - late final _CFAttributedStringBeginEditingPtr = - _lookup< - ffi.NativeFunction - >('CFAttributedStringBeginEditing'); - late final _CFAttributedStringBeginEditing = - _CFAttributedStringBeginEditingPtr.asFunction< - void Function(CFMutableAttributedStringRef) - >(); - - void CFAttributedStringEndEditing(CFMutableAttributedStringRef aStr) { - return _CFAttributedStringEndEditing(aStr); - } - - late final _CFAttributedStringEndEditingPtr = - _lookup< - ffi.NativeFunction - >('CFAttributedStringEndEditing'); - late final _CFAttributedStringEndEditing = - _CFAttributedStringEndEditingPtr.asFunction< - void Function(CFMutableAttributedStringRef) - >(); - - bool CFAttributedStringGetBidiLevelsAndResolvedDirections( - CFAttributedStringRef attributedString, - CFRange range, - int baseDirection, - ffi.Pointer bidiLevels, - ffi.Pointer baseDirections, - ) { - return _CFAttributedStringGetBidiLevelsAndResolvedDirections( - attributedString, - range, - baseDirection, - bidiLevels, - baseDirections, + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implement( + builder, + URLSession_task_didCompleteWithError_, ); - } - - late final _CFAttributedStringGetBidiLevelsAndResolvedDirectionsPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - CFAttributedStringRef, - CFRange, - ffi.Int8, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFAttributedStringGetBidiLevelsAndResolvedDirections'); - late final _CFAttributedStringGetBidiLevelsAndResolvedDirections = - _CFAttributedStringGetBidiLevelsAndResolvedDirectionsPtr.asFunction< - bool Function( - CFAttributedStringRef, - CFRange, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - bool CFAttributedStringGetStatisticalWritingDirections( - CFAttributedStringRef attributedString, - CFRange range, - int baseDirection, - ffi.Pointer bidiLevels, - ffi.Pointer baseDirections, - ) { - return _CFAttributedStringGetStatisticalWritingDirections( - attributedString, - range, - baseDirection, - bidiLevels, - baseDirections, + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implement( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - } - - late final _CFAttributedStringGetStatisticalWritingDirectionsPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - CFAttributedStringRef, - CFRange, - ffi.Int8, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFAttributedStringGetStatisticalWritingDirections'); - late final _CFAttributedStringGetStatisticalWritingDirections = - _CFAttributedStringGetStatisticalWritingDirectionsPtr.asFunction< - bool Function( - CFAttributedStringRef, - CFRange, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int CFURLEnumeratorGetTypeID() { - return _CFURLEnumeratorGetTypeID(); - } - - late final _CFURLEnumeratorGetTypeIDPtr = - _lookup>( - 'CFURLEnumeratorGetTypeID', - ); - late final _CFURLEnumeratorGetTypeID = - _CFURLEnumeratorGetTypeIDPtr.asFunction(); - - CFURLEnumeratorRef CFURLEnumeratorCreateForDirectoryURL( - CFAllocatorRef alloc, - CFURLRef directoryURL, - int option, - CFArrayRef propertyKeys, - ) { - return _CFURLEnumeratorCreateForDirectoryURL( - alloc, - directoryURL, - option, - propertyKeys, + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implement( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implement( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implement( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implement( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); } - late final _CFURLEnumeratorCreateForDirectoryURLPtr = - _lookup< - ffi.NativeFunction< - CFURLEnumeratorRef Function( - CFAllocatorRef, - CFURLRef, - CFOptionFlags, - CFArrayRef, - ) - > - >('CFURLEnumeratorCreateForDirectoryURL'); - late final _CFURLEnumeratorCreateForDirectoryURL = - _CFURLEnumeratorCreateForDirectoryURLPtr.asFunction< - CFURLEnumeratorRef Function(CFAllocatorRef, CFURLRef, int, CFArrayRef) - >(); - - CFURLEnumeratorRef CFURLEnumeratorCreateForMountedVolumes( - CFAllocatorRef alloc, - int option, - CFArrayRef propertyKeys, - ) { - return _CFURLEnumeratorCreateForMountedVolumes(alloc, option, propertyKeys); - } - - late final _CFURLEnumeratorCreateForMountedVolumesPtr = - _lookup< - ffi.NativeFunction< - CFURLEnumeratorRef Function(CFAllocatorRef, CFOptionFlags, CFArrayRef) - > - >('CFURLEnumeratorCreateForMountedVolumes'); - late final _CFURLEnumeratorCreateForMountedVolumes = - _CFURLEnumeratorCreateForMountedVolumesPtr.asFunction< - CFURLEnumeratorRef Function(CFAllocatorRef, int, CFArrayRef) - >(); - - CFURLEnumeratorResult CFURLEnumeratorGetNextURL( - CFURLEnumeratorRef enumerator, - ffi.Pointer url, - ffi.Pointer error, - ) { - return CFURLEnumeratorResult.fromValue( - _CFURLEnumeratorGetNextURL(enumerator, url, error), + /// Builds an object that implements the NSURLSessionDataDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionDataDelegate implementAsListener({ + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? + URLSession_dataTask_didBecomeDownloadTask_, + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? + URLSession_dataTask_didBecomeStreamTask_, + void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? + URLSession_dataTask_didReceiveData_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_didReceiveResponse_completionHandler_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_willCacheResponse_completionHandler_, + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionDataDelegate', + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implementAsListener( + builder, + URLSession_dataTask_didBecomeDownloadTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implementAsListener( + builder, + URLSession_dataTask_didBecomeStreamTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implementAsListener( + builder, + URLSession_dataTask_didReceiveData_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsListener( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsListener( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsListener( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionDataDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), ); } - late final _CFURLEnumeratorGetNextURLPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFURLEnumeratorRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFURLEnumeratorGetNextURL'); - late final _CFURLEnumeratorGetNextURL = - _CFURLEnumeratorGetNextURLPtr.asFunction< - int Function( - CFURLEnumeratorRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - void CFURLEnumeratorSkipDescendents(CFURLEnumeratorRef enumerator) { - return _CFURLEnumeratorSkipDescendents(enumerator); - } - - late final _CFURLEnumeratorSkipDescendentsPtr = - _lookup>( - 'CFURLEnumeratorSkipDescendents', - ); - late final _CFURLEnumeratorSkipDescendents = - _CFURLEnumeratorSkipDescendentsPtr.asFunction< - void Function(CFURLEnumeratorRef) - >(); - - int CFURLEnumeratorGetDescendentLevel(CFURLEnumeratorRef enumerator) { - return _CFURLEnumeratorGetDescendentLevel(enumerator); - } - - late final _CFURLEnumeratorGetDescendentLevelPtr = - _lookup>( - 'CFURLEnumeratorGetDescendentLevel', - ); - late final _CFURLEnumeratorGetDescendentLevel = - _CFURLEnumeratorGetDescendentLevelPtr.asFunction< - int Function(CFURLEnumeratorRef) - >(); - - int CFURLEnumeratorGetSourceDidChange(CFURLEnumeratorRef enumerator) { - return _CFURLEnumeratorGetSourceDidChange(enumerator); - } - - late final _CFURLEnumeratorGetSourceDidChangePtr = - _lookup>( - 'CFURLEnumeratorGetSourceDidChange', - ); - late final _CFURLEnumeratorGetSourceDidChange = - _CFURLEnumeratorGetSourceDidChangePtr.asFunction< - int Function(CFURLEnumeratorRef) - >(); - - acl_t acl_dup(acl_t acl) { - return _acl_dup(acl); - } - - late final _acl_dupPtr = _lookup>( - 'acl_dup', - ); - late final _acl_dup = _acl_dupPtr.asFunction(); - - int acl_free(ffi.Pointer obj_p) { - return _acl_free(obj_p); - } - - late final _acl_freePtr = - _lookup)>>( - 'acl_free', - ); - late final _acl_free = _acl_freePtr - .asFunction)>(); - - acl_t acl_init(int count) { - return _acl_init(count); - } - - late final _acl_initPtr = - _lookup>('acl_init'); - late final _acl_init = _acl_initPtr.asFunction(); - - int acl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d) { - return _acl_copy_entry(dest_d, src_d); - } - - late final _acl_copy_entryPtr = - _lookup>( - 'acl_copy_entry', - ); - late final _acl_copy_entry = _acl_copy_entryPtr - .asFunction(); - - int acl_create_entry( - ffi.Pointer acl_p, - ffi.Pointer entry_p, - ) { - return _acl_create_entry(acl_p, entry_p); - } - - late final _acl_create_entryPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('acl_create_entry'); - late final _acl_create_entry = _acl_create_entryPtr - .asFunction, ffi.Pointer)>(); - - int acl_create_entry_np( - ffi.Pointer acl_p, - ffi.Pointer entry_p, - int entry_index, - ) { - return _acl_create_entry_np(acl_p, entry_p, entry_index); - } - - late final _acl_create_entry_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >('acl_create_entry_np'); - late final _acl_create_entry_np = _acl_create_entry_npPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int acl_delete_entry(acl_t acl, acl_entry_t entry_d) { - return _acl_delete_entry(acl, entry_d); - } - - late final _acl_delete_entryPtr = - _lookup>( - 'acl_delete_entry', - ); - late final _acl_delete_entry = _acl_delete_entryPtr - .asFunction(); - - int acl_get_entry(acl_t acl, int entry_id, ffi.Pointer entry_p) { - return _acl_get_entry(acl, entry_id, entry_p); - } - - late final _acl_get_entryPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(acl_t, ffi.Int, ffi.Pointer) - > - >('acl_get_entry'); - late final _acl_get_entry = _acl_get_entryPtr - .asFunction)>(); - - int acl_valid(acl_t acl) { - return _acl_valid(acl); - } - - late final _acl_validPtr = - _lookup>('acl_valid'); - late final _acl_valid = _acl_validPtr.asFunction(); - - int acl_valid_fd_np(int fd, acl_type_t type, acl_t acl) { - return _acl_valid_fd_np(fd, type.value, acl); - } - - late final _acl_valid_fd_npPtr = - _lookup< - ffi.NativeFunction - >('acl_valid_fd_np'); - late final _acl_valid_fd_np = _acl_valid_fd_npPtr - .asFunction(); - - int acl_valid_file_np( - ffi.Pointer path, - acl_type_t type, - acl_t acl, - ) { - return _acl_valid_file_np(path, type.value, acl); - } - - late final _acl_valid_file_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.UnsignedInt, acl_t) - > - >('acl_valid_file_np'); - late final _acl_valid_file_np = _acl_valid_file_npPtr - .asFunction, int, acl_t)>(); - - int acl_valid_link_np( - ffi.Pointer path, - acl_type_t type, - acl_t acl, - ) { - return _acl_valid_link_np(path, type.value, acl); - } - - late final _acl_valid_link_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.UnsignedInt, acl_t) - > - >('acl_valid_link_np'); - late final _acl_valid_link_np = _acl_valid_link_npPtr - .asFunction, int, acl_t)>(); - - int acl_add_perm(acl_permset_t permset_d, acl_perm_t perm) { - return _acl_add_perm(permset_d, perm.value); - } - - late final _acl_add_permPtr = - _lookup< - ffi.NativeFunction - >('acl_add_perm'); - late final _acl_add_perm = _acl_add_permPtr - .asFunction(); - - int acl_calc_mask(ffi.Pointer acl_p) { - return _acl_calc_mask(acl_p); - } - - late final _acl_calc_maskPtr = - _lookup)>>( - 'acl_calc_mask', - ); - late final _acl_calc_mask = _acl_calc_maskPtr - .asFunction)>(); - - int acl_clear_perms(acl_permset_t permset_d) { - return _acl_clear_perms(permset_d); - } - - late final _acl_clear_permsPtr = - _lookup>( - 'acl_clear_perms', - ); - late final _acl_clear_perms = _acl_clear_permsPtr - .asFunction(); - - int acl_delete_perm(acl_permset_t permset_d, acl_perm_t perm) { - return _acl_delete_perm(permset_d, perm.value); - } - - late final _acl_delete_permPtr = - _lookup< - ffi.NativeFunction - >('acl_delete_perm'); - late final _acl_delete_perm = _acl_delete_permPtr - .asFunction(); - - int acl_get_perm_np(acl_permset_t permset_d, acl_perm_t perm) { - return _acl_get_perm_np(permset_d, perm.value); - } - - late final _acl_get_perm_npPtr = - _lookup< - ffi.NativeFunction - >('acl_get_perm_np'); - late final _acl_get_perm_np = _acl_get_perm_npPtr - .asFunction(); - - int acl_get_permset( - acl_entry_t entry_d, - ffi.Pointer permset_p, - ) { - return _acl_get_permset(entry_d, permset_p); - } - - late final _acl_get_permsetPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(acl_entry_t, ffi.Pointer) - > - >('acl_get_permset'); - late final _acl_get_permset = _acl_get_permsetPtr - .asFunction)>(); - - int acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d) { - return _acl_set_permset(entry_d, permset_d); - } - - late final _acl_set_permsetPtr = - _lookup>( - 'acl_set_permset', - ); - late final _acl_set_permset = _acl_set_permsetPtr - .asFunction(); - - int acl_maximal_permset_mask_np(ffi.Pointer mask_p) { - return _acl_maximal_permset_mask_np(mask_p); - } - - late final _acl_maximal_permset_mask_npPtr = - _lookup< - ffi.NativeFunction)> - >('acl_maximal_permset_mask_np'); - late final _acl_maximal_permset_mask_np = _acl_maximal_permset_mask_npPtr - .asFunction)>(); - - int acl_get_permset_mask_np( - acl_entry_t entry_d, - ffi.Pointer mask_p, - ) { - return _acl_get_permset_mask_np(entry_d, mask_p); - } - - late final _acl_get_permset_mask_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(acl_entry_t, ffi.Pointer) - > - >('acl_get_permset_mask_np'); - late final _acl_get_permset_mask_np = _acl_get_permset_mask_npPtr - .asFunction)>(); - - int acl_set_permset_mask_np(acl_entry_t entry_d, int mask) { - return _acl_set_permset_mask_np(entry_d, mask); - } - - late final _acl_set_permset_mask_npPtr = - _lookup< - ffi.NativeFunction - >('acl_set_permset_mask_np'); - late final _acl_set_permset_mask_np = _acl_set_permset_mask_npPtr - .asFunction(); - - int acl_add_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) { - return _acl_add_flag_np(flagset_d, flag.value); - } - - late final _acl_add_flag_npPtr = - _lookup< - ffi.NativeFunction - >('acl_add_flag_np'); - late final _acl_add_flag_np = _acl_add_flag_npPtr - .asFunction(); - - int acl_clear_flags_np(acl_flagset_t flagset_d) { - return _acl_clear_flags_np(flagset_d); - } - - late final _acl_clear_flags_npPtr = - _lookup>( - 'acl_clear_flags_np', - ); - late final _acl_clear_flags_np = _acl_clear_flags_npPtr - .asFunction(); - - int acl_delete_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) { - return _acl_delete_flag_np(flagset_d, flag.value); - } - - late final _acl_delete_flag_npPtr = - _lookup< - ffi.NativeFunction - >('acl_delete_flag_np'); - late final _acl_delete_flag_np = _acl_delete_flag_npPtr - .asFunction(); - - int acl_get_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) { - return _acl_get_flag_np(flagset_d, flag.value); - } - - late final _acl_get_flag_npPtr = - _lookup< - ffi.NativeFunction - >('acl_get_flag_np'); - late final _acl_get_flag_np = _acl_get_flag_npPtr - .asFunction(); - - int acl_get_flagset_np( - ffi.Pointer obj_p, - ffi.Pointer flagset_p, - ) { - return _acl_get_flagset_np(obj_p, flagset_p); - } - - late final _acl_get_flagset_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('acl_get_flagset_np'); - late final _acl_get_flagset_np = _acl_get_flagset_npPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer) - >(); - - int acl_set_flagset_np(ffi.Pointer obj_p, acl_flagset_t flagset_d) { - return _acl_set_flagset_np(obj_p, flagset_d); - } - - late final _acl_set_flagset_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, acl_flagset_t) - > - >('acl_set_flagset_np'); - late final _acl_set_flagset_np = _acl_set_flagset_npPtr - .asFunction, acl_flagset_t)>(); - - ffi.Pointer acl_get_qualifier(acl_entry_t entry_d) { - return _acl_get_qualifier(entry_d); - } - - late final _acl_get_qualifierPtr = - _lookup Function(acl_entry_t)>>( - 'acl_get_qualifier', - ); - late final _acl_get_qualifier = _acl_get_qualifierPtr - .asFunction Function(acl_entry_t)>(); - - int acl_get_tag_type( - acl_entry_t entry_d, - ffi.Pointer tag_type_p, - ) { - return _acl_get_tag_type(entry_d, tag_type_p); + /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will + /// be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsListener( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? + URLSession_dataTask_didBecomeDownloadTask_, + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? + URLSession_dataTask_didBecomeStreamTask_, + void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? + URLSession_dataTask_didReceiveData_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_didReceiveResponse_completionHandler_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_willCacheResponse_completionHandler_, + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implementAsListener( + builder, + URLSession_dataTask_didBecomeDownloadTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implementAsListener( + builder, + URLSession_dataTask_didBecomeStreamTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implementAsListener( + builder, + URLSession_dataTask_didReceiveData_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsListener( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsListener( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsListener( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); } - late final _acl_get_tag_typePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(acl_entry_t, ffi.Pointer) - > - >('acl_get_tag_type'); - late final _acl_get_tag_type = _acl_get_tag_typePtr - .asFunction)>(); - - int acl_set_qualifier( - acl_entry_t entry_d, - ffi.Pointer tag_qualifier_p, - ) { - return _acl_set_qualifier(entry_d, tag_qualifier_p); - } - - late final _acl_set_qualifierPtr = - _lookup< - ffi.NativeFunction)> - >('acl_set_qualifier'); - late final _acl_set_qualifier = _acl_set_qualifierPtr - .asFunction)>(); - - int acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type) { - return _acl_set_tag_type(entry_d, tag_type.value); - } - - late final _acl_set_tag_typePtr = - _lookup< - ffi.NativeFunction - >('acl_set_tag_type'); - late final _acl_set_tag_type = _acl_set_tag_typePtr - .asFunction(); - - int acl_delete_def_file(ffi.Pointer path_p) { - return _acl_delete_def_file(path_p); - } - - late final _acl_delete_def_filePtr = - _lookup)>>( - 'acl_delete_def_file', - ); - late final _acl_delete_def_file = _acl_delete_def_filePtr - .asFunction)>(); - - acl_t acl_get_fd(int fd) { - return _acl_get_fd(fd); - } - - late final _acl_get_fdPtr = - _lookup>('acl_get_fd'); - late final _acl_get_fd = _acl_get_fdPtr.asFunction(); - - acl_t acl_get_fd_np(int fd, acl_type_t type) { - return _acl_get_fd_np(fd, type.value); - } - - late final _acl_get_fd_npPtr = - _lookup>( - 'acl_get_fd_np', - ); - late final _acl_get_fd_np = _acl_get_fd_npPtr - .asFunction(); - - acl_t acl_get_file(ffi.Pointer path_p, acl_type_t type) { - return _acl_get_file(path_p, type.value); - } - - late final _acl_get_filePtr = - _lookup< - ffi.NativeFunction< - acl_t Function(ffi.Pointer, ffi.UnsignedInt) - > - >('acl_get_file'); - late final _acl_get_file = _acl_get_filePtr - .asFunction, int)>(); - - acl_t acl_get_link_np(ffi.Pointer path_p, acl_type_t type) { - return _acl_get_link_np(path_p, type.value); - } - - late final _acl_get_link_npPtr = - _lookup< - ffi.NativeFunction< - acl_t Function(ffi.Pointer, ffi.UnsignedInt) - > - >('acl_get_link_np'); - late final _acl_get_link_np = _acl_get_link_npPtr - .asFunction, int)>(); - - int acl_set_fd(int fd, acl_t acl) { - return _acl_set_fd(fd, acl); - } - - late final _acl_set_fdPtr = - _lookup>( - 'acl_set_fd', - ); - late final _acl_set_fd = _acl_set_fdPtr - .asFunction(); - - int acl_set_fd_np(int fd, acl_t acl, acl_type_t acl_type) { - return _acl_set_fd_np(fd, acl, acl_type.value); - } - - late final _acl_set_fd_npPtr = - _lookup< - ffi.NativeFunction - >('acl_set_fd_np'); - late final _acl_set_fd_np = _acl_set_fd_npPtr - .asFunction(); - - int acl_set_file(ffi.Pointer path_p, acl_type_t type, acl_t acl) { - return _acl_set_file(path_p, type.value, acl); - } - - late final _acl_set_filePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.UnsignedInt, acl_t) - > - >('acl_set_file'); - late final _acl_set_file = _acl_set_filePtr - .asFunction, int, acl_t)>(); - - int acl_set_link_np( - ffi.Pointer path_p, - acl_type_t type, - acl_t acl, - ) { - return _acl_set_link_np(path_p, type.value, acl); - } - - late final _acl_set_link_npPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.UnsignedInt, acl_t) - > - >('acl_set_link_np'); - late final _acl_set_link_np = _acl_set_link_npPtr - .asFunction, int, acl_t)>(); - - int acl_copy_ext(ffi.Pointer buf_p, acl_t acl, int size) { - return _acl_copy_ext(buf_p, acl, size); - } - - late final _acl_copy_extPtr = - _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Pointer, acl_t, ssize_t) - > - >('acl_copy_ext'); - late final _acl_copy_ext = _acl_copy_extPtr - .asFunction, acl_t, int)>(); - - int acl_copy_ext_native(ffi.Pointer buf_p, acl_t acl, int size) { - return _acl_copy_ext_native(buf_p, acl, size); - } - - late final _acl_copy_ext_nativePtr = - _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Pointer, acl_t, ssize_t) - > - >('acl_copy_ext_native'); - late final _acl_copy_ext_native = _acl_copy_ext_nativePtr - .asFunction, acl_t, int)>(); - - acl_t acl_copy_int(ffi.Pointer buf_p) { - return _acl_copy_int(buf_p); - } - - late final _acl_copy_intPtr = - _lookup)>>( - 'acl_copy_int', - ); - late final _acl_copy_int = _acl_copy_intPtr - .asFunction)>(); - - acl_t acl_copy_int_native(ffi.Pointer buf_p) { - return _acl_copy_int_native(buf_p); - } - - late final _acl_copy_int_nativePtr = - _lookup)>>( - 'acl_copy_int_native', - ); - late final _acl_copy_int_native = _acl_copy_int_nativePtr - .asFunction)>(); - - acl_t acl_from_text(ffi.Pointer buf_p) { - return _acl_from_text(buf_p); - } - - late final _acl_from_textPtr = - _lookup)>>( - 'acl_from_text', - ); - late final _acl_from_text = _acl_from_textPtr - .asFunction)>(); - - int acl_size(acl_t acl) { - return _acl_size(acl); - } - - late final _acl_sizePtr = - _lookup>('acl_size'); - late final _acl_size = _acl_sizePtr.asFunction(); - - ffi.Pointer acl_to_text(acl_t acl, ffi.Pointer len_p) { - return _acl_to_text(acl, len_p); - } - - late final _acl_to_textPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(acl_t, ffi.Pointer) - > - >('acl_to_text'); - late final _acl_to_text = _acl_to_textPtr - .asFunction< - ffi.Pointer Function(acl_t, ffi.Pointer) - >(); - - int CFFileSecurityGetTypeID() { - return _CFFileSecurityGetTypeID(); - } - - late final _CFFileSecurityGetTypeIDPtr = - _lookup>( - 'CFFileSecurityGetTypeID', - ); - late final _CFFileSecurityGetTypeID = - _CFFileSecurityGetTypeIDPtr.asFunction(); - - CFFileSecurityRef CFFileSecurityCreate(CFAllocatorRef allocator) { - return _CFFileSecurityCreate(allocator); - } - - late final _CFFileSecurityCreatePtr = - _lookup>( - 'CFFileSecurityCreate', - ); - late final _CFFileSecurityCreate = - _CFFileSecurityCreatePtr.asFunction< - CFFileSecurityRef Function(CFAllocatorRef) - >(); - - CFFileSecurityRef CFFileSecurityCreateCopy( - CFAllocatorRef allocator, - CFFileSecurityRef fileSec, - ) { - return _CFFileSecurityCreateCopy(allocator, fileSec); - } - - late final _CFFileSecurityCreateCopyPtr = - _lookup< - ffi.NativeFunction< - CFFileSecurityRef Function(CFAllocatorRef, CFFileSecurityRef) - > - >('CFFileSecurityCreateCopy'); - late final _CFFileSecurityCreateCopy = - _CFFileSecurityCreateCopyPtr.asFunction< - CFFileSecurityRef Function(CFAllocatorRef, CFFileSecurityRef) - >(); - - int CFFileSecurityCopyOwnerUUID( - CFFileSecurityRef fileSec, - ffi.Pointer ownerUUID, - ) { - return _CFFileSecurityCopyOwnerUUID(fileSec, ownerUUID); - } - - late final _CFFileSecurityCopyOwnerUUIDPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFFileSecurityRef, ffi.Pointer) - > - >('CFFileSecurityCopyOwnerUUID'); - late final _CFFileSecurityCopyOwnerUUID = - _CFFileSecurityCopyOwnerUUIDPtr.asFunction< - int Function(CFFileSecurityRef, ffi.Pointer) - >(); - - int CFFileSecuritySetOwnerUUID( - CFFileSecurityRef fileSec, - CFUUIDRef ownerUUID, - ) { - return _CFFileSecuritySetOwnerUUID(fileSec, ownerUUID); - } - - late final _CFFileSecuritySetOwnerUUIDPtr = - _lookup< - ffi.NativeFunction - >('CFFileSecuritySetOwnerUUID'); - late final _CFFileSecuritySetOwnerUUID = - _CFFileSecuritySetOwnerUUIDPtr.asFunction< - int Function(CFFileSecurityRef, CFUUIDRef) - >(); - - int CFFileSecurityCopyGroupUUID( - CFFileSecurityRef fileSec, - ffi.Pointer groupUUID, - ) { - return _CFFileSecurityCopyGroupUUID(fileSec, groupUUID); - } - - late final _CFFileSecurityCopyGroupUUIDPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFFileSecurityRef, ffi.Pointer) - > - >('CFFileSecurityCopyGroupUUID'); - late final _CFFileSecurityCopyGroupUUID = - _CFFileSecurityCopyGroupUUIDPtr.asFunction< - int Function(CFFileSecurityRef, ffi.Pointer) - >(); - - int CFFileSecuritySetGroupUUID( - CFFileSecurityRef fileSec, - CFUUIDRef groupUUID, - ) { - return _CFFileSecuritySetGroupUUID(fileSec, groupUUID); - } - - late final _CFFileSecuritySetGroupUUIDPtr = - _lookup< - ffi.NativeFunction - >('CFFileSecuritySetGroupUUID'); - late final _CFFileSecuritySetGroupUUID = - _CFFileSecuritySetGroupUUIDPtr.asFunction< - int Function(CFFileSecurityRef, CFUUIDRef) - >(); - - int CFFileSecurityCopyAccessControlList( - CFFileSecurityRef fileSec, - ffi.Pointer accessControlList, - ) { - return _CFFileSecurityCopyAccessControlList(fileSec, accessControlList); - } - - late final _CFFileSecurityCopyAccessControlListPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFFileSecurityRef, ffi.Pointer) - > - >('CFFileSecurityCopyAccessControlList'); - late final _CFFileSecurityCopyAccessControlList = - _CFFileSecurityCopyAccessControlListPtr.asFunction< - int Function(CFFileSecurityRef, ffi.Pointer) - >(); - - int CFFileSecuritySetAccessControlList( - CFFileSecurityRef fileSec, - acl_t accessControlList, - ) { - return _CFFileSecuritySetAccessControlList(fileSec, accessControlList); - } - - late final _CFFileSecuritySetAccessControlListPtr = - _lookup>( - 'CFFileSecuritySetAccessControlList', - ); - late final _CFFileSecuritySetAccessControlList = - _CFFileSecuritySetAccessControlListPtr.asFunction< - int Function(CFFileSecurityRef, acl_t) - >(); - - int CFFileSecurityGetOwner( - CFFileSecurityRef fileSec, - ffi.Pointer owner, - ) { - return _CFFileSecurityGetOwner(fileSec, owner); - } - - late final _CFFileSecurityGetOwnerPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFFileSecurityRef, ffi.Pointer) - > - >('CFFileSecurityGetOwner'); - late final _CFFileSecurityGetOwner = - _CFFileSecurityGetOwnerPtr.asFunction< - int Function(CFFileSecurityRef, ffi.Pointer) - >(); - - int CFFileSecuritySetOwner(CFFileSecurityRef fileSec, int owner) { - return _CFFileSecuritySetOwner(fileSec, owner); - } - - late final _CFFileSecuritySetOwnerPtr = - _lookup>( - 'CFFileSecuritySetOwner', - ); - late final _CFFileSecuritySetOwner = - _CFFileSecuritySetOwnerPtr.asFunction< - int Function(CFFileSecurityRef, int) - >(); - - int CFFileSecurityGetGroup( - CFFileSecurityRef fileSec, - ffi.Pointer group, - ) { - return _CFFileSecurityGetGroup(fileSec, group); - } - - late final _CFFileSecurityGetGroupPtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFFileSecurityRef, ffi.Pointer) - > - >('CFFileSecurityGetGroup'); - late final _CFFileSecurityGetGroup = - _CFFileSecurityGetGroupPtr.asFunction< - int Function(CFFileSecurityRef, ffi.Pointer) - >(); - - int CFFileSecuritySetGroup(CFFileSecurityRef fileSec, int group) { - return _CFFileSecuritySetGroup(fileSec, group); - } - - late final _CFFileSecuritySetGroupPtr = - _lookup>( - 'CFFileSecuritySetGroup', - ); - late final _CFFileSecuritySetGroup = - _CFFileSecuritySetGroupPtr.asFunction< - int Function(CFFileSecurityRef, int) - >(); - - int CFFileSecurityGetMode( - CFFileSecurityRef fileSec, - ffi.Pointer mode, - ) { - return _CFFileSecurityGetMode(fileSec, mode); - } - - late final _CFFileSecurityGetModePtr = - _lookup< - ffi.NativeFunction< - Boolean Function(CFFileSecurityRef, ffi.Pointer) - > - >('CFFileSecurityGetMode'); - late final _CFFileSecurityGetMode = - _CFFileSecurityGetModePtr.asFunction< - int Function(CFFileSecurityRef, ffi.Pointer) - >(); - - int CFFileSecuritySetMode(CFFileSecurityRef fileSec, int mode) { - return _CFFileSecuritySetMode(fileSec, mode); - } - - late final _CFFileSecuritySetModePtr = - _lookup>( - 'CFFileSecuritySetMode', - ); - late final _CFFileSecuritySetMode = - _CFFileSecuritySetModePtr.asFunction< - int Function(CFFileSecurityRef, int) - >(); - - int CFFileSecurityClearProperties( - CFFileSecurityRef fileSec, - int clearPropertyMask, - ) { - return _CFFileSecurityClearProperties(fileSec, clearPropertyMask); - } - - late final _CFFileSecurityClearPropertiesPtr = - _lookup< - ffi.NativeFunction - >('CFFileSecurityClearProperties'); - late final _CFFileSecurityClearProperties = - _CFFileSecurityClearPropertiesPtr.asFunction< - int Function(CFFileSecurityRef, int) - >(); - - CFStringRef CFStringTokenizerCopyBestStringLanguage( - CFStringRef string, - CFRange range, - ) { - return _CFStringTokenizerCopyBestStringLanguage(string, range); - } - - late final _CFStringTokenizerCopyBestStringLanguagePtr = - _lookup>( - 'CFStringTokenizerCopyBestStringLanguage', - ); - late final _CFStringTokenizerCopyBestStringLanguage = - _CFStringTokenizerCopyBestStringLanguagePtr.asFunction< - CFStringRef Function(CFStringRef, CFRange) - >(); - - int CFStringTokenizerGetTypeID() { - return _CFStringTokenizerGetTypeID(); - } - - late final _CFStringTokenizerGetTypeIDPtr = - _lookup>( - 'CFStringTokenizerGetTypeID', - ); - late final _CFStringTokenizerGetTypeID = - _CFStringTokenizerGetTypeIDPtr.asFunction(); - - CFStringTokenizerRef CFStringTokenizerCreate( - CFAllocatorRef alloc, - CFStringRef string, - CFRange range, - int options, - CFLocaleRef locale, - ) { - return _CFStringTokenizerCreate(alloc, string, range, options, locale); - } - - late final _CFStringTokenizerCreatePtr = - _lookup< - ffi.NativeFunction< - CFStringTokenizerRef Function( - CFAllocatorRef, - CFStringRef, - CFRange, - CFOptionFlags, - CFLocaleRef, - ) - > - >('CFStringTokenizerCreate'); - late final _CFStringTokenizerCreate = - _CFStringTokenizerCreatePtr.asFunction< - CFStringTokenizerRef Function( - CFAllocatorRef, - CFStringRef, - CFRange, - int, - CFLocaleRef, - ) - >(); - - void CFStringTokenizerSetString( - CFStringTokenizerRef tokenizer, - CFStringRef string, - CFRange range, - ) { - return _CFStringTokenizerSetString(tokenizer, string, range); - } - - late final _CFStringTokenizerSetStringPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFStringTokenizerRef, CFStringRef, CFRange) - > - >('CFStringTokenizerSetString'); - late final _CFStringTokenizerSetString = - _CFStringTokenizerSetStringPtr.asFunction< - void Function(CFStringTokenizerRef, CFStringRef, CFRange) - >(); - - int CFStringTokenizerGoToTokenAtIndex( - CFStringTokenizerRef tokenizer, - int index$1, - ) { - return _CFStringTokenizerGoToTokenAtIndex(tokenizer, index$1); - } - - late final _CFStringTokenizerGoToTokenAtIndexPtr = - _lookup< - ffi.NativeFunction< - CFOptionFlags Function(CFStringTokenizerRef, CFIndex) - > - >('CFStringTokenizerGoToTokenAtIndex'); - late final _CFStringTokenizerGoToTokenAtIndex = - _CFStringTokenizerGoToTokenAtIndexPtr.asFunction< - int Function(CFStringTokenizerRef, int) - >(); - - int CFStringTokenizerAdvanceToNextToken(CFStringTokenizerRef tokenizer) { - return _CFStringTokenizerAdvanceToNextToken(tokenizer); - } - - late final _CFStringTokenizerAdvanceToNextTokenPtr = - _lookup>( - 'CFStringTokenizerAdvanceToNextToken', - ); - late final _CFStringTokenizerAdvanceToNextToken = - _CFStringTokenizerAdvanceToNextTokenPtr.asFunction< - int Function(CFStringTokenizerRef) - >(); - - CFRange CFStringTokenizerGetCurrentTokenRange( - CFStringTokenizerRef tokenizer, - ) { - return _CFStringTokenizerGetCurrentTokenRange(tokenizer); - } - - late final _CFStringTokenizerGetCurrentTokenRangePtr = - _lookup>( - 'CFStringTokenizerGetCurrentTokenRange', - ); - late final _CFStringTokenizerGetCurrentTokenRange = - _CFStringTokenizerGetCurrentTokenRangePtr.asFunction< - CFRange Function(CFStringTokenizerRef) - >(); - - CFTypeRef CFStringTokenizerCopyCurrentTokenAttribute( - CFStringTokenizerRef tokenizer, - int attribute, - ) { - return _CFStringTokenizerCopyCurrentTokenAttribute(tokenizer, attribute); - } - - late final _CFStringTokenizerCopyCurrentTokenAttributePtr = - _lookup< - ffi.NativeFunction< - CFTypeRef Function(CFStringTokenizerRef, CFOptionFlags) - > - >('CFStringTokenizerCopyCurrentTokenAttribute'); - late final _CFStringTokenizerCopyCurrentTokenAttribute = - _CFStringTokenizerCopyCurrentTokenAttributePtr.asFunction< - CFTypeRef Function(CFStringTokenizerRef, int) - >(); - - int CFStringTokenizerGetCurrentSubTokens( - CFStringTokenizerRef tokenizer, - ffi.Pointer ranges, - int maxRangeLength, - CFMutableArrayRef derivedSubTokens, - ) { - return _CFStringTokenizerGetCurrentSubTokens( - tokenizer, - ranges, - maxRangeLength, - derivedSubTokens, + /// Builds an object that implements the NSURLSessionDataDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as blocking listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionDataDelegate implementAsBlocking({ + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? + URLSession_dataTask_didBecomeDownloadTask_, + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? + URLSession_dataTask_didBecomeStreamTask_, + void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? + URLSession_dataTask_didReceiveData_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_didReceiveResponse_completionHandler_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_willCacheResponse_completionHandler_, + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionDataDelegate', ); - } - - late final _CFStringTokenizerGetCurrentSubTokensPtr = - _lookup< - ffi.NativeFunction< - CFIndex Function( - CFStringTokenizerRef, - ffi.Pointer, - CFIndex, - CFMutableArrayRef, - ) - > - >('CFStringTokenizerGetCurrentSubTokens'); - late final _CFStringTokenizerGetCurrentSubTokens = - _CFStringTokenizerGetCurrentSubTokensPtr.asFunction< - int Function( - CFStringTokenizerRef, - ffi.Pointer, - int, - CFMutableArrayRef, - ) - >(); - - int CFFileDescriptorGetTypeID() { - return _CFFileDescriptorGetTypeID(); - } - - late final _CFFileDescriptorGetTypeIDPtr = - _lookup>( - 'CFFileDescriptorGetTypeID', - ); - late final _CFFileDescriptorGetTypeID = - _CFFileDescriptorGetTypeIDPtr.asFunction(); - - CFFileDescriptorRef CFFileDescriptorCreate( - CFAllocatorRef allocator, - int fd, - int closeOnInvalidate, - CFFileDescriptorCallBack callout, - ffi.Pointer context, - ) { - return _CFFileDescriptorCreate( - allocator, - fd, - closeOnInvalidate, - callout, - context, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implementAsBlocking( + builder, + URLSession_dataTask_didBecomeDownloadTask_, ); - } - - late final _CFFileDescriptorCreatePtr = - _lookup< - ffi.NativeFunction< - CFFileDescriptorRef Function( - CFAllocatorRef, - CFFileDescriptorNativeDescriptor, - Boolean, - CFFileDescriptorCallBack, - ffi.Pointer, - ) - > - >('CFFileDescriptorCreate'); - late final _CFFileDescriptorCreate = - _CFFileDescriptorCreatePtr.asFunction< - CFFileDescriptorRef Function( - CFAllocatorRef, - int, - int, - CFFileDescriptorCallBack, - ffi.Pointer, - ) - >(); - - int CFFileDescriptorGetNativeDescriptor(CFFileDescriptorRef f) { - return _CFFileDescriptorGetNativeDescriptor(f); - } - - late final _CFFileDescriptorGetNativeDescriptorPtr = - _lookup< - ffi.NativeFunction< - CFFileDescriptorNativeDescriptor Function(CFFileDescriptorRef) - > - >('CFFileDescriptorGetNativeDescriptor'); - late final _CFFileDescriptorGetNativeDescriptor = - _CFFileDescriptorGetNativeDescriptorPtr.asFunction< - int Function(CFFileDescriptorRef) - >(); - - void CFFileDescriptorGetContext( - CFFileDescriptorRef f, - ffi.Pointer context, - ) { - return _CFFileDescriptorGetContext(f, context); - } - - late final _CFFileDescriptorGetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CFFileDescriptorRef, - ffi.Pointer, - ) - > - >('CFFileDescriptorGetContext'); - late final _CFFileDescriptorGetContext = - _CFFileDescriptorGetContextPtr.asFunction< - void Function(CFFileDescriptorRef, ffi.Pointer) - >(); - - void CFFileDescriptorEnableCallBacks( - CFFileDescriptorRef f, - int callBackTypes, - ) { - return _CFFileDescriptorEnableCallBacks(f, callBackTypes); - } - - late final _CFFileDescriptorEnableCallBacksPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFFileDescriptorRef, CFOptionFlags) - > - >('CFFileDescriptorEnableCallBacks'); - late final _CFFileDescriptorEnableCallBacks = - _CFFileDescriptorEnableCallBacksPtr.asFunction< - void Function(CFFileDescriptorRef, int) - >(); - - void CFFileDescriptorDisableCallBacks( - CFFileDescriptorRef f, - int callBackTypes, - ) { - return _CFFileDescriptorDisableCallBacks(f, callBackTypes); - } - - late final _CFFileDescriptorDisableCallBacksPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFFileDescriptorRef, CFOptionFlags) - > - >('CFFileDescriptorDisableCallBacks'); - late final _CFFileDescriptorDisableCallBacks = - _CFFileDescriptorDisableCallBacksPtr.asFunction< - void Function(CFFileDescriptorRef, int) - >(); - - void CFFileDescriptorInvalidate(CFFileDescriptorRef f) { - return _CFFileDescriptorInvalidate(f); - } - - late final _CFFileDescriptorInvalidatePtr = - _lookup>( - 'CFFileDescriptorInvalidate', - ); - late final _CFFileDescriptorInvalidate = - _CFFileDescriptorInvalidatePtr.asFunction< - void Function(CFFileDescriptorRef) - >(); - - int CFFileDescriptorIsValid(CFFileDescriptorRef f) { - return _CFFileDescriptorIsValid(f); - } - - late final _CFFileDescriptorIsValidPtr = - _lookup>( - 'CFFileDescriptorIsValid', - ); - late final _CFFileDescriptorIsValid = - _CFFileDescriptorIsValidPtr.asFunction< - int Function(CFFileDescriptorRef) - >(); - - CFRunLoopSourceRef CFFileDescriptorCreateRunLoopSource( - CFAllocatorRef allocator, - CFFileDescriptorRef f, - int order, - ) { - return _CFFileDescriptorCreateRunLoopSource(allocator, f, order); - } - - late final _CFFileDescriptorCreateRunLoopSourcePtr = - _lookup< - ffi.NativeFunction< - CFRunLoopSourceRef Function( - CFAllocatorRef, - CFFileDescriptorRef, - CFIndex, - ) - > - >('CFFileDescriptorCreateRunLoopSource'); - late final _CFFileDescriptorCreateRunLoopSource = - _CFFileDescriptorCreateRunLoopSourcePtr.asFunction< - CFRunLoopSourceRef Function(CFAllocatorRef, CFFileDescriptorRef, int) - >(); - - int CFUserNotificationGetTypeID() { - return _CFUserNotificationGetTypeID(); - } - - late final _CFUserNotificationGetTypeIDPtr = - _lookup>( - 'CFUserNotificationGetTypeID', - ); - late final _CFUserNotificationGetTypeID = - _CFUserNotificationGetTypeIDPtr.asFunction(); - - CFUserNotificationRef CFUserNotificationCreate( - CFAllocatorRef allocator, - double timeout, - int flags, - ffi.Pointer error, - CFDictionaryRef dictionary, - ) { - return _CFUserNotificationCreate( - allocator, - timeout, - flags, - error, - dictionary, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implementAsBlocking( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - } - - late final _CFUserNotificationCreatePtr = - _lookup< - ffi.NativeFunction< - CFUserNotificationRef Function( - CFAllocatorRef, - CFTimeInterval, - CFOptionFlags, - ffi.Pointer, - CFDictionaryRef, - ) - > - >('CFUserNotificationCreate'); - late final _CFUserNotificationCreate = - _CFUserNotificationCreatePtr.asFunction< - CFUserNotificationRef Function( - CFAllocatorRef, - double, - int, - ffi.Pointer, - CFDictionaryRef, - ) - >(); - - int CFUserNotificationReceiveResponse( - CFUserNotificationRef userNotification, - double timeout, - ffi.Pointer responseFlags, - ) { - return _CFUserNotificationReceiveResponse( - userNotification, - timeout, - responseFlags, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implementAsBlocking( + builder, + URLSession_dataTask_didReceiveData_, ); - } - - late final _CFUserNotificationReceiveResponsePtr = - _lookup< - ffi.NativeFunction< - SInt32 Function( - CFUserNotificationRef, - CFTimeInterval, - ffi.Pointer, - ) - > - >('CFUserNotificationReceiveResponse'); - late final _CFUserNotificationReceiveResponse = - _CFUserNotificationReceiveResponsePtr.asFunction< - int Function(CFUserNotificationRef, double, ffi.Pointer) - >(); - - CFStringRef CFUserNotificationGetResponseValue( - CFUserNotificationRef userNotification, - CFStringRef key, - int idx, - ) { - return _CFUserNotificationGetResponseValue(userNotification, key, idx); - } - - late final _CFUserNotificationGetResponseValuePtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFUserNotificationRef, CFStringRef, CFIndex) - > - >('CFUserNotificationGetResponseValue'); - late final _CFUserNotificationGetResponseValue = - _CFUserNotificationGetResponseValuePtr.asFunction< - CFStringRef Function(CFUserNotificationRef, CFStringRef, int) - >(); - - CFDictionaryRef CFUserNotificationGetResponseDictionary( - CFUserNotificationRef userNotification, - ) { - return _CFUserNotificationGetResponseDictionary(userNotification); - } - - late final _CFUserNotificationGetResponseDictionaryPtr = - _lookup< - ffi.NativeFunction - >('CFUserNotificationGetResponseDictionary'); - late final _CFUserNotificationGetResponseDictionary = - _CFUserNotificationGetResponseDictionaryPtr.asFunction< - CFDictionaryRef Function(CFUserNotificationRef) - >(); - - int CFUserNotificationUpdate( - CFUserNotificationRef userNotification, - double timeout, - int flags, - CFDictionaryRef dictionary, - ) { - return _CFUserNotificationUpdate( - userNotification, - timeout, - flags, - dictionary, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsBlocking( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - } - - late final _CFUserNotificationUpdatePtr = - _lookup< - ffi.NativeFunction< - SInt32 Function( - CFUserNotificationRef, - CFTimeInterval, - CFOptionFlags, - CFDictionaryRef, - ) - > - >('CFUserNotificationUpdate'); - late final _CFUserNotificationUpdate = - _CFUserNotificationUpdatePtr.asFunction< - int Function(CFUserNotificationRef, double, int, CFDictionaryRef) - >(); - - int CFUserNotificationCancel(CFUserNotificationRef userNotification) { - return _CFUserNotificationCancel(userNotification); - } - - late final _CFUserNotificationCancelPtr = - _lookup>( - 'CFUserNotificationCancel', - ); - late final _CFUserNotificationCancel = - _CFUserNotificationCancelPtr.asFunction< - int Function(CFUserNotificationRef) - >(); - - CFRunLoopSourceRef CFUserNotificationCreateRunLoopSource( - CFAllocatorRef allocator, - CFUserNotificationRef userNotification, - CFUserNotificationCallBack callout, - int order, - ) { - return _CFUserNotificationCreateRunLoopSource( - allocator, - userNotification, - callout, - order, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsBlocking( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - } - - late final _CFUserNotificationCreateRunLoopSourcePtr = - _lookup< - ffi.NativeFunction< - CFRunLoopSourceRef Function( - CFAllocatorRef, - CFUserNotificationRef, - CFUserNotificationCallBack, - CFIndex, - ) - > - >('CFUserNotificationCreateRunLoopSource'); - late final _CFUserNotificationCreateRunLoopSource = - _CFUserNotificationCreateRunLoopSourcePtr.asFunction< - CFRunLoopSourceRef Function( - CFAllocatorRef, - CFUserNotificationRef, - CFUserNotificationCallBack, - int, - ) - >(); - - int CFUserNotificationDisplayNotice( - double timeout, - int flags, - CFURLRef iconURL, - CFURLRef soundURL, - CFURLRef localizationURL, - CFStringRef alertHeader, - CFStringRef alertMessage, - CFStringRef defaultButtonTitle, - ) { - return _CFUserNotificationDisplayNotice( - timeout, - flags, - iconURL, - soundURL, - localizationURL, - alertHeader, - alertMessage, - defaultButtonTitle, + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, ); - } - - late final _CFUserNotificationDisplayNoticePtr = - _lookup< - ffi.NativeFunction< - SInt32 Function( - CFTimeInterval, - CFOptionFlags, - CFURLRef, - CFURLRef, - CFURLRef, - CFStringRef, - CFStringRef, - CFStringRef, - ) - > - >('CFUserNotificationDisplayNotice'); - late final _CFUserNotificationDisplayNotice = - _CFUserNotificationDisplayNoticePtr.asFunction< - int Function( - double, - int, - CFURLRef, - CFURLRef, - CFURLRef, - CFStringRef, - CFStringRef, - CFStringRef, - ) - >(); - - int CFUserNotificationDisplayAlert( - double timeout, - int flags, - CFURLRef iconURL, - CFURLRef soundURL, - CFURLRef localizationURL, - CFStringRef alertHeader, - CFStringRef alertMessage, - CFStringRef defaultButtonTitle, - CFStringRef alternateButtonTitle, - CFStringRef otherButtonTitle, - ffi.Pointer responseFlags, - ) { - return _CFUserNotificationDisplayAlert( - timeout, - flags, - iconURL, - soundURL, - localizationURL, - alertHeader, - alertMessage, - defaultButtonTitle, - alternateButtonTitle, - otherButtonTitle, - responseFlags, - ); - } - - late final _CFUserNotificationDisplayAlertPtr = - _lookup< - ffi.NativeFunction< - SInt32 Function( - CFTimeInterval, - CFOptionFlags, - CFURLRef, - CFURLRef, - CFURLRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFStringRef, - ffi.Pointer, - ) - > - >('CFUserNotificationDisplayAlert'); - late final _CFUserNotificationDisplayAlert = - _CFUserNotificationDisplayAlertPtr.asFunction< - int Function( - double, - int, - CFURLRef, - CFURLRef, - CFURLRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFStringRef, - CFStringRef, - ffi.Pointer, - ) - >(); - - late final ffi.Pointer _kCFUserNotificationIconURLKey = - _lookup('kCFUserNotificationIconURLKey'); - - CFStringRef get kCFUserNotificationIconURLKey => - _kCFUserNotificationIconURLKey.value; - - late final ffi.Pointer _kCFUserNotificationSoundURLKey = - _lookup('kCFUserNotificationSoundURLKey'); - - CFStringRef get kCFUserNotificationSoundURLKey => - _kCFUserNotificationSoundURLKey.value; - - late final ffi.Pointer _kCFUserNotificationLocalizationURLKey = - _lookup('kCFUserNotificationLocalizationURLKey'); - - CFStringRef get kCFUserNotificationLocalizationURLKey => - _kCFUserNotificationLocalizationURLKey.value; - - late final ffi.Pointer _kCFUserNotificationAlertHeaderKey = - _lookup('kCFUserNotificationAlertHeaderKey'); - - CFStringRef get kCFUserNotificationAlertHeaderKey => - _kCFUserNotificationAlertHeaderKey.value; - - late final ffi.Pointer _kCFUserNotificationAlertMessageKey = - _lookup('kCFUserNotificationAlertMessageKey'); - - CFStringRef get kCFUserNotificationAlertMessageKey => - _kCFUserNotificationAlertMessageKey.value; - - late final ffi.Pointer - _kCFUserNotificationDefaultButtonTitleKey = _lookup( - 'kCFUserNotificationDefaultButtonTitleKey', - ); - - CFStringRef get kCFUserNotificationDefaultButtonTitleKey => - _kCFUserNotificationDefaultButtonTitleKey.value; - - late final ffi.Pointer - _kCFUserNotificationAlternateButtonTitleKey = _lookup( - 'kCFUserNotificationAlternateButtonTitleKey', - ); - - CFStringRef get kCFUserNotificationAlternateButtonTitleKey => - _kCFUserNotificationAlternateButtonTitleKey.value; - - late final ffi.Pointer _kCFUserNotificationOtherButtonTitleKey = - _lookup('kCFUserNotificationOtherButtonTitleKey'); - - CFStringRef get kCFUserNotificationOtherButtonTitleKey => - _kCFUserNotificationOtherButtonTitleKey.value; - - late final ffi.Pointer - _kCFUserNotificationProgressIndicatorValueKey = _lookup( - 'kCFUserNotificationProgressIndicatorValueKey', - ); - - CFStringRef get kCFUserNotificationProgressIndicatorValueKey => - _kCFUserNotificationProgressIndicatorValueKey.value; - - late final ffi.Pointer _kCFUserNotificationPopUpTitlesKey = - _lookup('kCFUserNotificationPopUpTitlesKey'); - - CFStringRef get kCFUserNotificationPopUpTitlesKey => - _kCFUserNotificationPopUpTitlesKey.value; - - late final ffi.Pointer _kCFUserNotificationTextFieldTitlesKey = - _lookup('kCFUserNotificationTextFieldTitlesKey'); - - CFStringRef get kCFUserNotificationTextFieldTitlesKey => - _kCFUserNotificationTextFieldTitlesKey.value; - - late final ffi.Pointer _kCFUserNotificationCheckBoxTitlesKey = - _lookup('kCFUserNotificationCheckBoxTitlesKey'); - - CFStringRef get kCFUserNotificationCheckBoxTitlesKey => - _kCFUserNotificationCheckBoxTitlesKey.value; - - late final ffi.Pointer _kCFUserNotificationTextFieldValuesKey = - _lookup('kCFUserNotificationTextFieldValuesKey'); - - CFStringRef get kCFUserNotificationTextFieldValuesKey => - _kCFUserNotificationTextFieldValuesKey.value; - - late final ffi.Pointer _kCFUserNotificationPopUpSelectionKey = - _lookup('kCFUserNotificationPopUpSelectionKey'); - - CFStringRef get kCFUserNotificationPopUpSelectionKey => - _kCFUserNotificationPopUpSelectionKey.value; - - late final ffi.Pointer _kCFUserNotificationAlertTopMostKey = - _lookup('kCFUserNotificationAlertTopMostKey'); - - CFStringRef get kCFUserNotificationAlertTopMostKey => - _kCFUserNotificationAlertTopMostKey.value; - - late final ffi.Pointer _kCFUserNotificationKeyboardTypesKey = - _lookup('kCFUserNotificationKeyboardTypesKey'); - - CFStringRef get kCFUserNotificationKeyboardTypesKey => - _kCFUserNotificationKeyboardTypesKey.value; - - int CFXMLNodeGetTypeID() { - return _CFXMLNodeGetTypeID(); - } - - late final _CFXMLNodeGetTypeIDPtr = - _lookup>('CFXMLNodeGetTypeID'); - late final _CFXMLNodeGetTypeID = - _CFXMLNodeGetTypeIDPtr.asFunction(); - - CFXMLNodeRef CFXMLNodeCreate( - CFAllocatorRef alloc, - CFXMLNodeTypeCode xmlType, - CFStringRef dataString, - ffi.Pointer additionalInfoPtr, - DartCFIndex version, - ) { - return _CFXMLNodeCreate( - alloc, - xmlType.value, - dataString, - additionalInfoPtr, - version, + NSURLSessionDataDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, ); - } - - late final _CFXMLNodeCreatePtr = - _lookup< - ffi.NativeFunction< - CFXMLNodeRef Function( - CFAllocatorRef, - CFIndex, - CFStringRef, - ffi.Pointer, - CFIndex, - ) - > - >('CFXMLNodeCreate'); - late final _CFXMLNodeCreate = - _CFXMLNodeCreatePtr.asFunction< - CFXMLNodeRef Function( - CFAllocatorRef, - int, - CFStringRef, - ffi.Pointer, - int, - ) - >(); - - CFXMLNodeRef CFXMLNodeCreateCopy( - CFAllocatorRef alloc, - CFXMLNodeRef origNode, - ) { - return _CFXMLNodeCreateCopy(alloc, origNode); - } - - late final _CFXMLNodeCreateCopyPtr = - _lookup< - ffi.NativeFunction - >('CFXMLNodeCreateCopy'); - late final _CFXMLNodeCreateCopy = - _CFXMLNodeCreateCopyPtr.asFunction< - CFXMLNodeRef Function(CFAllocatorRef, CFXMLNodeRef) - >(); - - CFXMLNodeTypeCode CFXMLNodeGetTypeCode(CFXMLNodeRef node) { - return CFXMLNodeTypeCode.fromValue(_CFXMLNodeGetTypeCode(node)); - } - - late final _CFXMLNodeGetTypeCodePtr = - _lookup>( - 'CFXMLNodeGetTypeCode', - ); - late final _CFXMLNodeGetTypeCode = - _CFXMLNodeGetTypeCodePtr.asFunction(); - - CFStringRef CFXMLNodeGetString(CFXMLNodeRef node) { - return _CFXMLNodeGetString(node); - } - - late final _CFXMLNodeGetStringPtr = - _lookup>( - 'CFXMLNodeGetString', - ); - late final _CFXMLNodeGetString = - _CFXMLNodeGetStringPtr.asFunction(); - - ffi.Pointer CFXMLNodeGetInfoPtr(CFXMLNodeRef node) { - return _CFXMLNodeGetInfoPtr(node); - } - - late final _CFXMLNodeGetInfoPtrPtr = - _lookup Function(CFXMLNodeRef)>>( - 'CFXMLNodeGetInfoPtr', - ); - late final _CFXMLNodeGetInfoPtr = - _CFXMLNodeGetInfoPtrPtr.asFunction< - ffi.Pointer Function(CFXMLNodeRef) - >(); - - int CFXMLNodeGetVersion(CFXMLNodeRef node) { - return _CFXMLNodeGetVersion(node); - } - - late final _CFXMLNodeGetVersionPtr = - _lookup>( - 'CFXMLNodeGetVersion', - ); - late final _CFXMLNodeGetVersion = - _CFXMLNodeGetVersionPtr.asFunction(); - - CFXMLTreeRef CFXMLTreeCreateWithNode( - CFAllocatorRef allocator, - CFXMLNodeRef node, - ) { - return _CFXMLTreeCreateWithNode(allocator, node); - } - - late final _CFXMLTreeCreateWithNodePtr = - _lookup< - ffi.NativeFunction - >('CFXMLTreeCreateWithNode'); - late final _CFXMLTreeCreateWithNode = - _CFXMLTreeCreateWithNodePtr.asFunction< - CFXMLTreeRef Function(CFAllocatorRef, CFXMLNodeRef) - >(); - - CFXMLNodeRef CFXMLTreeGetNode(CFXMLTreeRef xmlTree) { - return _CFXMLTreeGetNode(xmlTree); - } - - late final _CFXMLTreeGetNodePtr = - _lookup>( - 'CFXMLTreeGetNode', - ); - late final _CFXMLTreeGetNode = - _CFXMLTreeGetNodePtr.asFunction(); - - int CFXMLParserGetTypeID() { - return _CFXMLParserGetTypeID(); - } - - late final _CFXMLParserGetTypeIDPtr = - _lookup>('CFXMLParserGetTypeID'); - late final _CFXMLParserGetTypeID = - _CFXMLParserGetTypeIDPtr.asFunction(); - - CFXMLParserRef CFXMLParserCreate( - CFAllocatorRef allocator, - CFDataRef xmlData, - CFURLRef dataSource, - int parseOptions, - int versionOfNodes, - ffi.Pointer callBacks, - ffi.Pointer context, - ) { - return _CFXMLParserCreate( - allocator, - xmlData, - dataSource, - parseOptions, - versionOfNodes, - callBacks, - context, + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - } - - late final _CFXMLParserCreatePtr = - _lookup< - ffi.NativeFunction< - CFXMLParserRef Function( - CFAllocatorRef, - CFDataRef, - CFURLRef, - CFOptionFlags, - CFIndex, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFXMLParserCreate'); - late final _CFXMLParserCreate = - _CFXMLParserCreatePtr.asFunction< - CFXMLParserRef Function( - CFAllocatorRef, - CFDataRef, - CFURLRef, - int, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - CFXMLParserRef CFXMLParserCreateWithDataFromURL( - CFAllocatorRef allocator, - CFURLRef dataSource, - int parseOptions, - int versionOfNodes, - ffi.Pointer callBacks, - ffi.Pointer context, - ) { - return _CFXMLParserCreateWithDataFromURL( - allocator, - dataSource, - parseOptions, - versionOfNodes, - callBacks, - context, + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsBlocking( + builder, + URLSession_task_didCompleteWithError_, ); - } - - late final _CFXMLParserCreateWithDataFromURLPtr = - _lookup< - ffi.NativeFunction< - CFXMLParserRef Function( - CFAllocatorRef, - CFURLRef, - CFOptionFlags, - CFIndex, - ffi.Pointer, - ffi.Pointer, - ) - > - >('CFXMLParserCreateWithDataFromURL'); - late final _CFXMLParserCreateWithDataFromURL = - _CFXMLParserCreateWithDataFromURLPtr.asFunction< - CFXMLParserRef Function( - CFAllocatorRef, - CFURLRef, - int, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - void CFXMLParserGetContext( - CFXMLParserRef parser, - ffi.Pointer context, - ) { - return _CFXMLParserGetContext(parser, context); - } - - late final _CFXMLParserGetContextPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFXMLParserRef, ffi.Pointer) - > - >('CFXMLParserGetContext'); - late final _CFXMLParserGetContext = - _CFXMLParserGetContextPtr.asFunction< - void Function(CFXMLParserRef, ffi.Pointer) - >(); - - void CFXMLParserGetCallBacks( - CFXMLParserRef parser, - ffi.Pointer callBacks, - ) { - return _CFXMLParserGetCallBacks(parser, callBacks); - } - - late final _CFXMLParserGetCallBacksPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFXMLParserRef, ffi.Pointer) - > - >('CFXMLParserGetCallBacks'); - late final _CFXMLParserGetCallBacks = - _CFXMLParserGetCallBacksPtr.asFunction< - void Function(CFXMLParserRef, ffi.Pointer) - >(); - - CFURLRef CFXMLParserGetSourceURL(CFXMLParserRef parser) { - return _CFXMLParserGetSourceURL(parser); - } - - late final _CFXMLParserGetSourceURLPtr = - _lookup>( - 'CFXMLParserGetSourceURL', - ); - late final _CFXMLParserGetSourceURL = - _CFXMLParserGetSourceURLPtr.asFunction< - CFURLRef Function(CFXMLParserRef) - >(); - - int CFXMLParserGetLocation(CFXMLParserRef parser) { - return _CFXMLParserGetLocation(parser); - } - - late final _CFXMLParserGetLocationPtr = - _lookup>( - 'CFXMLParserGetLocation', - ); - late final _CFXMLParserGetLocation = - _CFXMLParserGetLocationPtr.asFunction(); - - int CFXMLParserGetLineNumber(CFXMLParserRef parser) { - return _CFXMLParserGetLineNumber(parser); - } - - late final _CFXMLParserGetLineNumberPtr = - _lookup>( - 'CFXMLParserGetLineNumber', - ); - late final _CFXMLParserGetLineNumber = - _CFXMLParserGetLineNumberPtr.asFunction(); - - ffi.Pointer CFXMLParserGetDocument(CFXMLParserRef parser) { - return _CFXMLParserGetDocument(parser); - } - - late final _CFXMLParserGetDocumentPtr = - _lookup< - ffi.NativeFunction Function(CFXMLParserRef)> - >('CFXMLParserGetDocument'); - late final _CFXMLParserGetDocument = - _CFXMLParserGetDocumentPtr.asFunction< - ffi.Pointer Function(CFXMLParserRef) - >(); - - int CFXMLParserGetStatusCode(CFXMLParserRef parser) { - return _CFXMLParserGetStatusCode(parser); - } - - late final _CFXMLParserGetStatusCodePtr = - _lookup>( - 'CFXMLParserGetStatusCode', - ); - late final _CFXMLParserGetStatusCode = - _CFXMLParserGetStatusCodePtr.asFunction(); - - CFStringRef CFXMLParserCopyErrorDescription(CFXMLParserRef parser) { - return _CFXMLParserCopyErrorDescription(parser); - } - - late final _CFXMLParserCopyErrorDescriptionPtr = - _lookup>( - 'CFXMLParserCopyErrorDescription', - ); - late final _CFXMLParserCopyErrorDescription = - _CFXMLParserCopyErrorDescriptionPtr.asFunction< - CFStringRef Function(CFXMLParserRef) - >(); - - void CFXMLParserAbort( - CFXMLParserRef parser, - int errorCode, - CFStringRef errorDescription, - ) { - return _CFXMLParserAbort(parser, errorCode, errorDescription); - } - - late final _CFXMLParserAbortPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(CFXMLParserRef, CFIndex, CFStringRef) - > - >('CFXMLParserAbort'); - late final _CFXMLParserAbort = - _CFXMLParserAbortPtr.asFunction< - void Function(CFXMLParserRef, int, CFStringRef) - >(); - - int CFXMLParserParse(CFXMLParserRef parser) { - return _CFXMLParserParse(parser); - } - - late final _CFXMLParserParsePtr = - _lookup>( - 'CFXMLParserParse', - ); - late final _CFXMLParserParse = - _CFXMLParserParsePtr.asFunction(); - - CFXMLTreeRef CFXMLTreeCreateFromData( - CFAllocatorRef allocator, - CFDataRef xmlData, - CFURLRef dataSource, - int parseOptions, - int versionOfNodes, - ) { - return _CFXMLTreeCreateFromData( - allocator, - xmlData, - dataSource, - parseOptions, - versionOfNodes, + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - } - - late final _CFXMLTreeCreateFromDataPtr = - _lookup< - ffi.NativeFunction< - CFXMLTreeRef Function( - CFAllocatorRef, - CFDataRef, - CFURLRef, - CFOptionFlags, - CFIndex, - ) - > - >('CFXMLTreeCreateFromData'); - late final _CFXMLTreeCreateFromData = - _CFXMLTreeCreateFromDataPtr.asFunction< - CFXMLTreeRef Function(CFAllocatorRef, CFDataRef, CFURLRef, int, int) - >(); - - CFXMLTreeRef CFXMLTreeCreateFromDataWithError( - CFAllocatorRef allocator, - CFDataRef xmlData, - CFURLRef dataSource, - int parseOptions, - int versionOfNodes, - ffi.Pointer errorDict, - ) { - return _CFXMLTreeCreateFromDataWithError( - allocator, - xmlData, - dataSource, - parseOptions, - versionOfNodes, - errorDict, + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, ); - } - - late final _CFXMLTreeCreateFromDataWithErrorPtr = - _lookup< - ffi.NativeFunction< - CFXMLTreeRef Function( - CFAllocatorRef, - CFDataRef, - CFURLRef, - CFOptionFlags, - CFIndex, - ffi.Pointer, - ) - > - >('CFXMLTreeCreateFromDataWithError'); - late final _CFXMLTreeCreateFromDataWithError = - _CFXMLTreeCreateFromDataWithErrorPtr.asFunction< - CFXMLTreeRef Function( - CFAllocatorRef, - CFDataRef, - CFURLRef, - int, - int, - ffi.Pointer, - ) - >(); - - CFXMLTreeRef CFXMLTreeCreateWithDataFromURL( - CFAllocatorRef allocator, - CFURLRef dataSource, - int parseOptions, - int versionOfNodes, - ) { - return _CFXMLTreeCreateWithDataFromURL( - allocator, - dataSource, - parseOptions, - versionOfNodes, + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( + builder, + URLSession_task_didReceiveInformationalResponse_, ); - } - - late final _CFXMLTreeCreateWithDataFromURLPtr = - _lookup< - ffi.NativeFunction< - CFXMLTreeRef Function( - CFAllocatorRef, - CFURLRef, - CFOptionFlags, - CFIndex, - ) - > - >('CFXMLTreeCreateWithDataFromURL'); - late final _CFXMLTreeCreateWithDataFromURL = - _CFXMLTreeCreateWithDataFromURLPtr.asFunction< - CFXMLTreeRef Function(CFAllocatorRef, CFURLRef, int, int) - >(); - - CFDataRef CFXMLTreeCreateXMLData( - CFAllocatorRef allocator, - CFXMLTreeRef xmlTree, - ) { - return _CFXMLTreeCreateXMLData(allocator, xmlTree); - } - - late final _CFXMLTreeCreateXMLDataPtr = - _lookup< - ffi.NativeFunction - >('CFXMLTreeCreateXMLData'); - late final _CFXMLTreeCreateXMLData = - _CFXMLTreeCreateXMLDataPtr.asFunction< - CFDataRef Function(CFAllocatorRef, CFXMLTreeRef) - >(); - - CFStringRef CFXMLCreateStringByEscapingEntities( - CFAllocatorRef allocator, - CFStringRef string, - CFDictionaryRef entitiesDictionary, - ) { - return _CFXMLCreateStringByEscapingEntities( - allocator, - string, - entitiesDictionary, + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, ); - } - - late final _CFXMLCreateStringByEscapingEntitiesPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFDictionaryRef) - > - >('CFXMLCreateStringByEscapingEntities'); - late final _CFXMLCreateStringByEscapingEntities = - _CFXMLCreateStringByEscapingEntitiesPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFDictionaryRef) - >(); - - CFStringRef CFXMLCreateStringByUnescapingEntities( - CFAllocatorRef allocator, - CFStringRef string, - CFDictionaryRef entitiesDictionary, - ) { - return _CFXMLCreateStringByUnescapingEntities( - allocator, - string, - entitiesDictionary, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStream_, ); - } - - late final _CFXMLCreateStringByUnescapingEntitiesPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFDictionaryRef) - > - >('CFXMLCreateStringByUnescapingEntities'); - late final _CFXMLCreateStringByUnescapingEntities = - _CFXMLCreateStringByUnescapingEntitiesPtr.asFunction< - CFStringRef Function(CFAllocatorRef, CFStringRef, CFDictionaryRef) - >(); - - late final ffi.Pointer _kCFXMLTreeErrorDescription = - _lookup('kCFXMLTreeErrorDescription'); - - CFStringRef get kCFXMLTreeErrorDescription => - _kCFXMLTreeErrorDescription.value; - - late final ffi.Pointer _kCFXMLTreeErrorLineNumber = - _lookup('kCFXMLTreeErrorLineNumber'); - - CFStringRef get kCFXMLTreeErrorLineNumber => _kCFXMLTreeErrorLineNumber.value; - - late final ffi.Pointer _kCFXMLTreeErrorLocation = - _lookup('kCFXMLTreeErrorLocation'); - - CFStringRef get kCFXMLTreeErrorLocation => _kCFXMLTreeErrorLocation.value; - - late final ffi.Pointer _kCFXMLTreeErrorStatusCode = - _lookup('kCFXMLTreeErrorStatusCode'); - - CFStringRef get kCFXMLTreeErrorStatusCode => _kCFXMLTreeErrorStatusCode.value; - - late final ffi.Pointer _gGuidCssm = _lookup( - 'gGuidCssm', - ); - - CSSM_GUID get gGuidCssm => _gGuidCssm.ref; - - late final ffi.Pointer _gGuidAppleFileDL = _lookup( - 'gGuidAppleFileDL', - ); - - CSSM_GUID get gGuidAppleFileDL => _gGuidAppleFileDL.ref; - - late final ffi.Pointer _gGuidAppleCSP = _lookup( - 'gGuidAppleCSP', - ); - - CSSM_GUID get gGuidAppleCSP => _gGuidAppleCSP.ref; - - late final ffi.Pointer _gGuidAppleCSPDL = _lookup( - 'gGuidAppleCSPDL', - ); - - CSSM_GUID get gGuidAppleCSPDL => _gGuidAppleCSPDL.ref; - - late final ffi.Pointer _gGuidAppleX509CL = _lookup( - 'gGuidAppleX509CL', - ); - - CSSM_GUID get gGuidAppleX509CL => _gGuidAppleX509CL.ref; - - late final ffi.Pointer _gGuidAppleX509TP = _lookup( - 'gGuidAppleX509TP', - ); - - CSSM_GUID get gGuidAppleX509TP => _gGuidAppleX509TP.ref; - - late final ffi.Pointer _gGuidAppleLDAPDL = _lookup( - 'gGuidAppleLDAPDL', - ); - - CSSM_GUID get gGuidAppleLDAPDL => _gGuidAppleLDAPDL.ref; - - late final ffi.Pointer _gGuidAppleDotMacTP = _lookup( - 'gGuidAppleDotMacTP', - ); - - CSSM_GUID get gGuidAppleDotMacTP => _gGuidAppleDotMacTP.ref; - - late final ffi.Pointer _gGuidAppleSdCSPDL = _lookup( - 'gGuidAppleSdCSPDL', - ); - - CSSM_GUID get gGuidAppleSdCSPDL => _gGuidAppleSdCSPDL.ref; - - late final ffi.Pointer _gGuidAppleDotMacDL = _lookup( - 'gGuidAppleDotMacDL', - ); - - CSSM_GUID get gGuidAppleDotMacDL => _gGuidAppleDotMacDL.ref; - - void cssmPerror(ffi.Pointer how, int error) { - return _cssmPerror(how, error); - } - - late final _cssmPerrorPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, CSSM_RETURN) - > - >('cssmPerror'); - late final _cssmPerror = _cssmPerrorPtr - .asFunction, int)>(); - - bool cssmOidToAlg( - ffi.Pointer oid, - ffi.Pointer alg, - ) { - return _cssmOidToAlg(oid, alg); - } - - late final _cssmOidToAlgPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('cssmOidToAlg'); - late final _cssmOidToAlg = _cssmOidToAlgPtr - .asFunction< - bool Function(ffi.Pointer, ffi.Pointer) - >(); - - ffi.Pointer cssmAlgToOid(int algId) { - return _cssmAlgToOid(algId); - } - - late final _cssmAlgToOidPtr = - _lookup< - ffi.NativeFunction Function(CSSM_ALGORITHMS)> - >('cssmAlgToOid'); - late final _cssmAlgToOid = _cssmAlgToOidPtr - .asFunction Function(int)>(); - - late final ffi.Pointer _kSecPropertyTypeTitle = - _lookup('kSecPropertyTypeTitle'); - - CFStringRef get kSecPropertyTypeTitle => _kSecPropertyTypeTitle.value; - - set kSecPropertyTypeTitle(CFStringRef value) => - _kSecPropertyTypeTitle.value = value; - - late final ffi.Pointer _kSecPropertyTypeError = - _lookup('kSecPropertyTypeError'); - - CFStringRef get kSecPropertyTypeError => _kSecPropertyTypeError.value; - - set kSecPropertyTypeError(CFStringRef value) => - _kSecPropertyTypeError.value = value; - - late final ffi.Pointer _kSecTrustEvaluationDate = - _lookup('kSecTrustEvaluationDate'); - - CFStringRef get kSecTrustEvaluationDate => _kSecTrustEvaluationDate.value; - - set kSecTrustEvaluationDate(CFStringRef value) => - _kSecTrustEvaluationDate.value = value; - - late final ffi.Pointer _kSecTrustExtendedValidation = - _lookup('kSecTrustExtendedValidation'); - - CFStringRef get kSecTrustExtendedValidation => - _kSecTrustExtendedValidation.value; - - set kSecTrustExtendedValidation(CFStringRef value) => - _kSecTrustExtendedValidation.value = value; - - late final ffi.Pointer _kSecTrustOrganizationName = - _lookup('kSecTrustOrganizationName'); - - CFStringRef get kSecTrustOrganizationName => _kSecTrustOrganizationName.value; - - set kSecTrustOrganizationName(CFStringRef value) => - _kSecTrustOrganizationName.value = value; - - late final ffi.Pointer _kSecTrustResultValue = - _lookup('kSecTrustResultValue'); - - CFStringRef get kSecTrustResultValue => _kSecTrustResultValue.value; - - set kSecTrustResultValue(CFStringRef value) => - _kSecTrustResultValue.value = value; - - late final ffi.Pointer _kSecTrustRevocationChecked = - _lookup('kSecTrustRevocationChecked'); - - CFStringRef get kSecTrustRevocationChecked => - _kSecTrustRevocationChecked.value; - - set kSecTrustRevocationChecked(CFStringRef value) => - _kSecTrustRevocationChecked.value = value; - - late final ffi.Pointer _kSecTrustRevocationValidUntilDate = - _lookup('kSecTrustRevocationValidUntilDate'); - - CFStringRef get kSecTrustRevocationValidUntilDate => - _kSecTrustRevocationValidUntilDate.value; - - set kSecTrustRevocationValidUntilDate(CFStringRef value) => - _kSecTrustRevocationValidUntilDate.value = value; - - late final ffi.Pointer _kSecTrustCertificateTransparency = - _lookup('kSecTrustCertificateTransparency'); - - CFStringRef get kSecTrustCertificateTransparency => - _kSecTrustCertificateTransparency.value; - - set kSecTrustCertificateTransparency(CFStringRef value) => - _kSecTrustCertificateTransparency.value = value; - - late final ffi.Pointer - _kSecTrustCertificateTransparencyWhiteList = _lookup( - 'kSecTrustCertificateTransparencyWhiteList', - ); - - CFStringRef get kSecTrustCertificateTransparencyWhiteList => - _kSecTrustCertificateTransparencyWhiteList.value; - - set kSecTrustCertificateTransparencyWhiteList(CFStringRef value) => - _kSecTrustCertificateTransparencyWhiteList.value = value; - - late final ffi.Pointer _kSecTrustQCStatements = - _lookup('kSecTrustQCStatements'); - - CFStringRef get kSecTrustQCStatements => _kSecTrustQCStatements.value; - - set kSecTrustQCStatements(CFStringRef value) => - _kSecTrustQCStatements.value = value; - - late final ffi.Pointer _kSecTrustQWACValidation = - _lookup('kSecTrustQWACValidation'); - - CFStringRef get kSecTrustQWACValidation => _kSecTrustQWACValidation.value; - - set kSecTrustQWACValidation(CFStringRef value) => - _kSecTrustQWACValidation.value = value; - - int SecTrustGetTypeID() { - return _SecTrustGetTypeID(); - } - - late final _SecTrustGetTypeIDPtr = - _lookup>('SecTrustGetTypeID'); - late final _SecTrustGetTypeID = - _SecTrustGetTypeIDPtr.asFunction(); - - int SecTrustCreateWithCertificates( - CFTypeRef certificates, - CFTypeRef policies, - ffi.Pointer trust, - ) { - return _SecTrustCreateWithCertificates(certificates, policies, trust); - } - - late final _SecTrustCreateWithCertificatesPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(CFTypeRef, CFTypeRef, ffi.Pointer) - > - >('SecTrustCreateWithCertificates'); - late final _SecTrustCreateWithCertificates = - _SecTrustCreateWithCertificatesPtr.asFunction< - int Function(CFTypeRef, CFTypeRef, ffi.Pointer) - >(); - - int SecTrustSetPolicies(SecTrustRef trust, CFTypeRef policies) { - return _SecTrustSetPolicies(trust, policies); - } - - late final _SecTrustSetPoliciesPtr = - _lookup>( - 'SecTrustSetPolicies', - ); - late final _SecTrustSetPolicies = - _SecTrustSetPoliciesPtr.asFunction< - int Function(SecTrustRef, CFTypeRef) - >(); - - int SecTrustCopyPolicies( - SecTrustRef trust, - ffi.Pointer policies, - ) { - return _SecTrustCopyPolicies(trust, policies); - } - - late final _SecTrustCopyPoliciesPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecTrustRef, ffi.Pointer) - > - >('SecTrustCopyPolicies'); - late final _SecTrustCopyPolicies = - _SecTrustCopyPoliciesPtr.asFunction< - int Function(SecTrustRef, ffi.Pointer) - >(); - - int SecTrustSetNetworkFetchAllowed(SecTrustRef trust, int allowFetch) { - return _SecTrustSetNetworkFetchAllowed(trust, allowFetch); - } - - late final _SecTrustSetNetworkFetchAllowedPtr = - _lookup>( - 'SecTrustSetNetworkFetchAllowed', - ); - late final _SecTrustSetNetworkFetchAllowed = - _SecTrustSetNetworkFetchAllowedPtr.asFunction< - int Function(SecTrustRef, int) - >(); - - int SecTrustGetNetworkFetchAllowed( - SecTrustRef trust, - ffi.Pointer allowFetch, - ) { - return _SecTrustGetNetworkFetchAllowed(trust, allowFetch); - } - - late final _SecTrustGetNetworkFetchAllowedPtr = - _lookup< - ffi.NativeFunction)> - >('SecTrustGetNetworkFetchAllowed'); - late final _SecTrustGetNetworkFetchAllowed = - _SecTrustGetNetworkFetchAllowedPtr.asFunction< - int Function(SecTrustRef, ffi.Pointer) - >(); - - int SecTrustSetAnchorCertificates( - SecTrustRef trust, - CFArrayRef anchorCertificates, - ) { - return _SecTrustSetAnchorCertificates(trust, anchorCertificates); - } - - late final _SecTrustSetAnchorCertificatesPtr = - _lookup>( - 'SecTrustSetAnchorCertificates', - ); - late final _SecTrustSetAnchorCertificates = - _SecTrustSetAnchorCertificatesPtr.asFunction< - int Function(SecTrustRef, CFArrayRef) - >(); - - int SecTrustSetAnchorCertificatesOnly( - SecTrustRef trust, - int anchorCertificatesOnly, - ) { - return _SecTrustSetAnchorCertificatesOnly(trust, anchorCertificatesOnly); - } - - late final _SecTrustSetAnchorCertificatesOnlyPtr = - _lookup>( - 'SecTrustSetAnchorCertificatesOnly', - ); - late final _SecTrustSetAnchorCertificatesOnly = - _SecTrustSetAnchorCertificatesOnlyPtr.asFunction< - int Function(SecTrustRef, int) - >(); - - int SecTrustCopyCustomAnchorCertificates( - SecTrustRef trust, - ffi.Pointer anchors, - ) { - return _SecTrustCopyCustomAnchorCertificates(trust, anchors); - } - - late final _SecTrustCopyCustomAnchorCertificatesPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecTrustRef, ffi.Pointer) - > - >('SecTrustCopyCustomAnchorCertificates'); - late final _SecTrustCopyCustomAnchorCertificates = - _SecTrustCopyCustomAnchorCertificatesPtr.asFunction< - int Function(SecTrustRef, ffi.Pointer) - >(); - - int SecTrustSetVerifyDate(SecTrustRef trust, CFDateRef verifyDate) { - return _SecTrustSetVerifyDate(trust, verifyDate); - } - - late final _SecTrustSetVerifyDatePtr = - _lookup>( - 'SecTrustSetVerifyDate', - ); - late final _SecTrustSetVerifyDate = - _SecTrustSetVerifyDatePtr.asFunction< - int Function(SecTrustRef, CFDateRef) - >(); - - double SecTrustGetVerifyTime(SecTrustRef trust) { - return _SecTrustGetVerifyTime(trust); - } - - late final _SecTrustGetVerifyTimePtr = - _lookup>( - 'SecTrustGetVerifyTime', - ); - late final _SecTrustGetVerifyTime = - _SecTrustGetVerifyTimePtr.asFunction(); - - int SecTrustEvaluate(SecTrustRef trust, ffi.Pointer result) { - return _SecTrustEvaluate(trust, result); - } - - late final _SecTrustEvaluatePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecTrustRef, ffi.Pointer) - > - >('SecTrustEvaluate'); - late final _SecTrustEvaluate = - _SecTrustEvaluatePtr.asFunction< - int Function(SecTrustRef, ffi.Pointer) - >(); - - DartSInt32 SecTrustEvaluateAsync( - SecTrustRef trust, - Dartdispatch_queue_t? queue, - DartSecTrustCallback result, - ) { - return _SecTrustEvaluateAsync( - trust, - queue?.ref.pointer ?? ffi.nullptr, - result.ref.pointer, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionDataDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), ); } - late final _SecTrustEvaluateAsyncPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecTrustRef, dispatch_queue_t, SecTrustCallback) - > - >('SecTrustEvaluateAsync'); - late final _SecTrustEvaluateAsync = - _SecTrustEvaluateAsyncPtr.asFunction< - int Function(SecTrustRef, dispatch_queue_t, SecTrustCallback) - >(); - - bool SecTrustEvaluateWithError( - SecTrustRef trust, - ffi.Pointer error, - ) { - return _SecTrustEvaluateWithError(trust, error); - } - - late final _SecTrustEvaluateWithErrorPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function(SecTrustRef, ffi.Pointer) - > - >('SecTrustEvaluateWithError'); - late final _SecTrustEvaluateWithError = - _SecTrustEvaluateWithErrorPtr.asFunction< - bool Function(SecTrustRef, ffi.Pointer) - >(); - - DartSInt32 SecTrustEvaluateAsyncWithError( - SecTrustRef trust, - Dartdispatch_queue_t queue, - DartSecTrustWithErrorCallback result, - ) { - return _SecTrustEvaluateAsyncWithError( - trust, - queue.ref.pointer, - result.ref.pointer, + /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking + /// listeners will be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsBlocking( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? + URLSession_dataTask_didBecomeDownloadTask_, + void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? + URLSession_dataTask_didBecomeStreamTask_, + void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? + URLSession_dataTask_didReceiveData_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_didReceiveResponse_completionHandler_, + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + )? + URLSession_dataTask_willCacheResponse_completionHandler_, + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implementAsBlocking( + builder, + URLSession_dataTask_didBecomeDownloadTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implementAsBlocking( + builder, + URLSession_dataTask_didBecomeStreamTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implementAsBlocking( + builder, + URLSession_dataTask_didReceiveData_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsBlocking( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsBlocking( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsBlocking( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, ); + builder.addProtocol($protocol); } - late final _SecTrustEvaluateAsyncWithErrorPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SecTrustRef, - dispatch_queue_t, - SecTrustWithErrorCallback, + /// Notification that a data task has become a download task. No + /// future messages will be sent to the data task. + static final URLSession_dataTask_didBecomeDownloadTask_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didBecomeDownloadTask_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didBecomeDownloadTask_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, ) - > - >('SecTrustEvaluateAsyncWithError'); - late final _SecTrustEvaluateAsyncWithError = - _SecTrustEvaluateAsyncWithErrorPtr.asFunction< - int Function(SecTrustRef, dispatch_queue_t, SecTrustWithErrorCallback) - >(); - - int SecTrustGetTrustResult( - SecTrustRef trust, - ffi.Pointer result, - ) { - return _SecTrustGetTrustResult(trust, result); - } - - late final _SecTrustGetTrustResultPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecTrustRef, ffi.Pointer) - > - >('SecTrustGetTrustResult'); - late final _SecTrustGetTrustResult = - _SecTrustGetTrustResultPtr.asFunction< - int Function(SecTrustRef, ffi.Pointer) - >(); - - SecKeyRef SecTrustCopyPublicKey(SecTrustRef trust) { - return _SecTrustCopyPublicKey(trust); - } - - late final _SecTrustCopyPublicKeyPtr = - _lookup>( - 'SecTrustCopyPublicKey', - ); - late final _SecTrustCopyPublicKey = - _SecTrustCopyPublicKeyPtr.asFunction(); - - SecKeyRef SecTrustCopyKey(SecTrustRef trust) { - return _SecTrustCopyKey(trust); - } - - late final _SecTrustCopyKeyPtr = - _lookup>( - 'SecTrustCopyKey', - ); - late final _SecTrustCopyKey = - _SecTrustCopyKeyPtr.asFunction(); - - int SecTrustGetCertificateCount(SecTrustRef trust) { - return _SecTrustGetCertificateCount(trust); - } - - late final _SecTrustGetCertificateCountPtr = - _lookup>( - 'SecTrustGetCertificateCount', - ); - late final _SecTrustGetCertificateCount = - _SecTrustGetCertificateCountPtr.asFunction(); - - SecCertificateRef SecTrustGetCertificateAtIndex(SecTrustRef trust, int ix) { - return _SecTrustGetCertificateAtIndex(trust, ix); - } - - late final _SecTrustGetCertificateAtIndexPtr = - _lookup< - ffi.NativeFunction - >('SecTrustGetCertificateAtIndex'); - late final _SecTrustGetCertificateAtIndex = - _SecTrustGetCertificateAtIndexPtr.asFunction< - SecCertificateRef Function(SecTrustRef, int) - >(); - - CFDataRef SecTrustCopyExceptions(SecTrustRef trust) { - return _SecTrustCopyExceptions(trust); - } - - late final _SecTrustCopyExceptionsPtr = - _lookup>( - 'SecTrustCopyExceptions', - ); - late final _SecTrustCopyExceptions = - _SecTrustCopyExceptionsPtr.asFunction(); - - bool SecTrustSetExceptions(SecTrustRef trust, CFDataRef exceptions) { - return _SecTrustSetExceptions(trust, exceptions); - } - - late final _SecTrustSetExceptionsPtr = - _lookup>( - 'SecTrustSetExceptions', - ); - late final _SecTrustSetExceptions = - _SecTrustSetExceptionsPtr.asFunction< - bool Function(SecTrustRef, CFDataRef) - >(); - - CFArrayRef SecTrustCopyProperties(SecTrustRef trust) { - return _SecTrustCopyProperties(trust); - } - - late final _SecTrustCopyPropertiesPtr = - _lookup>( - 'SecTrustCopyProperties', + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionDownloadTask arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionDownloadTask arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionDownloadTask arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final _SecTrustCopyProperties = - _SecTrustCopyPropertiesPtr.asFunction(); - - CFDictionaryRef SecTrustCopyResult(SecTrustRef trust) { - return _SecTrustCopyResult(trust); - } - late final _SecTrustCopyResultPtr = - _lookup>( - 'SecTrustCopyResult', + /// Notification that a data task has become a bidirectional stream + /// task. No future messages will be sent to the data task. The newly + /// created streamTask will carry the original request and response as + /// properties. + /// + /// For requests that were pipelined, the stream object will only allow + /// reading, and the object will immediately issue a + /// -URLSession:writeClosedForStream:. Pipelining can be disabled for + /// all requests in a session, or by the NSURLRequest + /// HTTPShouldUsePipelining property. + /// + /// The underlying connection is no longer considered part of the HTTP + /// connection cache and won't count against the total number of + /// connections per host. + static final URLSession_dataTask_didBecomeStreamTask_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didBecomeStreamTask_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didBecomeStreamTask_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionStreamTask arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionStreamTask arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionStreamTask arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final _SecTrustCopyResult = - _SecTrustCopyResultPtr.asFunction< - CFDictionaryRef Function(SecTrustRef) - >(); - - int SecTrustSetOCSPResponse(SecTrustRef trust, CFTypeRef responseData) { - return _SecTrustSetOCSPResponse(trust, responseData); - } - late final _SecTrustSetOCSPResponsePtr = - _lookup>( - 'SecTrustSetOCSPResponse', + /// Sent when data is available for the delegate to consume. As the + /// data may be discontiguous, you should use + /// [NSData enumerateByteRangesUsingBlock:] to access it. + static final URLSession_dataTask_didReceiveData_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionDataTask, objc.NSData) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didReceiveData_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didReceiveData_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionDataTask, objc.NSData) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + objc.NSData arg3, + ) => func(arg1, arg2, arg3), + ), + (void Function(NSURLSession, NSURLSessionDataTask, objc.NSData) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + objc.NSData arg3, + ) => func(arg1, arg2, arg3), + ), + (void Function(NSURLSession, NSURLSessionDataTask, objc.NSData) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + objc.NSData arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final _SecTrustSetOCSPResponse = - _SecTrustSetOCSPResponsePtr.asFunction< - int Function(SecTrustRef, CFTypeRef) - >(); - - int SecTrustSetSignedCertificateTimestamps( - SecTrustRef trust, - CFArrayRef sctArray, - ) { - return _SecTrustSetSignedCertificateTimestamps(trust, sctArray); - } - late final _SecTrustSetSignedCertificateTimestampsPtr = - _lookup>( - 'SecTrustSetSignedCertificateTimestamps', + /// The task has received a response and no further messages will be + /// received until the completion block is called. The disposition + /// allows you to cancel a request or to turn a data task into a + /// download task. This delegate message is optional - if you do not + /// implement it, you can get the response as a property of the task. + /// + /// This method will not be called for background upload tasks (which cannot be converted to download tasks). + static final URLSession_dataTask_didReceiveResponse_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLResponse arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLResponse arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLResponse arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), ); - late final _SecTrustSetSignedCertificateTimestamps = - _SecTrustSetSignedCertificateTimestampsPtr.asFunction< - int Function(SecTrustRef, CFArrayRef) - >(); - CFArrayRef SecTrustCopyCertificateChain(SecTrustRef trust) { - return _SecTrustCopyCertificateChain(trust); - } - - late final _SecTrustCopyCertificateChainPtr = - _lookup>( - 'SecTrustCopyCertificateChain', + /// Invoke the completion routine with a valid NSCachedURLResponse to + /// allow the resulting data to be cached, or pass nil to prevent + /// caching. Note that there is no guarantee that caching will be + /// attempted for a given resource, and you should not rely on this + /// message to receive the resource data. + static final URLSession_dataTask_willCacheResponse_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_willCacheResponse_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_willCacheResponse_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSCachedURLResponse arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSCachedURLResponse arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSCachedURLResponse arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), ); - late final _SecTrustCopyCertificateChain = - _SecTrustCopyCertificateChainPtr.asFunction< - CFArrayRef Function(SecTrustRef) - >(); - - int SecTrustSetOptions(SecTrustRef trustRef, int options) { - return _SecTrustSetOptions(trustRef, options); - } - late final _SecTrustSetOptionsPtr = - _lookup>( - 'SecTrustSetOptions', + /// The last message a session receives. A session will only become + /// invalid because of a systemic error or when it has been + /// explicitly invalidated, in which case the error parameter will be nil. + static final URLSession_didBecomeInvalidWithError_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, objc.NSError?) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_didBecomeInvalidWithError_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_didBecomeInvalidWithError_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), ); - late final _SecTrustSetOptions = - _SecTrustSetOptionsPtr.asFunction(); - - int SecTrustSetParameters( - SecTrustRef trustRef, - int action, - CFDataRef actionData, - ) { - return _SecTrustSetParameters(trustRef, action, actionData); - } - - late final _SecTrustSetParametersPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecTrustRef, CSSM_TP_ACTION, CFDataRef) - > - >('SecTrustSetParameters'); - late final _SecTrustSetParameters = - _SecTrustSetParametersPtr.asFunction< - int Function(SecTrustRef, int, CFDataRef) - >(); - - int SecTrustSetKeychains(SecTrustRef trust, CFTypeRef keychainOrArray) { - return _SecTrustSetKeychains(trust, keychainOrArray); - } - late final _SecTrustSetKeychainsPtr = - _lookup>( - 'SecTrustSetKeychains', + /// Notification that a task has been created. This method is the first message + /// a task sends, providing a place to configure the task before it is resumed. + /// + /// This delegate callback is *NOT* dispatched to the delegate queue. It is + /// invoked synchronously before the task creation method returns. + static final URLSession_didCreateTask_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_didCreateTask_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_didCreateTask_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), ); - late final _SecTrustSetKeychains = - _SecTrustSetKeychainsPtr.asFunction< - int Function(SecTrustRef, CFTypeRef) - >(); - - int SecTrustGetResult( - SecTrustRef trustRef, - ffi.Pointer result, - ffi.Pointer certChain, - ffi.Pointer> statusChain, - ) { - return _SecTrustGetResult(trustRef, result, certChain, statusChain); - } - late final _SecTrustGetResultPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SecTrustRef, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - > - >('SecTrustGetResult'); - late final _SecTrustGetResult = - _SecTrustGetResultPtr.asFunction< - int Function( - SecTrustRef, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + /// If implemented, when a connection level authentication challenge + /// has occurred, this delegate will be given the opportunity to + /// provide authentication credentials to the underlying + /// connection. Some types of authentication will apply to more than + /// one request on a given connection to a server (SSL Server Trust + /// challenges). If this delegate message is not implemented, the + /// behavior will be to use the default handling, which may involve user + /// interaction. + static final URLSession_didReceiveChallenge_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - >(); - - int SecTrustGetCssmResult( - SecTrustRef trust, - ffi.Pointer result, - ) { - return _SecTrustGetCssmResult(trust, result); - } - - late final _SecTrustGetCssmResultPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SecTrustRef, - ffi.Pointer, + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - > - >('SecTrustGetCssmResult'); - late final _SecTrustGetCssmResult = - _SecTrustGetCssmResultPtr.asFunction< - int Function( - SecTrustRef, - ffi.Pointer, - ) - >(); - - int SecTrustGetCssmResultCode( - SecTrustRef trust, - ffi.Pointer resultCode, - ) { - return _SecTrustGetCssmResultCode(trust, resultCode); - } - - late final _SecTrustGetCssmResultCodePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecTrustRef, ffi.Pointer) - > - >('SecTrustGetCssmResultCode'); - late final _SecTrustGetCssmResultCode = - _SecTrustGetCssmResultCodePtr.asFunction< - int Function(SecTrustRef, ffi.Pointer) - >(); - - int SecTrustGetTPHandle( - SecTrustRef trust, - ffi.Pointer handle, - ) { - return _SecTrustGetTPHandle(trust, handle); - } - - late final _SecTrustGetTPHandlePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecTrustRef, ffi.Pointer) - > - >('SecTrustGetTPHandle'); - late final _SecTrustGetTPHandle = - _SecTrustGetTPHandlePtr.asFunction< - int Function(SecTrustRef, ffi.Pointer) - >(); - - int SecTrustCopyAnchorCertificates(ffi.Pointer anchors) { - return _SecTrustCopyAnchorCertificates(anchors); - } - - late final _SecTrustCopyAnchorCertificatesPtr = - _lookup)>>( - 'SecTrustCopyAnchorCertificates', - ); - late final _SecTrustCopyAnchorCertificates = - _SecTrustCopyAnchorCertificatesPtr.asFunction< - int Function(ffi.Pointer) - >(); - - int SecCertificateGetTypeID() { - return _SecCertificateGetTypeID(); - } - - late final _SecCertificateGetTypeIDPtr = - _lookup>( - 'SecCertificateGetTypeID', - ); - late final _SecCertificateGetTypeID = - _SecCertificateGetTypeIDPtr.asFunction(); - - SecCertificateRef SecCertificateCreateWithData( - CFAllocatorRef allocator, - CFDataRef data, - ) { - return _SecCertificateCreateWithData(allocator, data); - } - - late final _SecCertificateCreateWithDataPtr = - _lookup< - ffi.NativeFunction< - SecCertificateRef Function(CFAllocatorRef, CFDataRef) - > - >('SecCertificateCreateWithData'); - late final _SecCertificateCreateWithData = - _SecCertificateCreateWithDataPtr.asFunction< - SecCertificateRef Function(CFAllocatorRef, CFDataRef) - >(); - - CFDataRef SecCertificateCopyData(SecCertificateRef certificate) { - return _SecCertificateCopyData(certificate); - } - - late final _SecCertificateCopyDataPtr = - _lookup>( - 'SecCertificateCopyData', - ); - late final _SecCertificateCopyData = - _SecCertificateCopyDataPtr.asFunction< - CFDataRef Function(SecCertificateRef) - >(); - - CFStringRef SecCertificateCopySubjectSummary(SecCertificateRef certificate) { - return _SecCertificateCopySubjectSummary(certificate); - } - - late final _SecCertificateCopySubjectSummaryPtr = - _lookup>( - 'SecCertificateCopySubjectSummary', + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final _SecCertificateCopySubjectSummary = - _SecCertificateCopySubjectSummaryPtr.asFunction< - CFStringRef Function(SecCertificateRef) - >(); - - int SecCertificateCopyCommonName( - SecCertificateRef certificate, - ffi.Pointer commonName, - ) { - return _SecCertificateCopyCommonName(certificate, commonName); - } - - late final _SecCertificateCopyCommonNamePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateCopyCommonName'); - late final _SecCertificateCopyCommonName = - _SecCertificateCopyCommonNamePtr.asFunction< - int Function(SecCertificateRef, ffi.Pointer) - >(); - - int SecCertificateCopyEmailAddresses( - SecCertificateRef certificate, - ffi.Pointer emailAddresses, - ) { - return _SecCertificateCopyEmailAddresses(certificate, emailAddresses); - } - - late final _SecCertificateCopyEmailAddressesPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateCopyEmailAddresses'); - late final _SecCertificateCopyEmailAddresses = - _SecCertificateCopyEmailAddressesPtr.asFunction< - int Function(SecCertificateRef, ffi.Pointer) - >(); - - CFDataRef SecCertificateCopyNormalizedIssuerSequence( - SecCertificateRef certificate, - ) { - return _SecCertificateCopyNormalizedIssuerSequence(certificate); - } - late final _SecCertificateCopyNormalizedIssuerSequencePtr = - _lookup>( - 'SecCertificateCopyNormalizedIssuerSequence', + /// Sent as the last message related to a specific task. Error may be + /// nil, which implies that no error occurred and this task is complete. + static final URLSession_task_didCompleteWithError_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, objc.NSError?) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didCompleteWithError_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didCompleteWithError_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final _SecCertificateCopyNormalizedIssuerSequence = - _SecCertificateCopyNormalizedIssuerSequencePtr.asFunction< - CFDataRef Function(SecCertificateRef) - >(); - - CFDataRef SecCertificateCopyNormalizedSubjectSequence( - SecCertificateRef certificate, - ) { - return _SecCertificateCopyNormalizedSubjectSequence(certificate); - } - late final _SecCertificateCopyNormalizedSubjectSequencePtr = - _lookup>( - 'SecCertificateCopyNormalizedSubjectSequence', + /// Sent when complete statistics information has been collected for the task. + static final URLSession_task_didFinishCollectingMetrics_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didFinishCollectingMetrics_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didFinishCollectingMetrics_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final _SecCertificateCopyNormalizedSubjectSequence = - _SecCertificateCopyNormalizedSubjectSequencePtr.asFunction< - CFDataRef Function(SecCertificateRef) - >(); - - SecKeyRef SecCertificateCopyKey(SecCertificateRef certificate) { - return _SecCertificateCopyKey(certificate); - } - late final _SecCertificateCopyKeyPtr = - _lookup>( - 'SecCertificateCopyKey', + /// The task has received a request specific authentication challenge. + /// If this delegate is not implemented, the session specific authentication challenge + /// will *NOT* be called and the behavior will be the same as using the default handling + /// disposition. + static final URLSession_task_didReceiveChallenge_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), ); - late final _SecCertificateCopyKey = - _SecCertificateCopyKeyPtr.asFunction< - SecKeyRef Function(SecCertificateRef) - >(); - - int SecCertificateCopyPublicKey( - SecCertificateRef certificate, - ffi.Pointer key, - ) { - return _SecCertificateCopyPublicKey(certificate, key); - } - - late final _SecCertificateCopyPublicKeyPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateCopyPublicKey'); - late final _SecCertificateCopyPublicKey = - _SecCertificateCopyPublicKeyPtr.asFunction< - int Function(SecCertificateRef, ffi.Pointer) - >(); - - CFDataRef SecCertificateCopySerialNumberData( - SecCertificateRef certificate, - ffi.Pointer error, - ) { - return _SecCertificateCopySerialNumberData(certificate, error); - } - - late final _SecCertificateCopySerialNumberDataPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateCopySerialNumberData'); - late final _SecCertificateCopySerialNumberData = - _SecCertificateCopySerialNumberDataPtr.asFunction< - CFDataRef Function(SecCertificateRef, ffi.Pointer) - >(); - - CFDateRef SecCertificateCopyNotValidBeforeDate( - SecCertificateRef certificate, - ) { - return _SecCertificateCopyNotValidBeforeDate(certificate); - } - late final _SecCertificateCopyNotValidBeforeDatePtr = - _lookup>( - 'SecCertificateCopyNotValidBeforeDate', + /// Sent for each informational response received except 101 switching protocols. + static final URLSession_task_didReceiveInformationalResponse_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didReceiveInformationalResponse_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didReceiveInformationalResponse_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final _SecCertificateCopyNotValidBeforeDate = - _SecCertificateCopyNotValidBeforeDatePtr.asFunction< - CFDateRef Function(SecCertificateRef) - >(); - - CFDateRef SecCertificateCopyNotValidAfterDate(SecCertificateRef certificate) { - return _SecCertificateCopyNotValidAfterDate(certificate); - } - late final _SecCertificateCopyNotValidAfterDatePtr = - _lookup>( - 'SecCertificateCopyNotValidAfterDate', + /// Sent periodically to notify the delegate of upload progress. This + /// information is also available as properties of the task. + static final URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, int, int, int) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_h68abb) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), ); - late final _SecCertificateCopyNotValidAfterDate = - _SecCertificateCopyNotValidAfterDatePtr.asFunction< - CFDateRef Function(SecCertificateRef) - >(); - - CFDataRef SecCertificateCopySerialNumber( - SecCertificateRef certificate, - ffi.Pointer error, - ) { - return _SecCertificateCopySerialNumber(certificate, error); - } - - late final _SecCertificateCopySerialNumberPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateCopySerialNumber'); - late final _SecCertificateCopySerialNumber = - _SecCertificateCopySerialNumberPtr.asFunction< - CFDataRef Function(SecCertificateRef, ffi.Pointer) - >(); - - int SecCertificateCreateFromData( - ffi.Pointer data, - int type, - int encoding, - ffi.Pointer certificate, - ) { - return _SecCertificateCreateFromData(data, type, encoding, certificate); - } - late final _SecCertificateCreateFromDataPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - ffi.Pointer, - CSSM_CERT_TYPE, - CSSM_CERT_ENCODING, - ffi.Pointer, - ) - > - >('SecCertificateCreateFromData'); - late final _SecCertificateCreateFromData = - _SecCertificateCreateFromDataPtr.asFunction< - int Function( - ffi.Pointer, - int, - int, - ffi.Pointer, + /// Sent if a task requires a new, unopened body stream. This may be + /// necessary when authentication has failed for any request that + /// involves a body stream. + static final URLSession_task_needNewBodyStream_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, ) - >(); - - int SecCertificateAddToKeychain( - SecCertificateRef certificate, - SecKeychainRef keychain, - ) { - return _SecCertificateAddToKeychain(certificate, keychain); - } - - late final _SecCertificateAddToKeychainPtr = - _lookup< - ffi.NativeFunction - >('SecCertificateAddToKeychain'); - late final _SecCertificateAddToKeychain = - _SecCertificateAddToKeychainPtr.asFunction< - int Function(SecCertificateRef, SecKeychainRef) - >(); - - int SecCertificateGetData(SecCertificateRef certificate, CSSM_DATA_PTR data) { - return _SecCertificateGetData(certificate, data); - } - - late final _SecCertificateGetDataPtr = - _lookup< - ffi.NativeFunction - >('SecCertificateGetData'); - late final _SecCertificateGetData = - _SecCertificateGetDataPtr.asFunction< - int Function(SecCertificateRef, CSSM_DATA_PTR) - >(); - - int SecCertificateGetType( - SecCertificateRef certificate, - ffi.Pointer certificateType, - ) { - return _SecCertificateGetType(certificate, certificateType); - } - - late final _SecCertificateGetTypePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateGetType'); - late final _SecCertificateGetType = - _SecCertificateGetTypePtr.asFunction< - int Function(SecCertificateRef, ffi.Pointer) - >(); - - int SecCertificateGetSubject( - SecCertificateRef certificate, - ffi.Pointer> subject, - ) { - return _SecCertificateGetSubject(certificate, subject); - } - - late final _SecCertificateGetSubjectPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SecCertificateRef, - ffi.Pointer>, + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_needNewBodyStream_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_needNewBodyStream_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, ) - > - >('SecCertificateGetSubject'); - late final _SecCertificateGetSubject = - _SecCertificateGetSubjectPtr.asFunction< - int Function( - SecCertificateRef, - ffi.Pointer>, - ) - >(); - - int SecCertificateGetIssuer( - SecCertificateRef certificate, - ffi.Pointer> issuer, - ) { - return _SecCertificateGetIssuer(certificate, issuer); - } - - late final _SecCertificateGetIssuerPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SecCertificateRef, - ffi.Pointer>, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, ) - > - >('SecCertificateGetIssuer'); - late final _SecCertificateGetIssuer = - _SecCertificateGetIssuerPtr.asFunction< - int Function( - SecCertificateRef, - ffi.Pointer>, - ) - >(); - - int SecCertificateGetCLHandle( - SecCertificateRef certificate, - ffi.Pointer clHandle, - ) { - return _SecCertificateGetCLHandle(certificate, clHandle); - } - - late final _SecCertificateGetCLHandlePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateGetCLHandle'); - late final _SecCertificateGetCLHandle = - _SecCertificateGetCLHandlePtr.asFunction< - int Function(SecCertificateRef, ffi.Pointer) - >(); - - int SecCertificateGetAlgorithmID( - SecCertificateRef certificate, - ffi.Pointer> algid, - ) { - return _SecCertificateGetAlgorithmID(certificate, algid); - } - - late final _SecCertificateGetAlgorithmIDPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SecCertificateRef, - ffi.Pointer>, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, ) - > - >('SecCertificateGetAlgorithmID'); - late final _SecCertificateGetAlgorithmID = - _SecCertificateGetAlgorithmIDPtr.asFunction< - int Function(SecCertificateRef, ffi.Pointer>) - >(); - - int SecCertificateCopyPreference( - CFStringRef name, - int keyUsage, - ffi.Pointer certificate, - ) { - return _SecCertificateCopyPreference(name, keyUsage, certificate); - } - - late final _SecCertificateCopyPreferencePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(CFStringRef, uint32, ffi.Pointer) - > - >('SecCertificateCopyPreference'); - late final _SecCertificateCopyPreference = - _SecCertificateCopyPreferencePtr.asFunction< - int Function(CFStringRef, int, ffi.Pointer) - >(); - - SecCertificateRef SecCertificateCopyPreferred( - CFStringRef name, - CFArrayRef keyUsage, - ) { - return _SecCertificateCopyPreferred(name, keyUsage); - } - - late final _SecCertificateCopyPreferredPtr = - _lookup< - ffi.NativeFunction - >('SecCertificateCopyPreferred'); - late final _SecCertificateCopyPreferred = - _SecCertificateCopyPreferredPtr.asFunction< - SecCertificateRef Function(CFStringRef, CFArrayRef) - >(); - - int SecCertificateSetPreference( - SecCertificateRef certificate, - CFStringRef name, - int keyUsage, - CFDateRef date, - ) { - return _SecCertificateSetPreference(certificate, name, keyUsage, date); - } - - late final _SecCertificateSetPreferencePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecCertificateRef, CFStringRef, uint32, CFDateRef) - > - >('SecCertificateSetPreference'); - late final _SecCertificateSetPreference = - _SecCertificateSetPreferencePtr.asFunction< - int Function(SecCertificateRef, CFStringRef, int, CFDateRef) - >(); - - int SecCertificateSetPreferred( - SecCertificateRef certificate, - CFStringRef name, - CFArrayRef keyUsage, - ) { - return _SecCertificateSetPreferred(certificate, name, keyUsage); - } - - late final _SecCertificateSetPreferredPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecCertificateRef, CFStringRef, CFArrayRef) - > - >('SecCertificateSetPreferred'); - late final _SecCertificateSetPreferred = - _SecCertificateSetPreferredPtr.asFunction< - int Function(SecCertificateRef, CFStringRef, CFArrayRef) - >(); - - late final ffi.Pointer _kSecPropertyKeyType = - _lookup('kSecPropertyKeyType'); - - CFStringRef get kSecPropertyKeyType => _kSecPropertyKeyType.value; - - set kSecPropertyKeyType(CFStringRef value) => - _kSecPropertyKeyType.value = value; - - late final ffi.Pointer _kSecPropertyKeyLabel = - _lookup('kSecPropertyKeyLabel'); - - CFStringRef get kSecPropertyKeyLabel => _kSecPropertyKeyLabel.value; - - set kSecPropertyKeyLabel(CFStringRef value) => - _kSecPropertyKeyLabel.value = value; - - late final ffi.Pointer _kSecPropertyKeyLocalizedLabel = - _lookup('kSecPropertyKeyLocalizedLabel'); - - CFStringRef get kSecPropertyKeyLocalizedLabel => - _kSecPropertyKeyLocalizedLabel.value; - - set kSecPropertyKeyLocalizedLabel(CFStringRef value) => - _kSecPropertyKeyLocalizedLabel.value = value; - - late final ffi.Pointer _kSecPropertyKeyValue = - _lookup('kSecPropertyKeyValue'); - - CFStringRef get kSecPropertyKeyValue => _kSecPropertyKeyValue.value; - - set kSecPropertyKeyValue(CFStringRef value) => - _kSecPropertyKeyValue.value = value; - - late final ffi.Pointer _kSecPropertyTypeWarning = - _lookup('kSecPropertyTypeWarning'); - - CFStringRef get kSecPropertyTypeWarning => _kSecPropertyTypeWarning.value; - - set kSecPropertyTypeWarning(CFStringRef value) => - _kSecPropertyTypeWarning.value = value; - - late final ffi.Pointer _kSecPropertyTypeSuccess = - _lookup('kSecPropertyTypeSuccess'); - - CFStringRef get kSecPropertyTypeSuccess => _kSecPropertyTypeSuccess.value; - - set kSecPropertyTypeSuccess(CFStringRef value) => - _kSecPropertyTypeSuccess.value = value; - - late final ffi.Pointer _kSecPropertyTypeSection = - _lookup('kSecPropertyTypeSection'); - - CFStringRef get kSecPropertyTypeSection => _kSecPropertyTypeSection.value; - - set kSecPropertyTypeSection(CFStringRef value) => - _kSecPropertyTypeSection.value = value; - - late final ffi.Pointer _kSecPropertyTypeData = - _lookup('kSecPropertyTypeData'); - - CFStringRef get kSecPropertyTypeData => _kSecPropertyTypeData.value; - - set kSecPropertyTypeData(CFStringRef value) => - _kSecPropertyTypeData.value = value; - - late final ffi.Pointer _kSecPropertyTypeString = - _lookup('kSecPropertyTypeString'); - - CFStringRef get kSecPropertyTypeString => _kSecPropertyTypeString.value; - - set kSecPropertyTypeString(CFStringRef value) => - _kSecPropertyTypeString.value = value; - - late final ffi.Pointer _kSecPropertyTypeURL = - _lookup('kSecPropertyTypeURL'); - - CFStringRef get kSecPropertyTypeURL => _kSecPropertyTypeURL.value; - - set kSecPropertyTypeURL(CFStringRef value) => - _kSecPropertyTypeURL.value = value; - - late final ffi.Pointer _kSecPropertyTypeDate = - _lookup('kSecPropertyTypeDate'); - - CFStringRef get kSecPropertyTypeDate => _kSecPropertyTypeDate.value; - - set kSecPropertyTypeDate(CFStringRef value) => - _kSecPropertyTypeDate.value = value; - - late final ffi.Pointer _kSecPropertyTypeArray = - _lookup('kSecPropertyTypeArray'); - - CFStringRef get kSecPropertyTypeArray => _kSecPropertyTypeArray.value; - - set kSecPropertyTypeArray(CFStringRef value) => - _kSecPropertyTypeArray.value = value; - - late final ffi.Pointer _kSecPropertyTypeNumber = - _lookup('kSecPropertyTypeNumber'); - - CFStringRef get kSecPropertyTypeNumber => _kSecPropertyTypeNumber.value; - - set kSecPropertyTypeNumber(CFStringRef value) => - _kSecPropertyTypeNumber.value = value; - - CFDictionaryRef SecCertificateCopyValues( - SecCertificateRef certificate, - CFArrayRef keys, - ffi.Pointer error, - ) { - return _SecCertificateCopyValues(certificate, keys, error); - } + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), + ); - late final _SecCertificateCopyValuesPtr = - _lookup< - ffi.NativeFunction< - CFDictionaryRef Function( - SecCertificateRef, - CFArrayRef, - ffi.Pointer, - ) - > - >('SecCertificateCopyValues'); - late final _SecCertificateCopyValues = - _SecCertificateCopyValuesPtr.asFunction< - CFDictionaryRef Function( - SecCertificateRef, - CFArrayRef, - ffi.Pointer, + /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be + /// necessary when resuming a failed upload task. + /// + /// - Parameter session: The session containing the task that needs a new body stream from the given offset. + /// - Parameter task: The task that needs a new body stream. + /// - Parameter offset: The starting offset required for the body stream. + /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. + static final URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, ) - >(); - - CFStringRef SecCertificateCopyLongDescription( - CFAllocatorRef alloc, - SecCertificateRef certificate, - ffi.Pointer error, - ) { - return _SecCertificateCopyLongDescription(alloc, certificate, error); - } - - late final _SecCertificateCopyLongDescriptionPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - SecCertificateRef, - ffi.Pointer, + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_jyim80) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, ) - > - >('SecCertificateCopyLongDescription'); - late final _SecCertificateCopyLongDescription = - _SecCertificateCopyLongDescriptionPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - SecCertificateRef, - ffi.Pointer, - ) - >(); - - CFStringRef SecCertificateCopyShortDescription( - CFAllocatorRef alloc, - SecCertificateRef certificate, - ffi.Pointer error, - ) { - return _SecCertificateCopyShortDescription(alloc, certificate, error); - } - - late final _SecCertificateCopyShortDescriptionPtr = - _lookup< - ffi.NativeFunction< - CFStringRef Function( - CFAllocatorRef, - SecCertificateRef, - ffi.Pointer, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, ) - > - >('SecCertificateCopyShortDescription'); - late final _SecCertificateCopyShortDescription = - _SecCertificateCopyShortDescriptionPtr.asFunction< - CFStringRef Function( - CFAllocatorRef, - SecCertificateRef, - ffi.Pointer, - ) - >(); - - CFDataRef SecCertificateCopyNormalizedIssuerContent( - SecCertificateRef certificate, - ffi.Pointer error, - ) { - return _SecCertificateCopyNormalizedIssuerContent(certificate, error); - } - - late final _SecCertificateCopyNormalizedIssuerContentPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateCopyNormalizedIssuerContent'); - late final _SecCertificateCopyNormalizedIssuerContent = - _SecCertificateCopyNormalizedIssuerContentPtr.asFunction< - CFDataRef Function(SecCertificateRef, ffi.Pointer) - >(); - - CFDataRef SecCertificateCopyNormalizedSubjectContent( - SecCertificateRef certificate, - ffi.Pointer error, - ) { - return _SecCertificateCopyNormalizedSubjectContent(certificate, error); - } - - late final _SecCertificateCopyNormalizedSubjectContentPtr = - _lookup< - ffi.NativeFunction< - CFDataRef Function(SecCertificateRef, ffi.Pointer) - > - >('SecCertificateCopyNormalizedSubjectContent'); - late final _SecCertificateCopyNormalizedSubjectContent = - _SecCertificateCopyNormalizedSubjectContentPtr.asFunction< - CFDataRef Function(SecCertificateRef, ffi.Pointer) - >(); - - int SecIdentityGetTypeID() { - return _SecIdentityGetTypeID(); - } - - late final _SecIdentityGetTypeIDPtr = - _lookup>('SecIdentityGetTypeID'); - late final _SecIdentityGetTypeID = - _SecIdentityGetTypeIDPtr.asFunction(); - - SecIdentityRef SecIdentityCreate( - CFAllocatorRef allocator, - SecCertificateRef certificate, - SecKeyRef privateKey, - ) { - return _SecIdentityCreate(allocator, certificate, privateKey); - } - - late final _SecIdentityCreatePtr = - _lookup< - ffi.NativeFunction< - SecIdentityRef Function(CFAllocatorRef, SecCertificateRef, SecKeyRef) - > - >('SecIdentityCreate'); - late final _SecIdentityCreate = - _SecIdentityCreatePtr.asFunction< - SecIdentityRef Function(CFAllocatorRef, SecCertificateRef, SecKeyRef) - >(); - - int SecIdentityCreateWithCertificate( - CFTypeRef keychainOrArray, - SecCertificateRef certificateRef, - ffi.Pointer identityRef, - ) { - return _SecIdentityCreateWithCertificate( - keychainOrArray, - certificateRef, - identityRef, - ); - } - - late final _SecIdentityCreateWithCertificatePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - CFTypeRef, - SecCertificateRef, - ffi.Pointer, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, ) - > - >('SecIdentityCreateWithCertificate'); - late final _SecIdentityCreateWithCertificate = - _SecIdentityCreateWithCertificatePtr.asFunction< - int Function(CFTypeRef, SecCertificateRef, ffi.Pointer) - >(); - - int SecIdentityCopyCertificate( - SecIdentityRef identityRef, - ffi.Pointer certificateRef, - ) { - return _SecIdentityCopyCertificate(identityRef, certificateRef); - } - - late final _SecIdentityCopyCertificatePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecIdentityRef, ffi.Pointer) - > - >('SecIdentityCopyCertificate'); - late final _SecIdentityCopyCertificate = - _SecIdentityCopyCertificatePtr.asFunction< - int Function(SecIdentityRef, ffi.Pointer) - >(); - - int SecIdentityCopyPrivateKey( - SecIdentityRef identityRef, - ffi.Pointer privateKeyRef, - ) { - return _SecIdentityCopyPrivateKey(identityRef, privateKeyRef); - } - - late final _SecIdentityCopyPrivateKeyPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecIdentityRef, ffi.Pointer) - > - >('SecIdentityCopyPrivateKey'); - late final _SecIdentityCopyPrivateKey = - _SecIdentityCopyPrivateKeyPtr.asFunction< - int Function(SecIdentityRef, ffi.Pointer) - >(); - - int SecIdentityCopyPreference( - CFStringRef name, - int keyUsage, - CFArrayRef validIssuers, - ffi.Pointer identity, - ) { - return _SecIdentityCopyPreference(name, keyUsage, validIssuers, identity); - } + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ); - late final _SecIdentityCopyPreferencePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - CFStringRef, - CSSM_KEYUSE, - CFArrayRef, - ffi.Pointer, + /// Sent when the system is ready to begin work for a task with a delayed start + /// time set (using the earliestBeginDate property). The completionHandler must + /// be invoked in order for loading to proceed. The disposition provided to the + /// completion handler continues the load with the original request provided to + /// the task, replaces the request with the specified task, or cancels the task. + /// If this delegate is not implemented, loading will proceed with the original + /// request. + /// + /// Recommendation: only implement this delegate if tasks that have the + /// earliestBeginDate property set may become stale and require alteration prior + /// to starting the network load. + /// + /// If a new request is specified, the allowsExpensiveNetworkAccess, + /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties + /// from the new request will not be used; the properties from the + /// original request will continue to be used. + /// + /// Canceling the task is equivalent to calling the task's cancel method; the + /// URLSession:task:didCompleteWithError: task delegate will be called with error + /// NSURLErrorCancelled. + static final URLSession_task_willBeginDelayedRequest_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, ) - > - >('SecIdentityCopyPreference'); - late final _SecIdentityCopyPreference = - _SecIdentityCopyPreferencePtr.asFunction< - int Function(CFStringRef, int, CFArrayRef, ffi.Pointer) - >(); - - SecIdentityRef SecIdentityCopyPreferred( - CFStringRef name, - CFArrayRef keyUsage, - CFArrayRef validIssuers, - ) { - return _SecIdentityCopyPreferred(name, keyUsage, validIssuers); - } - - late final _SecIdentityCopyPreferredPtr = - _lookup< - ffi.NativeFunction< - SecIdentityRef Function(CFStringRef, CFArrayRef, CFArrayRef) - > - >('SecIdentityCopyPreferred'); - late final _SecIdentityCopyPreferred = - _SecIdentityCopyPreferredPtr.asFunction< - SecIdentityRef Function(CFStringRef, CFArrayRef, CFArrayRef) - >(); - - int SecIdentitySetPreference( - SecIdentityRef identity, - CFStringRef name, - int keyUsage, - ) { - return _SecIdentitySetPreference(identity, name, keyUsage); - } - - late final _SecIdentitySetPreferencePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecIdentityRef, CFStringRef, CSSM_KEYUSE) - > - >('SecIdentitySetPreference'); - late final _SecIdentitySetPreference = - _SecIdentitySetPreferencePtr.asFunction< - int Function(SecIdentityRef, CFStringRef, int) - >(); - - int SecIdentitySetPreferred( - SecIdentityRef identity, - CFStringRef name, - CFArrayRef keyUsage, - ) { - return _SecIdentitySetPreferred(identity, name, keyUsage); - } - - late final _SecIdentitySetPreferredPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SecIdentityRef, CFStringRef, CFArrayRef) - > - >('SecIdentitySetPreferred'); - late final _SecIdentitySetPreferred = - _SecIdentitySetPreferredPtr.asFunction< - int Function(SecIdentityRef, CFStringRef, CFArrayRef) - >(); - - int SecIdentityCopySystemIdentity( - CFStringRef domain, - ffi.Pointer idRef, - ffi.Pointer actualDomain, - ) { - return _SecIdentityCopySystemIdentity(domain, idRef, actualDomain); - } - - late final _SecIdentityCopySystemIdentityPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - CFStringRef, - ffi.Pointer, - ffi.Pointer, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, ) - > - >('SecIdentityCopySystemIdentity'); - late final _SecIdentityCopySystemIdentity = - _SecIdentityCopySystemIdentityPtr.asFunction< - int Function( - CFStringRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int SecIdentitySetSystemIdentity(CFStringRef domain, SecIdentityRef idRef) { - return _SecIdentitySetSystemIdentity(domain, idRef); - } - - late final _SecIdentitySetSystemIdentityPtr = - _lookup< - ffi.NativeFunction - >('SecIdentitySetSystemIdentity'); - late final _SecIdentitySetSystemIdentity = - _SecIdentitySetSystemIdentityPtr.asFunction< - int Function(CFStringRef, SecIdentityRef) - >(); - - late final ffi.Pointer _kSecIdentityDomainDefault = - _lookup('kSecIdentityDomainDefault'); - - CFStringRef get kSecIdentityDomainDefault => _kSecIdentityDomainDefault.value; - - set kSecIdentityDomainDefault(CFStringRef value) => - _kSecIdentityDomainDefault.value = value; - - late final ffi.Pointer _kSecIdentityDomainKerberosKDC = - _lookup('kSecIdentityDomainKerberosKDC'); - - CFStringRef get kSecIdentityDomainKerberosKDC => - _kSecIdentityDomainKerberosKDC.value; - - set kSecIdentityDomainKerberosKDC(CFStringRef value) => - _kSecIdentityDomainKerberosKDC.value = value; - - Dartsec_trust_t? sec_trust_create(SecTrustRef trust) { - return _sec_trust_create(trust).address == 0 - ? null - : objc.NSObject.fromPointer( - _sec_trust_create(trust), - retain: false, - release: true, - ); - } - - late final _sec_trust_createPtr = - _lookup>( - 'sec_trust_create', - ); - late final _sec_trust_create = _sec_trust_createPtr - .asFunction(); - - SecTrustRef sec_trust_copy_ref(Dartsec_trust_t trust) { - return _sec_trust_copy_ref(trust.ref.pointer); - } - - late final _sec_trust_copy_refPtr = - _lookup>( - 'sec_trust_copy_ref', + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), ); - late final _sec_trust_copy_ref = _sec_trust_copy_refPtr - .asFunction(); - - Dartsec_identity_t? sec_identity_create(SecIdentityRef identity) { - return _sec_identity_create(identity).address == 0 - ? null - : objc.NSObject.fromPointer( - _sec_identity_create(identity), - retain: false, - release: true, - ); - } - late final _sec_identity_createPtr = - _lookup>( - 'sec_identity_create', + /// An HTTP request is attempting to perform a redirection to a different + /// URL. You must invoke the completion routine to allow the + /// redirection, allow the redirection with a modified request, or + /// pass nil to the completionHandler to cause the body of the redirection + /// response to be delivered as the payload of this request. The default + /// is to follow redirections. + /// + /// For tasks in background sessions, redirections will always be followed and this method will not be called. + static final URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_l2g8ke) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), ); - late final _sec_identity_create = _sec_identity_createPtr - .asFunction(); - - Dartsec_identity_t? sec_identity_create_with_certificates( - SecIdentityRef identity, - CFArrayRef certificates, - ) { - return _sec_identity_create_with_certificates( - identity, - certificates, - ).address == - 0 - ? null - : objc.NSObject.fromPointer( - _sec_identity_create_with_certificates(identity, certificates), - retain: false, - release: true, - ); - } - - late final _sec_identity_create_with_certificatesPtr = - _lookup< - ffi.NativeFunction - >('sec_identity_create_with_certificates'); - late final _sec_identity_create_with_certificates = - _sec_identity_create_with_certificatesPtr - .asFunction(); - - bool sec_identity_access_certificates( - Dartsec_identity_t identity, - objc.ObjCBlock handler, - ) { - return _sec_identity_access_certificates( - identity.ref.pointer, - handler.ref.pointer, - ); - } - late final _sec_identity_access_certificatesPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function(sec_identity_t, ffi.Pointer) - > - >('sec_identity_access_certificates'); - late final _sec_identity_access_certificates = - _sec_identity_access_certificatesPtr - .asFunction< - bool Function(sec_identity_t, ffi.Pointer) - >(); - - SecIdentityRef sec_identity_copy_ref(Dartsec_identity_t identity) { - return _sec_identity_copy_ref(identity.ref.pointer); - } - - late final _sec_identity_copy_refPtr = - _lookup>( - 'sec_identity_copy_ref', + /// Sent when a task cannot start the network loading process because the current + /// network connectivity is not available or sufficient for the task's request. + /// + /// This delegate will be called at most one time per task, and is only called if + /// the waitsForConnectivity property in the NSURLSessionConfiguration has been + /// set to YES. + /// + /// This delegate callback will never be called for background sessions, because + /// the waitForConnectivity property is ignored by those sessions. + static final URLSession_taskIsWaitingForConnectivity_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask) + >( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_taskIsWaitingForConnectivity_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_taskIsWaitingForConnectivity_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), ); - late final _sec_identity_copy_ref = _sec_identity_copy_refPtr - .asFunction(); - CFArrayRef sec_identity_copy_certificates_ref(Dartsec_identity_t identity) { - return _sec_identity_copy_certificates_ref(identity.ref.pointer); - } - - late final _sec_identity_copy_certificates_refPtr = - _lookup>( - 'sec_identity_copy_certificates_ref', + /// If an application has received an + /// -application:handleEventsForBackgroundURLSession:completionHandler: + /// message, the session delegate will receive this message to indicate + /// that all messages previously enqueued for this session have been + /// delivered. At this time it is safe to invoke the previously stored + /// completion handler, or to begin any internal updates that will + /// result in invoking the completion handler. + static final URLSessionDidFinishEventsForBackgroundURLSession_ = + objc.ObjCProtocolListenableMethod( + _protocol_NSURLSessionDataDelegate, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_18v1jvf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.fromFunction( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.listener( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.blocking( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), ); - late final _sec_identity_copy_certificates_ref = - _sec_identity_copy_certificates_refPtr - .asFunction(); - - Dartsec_certificate_t? sec_certificate_create(SecCertificateRef certificate) { - return _sec_certificate_create(certificate).address == 0 - ? null - : objc.NSObject.fromPointer( - _sec_certificate_create(certificate), - retain: false, - release: true, - ); - } - - late final _sec_certificate_createPtr = - _lookup< - ffi.NativeFunction - >('sec_certificate_create'); - late final _sec_certificate_create = _sec_certificate_createPtr - .asFunction(); - - SecCertificateRef sec_certificate_copy_ref( - Dartsec_certificate_t certificate, - ) { - return _sec_certificate_copy_ref(certificate.ref.pointer); - } - - late final _sec_certificate_copy_refPtr = - _lookup< - ffi.NativeFunction - >('sec_certificate_copy_ref'); - late final _sec_certificate_copy_ref = _sec_certificate_copy_refPtr - .asFunction(); - - ffi.Pointer sec_protocol_metadata_get_negotiated_protocol( - Dartsec_protocol_metadata_t metadata, - ) { - return _sec_protocol_metadata_get_negotiated_protocol(metadata.ref.pointer); - } - - late final _sec_protocol_metadata_get_negotiated_protocolPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(sec_protocol_metadata_t) - > - >('sec_protocol_metadata_get_negotiated_protocol'); - late final _sec_protocol_metadata_get_negotiated_protocol = - _sec_protocol_metadata_get_negotiated_protocolPtr - .asFunction< - ffi.Pointer Function(sec_protocol_metadata_t) - >(); +} - ffi.Pointer sec_protocol_metadata_copy_negotiated_protocol( - Dartsec_protocol_metadata_t metadata, - ) { - return _sec_protocol_metadata_copy_negotiated_protocol( - metadata.ref.pointer, - ); - } +late final _protocol_NSURLSessionDownloadDelegate = objc.getProtocol( + "NSURLSessionDownloadDelegate", +); +late final _sel_URLSession_downloadTask_didFinishDownloadingToURL_ = objc + .registerName("URLSession:downloadTask:didFinishDownloadingToURL:"); - late final _sec_protocol_metadata_copy_negotiated_protocolPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(sec_protocol_metadata_t) - > - >('sec_protocol_metadata_copy_negotiated_protocol'); - late final _sec_protocol_metadata_copy_negotiated_protocol = - _sec_protocol_metadata_copy_negotiated_protocolPtr - .asFunction< - ffi.Pointer Function(sec_protocol_metadata_t) - >(); +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, objc.NSURL)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + >(pointer, retain: retain, release: release); - Dartdispatch_data_t? sec_protocol_metadata_copy_peer_public_key( - Dartsec_protocol_metadata_t metadata, - ) { - return _sec_protocol_metadata_copy_peer_public_key( - metadata.ref.pointer, - ).address == - 0 - ? null - : objc.NSObject.fromPointer( - _sec_protocol_metadata_copy_peer_public_key(metadata.ref.pointer), - retain: false, - release: true, - ); - } + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _sec_protocol_metadata_copy_peer_public_keyPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_metadata_copy_peer_public_key'); - late final _sec_protocol_metadata_copy_peer_public_key = - _sec_protocol_metadata_copy_peer_public_keyPtr - .asFunction(); + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: true, + release: true, + ), + objc.NSURL.fromPointer(arg3, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - tls_protocol_version_t - sec_protocol_metadata_get_negotiated_tls_protocol_version( - Dartsec_protocol_metadata_t metadata, - ) { - return tls_protocol_version_t.fromValue( - _sec_protocol_metadata_get_negotiated_tls_protocol_version( - metadata.ref.pointer, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + objc.NSURL.fromPointer(arg3, retain: false, release: true), ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + >(wrapper, retain: false, release: true); } - late final _sec_protocol_metadata_get_negotiated_tls_protocol_versionPtr = - _lookup>( - 'sec_protocol_metadata_get_negotiated_tls_protocol_version', - ); - late final _sec_protocol_metadata_get_negotiated_tls_protocol_version = - _sec_protocol_metadata_get_negotiated_tls_protocol_versionPtr - .asFunction(); - - SSLProtocol sec_protocol_metadata_get_negotiated_protocol_version( - Dartsec_protocol_metadata_t metadata, - ) { - return SSLProtocol.fromValue( - _sec_protocol_metadata_get_negotiated_protocol_version( - metadata.ref.pointer, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + objc.NSURL.fromPointer(arg3, retain: false, release: true), ), + keepIsolateAlive, ); - } - - late final _sec_protocol_metadata_get_negotiated_protocol_versionPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_metadata_get_negotiated_protocol_version'); - late final _sec_protocol_metadata_get_negotiated_protocol_version = - _sec_protocol_metadata_get_negotiated_protocol_versionPtr - .asFunction(); - - tls_ciphersuite_t sec_protocol_metadata_get_negotiated_tls_ciphersuite( - Dartsec_protocol_metadata_t metadata, - ) { - return tls_ciphersuite_t.fromValue( - _sec_protocol_metadata_get_negotiated_tls_ciphersuite( - metadata.ref.pointer, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + objc.NSURL.fromPointer(arg3, retain: false, release: true), ), + keepIsolateAlive, ); - } - - late final _sec_protocol_metadata_get_negotiated_tls_ciphersuitePtr = - _lookup>( - 'sec_protocol_metadata_get_negotiated_tls_ciphersuite', - ); - late final _sec_protocol_metadata_get_negotiated_tls_ciphersuite = - _sec_protocol_metadata_get_negotiated_tls_ciphersuitePtr - .asFunction(); - - DartSSLCipherSuite sec_protocol_metadata_get_negotiated_ciphersuite( - Dartsec_protocol_metadata_t metadata, - ) { - return _sec_protocol_metadata_get_negotiated_ciphersuite( - metadata.ref.pointer, + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + raw, + rawListener, + objc.objCContext, ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, + ) + >(wrapper, retain: false, release: true); } - late final _sec_protocol_metadata_get_negotiated_ciphersuitePtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_metadata_get_negotiated_ciphersuite'); - late final _sec_protocol_metadata_get_negotiated_ciphersuite = - _sec_protocol_metadata_get_negotiated_ciphersuitePtr - .asFunction(); - - bool sec_protocol_metadata_get_early_data_accepted( - Dartsec_protocol_metadata_t metadata, - ) { - return _sec_protocol_metadata_get_early_data_accepted(metadata.ref.pointer); - } - - late final _sec_protocol_metadata_get_early_data_acceptedPtr = - _lookup>( - 'sec_protocol_metadata_get_early_data_accepted', - ); - late final _sec_protocol_metadata_get_early_data_accepted = - _sec_protocol_metadata_get_early_data_acceptedPtr - .asFunction(); - - bool sec_protocol_metadata_access_peer_certificate_chain( - Dartsec_protocol_metadata_t metadata, - objc.ObjCBlock handler, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _sec_protocol_metadata_access_peer_certificate_chain( - metadata.ref.pointer, - handler.ref.pointer, - ); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - late final _sec_protocol_metadata_access_peer_certificate_chainPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - sec_protocol_metadata_t, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('sec_protocol_metadata_access_peer_certificate_chain'); - late final _sec_protocol_metadata_access_peer_certificate_chain = - _sec_protocol_metadata_access_peer_certificate_chainPtr - .asFunction< - bool Function( - sec_protocol_metadata_t, - ffi.Pointer, - ) - >(); - - bool sec_protocol_metadata_access_ocsp_response( - Dartsec_protocol_metadata_t metadata, - objc.ObjCBlock handler, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) { - return _sec_protocol_metadata_access_ocsp_response( - metadata.ref.pointer, - handler.ref.pointer, - ); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _sec_protocol_metadata_access_ocsp_responsePtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - sec_protocol_metadata_t, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - > - >('sec_protocol_metadata_access_ocsp_response'); - late final _sec_protocol_metadata_access_ocsp_response = - _sec_protocol_metadata_access_ocsp_responsePtr - .asFunction< - bool Function( - sec_protocol_metadata_t, - ffi.Pointer, - ) - >(); - - bool sec_protocol_metadata_access_supported_signature_algorithms( - Dartsec_protocol_metadata_t metadata, - objc.ObjCBlock handler, - ) { - return _sec_protocol_metadata_access_supported_signature_algorithms( - metadata.ref.pointer, - handler.ref.pointer, - ); - } - - late final _sec_protocol_metadata_access_supported_signature_algorithmsPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - sec_protocol_metadata_t, + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( ffi.Pointer, - ) - > - >('sec_protocol_metadata_access_supported_signature_algorithms'); - late final _sec_protocol_metadata_access_supported_signature_algorithms = - _sec_protocol_metadata_access_supported_signature_algorithmsPtr - .asFunction< - bool Function( - sec_protocol_metadata_t, - ffi.Pointer, - ) - >(); - - bool sec_protocol_metadata_access_distinguished_names( - Dartsec_protocol_metadata_t metadata, - objc.ObjCBlock handler, - ) { - return _sec_protocol_metadata_access_distinguished_names( - metadata.ref.pointer, - handler.ref.pointer, - ); - } - - late final _sec_protocol_metadata_access_distinguished_namesPtr = - _lookup< + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< ffi.NativeFunction< - ffi.Bool Function( - sec_protocol_metadata_t, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ) > - >('sec_protocol_metadata_access_distinguished_names'); - late final _sec_protocol_metadata_access_distinguished_names = - _sec_protocol_metadata_access_distinguished_namesPtr - .asFunction< - bool Function( - sec_protocol_metadata_t, + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - bool sec_protocol_metadata_access_pre_shared_keys( - Dartsec_protocol_metadata_t metadata, - objc.ObjCBlock handler, - ) { - return _sec_protocol_metadata_access_pre_shared_keys( - metadata.ref.pointer, - handler.ref.pointer, - ); - } + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - late final _sec_protocol_metadata_access_pre_shared_keysPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function( - sec_protocol_metadata_t, - ffi.Pointer, +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, objc.NSURL)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + objc.NSURL, ) - > - >('sec_protocol_metadata_access_pre_shared_keys'); - late final _sec_protocol_metadata_access_pre_shared_keys = - _sec_protocol_metadata_access_pre_shared_keysPtr + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + objc.NSURL arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() .asFunction< - bool Function( - sec_protocol_metadata_t, + void Function( ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >(); - - ffi.Pointer sec_protocol_metadata_get_server_name( - Dartsec_protocol_metadata_t metadata, - ) { - return _sec_protocol_metadata_get_server_name(metadata.ref.pointer); - } - - late final _sec_protocol_metadata_get_server_namePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(sec_protocol_metadata_t) - > - >('sec_protocol_metadata_get_server_name'); - late final _sec_protocol_metadata_get_server_name = - _sec_protocol_metadata_get_server_namePtr - .asFunction< - ffi.Pointer Function(sec_protocol_metadata_t) - >(); - - ffi.Pointer sec_protocol_metadata_copy_server_name( - Dartsec_protocol_metadata_t metadata, - ) { - return _sec_protocol_metadata_copy_server_name(metadata.ref.pointer); - } - - late final _sec_protocol_metadata_copy_server_namePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(sec_protocol_metadata_t) - > - >('sec_protocol_metadata_copy_server_name'); - late final _sec_protocol_metadata_copy_server_name = - _sec_protocol_metadata_copy_server_namePtr - .asFunction< - ffi.Pointer Function(sec_protocol_metadata_t) - >(); + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3.ref.pointer, + ); +} - bool sec_protocol_metadata_peers_are_equal( - Dartsec_protocol_metadata_t metadataA, - Dartsec_protocol_metadata_t metadataB, - ) { - return _sec_protocol_metadata_peers_are_equal( - metadataA.ref.pointer, - metadataB.ref.pointer, +late final _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_ = + objc.registerName( + "URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:", ); - } - - late final _sec_protocol_metadata_peers_are_equalPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function(sec_protocol_metadata_t, sec_protocol_metadata_t) - > - >('sec_protocol_metadata_peers_are_equal'); - late final _sec_protocol_metadata_peers_are_equal = - _sec_protocol_metadata_peers_are_equalPtr - .asFunction< - bool Function(sec_protocol_metadata_t, sec_protocol_metadata_t) - >(); - bool sec_protocol_metadata_challenge_parameters_are_equal( - Dartsec_protocol_metadata_t metadataA, - Dartsec_protocol_metadata_t metadataB, - ) { - return _sec_protocol_metadata_challenge_parameters_are_equal( - metadataA.ref.pointer, - metadataB.ref.pointer, - ); - } +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64 { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >(pointer, retain: retain, release: release); - late final _sec_protocol_metadata_challenge_parameters_are_equalPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function(sec_protocol_metadata_t, sec_protocol_metadata_t) - > - >('sec_protocol_metadata_challenge_parameters_are_equal'); - late final _sec_protocol_metadata_challenge_parameters_are_equal = - _sec_protocol_metadata_challenge_parameters_are_equalPtr - .asFunction< - bool Function(sec_protocol_metadata_t, sec_protocol_metadata_t) - >(); - - Dartdispatch_data_t? sec_protocol_metadata_create_secret( - Dartsec_protocol_metadata_t metadata, - int label_len, - ffi.Pointer label, - int exporter_length, - ) { - return _sec_protocol_metadata_create_secret( - metadata.ref.pointer, - label_len, - label, - exporter_length, - ).address == - 0 - ? null - : objc.NSObject.fromPointer( - _sec_protocol_metadata_create_secret( - metadata.ref.pointer, - label_len, - label, - exporter_length, - ), - retain: false, - release: true, - ); - } + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ffi.Int64 arg5, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - late final _sec_protocol_metadata_create_secretPtr = - _lookup< - ffi.NativeFunction< - dispatch_data_t Function( - sec_protocol_metadata_t, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - > - >('sec_protocol_metadata_create_secret'); - late final _sec_protocol_metadata_create_secret = - _sec_protocol_metadata_create_secretPtr - .asFunction< - dispatch_data_t Function( - sec_protocol_metadata_t, - int, - ffi.Pointer, - int, - ) - >(); - - Dartdispatch_data_t? sec_protocol_metadata_create_secret_with_context( - Dartsec_protocol_metadata_t metadata, - int label_len, - ffi.Pointer label, - int context_len, - ffi.Pointer context, - int exporter_length, - ) { - return _sec_protocol_metadata_create_secret_with_context( - metadata.ref.pointer, - label_len, - label, - context_len, - context, - exporter_length, - ).address == - 0 - ? null - : objc.NSObject.fromPointer( - _sec_protocol_metadata_create_secret_with_context( - metadata.ref.pointer, - label_len, - label, - context_len, - context, - exporter_length, + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + int, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: true, + release: true, ), - retain: false, - release: true, - ); - } - - late final _sec_protocol_metadata_create_secret_with_contextPtr = - _lookup< - ffi.NativeFunction< - dispatch_data_t Function( - sec_protocol_metadata_t, - ffi.Size, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - > - >('sec_protocol_metadata_create_secret_with_context'); - late final _sec_protocol_metadata_create_secret_with_context = - _sec_protocol_metadata_create_secret_with_contextPtr - .asFunction< - dispatch_data_t Function( - sec_protocol_metadata_t, - int, - ffi.Pointer, - int, - ffi.Pointer, - int, - ) - >(); + arg3, + arg4, + arg5, + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); - bool sec_protocol_options_are_equal( - Dartsec_protocol_options_t optionsA, - Dartsec_protocol_options_t optionsB, - ) { - return _sec_protocol_options_are_equal( - optionsA.ref.pointer, - optionsB.ref.pointer, + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + int, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4, + arg5, + ), + keepIsolateAlive, ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_h68abb(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >(wrapper, retain: false, release: true); } - late final _sec_protocol_options_are_equalPtr = - _lookup< - ffi.NativeFunction< - ffi.Bool Function(sec_protocol_options_t, sec_protocol_options_t) - > - >('sec_protocol_options_are_equal'); - late final _sec_protocol_options_are_equal = - _sec_protocol_options_are_equalPtr - .asFunction< - bool Function(sec_protocol_options_t, sec_protocol_options_t) - >(); - - void sec_protocol_options_set_local_identity( - Dartsec_protocol_options_t options, - Dartsec_identity_t identity, - ) { - return _sec_protocol_options_set_local_identity( - options.ref.pointer, - identity.ref.pointer, + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + int, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4, + arg5, + ), + keepIsolateAlive, ); - } - - late final _sec_protocol_options_set_local_identityPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, sec_identity_t) - > - >('sec_protocol_options_set_local_identity'); - late final _sec_protocol_options_set_local_identity = - _sec_protocol_options_set_local_identityPtr - .asFunction(); - - void sec_protocol_options_append_tls_ciphersuite( - Dartsec_protocol_options_t options, - tls_ciphersuite_t ciphersuite, - ) { - return _sec_protocol_options_append_tls_ciphersuite( - options.ref.pointer, - ciphersuite.value, + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4, + arg5, + ), + keepIsolateAlive, ); - } - - late final _sec_protocol_options_append_tls_ciphersuitePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.Uint16) - > - >('sec_protocol_options_append_tls_ciphersuite'); - late final _sec_protocol_options_append_tls_ciphersuite = - _sec_protocol_options_append_tls_ciphersuitePtr - .asFunction(); - - void sec_protocol_options_add_tls_ciphersuite( - Dartsec_protocol_options_t options, - DartSSLCipherSuite ciphersuite, - ) { - return _sec_protocol_options_add_tls_ciphersuite( - options.ref.pointer, - ciphersuite, + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_h68abb( + raw, + rawListener, + objc.objCContext, ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >(wrapper, retain: false, release: true); } - late final _sec_protocol_options_add_tls_ciphersuitePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, SSLCipherSuite) - > - >('sec_protocol_options_add_tls_ciphersuite'); - late final _sec_protocol_options_add_tls_ciphersuite = - _sec_protocol_options_add_tls_ciphersuitePtr - .asFunction(); - - void sec_protocol_options_append_tls_ciphersuite_group( - Dartsec_protocol_options_t options, - tls_ciphersuite_group_t group, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, ) { - return _sec_protocol_options_append_tls_ciphersuite_group( - options.ref.pointer, - group.value, - ); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + objc.objectRelease(block.cast()); } - late final _sec_protocol_options_append_tls_ciphersuite_groupPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.Uint16) - > - >('sec_protocol_options_append_tls_ciphersuite_group'); - late final _sec_protocol_options_append_tls_ciphersuite_group = - _sec_protocol_options_append_tls_ciphersuite_groupPtr - .asFunction(); - - void sec_protocol_options_add_tls_ciphersuite_group( - Dartsec_protocol_options_t options, - SSLCiphersuiteGroup group, - ) { - return _sec_protocol_options_add_tls_ciphersuite_group( - options.ref.pointer, - group.value, - ); - } - - late final _sec_protocol_options_add_tls_ciphersuite_groupPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.UnsignedInt) - > - >('sec_protocol_options_add_tls_ciphersuite_group'); - late final _sec_protocol_options_add_tls_ciphersuite_group = - _sec_protocol_options_add_tls_ciphersuite_groupPtr - .asFunction(); - - void sec_protocol_options_set_tls_min_version( - Dartsec_protocol_options_t options, - SSLProtocol version, - ) { - return _sec_protocol_options_set_tls_min_version( - options.ref.pointer, - version.value, - ); - } - - late final _sec_protocol_options_set_tls_min_versionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.UnsignedInt) - > - >('sec_protocol_options_set_tls_min_version'); - late final _sec_protocol_options_set_tls_min_version = - _sec_protocol_options_set_tls_min_versionPtr - .asFunction(); - - void sec_protocol_options_set_min_tls_protocol_version( - Dartsec_protocol_options_t options, - tls_protocol_version_t version, - ) { - return _sec_protocol_options_set_min_tls_protocol_version( - options.ref.pointer, - version.value, - ); - } - - late final _sec_protocol_options_set_min_tls_protocol_versionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.Uint16) - > - >('sec_protocol_options_set_min_tls_protocol_version'); - late final _sec_protocol_options_set_min_tls_protocol_version = - _sec_protocol_options_set_min_tls_protocol_versionPtr - .asFunction(); - - tls_protocol_version_t - sec_protocol_options_get_default_min_tls_protocol_version() { - return tls_protocol_version_t.fromValue( - _sec_protocol_options_get_default_min_tls_protocol_version(), - ); - } - - late final _sec_protocol_options_get_default_min_tls_protocol_versionPtr = - _lookup>( - 'sec_protocol_options_get_default_min_tls_protocol_version', - ); - late final _sec_protocol_options_get_default_min_tls_protocol_version = - _sec_protocol_options_get_default_min_tls_protocol_versionPtr - .asFunction(); - - tls_protocol_version_t - sec_protocol_options_get_default_min_dtls_protocol_version() { - return tls_protocol_version_t.fromValue( - _sec_protocol_options_get_default_min_dtls_protocol_version(), - ); - } - - late final _sec_protocol_options_get_default_min_dtls_protocol_versionPtr = - _lookup>( - 'sec_protocol_options_get_default_min_dtls_protocol_version', - ); - late final _sec_protocol_options_get_default_min_dtls_protocol_version = - _sec_protocol_options_get_default_min_dtls_protocol_versionPtr - .asFunction(); - - void sec_protocol_options_set_tls_max_version( - Dartsec_protocol_options_t options, - SSLProtocol version, - ) { - return _sec_protocol_options_set_tls_max_version( - options.ref.pointer, - version.value, - ); - } - - late final _sec_protocol_options_set_tls_max_versionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.UnsignedInt) - > - >('sec_protocol_options_set_tls_max_version'); - late final _sec_protocol_options_set_tls_max_version = - _sec_protocol_options_set_tls_max_versionPtr - .asFunction(); - - void sec_protocol_options_set_max_tls_protocol_version( - Dartsec_protocol_options_t options, - tls_protocol_version_t version, - ) { - return _sec_protocol_options_set_max_tls_protocol_version( - options.ref.pointer, - version.value, - ); - } - - late final _sec_protocol_options_set_max_tls_protocol_versionPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.Uint16) - > - >('sec_protocol_options_set_max_tls_protocol_version'); - late final _sec_protocol_options_set_max_tls_protocol_version = - _sec_protocol_options_set_max_tls_protocol_versionPtr - .asFunction(); - - tls_protocol_version_t - sec_protocol_options_get_default_max_tls_protocol_version() { - return tls_protocol_version_t.fromValue( - _sec_protocol_options_get_default_max_tls_protocol_version(), - ); - } - - late final _sec_protocol_options_get_default_max_tls_protocol_versionPtr = - _lookup>( - 'sec_protocol_options_get_default_max_tls_protocol_version', - ); - late final _sec_protocol_options_get_default_max_tls_protocol_version = - _sec_protocol_options_get_default_max_tls_protocol_versionPtr - .asFunction(); - - tls_protocol_version_t - sec_protocol_options_get_default_max_dtls_protocol_version() { - return tls_protocol_version_t.fromValue( - _sec_protocol_options_get_default_max_dtls_protocol_version(), - ); - } - - late final _sec_protocol_options_get_default_max_dtls_protocol_versionPtr = - _lookup>( - 'sec_protocol_options_get_default_max_dtls_protocol_version', - ); - late final _sec_protocol_options_get_default_max_dtls_protocol_version = - _sec_protocol_options_get_default_max_dtls_protocol_versionPtr - .asFunction(); - - bool sec_protocol_options_get_enable_encrypted_client_hello( - Dartsec_protocol_options_t options, - ) { - return _sec_protocol_options_get_enable_encrypted_client_hello( - options.ref.pointer, - ); - } - - late final _sec_protocol_options_get_enable_encrypted_client_helloPtr = - _lookup>( - 'sec_protocol_options_get_enable_encrypted_client_hello', - ); - late final _sec_protocol_options_get_enable_encrypted_client_hello = - _sec_protocol_options_get_enable_encrypted_client_helloPtr - .asFunction(); - - bool sec_protocol_options_get_quic_use_legacy_codepoint( - Dartsec_protocol_options_t options, - ) { - return _sec_protocol_options_get_quic_use_legacy_codepoint( - options.ref.pointer, - ); - } - - late final _sec_protocol_options_get_quic_use_legacy_codepointPtr = - _lookup>( - 'sec_protocol_options_get_quic_use_legacy_codepoint', - ); - late final _sec_protocol_options_get_quic_use_legacy_codepoint = - _sec_protocol_options_get_quic_use_legacy_codepointPtr - .asFunction(); - - void sec_protocol_options_add_tls_application_protocol( - Dartsec_protocol_options_t options, - ffi.Pointer application_protocol, - ) { - return _sec_protocol_options_add_tls_application_protocol( - options.ref.pointer, - application_protocol, - ); - } - - late final _sec_protocol_options_add_tls_application_protocolPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.Pointer) - > - >('sec_protocol_options_add_tls_application_protocol'); - late final _sec_protocol_options_add_tls_application_protocol = - _sec_protocol_options_add_tls_application_protocolPtr - .asFunction< - void Function(sec_protocol_options_t, ffi.Pointer) - >(); - - void sec_protocol_options_set_tls_server_name( - Dartsec_protocol_options_t options, - ffi.Pointer server_name, - ) { - return _sec_protocol_options_set_tls_server_name( - options.ref.pointer, - server_name, - ); - } - - late final _sec_protocol_options_set_tls_server_namePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, ffi.Pointer) - > - >('sec_protocol_options_set_tls_server_name'); - late final _sec_protocol_options_set_tls_server_name = - _sec_protocol_options_set_tls_server_namePtr - .asFunction< - void Function(sec_protocol_options_t, ffi.Pointer) - >(); - - void sec_protocol_options_set_tls_diffie_hellman_parameters( - Dartsec_protocol_options_t options, - Dartdispatch_data_t params, - ) { - return _sec_protocol_options_set_tls_diffie_hellman_parameters( - options.ref.pointer, - params.ref.pointer, - ); - } - - late final _sec_protocol_options_set_tls_diffie_hellman_parametersPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, dispatch_data_t) - > - >('sec_protocol_options_set_tls_diffie_hellman_parameters'); - late final _sec_protocol_options_set_tls_diffie_hellman_parameters = - _sec_protocol_options_set_tls_diffie_hellman_parametersPtr - .asFunction(); - - void sec_protocol_options_add_pre_shared_key( - Dartsec_protocol_options_t options, - Dartdispatch_data_t psk, - Dartdispatch_data_t psk_identity, - ) { - return _sec_protocol_options_add_pre_shared_key( - options.ref.pointer, - psk.ref.pointer, - psk_identity.ref.pointer, - ); - } - - late final _sec_protocol_options_add_pre_shared_keyPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + _listenerCallable = + ffi.NativeCallable< ffi.Void Function( - sec_protocol_options_t, - dispatch_data_t, - dispatch_data_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - > - >('sec_protocol_options_add_pre_shared_key'); - late final _sec_protocol_options_add_pre_shared_key = - _sec_protocol_options_add_pre_shared_keyPtr - .asFunction< - void Function( - sec_protocol_options_t, - dispatch_data_t, - dispatch_data_t, - ) - >(); - - void sec_protocol_options_set_tls_pre_shared_key_identity_hint( - Dartsec_protocol_options_t options, - Dartdispatch_data_t psk_identity_hint, - ) { - return _sec_protocol_options_set_tls_pre_shared_key_identity_hint( - options.ref.pointer, - psk_identity_hint.ref.pointer, - ); - } - - late final _sec_protocol_options_set_tls_pre_shared_key_identity_hintPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(sec_protocol_options_t, dispatch_data_t) - > - >('sec_protocol_options_set_tls_pre_shared_key_identity_hint'); - late final _sec_protocol_options_set_tls_pre_shared_key_identity_hint = - _sec_protocol_options_set_tls_pre_shared_key_identity_hintPtr - .asFunction(); - - void sec_protocol_options_set_pre_shared_key_selection_block( - Dartsec_protocol_options_t options, - Dartsec_protocol_pre_shared_key_selection_t psk_selection_block, - Dartdispatch_queue_t psk_selection_queue, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, ) { - return _sec_protocol_options_set_pre_shared_key_selection_block( - options.ref.pointer, - psk_selection_block.ref.pointer, - psk_selection_queue.ref.pointer, - ); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _sec_protocol_options_set_pre_shared_key_selection_blockPtr = - _lookup< - ffi.NativeFunction< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + _blockingCallable = + ffi.NativeCallable< ffi.Void Function( - sec_protocol_options_t, - sec_protocol_pre_shared_key_selection_t, - dispatch_queue_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - > - >('sec_protocol_options_set_pre_shared_key_selection_block'); - late final _sec_protocol_options_set_pre_shared_key_selection_block = - _sec_protocol_options_set_pre_shared_key_selection_blockPtr - .asFunction< - void Function( - sec_protocol_options_t, - sec_protocol_pre_shared_key_selection_t, - dispatch_queue_t, - ) - >(); - - void sec_protocol_options_set_tls_tickets_enabled( - Dartsec_protocol_options_t options, - bool tickets_enabled, - ) { - return _sec_protocol_options_set_tls_tickets_enabled( - options.ref.pointer, - tickets_enabled, - ); - } - - late final _sec_protocol_options_set_tls_tickets_enabledPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_tls_tickets_enabled'); - late final _sec_protocol_options_set_tls_tickets_enabled = - _sec_protocol_options_set_tls_tickets_enabledPtr - .asFunction(); - - void sec_protocol_options_set_tls_is_fallback_attempt( - Dartsec_protocol_options_t options, - bool is_fallback_attempt, - ) { - return _sec_protocol_options_set_tls_is_fallback_attempt( - options.ref.pointer, - is_fallback_attempt, - ); - } - - late final _sec_protocol_options_set_tls_is_fallback_attemptPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_tls_is_fallback_attempt'); - late final _sec_protocol_options_set_tls_is_fallback_attempt = - _sec_protocol_options_set_tls_is_fallback_attemptPtr - .asFunction(); - - void sec_protocol_options_set_tls_resumption_enabled( - Dartsec_protocol_options_t options, - bool resumption_enabled, - ) { - return _sec_protocol_options_set_tls_resumption_enabled( - options.ref.pointer, - resumption_enabled, - ); - } - - late final _sec_protocol_options_set_tls_resumption_enabledPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_tls_resumption_enabled'); - late final _sec_protocol_options_set_tls_resumption_enabled = - _sec_protocol_options_set_tls_resumption_enabledPtr - .asFunction(); - - void sec_protocol_options_set_tls_false_start_enabled( - Dartsec_protocol_options_t options, - bool false_start_enabled, - ) { - return _sec_protocol_options_set_tls_false_start_enabled( - options.ref.pointer, - false_start_enabled, - ); - } - - late final _sec_protocol_options_set_tls_false_start_enabledPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_tls_false_start_enabled'); - late final _sec_protocol_options_set_tls_false_start_enabled = - _sec_protocol_options_set_tls_false_start_enabledPtr - .asFunction(); - - void sec_protocol_options_set_tls_ocsp_enabled( - Dartsec_protocol_options_t options, - bool ocsp_enabled, - ) { - return _sec_protocol_options_set_tls_ocsp_enabled( - options.ref.pointer, - ocsp_enabled, - ); - } - - late final _sec_protocol_options_set_tls_ocsp_enabledPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_tls_ocsp_enabled'); - late final _sec_protocol_options_set_tls_ocsp_enabled = - _sec_protocol_options_set_tls_ocsp_enabledPtr - .asFunction(); - - void sec_protocol_options_set_tls_sct_enabled( - Dartsec_protocol_options_t options, - bool sct_enabled, - ) { - return _sec_protocol_options_set_tls_sct_enabled( - options.ref.pointer, - sct_enabled, - ); - } - - late final _sec_protocol_options_set_tls_sct_enabledPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_tls_sct_enabled'); - late final _sec_protocol_options_set_tls_sct_enabled = - _sec_protocol_options_set_tls_sct_enabledPtr - .asFunction(); - - void sec_protocol_options_set_tls_renegotiation_enabled( - Dartsec_protocol_options_t options, - bool renegotiation_enabled, - ) { - return _sec_protocol_options_set_tls_renegotiation_enabled( - options.ref.pointer, - renegotiation_enabled, - ); - } - - late final _sec_protocol_options_set_tls_renegotiation_enabledPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_tls_renegotiation_enabled'); - late final _sec_protocol_options_set_tls_renegotiation_enabled = - _sec_protocol_options_set_tls_renegotiation_enabledPtr - .asFunction(); - - void sec_protocol_options_set_peer_authentication_required( - Dartsec_protocol_options_t options, - bool peer_authentication_required, - ) { - return _sec_protocol_options_set_peer_authentication_required( - options.ref.pointer, - peer_authentication_required, - ); - } - - late final _sec_protocol_options_set_peer_authentication_requiredPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_peer_authentication_required'); - late final _sec_protocol_options_set_peer_authentication_required = - _sec_protocol_options_set_peer_authentication_requiredPtr - .asFunction(); - - void sec_protocol_options_set_peer_authentication_optional( - Dartsec_protocol_options_t options, - bool peer_authentication_optional, - ) { - return _sec_protocol_options_set_peer_authentication_optional( - options.ref.pointer, - peer_authentication_optional, - ); - } - - late final _sec_protocol_options_set_peer_authentication_optionalPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_peer_authentication_optional'); - late final _sec_protocol_options_set_peer_authentication_optional = - _sec_protocol_options_set_peer_authentication_optionalPtr - .asFunction(); - - void sec_protocol_options_set_enable_encrypted_client_hello( - Dartsec_protocol_options_t options, - bool enable_encrypted_client_hello, - ) { - return _sec_protocol_options_set_enable_encrypted_client_hello( - options.ref.pointer, - enable_encrypted_client_hello, - ); - } - - late final _sec_protocol_options_set_enable_encrypted_client_helloPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_enable_encrypted_client_hello'); - late final _sec_protocol_options_set_enable_encrypted_client_hello = - _sec_protocol_options_set_enable_encrypted_client_helloPtr - .asFunction(); - - void sec_protocol_options_set_quic_use_legacy_codepoint( - Dartsec_protocol_options_t options, - bool quic_use_legacy_codepoint, - ) { - return _sec_protocol_options_set_quic_use_legacy_codepoint( - options.ref.pointer, - quic_use_legacy_codepoint, - ); - } - - late final _sec_protocol_options_set_quic_use_legacy_codepointPtr = - _lookup< - ffi.NativeFunction - >('sec_protocol_options_set_quic_use_legacy_codepoint'); - late final _sec_protocol_options_set_quic_use_legacy_codepoint = - _sec_protocol_options_set_quic_use_legacy_codepointPtr - .asFunction(); - - void sec_protocol_options_set_key_update_block( - Dartsec_protocol_options_t options, - Dartsec_protocol_key_update_t key_update_block, - Dartdispatch_queue_t key_update_queue, - ) { - return _sec_protocol_options_set_key_update_block( - options.ref.pointer, - key_update_block.ref.pointer, - key_update_queue.ref.pointer, - ); - } - - late final _sec_protocol_options_set_key_update_blockPtr = - _lookup< - ffi.NativeFunction< + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< ffi.Void Function( - sec_protocol_options_t, - sec_protocol_key_update_t, - dispatch_queue_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - > - >('sec_protocol_options_set_key_update_block'); - late final _sec_protocol_options_set_key_update_block = - _sec_protocol_options_set_key_update_blockPtr - .asFunction< - void Function( - sec_protocol_options_t, - sec_protocol_key_update_t, - dispatch_queue_t, - ) - >(); - - void sec_protocol_options_set_challenge_block( - Dartsec_protocol_options_t options, - Dartsec_protocol_challenge_t challenge_block, - Dartdispatch_queue_t challenge_queue, - ) { - return _sec_protocol_options_set_challenge_block( - options.ref.pointer, - challenge_block.ref.pointer, - challenge_queue.ref.pointer, - ); - } - - late final _sec_protocol_options_set_challenge_blockPtr = - _lookup< + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => block.ref.target + .cast< ffi.NativeFunction< ffi.Void Function( - sec_protocol_options_t, - sec_protocol_challenge_t, - dispatch_queue_t, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ffi.Int64 arg5, ) > - >('sec_protocol_options_set_challenge_block'); - late final _sec_protocol_options_set_challenge_block = - _sec_protocol_options_set_challenge_blockPtr - .asFunction< - void Function( - sec_protocol_options_t, - sec_protocol_challenge_t, - dispatch_queue_t, + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ) + >()(arg0, arg1, arg2, arg3, arg4, arg5); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - >(); - - void sec_protocol_options_set_verify_block( - Dartsec_protocol_options_t options, - Dartsec_protocol_verify_t verify_block, - Dartdispatch_queue_t verify_block_queue, - ) { - return _sec_protocol_options_set_verify_block( - options.ref.pointer, - verify_block.ref.pointer, - verify_block_queue.ref.pointer, - ); - } + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4, arg5); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >(_closureTrampoline) + .cast(); +} - late final _sec_protocol_options_set_verify_blockPtr = - _lookup< - ffi.NativeFunction< +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64$CallExtension + on + objc.ObjCBlock< ffi.Void Function( - sec_protocol_options_t, - sec_protocol_verify_t, - dispatch_queue_t, + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - > - >('sec_protocol_options_set_verify_block'); - late final _sec_protocol_options_set_verify_block = - _sec_protocol_options_set_verify_blockPtr + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + int arg5, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ffi.Int64 arg5, + ) + > + >() .asFunction< void Function( - sec_protocol_options_t, - sec_protocol_verify_t, - dispatch_queue_t, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, ) - >(); - - late final ffi.Pointer _kSSLSessionConfig_default = - _lookup('kSSLSessionConfig_default'); - - CFStringRef get kSSLSessionConfig_default => _kSSLSessionConfig_default.value; - - set kSSLSessionConfig_default(CFStringRef value) => - _kSSLSessionConfig_default.value = value; - - late final ffi.Pointer _kSSLSessionConfig_ATSv1 = - _lookup('kSSLSessionConfig_ATSv1'); - - CFStringRef get kSSLSessionConfig_ATSv1 => _kSSLSessionConfig_ATSv1.value; - - set kSSLSessionConfig_ATSv1(CFStringRef value) => - _kSSLSessionConfig_ATSv1.value = value; - - late final ffi.Pointer _kSSLSessionConfig_ATSv1_noPFS = - _lookup('kSSLSessionConfig_ATSv1_noPFS'); - - CFStringRef get kSSLSessionConfig_ATSv1_noPFS => - _kSSLSessionConfig_ATSv1_noPFS.value; - - set kSSLSessionConfig_ATSv1_noPFS(CFStringRef value) => - _kSSLSessionConfig_ATSv1_noPFS.value = value; - - late final ffi.Pointer _kSSLSessionConfig_standard = - _lookup('kSSLSessionConfig_standard'); - - CFStringRef get kSSLSessionConfig_standard => - _kSSLSessionConfig_standard.value; - - set kSSLSessionConfig_standard(CFStringRef value) => - _kSSLSessionConfig_standard.value = value; - - late final ffi.Pointer _kSSLSessionConfig_RC4_fallback = - _lookup('kSSLSessionConfig_RC4_fallback'); - - CFStringRef get kSSLSessionConfig_RC4_fallback => - _kSSLSessionConfig_RC4_fallback.value; - - set kSSLSessionConfig_RC4_fallback(CFStringRef value) => - _kSSLSessionConfig_RC4_fallback.value = value; - - late final ffi.Pointer _kSSLSessionConfig_TLSv1_fallback = - _lookup('kSSLSessionConfig_TLSv1_fallback'); + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3, + arg4, + arg5, + ); +} - CFStringRef get kSSLSessionConfig_TLSv1_fallback => - _kSSLSessionConfig_TLSv1_fallback.value; +late final _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_ = + objc.registerName( + "URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:", + ); +final _objc_msgSend_fm5719 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + ) + >(); - set kSSLSessionConfig_TLSv1_fallback(CFStringRef value) => - _kSSLSessionConfig_TLSv1_fallback.value = value; +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64 { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + >(pointer, retain: retain, release: release); - late final ffi.Pointer _kSSLSessionConfig_TLSv1_RC4_fallback = - _lookup('kSSLSessionConfig_TLSv1_RC4_fallback'); + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); - CFStringRef get kSSLSessionConfig_TLSv1_RC4_fallback => - _kSSLSessionConfig_TLSv1_RC4_fallback.value; - - set kSSLSessionConfig_TLSv1_RC4_fallback(CFStringRef value) => - _kSSLSessionConfig_TLSv1_RC4_fallback.value = value; - - late final ffi.Pointer _kSSLSessionConfig_legacy = - _lookup('kSSLSessionConfig_legacy'); - - CFStringRef get kSSLSessionConfig_legacy => _kSSLSessionConfig_legacy.value; - - set kSSLSessionConfig_legacy(CFStringRef value) => - _kSSLSessionConfig_legacy.value = value; - - late final ffi.Pointer _kSSLSessionConfig_legacy_DHE = - _lookup('kSSLSessionConfig_legacy_DHE'); - - CFStringRef get kSSLSessionConfig_legacy_DHE => - _kSSLSessionConfig_legacy_DHE.value; - - set kSSLSessionConfig_legacy_DHE(CFStringRef value) => - _kSSLSessionConfig_legacy_DHE.value = value; - - late final ffi.Pointer _kSSLSessionConfig_anonymous = - _lookup('kSSLSessionConfig_anonymous'); - - CFStringRef get kSSLSessionConfig_anonymous => - _kSSLSessionConfig_anonymous.value; - - set kSSLSessionConfig_anonymous(CFStringRef value) => - _kSSLSessionConfig_anonymous.value = value; - - late final ffi.Pointer _kSSLSessionConfig_3DES_fallback = - _lookup('kSSLSessionConfig_3DES_fallback'); - - CFStringRef get kSSLSessionConfig_3DES_fallback => - _kSSLSessionConfig_3DES_fallback.value; - - set kSSLSessionConfig_3DES_fallback(CFStringRef value) => - _kSSLSessionConfig_3DES_fallback.value = value; - - late final ffi.Pointer _kSSLSessionConfig_TLSv1_3DES_fallback = - _lookup('kSSLSessionConfig_TLSv1_3DES_fallback'); - - CFStringRef get kSSLSessionConfig_TLSv1_3DES_fallback => - _kSSLSessionConfig_TLSv1_3DES_fallback.value; - - set kSSLSessionConfig_TLSv1_3DES_fallback(CFStringRef value) => - _kSSLSessionConfig_TLSv1_3DES_fallback.value = value; - - int SSLContextGetTypeID() { - return _SSLContextGetTypeID(); - } - - late final _SSLContextGetTypeIDPtr = - _lookup>('SSLContextGetTypeID'); - late final _SSLContextGetTypeID = - _SSLContextGetTypeIDPtr.asFunction(); - - SSLContextRef SSLCreateContext( - CFAllocatorRef alloc, - SSLProtocolSide protocolSide, - SSLConnectionType connectionType, - ) { - return _SSLCreateContext(alloc, protocolSide.value, connectionType.value); - } - - late final _SSLCreateContextPtr = - _lookup< - ffi.NativeFunction< - SSLContextRef Function( - CFAllocatorRef, - ffi.UnsignedInt, - ffi.UnsignedInt, - ) - > - >('SSLCreateContext'); - late final _SSLCreateContext = - _SSLCreateContextPtr.asFunction< - SSLContextRef Function(CFAllocatorRef, int, int) - >(); - - int SSLNewContext(int isServer, ffi.Pointer contextPtr) { - return _SSLNewContext(isServer, contextPtr); - } - - late final _SSLNewContextPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(Boolean, ffi.Pointer) - > - >('SSLNewContext'); - late final _SSLNewContext = - _SSLNewContextPtr.asFunction< - int Function(int, ffi.Pointer) - >(); - - int SSLDisposeContext(SSLContextRef context) { - return _SSLDisposeContext(context); - } - - late final _SSLDisposeContextPtr = - _lookup>( - 'SSLDisposeContext', + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: true, + release: true, + ), + arg3, + arg4, + ), + keepIsolateAlive, + ), + retain: false, + release: true, ); - late final _SSLDisposeContext = - _SSLDisposeContextPtr.asFunction(); - int SSLGetSessionState( - SSLContextRef context, - ffi.Pointer state, - ) { - return _SSLGetSessionState(context, state); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4, + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_ly2579(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + >(wrapper, retain: false, release: true); } - late final _SSLGetSessionStatePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetSessionState'); - late final _SSLGetSessionState = - _SSLGetSessionStatePtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - DartSInt32 SSLSetSessionOption( - SSLContextRef context, - SSLSessionOption option, - DartBoolean value, - ) { - return _SSLSetSessionOption(context, option.value, value); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4, + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4, + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_ly2579( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + >(wrapper, retain: false, release: true); } - late final _SSLSetSessionOptionPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.UnsignedInt, Boolean) - > - >('SSLSetSessionOption'); - late final _SSLSetSessionOption = - _SSLSetSessionOptionPtr.asFunction< - int Function(SSLContextRef, int, int) - >(); - - DartSInt32 SSLGetSessionOption( - SSLContextRef context, - SSLSessionOption option, - ffi.Pointer value, + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, ) { - return _SSLGetSessionOption(context, option.value, value); + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4); + objc.objectRelease(block.cast()); } - late final _SSLGetSessionOptionPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.UnsignedInt, - ffi.Pointer, + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, ) - > - >('SSLGetSessionOption'); - late final _SSLGetSessionOption = - _SSLGetSessionOptionPtr.asFunction< - int Function(SSLContextRef, int, ffi.Pointer) - >(); - - int SSLSetIOFuncs( - SSLContextRef context, - SSLReadFunc readFunc, - SSLWriteFunc writeFunc, + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, ) { - return _SSLSetIOFuncs(context, readFunc, writeFunc); + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - late final _SSLSetIOFuncsPtr = - _lookup< + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + ) => block.ref.target + .cast< ffi.NativeFunction< - OSStatus Function(SSLContextRef, SSLReadFunc, SSLWriteFunc) + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ) > - >('SSLSetIOFuncs'); - late final _SSLSetIOFuncs = - _SSLSetIOFuncsPtr.asFunction< - int Function(SSLContextRef, SSLReadFunc, SSLWriteFunc) - >(); - - int SSLSetSessionConfig(SSLContextRef context, CFStringRef config) { - return _SSLSetSessionConfig(context, config); - } - - late final _SSLSetSessionConfigPtr = - _lookup< - ffi.NativeFunction - >('SSLSetSessionConfig'); - late final _SSLSetSessionConfig = - _SSLSetSessionConfigPtr.asFunction< - int Function(SSLContextRef, CFStringRef) - >(); - - DartSInt32 SSLSetProtocolVersionMin( - SSLContextRef context, - SSLProtocol minVersion, - ) { - return _SSLSetProtocolVersionMin(context, minVersion.value); - } - - late final _SSLSetProtocolVersionMinPtr = - _lookup< - ffi.NativeFunction - >('SSLSetProtocolVersionMin'); - late final _SSLSetProtocolVersionMin = - _SSLSetProtocolVersionMinPtr.asFunction< - int Function(SSLContextRef, int) - >(); - - int SSLGetProtocolVersionMin( - SSLContextRef context, - ffi.Pointer minVersion, - ) { - return _SSLGetProtocolVersionMin(context, minVersion); - } + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + ) + >()(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + >(_closureTrampoline) + .cast(); +} - late final _SSLGetProtocolVersionMinPtr = - _lookup< +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + ) => ref.pointer.ref.invoke + .cast< ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Int64 arg3, + ffi.Int64 arg4, + ) > - >('SSLGetProtocolVersionMin'); - late final _SSLGetProtocolVersionMin = - _SSLGetProtocolVersionMinPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - DartSInt32 SSLSetProtocolVersionMax( - SSLContextRef context, - SSLProtocol maxVersion, - ) { - return _SSLSetProtocolVersionMax(context, maxVersion.value); - } - - late final _SSLSetProtocolVersionMaxPtr = - _lookup< - ffi.NativeFunction - >('SSLSetProtocolVersionMax'); - late final _SSLSetProtocolVersionMax = - _SSLSetProtocolVersionMaxPtr.asFunction< - int Function(SSLContextRef, int) - >(); - - int SSLGetProtocolVersionMax( - SSLContextRef context, - ffi.Pointer maxVersion, - ) { - return _SSLGetProtocolVersionMax(context, maxVersion); - } + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + ) + >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer, arg3, arg4); +} - late final _SSLGetProtocolVersionMaxPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetProtocolVersionMax'); - late final _SSLGetProtocolVersionMax = - _SSLGetProtocolVersionMaxPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - DartSInt32 SSLSetProtocolVersionEnabled( - SSLContextRef context, - SSLProtocol protocol, - DartBoolean enable, - ) { - return _SSLSetProtocolVersionEnabled(context, protocol.value, enable); - } +/// Messages related to the operation of a task that writes data to a +/// file and notifies the delegate upon completion. +extension type NSURLSessionDownloadDelegate._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol, NSURLSessionTaskDelegate { + /// Constructs a [NSURLSessionDownloadDelegate] that points to the same underlying object as [other]. + NSURLSessionDownloadDelegate.as(objc.ObjCObject other) : object$ = other; - late final _SSLSetProtocolVersionEnabledPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.UnsignedInt, Boolean) - > - >('SSLSetProtocolVersionEnabled'); - late final _SSLSetProtocolVersionEnabled = - _SSLSetProtocolVersionEnabledPtr.asFunction< - int Function(SSLContextRef, int, int) - >(); - - DartSInt32 SSLGetProtocolVersionEnabled( - SSLContextRef context, - SSLProtocol protocol, - ffi.Pointer enable, - ) { - return _SSLGetProtocolVersionEnabled(context, protocol.value, enable); - } + /// Constructs a [NSURLSessionDownloadDelegate] that wraps the given raw object pointer. + NSURLSessionDownloadDelegate.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); - late final _SSLGetProtocolVersionEnabledPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.UnsignedInt, - ffi.Pointer, - ) - > - >('SSLGetProtocolVersionEnabled'); - late final _SSLGetProtocolVersionEnabled = - _SSLGetProtocolVersionEnabledPtr.asFunction< - int Function(SSLContextRef, int, ffi.Pointer) - >(); - - DartSInt32 SSLSetProtocolVersion(SSLContextRef context, SSLProtocol version) { - return _SSLSetProtocolVersion(context, version.value); - } - - late final _SSLSetProtocolVersionPtr = - _lookup< - ffi.NativeFunction - >('SSLSetProtocolVersion'); - late final _SSLSetProtocolVersion = - _SSLSetProtocolVersionPtr.asFunction(); - - int SSLGetProtocolVersion( - SSLContextRef context, - ffi.Pointer protocol, - ) { - return _SSLGetProtocolVersion(context, protocol); + /// Returns whether [obj] is an instance of [NSURLSessionDownloadDelegate]. + static bool conformsTo(objc.ObjCObject obj) { + return _objc_msgSend_e3qsqz( + obj.ref.pointer, + _sel_conformsToProtocol_, + _protocol_NSURLSessionDownloadDelegate, + ); } +} - late final _SSLGetProtocolVersionPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetProtocolVersion'); - late final _SSLGetProtocolVersion = - _SSLGetProtocolVersionPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetCertificate(SSLContextRef context, CFArrayRef certRefs) { - return _SSLSetCertificate(context, certRefs); - } - - late final _SSLSetCertificatePtr = - _lookup>( - 'SSLSetCertificate', +extension NSURLSessionDownloadDelegate$Methods on NSURLSessionDownloadDelegate { + /// The last message a session receives. A session will only become + /// invalid because of a systemic error or when it has been + /// explicitly invalidated, in which case the error parameter will be nil. + void URLSession$5( + NSURLSession session, { + objc.NSError? didBecomeInvalidWithError, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:didBecomeInvalidWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:didBecomeInvalidWithError:', ); - late final _SSLSetCertificate = - _SSLSetCertificatePtr.asFunction< - int Function(SSLContextRef, CFArrayRef) - >(); - - int SSLSetConnection(SSLContextRef context, SSLConnectionRef connection) { - return _SSLSetConnection(context, connection); - } - - late final _SSLSetConnectionPtr = - _lookup< - ffi.NativeFunction - >('SSLSetConnection'); - late final _SSLSetConnection = - _SSLSetConnectionPtr.asFunction< - int Function(SSLContextRef, SSLConnectionRef) - >(); - - int SSLGetConnection( - SSLContextRef context, - ffi.Pointer connection, - ) { - return _SSLGetConnection(context, connection); - } - - late final _SSLGetConnectionPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetConnection'); - late final _SSLGetConnection = - _SSLGetConnectionPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetPeerDomainName( - SSLContextRef context, - ffi.Pointer peerName, - int peerNameLen, - ) { - return _SSLSetPeerDomainName(context, peerName, peerNameLen); - } - - late final _SSLSetPeerDomainNamePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer, ffi.Size) - > - >('SSLSetPeerDomainName'); - late final _SSLSetPeerDomainName = - _SSLSetPeerDomainNamePtr.asFunction< - int Function(SSLContextRef, ffi.Pointer, int) - >(); - - int SSLGetPeerDomainNameLength( - SSLContextRef context, - ffi.Pointer peerNameLen, - ) { - return _SSLGetPeerDomainNameLength(context, peerNameLen); - } - - late final _SSLGetPeerDomainNameLengthPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetPeerDomainNameLength'); - late final _SSLGetPeerDomainNameLength = - _SSLGetPeerDomainNameLengthPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLGetPeerDomainName( - SSLContextRef context, - ffi.Pointer peerName, - ffi.Pointer peerNameLen, - ) { - return _SSLGetPeerDomainName(context, peerName, peerNameLen); - } - - late final _SSLGetPeerDomainNamePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('SSLGetPeerDomainName'); - late final _SSLGetPeerDomainName = - _SSLGetPeerDomainNamePtr.asFunction< - int Function( - SSLContextRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int SSLCopyRequestedPeerNameLength( - SSLContextRef ctx, - ffi.Pointer peerNameLen, - ) { - return _SSLCopyRequestedPeerNameLength(ctx, peerNameLen); - } - - late final _SSLCopyRequestedPeerNameLengthPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLCopyRequestedPeerNameLength'); - late final _SSLCopyRequestedPeerNameLength = - _SSLCopyRequestedPeerNameLengthPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLCopyRequestedPeerName( - SSLContextRef context, - ffi.Pointer peerName, - ffi.Pointer peerNameLen, - ) { - return _SSLCopyRequestedPeerName(context, peerName, peerNameLen); - } - - late final _SSLCopyRequestedPeerNamePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('SSLCopyRequestedPeerName'); - late final _SSLCopyRequestedPeerName = - _SSLCopyRequestedPeerNamePtr.asFunction< - int Function( - SSLContextRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int SSLSetDatagramHelloCookie( - SSLContextRef dtlsContext, - ffi.Pointer cookie, - int cookieLen, - ) { - return _SSLSetDatagramHelloCookie(dtlsContext, cookie, cookieLen); - } - - late final _SSLSetDatagramHelloCookiePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer, ffi.Size) - > - >('SSLSetDatagramHelloCookie'); - late final _SSLSetDatagramHelloCookie = - _SSLSetDatagramHelloCookiePtr.asFunction< - int Function(SSLContextRef, ffi.Pointer, int) - >(); - - int SSLSetMaxDatagramRecordSize(SSLContextRef dtlsContext, int maxSize) { - return _SSLSetMaxDatagramRecordSize(dtlsContext, maxSize); + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + session.ref.pointer, + didBecomeInvalidWithError?.ref.pointer ?? ffi.nullptr, + ); } - late final _SSLSetMaxDatagramRecordSizePtr = - _lookup>( - 'SSLSetMaxDatagramRecordSize', + /// Notification that a task has been created. This method is the first message + /// a task sends, providing a place to configure the task before it is resumed. + /// + /// This delegate callback is *NOT* dispatched to the delegate queue. It is + /// invoked synchronously before the task creation method returns. + void URLSession$6( + NSURLSession session, { + required NSURLSessionTask didCreateTask, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:didCreateTask:', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didCreateTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:didCreateTask:', ); - late final _SSLSetMaxDatagramRecordSize = - _SSLSetMaxDatagramRecordSizePtr.asFunction< - int Function(SSLContextRef, int) - >(); - - int SSLGetMaxDatagramRecordSize( - SSLContextRef dtlsContext, - ffi.Pointer maxSize, - ) { - return _SSLGetMaxDatagramRecordSize(dtlsContext, maxSize); - } - - late final _SSLGetMaxDatagramRecordSizePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetMaxDatagramRecordSize'); - late final _SSLGetMaxDatagramRecordSize = - _SSLGetMaxDatagramRecordSizePtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLGetNegotiatedProtocolVersion( - SSLContextRef context, - ffi.Pointer protocol, - ) { - return _SSLGetNegotiatedProtocolVersion(context, protocol); - } - - late final _SSLGetNegotiatedProtocolVersionPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetNegotiatedProtocolVersion'); - late final _SSLGetNegotiatedProtocolVersion = - _SSLGetNegotiatedProtocolVersionPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLGetNumberSupportedCiphers( - SSLContextRef context, - ffi.Pointer numCiphers, - ) { - return _SSLGetNumberSupportedCiphers(context, numCiphers); - } - - late final _SSLGetNumberSupportedCiphersPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetNumberSupportedCiphers'); - late final _SSLGetNumberSupportedCiphers = - _SSLGetNumberSupportedCiphersPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLGetSupportedCiphers( - SSLContextRef context, - ffi.Pointer ciphers, - ffi.Pointer numCiphers, - ) { - return _SSLGetSupportedCiphers(context, ciphers, numCiphers); - } - - late final _SSLGetSupportedCiphersPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('SSLGetSupportedCiphers'); - late final _SSLGetSupportedCiphers = - _SSLGetSupportedCiphersPtr.asFunction< - int Function( - SSLContextRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int SSLGetNumberEnabledCiphers( - SSLContextRef context, - ffi.Pointer numCiphers, - ) { - return _SSLGetNumberEnabledCiphers(context, numCiphers); - } - - late final _SSLGetNumberEnabledCiphersPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetNumberEnabledCiphers'); - late final _SSLGetNumberEnabledCiphers = - _SSLGetNumberEnabledCiphersPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetEnabledCiphers( - SSLContextRef context, - ffi.Pointer ciphers, - int numCiphers, - ) { - return _SSLSetEnabledCiphers(context, ciphers, numCiphers); + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_didCreateTask_, + session.ref.pointer, + didCreateTask.ref.pointer, + ); } - late final _SSLSetEnabledCiphersPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer, - ffi.Size, - ) - > - >('SSLSetEnabledCiphers'); - late final _SSLSetEnabledCiphers = - _SSLSetEnabledCiphersPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer, int) - >(); - - int SSLGetEnabledCiphers( - SSLContextRef context, - ffi.Pointer ciphers, - ffi.Pointer numCiphers, - ) { - return _SSLGetEnabledCiphers(context, ciphers, numCiphers); + /// If implemented, when a connection level authentication challenge + /// has occurred, this delegate will be given the opportunity to + /// provide authentication credentials to the underlying + /// connection. Some types of authentication will apply to more than + /// one request on a given connection to a server (SSL Server Trust + /// challenges). If this delegate message is not implemented, the + /// behavior will be to use the default handling, which may involve user + /// interaction. + void URLSession$7( + NSURLSession session, { + required NSURLAuthenticationChallenge didReceiveChallenge, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:didReceiveChallenge:completionHandler:', + ); + } + _objc_msgSend_18qun1e( + object$.ref.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + session.ref.pointer, + didReceiveChallenge.ref.pointer, + completionHandler.ref.pointer, + ); } - late final _SSLGetEnabledCiphersPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer, - ffi.Pointer, - ) - > - >('SSLGetEnabledCiphers'); - late final _SSLGetEnabledCiphers = - _SSLGetEnabledCiphersPtr.asFunction< - int Function( - SSLContextRef, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int SSLSetSessionTicketsEnabled(SSLContextRef context, int enabled) { - return _SSLSetSessionTicketsEnabled(context, enabled); + /// Sent when a download task that has completed a download. The delegate should + /// copy or move the file at the given location to a new location as it will be + /// removed when the delegate message returns. URLSession:task:didCompleteWithError: will + /// still be called. + void URLSession( + NSURLSession session, { + required NSURLSessionDownloadTask downloadTask, + required objc.NSURL didFinishDownloadingToURL, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didFinishDownloadingToURL:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_downloadTask_didFinishDownloadingToURL_, + session.ref.pointer, + downloadTask.ref.pointer, + didFinishDownloadingToURL.ref.pointer, + ); } - late final _SSLSetSessionTicketsEnabledPtr = - _lookup>( - 'SSLSetSessionTicketsEnabled', + /// Sent when a download has been resumed. If a download failed with an + /// error, the -userInfo dictionary of the error will contain an + /// NSURLSessionDownloadTaskResumeData key, whose value is the resume + /// data. + void URLSession$1( + NSURLSession session, { + required NSURLSessionDownloadTask downloadTask, + required int didResumeAtOffset, + required int expectedTotalBytes, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:', ); - late final _SSLSetSessionTicketsEnabled = - _SSLSetSessionTicketsEnabledPtr.asFunction< - int Function(SSLContextRef, int) - >(); - - int SSLSetEnableCertVerify(SSLContextRef context, int enableVerify) { - return _SSLSetEnableCertVerify(context, enableVerify); + } + _objc_msgSend_fm5719( + object$.ref.pointer, + _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + session.ref.pointer, + downloadTask.ref.pointer, + didResumeAtOffset, + expectedTotalBytes, + ); } - late final _SSLSetEnableCertVerifyPtr = - _lookup>( - 'SSLSetEnableCertVerify', + /// Sent periodically to notify the delegate of download progress. + void URLSession$2( + NSURLSession session, { + required NSURLSessionDownloadTask downloadTask, + required int didWriteData, + required int totalBytesWritten, + required int totalBytesExpectedToWrite, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:', ); - late final _SSLSetEnableCertVerify = - _SSLSetEnableCertVerifyPtr.asFunction(); - - int SSLGetEnableCertVerify( - SSLContextRef context, - ffi.Pointer enableVerify, - ) { - return _SSLGetEnableCertVerify(context, enableVerify); - } - - late final _SSLGetEnableCertVerifyPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetEnableCertVerify'); - late final _SSLGetEnableCertVerify = - _SSLGetEnableCertVerifyPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetAllowsExpiredCerts(SSLContextRef context, int allowsExpired) { - return _SSLSetAllowsExpiredCerts(context, allowsExpired); + } + _objc_msgSend_1modw1b( + object$.ref.pointer, + _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + session.ref.pointer, + downloadTask.ref.pointer, + didWriteData, + totalBytesWritten, + totalBytesExpectedToWrite, + ); } - late final _SSLSetAllowsExpiredCertsPtr = - _lookup>( - 'SSLSetAllowsExpiredCerts', + /// Sent as the last message related to a specific task. Error may be + /// nil, which implies that no error occurred and this task is complete. + void URLSession$8( + NSURLSession session, { + required NSURLSessionTask task, + objc.NSError? didCompleteWithError, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:didCompleteWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didCompleteWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didCompleteWithError:', ); - late final _SSLSetAllowsExpiredCerts = - _SSLSetAllowsExpiredCertsPtr.asFunction< - int Function(SSLContextRef, int) - >(); - - int SSLGetAllowsExpiredCerts( - SSLContextRef context, - ffi.Pointer allowsExpired, - ) { - return _SSLGetAllowsExpiredCerts(context, allowsExpired); - } - - late final _SSLGetAllowsExpiredCertsPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetAllowsExpiredCerts'); - late final _SSLGetAllowsExpiredCerts = - _SSLGetAllowsExpiredCertsPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetAllowsExpiredRoots(SSLContextRef context, int allowsExpired) { - return _SSLSetAllowsExpiredRoots(context, allowsExpired); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didCompleteWithError_, + session.ref.pointer, + task.ref.pointer, + didCompleteWithError?.ref.pointer ?? ffi.nullptr, + ); } - late final _SSLSetAllowsExpiredRootsPtr = - _lookup>( - 'SSLSetAllowsExpiredRoots', + /// Sent when complete statistics information has been collected for the task. + void URLSession$9( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLSessionTaskMetrics didFinishCollectingMetrics, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:didFinishCollectingMetrics:', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didFinishCollectingMetrics:', ); - late final _SSLSetAllowsExpiredRoots = - _SSLSetAllowsExpiredRootsPtr.asFunction< - int Function(SSLContextRef, int) - >(); - - int SSLGetAllowsExpiredRoots( - SSLContextRef context, - ffi.Pointer allowsExpired, - ) { - return _SSLGetAllowsExpiredRoots(context, allowsExpired); - } - - late final _SSLGetAllowsExpiredRootsPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetAllowsExpiredRoots'); - late final _SSLGetAllowsExpiredRoots = - _SSLGetAllowsExpiredRootsPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetAllowsAnyRoot(SSLContextRef context, int anyRoot) { - return _SSLSetAllowsAnyRoot(context, anyRoot); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + session.ref.pointer, + task.ref.pointer, + didFinishCollectingMetrics.ref.pointer, + ); } - late final _SSLSetAllowsAnyRootPtr = - _lookup>( - 'SSLSetAllowsAnyRoot', + /// The task has received a request specific authentication challenge. + /// If this delegate is not implemented, the session specific authentication challenge + /// will *NOT* be called and the behavior will be the same as using the default handling + /// disposition. + void URLSession$10( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLAuthenticationChallenge didReceiveChallenge, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didReceiveChallenge:completionHandler:', ); - late final _SSLSetAllowsAnyRoot = - _SSLSetAllowsAnyRootPtr.asFunction(); - - int SSLGetAllowsAnyRoot(SSLContextRef context, ffi.Pointer anyRoot) { - return _SSLGetAllowsAnyRoot(context, anyRoot); - } - - late final _SSLGetAllowsAnyRootPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetAllowsAnyRoot'); - late final _SSLGetAllowsAnyRoot = - _SSLGetAllowsAnyRootPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetTrustedRoots( - SSLContextRef context, - CFArrayRef trustedRoots, - int replaceExisting, - ) { - return _SSLSetTrustedRoots(context, trustedRoots, replaceExisting); - } - - late final _SSLSetTrustedRootsPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, CFArrayRef, Boolean) - > - >('SSLSetTrustedRoots'); - late final _SSLSetTrustedRoots = - _SSLSetTrustedRootsPtr.asFunction< - int Function(SSLContextRef, CFArrayRef, int) - >(); - - int SSLCopyTrustedRoots( - SSLContextRef context, - ffi.Pointer trustedRoots, - ) { - return _SSLCopyTrustedRoots(context, trustedRoots); - } - - late final _SSLCopyTrustedRootsPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLCopyTrustedRoots'); - late final _SSLCopyTrustedRoots = - _SSLCopyTrustedRootsPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLCopyPeerCertificates( - SSLContextRef context, - ffi.Pointer certs, - ) { - return _SSLCopyPeerCertificates(context, certs); - } - - late final _SSLCopyPeerCertificatesPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLCopyPeerCertificates'); - late final _SSLCopyPeerCertificates = - _SSLCopyPeerCertificatesPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLCopyPeerTrust(SSLContextRef context, ffi.Pointer trust) { - return _SSLCopyPeerTrust(context, trust); - } - - late final _SSLCopyPeerTrustPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLCopyPeerTrust'); - late final _SSLCopyPeerTrust = - _SSLCopyPeerTrustPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetPeerID( - SSLContextRef context, - ffi.Pointer peerID, - int peerIDLen, - ) { - return _SSLSetPeerID(context, peerID, peerIDLen); - } - - late final _SSLSetPeerIDPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer, ffi.Size) - > - >('SSLSetPeerID'); - late final _SSLSetPeerID = - _SSLSetPeerIDPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer, int) - >(); - - int SSLGetPeerID( - SSLContextRef context, - ffi.Pointer> peerID, - ffi.Pointer peerIDLen, - ) { - return _SSLGetPeerID(context, peerID, peerIDLen); - } - - late final _SSLGetPeerIDPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer>, - ffi.Pointer, - ) - > - >('SSLGetPeerID'); - late final _SSLGetPeerID = - _SSLGetPeerIDPtr.asFunction< - int Function( - SSLContextRef, - ffi.Pointer>, - ffi.Pointer, - ) - >(); - - int SSLGetNegotiatedCipher( - SSLContextRef context, - ffi.Pointer cipherSuite, - ) { - return _SSLGetNegotiatedCipher(context, cipherSuite); - } - - late final _SSLGetNegotiatedCipherPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetNegotiatedCipher'); - late final _SSLGetNegotiatedCipher = - _SSLGetNegotiatedCipherPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetALPNProtocols(SSLContextRef context, CFArrayRef protocols) { - return _SSLSetALPNProtocols(context, protocols); + } + _objc_msgSend_m7tls4( + object$.ref.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + session.ref.pointer, + task.ref.pointer, + didReceiveChallenge.ref.pointer, + completionHandler.ref.pointer, + ); } - late final _SSLSetALPNProtocolsPtr = - _lookup>( - 'SSLSetALPNProtocols', + /// Sent for each informational response received except 101 switching protocols. + void URLSession$11( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse didReceiveInformationalResponse, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:didReceiveInformationalResponse:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didReceiveInformationalResponse:', ); - late final _SSLSetALPNProtocols = - _SSLSetALPNProtocolsPtr.asFunction< - int Function(SSLContextRef, CFArrayRef) - >(); - - int SSLCopyALPNProtocols( - SSLContextRef context, - ffi.Pointer protocols, - ) { - return _SSLCopyALPNProtocols(context, protocols); - } - - late final _SSLCopyALPNProtocolsPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLCopyALPNProtocols'); - late final _SSLCopyALPNProtocols = - _SSLCopyALPNProtocolsPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetOCSPResponse(SSLContextRef context, CFDataRef response) { - return _SSLSetOCSPResponse(context, response); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + session.ref.pointer, + task.ref.pointer, + didReceiveInformationalResponse.ref.pointer, + ); } - late final _SSLSetOCSPResponsePtr = - _lookup>( - 'SSLSetOCSPResponse', + /// Sent periodically to notify the delegate of upload progress. This + /// information is also available as properties of the task. + void URLSession$12( + NSURLSession session, { + required NSURLSessionTask task, + required int didSendBodyData, + required int totalBytesSent, + required int totalBytesExpectedToSend, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', ); - late final _SSLSetOCSPResponse = - _SSLSetOCSPResponsePtr.asFunction< - int Function(SSLContextRef, CFDataRef) - >(); - - int SSLSetEncryptionCertificate(SSLContextRef context, CFArrayRef certRefs) { - return _SSLSetEncryptionCertificate(context, certRefs); + } + _objc_msgSend_1modw1b( + object$.ref.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + session.ref.pointer, + task.ref.pointer, + didSendBodyData, + totalBytesSent, + totalBytesExpectedToSend, + ); } - late final _SSLSetEncryptionCertificatePtr = - _lookup>( - 'SSLSetEncryptionCertificate', + /// Sent if a task requires a new, unopened body stream. This may be + /// necessary when authentication has failed for any request that + /// involves a body stream. + void URLSession$13( + NSURLSession session, { + required NSURLSessionTask task, + required objc.ObjCBlock + needNewBodyStream, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:needNewBodyStream:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStream_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:needNewBodyStream:', ); - late final _SSLSetEncryptionCertificate = - _SSLSetEncryptionCertificatePtr.asFunction< - int Function(SSLContextRef, CFArrayRef) - >(); - - DartSInt32 SSLSetClientSideAuthenticate( - SSLContextRef context, - SSLAuthenticate auth, - ) { - return _SSLSetClientSideAuthenticate(context, auth.value); - } - - late final _SSLSetClientSideAuthenticatePtr = - _lookup< - ffi.NativeFunction - >('SSLSetClientSideAuthenticate'); - late final _SSLSetClientSideAuthenticate = - _SSLSetClientSideAuthenticatePtr.asFunction< - int Function(SSLContextRef, int) - >(); - - int SSLAddDistinguishedName( - SSLContextRef context, - ffi.Pointer derDN, - int derDNLen, - ) { - return _SSLAddDistinguishedName(context, derDN, derDNLen); - } - - late final _SSLAddDistinguishedNamePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer, ffi.Size) - > - >('SSLAddDistinguishedName'); - late final _SSLAddDistinguishedName = - _SSLAddDistinguishedNamePtr.asFunction< - int Function(SSLContextRef, ffi.Pointer, int) - >(); - - int SSLSetCertificateAuthorities( - SSLContextRef context, - CFTypeRef certificateOrArray, - int replaceExisting, - ) { - return _SSLSetCertificateAuthorities( - context, - certificateOrArray, - replaceExisting, + } + _objc_msgSend_18qun1e( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStream_, + session.ref.pointer, + task.ref.pointer, + needNewBodyStream.ref.pointer, ); } - late final _SSLSetCertificateAuthoritiesPtr = - _lookup< - ffi.NativeFunction - >('SSLSetCertificateAuthorities'); - late final _SSLSetCertificateAuthorities = - _SSLSetCertificateAuthoritiesPtr.asFunction< - int Function(SSLContextRef, CFTypeRef, int) - >(); - - int SSLCopyCertificateAuthorities( - SSLContextRef context, - ffi.Pointer certificates, - ) { - return _SSLCopyCertificateAuthorities(context, certificates); - } - - late final _SSLCopyCertificateAuthoritiesPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLCopyCertificateAuthorities'); - late final _SSLCopyCertificateAuthorities = - _SSLCopyCertificateAuthoritiesPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLCopyDistinguishedNames( - SSLContextRef context, - ffi.Pointer names, - ) { - return _SSLCopyDistinguishedNames(context, names); - } - - late final _SSLCopyDistinguishedNamesPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLCopyDistinguishedNames'); - late final _SSLCopyDistinguishedNames = - _SSLCopyDistinguishedNamesPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLGetClientCertificateState( - SSLContextRef context, - ffi.Pointer clientState, - ) { - return _SSLGetClientCertificateState(context, clientState); - } - - late final _SSLGetClientCertificateStatePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetClientCertificateState'); - late final _SSLGetClientCertificateState = - _SSLGetClientCertificateStatePtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLSetDiffieHellmanParams( - SSLContextRef context, - ffi.Pointer dhParams, - int dhParamsLen, - ) { - return _SSLSetDiffieHellmanParams(context, dhParams, dhParamsLen); - } - - late final _SSLSetDiffieHellmanParamsPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer, ffi.Size) - > - >('SSLSetDiffieHellmanParams'); - late final _SSLSetDiffieHellmanParams = - _SSLSetDiffieHellmanParamsPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer, int) - >(); - - int SSLGetDiffieHellmanParams( - SSLContextRef context, - ffi.Pointer> dhParams, - ffi.Pointer dhParamsLen, - ) { - return _SSLGetDiffieHellmanParams(context, dhParams, dhParamsLen); - } - - late final _SSLGetDiffieHellmanParamsPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer>, - ffi.Pointer, - ) - > - >('SSLGetDiffieHellmanParams'); - late final _SSLGetDiffieHellmanParams = - _SSLGetDiffieHellmanParamsPtr.asFunction< - int Function( - SSLContextRef, - ffi.Pointer>, - ffi.Pointer, - ) - >(); - - int SSLSetRsaBlinding(SSLContextRef context, int blinding) { - return _SSLSetRsaBlinding(context, blinding); - } - - late final _SSLSetRsaBlindingPtr = - _lookup>( - 'SSLSetRsaBlinding', - ); - late final _SSLSetRsaBlinding = - _SSLSetRsaBlindingPtr.asFunction(); - - int SSLGetRsaBlinding(SSLContextRef context, ffi.Pointer blinding) { - return _SSLGetRsaBlinding(context, blinding); - } - - late final _SSLGetRsaBlindingPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetRsaBlinding'); - late final _SSLGetRsaBlinding = - _SSLGetRsaBlindingPtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLHandshake(SSLContextRef context) { - return _SSLHandshake(context); - } - - late final _SSLHandshakePtr = - _lookup>( - 'SSLHandshake', - ); - late final _SSLHandshake = - _SSLHandshakePtr.asFunction(); - - int SSLReHandshake(SSLContextRef context) { - return _SSLReHandshake(context); - } - - late final _SSLReHandshakePtr = - _lookup>( - 'SSLReHandshake', - ); - late final _SSLReHandshake = - _SSLReHandshakePtr.asFunction(); - - int SSLWrite( - SSLContextRef context, - ffi.Pointer data, - int dataLength, - ffi.Pointer processed, - ) { - return _SSLWrite(context, data, dataLength, processed); - } - - late final _SSLWritePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ) - > - >('SSLWrite'); - late final _SSLWrite = - _SSLWritePtr.asFunction< - int Function( - SSLContextRef, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - int SSLRead( - SSLContextRef context, - ffi.Pointer data, - int dataLength, - ffi.Pointer processed, - ) { - return _SSLRead(context, data, dataLength, processed); - } - - late final _SSLReadPtr = - _lookup< - ffi.NativeFunction< - OSStatus Function( - SSLContextRef, - ffi.Pointer, - ffi.Size, - ffi.Pointer, - ) - > - >('SSLRead'); - late final _SSLRead = - _SSLReadPtr.asFunction< - int Function( - SSLContextRef, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - - int SSLGetBufferedReadSize( - SSLContextRef context, - ffi.Pointer bufferSize, - ) { - return _SSLGetBufferedReadSize(context, bufferSize); - } - - late final _SSLGetBufferedReadSizePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetBufferedReadSize'); - late final _SSLGetBufferedReadSize = - _SSLGetBufferedReadSizePtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLGetDatagramWriteSize( - SSLContextRef dtlsContext, - ffi.Pointer bufSize, - ) { - return _SSLGetDatagramWriteSize(dtlsContext, bufSize); - } - - late final _SSLGetDatagramWriteSizePtr = - _lookup< - ffi.NativeFunction< - OSStatus Function(SSLContextRef, ffi.Pointer) - > - >('SSLGetDatagramWriteSize'); - late final _SSLGetDatagramWriteSize = - _SSLGetDatagramWriteSizePtr.asFunction< - int Function(SSLContextRef, ffi.Pointer) - >(); - - int SSLClose(SSLContextRef context) { - return _SSLClose(context); - } - - late final _SSLClosePtr = - _lookup>('SSLClose'); - late final _SSLClose = _SSLClosePtr.asFunction(); - - int SSLSetError(SSLContextRef context, int status) { - return _SSLSetError(context, status); - } - - late final _SSLSetErrorPtr = - _lookup>( - 'SSLSetError', - ); - late final _SSLSetError = - _SSLSetErrorPtr.asFunction(); - - /// -1LL - late final ffi.Pointer _NSURLSessionTransferSizeUnknown = - _lookup('NSURLSessionTransferSizeUnknown'); - - int get NSURLSessionTransferSizeUnknown => - _NSURLSessionTransferSizeUnknown.value; - - late final ffi.Pointer _NSURLSessionTaskPriorityDefault = - _lookup('NSURLSessionTaskPriorityDefault'); - - double get NSURLSessionTaskPriorityDefault => - _NSURLSessionTaskPriorityDefault.value; - - late final ffi.Pointer _NSURLSessionTaskPriorityLow = - _lookup('NSURLSessionTaskPriorityLow'); - - double get NSURLSessionTaskPriorityLow => _NSURLSessionTaskPriorityLow.value; - - late final ffi.Pointer _NSURLSessionTaskPriorityHigh = - _lookup('NSURLSessionTaskPriorityHigh'); - - double get NSURLSessionTaskPriorityHigh => - _NSURLSessionTaskPriorityHigh.value; - - /// Key in the userInfo dictionary of an NSError received during a failed download. - late final ffi.Pointer> - _NSURLSessionDownloadTaskResumeData = - _lookup>( - 'NSURLSessionDownloadTaskResumeData', - ); - - objc.NSString get NSURLSessionDownloadTaskResumeData => - objc.NSString.fromPointer( - _NSURLSessionDownloadTaskResumeData.value, - retain: true, - release: true, - ); - - set NSURLSessionDownloadTaskResumeData(objc.NSString value) { - objc.NSString.fromPointer( - _NSURLSessionDownloadTaskResumeData.value, - retain: false, - release: true, - ).ref.release(); - _NSURLSessionDownloadTaskResumeData.value = value.ref - .retainAndReturnPointer(); - } - - /// Key in the userInfo dictionary of an NSError received during a failed upload. - late final ffi.Pointer> - _NSURLSessionUploadTaskResumeData = _lookup>( - 'NSURLSessionUploadTaskResumeData', - ); - - objc.NSString get NSURLSessionUploadTaskResumeData => - objc.NSString.fromPointer( - _NSURLSessionUploadTaskResumeData.value, - retain: true, - release: true, - ); - - set NSURLSessionUploadTaskResumeData(objc.NSString value) { - objc.NSString.fromPointer( - _NSURLSessionUploadTaskResumeData.value, - retain: false, - release: true, - ).ref.release(); - _NSURLSessionUploadTaskResumeData.value = value.ref - .retainAndReturnPointer(); - } - - NSRange NSUnionRange(NSRange range1, NSRange range2) { - return _NSUnionRange(range1, range2); - } - - late final _NSUnionRangePtr = - _lookup>( - 'NSUnionRange', - ); - late final _NSUnionRange = - _NSUnionRangePtr.asFunction(); - - NSRange NSIntersectionRange(NSRange range1, NSRange range2) { - return _NSIntersectionRange(range1, range2); - } - - late final _NSIntersectionRangePtr = - _lookup>( - 'NSIntersectionRange', - ); - late final _NSIntersectionRange = - _NSIntersectionRangePtr.asFunction(); - - objc.NSString NSStringFromRange(NSRange range) { - return objc.NSString.fromPointer( - _NSStringFromRange(range), - retain: true, - release: true, + /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be + /// necessary when resuming a failed upload task. + /// + /// - Parameter session: The session containing the task that needs a new body stream from the given offset. + /// - Parameter task: The task that needs a new body stream. + /// - Parameter offset: The starting offset required for the body stream. + /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. + void URLSession$14( + NSURLSession session, { + required NSURLSessionTask task, + required int needNewBodyStreamFromOffset, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), ); - } - - late final _NSStringFromRangePtr = - _lookup< - ffi.NativeFunction Function(NSRange)> - >('NSStringFromRange'); - late final _NSStringFromRange = - _NSStringFromRangePtr.asFunction< - ffi.Pointer Function(NSRange) - >(); - - NSRange NSRangeFromString(objc.NSString aString) { - return _NSRangeFromString(aString.ref.pointer); - } - - late final _NSRangeFromStringPtr = - _lookup< - ffi.NativeFunction)> - >('NSRangeFromString'); - late final _NSRangeFromString = - _NSRangeFromStringPtr.asFunction< - NSRange Function(ffi.Pointer) - >(); - - late final ffi.Pointer> - _NSItemProviderPreferredImageSizeKey = - _lookup>( - 'NSItemProviderPreferredImageSizeKey', - ); - - objc.NSString get NSItemProviderPreferredImageSizeKey => - objc.NSString.fromPointer( - _NSItemProviderPreferredImageSizeKey.value, - retain: true, - release: true, + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', ); - - set NSItemProviderPreferredImageSizeKey(objc.NSString value) { - objc.NSString.fromPointer( - _NSItemProviderPreferredImageSizeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSItemProviderPreferredImageSizeKey.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_9cddqw( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + session.ref.pointer, + task.ref.pointer, + needNewBodyStreamFromOffset, + completionHandler.ref.pointer, + ); } - late final ffi.Pointer> - _NSExtensionJavaScriptPreprocessingResultsKey = - _lookup>( - 'NSExtensionJavaScriptPreprocessingResultsKey', - ); - - objc.NSString get NSExtensionJavaScriptPreprocessingResultsKey => - objc.NSString.fromPointer( - _NSExtensionJavaScriptPreprocessingResultsKey.value, - retain: true, - release: true, + /// Sent when the system is ready to begin work for a task with a delayed start + /// time set (using the earliestBeginDate property). The completionHandler must + /// be invoked in order for loading to proceed. The disposition provided to the + /// completion handler continues the load with the original request provided to + /// the task, replaces the request with the specified task, or cancels the task. + /// If this delegate is not implemented, loading will proceed with the original + /// request. + /// + /// Recommendation: only implement this delegate if tasks that have the + /// earliestBeginDate property set may become stale and require alteration prior + /// to starting the network load. + /// + /// If a new request is specified, the allowsExpensiveNetworkAccess, + /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties + /// from the new request will not be used; the properties from the + /// original request will continue to be used. + /// + /// Canceling the task is equivalent to calling the task's cancel method; the + /// URLSession:task:didCompleteWithError: task delegate will be called with error + /// NSURLErrorCancelled. + void URLSession$15( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLRequest willBeginDelayedRequest, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:willBeginDelayedRequest:completionHandler:', ); - - set NSExtensionJavaScriptPreprocessingResultsKey(objc.NSString value) { - objc.NSString.fromPointer( - _NSExtensionJavaScriptPreprocessingResultsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSExtensionJavaScriptPreprocessingResultsKey.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_m7tls4( + object$.ref.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + session.ref.pointer, + task.ref.pointer, + willBeginDelayedRequest.ref.pointer, + completionHandler.ref.pointer, + ); } - late final ffi.Pointer> - _NSExtensionJavaScriptFinalizeArgumentKey = - _lookup>( - 'NSExtensionJavaScriptFinalizeArgumentKey', - ); - - objc.NSString get NSExtensionJavaScriptFinalizeArgumentKey => - objc.NSString.fromPointer( - _NSExtensionJavaScriptFinalizeArgumentKey.value, - retain: true, - release: true, + /// An HTTP request is attempting to perform a redirection to a different + /// URL. You must invoke the completion routine to allow the + /// redirection, allow the redirection with a modified request, or + /// pass nil to the completionHandler to cause the body of the redirection + /// response to be delivered as the payload of this request. The default + /// is to follow redirections. + /// + /// For tasks in background sessions, redirections will always be followed and this method will not be called. + void URLSession$16( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse willPerformHTTPRedirection, + required NSURLRequest newRequest, + required objc.ObjCBlock completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', ); - - set NSExtensionJavaScriptFinalizeArgumentKey(objc.NSString value) { - objc.NSString.fromPointer( - _NSExtensionJavaScriptFinalizeArgumentKey.value, - retain: false, - release: true, - ).ref.release(); - _NSExtensionJavaScriptFinalizeArgumentKey.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer> - _NSItemProviderErrorDomain = _lookup>( - 'NSItemProviderErrorDomain', - ); - - objc.NSString get NSItemProviderErrorDomain => objc.NSString.fromPointer( - _NSItemProviderErrorDomain.value, - retain: true, - release: true, - ); - - set NSItemProviderErrorDomain(objc.NSString value) { - objc.NSString.fromPointer( - _NSItemProviderErrorDomain.value, - retain: false, - release: true, - ).ref.release(); - _NSItemProviderErrorDomain.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_e1wgee( + object$.ref.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + session.ref.pointer, + task.ref.pointer, + willPerformHTTPRedirection.ref.pointer, + newRequest.ref.pointer, + completionHandler.ref.pointer, + ); } - late final ffi.Pointer _NSStringTransformLatinToKatakana = - _lookup('NSStringTransformLatinToKatakana'); - - DartNSStringTransform get NSStringTransformLatinToKatakana => - objc.NSString.fromPointer( - _NSStringTransformLatinToKatakana.value, - retain: true, - release: true, + /// Sent when a task cannot start the network loading process because the current + /// network connectivity is not available or sufficient for the task's request. + /// + /// This delegate will be called at most one time per task, and is only called if + /// the waitsForConnectivity property in the NSURLSessionConfiguration has been + /// set to YES. + /// + /// This delegate callback will never be called for background sessions, because + /// the waitForConnectivity property is ignored by those sessions. + void URLSession$17( + NSURLSession session, { + required NSURLSessionTask taskIsWaitingForConnectivity, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:taskIsWaitingForConnectivity:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:taskIsWaitingForConnectivity:', ); - - set NSStringTransformLatinToKatakana(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformLatinToKatakana.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformLatinToKatakana.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + session.ref.pointer, + taskIsWaitingForConnectivity.ref.pointer, + ); } - late final ffi.Pointer _NSStringTransformLatinToHiragana = - _lookup('NSStringTransformLatinToHiragana'); - - DartNSStringTransform get NSStringTransformLatinToHiragana => - objc.NSString.fromPointer( - _NSStringTransformLatinToHiragana.value, - retain: true, - release: true, + /// If an application has received an + /// -application:handleEventsForBackgroundURLSession:completionHandler: + /// message, the session delegate will receive this message to indicate + /// that all messages previously enqueued for this session have been + /// delivered. At this time it is safe to invoke the previously stored + /// completion handler, or to begin any internal updates that will + /// result in invoking the completion handler. + void URLSessionDidFinishEventsForBackgroundURLSession(NSURLSession session) { + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSessionDidFinishEventsForBackgroundURLSession:', ); - - set NSStringTransformLatinToHiragana(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformLatinToHiragana.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformLatinToHiragana.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + session.ref.pointer, + ); } +} - late final ffi.Pointer _NSStringTransformLatinToHangul = - _lookup('NSStringTransformLatinToHangul'); - - DartNSStringTransform get NSStringTransformLatinToHangul => - objc.NSString.fromPointer( - _NSStringTransformLatinToHangul.value, - retain: true, - release: true, - ); +interface class NSURLSessionDownloadDelegate$Builder { + /// Returns the [objc.Protocol] object for this protocol. + static objc.Protocol get $protocol => + objc.Protocol.fromPointer(_protocol_NSURLSessionDownloadDelegate.cast()); - set NSStringTransformLatinToHangul(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformLatinToHangul.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformLatinToHangul.value = value.ref.retainAndReturnPointer(); + /// Builds an object that implements the NSURLSessionDownloadDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionDownloadDelegate implement({ + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + URLSession_downloadTask_didFinishDownloadingToURL_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionDownloadDelegate', + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDownloadDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didFinishDownloadingToURL_.implement( + builder, + URLSession_downloadTask_didFinishDownloadingToURL_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implement( + builder, + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implement( + builder, + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didCompleteWithError_.implement( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implement( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implement( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStream_.implement( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implement( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implement( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionDownloadDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); } - late final ffi.Pointer _NSStringTransformLatinToArabic = - _lookup('NSStringTransformLatinToArabic'); - - DartNSStringTransform get NSStringTransformLatinToArabic => - objc.NSString.fromPointer( - _NSStringTransformLatinToArabic.value, - retain: true, - release: true, - ); - - set NSStringTransformLatinToArabic(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformLatinToArabic.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformLatinToArabic.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSStringTransformLatinToHebrew = - _lookup('NSStringTransformLatinToHebrew'); - - DartNSStringTransform get NSStringTransformLatinToHebrew => - objc.NSString.fromPointer( - _NSStringTransformLatinToHebrew.value, - retain: true, - release: true, - ); - - set NSStringTransformLatinToHebrew(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformLatinToHebrew.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformLatinToHebrew.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSStringTransformLatinToThai = - _lookup('NSStringTransformLatinToThai'); - - DartNSStringTransform get NSStringTransformLatinToThai => - objc.NSString.fromPointer( - _NSStringTransformLatinToThai.value, - retain: true, - release: true, - ); - - set NSStringTransformLatinToThai(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformLatinToThai.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformLatinToThai.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSStringTransformLatinToCyrillic = - _lookup('NSStringTransformLatinToCyrillic'); - - DartNSStringTransform get NSStringTransformLatinToCyrillic => - objc.NSString.fromPointer( - _NSStringTransformLatinToCyrillic.value, - retain: true, - release: true, - ); - - set NSStringTransformLatinToCyrillic(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformLatinToCyrillic.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformLatinToCyrillic.value = value.ref - .retainAndReturnPointer(); + /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilder( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + URLSession_downloadTask_didFinishDownloadingToURL_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDownloadDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didFinishDownloadingToURL_.implement( + builder, + URLSession_downloadTask_didFinishDownloadingToURL_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implement( + builder, + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implement( + builder, + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didCompleteWithError_.implement( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implement( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implement( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStream_.implement( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implement( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implement( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); } - late final ffi.Pointer _NSStringTransformLatinToGreek = - _lookup('NSStringTransformLatinToGreek'); - - DartNSStringTransform get NSStringTransformLatinToGreek => - objc.NSString.fromPointer( - _NSStringTransformLatinToGreek.value, - retain: true, - release: true, - ); - - set NSStringTransformLatinToGreek(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformLatinToGreek.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformLatinToGreek.value = value.ref.retainAndReturnPointer(); + /// Builds an object that implements the NSURLSessionDownloadDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionDownloadDelegate implementAsListener({ + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + URLSession_downloadTask_didFinishDownloadingToURL_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionDownloadDelegate', + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsListener( + builder, + URLSession_downloadTask_didFinishDownloadingToURL_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsListener( + builder, + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsListener( + builder, + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsListener( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionDownloadDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); } - late final ffi.Pointer _NSStringTransformToLatin = - _lookup('NSStringTransformToLatin'); - - DartNSStringTransform get NSStringTransformToLatin => - objc.NSString.fromPointer( - _NSStringTransformToLatin.value, - retain: true, - release: true, - ); - - set NSStringTransformToLatin(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformToLatin.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformToLatin.value = value.ref.retainAndReturnPointer(); + /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will + /// be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsListener( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + URLSession_downloadTask_didFinishDownloadingToURL_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsListener( + builder, + URLSession_downloadTask_didFinishDownloadingToURL_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsListener( + builder, + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsListener( + builder, + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsListener( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); } - late final ffi.Pointer _NSStringTransformMandarinToLatin = - _lookup('NSStringTransformMandarinToLatin'); - - DartNSStringTransform get NSStringTransformMandarinToLatin => - objc.NSString.fromPointer( - _NSStringTransformMandarinToLatin.value, - retain: true, - release: true, - ); - - set NSStringTransformMandarinToLatin(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformMandarinToLatin.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformMandarinToLatin.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSStringTransformHiraganaToKatakana = _lookup( - 'NSStringTransformHiraganaToKatakana', - ); - - DartNSStringTransform get NSStringTransformHiraganaToKatakana => - objc.NSString.fromPointer( - _NSStringTransformHiraganaToKatakana.value, - retain: true, - release: true, - ); - - set NSStringTransformHiraganaToKatakana(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformHiraganaToKatakana.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformHiraganaToKatakana.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSStringTransformFullwidthToHalfwidth = _lookup( - 'NSStringTransformFullwidthToHalfwidth', - ); - - DartNSStringTransform get NSStringTransformFullwidthToHalfwidth => - objc.NSString.fromPointer( - _NSStringTransformFullwidthToHalfwidth.value, - retain: true, - release: true, - ); - - set NSStringTransformFullwidthToHalfwidth(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformFullwidthToHalfwidth.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformFullwidthToHalfwidth.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer _NSStringTransformToXMLHex = - _lookup('NSStringTransformToXMLHex'); - - DartNSStringTransform get NSStringTransformToXMLHex => - objc.NSString.fromPointer( - _NSStringTransformToXMLHex.value, - retain: true, - release: true, - ); - - set NSStringTransformToXMLHex(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformToXMLHex.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformToXMLHex.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSStringTransformToUnicodeName = - _lookup('NSStringTransformToUnicodeName'); - - DartNSStringTransform get NSStringTransformToUnicodeName => - objc.NSString.fromPointer( - _NSStringTransformToUnicodeName.value, - retain: true, - release: true, - ); - - set NSStringTransformToUnicodeName(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformToUnicodeName.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformToUnicodeName.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSStringTransformStripCombiningMarks = _lookup( - 'NSStringTransformStripCombiningMarks', - ); - - DartNSStringTransform get NSStringTransformStripCombiningMarks => - objc.NSString.fromPointer( - _NSStringTransformStripCombiningMarks.value, - retain: true, - release: true, - ); - - set NSStringTransformStripCombiningMarks(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformStripCombiningMarks.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformStripCombiningMarks.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer _NSStringTransformStripDiacritics = - _lookup('NSStringTransformStripDiacritics'); - - DartNSStringTransform get NSStringTransformStripDiacritics => - objc.NSString.fromPointer( - _NSStringTransformStripDiacritics.value, - retain: true, - release: true, - ); - - set NSStringTransformStripDiacritics(DartNSStringTransform value) { - objc.NSString.fromPointer( - _NSStringTransformStripDiacritics.value, - retain: false, - release: true, - ).ref.release(); - _NSStringTransformStripDiacritics.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSStringEncodingDetectionSuggestedEncodingsKey = - _lookup( - 'NSStringEncodingDetectionSuggestedEncodingsKey', - ); - - DartNSStringEncodingDetectionOptionsKey - get NSStringEncodingDetectionSuggestedEncodingsKey => - objc.NSString.fromPointer( - _NSStringEncodingDetectionSuggestedEncodingsKey.value, - retain: true, - release: true, - ); - - set NSStringEncodingDetectionSuggestedEncodingsKey( - DartNSStringEncodingDetectionOptionsKey value, - ) { - objc.NSString.fromPointer( - _NSStringEncodingDetectionSuggestedEncodingsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSStringEncodingDetectionSuggestedEncodingsKey.value = value.ref - .retainAndReturnPointer(); + /// Builds an object that implements the NSURLSessionDownloadDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as blocking listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionDownloadDelegate implementAsBlocking({ + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + URLSession_downloadTask_didFinishDownloadingToURL_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionDownloadDelegate', + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsBlocking( + builder, + URLSession_downloadTask_didFinishDownloadingToURL_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsBlocking( + builder, + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsBlocking( + builder, + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsBlocking( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionDownloadDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); } - late final ffi.Pointer - _NSStringEncodingDetectionDisallowedEncodingsKey = - _lookup( - 'NSStringEncodingDetectionDisallowedEncodingsKey', - ); - - DartNSStringEncodingDetectionOptionsKey - get NSStringEncodingDetectionDisallowedEncodingsKey => - objc.NSString.fromPointer( - _NSStringEncodingDetectionDisallowedEncodingsKey.value, - retain: true, - release: true, - ); - - set NSStringEncodingDetectionDisallowedEncodingsKey( - DartNSStringEncodingDetectionOptionsKey value, - ) { - objc.NSString.fromPointer( - _NSStringEncodingDetectionDisallowedEncodingsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSStringEncodingDetectionDisallowedEncodingsKey.value = value.ref - .retainAndReturnPointer(); + /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking + /// listeners will be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsBlocking( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + URLSession_downloadTask_didFinishDownloadingToURL_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsBlocking( + builder, + URLSession_downloadTask_didFinishDownloadingToURL_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsBlocking( + builder, + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsBlocking( + builder, + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsBlocking( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionDownloadDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); } - late final ffi.Pointer - _NSStringEncodingDetectionUseOnlySuggestedEncodingsKey = - _lookup( - 'NSStringEncodingDetectionUseOnlySuggestedEncodingsKey', - ); - - DartNSStringEncodingDetectionOptionsKey - get NSStringEncodingDetectionUseOnlySuggestedEncodingsKey => - objc.NSString.fromPointer( - _NSStringEncodingDetectionUseOnlySuggestedEncodingsKey.value, - retain: true, - release: true, + /// The last message a session receives. A session will only become + /// invalid because of a systemic error or when it has been + /// explicitly invalidated, in which case the error parameter will be nil. + static final URLSession_didBecomeInvalidWithError_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, objc.NSError?) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didBecomeInvalidWithError_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didBecomeInvalidWithError_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), ); - set NSStringEncodingDetectionUseOnlySuggestedEncodingsKey( - DartNSStringEncodingDetectionOptionsKey value, - ) { - objc.NSString.fromPointer( - _NSStringEncodingDetectionUseOnlySuggestedEncodingsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSStringEncodingDetectionUseOnlySuggestedEncodingsKey.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSStringEncodingDetectionAllowLossyKey = - _lookup( - 'NSStringEncodingDetectionAllowLossyKey', + /// Notification that a task has been created. This method is the first message + /// a task sends, providing a place to configure the task before it is resumed. + /// + /// This delegate callback is *NOT* dispatched to the delegate queue. It is + /// invoked synchronously before the task creation method returns. + static final URLSession_didCreateTask_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didCreateTask_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didCreateTask_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), ); - DartNSStringEncodingDetectionOptionsKey - get NSStringEncodingDetectionAllowLossyKey => objc.NSString.fromPointer( - _NSStringEncodingDetectionAllowLossyKey.value, - retain: true, - release: true, - ); - - set NSStringEncodingDetectionAllowLossyKey( - DartNSStringEncodingDetectionOptionsKey value, - ) { - objc.NSString.fromPointer( - _NSStringEncodingDetectionAllowLossyKey.value, - retain: false, - release: true, - ).ref.release(); - _NSStringEncodingDetectionAllowLossyKey.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSStringEncodingDetectionFromWindowsKey = - _lookup( - 'NSStringEncodingDetectionFromWindowsKey', - ); - - DartNSStringEncodingDetectionOptionsKey - get NSStringEncodingDetectionFromWindowsKey => objc.NSString.fromPointer( - _NSStringEncodingDetectionFromWindowsKey.value, - retain: true, - release: true, - ); - - set NSStringEncodingDetectionFromWindowsKey( - DartNSStringEncodingDetectionOptionsKey value, - ) { - objc.NSString.fromPointer( - _NSStringEncodingDetectionFromWindowsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSStringEncodingDetectionFromWindowsKey.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSStringEncodingDetectionLossySubstitutionKey = - _lookup( - 'NSStringEncodingDetectionLossySubstitutionKey', - ); - - DartNSStringEncodingDetectionOptionsKey - get NSStringEncodingDetectionLossySubstitutionKey => - objc.NSString.fromPointer( - _NSStringEncodingDetectionLossySubstitutionKey.value, - retain: true, - release: true, - ); - - set NSStringEncodingDetectionLossySubstitutionKey( - DartNSStringEncodingDetectionOptionsKey value, - ) { - objc.NSString.fromPointer( - _NSStringEncodingDetectionLossySubstitutionKey.value, - retain: false, - release: true, - ).ref.release(); - _NSStringEncodingDetectionLossySubstitutionKey.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSStringEncodingDetectionLikelyLanguageKey = - _lookup( - 'NSStringEncodingDetectionLikelyLanguageKey', - ); - - DartNSStringEncodingDetectionOptionsKey - get NSStringEncodingDetectionLikelyLanguageKey => objc.NSString.fromPointer( - _NSStringEncodingDetectionLikelyLanguageKey.value, - retain: true, - release: true, - ); - - set NSStringEncodingDetectionLikelyLanguageKey( - DartNSStringEncodingDetectionOptionsKey value, - ) { - objc.NSString.fromPointer( - _NSStringEncodingDetectionLikelyLanguageKey.value, - retain: false, - release: true, - ).ref.release(); - _NSStringEncodingDetectionLikelyLanguageKey.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer _NSCharacterConversionException = - _lookup('NSCharacterConversionException'); - - DartNSExceptionName get NSCharacterConversionException => - objc.NSString.fromPointer( - _NSCharacterConversionException.value, - retain: true, - release: true, - ); - - set NSCharacterConversionException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSCharacterConversionException.value, - retain: false, - release: true, - ).ref.release(); - _NSCharacterConversionException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSParseErrorException = - _lookup('NSParseErrorException'); - - DartNSExceptionName get NSParseErrorException => objc.NSString.fromPointer( - _NSParseErrorException.value, - retain: true, - release: true, - ); - - set NSParseErrorException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSParseErrorException.value, - retain: false, - release: true, - ).ref.release(); - _NSParseErrorException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer> - _NSHTTPPropertyStatusCodeKey = _lookup>( - 'NSHTTPPropertyStatusCodeKey', - ); - - objc.NSString get NSHTTPPropertyStatusCodeKey => objc.NSString.fromPointer( - _NSHTTPPropertyStatusCodeKey.value, - retain: true, - release: true, - ); - - late final ffi.Pointer> - _NSHTTPPropertyStatusReasonKey = _lookup>( - 'NSHTTPPropertyStatusReasonKey', - ); - - objc.NSString get NSHTTPPropertyStatusReasonKey => objc.NSString.fromPointer( - _NSHTTPPropertyStatusReasonKey.value, - retain: true, - release: true, - ); - - late final ffi.Pointer> - _NSHTTPPropertyServerHTTPVersionKey = - _lookup>( - 'NSHTTPPropertyServerHTTPVersionKey', - ); - - objc.NSString get NSHTTPPropertyServerHTTPVersionKey => - objc.NSString.fromPointer( - _NSHTTPPropertyServerHTTPVersionKey.value, - retain: true, - release: true, + /// If implemented, when a connection level authentication challenge + /// has occurred, this delegate will be given the opportunity to + /// provide authentication credentials to the underlying + /// connection. Some types of authentication will apply to more than + /// one request on a given connection to a server (SSL Server Trust + /// challenges). If this delegate message is not implemented, the + /// behavior will be to use the default handling, which may involve user + /// interaction. + static final URLSession_didReceiveChallenge_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final ffi.Pointer> - _NSHTTPPropertyRedirectionHeadersKey = - _lookup>( - 'NSHTTPPropertyRedirectionHeadersKey', + /// Sent when a download task that has completed a download. The delegate should + /// copy or move the file at the given location to a new location as it will be + /// removed when the delegate message returns. URLSession:task:didCompleteWithError: will + /// still be called. + static final URLSession_downloadTask_didFinishDownloadingToURL_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didFinishDownloadingToURL_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didFinishDownloadingToURL_, + isRequired: true, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + objc.NSURL arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + objc.NSURL arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + objc.NSURL arg3, + ) => func(arg1, arg2, arg3), + ), ); - objc.NSString get NSHTTPPropertyRedirectionHeadersKey => - objc.NSString.fromPointer( - _NSHTTPPropertyRedirectionHeadersKey.value, - retain: true, - release: true, + /// Sent when a download has been resumed. If a download failed with an + /// error, the -userInfo dictionary of the error will contain an + /// NSURLSessionDownloadTaskResumeData key, whose value is the resume + /// data. + static final URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionDownloadTask, int, int) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_ly2579) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, int, int) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, int, int) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, int, int) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + ) => func(arg1, arg2, arg3, arg4), + ), ); - late final ffi.Pointer> - _NSHTTPPropertyErrorPageDataKey = _lookup>( - 'NSHTTPPropertyErrorPageDataKey', - ); - - objc.NSString get NSHTTPPropertyErrorPageDataKey => objc.NSString.fromPointer( - _NSHTTPPropertyErrorPageDataKey.value, - retain: true, - release: true, - ); - - late final ffi.Pointer> - _NSHTTPPropertyHTTPProxy = _lookup>( - 'NSHTTPPropertyHTTPProxy', - ); - - objc.NSString get NSHTTPPropertyHTTPProxy => objc.NSString.fromPointer( - _NSHTTPPropertyHTTPProxy.value, - retain: true, - release: true, - ); - - late final ffi.Pointer> - _NSFTPPropertyUserLoginKey = _lookup>( - 'NSFTPPropertyUserLoginKey', - ); - - objc.NSString get NSFTPPropertyUserLoginKey => objc.NSString.fromPointer( - _NSFTPPropertyUserLoginKey.value, - retain: true, - release: true, - ); - - late final ffi.Pointer> - _NSFTPPropertyUserPasswordKey = _lookup>( - 'NSFTPPropertyUserPasswordKey', - ); - - objc.NSString get NSFTPPropertyUserPasswordKey => objc.NSString.fromPointer( - _NSFTPPropertyUserPasswordKey.value, - retain: true, - release: true, - ); - - late final ffi.Pointer> - _NSFTPPropertyActiveTransferModeKey = - _lookup>( - 'NSFTPPropertyActiveTransferModeKey', + /// Sent periodically to notify the delegate of download progress. + static final URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_h68abb) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ( + void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), ); - objc.NSString get NSFTPPropertyActiveTransferModeKey => - objc.NSString.fromPointer( - _NSFTPPropertyActiveTransferModeKey.value, - retain: true, - release: true, + /// Sent as the last message related to a specific task. Error may be + /// nil, which implies that no error occurred and this task is complete. + static final URLSession_task_didCompleteWithError_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, objc.NSError?) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didCompleteWithError_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didCompleteWithError_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), ); - late final ffi.Pointer> - _NSFTPPropertyFileOffsetKey = _lookup>( - 'NSFTPPropertyFileOffsetKey', - ); - - objc.NSString get NSFTPPropertyFileOffsetKey => objc.NSString.fromPointer( - _NSFTPPropertyFileOffsetKey.value, - retain: true, - release: true, - ); - - late final ffi.Pointer> - _NSFTPPropertyFTPProxy = _lookup>( - 'NSFTPPropertyFTPProxy', - ); - - objc.NSString get NSFTPPropertyFTPProxy => objc.NSString.fromPointer( - _NSFTPPropertyFTPProxy.value, - retain: true, - release: true, - ); - - /// A string constant for the "file" URL scheme. If you are using this to compare to a URL's scheme to see if it is a file URL, you should instead use the NSURL fileURL property -- the fileURL property is much faster. - late final ffi.Pointer> _NSURLFileScheme = - _lookup>('NSURLFileScheme'); - - objc.NSString get NSURLFileScheme => objc.NSString.fromPointer( - _NSURLFileScheme.value, - retain: true, - release: true, - ); - - set NSURLFileScheme(objc.NSString value) { - objc.NSString.fromPointer( - _NSURLFileScheme.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileScheme.value = value.ref.retainAndReturnPointer(); - } - - /// Key for the resource properties that have not been set after setResourceValues:error: returns an error, returned as an array of of strings. - late final ffi.Pointer _NSURLKeysOfUnsetValuesKey = - _lookup('NSURLKeysOfUnsetValuesKey'); - - DartNSURLResourceKey get NSURLKeysOfUnsetValuesKey => - objc.NSString.fromPointer( - _NSURLKeysOfUnsetValuesKey.value, - retain: true, - release: true, + /// Sent when complete statistics information has been collected for the task. + static final URLSession_task_didFinishCollectingMetrics_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didFinishCollectingMetrics_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didFinishCollectingMetrics_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), ); - set NSURLKeysOfUnsetValuesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLKeysOfUnsetValuesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLKeysOfUnsetValuesKey.value = value.ref.retainAndReturnPointer(); - } - - /// The resource name provided by the file system (Read-write, value type NSString) - late final ffi.Pointer _NSURLNameKey = - _lookup('NSURLNameKey'); - - DartNSURLResourceKey get NSURLNameKey => objc.NSString.fromPointer( - _NSURLNameKey.value, - retain: true, - release: true, - ); - - set NSURLNameKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLNameKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLNameKey.value = value.ref.retainAndReturnPointer(); - } - - /// Localized or extension-hidden name as displayed to users (Read-only, value type NSString) - late final ffi.Pointer _NSURLLocalizedNameKey = - _lookup('NSURLLocalizedNameKey'); - - DartNSURLResourceKey get NSURLLocalizedNameKey => objc.NSString.fromPointer( - _NSURLLocalizedNameKey.value, - retain: true, - release: true, - ); - - set NSURLLocalizedNameKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLLocalizedNameKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLLocalizedNameKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for regular files (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsRegularFileKey = - _lookup('NSURLIsRegularFileKey'); - - DartNSURLResourceKey get NSURLIsRegularFileKey => objc.NSString.fromPointer( - _NSURLIsRegularFileKey.value, - retain: true, - release: true, - ); - - set NSURLIsRegularFileKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsRegularFileKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsRegularFileKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for directories (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsDirectoryKey = - _lookup('NSURLIsDirectoryKey'); - - DartNSURLResourceKey get NSURLIsDirectoryKey => objc.NSString.fromPointer( - _NSURLIsDirectoryKey.value, - retain: true, - release: true, - ); - - set NSURLIsDirectoryKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsDirectoryKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsDirectoryKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for symlinks (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsSymbolicLinkKey = - _lookup('NSURLIsSymbolicLinkKey'); - - DartNSURLResourceKey get NSURLIsSymbolicLinkKey => objc.NSString.fromPointer( - _NSURLIsSymbolicLinkKey.value, - retain: true, - release: true, - ); - - set NSURLIsSymbolicLinkKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsSymbolicLinkKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsSymbolicLinkKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for the root directory of a volume (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsVolumeKey = - _lookup('NSURLIsVolumeKey'); - - DartNSURLResourceKey get NSURLIsVolumeKey => objc.NSString.fromPointer( - _NSURLIsVolumeKey.value, - retain: true, - release: true, - ); - - set NSURLIsVolumeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsVolumeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsVolumeKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for packaged directories (Read-only 10_6 and 10_7, read-write 10_8, value type boolean NSNumber). Note: You can only set or clear this property on directories; if you try to set this property on non-directory objects, the property is ignored. If the directory is a package for some other reason (extension type, etc), setting this property to false will have no effect. - late final ffi.Pointer _NSURLIsPackageKey = - _lookup('NSURLIsPackageKey'); - - DartNSURLResourceKey get NSURLIsPackageKey => objc.NSString.fromPointer( - _NSURLIsPackageKey.value, - retain: true, - release: true, - ); - - set NSURLIsPackageKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsPackageKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsPackageKey.value = value.ref.retainAndReturnPointer(); - } - - /// True if resource is an application (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsApplicationKey = - _lookup('NSURLIsApplicationKey'); - - DartNSURLResourceKey get NSURLIsApplicationKey => objc.NSString.fromPointer( - _NSURLIsApplicationKey.value, - retain: true, - release: true, - ); - - set NSURLIsApplicationKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsApplicationKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsApplicationKey.value = value.ref.retainAndReturnPointer(); - } - - /// True if the resource is scriptable. Only applies to applications (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLApplicationIsScriptableKey = - _lookup('NSURLApplicationIsScriptableKey'); - - DartNSURLResourceKey get NSURLApplicationIsScriptableKey => - objc.NSString.fromPointer( - _NSURLApplicationIsScriptableKey.value, - retain: true, - release: true, - ); - - set NSURLApplicationIsScriptableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLApplicationIsScriptableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLApplicationIsScriptableKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for system-immutable resources (Read-write, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsSystemImmutableKey = - _lookup('NSURLIsSystemImmutableKey'); - - DartNSURLResourceKey get NSURLIsSystemImmutableKey => - objc.NSString.fromPointer( - _NSURLIsSystemImmutableKey.value, - retain: true, - release: true, - ); - - set NSURLIsSystemImmutableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsSystemImmutableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsSystemImmutableKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for user-immutable resources (Read-write, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsUserImmutableKey = - _lookup('NSURLIsUserImmutableKey'); - - DartNSURLResourceKey get NSURLIsUserImmutableKey => objc.NSString.fromPointer( - _NSURLIsUserImmutableKey.value, - retain: true, - release: true, - ); - - set NSURLIsUserImmutableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsUserImmutableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsUserImmutableKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for resources normally not displayed to users (Read-write, value type boolean NSNumber). Note: If the resource is a hidden because its name starts with a period, setting this property to false will not change the property. - late final ffi.Pointer _NSURLIsHiddenKey = - _lookup('NSURLIsHiddenKey'); - - DartNSURLResourceKey get NSURLIsHiddenKey => objc.NSString.fromPointer( - _NSURLIsHiddenKey.value, - retain: true, - release: true, - ); - - set NSURLIsHiddenKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsHiddenKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsHiddenKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for resources whose filename extension is removed from the localized name property (Read-write, value type boolean NSNumber) - late final ffi.Pointer _NSURLHasHiddenExtensionKey = - _lookup('NSURLHasHiddenExtensionKey'); - - DartNSURLResourceKey get NSURLHasHiddenExtensionKey => - objc.NSString.fromPointer( - _NSURLHasHiddenExtensionKey.value, - retain: true, - release: true, + /// The task has received a request specific authentication challenge. + /// If this delegate is not implemented, the session specific authentication challenge + /// will *NOT* be called and the behavior will be the same as using the default handling + /// disposition. + static final URLSession_task_didReceiveChallenge_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), ); - set NSURLHasHiddenExtensionKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLHasHiddenExtensionKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLHasHiddenExtensionKey.value = value.ref.retainAndReturnPointer(); - } - - /// The date the resource was created (Read-write, value type NSDate) - late final ffi.Pointer _NSURLCreationDateKey = - _lookup('NSURLCreationDateKey'); - - DartNSURLResourceKey get NSURLCreationDateKey => objc.NSString.fromPointer( - _NSURLCreationDateKey.value, - retain: true, - release: true, - ); - - set NSURLCreationDateKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLCreationDateKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLCreationDateKey.value = value.ref.retainAndReturnPointer(); - } - - /// The date the resource was last accessed (Read-write, value type NSDate) - late final ffi.Pointer _NSURLContentAccessDateKey = - _lookup('NSURLContentAccessDateKey'); - - DartNSURLResourceKey get NSURLContentAccessDateKey => - objc.NSString.fromPointer( - _NSURLContentAccessDateKey.value, - retain: true, - release: true, + /// Sent for each informational response received except 101 switching protocols. + static final URLSession_task_didReceiveInformationalResponse_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didReceiveInformationalResponse_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didReceiveInformationalResponse_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), ); - set NSURLContentAccessDateKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLContentAccessDateKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLContentAccessDateKey.value = value.ref.retainAndReturnPointer(); - } - - /// The time the resource content was last modified (Read-write, value type NSDate) - late final ffi.Pointer _NSURLContentModificationDateKey = - _lookup('NSURLContentModificationDateKey'); - - DartNSURLResourceKey get NSURLContentModificationDateKey => - objc.NSString.fromPointer( - _NSURLContentModificationDateKey.value, - retain: true, - release: true, + /// Sent periodically to notify the delegate of upload progress. This + /// information is also available as properties of the task. + static final URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, int, int, int) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_h68abb) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), ); - set NSURLContentModificationDateKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLContentModificationDateKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLContentModificationDateKey.value = value.ref.retainAndReturnPointer(); - } - - /// The time the resource's attributes were last modified (Read-only, value type NSDate) - late final ffi.Pointer _NSURLAttributeModificationDateKey = - _lookup('NSURLAttributeModificationDateKey'); - - DartNSURLResourceKey get NSURLAttributeModificationDateKey => - objc.NSString.fromPointer( - _NSURLAttributeModificationDateKey.value, - retain: true, - release: true, + /// Sent if a task requires a new, unopened body stream. This may be + /// necessary when authentication has failed for any request that + /// involves a body stream. + static final URLSession_task_needNewBodyStream_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_needNewBodyStream_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_needNewBodyStream_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), ); - set NSURLAttributeModificationDateKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLAttributeModificationDateKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLAttributeModificationDateKey.value = value.ref - .retainAndReturnPointer(); - } - - /// Number of hard links to the resource (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLLinkCountKey = - _lookup('NSURLLinkCountKey'); - - DartNSURLResourceKey get NSURLLinkCountKey => objc.NSString.fromPointer( - _NSURLLinkCountKey.value, - retain: true, - release: true, - ); - - set NSURLLinkCountKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLLinkCountKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLLinkCountKey.value = value.ref.retainAndReturnPointer(); - } - - /// The resource's parent directory, if any (Read-only, value type NSURL) - late final ffi.Pointer _NSURLParentDirectoryURLKey = - _lookup('NSURLParentDirectoryURLKey'); - - DartNSURLResourceKey get NSURLParentDirectoryURLKey => - objc.NSString.fromPointer( - _NSURLParentDirectoryURLKey.value, - retain: true, - release: true, + /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be + /// necessary when resuming a failed upload task. + /// + /// - Parameter session: The session containing the task that needs a new body stream from the given offset. + /// - Parameter task: The task that needs a new body stream. + /// - Parameter offset: The starting offset required for the body stream. + /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. + static final URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_jyim80) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), ); - set NSURLParentDirectoryURLKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLParentDirectoryURLKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLParentDirectoryURLKey.value = value.ref.retainAndReturnPointer(); - } - - /// URL of the volume on which the resource is stored (Read-only, value type NSURL) - late final ffi.Pointer _NSURLVolumeURLKey = - _lookup('NSURLVolumeURLKey'); - - DartNSURLResourceKey get NSURLVolumeURLKey => objc.NSString.fromPointer( - _NSURLVolumeURLKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeURLKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeURLKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeURLKey.value = value.ref.retainAndReturnPointer(); - } - - /// Uniform type identifier (UTI) for the resource (Read-only, value type NSString) - late final ffi.Pointer _NSURLTypeIdentifierKey = - _lookup('NSURLTypeIdentifierKey'); - - DartNSURLResourceKey get NSURLTypeIdentifierKey => objc.NSString.fromPointer( - _NSURLTypeIdentifierKey.value, - retain: true, - release: true, - ); - - set NSURLTypeIdentifierKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLTypeIdentifierKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLTypeIdentifierKey.value = value.ref.retainAndReturnPointer(); - } - - /// File type (UTType) for the resource (Read-only, value type UTType) - late final ffi.Pointer _NSURLContentTypeKey = - _lookup('NSURLContentTypeKey'); - - DartNSURLResourceKey get NSURLContentTypeKey => objc.NSString.fromPointer( - _NSURLContentTypeKey.value, - retain: true, - release: true, - ); - - set NSURLContentTypeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLContentTypeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLContentTypeKey.value = value.ref.retainAndReturnPointer(); - } - - /// User-visible type or "kind" description (Read-only, value type NSString) - late final ffi.Pointer _NSURLLocalizedTypeDescriptionKey = - _lookup('NSURLLocalizedTypeDescriptionKey'); - - DartNSURLResourceKey get NSURLLocalizedTypeDescriptionKey => - objc.NSString.fromPointer( - _NSURLLocalizedTypeDescriptionKey.value, - retain: true, - release: true, + /// Sent when the system is ready to begin work for a task with a delayed start + /// time set (using the earliestBeginDate property). The completionHandler must + /// be invoked in order for loading to proceed. The disposition provided to the + /// completion handler continues the load with the original request provided to + /// the task, replaces the request with the specified task, or cancels the task. + /// If this delegate is not implemented, loading will proceed with the original + /// request. + /// + /// Recommendation: only implement this delegate if tasks that have the + /// earliestBeginDate property set may become stale and require alteration prior + /// to starting the network load. + /// + /// If a new request is specified, the allowsExpensiveNetworkAccess, + /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties + /// from the new request will not be used; the properties from the + /// original request will continue to be used. + /// + /// Canceling the task is equivalent to calling the task's cancel method; the + /// URLSession:task:didCompleteWithError: task delegate will be called with error + /// NSURLErrorCancelled. + static final URLSession_task_willBeginDelayedRequest_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), ); - set NSURLLocalizedTypeDescriptionKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLLocalizedTypeDescriptionKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLLocalizedTypeDescriptionKey.value = value.ref - .retainAndReturnPointer(); - } - - /// The label number assigned to the resource (Read-write, value type NSNumber) - late final ffi.Pointer _NSURLLabelNumberKey = - _lookup('NSURLLabelNumberKey'); - - DartNSURLResourceKey get NSURLLabelNumberKey => objc.NSString.fromPointer( - _NSURLLabelNumberKey.value, - retain: true, - release: true, - ); - - set NSURLLabelNumberKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLLabelNumberKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLLabelNumberKey.value = value.ref.retainAndReturnPointer(); - } - - /// The color of the assigned label (Read-only, value type NSColor) - late final ffi.Pointer _NSURLLabelColorKey = - _lookup('NSURLLabelColorKey'); - - DartNSURLResourceKey get NSURLLabelColorKey => objc.NSString.fromPointer( - _NSURLLabelColorKey.value, - retain: true, - release: true, - ); - - set NSURLLabelColorKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLLabelColorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLLabelColorKey.value = value.ref.retainAndReturnPointer(); - } - - /// The user-visible label text (Read-only, value type NSString) - late final ffi.Pointer _NSURLLocalizedLabelKey = - _lookup('NSURLLocalizedLabelKey'); - - DartNSURLResourceKey get NSURLLocalizedLabelKey => objc.NSString.fromPointer( - _NSURLLocalizedLabelKey.value, - retain: true, - release: true, - ); - - set NSURLLocalizedLabelKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLLocalizedLabelKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLLocalizedLabelKey.value = value.ref.retainAndReturnPointer(); - } - - /// The icon normally displayed for the resource (Read-only, value type NSImage) - late final ffi.Pointer _NSURLEffectiveIconKey = - _lookup('NSURLEffectiveIconKey'); - - DartNSURLResourceKey get NSURLEffectiveIconKey => objc.NSString.fromPointer( - _NSURLEffectiveIconKey.value, - retain: true, - release: true, - ); - - set NSURLEffectiveIconKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLEffectiveIconKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLEffectiveIconKey.value = value.ref.retainAndReturnPointer(); - } - - /// The custom icon assigned to the resource, if any (Currently not implemented, value type NSImage) - late final ffi.Pointer _NSURLCustomIconKey = - _lookup('NSURLCustomIconKey'); - - DartNSURLResourceKey get NSURLCustomIconKey => objc.NSString.fromPointer( - _NSURLCustomIconKey.value, - retain: true, - release: true, - ); - - set NSURLCustomIconKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLCustomIconKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLCustomIconKey.value = value.ref.retainAndReturnPointer(); - } + /// An HTTP request is attempting to perform a redirection to a different + /// URL. You must invoke the completion routine to allow the + /// redirection, allow the redirection with a modified request, or + /// pass nil to the completionHandler to cause the body of the redirection + /// response to be delivered as the payload of this request. The default + /// is to follow redirections. + /// + /// For tasks in background sessions, redirections will always be followed and this method will not be called. + static final URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_l2g8ke) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ); - /// An identifier which can be used to compare two file system objects for equality using -isEqual (i.e, two object identifiers are equal if they have the same file system path or if the paths are linked to same inode on the same file system). This identifier is not persistent across system restarts. (Read-only, value type id ) - late final ffi.Pointer _NSURLFileResourceIdentifierKey = - _lookup('NSURLFileResourceIdentifierKey'); + /// Sent when a task cannot start the network loading process because the current + /// network connectivity is not available or sufficient for the task's request. + /// + /// This delegate will be called at most one time per task, and is only called if + /// the waitsForConnectivity property in the NSURLSessionConfiguration has been + /// set to YES. + /// + /// This delegate callback will never be called for background sessions, because + /// the waitForConnectivity property is ignored by those sessions. + static final URLSession_taskIsWaitingForConnectivity_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask) + >( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_taskIsWaitingForConnectivity_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_taskIsWaitingForConnectivity_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + ); - DartNSURLResourceKey get NSURLFileResourceIdentifierKey => - objc.NSString.fromPointer( - _NSURLFileResourceIdentifierKey.value, - retain: true, - release: true, + /// If an application has received an + /// -application:handleEventsForBackgroundURLSession:completionHandler: + /// message, the session delegate will receive this message to indicate + /// that all messages previously enqueued for this session have been + /// delivered. At this time it is safe to invoke the previously stored + /// completion handler, or to begin any internal updates that will + /// result in invoking the completion handler. + static final URLSessionDidFinishEventsForBackgroundURLSession_ = + objc.ObjCProtocolListenableMethod( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_18v1jvf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.fromFunction( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.listener( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.blocking( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), ); +} - set NSURLFileResourceIdentifierKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLFileResourceIdentifierKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceIdentifierKey.value = value.ref.retainAndReturnPointer(); - } +late final _protocol_NSURLSessionWebSocketDelegate = objc.getProtocol( + "NSURLSessionWebSocketDelegate", +); +late final _sel_URLSession_webSocketTask_didOpenWithProtocol_ = objc + .registerName("URLSession:webSocketTask:didOpenWithProtocol:"); - /// An identifier that can be used to identify the volume the file system object is on. Other objects on the same volume will have the same volume identifier and can be compared using for equality using -isEqual. This identifier is not persistent across system restarts. (Read-only, value type id ) - late final ffi.Pointer _NSURLVolumeIdentifierKey = - _lookup('NSURLVolumeIdentifierKey'); +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + >(pointer, retain: retain, release: release); - DartNSURLResourceKey get NSURLVolumeIdentifierKey => - objc.NSString.fromPointer( - _NSURLVolumeIdentifierKey.value, - retain: true, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, release: true, ); - set NSURLVolumeIdentifierKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIdentifierKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIdentifierKey.value = value.ref.retainAndReturnPointer(); - } - - /// The optimal block size when reading or writing this file's data, or nil if not available. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLPreferredIOBlockSizeKey = - _lookup('NSURLPreferredIOBlockSizeKey'); - - DartNSURLResourceKey get NSURLPreferredIOBlockSizeKey => - objc.NSString.fromPointer( - _NSURLPreferredIOBlockSizeKey.value, - retain: true, + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionWebSocketTask.fromPointer( + arg2, + retain: true, + release: true, + ), + arg3.address == 0 + ? null + : objc.NSString.fromPointer(arg3, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, release: true, ); - set NSURLPreferredIOBlockSizeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLPreferredIOBlockSizeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLPreferredIOBlockSizeKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if this process (as determined by EUID) can read the resource. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsReadableKey = - _lookup('NSURLIsReadableKey'); - - DartNSURLResourceKey get NSURLIsReadableKey => objc.NSString.fromPointer( - _NSURLIsReadableKey.value, - retain: true, - release: true, - ); - - set NSURLIsReadableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsReadableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsReadableKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if this process (as determined by EUID) can write to the resource. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsWritableKey = - _lookup('NSURLIsWritableKey'); - - DartNSURLResourceKey get NSURLIsWritableKey => objc.NSString.fromPointer( - _NSURLIsWritableKey.value, - retain: true, - release: true, - ); - - set NSURLIsWritableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsWritableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsWritableKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if this process (as determined by EUID) can execute a file resource or search a directory resource. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsExecutableKey = - _lookup('NSURLIsExecutableKey'); - - DartNSURLResourceKey get NSURLIsExecutableKey => objc.NSString.fromPointer( - _NSURLIsExecutableKey.value, - retain: true, - release: true, - ); - - set NSURLIsExecutableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsExecutableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsExecutableKey.value = value.ref.retainAndReturnPointer(); - } - - /// The file system object's security information encapsulated in a NSFileSecurity object. (Read-write, Value type NSFileSecurity) - late final ffi.Pointer _NSURLFileSecurityKey = - _lookup('NSURLFileSecurityKey'); - - DartNSURLResourceKey get NSURLFileSecurityKey => objc.NSString.fromPointer( - _NSURLFileSecurityKey.value, - retain: true, - release: true, - ); - - set NSURLFileSecurityKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLFileSecurityKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileSecurityKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if resource should be excluded from backups, false otherwise (Read-write, value type boolean NSNumber). This property is only useful for excluding cache and other application support files which are not needed in a backup. Some operations commonly made to user documents will cause this property to be reset to false and so this property should not be used on user documents. - late final ffi.Pointer _NSURLIsExcludedFromBackupKey = - _lookup('NSURLIsExcludedFromBackupKey'); - - DartNSURLResourceKey get NSURLIsExcludedFromBackupKey => - objc.NSString.fromPointer( - _NSURLIsExcludedFromBackupKey.value, - retain: true, - release: true, - ); - - set NSURLIsExcludedFromBackupKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsExcludedFromBackupKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsExcludedFromBackupKey.value = value.ref.retainAndReturnPointer(); - } - - /// The array of Tag names (Read-write, value type NSArray of NSString) - late final ffi.Pointer _NSURLTagNamesKey = - _lookup('NSURLTagNamesKey'); - - DartNSURLResourceKey get NSURLTagNamesKey => objc.NSString.fromPointer( - _NSURLTagNamesKey.value, - retain: true, - release: true, - ); - - set NSURLTagNamesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLTagNamesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLTagNamesKey.value = value.ref.retainAndReturnPointer(); - } - - /// the URL's path as a file system path (Read-only, value type NSString) - late final ffi.Pointer _NSURLPathKey = - _lookup('NSURLPathKey'); - - DartNSURLResourceKey get NSURLPathKey => objc.NSString.fromPointer( - _NSURLPathKey.value, - retain: true, - release: true, - ); - - set NSURLPathKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLPathKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLPathKey.value = value.ref.retainAndReturnPointer(); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionWebSocketTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3.address == 0 + ? null + : objc.NSString.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + >(wrapper, retain: false, release: true); } - /// the URL's path as a canonical absolute file system path (Read-only, value type NSString) - late final ffi.Pointer _NSURLCanonicalPathKey = - _lookup('NSURLCanonicalPathKey'); - - DartNSURLResourceKey get NSURLCanonicalPathKey => objc.NSString.fromPointer( - _NSURLCanonicalPathKey.value, - retain: true, - release: true, - ); - - set NSURLCanonicalPathKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLCanonicalPathKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLCanonicalPathKey.value = value.ref.retainAndReturnPointer(); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionWebSocketTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3.address == 0 + ? null + : objc.NSString.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionWebSocketTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3.address == 0 + ? null + : objc.NSString.fromPointer(arg3, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + >(wrapper, retain: false, release: true); } - /// true if this URL is a file system trigger directory. Traversing or opening a file system trigger will cause an attempt to mount a file system on the trigger directory. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsMountTriggerKey = - _lookup('NSURLIsMountTriggerKey'); - - DartNSURLResourceKey get NSURLIsMountTriggerKey => objc.NSString.fromPointer( - _NSURLIsMountTriggerKey.value, - retain: true, - release: true, - ); - - set NSURLIsMountTriggerKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsMountTriggerKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsMountTriggerKey.value = value.ref.retainAndReturnPointer(); + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); } - /// An opaque generation identifier which can be compared using isEqual: to determine if the data in a document has been modified. For URLs which refer to the same file inode, the generation identifier will change when the data in the file's data fork is changed (changes to extended attributes or other file system metadata do not change the generation identifier). For URLs which refer to the same directory inode, the generation identifier will change when direct children of that directory are added, removed or renamed (changes to the data of the direct children of that directory will not change the generation identifier). The generation identifier is persistent across system restarts. The generation identifier is tied to a specific document on a specific volume and is not transferred when the document is copied to another volume. This property is not supported by all volumes. (Read-only, value type id ) - late final ffi.Pointer _NSURLGenerationIdentifierKey = - _lookup('NSURLGenerationIdentifierKey'); - - DartNSURLResourceKey get NSURLGenerationIdentifierKey => - objc.NSString.fromPointer( - _NSURLGenerationIdentifierKey.value, - retain: true, - release: true, - ); - - set NSURLGenerationIdentifierKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLGenerationIdentifierKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLGenerationIdentifierKey.value = value.ref.retainAndReturnPointer(); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) { + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - /// The document identifier -- a value assigned by the kernel to a document (which can be either a file or directory) and is used to identify the document regardless of where it gets moved on a volume. The document identifier survives "safe save” operations; i.e it is sticky to the path it was assigned to (-replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error: is the preferred safe-save API). The document identifier is persistent across system restarts. The document identifier is not transferred when the file is copied. Document identifiers are only unique within a single volume. This property is not supported by all volumes. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLDocumentIdentifierKey = - _lookup('NSURLDocumentIdentifierKey'); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - DartNSURLResourceKey get NSURLDocumentIdentifierKey => - objc.NSString.fromPointer( - _NSURLDocumentIdentifierKey.value, - retain: true, - release: true, +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionWebSocketTask arg2, + objc.NSString? arg3, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3?.ref.pointer ?? ffi.nullptr, ); +} - set NSURLDocumentIdentifierKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLDocumentIdentifierKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLDocumentIdentifierKey.value = value.ref.retainAndReturnPointer(); - } +late final _sel_URLSession_webSocketTask_didCloseWithCode_reason_ = objc + .registerName("URLSession:webSocketTask:didCloseWithCode:reason:"); +final _objc_msgSend_d9bpjb = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ) + >(); - /// The date the resource was created, or renamed into or within its parent directory. Note that inconsistent behavior may be observed when this attribute is requested on hard-linked items. This property is not supported by all volumes. (Read-only before macOS 10.15, iOS 13.0, watchOS 6.0, and tvOS 13.0; Read-write after, value type NSDate) - late final ffi.Pointer _NSURLAddedToDirectoryDateKey = - _lookup('NSURLAddedToDirectoryDateKey'); +/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, ffi.Long, objc.NSData?)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + >(pointer, retain: retain, release: release); - DartNSURLResourceKey get NSURLAddedToDirectoryDateKey => - objc.NSString.fromPointer( - _NSURLAddedToDirectoryDateKey.value, - retain: true, + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Long arg3, + ffi.Pointer arg4, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, release: true, ); - set NSURLAddedToDirectoryDateKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLAddedToDirectoryDateKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLAddedToDirectoryDateKey.value = value.ref.retainAndReturnPointer(); - } - - /// The quarantine properties as defined in LSQuarantine.h. To remove quarantine information from a file, pass NSNull as the value when setting this property. (Read-write, value type NSDictionary) - late final ffi.Pointer _NSURLQuarantinePropertiesKey = - _lookup('NSURLQuarantinePropertiesKey'); - - DartNSURLResourceKey get NSURLQuarantinePropertiesKey => - objc.NSString.fromPointer( - _NSURLQuarantinePropertiesKey.value, - retain: true, - release: true, - ); - - set NSURLQuarantinePropertiesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLQuarantinePropertiesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLQuarantinePropertiesKey.value = value.ref.retainAndReturnPointer(); - } - - /// Returns the file system object type. (Read-only, value type NSString) - late final ffi.Pointer _NSURLFileResourceTypeKey = - _lookup('NSURLFileResourceTypeKey'); - - DartNSURLResourceKey get NSURLFileResourceTypeKey => - objc.NSString.fromPointer( - _NSURLFileResourceTypeKey.value, - retain: true, + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + > + fromFunction( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + int, + objc.NSData?, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionWebSocketTask.fromPointer( + arg2, + retain: true, + release: true, + ), + arg3, + arg4.address == 0 + ? null + : objc.NSData.fromPointer(arg4, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, release: true, ); - set NSURLFileResourceTypeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeKey.value = value.ref.retainAndReturnPointer(); + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + > + listener( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + int, + objc.NSData?, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionWebSocketTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4.address == 0 + ? null + : objc.NSData.fromPointer(arg4, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1lx650f(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + >(wrapper, retain: false, release: true); } - /// The file system's internal inode identifier for the item. This value is not stable for all file systems or across all mounts, so it should be used sparingly and not persisted. It is useful, for example, to match URLs from the URL enumerator with paths from FSEvents. (Read-only, value type NSNumber containing an unsigned long long). - late final ffi.Pointer _NSURLFileIdentifierKey = - _lookup('NSURLFileIdentifierKey'); + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + > + blocking( + void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + int, + objc.NSData?, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionWebSocketTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4.address == 0 + ? null + : objc.NSData.fromPointer(arg4, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => fn( + arg0, + NSURLSession.fromPointer(arg1, retain: false, release: true), + NSURLSessionWebSocketTask.fromPointer( + arg2, + retain: false, + release: true, + ), + arg3, + arg4.address == 0 + ? null + : objc.NSData.fromPointer(arg4, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1lx650f( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + >(wrapper, retain: false, release: true); + } - DartNSURLResourceKey get NSURLFileIdentifierKey => objc.NSString.fromPointer( - _NSURLFileIdentifierKey.value, - retain: true, - release: true, - ); + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + objc.objectRelease(block.cast()); + } - set NSURLFileIdentifierKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLFileIdentifierKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileIdentifierKey.value = value.ref.retainAndReturnPointer(); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) { + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } } - /// A 64-bit value assigned by APFS that identifies a file's content data stream. Only cloned files and their originals can have the same identifier. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLFileContentIdentifierKey = - _lookup('NSURLFileContentIdentifierKey'); + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Long arg3, + ffi.Pointer arg4, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ) + >()(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ))(arg0, arg1, arg2, arg3, arg4); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} - DartNSURLResourceKey get NSURLFileContentIdentifierKey => - objc.NSString.fromPointer( - _NSURLFileContentIdentifierKey.value, - retain: true, - release: true, +/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, ffi.Long, objc.NSData?)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionWebSocketTask arg2, + int arg3, + objc.NSData? arg4, + ) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Long arg3, + ffi.Pointer arg4, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + arg1.ref.pointer, + arg2.ref.pointer, + arg3, + arg4?.ref.pointer ?? ffi.nullptr, ); +} - set NSURLFileContentIdentifierKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLFileContentIdentifierKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileContentIdentifierKey.value = value.ref.retainAndReturnPointer(); - } - - /// True for cloned files and their originals that may share all, some, or no data blocks. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLMayShareFileContentKey = - _lookup('NSURLMayShareFileContentKey'); +/// NSURLSessionWebSocketDelegate +extension type NSURLSessionWebSocketDelegate._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol, NSURLSessionTaskDelegate { + /// Constructs a [NSURLSessionWebSocketDelegate] that points to the same underlying object as [other]. + NSURLSessionWebSocketDelegate.as(objc.ObjCObject other) : object$ = other; - DartNSURLResourceKey get NSURLMayShareFileContentKey => - objc.NSString.fromPointer( - _NSURLMayShareFileContentKey.value, - retain: true, - release: true, - ); + /// Constructs a [NSURLSessionWebSocketDelegate] that wraps the given raw object pointer. + NSURLSessionWebSocketDelegate.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); - set NSURLMayShareFileContentKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLMayShareFileContentKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLMayShareFileContentKey.value = value.ref.retainAndReturnPointer(); + /// Returns whether [obj] is an instance of [NSURLSessionWebSocketDelegate]. + static bool conformsTo(objc.ObjCObject obj) { + return _objc_msgSend_e3qsqz( + obj.ref.pointer, + _sel_conformsToProtocol_, + _protocol_NSURLSessionWebSocketDelegate, + ); } +} - /// True if the file has extended attributes. False guarantees there are none. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLMayHaveExtendedAttributesKey = - _lookup('NSURLMayHaveExtendedAttributesKey'); - - DartNSURLResourceKey get NSURLMayHaveExtendedAttributesKey => - objc.NSString.fromPointer( - _NSURLMayHaveExtendedAttributesKey.value, - retain: true, - release: true, +extension NSURLSessionWebSocketDelegate$Methods + on NSURLSessionWebSocketDelegate { + /// The last message a session receives. A session will only become + /// invalid because of a systemic error or when it has been + /// explicitly invalidated, in which case the error parameter will be nil. + void URLSession$5( + NSURLSession session, { + objc.NSError? didBecomeInvalidWithError, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:didBecomeInvalidWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:didBecomeInvalidWithError:', ); - - set NSURLMayHaveExtendedAttributesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLMayHaveExtendedAttributesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLMayHaveExtendedAttributesKey.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + session.ref.pointer, + didBecomeInvalidWithError?.ref.pointer ?? ffi.nullptr, + ); } - /// True if the file can be deleted by the file system when asked to free space. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLIsPurgeableKey = - _lookup('NSURLIsPurgeableKey'); - - DartNSURLResourceKey get NSURLIsPurgeableKey => objc.NSString.fromPointer( - _NSURLIsPurgeableKey.value, - retain: true, - release: true, - ); - - set NSURLIsPurgeableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsPurgeableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsPurgeableKey.value = value.ref.retainAndReturnPointer(); - } - - /// True if the file has sparse regions. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLIsSparseKey = - _lookup('NSURLIsSparseKey'); - - DartNSURLResourceKey get NSURLIsSparseKey => objc.NSString.fromPointer( - _NSURLIsSparseKey.value, - retain: true, - release: true, - ); - - set NSURLIsSparseKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsSparseKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsSparseKey.value = value.ref.retainAndReturnPointer(); - } - - /// The file system object type values returned for the NSURLFileResourceTypeKey - late final ffi.Pointer - _NSURLFileResourceTypeNamedPipe = _lookup( - 'NSURLFileResourceTypeNamedPipe', - ); - - DartNSURLFileResourceType get NSURLFileResourceTypeNamedPipe => - objc.NSString.fromPointer( - _NSURLFileResourceTypeNamedPipe.value, - retain: true, - release: true, + /// Notification that a task has been created. This method is the first message + /// a task sends, providing a place to configure the task before it is resumed. + /// + /// This delegate callback is *NOT* dispatched to the delegate queue. It is + /// invoked synchronously before the task creation method returns. + void URLSession$6( + NSURLSession session, { + required NSURLSessionTask didCreateTask, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:didCreateTask:', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didCreateTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:didCreateTask:', ); - - set NSURLFileResourceTypeNamedPipe(DartNSURLFileResourceType value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeNamedPipe.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeNamedPipe.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_didCreateTask_, + session.ref.pointer, + didCreateTask.ref.pointer, + ); } - late final ffi.Pointer - _NSURLFileResourceTypeCharacterSpecial = _lookup( - 'NSURLFileResourceTypeCharacterSpecial', - ); - - DartNSURLFileResourceType get NSURLFileResourceTypeCharacterSpecial => - objc.NSString.fromPointer( - _NSURLFileResourceTypeCharacterSpecial.value, - retain: true, - release: true, + /// If implemented, when a connection level authentication challenge + /// has occurred, this delegate will be given the opportunity to + /// provide authentication credentials to the underlying + /// connection. Some types of authentication will apply to more than + /// one request on a given connection to a server (SSL Server Trust + /// challenges). If this delegate message is not implemented, the + /// behavior will be to use the default handling, which may involve user + /// interaction. + void URLSession$7( + NSURLSession session, { + required NSURLAuthenticationChallenge didReceiveChallenge, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:didReceiveChallenge:completionHandler:', ); - - set NSURLFileResourceTypeCharacterSpecial(DartNSURLFileResourceType value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeCharacterSpecial.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeCharacterSpecial.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_18qun1e( + object$.ref.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + session.ref.pointer, + didReceiveChallenge.ref.pointer, + completionHandler.ref.pointer, + ); } - late final ffi.Pointer - _NSURLFileResourceTypeDirectory = _lookup( - 'NSURLFileResourceTypeDirectory', - ); - - DartNSURLFileResourceType get NSURLFileResourceTypeDirectory => - objc.NSString.fromPointer( - _NSURLFileResourceTypeDirectory.value, - retain: true, - release: true, + /// Sent as the last message related to a specific task. Error may be + /// nil, which implies that no error occurred and this task is complete. + void URLSession$8( + NSURLSession session, { + required NSURLSessionTask task, + objc.NSError? didCompleteWithError, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didCompleteWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didCompleteWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didCompleteWithError:', ); - - set NSURLFileResourceTypeDirectory(DartNSURLFileResourceType value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeDirectory.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeDirectory.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didCompleteWithError_, + session.ref.pointer, + task.ref.pointer, + didCompleteWithError?.ref.pointer ?? ffi.nullptr, + ); } - late final ffi.Pointer - _NSURLFileResourceTypeBlockSpecial = _lookup( - 'NSURLFileResourceTypeBlockSpecial', - ); - - DartNSURLFileResourceType get NSURLFileResourceTypeBlockSpecial => - objc.NSString.fromPointer( - _NSURLFileResourceTypeBlockSpecial.value, - retain: true, - release: true, + /// Sent when complete statistics information has been collected for the task. + void URLSession$9( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLSessionTaskMetrics didFinishCollectingMetrics, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didFinishCollectingMetrics:', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didFinishCollectingMetrics:', ); - - set NSURLFileResourceTypeBlockSpecial(DartNSURLFileResourceType value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeBlockSpecial.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeBlockSpecial.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + session.ref.pointer, + task.ref.pointer, + didFinishCollectingMetrics.ref.pointer, + ); } - late final ffi.Pointer _NSURLFileResourceTypeRegular = - _lookup('NSURLFileResourceTypeRegular'); - - DartNSURLFileResourceType get NSURLFileResourceTypeRegular => - objc.NSString.fromPointer( - _NSURLFileResourceTypeRegular.value, - retain: true, - release: true, + /// The task has received a request specific authentication challenge. + /// If this delegate is not implemented, the session specific authentication challenge + /// will *NOT* be called and the behavior will be the same as using the default handling + /// disposition. + void URLSession$10( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLAuthenticationChallenge didReceiveChallenge, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didReceiveChallenge:completionHandler:', ); - - set NSURLFileResourceTypeRegular(DartNSURLFileResourceType value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeRegular.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeRegular.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_m7tls4( + object$.ref.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + session.ref.pointer, + task.ref.pointer, + didReceiveChallenge.ref.pointer, + completionHandler.ref.pointer, + ); } - late final ffi.Pointer - _NSURLFileResourceTypeSymbolicLink = _lookup( - 'NSURLFileResourceTypeSymbolicLink', - ); - - DartNSURLFileResourceType get NSURLFileResourceTypeSymbolicLink => - objc.NSString.fromPointer( - _NSURLFileResourceTypeSymbolicLink.value, - retain: true, - release: true, + /// Sent for each informational response received except 101 switching protocols. + void URLSession$11( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse didReceiveInformationalResponse, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didReceiveInformationalResponse:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didReceiveInformationalResponse:', ); - - set NSURLFileResourceTypeSymbolicLink(DartNSURLFileResourceType value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeSymbolicLink.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeSymbolicLink.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + session.ref.pointer, + task.ref.pointer, + didReceiveInformationalResponse.ref.pointer, + ); } - late final ffi.Pointer _NSURLFileResourceTypeSocket = - _lookup('NSURLFileResourceTypeSocket'); - - DartNSURLFileResourceType get NSURLFileResourceTypeSocket => - objc.NSString.fromPointer( - _NSURLFileResourceTypeSocket.value, - retain: true, - release: true, + /// Sent periodically to notify the delegate of upload progress. This + /// information is also available as properties of the task. + void URLSession$12( + NSURLSession session, { + required NSURLSessionTask task, + required int didSendBodyData, + required int totalBytesSent, + required int totalBytesExpectedToSend, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', ); - - set NSURLFileResourceTypeSocket(DartNSURLFileResourceType value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeSocket.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeSocket.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_1modw1b( + object$.ref.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + session.ref.pointer, + task.ref.pointer, + didSendBodyData, + totalBytesSent, + totalBytesExpectedToSend, + ); } - late final ffi.Pointer _NSURLFileResourceTypeUnknown = - _lookup('NSURLFileResourceTypeUnknown'); - - DartNSURLFileResourceType get NSURLFileResourceTypeUnknown => - objc.NSString.fromPointer( - _NSURLFileResourceTypeUnknown.value, - retain: true, - release: true, + /// Sent if a task requires a new, unopened body stream. This may be + /// necessary when authentication has failed for any request that + /// involves a body stream. + void URLSession$13( + NSURLSession session, { + required NSURLSessionTask task, + required objc.ObjCBlock + needNewBodyStream, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:needNewBodyStream:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStream_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:needNewBodyStream:', ); - - set NSURLFileResourceTypeUnknown(DartNSURLFileResourceType value) { - objc.NSString.fromPointer( - _NSURLFileResourceTypeUnknown.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileResourceTypeUnknown.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_18qun1e( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStream_, + session.ref.pointer, + task.ref.pointer, + needNewBodyStream.ref.pointer, + ); } - /// dictionary of NSImage/UIImage objects keyed by size - late final ffi.Pointer _NSURLThumbnailDictionaryKey = - _lookup('NSURLThumbnailDictionaryKey'); - - DartNSURLResourceKey get NSURLThumbnailDictionaryKey => - objc.NSString.fromPointer( - _NSURLThumbnailDictionaryKey.value, - retain: true, - release: true, + /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be + /// necessary when resuming a failed upload task. + /// + /// - Parameter session: The session containing the task that needs a new body stream from the given offset. + /// - Parameter task: The task that needs a new body stream. + /// - Parameter offset: The starting offset required for the body stream. + /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. + void URLSession$14( + NSURLSession session, { + required NSURLSessionTask task, + required int needNewBodyStreamFromOffset, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', ); - - set NSURLThumbnailDictionaryKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLThumbnailDictionaryKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLThumbnailDictionaryKey.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_9cddqw( + object$.ref.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + session.ref.pointer, + task.ref.pointer, + needNewBodyStreamFromOffset, + completionHandler.ref.pointer, + ); } - /// returns all thumbnails as a single NSImage - late final ffi.Pointer _NSURLThumbnailKey = - _lookup('NSURLThumbnailKey'); - - DartNSURLResourceKey get NSURLThumbnailKey => objc.NSString.fromPointer( - _NSURLThumbnailKey.value, - retain: true, - release: true, - ); - - set NSURLThumbnailKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLThumbnailKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLThumbnailKey.value = value.ref.retainAndReturnPointer(); + /// Sent when the system is ready to begin work for a task with a delayed start + /// time set (using the earliestBeginDate property). The completionHandler must + /// be invoked in order for loading to proceed. The disposition provided to the + /// completion handler continues the load with the original request provided to + /// the task, replaces the request with the specified task, or cancels the task. + /// If this delegate is not implemented, loading will proceed with the original + /// request. + /// + /// Recommendation: only implement this delegate if tasks that have the + /// earliestBeginDate property set may become stale and require alteration prior + /// to starting the network load. + /// + /// If a new request is specified, the allowsExpensiveNetworkAccess, + /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties + /// from the new request will not be used; the properties from the + /// original request will continue to be used. + /// + /// Canceling the task is equivalent to calling the task's cancel method; the + /// URLSession:task:didCompleteWithError: task delegate will be called with error + /// NSURLErrorCancelled. + void URLSession$15( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLRequest willBeginDelayedRequest, + required objc.ObjCBlock + completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:willBeginDelayedRequest:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + object$.ref.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + session.ref.pointer, + task.ref.pointer, + willBeginDelayedRequest.ref.pointer, + completionHandler.ref.pointer, + ); } - /// size key for a 1024 x 1024 thumbnail image - late final ffi.Pointer - _NSThumbnail1024x1024SizeKey = _lookup( - 'NSThumbnail1024x1024SizeKey', - ); - - DartNSURLThumbnailDictionaryItem get NSThumbnail1024x1024SizeKey => - objc.NSString.fromPointer( - _NSThumbnail1024x1024SizeKey.value, - retain: true, - release: true, + /// An HTTP request is attempting to perform a redirection to a different + /// URL. You must invoke the completion routine to allow the + /// redirection, allow the redirection with a modified request, or + /// pass nil to the completionHandler to cause the body of the redirection + /// response to be delivered as the payload of this request. The default + /// is to follow redirections. + /// + /// For tasks in background sessions, redirections will always be followed and this method will not be called. + void URLSession$16( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse willPerformHTTPRedirection, + required NSURLRequest newRequest, + required objc.ObjCBlock completionHandler, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', ); - - set NSThumbnail1024x1024SizeKey(DartNSURLThumbnailDictionaryItem value) { - objc.NSString.fromPointer( - _NSThumbnail1024x1024SizeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSThumbnail1024x1024SizeKey.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_e1wgee( + object$.ref.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + session.ref.pointer, + task.ref.pointer, + willPerformHTTPRedirection.ref.pointer, + newRequest.ref.pointer, + completionHandler.ref.pointer, + ); } - /// Total file size in bytes (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLFileSizeKey = - _lookup('NSURLFileSizeKey'); - - DartNSURLResourceKey get NSURLFileSizeKey => objc.NSString.fromPointer( - _NSURLFileSizeKey.value, - retain: true, - release: true, - ); - - set NSURLFileSizeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLFileSizeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileSizeKey.value = value.ref.retainAndReturnPointer(); + /// Sent when a task cannot start the network loading process because the current + /// network connectivity is not available or sufficient for the task's request. + /// + /// This delegate will be called at most one time per task, and is only called if + /// the waitsForConnectivity property in the NSURLSessionConfiguration has been + /// set to YES. + /// + /// This delegate callback will never be called for background sessions, because + /// the waitForConnectivity property is ignored by those sessions. + void URLSession$17( + NSURLSession session, { + required NSURLSessionTask taskIsWaitingForConnectivity, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:taskIsWaitingForConnectivity:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:taskIsWaitingForConnectivity:', + ); + } + _objc_msgSend_pfv6jd( + object$.ref.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + session.ref.pointer, + taskIsWaitingForConnectivity.ref.pointer, + ); } - /// Total size allocated on disk for the file in bytes (number of blocks times block size) (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLFileAllocatedSizeKey = - _lookup('NSURLFileAllocatedSizeKey'); - - DartNSURLResourceKey get NSURLFileAllocatedSizeKey => - objc.NSString.fromPointer( - _NSURLFileAllocatedSizeKey.value, - retain: true, - release: true, + /// Indicates that the WebSocket has received a close frame from the server endpoint. + /// The close code and the close reason may be provided by the delegate if the server elects to send + /// this information in the close frame + void URLSession( + NSURLSession session, { + required NSURLSessionWebSocketTask webSocketTask, + required int didCloseWithCode, + objc.NSData? reason, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:webSocketTask:didCloseWithCode:reason:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_webSocketTask_didCloseWithCode_reason_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:webSocketTask:didCloseWithCode:reason:', ); - - set NSURLFileAllocatedSizeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLFileAllocatedSizeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileAllocatedSizeKey.value = value.ref.retainAndReturnPointer(); + } + _objc_msgSend_d9bpjb( + object$.ref.pointer, + _sel_URLSession_webSocketTask_didCloseWithCode_reason_, + session.ref.pointer, + webSocketTask.ref.pointer, + didCloseWithCode, + reason?.ref.pointer ?? ffi.nullptr, + ); } - /// Total displayable size of the file in bytes (this may include space used by metadata), or nil if not available. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLTotalFileSizeKey = - _lookup('NSURLTotalFileSizeKey'); - - DartNSURLResourceKey get NSURLTotalFileSizeKey => objc.NSString.fromPointer( - _NSURLTotalFileSizeKey.value, - retain: true, - release: true, - ); - - set NSURLTotalFileSizeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLTotalFileSizeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLTotalFileSizeKey.value = value.ref.retainAndReturnPointer(); - } - - /// Total allocated size of the file in bytes (this may include space used by metadata), or nil if not available. This can be less than the value returned by NSURLTotalFileSizeKey if the resource is compressed. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLTotalFileAllocatedSizeKey = - _lookup('NSURLTotalFileAllocatedSizeKey'); - - DartNSURLResourceKey get NSURLTotalFileAllocatedSizeKey => - objc.NSString.fromPointer( - _NSURLTotalFileAllocatedSizeKey.value, - retain: true, - release: true, - ); - - set NSURLTotalFileAllocatedSizeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLTotalFileAllocatedSizeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLTotalFileAllocatedSizeKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the resource is a Finder alias file or a symlink, false otherwise ( Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsAliasFileKey = - _lookup('NSURLIsAliasFileKey'); - - DartNSURLResourceKey get NSURLIsAliasFileKey => objc.NSString.fromPointer( - _NSURLIsAliasFileKey.value, - retain: true, - release: true, - ); - - set NSURLIsAliasFileKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsAliasFileKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsAliasFileKey.value = value.ref.retainAndReturnPointer(); - } - - /// The protection level for this file - late final ffi.Pointer _NSURLFileProtectionKey = - _lookup('NSURLFileProtectionKey'); - - DartNSURLResourceKey get NSURLFileProtectionKey => objc.NSString.fromPointer( - _NSURLFileProtectionKey.value, - retain: true, - release: true, - ); - - set NSURLFileProtectionKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLFileProtectionKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileProtectionKey.value = value.ref.retainAndReturnPointer(); - } - - /// The file has no special protections associated with it. It can be read from or written to at any time. - late final ffi.Pointer _NSURLFileProtectionNone = - _lookup('NSURLFileProtectionNone'); - - DartNSURLFileProtectionType get NSURLFileProtectionNone => - objc.NSString.fromPointer( - _NSURLFileProtectionNone.value, - retain: true, - release: true, - ); - - set NSURLFileProtectionNone(DartNSURLFileProtectionType value) { - objc.NSString.fromPointer( - _NSURLFileProtectionNone.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileProtectionNone.value = value.ref.retainAndReturnPointer(); - } - - /// The file is stored in an encrypted format on disk and cannot be read from or written to while the device is locked or booting. Transient data files with this protection type should be excluded from backups using NSURLIsExcludedFromBackupKey. - late final ffi.Pointer _NSURLFileProtectionComplete = - _lookup('NSURLFileProtectionComplete'); - - DartNSURLFileProtectionType get NSURLFileProtectionComplete => - objc.NSString.fromPointer( - _NSURLFileProtectionComplete.value, - retain: true, - release: true, - ); - - set NSURLFileProtectionComplete(DartNSURLFileProtectionType value) { - objc.NSString.fromPointer( - _NSURLFileProtectionComplete.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileProtectionComplete.value = value.ref.retainAndReturnPointer(); - } - - /// The file is stored in an encrypted format on disk. Files can be created while the device is locked, but once closed, cannot be opened again until the device is unlocked. If the file is opened when unlocked, you may continue to access the file normally, even if the user locks the device. There is a small performance penalty when the file is created and opened, though not when being written to or read from. This can be mitigated by changing the file protection to NSURLFileProtectionComplete when the device is unlocked. Transient data files with this protection type should be excluded from backups using NSURLIsExcludedFromBackupKey. - late final ffi.Pointer - _NSURLFileProtectionCompleteUnlessOpen = _lookup( - 'NSURLFileProtectionCompleteUnlessOpen', - ); - - DartNSURLFileProtectionType get NSURLFileProtectionCompleteUnlessOpen => - objc.NSString.fromPointer( - _NSURLFileProtectionCompleteUnlessOpen.value, - retain: true, - release: true, - ); - - set NSURLFileProtectionCompleteUnlessOpen(DartNSURLFileProtectionType value) { - objc.NSString.fromPointer( - _NSURLFileProtectionCompleteUnlessOpen.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileProtectionCompleteUnlessOpen.value = value.ref - .retainAndReturnPointer(); - } - - /// The file is stored in an encrypted format on disk and cannot be accessed until after the device has booted. After the user unlocks the device for the first time, your app can access the file and continue to access it even if the user subsequently locks the device. - late final ffi.Pointer - _NSURLFileProtectionCompleteUntilFirstUserAuthentication = - _lookup( - 'NSURLFileProtectionCompleteUntilFirstUserAuthentication', - ); - - DartNSURLFileProtectionType - get NSURLFileProtectionCompleteUntilFirstUserAuthentication => - objc.NSString.fromPointer( - _NSURLFileProtectionCompleteUntilFirstUserAuthentication.value, - retain: true, - release: true, - ); - - set NSURLFileProtectionCompleteUntilFirstUserAuthentication( - DartNSURLFileProtectionType value, - ) { - objc.NSString.fromPointer( - _NSURLFileProtectionCompleteUntilFirstUserAuthentication.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileProtectionCompleteUntilFirstUserAuthentication.value = value.ref - .retainAndReturnPointer(); - } - - /// The file is stored in an encrypted format on disk and cannot be accessed until after first unlock after the device has booted. After this first unlock, your app can access the file even while the device is locked until access expiry. Access is renewed once the user unlocks the device again. - late final ffi.Pointer - _NSURLFileProtectionCompleteWhenUserInactive = - _lookup( - 'NSURLFileProtectionCompleteWhenUserInactive', - ); - - DartNSURLFileProtectionType get NSURLFileProtectionCompleteWhenUserInactive => - objc.NSString.fromPointer( - _NSURLFileProtectionCompleteWhenUserInactive.value, - retain: true, - release: true, - ); - - set NSURLFileProtectionCompleteWhenUserInactive( - DartNSURLFileProtectionType value, - ) { - objc.NSString.fromPointer( - _NSURLFileProtectionCompleteWhenUserInactive.value, - retain: false, - release: true, - ).ref.release(); - _NSURLFileProtectionCompleteWhenUserInactive.value = value.ref - .retainAndReturnPointer(); - } - - /// Returns the count of file system objects contained in the directory. This is a count of objects actually stored in the file system, so excludes virtual items like "." and "..". The property is useful for quickly identifying an empty directory for backup and syncing. If the URL is not a directory or the file system cannot cheaply compute the value, `nil` is returned. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLDirectoryEntryCountKey = - _lookup('NSURLDirectoryEntryCountKey'); - - DartNSURLResourceKey get NSURLDirectoryEntryCountKey => - objc.NSString.fromPointer( - _NSURLDirectoryEntryCountKey.value, - retain: true, - release: true, - ); - - set NSURLDirectoryEntryCountKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLDirectoryEntryCountKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLDirectoryEntryCountKey.value = value.ref.retainAndReturnPointer(); - } - - /// The user-visible volume format (Read-only, value type NSString) - late final ffi.Pointer - _NSURLVolumeLocalizedFormatDescriptionKey = _lookup( - 'NSURLVolumeLocalizedFormatDescriptionKey', - ); - - DartNSURLResourceKey get NSURLVolumeLocalizedFormatDescriptionKey => - objc.NSString.fromPointer( - _NSURLVolumeLocalizedFormatDescriptionKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeLocalizedFormatDescriptionKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeLocalizedFormatDescriptionKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeLocalizedFormatDescriptionKey.value = value.ref - .retainAndReturnPointer(); - } - - /// Total volume capacity in bytes (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLVolumeTotalCapacityKey = - _lookup('NSURLVolumeTotalCapacityKey'); - - DartNSURLResourceKey get NSURLVolumeTotalCapacityKey => - objc.NSString.fromPointer( - _NSURLVolumeTotalCapacityKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeTotalCapacityKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeTotalCapacityKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeTotalCapacityKey.value = value.ref.retainAndReturnPointer(); - } - - /// Total free space in bytes (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLVolumeAvailableCapacityKey = - _lookup('NSURLVolumeAvailableCapacityKey'); - - DartNSURLResourceKey get NSURLVolumeAvailableCapacityKey => - objc.NSString.fromPointer( - _NSURLVolumeAvailableCapacityKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeAvailableCapacityKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeAvailableCapacityKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeAvailableCapacityKey.value = value.ref.retainAndReturnPointer(); - } - - /// Total number of resources on the volume (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLVolumeResourceCountKey = - _lookup('NSURLVolumeResourceCountKey'); - - DartNSURLResourceKey get NSURLVolumeResourceCountKey => - objc.NSString.fromPointer( - _NSURLVolumeResourceCountKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeResourceCountKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeResourceCountKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeResourceCountKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume format supports persistent object identifiers and can look up file system objects by their IDs (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsPersistentIDsKey = _lookup( - 'NSURLVolumeSupportsPersistentIDsKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsPersistentIDsKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsPersistentIDsKey.value, - retain: true, - release: true, + /// Indicates that the WebSocket handshake was successful and the connection has been upgraded to webSockets. + /// It will also provide the protocol that is picked in the handshake. If the handshake fails, this delegate will not be invoked. + void URLSession$1( + NSURLSession session, { + required NSURLSessionWebSocketTask webSocketTask, + objc.NSString? didOpenWithProtocol, + }) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:webSocketTask:didOpenWithProtocol:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSession_webSocketTask_didOpenWithProtocol_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:webSocketTask:didOpenWithProtocol:', ); - - set NSURLVolumeSupportsPersistentIDsKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsPersistentIDsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsPersistentIDsKey.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_r8gdi7( + object$.ref.pointer, + _sel_URLSession_webSocketTask_didOpenWithProtocol_, + session.ref.pointer, + webSocketTask.ref.pointer, + didOpenWithProtocol?.ref.pointer ?? ffi.nullptr, + ); } - /// true if the volume format supports symbolic links (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsSymbolicLinksKey = _lookup( - 'NSURLVolumeSupportsSymbolicLinksKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsSymbolicLinksKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsSymbolicLinksKey.value, - retain: true, - release: true, + /// If an application has received an + /// -application:handleEventsForBackgroundURLSession:completionHandler: + /// message, the session delegate will receive this message to indicate + /// that all messages previously enqueued for this session have been + /// delivered. At this time it is safe to invoke the previously stored + /// completion handler, or to begin any internal updates that will + /// result in invoking the completion handler. + void URLSessionDidFinishEventsForBackgroundURLSession(NSURLSession session) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), + ); + if (!objc.respondsToSelector( + object$.ref.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSessionDidFinishEventsForBackgroundURLSession:', ); - - set NSURLVolumeSupportsSymbolicLinksKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsSymbolicLinksKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsSymbolicLinksKey.value = value.ref - .retainAndReturnPointer(); + } + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + session.ref.pointer, + ); } +} - /// true if the volume format supports hard links (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsHardLinksKey = - _lookup('NSURLVolumeSupportsHardLinksKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsHardLinksKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsHardLinksKey.value, - retain: true, - release: true, - ); +interface class NSURLSessionWebSocketDelegate$Builder { + /// Returns the [objc.Protocol] object for this protocol. + static objc.Protocol get $protocol => + objc.Protocol.fromPointer(_protocol_NSURLSessionWebSocketDelegate.cast()); - set NSURLVolumeSupportsHardLinksKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsHardLinksKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsHardLinksKey.value = value.ref.retainAndReturnPointer(); + /// Builds an object that implements the NSURLSessionWebSocketDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionWebSocketDelegate implement({ + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession, NSURLSessionWebSocketTask, int, objc.NSData?)? + URLSession_webSocketTask_didCloseWithCode_reason_, + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? + URLSession_webSocketTask_didOpenWithProtocol_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionWebSocketDelegate', + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionWebSocketDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didCompleteWithError_.implement( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implement( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implement( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStream_.implement( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implement( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didCloseWithCode_reason_.implement( + builder, + URLSession_webSocketTask_didCloseWithCode_reason_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didOpenWithProtocol_.implement( + builder, + URLSession_webSocketTask_didOpenWithProtocol_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implement( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionWebSocketDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); } - /// true if the volume format supports a journal used to speed recovery in case of unplanned restart (such as a power outage or crash). This does not necessarily mean the volume is actively using a journal. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsJournalingKey = - _lookup('NSURLVolumeSupportsJournalingKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsJournalingKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsJournalingKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsJournalingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsJournalingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsJournalingKey.value = value.ref - .retainAndReturnPointer(); + /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilder( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession, NSURLSessionWebSocketTask, int, objc.NSData?)? + URLSession_webSocketTask_didCloseWithCode_reason_, + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? + URLSession_webSocketTask_didOpenWithProtocol_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionWebSocketDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didCompleteWithError_.implement( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implement( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implement( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStream_.implement( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implement( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didCloseWithCode_reason_.implement( + builder, + URLSession_webSocketTask_didCloseWithCode_reason_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didOpenWithProtocol_.implement( + builder, + URLSession_webSocketTask_didOpenWithProtocol_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implement( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); } - /// true if the volume is currently using a journal for speedy recovery after an unplanned restart. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsJournalingKey = - _lookup('NSURLVolumeIsJournalingKey'); - - DartNSURLResourceKey get NSURLVolumeIsJournalingKey => - objc.NSString.fromPointer( - _NSURLVolumeIsJournalingKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsJournalingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsJournalingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsJournalingKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume format supports sparse files, that is, files which can have 'holes' that have never been written to, and thus do not consume space on disk. A sparse file may have an allocated size on disk that is less than its logical length (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsSparseFilesKey = - _lookup('NSURLVolumeSupportsSparseFilesKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsSparseFilesKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsSparseFilesKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsSparseFilesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsSparseFilesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsSparseFilesKey.value = value.ref - .retainAndReturnPointer(); - } - - /// For security reasons, parts of a file (runs) that have never been written to must appear to contain zeroes. true if the volume keeps track of allocated but unwritten runs of a file so that it can substitute zeroes without actually writing zeroes to the media. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsZeroRunsKey = - _lookup('NSURLVolumeSupportsZeroRunsKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsZeroRunsKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsZeroRunsKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsZeroRunsKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsZeroRunsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsZeroRunsKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume format treats upper and lower case characters in file and directory names as different. Otherwise an upper case character is equivalent to a lower case character, and you can't have two names that differ solely in the case of the characters. (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsCaseSensitiveNamesKey = _lookup( - 'NSURLVolumeSupportsCaseSensitiveNamesKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsCaseSensitiveNamesKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsCaseSensitiveNamesKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsCaseSensitiveNamesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsCaseSensitiveNamesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsCaseSensitiveNamesKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume format preserves the case of file and directory names. Otherwise the volume may change the case of some characters (typically making them all upper or all lower case). (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsCasePreservedNamesKey = _lookup( - 'NSURLVolumeSupportsCasePreservedNamesKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsCasePreservedNamesKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsCasePreservedNamesKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsCasePreservedNamesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsCasePreservedNamesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsCasePreservedNamesKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume supports reliable storage of times for the root directory. (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsRootDirectoryDatesKey = _lookup( - 'NSURLVolumeSupportsRootDirectoryDatesKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsRootDirectoryDatesKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsRootDirectoryDatesKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsRootDirectoryDatesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsRootDirectoryDatesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsRootDirectoryDatesKey.value = value.ref - .retainAndReturnPointer(); + /// Builds an object that implements the NSURLSessionWebSocketDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionWebSocketDelegate implementAsListener({ + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession, NSURLSessionWebSocketTask, int, objc.NSData?)? + URLSession_webSocketTask_didCloseWithCode_reason_, + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? + URLSession_webSocketTask_didOpenWithProtocol_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionWebSocketDelegate', + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsListener( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didCloseWithCode_reason_.implementAsListener( + builder, + URLSession_webSocketTask_didCloseWithCode_reason_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didOpenWithProtocol_.implementAsListener( + builder, + URLSession_webSocketTask_didOpenWithProtocol_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionWebSocketDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); } - /// true if the volume supports returning volume size values (NSURLVolumeTotalCapacityKey and NSURLVolumeAvailableCapacityKey). (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsVolumeSizesKey = - _lookup('NSURLVolumeSupportsVolumeSizesKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsVolumeSizesKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsVolumeSizesKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsVolumeSizesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsVolumeSizesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsVolumeSizesKey.value = value.ref - .retainAndReturnPointer(); + /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will + /// be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsListener( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession, NSURLSessionWebSocketTask, int, objc.NSData?)? + URLSession_webSocketTask_didCloseWithCode_reason_, + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? + URLSession_webSocketTask_didOpenWithProtocol_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsListener( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didCloseWithCode_reason_.implementAsListener( + builder, + URLSession_webSocketTask_didCloseWithCode_reason_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didOpenWithProtocol_.implementAsListener( + builder, + URLSession_webSocketTask_didOpenWithProtocol_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); } - /// true if the volume can be renamed. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsRenamingKey = - _lookup('NSURLVolumeSupportsRenamingKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsRenamingKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsRenamingKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsRenamingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsRenamingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsRenamingKey.value = value.ref.retainAndReturnPointer(); + /// Builds an object that implements the NSURLSessionWebSocketDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as blocking listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static NSURLSessionWebSocketDelegate implementAsBlocking({ + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession, NSURLSessionWebSocketTask, int, objc.NSData?)? + URLSession_webSocketTask_didCloseWithCode_reason_, + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? + URLSession_webSocketTask_didOpenWithProtocol_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionWebSocketDelegate', + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsBlocking( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didCloseWithCode_reason_.implementAsBlocking( + builder, + URLSession_webSocketTask_didCloseWithCode_reason_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didOpenWithProtocol_.implementAsBlocking( + builder, + URLSession_webSocketTask_didOpenWithProtocol_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionWebSocketDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); } - /// true if the volume implements whole-file flock(2) style advisory locks, and the O_EXLOCK and O_SHLOCK flags of the open(2) call. (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsAdvisoryFileLockingKey = _lookup( - 'NSURLVolumeSupportsAdvisoryFileLockingKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsAdvisoryFileLockingKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsAdvisoryFileLockingKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsAdvisoryFileLockingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsAdvisoryFileLockingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsAdvisoryFileLockingKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume implements extended security (ACLs). (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsExtendedSecurityKey = _lookup( - 'NSURLVolumeSupportsExtendedSecurityKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsExtendedSecurityKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsExtendedSecurityKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsExtendedSecurityKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsExtendedSecurityKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsExtendedSecurityKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume should be visible via the GUI (i.e., appear on the Desktop as a separate volume). (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsBrowsableKey = - _lookup('NSURLVolumeIsBrowsableKey'); - - DartNSURLResourceKey get NSURLVolumeIsBrowsableKey => - objc.NSString.fromPointer( - _NSURLVolumeIsBrowsableKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsBrowsableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsBrowsableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsBrowsableKey.value = value.ref.retainAndReturnPointer(); - } - - /// The largest file size (in bytes) supported by this file system, or nil if this cannot be determined. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLVolumeMaximumFileSizeKey = - _lookup('NSURLVolumeMaximumFileSizeKey'); - - DartNSURLResourceKey get NSURLVolumeMaximumFileSizeKey => - objc.NSString.fromPointer( - _NSURLVolumeMaximumFileSizeKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeMaximumFileSizeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeMaximumFileSizeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeMaximumFileSizeKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume's media is ejectable from the drive mechanism under software control. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsEjectableKey = - _lookup('NSURLVolumeIsEjectableKey'); - - DartNSURLResourceKey get NSURLVolumeIsEjectableKey => - objc.NSString.fromPointer( - _NSURLVolumeIsEjectableKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsEjectableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsEjectableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsEjectableKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume's media is removable from the drive mechanism. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsRemovableKey = - _lookup('NSURLVolumeIsRemovableKey'); - - DartNSURLResourceKey get NSURLVolumeIsRemovableKey => - objc.NSString.fromPointer( - _NSURLVolumeIsRemovableKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsRemovableKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsRemovableKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsRemovableKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume's device is connected to an internal bus, false if connected to an external bus, or nil if not available. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsInternalKey = - _lookup('NSURLVolumeIsInternalKey'); - - DartNSURLResourceKey get NSURLVolumeIsInternalKey => - objc.NSString.fromPointer( - _NSURLVolumeIsInternalKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsInternalKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsInternalKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsInternalKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume is automounted. Note: do not mistake this with the functionality provided by kCFURLVolumeSupportsBrowsingKey. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsAutomountedKey = - _lookup('NSURLVolumeIsAutomountedKey'); - - DartNSURLResourceKey get NSURLVolumeIsAutomountedKey => - objc.NSString.fromPointer( - _NSURLVolumeIsAutomountedKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsAutomountedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsAutomountedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsAutomountedKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume is stored on a local device. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsLocalKey = - _lookup('NSURLVolumeIsLocalKey'); - - DartNSURLResourceKey get NSURLVolumeIsLocalKey => objc.NSString.fromPointer( - _NSURLVolumeIsLocalKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsLocalKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsLocalKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsLocalKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume is read-only. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsReadOnlyKey = - _lookup('NSURLVolumeIsReadOnlyKey'); - - DartNSURLResourceKey get NSURLVolumeIsReadOnlyKey => - objc.NSString.fromPointer( - _NSURLVolumeIsReadOnlyKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsReadOnlyKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsReadOnlyKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsReadOnlyKey.value = value.ref.retainAndReturnPointer(); - } - - /// The volume's creation date, or nil if this cannot be determined. (Read-only, value type NSDate) - late final ffi.Pointer _NSURLVolumeCreationDateKey = - _lookup('NSURLVolumeCreationDateKey'); - - DartNSURLResourceKey get NSURLVolumeCreationDateKey => - objc.NSString.fromPointer( - _NSURLVolumeCreationDateKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeCreationDateKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeCreationDateKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeCreationDateKey.value = value.ref.retainAndReturnPointer(); - } - - /// The NSURL needed to remount a network volume, or nil if not available. (Read-only, value type NSURL) - late final ffi.Pointer _NSURLVolumeURLForRemountingKey = - _lookup('NSURLVolumeURLForRemountingKey'); - - DartNSURLResourceKey get NSURLVolumeURLForRemountingKey => - objc.NSString.fromPointer( - _NSURLVolumeURLForRemountingKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeURLForRemountingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeURLForRemountingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeURLForRemountingKey.value = value.ref.retainAndReturnPointer(); - } - - /// The volume's persistent UUID as a string, or nil if a persistent UUID is not available for the volume. (Read-only, value type NSString) - late final ffi.Pointer _NSURLVolumeUUIDStringKey = - _lookup('NSURLVolumeUUIDStringKey'); - - DartNSURLResourceKey get NSURLVolumeUUIDStringKey => - objc.NSString.fromPointer( - _NSURLVolumeUUIDStringKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeUUIDStringKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeUUIDStringKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeUUIDStringKey.value = value.ref.retainAndReturnPointer(); - } - - /// The name of the volume (Read-write if NSURLVolumeSupportsRenamingKey is YES, otherwise read-only, value type NSString) - late final ffi.Pointer _NSURLVolumeNameKey = - _lookup('NSURLVolumeNameKey'); - - DartNSURLResourceKey get NSURLVolumeNameKey => objc.NSString.fromPointer( - _NSURLVolumeNameKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeNameKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeNameKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeNameKey.value = value.ref.retainAndReturnPointer(); - } - - /// The user-presentable name of the volume (Read-only, value type NSString) - late final ffi.Pointer _NSURLVolumeLocalizedNameKey = - _lookup('NSURLVolumeLocalizedNameKey'); - - DartNSURLResourceKey get NSURLVolumeLocalizedNameKey => - objc.NSString.fromPointer( - _NSURLVolumeLocalizedNameKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeLocalizedNameKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeLocalizedNameKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeLocalizedNameKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume is encrypted. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsEncryptedKey = - _lookup('NSURLVolumeIsEncryptedKey'); - - DartNSURLResourceKey get NSURLVolumeIsEncryptedKey => - objc.NSString.fromPointer( - _NSURLVolumeIsEncryptedKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsEncryptedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsEncryptedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsEncryptedKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume is the root filesystem. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeIsRootFileSystemKey = - _lookup('NSURLVolumeIsRootFileSystemKey'); - - DartNSURLResourceKey get NSURLVolumeIsRootFileSystemKey => - objc.NSString.fromPointer( - _NSURLVolumeIsRootFileSystemKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeIsRootFileSystemKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeIsRootFileSystemKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeIsRootFileSystemKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if the volume supports transparent decompression of compressed files using decmpfs. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsCompressionKey = - _lookup('NSURLVolumeSupportsCompressionKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsCompressionKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsCompressionKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsCompressionKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsCompressionKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsCompressionKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume supports clonefile(2) (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsFileCloningKey = - _lookup('NSURLVolumeSupportsFileCloningKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsFileCloningKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsFileCloningKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsFileCloningKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsFileCloningKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsFileCloningKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume supports renamex_np(2)'s RENAME_SWAP option (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLVolumeSupportsSwapRenamingKey = - _lookup('NSURLVolumeSupportsSwapRenamingKey'); - - DartNSURLResourceKey get NSURLVolumeSupportsSwapRenamingKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsSwapRenamingKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsSwapRenamingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsSwapRenamingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsSwapRenamingKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume supports renamex_np(2)'s RENAME_EXCL option (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsExclusiveRenamingKey = _lookup( - 'NSURLVolumeSupportsExclusiveRenamingKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsExclusiveRenamingKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsExclusiveRenamingKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsExclusiveRenamingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsExclusiveRenamingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsExclusiveRenamingKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume supports making files immutable with the NSURLIsUserImmutableKey or NSURLIsSystemImmutableKey properties (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsImmutableFilesKey = _lookup( - 'NSURLVolumeSupportsImmutableFilesKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsImmutableFilesKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsImmutableFilesKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsImmutableFilesKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsImmutableFilesKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsImmutableFilesKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the volume supports setting POSIX access permissions with the NSURLFileSecurityKey property (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsAccessPermissionsKey = _lookup( - 'NSURLVolumeSupportsAccessPermissionsKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsAccessPermissionsKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsAccessPermissionsKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsAccessPermissionsKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsAccessPermissionsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsAccessPermissionsKey.value = value.ref - .retainAndReturnPointer(); - } - - /// True if the volume supports the File Protection attribute (see NSURLFileProtectionKey). (Read-only, value type NSNumber) - late final ffi.Pointer - _NSURLVolumeSupportsFileProtectionKey = _lookup( - 'NSURLVolumeSupportsFileProtectionKey', - ); - - DartNSURLResourceKey get NSURLVolumeSupportsFileProtectionKey => - objc.NSString.fromPointer( - _NSURLVolumeSupportsFileProtectionKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSupportsFileProtectionKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSupportsFileProtectionKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSupportsFileProtectionKey.value = value.ref - .retainAndReturnPointer(); - } - - /// (Read-only, value type NSNumber) - late final ffi.Pointer - _NSURLVolumeAvailableCapacityForImportantUsageKey = _lookup( - 'NSURLVolumeAvailableCapacityForImportantUsageKey', - ); - - DartNSURLResourceKey get NSURLVolumeAvailableCapacityForImportantUsageKey => - objc.NSString.fromPointer( - _NSURLVolumeAvailableCapacityForImportantUsageKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeAvailableCapacityForImportantUsageKey( - DartNSURLResourceKey value, - ) { - objc.NSString.fromPointer( - _NSURLVolumeAvailableCapacityForImportantUsageKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeAvailableCapacityForImportantUsageKey.value = value.ref - .retainAndReturnPointer(); - } - - /// (Read-only, value type NSNumber) - late final ffi.Pointer - _NSURLVolumeAvailableCapacityForOpportunisticUsageKey = - _lookup( - 'NSURLVolumeAvailableCapacityForOpportunisticUsageKey', - ); - - DartNSURLResourceKey - get NSURLVolumeAvailableCapacityForOpportunisticUsageKey => - objc.NSString.fromPointer( - _NSURLVolumeAvailableCapacityForOpportunisticUsageKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeAvailableCapacityForOpportunisticUsageKey( - DartNSURLResourceKey value, - ) { - objc.NSString.fromPointer( - _NSURLVolumeAvailableCapacityForOpportunisticUsageKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeAvailableCapacityForOpportunisticUsageKey.value = value.ref - .retainAndReturnPointer(); - } - - /// The name of the file system type. (Read-only, value type NSString) - late final ffi.Pointer _NSURLVolumeTypeNameKey = - _lookup('NSURLVolumeTypeNameKey'); - - DartNSURLResourceKey get NSURLVolumeTypeNameKey => objc.NSString.fromPointer( - _NSURLVolumeTypeNameKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeTypeNameKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeTypeNameKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeTypeNameKey.value = value.ref.retainAndReturnPointer(); - } - - /// The file system subtype value. (Read-only, value type NSNumber) - late final ffi.Pointer _NSURLVolumeSubtypeKey = - _lookup('NSURLVolumeSubtypeKey'); - - DartNSURLResourceKey get NSURLVolumeSubtypeKey => objc.NSString.fromPointer( - _NSURLVolumeSubtypeKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeSubtypeKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeSubtypeKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeSubtypeKey.value = value.ref.retainAndReturnPointer(); - } - - /// The volume mounted from location. (Read-only, value type NSString) - late final ffi.Pointer _NSURLVolumeMountFromLocationKey = - _lookup('NSURLVolumeMountFromLocationKey'); - - DartNSURLResourceKey get NSURLVolumeMountFromLocationKey => - objc.NSString.fromPointer( - _NSURLVolumeMountFromLocationKey.value, - retain: true, - release: true, - ); - - set NSURLVolumeMountFromLocationKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLVolumeMountFromLocationKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLVolumeMountFromLocationKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if this item is synced to the cloud, false if it is only a local file. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLIsUbiquitousItemKey = - _lookup('NSURLIsUbiquitousItemKey'); - - DartNSURLResourceKey get NSURLIsUbiquitousItemKey => - objc.NSString.fromPointer( - _NSURLIsUbiquitousItemKey.value, - retain: true, - release: true, - ); - - set NSURLIsUbiquitousItemKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLIsUbiquitousItemKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLIsUbiquitousItemKey.value = value.ref.retainAndReturnPointer(); - } - - /// true if this item has conflicts outstanding. (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLUbiquitousItemHasUnresolvedConflictsKey = _lookup( - 'NSURLUbiquitousItemHasUnresolvedConflictsKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemHasUnresolvedConflictsKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemHasUnresolvedConflictsKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemHasUnresolvedConflictsKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemHasUnresolvedConflictsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemHasUnresolvedConflictsKey.value = value.ref - .retainAndReturnPointer(); - } - - /// equivalent to NSURLUbiquitousItemDownloadingStatusKey == NSURLUbiquitousItemDownloadingStatusCurrent. Has never behaved as documented in earlier releases, hence deprecated. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLUbiquitousItemIsDownloadedKey = - _lookup('NSURLUbiquitousItemIsDownloadedKey'); - - DartNSURLResourceKey get NSURLUbiquitousItemIsDownloadedKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsDownloadedKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemIsDownloadedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsDownloadedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemIsDownloadedKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if data is being downloaded for this item. (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLUbiquitousItemIsDownloadingKey = _lookup( - 'NSURLUbiquitousItemIsDownloadingKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemIsDownloadingKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsDownloadingKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemIsDownloadingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsDownloadingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemIsDownloadingKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if there is data present in the cloud for this item. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLUbiquitousItemIsUploadedKey = - _lookup('NSURLUbiquitousItemIsUploadedKey'); - - DartNSURLResourceKey get NSURLUbiquitousItemIsUploadedKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsUploadedKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemIsUploadedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsUploadedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemIsUploadedKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if data is being uploaded for this item. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLUbiquitousItemIsUploadingKey = - _lookup('NSURLUbiquitousItemIsUploadingKey'); - - DartNSURLResourceKey get NSURLUbiquitousItemIsUploadingKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsUploadingKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemIsUploadingKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsUploadingKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemIsUploadingKey.value = value.ref - .retainAndReturnPointer(); - } - - /// Use NSMetadataQuery and NSMetadataUbiquitousItemPercentDownloadedKey on NSMetadataItem instead - late final ffi.Pointer - _NSURLUbiquitousItemPercentDownloadedKey = _lookup( - 'NSURLUbiquitousItemPercentDownloadedKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemPercentDownloadedKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemPercentDownloadedKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemPercentDownloadedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemPercentDownloadedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemPercentDownloadedKey.value = value.ref - .retainAndReturnPointer(); - } - - /// Use NSMetadataQuery and NSMetadataUbiquitousItemPercentUploadedKey on NSMetadataItem instead - late final ffi.Pointer - _NSURLUbiquitousItemPercentUploadedKey = _lookup( - 'NSURLUbiquitousItemPercentUploadedKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemPercentUploadedKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemPercentUploadedKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemPercentUploadedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemPercentUploadedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemPercentUploadedKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns the download status of this item. (Read-only, value type NSString). Possible values below. - late final ffi.Pointer - _NSURLUbiquitousItemDownloadingStatusKey = _lookup( - 'NSURLUbiquitousItemDownloadingStatusKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemDownloadingStatusKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingStatusKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemDownloadingStatusKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingStatusKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemDownloadingStatusKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns the error when downloading the item from iCloud failed, see the NSUbiquitousFile section in FoundationErrors.h (Read-only, value type NSError) - late final ffi.Pointer - _NSURLUbiquitousItemDownloadingErrorKey = _lookup( - 'NSURLUbiquitousItemDownloadingErrorKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemDownloadingErrorKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingErrorKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemDownloadingErrorKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemDownloadingErrorKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns the error when uploading the item to iCloud failed, see the NSUbiquitousFile section in FoundationErrors.h (Read-only, value type NSError) - late final ffi.Pointer - _NSURLUbiquitousItemUploadingErrorKey = _lookup( - 'NSURLUbiquitousItemUploadingErrorKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemUploadingErrorKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemUploadingErrorKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemUploadingErrorKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemUploadingErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemUploadingErrorKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns whether a download of this item has already been requested with an API like -startDownloadingUbiquitousItemAtURL:error: (Read-only, value type boolean NSNumber) - late final ffi.Pointer - _NSURLUbiquitousItemDownloadRequestedKey = _lookup( - 'NSURLUbiquitousItemDownloadRequestedKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemDownloadRequestedKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadRequestedKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemDownloadRequestedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadRequestedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemDownloadRequestedKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns the name of this item's container as displayed to users. - late final ffi.Pointer - _NSURLUbiquitousItemContainerDisplayNameKey = _lookup( - 'NSURLUbiquitousItemContainerDisplayNameKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemContainerDisplayNameKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemContainerDisplayNameKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemContainerDisplayNameKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemContainerDisplayNameKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemContainerDisplayNameKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the item is excluded from sync, which means it is locally on disk but won't be available on the server. An excluded item is no longer ubiquitous. (Read-write, value type boolean NSNumber - late final ffi.Pointer - _NSURLUbiquitousItemIsExcludedFromSyncKey = _lookup( - 'NSURLUbiquitousItemIsExcludedFromSyncKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemIsExcludedFromSyncKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsExcludedFromSyncKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemIsExcludedFromSyncKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsExcludedFromSyncKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemIsExcludedFromSyncKey.value = value.ref - .retainAndReturnPointer(); - } - - /// true if the ubiquitous item is shared. (Read-only, value type boolean NSNumber) - late final ffi.Pointer _NSURLUbiquitousItemIsSharedKey = - _lookup('NSURLUbiquitousItemIsSharedKey'); - - DartNSURLResourceKey get NSURLUbiquitousItemIsSharedKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsSharedKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemIsSharedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsSharedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemIsSharedKey.value = value.ref.retainAndReturnPointer(); - } - - /// returns the current user's role for this shared item, or nil if not shared. (Read-only, value type NSString). Possible values below. - late final ffi.Pointer - _NSURLUbiquitousSharedItemCurrentUserRoleKey = _lookup( - 'NSURLUbiquitousSharedItemCurrentUserRoleKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousSharedItemCurrentUserRoleKey => - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemCurrentUserRoleKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousSharedItemCurrentUserRoleKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemCurrentUserRoleKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousSharedItemCurrentUserRoleKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns the permissions for the current user, or nil if not shared. (Read-only, value type NSString). Possible values below. - late final ffi.Pointer - _NSURLUbiquitousSharedItemCurrentUserPermissionsKey = - _lookup( - 'NSURLUbiquitousSharedItemCurrentUserPermissionsKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousSharedItemCurrentUserPermissionsKey => - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemCurrentUserPermissionsKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousSharedItemCurrentUserPermissionsKey( - DartNSURLResourceKey value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemCurrentUserPermissionsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousSharedItemCurrentUserPermissionsKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns a NSPersonNameComponents, or nil if the current user. (Read-only, value type NSPersonNameComponents) - late final ffi.Pointer - _NSURLUbiquitousSharedItemOwnerNameComponentsKey = _lookup( - 'NSURLUbiquitousSharedItemOwnerNameComponentsKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousSharedItemOwnerNameComponentsKey => - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemOwnerNameComponentsKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousSharedItemOwnerNameComponentsKey( - DartNSURLResourceKey value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemOwnerNameComponentsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousSharedItemOwnerNameComponentsKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns a NSPersonNameComponents for the most recent editor of the document, or nil if it is the current user. (Read-only, value type NSPersonNameComponents) - late final ffi.Pointer - _NSURLUbiquitousSharedItemMostRecentEditorNameComponentsKey = - _lookup( - 'NSURLUbiquitousSharedItemMostRecentEditorNameComponentsKey', - ); - - DartNSURLResourceKey - get NSURLUbiquitousSharedItemMostRecentEditorNameComponentsKey => - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemMostRecentEditorNameComponentsKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousSharedItemMostRecentEditorNameComponentsKey( - DartNSURLResourceKey value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemMostRecentEditorNameComponentsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousSharedItemMostRecentEditorNameComponentsKey.value = value - .ref - .retainAndReturnPointer(); - } - - /// this item has not been downloaded yet. Use startDownloadingUbiquitousItemAtURL:error: to download it. - late final ffi.Pointer - _NSURLUbiquitousItemDownloadingStatusNotDownloaded = - _lookup( - 'NSURLUbiquitousItemDownloadingStatusNotDownloaded', - ); - - DartNSURLUbiquitousItemDownloadingStatus - get NSURLUbiquitousItemDownloadingStatusNotDownloaded => - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingStatusNotDownloaded.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemDownloadingStatusNotDownloaded( - DartNSURLUbiquitousItemDownloadingStatus value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingStatusNotDownloaded.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemDownloadingStatusNotDownloaded.value = value.ref - .retainAndReturnPointer(); - } - - /// there is a local version of this item available. The most current version will get downloaded as soon as possible. - late final ffi.Pointer - _NSURLUbiquitousItemDownloadingStatusDownloaded = - _lookup( - 'NSURLUbiquitousItemDownloadingStatusDownloaded', - ); - - DartNSURLUbiquitousItemDownloadingStatus - get NSURLUbiquitousItemDownloadingStatusDownloaded => - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingStatusDownloaded.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemDownloadingStatusDownloaded( - DartNSURLUbiquitousItemDownloadingStatus value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingStatusDownloaded.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemDownloadingStatusDownloaded.value = value.ref - .retainAndReturnPointer(); - } - - /// there is a local version of this item and it is the most up-to-date version known to this device. - late final ffi.Pointer - _NSURLUbiquitousItemDownloadingStatusCurrent = - _lookup( - 'NSURLUbiquitousItemDownloadingStatusCurrent', - ); - - DartNSURLUbiquitousItemDownloadingStatus - get NSURLUbiquitousItemDownloadingStatusCurrent => objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingStatusCurrent.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemDownloadingStatusCurrent( - DartNSURLUbiquitousItemDownloadingStatus value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemDownloadingStatusCurrent.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemDownloadingStatusCurrent.value = value.ref - .retainAndReturnPointer(); - } - - /// the current user is the owner of this shared item. - late final ffi.Pointer - _NSURLUbiquitousSharedItemRoleOwner = _lookup( - 'NSURLUbiquitousSharedItemRoleOwner', - ); - - DartNSURLUbiquitousSharedItemRole get NSURLUbiquitousSharedItemRoleOwner => - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemRoleOwner.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousSharedItemRoleOwner( - DartNSURLUbiquitousSharedItemRole value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemRoleOwner.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousSharedItemRoleOwner.value = value.ref - .retainAndReturnPointer(); - } - - /// the current user is a participant of this shared item. - late final ffi.Pointer - _NSURLUbiquitousSharedItemRoleParticipant = - _lookup( - 'NSURLUbiquitousSharedItemRoleParticipant', - ); - - DartNSURLUbiquitousSharedItemRole - get NSURLUbiquitousSharedItemRoleParticipant => objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemRoleParticipant.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousSharedItemRoleParticipant( - DartNSURLUbiquitousSharedItemRole value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemRoleParticipant.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousSharedItemRoleParticipant.value = value.ref - .retainAndReturnPointer(); - } - - /// the current user is only allowed to read this item - late final ffi.Pointer - _NSURLUbiquitousSharedItemPermissionsReadOnly = - _lookup( - 'NSURLUbiquitousSharedItemPermissionsReadOnly', - ); - - DartNSURLUbiquitousSharedItemPermissions - get NSURLUbiquitousSharedItemPermissionsReadOnly => objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemPermissionsReadOnly.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousSharedItemPermissionsReadOnly( - DartNSURLUbiquitousSharedItemPermissions value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemPermissionsReadOnly.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousSharedItemPermissionsReadOnly.value = value.ref - .retainAndReturnPointer(); - } - - /// the current user is allowed to both read and write this item - late final ffi.Pointer - _NSURLUbiquitousSharedItemPermissionsReadWrite = - _lookup( - 'NSURLUbiquitousSharedItemPermissionsReadWrite', - ); - - DartNSURLUbiquitousSharedItemPermissions - get NSURLUbiquitousSharedItemPermissionsReadWrite => - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemPermissionsReadWrite.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousSharedItemPermissionsReadWrite( - DartNSURLUbiquitousSharedItemPermissions value, - ) { - objc.NSString.fromPointer( - _NSURLUbiquitousSharedItemPermissionsReadWrite.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousSharedItemPermissionsReadWrite.value = value.ref - .retainAndReturnPointer(); - } - - /// returns the read-only value of the NSFileManagerSupportedSyncControls options as a NSNumber. - late final ffi.Pointer - _NSURLUbiquitousItemSupportedSyncControlsKey = _lookup( - 'NSURLUbiquitousItemSupportedSyncControlsKey', - ); - - DartNSURLResourceKey get NSURLUbiquitousItemSupportedSyncControlsKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemSupportedSyncControlsKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemSupportedSyncControlsKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemSupportedSyncControlsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemSupportedSyncControlsKey.value = value.ref - .retainAndReturnPointer(); - } - - /// returns a boolean. - late final ffi.Pointer _NSURLUbiquitousItemIsSyncPausedKey = - _lookup('NSURLUbiquitousItemIsSyncPausedKey'); - - DartNSURLResourceKey get NSURLUbiquitousItemIsSyncPausedKey => - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsSyncPausedKey.value, - retain: true, - release: true, - ); - - set NSURLUbiquitousItemIsSyncPausedKey(DartNSURLResourceKey value) { - objc.NSString.fromPointer( - _NSURLUbiquitousItemIsSyncPausedKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLUbiquitousItemIsSyncPausedKey.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer _NSGenericException = - _lookup('NSGenericException'); - - DartNSExceptionName get NSGenericException => objc.NSString.fromPointer( - _NSGenericException.value, - retain: true, - release: true, - ); - - set NSGenericException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSGenericException.value, - retain: false, - release: true, - ).ref.release(); - _NSGenericException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSRangeException = - _lookup('NSRangeException'); - - DartNSExceptionName get NSRangeException => objc.NSString.fromPointer( - _NSRangeException.value, - retain: true, - release: true, - ); - - set NSRangeException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSRangeException.value, - retain: false, - release: true, - ).ref.release(); - _NSRangeException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSInvalidArgumentException = - _lookup('NSInvalidArgumentException'); - - DartNSExceptionName get NSInvalidArgumentException => - objc.NSString.fromPointer( - _NSInvalidArgumentException.value, - retain: true, - release: true, - ); - - set NSInvalidArgumentException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSInvalidArgumentException.value, - retain: false, - release: true, - ).ref.release(); - _NSInvalidArgumentException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSInternalInconsistencyException = - _lookup('NSInternalInconsistencyException'); - - DartNSExceptionName get NSInternalInconsistencyException => - objc.NSString.fromPointer( - _NSInternalInconsistencyException.value, - retain: true, - release: true, - ); - - set NSInternalInconsistencyException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSInternalInconsistencyException.value, - retain: false, - release: true, - ).ref.release(); - _NSInternalInconsistencyException.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer _NSMallocException = - _lookup('NSMallocException'); - - DartNSExceptionName get NSMallocException => objc.NSString.fromPointer( - _NSMallocException.value, - retain: true, - release: true, - ); - - set NSMallocException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSMallocException.value, - retain: false, - release: true, - ).ref.release(); - _NSMallocException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSObjectInaccessibleException = - _lookup('NSObjectInaccessibleException'); - - DartNSExceptionName get NSObjectInaccessibleException => - objc.NSString.fromPointer( - _NSObjectInaccessibleException.value, - retain: true, - release: true, - ); - - set NSObjectInaccessibleException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSObjectInaccessibleException.value, - retain: false, - release: true, - ).ref.release(); - _NSObjectInaccessibleException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSObjectNotAvailableException = - _lookup('NSObjectNotAvailableException'); - - DartNSExceptionName get NSObjectNotAvailableException => - objc.NSString.fromPointer( - _NSObjectNotAvailableException.value, - retain: true, - release: true, - ); - - set NSObjectNotAvailableException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSObjectNotAvailableException.value, - retain: false, - release: true, - ).ref.release(); - _NSObjectNotAvailableException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSDestinationInvalidException = - _lookup('NSDestinationInvalidException'); - - DartNSExceptionName get NSDestinationInvalidException => - objc.NSString.fromPointer( - _NSDestinationInvalidException.value, - retain: true, - release: true, - ); - - set NSDestinationInvalidException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSDestinationInvalidException.value, - retain: false, - release: true, - ).ref.release(); - _NSDestinationInvalidException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSPortTimeoutException = - _lookup('NSPortTimeoutException'); - - DartNSExceptionName get NSPortTimeoutException => objc.NSString.fromPointer( - _NSPortTimeoutException.value, - retain: true, - release: true, - ); - - set NSPortTimeoutException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSPortTimeoutException.value, - retain: false, - release: true, - ).ref.release(); - _NSPortTimeoutException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSInvalidSendPortException = - _lookup('NSInvalidSendPortException'); - - DartNSExceptionName get NSInvalidSendPortException => - objc.NSString.fromPointer( - _NSInvalidSendPortException.value, - retain: true, - release: true, - ); - - set NSInvalidSendPortException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSInvalidSendPortException.value, - retain: false, - release: true, - ).ref.release(); - _NSInvalidSendPortException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSInvalidReceivePortException = - _lookup('NSInvalidReceivePortException'); - - DartNSExceptionName get NSInvalidReceivePortException => - objc.NSString.fromPointer( - _NSInvalidReceivePortException.value, - retain: true, - release: true, - ); - - set NSInvalidReceivePortException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSInvalidReceivePortException.value, - retain: false, - release: true, - ).ref.release(); - _NSInvalidReceivePortException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSPortSendException = - _lookup('NSPortSendException'); - - DartNSExceptionName get NSPortSendException => objc.NSString.fromPointer( - _NSPortSendException.value, - retain: true, - release: true, - ); - - set NSPortSendException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSPortSendException.value, - retain: false, - release: true, - ).ref.release(); - _NSPortSendException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSPortReceiveException = - _lookup('NSPortReceiveException'); - - DartNSExceptionName get NSPortReceiveException => objc.NSString.fromPointer( - _NSPortReceiveException.value, - retain: true, - release: true, - ); - - set NSPortReceiveException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSPortReceiveException.value, - retain: false, - release: true, - ).ref.release(); - _NSPortReceiveException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSOldStyleException = - _lookup('NSOldStyleException'); - - DartNSExceptionName get NSOldStyleException => objc.NSString.fromPointer( - _NSOldStyleException.value, - retain: true, - release: true, - ); - - set NSOldStyleException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSOldStyleException.value, - retain: false, - release: true, - ).ref.release(); - _NSOldStyleException.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSInconsistentArchiveException = - _lookup('NSInconsistentArchiveException'); - - DartNSExceptionName get NSInconsistentArchiveException => - objc.NSString.fromPointer( - _NSInconsistentArchiveException.value, - retain: true, - release: true, - ); - - set NSInconsistentArchiveException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSInconsistentArchiveException.value, - retain: false, - release: true, - ).ref.release(); - _NSInconsistentArchiveException.value = value.ref.retainAndReturnPointer(); - } - - ffi.Pointer NSGetUncaughtExceptionHandler() { - return _NSGetUncaughtExceptionHandler(); - } - - late final _NSGetUncaughtExceptionHandlerPtr = - _lookup< - ffi.NativeFunction Function()> - >('NSGetUncaughtExceptionHandler'); - late final _NSGetUncaughtExceptionHandler = - _NSGetUncaughtExceptionHandlerPtr.asFunction< - ffi.Pointer Function() - >(); - - void NSSetUncaughtExceptionHandler( - ffi.Pointer arg0, - ) { - return _NSSetUncaughtExceptionHandler(arg0); - } - - late final _NSSetUncaughtExceptionHandlerPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >('NSSetUncaughtExceptionHandler'); - late final _NSSetUncaughtExceptionHandler = - _NSSetUncaughtExceptionHandlerPtr.asFunction< - void Function(ffi.Pointer) - >(); - - late final ffi.Pointer> - _NSAssertionHandlerKey = _lookup>( - 'NSAssertionHandlerKey', - ); - - objc.NSString get NSAssertionHandlerKey => objc.NSString.fromPointer( - _NSAssertionHandlerKey.value, - retain: true, - release: true, - ); - - set NSAssertionHandlerKey(objc.NSString value) { - objc.NSString.fromPointer( - _NSAssertionHandlerKey.value, - retain: false, - release: true, - ).ref.release(); - _NSAssertionHandlerKey.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSInvocationOperationVoidResultException = _lookup( - 'NSInvocationOperationVoidResultException', - ); - - DartNSExceptionName get NSInvocationOperationVoidResultException => - objc.NSString.fromPointer( - _NSInvocationOperationVoidResultException.value, - retain: true, - release: true, - ); - - set NSInvocationOperationVoidResultException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSInvocationOperationVoidResultException.value, - retain: false, - release: true, - ).ref.release(); - _NSInvocationOperationVoidResultException.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSInvocationOperationCancelledException = _lookup( - 'NSInvocationOperationCancelledException', - ); - - DartNSExceptionName get NSInvocationOperationCancelledException => - objc.NSString.fromPointer( - _NSInvocationOperationCancelledException.value, - retain: true, - release: true, - ); - - set NSInvocationOperationCancelledException(DartNSExceptionName value) { - objc.NSString.fromPointer( - _NSInvocationOperationCancelledException.value, - retain: false, - release: true, - ).ref.release(); - _NSInvocationOperationCancelledException.value = value.ref - .retainAndReturnPointer(); - } - - late final ffi.Pointer - _NSOperationQueueDefaultMaxConcurrentOperationCount = _lookup( - 'NSOperationQueueDefaultMaxConcurrentOperationCount', - ); - - DartNSInteger get NSOperationQueueDefaultMaxConcurrentOperationCount => - _NSOperationQueueDefaultMaxConcurrentOperationCount.value; - - /// Predefined domain for errors from most AppKit and Foundation APIs. - late final ffi.Pointer _NSCocoaErrorDomain = - _lookup('NSCocoaErrorDomain'); - - DartNSErrorDomain get NSCocoaErrorDomain => objc.NSString.fromPointer( - _NSCocoaErrorDomain.value, - retain: true, - release: true, - ); - - set NSCocoaErrorDomain(DartNSErrorDomain value) { - objc.NSString.fromPointer( - _NSCocoaErrorDomain.value, - retain: false, - release: true, - ).ref.release(); - _NSCocoaErrorDomain.value = value.ref.retainAndReturnPointer(); - } - - /// Other predefined domains; value of "code" will correspond to preexisting values in these domains. - late final ffi.Pointer _NSPOSIXErrorDomain = - _lookup('NSPOSIXErrorDomain'); - - DartNSErrorDomain get NSPOSIXErrorDomain => objc.NSString.fromPointer( - _NSPOSIXErrorDomain.value, - retain: true, - release: true, - ); - - set NSPOSIXErrorDomain(DartNSErrorDomain value) { - objc.NSString.fromPointer( - _NSPOSIXErrorDomain.value, - retain: false, - release: true, - ).ref.release(); - _NSPOSIXErrorDomain.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSOSStatusErrorDomain = - _lookup('NSOSStatusErrorDomain'); - - DartNSErrorDomain get NSOSStatusErrorDomain => objc.NSString.fromPointer( - _NSOSStatusErrorDomain.value, - retain: true, - release: true, - ); - - set NSOSStatusErrorDomain(DartNSErrorDomain value) { - objc.NSString.fromPointer( - _NSOSStatusErrorDomain.value, - retain: false, - release: true, - ).ref.release(); - _NSOSStatusErrorDomain.value = value.ref.retainAndReturnPointer(); - } - - late final ffi.Pointer _NSMachErrorDomain = - _lookup('NSMachErrorDomain'); - - DartNSErrorDomain get NSMachErrorDomain => objc.NSString.fromPointer( - _NSMachErrorDomain.value, - retain: true, - release: true, - ); - - set NSMachErrorDomain(DartNSErrorDomain value) { - objc.NSString.fromPointer( - _NSMachErrorDomain.value, - retain: false, - release: true, - ).ref.release(); - _NSMachErrorDomain.value = value.ref.retainAndReturnPointer(); - } - - /// Key in userInfo. A recommended standard way to embed NSErrors from underlying calls. The value of this key should be an NSError. - late final ffi.Pointer _NSUnderlyingErrorKey = - _lookup('NSUnderlyingErrorKey'); - - DartNSErrorUserInfoKey get NSUnderlyingErrorKey => objc.NSString.fromPointer( - _NSUnderlyingErrorKey.value, - retain: true, - release: true, - ); - - set NSUnderlyingErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSUnderlyingErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSUnderlyingErrorKey.value = value.ref.retainAndReturnPointer(); - } - - /// Key in userInfo. A recommended standard way to embed a list of several NSErrors from underlying calls. The value of this key should be an NSArray of NSError. This value is independent from the value of `NSUnderlyingErrorKey` - neither, one, or both may be set. - late final ffi.Pointer _NSMultipleUnderlyingErrorsKey = - _lookup('NSMultipleUnderlyingErrorsKey'); - - DartNSErrorUserInfoKey get NSMultipleUnderlyingErrorsKey => - objc.NSString.fromPointer( - _NSMultipleUnderlyingErrorsKey.value, - retain: true, - release: true, - ); - - set NSMultipleUnderlyingErrorsKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSMultipleUnderlyingErrorsKey.value, - retain: false, - release: true, - ).ref.release(); - _NSMultipleUnderlyingErrorsKey.value = value.ref.retainAndReturnPointer(); - } - - /// NSString, a complete sentence (or more) describing ideally both what failed and why it failed. - late final ffi.Pointer _NSLocalizedDescriptionKey = - _lookup('NSLocalizedDescriptionKey'); - - DartNSErrorUserInfoKey get NSLocalizedDescriptionKey => - objc.NSString.fromPointer( - _NSLocalizedDescriptionKey.value, - retain: true, - release: true, - ); - - set NSLocalizedDescriptionKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSLocalizedDescriptionKey.value, - retain: false, - release: true, - ).ref.release(); - _NSLocalizedDescriptionKey.value = value.ref.retainAndReturnPointer(); - } - - /// NSString, a complete sentence (or more) describing why the operation failed. - late final ffi.Pointer _NSLocalizedFailureReasonErrorKey = - _lookup('NSLocalizedFailureReasonErrorKey'); - - DartNSErrorUserInfoKey get NSLocalizedFailureReasonErrorKey => - objc.NSString.fromPointer( - _NSLocalizedFailureReasonErrorKey.value, - retain: true, - release: true, - ); - - set NSLocalizedFailureReasonErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSLocalizedFailureReasonErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSLocalizedFailureReasonErrorKey.value = value.ref - .retainAndReturnPointer(); - } - - /// NSString, a complete sentence (or more) describing what the user can do to fix the problem. - late final ffi.Pointer - _NSLocalizedRecoverySuggestionErrorKey = _lookup( - 'NSLocalizedRecoverySuggestionErrorKey', - ); - - DartNSErrorUserInfoKey get NSLocalizedRecoverySuggestionErrorKey => - objc.NSString.fromPointer( - _NSLocalizedRecoverySuggestionErrorKey.value, - retain: true, - release: true, - ); - - set NSLocalizedRecoverySuggestionErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSLocalizedRecoverySuggestionErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSLocalizedRecoverySuggestionErrorKey.value = value.ref - .retainAndReturnPointer(); - } - - /// NSArray of NSStrings corresponding to button titles. - late final ffi.Pointer - _NSLocalizedRecoveryOptionsErrorKey = _lookup( - 'NSLocalizedRecoveryOptionsErrorKey', - ); - - DartNSErrorUserInfoKey get NSLocalizedRecoveryOptionsErrorKey => - objc.NSString.fromPointer( - _NSLocalizedRecoveryOptionsErrorKey.value, - retain: true, - release: true, - ); - - set NSLocalizedRecoveryOptionsErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSLocalizedRecoveryOptionsErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSLocalizedRecoveryOptionsErrorKey.value = value.ref - .retainAndReturnPointer(); - } - - /// Instance of a subclass of NSObject that conforms to the NSErrorRecoveryAttempting informal protocol - late final ffi.Pointer _NSRecoveryAttempterErrorKey = - _lookup('NSRecoveryAttempterErrorKey'); - - DartNSErrorUserInfoKey get NSRecoveryAttempterErrorKey => - objc.NSString.fromPointer( - _NSRecoveryAttempterErrorKey.value, - retain: true, - release: true, - ); - - set NSRecoveryAttempterErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSRecoveryAttempterErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSRecoveryAttempterErrorKey.value = value.ref.retainAndReturnPointer(); - } - - /// NSString containing a help anchor - late final ffi.Pointer _NSHelpAnchorErrorKey = - _lookup('NSHelpAnchorErrorKey'); - - DartNSErrorUserInfoKey get NSHelpAnchorErrorKey => objc.NSString.fromPointer( - _NSHelpAnchorErrorKey.value, - retain: true, - release: true, - ); - - set NSHelpAnchorErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSHelpAnchorErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSHelpAnchorErrorKey.value = value.ref.retainAndReturnPointer(); - } - - /// NSString. This provides a string which will be shown when constructing the debugDescription of the NSError, to be used when debugging or when formatting the error with %@. This string will never be used in localizedDescription, so will not be shown to the user. - late final ffi.Pointer _NSDebugDescriptionErrorKey = - _lookup('NSDebugDescriptionErrorKey'); - - DartNSErrorUserInfoKey get NSDebugDescriptionErrorKey => - objc.NSString.fromPointer( - _NSDebugDescriptionErrorKey.value, - retain: true, - release: true, - ); - - set NSDebugDescriptionErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSDebugDescriptionErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSDebugDescriptionErrorKey.value = value.ref.retainAndReturnPointer(); - } - - /// NSString, a complete sentence (or more) describing what failed. Setting a value for this key in userInfo dictionary of errors received from framework APIs is a good way to customize and fine tune the localizedDescription of an NSError. As an example, for Foundation error code NSFileWriteOutOfSpaceError, setting the value of this key to "The image library could not be saved." will allow the localizedDescription of the error to come out as "The image library could not be saved. The volume Macintosh HD is out of space." rather than the default (say) “You can't save the file ImgDatabaseV2 because the volume Macintosh HD is out of space." - late final ffi.Pointer _NSLocalizedFailureErrorKey = - _lookup('NSLocalizedFailureErrorKey'); - - DartNSErrorUserInfoKey get NSLocalizedFailureErrorKey => - objc.NSString.fromPointer( - _NSLocalizedFailureErrorKey.value, - retain: true, - release: true, - ); - - set NSLocalizedFailureErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSLocalizedFailureErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSLocalizedFailureErrorKey.value = value.ref.retainAndReturnPointer(); - } - - /// NSNumber containing NSStringEncoding - late final ffi.Pointer _NSStringEncodingErrorKey = - _lookup('NSStringEncodingErrorKey'); - - DartNSErrorUserInfoKey get NSStringEncodingErrorKey => - objc.NSString.fromPointer( - _NSStringEncodingErrorKey.value, - retain: true, - release: true, - ); - - set NSStringEncodingErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSStringEncodingErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSStringEncodingErrorKey.value = value.ref.retainAndReturnPointer(); - } - - /// NSURL - late final ffi.Pointer _NSURLErrorKey = - _lookup('NSURLErrorKey'); - - DartNSErrorUserInfoKey get NSURLErrorKey => objc.NSString.fromPointer( - _NSURLErrorKey.value, - retain: true, - release: true, - ); - - set NSURLErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSURLErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSURLErrorKey.value = value.ref.retainAndReturnPointer(); - } - - /// NSString - late final ffi.Pointer _NSFilePathErrorKey = - _lookup('NSFilePathErrorKey'); - - DartNSErrorUserInfoKey get NSFilePathErrorKey => objc.NSString.fromPointer( - _NSFilePathErrorKey.value, - retain: true, - release: true, - ); - - set NSFilePathErrorKey(DartNSErrorUserInfoKey value) { - objc.NSString.fromPointer( - _NSFilePathErrorKey.value, - retain: false, - release: true, - ).ref.release(); - _NSFilePathErrorKey.value = value.ref.retainAndReturnPointer(); - } -} - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1pl9qdv( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1pl9qdv( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Bool Function(ffi.Pointer, ffi.Pointer) ->() -external bool _NativeCupertinoHttp_protocolTrampoline_e3qsqz( - ffi.Pointer target, - ffi.Pointer arg0, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_18v1jvf( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_18v1jvf( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, -); - -@ffi.Native< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external instancetype _NativeCupertinoHttp_protocolTrampoline_xr62hr( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_xtuoz7( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) ->() -external ffi.Pointer -_NativeCupertinoHttp_protocolTrampoline_1mbt9g9( - ffi.Pointer target, - ffi.Pointer arg0, -); - -@ffi.Native< - NSUInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - NSUInteger, - ) ->() -external int _NativeCupertinoHttp_protocolTrampoline_17ap02x( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - int arg3, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_tg5tbv( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_tg5tbv( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1dqvvol( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1dqvvol( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_6enxqz( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_6enxqz( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_18kzm6a( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_18kzm6a( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_9o8504( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_9o8504( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_og5b6y( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_og5b6y( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_gwxhxt( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_gwxhxt( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_k73ff5( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_k73ff5( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_15f11yh( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_15f11yh( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_pfv6jd( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_18qun1e( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_18qun1e( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_o762yo( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_o762yo( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1s56lr9( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1s56lr9( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_r8gdi7( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_16sve1d( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_16sve1d( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_xx612k( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_xx612k( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1otpo83( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1otpo83( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_xx612k( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1tz5yf( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_1tz5yf( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_fjrv01( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_fjrv01( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_fjrv01( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_l2g8ke( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_l2g8ke( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_l2g8ke( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_n8yd09( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_n8yd09( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_bklti2( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_bklti2( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_bklti2( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_jyim80( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_jyim80( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_jyim80( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_h68abb( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_h68abb( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_h68abb( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_ly2579( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_ly2579( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_ly2579( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1lx650f( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1lx650f( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_1lx650f( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1b3bb6a( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1b3bb6a( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) ->() -external instancetype _NativeCupertinoHttp_protocolTrampoline_10z9f5k( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3, -); - -@ffi.Native< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external int _NativeCupertinoHttp_protocolTrampoline_1ldqghh( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->() -external ffi.Pointer -_NativeCupertinoHttp_protocolTrampoline_1q0i84( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, -); - -@ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_ovsamd( - ffi.Pointer block, -); - -@ffi.Native< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_ovsamd( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, -); - -@ffi.Native< - ffi.Void Function(ffi.Pointer, ffi.Pointer) ->() -external void _NativeCupertinoHttp_protocolTrampoline_ovsamd( - ffi.Pointer target, - ffi.Pointer arg0, -); - -typedef __int8_t = ffi.SignedChar; -typedef Dart__int8_t = int; -typedef __uint8_t = ffi.UnsignedChar; -typedef Dart__uint8_t = int; -typedef __int16_t = ffi.Short; -typedef Dart__int16_t = int; -typedef __uint16_t = ffi.UnsignedShort; -typedef Dart__uint16_t = int; -typedef __int32_t = ffi.Int; -typedef Dart__int32_t = int; -typedef __uint32_t = ffi.UnsignedInt; -typedef Dart__uint32_t = int; -typedef __int64_t = ffi.LongLong; -typedef Dart__int64_t = int; -typedef __uint64_t = ffi.UnsignedLongLong; -typedef Dart__uint64_t = int; -typedef __darwin_intptr_t = ffi.Long; -typedef Dart__darwin_intptr_t = int; -typedef __darwin_natural_t = ffi.UnsignedInt; -typedef Dart__darwin_natural_t = int; -typedef __darwin_ct_rune_t = ffi.Int; -typedef Dart__darwin_ct_rune_t = int; - -final class __mbstate_t extends ffi.Union { - @ffi.Array.multi([128]) - external ffi.Array __mbstate8; - - @ffi.LongLong() - external int _mbstateL; -} - -typedef __darwin_mbstate_t = __mbstate_t; -typedef __darwin_ptrdiff_t = ffi.Long; -typedef Dart__darwin_ptrdiff_t = int; -typedef __darwin_size_t = ffi.UnsignedLong; -typedef Dart__darwin_size_t = int; -typedef __builtin_va_list = ffi.Pointer; -typedef __darwin_va_list = __builtin_va_list; -typedef __darwin_wchar_t = ffi.Int; -typedef Dart__darwin_wchar_t = int; -typedef __darwin_rune_t = __darwin_wchar_t; -typedef __darwin_wint_t = ffi.Int; -typedef Dart__darwin_wint_t = int; -typedef __darwin_clock_t = ffi.UnsignedLong; -typedef Dart__darwin_clock_t = int; -typedef __darwin_socklen_t = __uint32_t; -typedef __darwin_ssize_t = ffi.Long; -typedef Dart__darwin_ssize_t = int; -typedef __darwin_time_t = ffi.Long; -typedef Dart__darwin_time_t = int; -typedef __darwin_blkcnt_t = __int64_t; -typedef __darwin_blksize_t = __int32_t; -typedef __darwin_dev_t = __int32_t; -typedef __darwin_fsblkcnt_t = ffi.UnsignedInt; -typedef Dart__darwin_fsblkcnt_t = int; -typedef __darwin_fsfilcnt_t = ffi.UnsignedInt; -typedef Dart__darwin_fsfilcnt_t = int; -typedef __darwin_gid_t = __uint32_t; -typedef __darwin_id_t = __uint32_t; -typedef __darwin_ino64_t = __uint64_t; -typedef __darwin_ino_t = __darwin_ino64_t; -typedef __darwin_mach_port_name_t = __darwin_natural_t; -typedef __darwin_mach_port_t = __darwin_mach_port_name_t; -typedef __darwin_mode_t = __uint16_t; -typedef __darwin_off_t = __int64_t; -typedef __darwin_pid_t = __int32_t; -typedef __darwin_sigset_t = __uint32_t; -typedef __darwin_suseconds_t = __int32_t; -typedef __darwin_uid_t = __uint32_t; -typedef __darwin_useconds_t = __uint32_t; - -final class __darwin_pthread_handler_rec extends ffi.Struct { - external ffi.Pointer< - ffi.NativeFunction)> - > - __routine; - - external ffi.Pointer __arg; - - external ffi.Pointer<__darwin_pthread_handler_rec> __next; -} - -final class _opaque_pthread_attr_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([56]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_cond_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([40]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_condattr_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([8]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_mutex_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([56]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_mutexattr_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([8]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_once_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([8]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_rwlock_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([192]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_rwlockattr_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([16]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - external ffi.Pointer<__darwin_pthread_handler_rec> __cleanup_stack; - - @ffi.Array.multi([8176]) - external ffi.Array __opaque; -} - -typedef __darwin_pthread_attr_t = _opaque_pthread_attr_t; -typedef __darwin_pthread_cond_t = _opaque_pthread_cond_t; -typedef __darwin_pthread_condattr_t = _opaque_pthread_condattr_t; -typedef __darwin_pthread_key_t = ffi.UnsignedLong; -typedef Dart__darwin_pthread_key_t = int; -typedef __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -typedef __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t; -typedef __darwin_pthread_once_t = _opaque_pthread_once_t; -typedef __darwin_pthread_rwlock_t = _opaque_pthread_rwlock_t; -typedef __darwin_pthread_rwlockattr_t = _opaque_pthread_rwlockattr_t; -typedef __darwin_pthread_t = ffi.Pointer<_opaque_pthread_t>; -typedef __darwin_nl_item = ffi.Int; -typedef Dart__darwin_nl_item = int; -typedef __darwin_wctrans_t = ffi.Int; -typedef Dart__darwin_wctrans_t = int; -typedef __darwin_wctype_t = __uint32_t; - -enum idtype_t { - P_ALL(0), - P_PID(1), - P_PGID(2); - - final int value; - const idtype_t(this.value); - - static idtype_t fromValue(int value) => switch (value) { - 0 => P_ALL, - 1 => P_PID, - 2 => P_PGID, - _ => throw ArgumentError('Unknown value for idtype_t: $value'), - }; -} - -typedef pid_t = __darwin_pid_t; -typedef id_t = __darwin_id_t; -typedef sig_atomic_t = ffi.Int; -typedef Dartsig_atomic_t = int; -typedef u_int8_t = ffi.UnsignedChar; -typedef Dartu_int8_t = int; -typedef u_int16_t = ffi.UnsignedShort; -typedef Dartu_int16_t = int; -typedef u_int32_t = ffi.UnsignedInt; -typedef Dartu_int32_t = int; -typedef u_int64_t = ffi.UnsignedLongLong; -typedef Dartu_int64_t = int; -typedef register_t = ffi.Int64; -typedef Dartregister_t = int; -typedef user_addr_t = u_int64_t; -typedef user_size_t = u_int64_t; -typedef user_ssize_t = ffi.Int64; -typedef Dartuser_ssize_t = int; -typedef user_long_t = ffi.Int64; -typedef Dartuser_long_t = int; -typedef user_ulong_t = u_int64_t; -typedef user_time_t = ffi.Int64; -typedef Dartuser_time_t = int; -typedef user_off_t = ffi.Int64; -typedef Dartuser_off_t = int; -typedef syscall_arg_t = u_int64_t; - -final class __darwin_arm_exception_state extends ffi.Struct { - @__uint32_t() - external int __exception; - - @__uint32_t() - external int __fsr; - - @__uint32_t() - external int __far; -} - -final class __darwin_arm_exception_state64 extends ffi.Struct { - @__uint64_t() - external int __far; - - @__uint32_t() - external int __esr; - - @__uint32_t() - external int __exception; -} - -final class __darwin_arm_exception_state64_v2 extends ffi.Struct { - @__uint64_t() - external int __far; - - @__uint64_t() - external int __esr; -} - -final class __darwin_arm_thread_state extends ffi.Struct { - @ffi.Array.multi([13]) - external ffi.Array<__uint32_t> __r; - - @__uint32_t() - external int __sp; - - @__uint32_t() - external int __lr; - - @__uint32_t() - external int __pc; - - @__uint32_t() - external int __cpsr; -} - -final class __darwin_arm_thread_state64 extends ffi.Struct { - @ffi.Array.multi([29]) - external ffi.Array<__uint64_t> __x; - - @__uint64_t() - external int __fp; - - @__uint64_t() - external int __lr; - - @__uint64_t() - external int __sp; - - @__uint64_t() - external int __pc; - - @__uint32_t() - external int __cpsr; - - @__uint32_t() - external int __pad; -} - -final class __darwin_arm_vfp_state extends ffi.Struct { - @ffi.Array.multi([64]) - external ffi.Array<__uint32_t> __r; - - @__uint32_t() - external int __fpscr; -} - -final class __darwin_arm_neon_state64 extends ffi.Opaque {} - -final class __darwin_arm_neon_state extends ffi.Opaque {} - -final class __arm_pagein_state extends ffi.Struct { - @ffi.Int() - external int __pagein_error; -} - -final class __darwin_arm_sme_state extends ffi.Struct { - @__uint64_t() - external int __svcr; - - @__uint64_t() - external int __tpidr2_el0; - - @__uint16_t() - external int __svl_b; -} - -final class __darwin_arm_sve_z_state extends ffi.Struct { - @ffi.Array.multi([16, 256]) - external ffi.Array> __z; -} - -final class __darwin_arm_sve_p_state extends ffi.Struct { - @ffi.Array.multi([16, 32]) - external ffi.Array> __p; -} - -final class __darwin_arm_sme_za_state extends ffi.Struct { - @ffi.Array.multi([4096]) - external ffi.Array __za; -} - -final class __darwin_arm_sme2_state extends ffi.Struct { - @ffi.Array.multi([64]) - external ffi.Array __zt0; -} - -final class __arm_legacy_debug_state extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array<__uint32_t> __bvr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint32_t> __bcr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint32_t> __wvr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint32_t> __wcr; -} - -final class __darwin_arm_debug_state32 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array<__uint32_t> __bvr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint32_t> __bcr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint32_t> __wvr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint32_t> __wcr; - - @__uint64_t() - external int __mdscr_el1; -} - -final class __darwin_arm_debug_state64 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array<__uint64_t> __bvr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint64_t> __bcr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint64_t> __wvr; - - @ffi.Array.multi([16]) - external ffi.Array<__uint64_t> __wcr; - - @__uint64_t() - external int __mdscr_el1; -} - -final class __darwin_arm_cpmu_state64 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array<__uint64_t> __ctrs; -} - -final class __darwin_mcontext32 extends ffi.Struct { - external __darwin_arm_exception_state __es; - - external __darwin_arm_thread_state __ss; - - external __darwin_arm_vfp_state __fs; -} - -final class __darwin_mcontext64 extends ffi.Opaque {} - -typedef mcontext_t = ffi.Pointer<__darwin_mcontext64>; -typedef pthread_attr_t = __darwin_pthread_attr_t; - -final class __darwin_sigaltstack extends ffi.Struct { - external ffi.Pointer ss_sp; - - @__darwin_size_t() - external int ss_size; - - @ffi.Int() - external int ss_flags; -} - -typedef stack_t = __darwin_sigaltstack; - -final class __darwin_ucontext extends ffi.Struct { - @ffi.Int() - external int uc_onstack; - - @__darwin_sigset_t() - external int uc_sigmask; - - external __darwin_sigaltstack uc_stack; - - external ffi.Pointer<__darwin_ucontext> uc_link; - - @__darwin_size_t() - external int uc_mcsize; - - external ffi.Pointer<__darwin_mcontext64> uc_mcontext; -} - -typedef ucontext_t = __darwin_ucontext; -typedef sigset_t = __darwin_sigset_t; -typedef uid_t = __darwin_uid_t; - -final class sigval extends ffi.Union { - @ffi.Int() - external int sival_int; - - external ffi.Pointer sival_ptr; -} - -final class sigevent extends ffi.Struct { - @ffi.Int() - external int sigev_notify; - - @ffi.Int() - external int sigev_signo; - - external sigval sigev_value; - - external ffi.Pointer> - sigev_notify_function; - - external ffi.Pointer sigev_notify_attributes; -} - -final class __siginfo extends ffi.Struct { - @ffi.Int() - external int si_signo; - - @ffi.Int() - external int si_errno; - - @ffi.Int() - external int si_code; - - @pid_t() - external int si_pid; - - @uid_t() - external int si_uid; - - @ffi.Int() - external int si_status; - - external ffi.Pointer si_addr; - - external sigval si_value; - - @ffi.Long() - external int si_band; - - @ffi.Array.multi([7]) - external ffi.Array __pad; -} - -typedef siginfo_t = __siginfo; - -final class __sigaction_u extends ffi.Union { - external ffi.Pointer> - __sa_handler; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Int, ffi.Pointer<__siginfo>, ffi.Pointer) - > - > - __sa_sigaction; -} - -final class __sigaction extends ffi.Struct { - external __sigaction_u __sigaction_u$1; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) - > - > - sa_tramp; - - @sigset_t() - external int sa_mask; - - @ffi.Int() - external int sa_flags; -} - -final class sigaction$1 extends ffi.Struct { - external __sigaction_u __sigaction_u$1; - - @sigset_t() - external int sa_mask; - - @ffi.Int() - external int sa_flags; -} - -typedef sig_tFunction = ffi.Void Function(ffi.Int); -typedef Dartsig_tFunction = void Function(int); -typedef sig_t = ffi.Pointer>; - -final class sigvec$1 extends ffi.Struct { - external ffi.Pointer> - sv_handler; - - @ffi.Int() - external int sv_mask; - - @ffi.Int() - external int sv_flags; -} - -final class sigstack extends ffi.Struct { - external ffi.Pointer ss_sp; - - @ffi.Int() - external int ss_onstack; -} - -typedef int_least8_t = ffi.Int8; -typedef Dartint_least8_t = int; -typedef int_least16_t = ffi.Int16; -typedef Dartint_least16_t = int; -typedef int_least32_t = ffi.Int32; -typedef Dartint_least32_t = int; -typedef int_least64_t = ffi.Int64; -typedef Dartint_least64_t = int; -typedef uint_least8_t = ffi.Uint8; -typedef Dartuint_least8_t = int; -typedef uint_least16_t = ffi.Uint16; -typedef Dartuint_least16_t = int; -typedef uint_least32_t = ffi.Uint32; -typedef Dartuint_least32_t = int; -typedef uint_least64_t = ffi.Uint64; -typedef Dartuint_least64_t = int; -typedef int_fast8_t = ffi.Int8; -typedef Dartint_fast8_t = int; -typedef int_fast16_t = ffi.Int16; -typedef Dartint_fast16_t = int; -typedef int_fast32_t = ffi.Int32; -typedef Dartint_fast32_t = int; -typedef int_fast64_t = ffi.Int64; -typedef Dartint_fast64_t = int; -typedef uint_fast8_t = ffi.Uint8; -typedef Dartuint_fast8_t = int; -typedef uint_fast16_t = ffi.Uint16; -typedef Dartuint_fast16_t = int; -typedef uint_fast32_t = ffi.Uint32; -typedef Dartuint_fast32_t = int; -typedef uint_fast64_t = ffi.Uint64; -typedef Dartuint_fast64_t = int; -typedef intmax_t = ffi.Long; -typedef Dartintmax_t = int; -typedef uintmax_t = ffi.UnsignedLong; -typedef Dartuintmax_t = int; - -final class timeval extends ffi.Struct { - @__darwin_time_t() - external int tv_sec; - - @__darwin_suseconds_t() - external int tv_usec; -} - -typedef rlim_t = __uint64_t; - -final class rusage extends ffi.Struct { - external timeval ru_utime; - - external timeval ru_stime; - - @ffi.Long() - external int ru_maxrss; - - @ffi.Long() - external int ru_ixrss; - - @ffi.Long() - external int ru_idrss; - - @ffi.Long() - external int ru_isrss; - - @ffi.Long() - external int ru_minflt; - - @ffi.Long() - external int ru_majflt; - - @ffi.Long() - external int ru_nswap; - - @ffi.Long() - external int ru_inblock; - - @ffi.Long() - external int ru_oublock; - - @ffi.Long() - external int ru_msgsnd; - - @ffi.Long() - external int ru_msgrcv; - - @ffi.Long() - external int ru_nsignals; - - @ffi.Long() - external int ru_nvcsw; - - @ffi.Long() - external int ru_nivcsw; -} - -typedef rusage_info_t = ffi.Pointer; - -final class rusage_info_v0 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array ri_uuid; - - @ffi.Uint64() - external int ri_user_time; - - @ffi.Uint64() - external int ri_system_time; - - @ffi.Uint64() - external int ri_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_interrupt_wkups; - - @ffi.Uint64() - external int ri_pageins; - - @ffi.Uint64() - external int ri_wired_size; - - @ffi.Uint64() - external int ri_resident_size; - - @ffi.Uint64() - external int ri_phys_footprint; - - @ffi.Uint64() - external int ri_proc_start_abstime; - - @ffi.Uint64() - external int ri_proc_exit_abstime; -} - -final class rusage_info_v1 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array ri_uuid; - - @ffi.Uint64() - external int ri_user_time; - - @ffi.Uint64() - external int ri_system_time; - - @ffi.Uint64() - external int ri_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_interrupt_wkups; - - @ffi.Uint64() - external int ri_pageins; - - @ffi.Uint64() - external int ri_wired_size; - - @ffi.Uint64() - external int ri_resident_size; - - @ffi.Uint64() - external int ri_phys_footprint; - - @ffi.Uint64() - external int ri_proc_start_abstime; - - @ffi.Uint64() - external int ri_proc_exit_abstime; - - @ffi.Uint64() - external int ri_child_user_time; - - @ffi.Uint64() - external int ri_child_system_time; - - @ffi.Uint64() - external int ri_child_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_child_interrupt_wkups; - - @ffi.Uint64() - external int ri_child_pageins; - - @ffi.Uint64() - external int ri_child_elapsed_abstime; -} - -final class rusage_info_v2 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array ri_uuid; - - @ffi.Uint64() - external int ri_user_time; - - @ffi.Uint64() - external int ri_system_time; - - @ffi.Uint64() - external int ri_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_interrupt_wkups; - - @ffi.Uint64() - external int ri_pageins; - - @ffi.Uint64() - external int ri_wired_size; - - @ffi.Uint64() - external int ri_resident_size; - - @ffi.Uint64() - external int ri_phys_footprint; - - @ffi.Uint64() - external int ri_proc_start_abstime; - - @ffi.Uint64() - external int ri_proc_exit_abstime; - - @ffi.Uint64() - external int ri_child_user_time; - - @ffi.Uint64() - external int ri_child_system_time; - - @ffi.Uint64() - external int ri_child_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_child_interrupt_wkups; - - @ffi.Uint64() - external int ri_child_pageins; - - @ffi.Uint64() - external int ri_child_elapsed_abstime; - - @ffi.Uint64() - external int ri_diskio_bytesread; - - @ffi.Uint64() - external int ri_diskio_byteswritten; -} - -final class rusage_info_v3 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array ri_uuid; - - @ffi.Uint64() - external int ri_user_time; - - @ffi.Uint64() - external int ri_system_time; - - @ffi.Uint64() - external int ri_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_interrupt_wkups; - - @ffi.Uint64() - external int ri_pageins; - - @ffi.Uint64() - external int ri_wired_size; - - @ffi.Uint64() - external int ri_resident_size; - - @ffi.Uint64() - external int ri_phys_footprint; - - @ffi.Uint64() - external int ri_proc_start_abstime; - - @ffi.Uint64() - external int ri_proc_exit_abstime; - - @ffi.Uint64() - external int ri_child_user_time; - - @ffi.Uint64() - external int ri_child_system_time; - - @ffi.Uint64() - external int ri_child_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_child_interrupt_wkups; - - @ffi.Uint64() - external int ri_child_pageins; - - @ffi.Uint64() - external int ri_child_elapsed_abstime; - - @ffi.Uint64() - external int ri_diskio_bytesread; - - @ffi.Uint64() - external int ri_diskio_byteswritten; - - @ffi.Uint64() - external int ri_cpu_time_qos_default; - - @ffi.Uint64() - external int ri_cpu_time_qos_maintenance; - - @ffi.Uint64() - external int ri_cpu_time_qos_background; - - @ffi.Uint64() - external int ri_cpu_time_qos_utility; - - @ffi.Uint64() - external int ri_cpu_time_qos_legacy; - - @ffi.Uint64() - external int ri_cpu_time_qos_user_initiated; - - @ffi.Uint64() - external int ri_cpu_time_qos_user_interactive; - - @ffi.Uint64() - external int ri_billed_system_time; - - @ffi.Uint64() - external int ri_serviced_system_time; -} - -final class rusage_info_v4 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array ri_uuid; - - @ffi.Uint64() - external int ri_user_time; - - @ffi.Uint64() - external int ri_system_time; - - @ffi.Uint64() - external int ri_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_interrupt_wkups; - - @ffi.Uint64() - external int ri_pageins; - - @ffi.Uint64() - external int ri_wired_size; - - @ffi.Uint64() - external int ri_resident_size; - - @ffi.Uint64() - external int ri_phys_footprint; - - @ffi.Uint64() - external int ri_proc_start_abstime; - - @ffi.Uint64() - external int ri_proc_exit_abstime; - - @ffi.Uint64() - external int ri_child_user_time; - - @ffi.Uint64() - external int ri_child_system_time; - - @ffi.Uint64() - external int ri_child_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_child_interrupt_wkups; - - @ffi.Uint64() - external int ri_child_pageins; - - @ffi.Uint64() - external int ri_child_elapsed_abstime; - - @ffi.Uint64() - external int ri_diskio_bytesread; - - @ffi.Uint64() - external int ri_diskio_byteswritten; - - @ffi.Uint64() - external int ri_cpu_time_qos_default; - - @ffi.Uint64() - external int ri_cpu_time_qos_maintenance; - - @ffi.Uint64() - external int ri_cpu_time_qos_background; - - @ffi.Uint64() - external int ri_cpu_time_qos_utility; - - @ffi.Uint64() - external int ri_cpu_time_qos_legacy; - - @ffi.Uint64() - external int ri_cpu_time_qos_user_initiated; - - @ffi.Uint64() - external int ri_cpu_time_qos_user_interactive; - - @ffi.Uint64() - external int ri_billed_system_time; - - @ffi.Uint64() - external int ri_serviced_system_time; - - @ffi.Uint64() - external int ri_logical_writes; - - @ffi.Uint64() - external int ri_lifetime_max_phys_footprint; - - @ffi.Uint64() - external int ri_instructions; - - @ffi.Uint64() - external int ri_cycles; - - @ffi.Uint64() - external int ri_billed_energy; - - @ffi.Uint64() - external int ri_serviced_energy; - - @ffi.Uint64() - external int ri_interval_max_phys_footprint; - - @ffi.Uint64() - external int ri_runnable_time; -} - -final class rusage_info_v5 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array ri_uuid; - - @ffi.Uint64() - external int ri_user_time; - - @ffi.Uint64() - external int ri_system_time; - - @ffi.Uint64() - external int ri_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_interrupt_wkups; - - @ffi.Uint64() - external int ri_pageins; - - @ffi.Uint64() - external int ri_wired_size; - - @ffi.Uint64() - external int ri_resident_size; - - @ffi.Uint64() - external int ri_phys_footprint; - - @ffi.Uint64() - external int ri_proc_start_abstime; - - @ffi.Uint64() - external int ri_proc_exit_abstime; - - @ffi.Uint64() - external int ri_child_user_time; - - @ffi.Uint64() - external int ri_child_system_time; - - @ffi.Uint64() - external int ri_child_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_child_interrupt_wkups; - - @ffi.Uint64() - external int ri_child_pageins; - - @ffi.Uint64() - external int ri_child_elapsed_abstime; - - @ffi.Uint64() - external int ri_diskio_bytesread; - - @ffi.Uint64() - external int ri_diskio_byteswritten; - - @ffi.Uint64() - external int ri_cpu_time_qos_default; - - @ffi.Uint64() - external int ri_cpu_time_qos_maintenance; - - @ffi.Uint64() - external int ri_cpu_time_qos_background; - - @ffi.Uint64() - external int ri_cpu_time_qos_utility; - - @ffi.Uint64() - external int ri_cpu_time_qos_legacy; - - @ffi.Uint64() - external int ri_cpu_time_qos_user_initiated; - - @ffi.Uint64() - external int ri_cpu_time_qos_user_interactive; - - @ffi.Uint64() - external int ri_billed_system_time; - - @ffi.Uint64() - external int ri_serviced_system_time; - - @ffi.Uint64() - external int ri_logical_writes; - - @ffi.Uint64() - external int ri_lifetime_max_phys_footprint; - - @ffi.Uint64() - external int ri_instructions; - - @ffi.Uint64() - external int ri_cycles; - - @ffi.Uint64() - external int ri_billed_energy; - - @ffi.Uint64() - external int ri_serviced_energy; - - @ffi.Uint64() - external int ri_interval_max_phys_footprint; - - @ffi.Uint64() - external int ri_runnable_time; - - @ffi.Uint64() - external int ri_flags; -} - -final class rusage_info_v6 extends ffi.Struct { - @ffi.Array.multi([16]) - external ffi.Array ri_uuid; - - @ffi.Uint64() - external int ri_user_time; - - @ffi.Uint64() - external int ri_system_time; - - @ffi.Uint64() - external int ri_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_interrupt_wkups; - - @ffi.Uint64() - external int ri_pageins; - - @ffi.Uint64() - external int ri_wired_size; - - @ffi.Uint64() - external int ri_resident_size; - - @ffi.Uint64() - external int ri_phys_footprint; - - @ffi.Uint64() - external int ri_proc_start_abstime; - - @ffi.Uint64() - external int ri_proc_exit_abstime; - - @ffi.Uint64() - external int ri_child_user_time; - - @ffi.Uint64() - external int ri_child_system_time; - - @ffi.Uint64() - external int ri_child_pkg_idle_wkups; - - @ffi.Uint64() - external int ri_child_interrupt_wkups; - - @ffi.Uint64() - external int ri_child_pageins; - - @ffi.Uint64() - external int ri_child_elapsed_abstime; - - @ffi.Uint64() - external int ri_diskio_bytesread; - - @ffi.Uint64() - external int ri_diskio_byteswritten; - - @ffi.Uint64() - external int ri_cpu_time_qos_default; - - @ffi.Uint64() - external int ri_cpu_time_qos_maintenance; - - @ffi.Uint64() - external int ri_cpu_time_qos_background; - - @ffi.Uint64() - external int ri_cpu_time_qos_utility; - - @ffi.Uint64() - external int ri_cpu_time_qos_legacy; - - @ffi.Uint64() - external int ri_cpu_time_qos_user_initiated; - - @ffi.Uint64() - external int ri_cpu_time_qos_user_interactive; - - @ffi.Uint64() - external int ri_billed_system_time; - - @ffi.Uint64() - external int ri_serviced_system_time; - - @ffi.Uint64() - external int ri_logical_writes; - - @ffi.Uint64() - external int ri_lifetime_max_phys_footprint; - - @ffi.Uint64() - external int ri_instructions; - - @ffi.Uint64() - external int ri_cycles; - - @ffi.Uint64() - external int ri_billed_energy; - - @ffi.Uint64() - external int ri_serviced_energy; - - @ffi.Uint64() - external int ri_interval_max_phys_footprint; - - @ffi.Uint64() - external int ri_runnable_time; - - @ffi.Uint64() - external int ri_flags; - - @ffi.Uint64() - external int ri_user_ptime; - - @ffi.Uint64() - external int ri_system_ptime; - - @ffi.Uint64() - external int ri_pinstructions; - - @ffi.Uint64() - external int ri_pcycles; - - @ffi.Uint64() - external int ri_energy_nj; - - @ffi.Uint64() - external int ri_penergy_nj; - - @ffi.Uint64() - external int ri_secure_time_in_system; - - @ffi.Uint64() - external int ri_secure_ptime_in_system; - - @ffi.Uint64() - external int ri_neural_footprint; - - @ffi.Uint64() - external int ri_lifetime_max_neural_footprint; - - @ffi.Uint64() - external int ri_interval_max_neural_footprint; - - @ffi.Array.multi([9]) - external ffi.Array ri_reserved; -} - -typedef rusage_info_current = rusage_info_v6; - -final class rlimit extends ffi.Struct { - @rlim_t() - external int rlim_cur; - - @rlim_t() - external int rlim_max; -} - -final class proc_rlimit_control_wakeupmon extends ffi.Struct { - @ffi.Uint32() - external int wm_flags; - - @ffi.Int32() - external int wm_rate; -} - -final class wait$1 extends ffi.Opaque {} - -typedef ct_rune_t = __darwin_ct_rune_t; -typedef rune_t = __darwin_rune_t; - -final class div_t extends ffi.Struct { - @ffi.Int() - external int quot; - - @ffi.Int() - external int rem; -} - -final class ldiv_t extends ffi.Struct { - @ffi.Long() - external int quot; - - @ffi.Long() - external int rem; -} - -final class lldiv_t extends ffi.Struct { - @ffi.LongLong() - external int quot; - - @ffi.LongLong() - external int rem; -} - -typedef malloc_type_id_t = ffi.UnsignedLongLong; -typedef Dartmalloc_type_id_t = int; - -final class _malloc_zone_t extends ffi.Opaque {} - -typedef malloc_zone_t = _malloc_zone_t; -typedef dev_t = __darwin_dev_t; -typedef mode_t = __darwin_mode_t; - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer> ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function() fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock(_closureCallable, () => fn(), keepIsolateAlive), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function() fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - () => fn(), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1pl9qdv(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function() fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - () => fn(), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - () => fn(), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1pl9qdv( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline(ffi.Pointer block) { - (objc.getBlockClosure(block) as void Function())(); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable)> - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ) { - try { - (objc.getBlockClosure(block) as void Function())(); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline(ffi.Pointer block) => block - .ref - .target - .cast>() - .asFunction()(); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline(ffi.Pointer block) => - (objc.getBlockClosure(block) as void Function())(); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid$CallExtension - on objc.ObjCBlock { - void call() => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer block) - > - >() - .asFunction)>()( - ref.pointer, - ); -} - -/// Construction methods for `objc.ObjCBlock, ffi.Pointer)>`. -abstract final class ObjCBlock_ffiInt_ffiVoid_ffiVoid { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer arg0, ffi.Pointer arg1) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - fromFunction( - int Function(ffi.Pointer, ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - >( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, arg1), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static int _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - int Function(ffi.Pointer, ffi.Pointer) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline, 0) - .cast(); - static int _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as int Function(ffi.Pointer, ffi.Pointer))( - arg0, - arg1, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline, 0) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, ffi.Pointer)>`. -extension ObjCBlock_ffiInt_ffiVoid_ffiVoid$CallExtension - on - objc.ObjCBlock< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > { - int call(ffi.Pointer arg0, ffi.Pointer arg1) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1); -} - -typedef ptrdiff_t = ffi.Long; -typedef Dartptrdiff_t = int; -typedef rsize_t = ffi.UnsignedLong; -typedef Dartrsize_t = int; -typedef u_char = ffi.UnsignedChar; -typedef Dartu_char = int; -typedef u_short = ffi.UnsignedShort; -typedef Dartu_short = int; -typedef u_int = ffi.UnsignedInt; -typedef Dartu_int = int; -typedef u_long = ffi.UnsignedLong; -typedef Dartu_long = int; -typedef ushort = ffi.UnsignedShort; -typedef Dartushort = int; -typedef uint = ffi.UnsignedInt; -typedef Dartuint = int; -typedef u_quad_t = u_int64_t; -typedef quad_t = ffi.Int64; -typedef Dartquad_t = int; -typedef qaddr_t = ffi.Pointer; -typedef caddr_t = ffi.Pointer; -typedef daddr_t = ffi.Int32; -typedef Dartdaddr_t = int; -typedef fixpt_t = u_int32_t; -typedef blkcnt_t = __darwin_blkcnt_t; -typedef blksize_t = __darwin_blksize_t; -typedef gid_t = __darwin_gid_t; -typedef in_addr_t = __uint32_t; -typedef in_port_t = __uint16_t; -typedef ino_t = __darwin_ino_t; -typedef ino64_t = __darwin_ino64_t; -typedef key_t = __int32_t; -typedef nlink_t = __uint16_t; -typedef off_t = __darwin_off_t; -typedef segsz_t = ffi.Int32; -typedef Dartsegsz_t = int; -typedef swblk_t = ffi.Int32; -typedef Dartswblk_t = int; -typedef clock_t = __darwin_clock_t; -typedef ssize_t = __darwin_ssize_t; -typedef time_t = __darwin_time_t; -typedef useconds_t = __darwin_useconds_t; -typedef suseconds_t = __darwin_suseconds_t; -typedef errno_t = ffi.Int; -typedef Darterrno_t = int; - -final class fd_set extends ffi.Struct { - @ffi.Array.multi([32]) - external ffi.Array<__int32_t> fds_bits; -} - -typedef fd_mask = __int32_t; -typedef pthread_cond_t = __darwin_pthread_cond_t; -typedef pthread_condattr_t = __darwin_pthread_condattr_t; -typedef pthread_mutex_t = __darwin_pthread_mutex_t; -typedef pthread_mutexattr_t = __darwin_pthread_mutexattr_t; -typedef pthread_once_t = __darwin_pthread_once_t; -typedef pthread_rwlock_t = __darwin_pthread_rwlock_t; -typedef pthread_rwlockattr_t = __darwin_pthread_rwlockattr_t; -typedef pthread_t = __darwin_pthread_t; -typedef pthread_key_t = __darwin_pthread_key_t; -typedef fsblkcnt_t = __darwin_fsblkcnt_t; -typedef fsfilcnt_t = __darwin_fsfilcnt_t; - -final class objc_class extends ffi.Opaque {} - -final class objc_object extends ffi.Struct { - external ffi.Pointer isaAsInt; -} - -final class objc_selector extends ffi.Opaque {} - -typedef IMPFunction = ffi.Void Function(); -typedef DartIMPFunction = void Function(); -typedef IMP = ffi.Pointer>; -typedef objc_zone_t = ffi.Pointer<_malloc_zone_t>; -typedef objc_objectptr_t = ffi.Pointer; -typedef NSInteger = ffi.Long; -typedef DartNSInteger = int; -typedef NSUInteger = ffi.UnsignedLong; -typedef DartNSUInteger = int; -typedef __gnuc_va_list = __builtin_va_list; -typedef va_list = __builtin_va_list; -typedef NSExceptionName = ffi.Pointer; -typedef DartNSExceptionName = objc.NSString; -typedef NSRunLoopMode = ffi.Pointer; -typedef DartNSRunLoopMode = objc.NSString; - -/// Construction methods for `objc.ObjCBlock, ffi.Pointer)>`. -abstract final class ObjCBlock_NSComparisonResult_objcObjCObjectImpl_objcObjCObjectImpl { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - fromFunction( - objc.NSComparisonResult Function(objc.ObjCObject, objc.ObjCObject) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - objc.ObjCObject(arg0, retain: true, release: true), - objc.ObjCObject(arg1, retain: true, release: true), - ).value, - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static int _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline, 0) - .cast(); - static int _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as int Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline, 0) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, ffi.Pointer)>`. -extension ObjCBlock_NSComparisonResult_objcObjCObjectImpl_objcObjCObjectImpl$CallExtension - on - objc.ObjCBlock< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > { - objc.NSComparisonResult call(objc.ObjCObject arg0, objc.ObjCObject arg1) => - objc.NSComparisonResult.fromValue( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer), - ); -} - -typedef NSComparator = ffi.Pointer; -typedef DartNSComparator = - objc.ObjCBlock< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - >; -typedef ptrauth_extra_data_t = ffi.UnsignedLong; -typedef Dartptrauth_extra_data_t = int; -typedef ptrauth_generic_signature_t = ffi.UnsignedLong; -typedef Dartptrauth_generic_signature_t = int; -typedef UInt8 = ffi.UnsignedChar; -typedef DartUInt8 = int; -typedef SInt8 = ffi.SignedChar; -typedef DartSInt8 = int; -typedef UInt16 = ffi.UnsignedShort; -typedef DartUInt16 = int; -typedef SInt16 = ffi.Short; -typedef DartSInt16 = int; -typedef UInt32 = ffi.UnsignedInt; -typedef DartUInt32 = int; -typedef SInt32 = ffi.Int; -typedef DartSInt32 = int; - -@ffi.Packed(2) -final class wide extends ffi.Struct { - @UInt32() - external int lo; - - @SInt32() - external int hi; -} - -@ffi.Packed(2) -final class UnsignedWide extends ffi.Struct { - @UInt32() - external int lo; - - @UInt32() - external int hi; -} - -typedef SInt64 = ffi.LongLong; -typedef DartSInt64 = int; -typedef UInt64 = ffi.UnsignedLongLong; -typedef DartUInt64 = int; -typedef Fixed = SInt32; -typedef FixedPtr = ffi.Pointer; -typedef Fract = SInt32; -typedef FractPtr = ffi.Pointer; -typedef UnsignedFixed = UInt32; -typedef UnsignedFixedPtr = ffi.Pointer; -typedef ShortFixed = ffi.Short; -typedef DartShortFixed = int; -typedef ShortFixedPtr = ffi.Pointer; -typedef Float32 = ffi.Float; -typedef DartFloat32 = double; -typedef Float64 = ffi.Double; -typedef DartFloat64 = double; - -final class Float80 extends ffi.Struct { - @SInt16() - external int exp$1; - - @ffi.Array.multi([4]) - external ffi.Array man; -} - -final class Float96 extends ffi.Struct { - @ffi.Array.multi([2]) - external ffi.Array exp$1; - - @ffi.Array.multi([4]) - external ffi.Array man; -} - -@ffi.Packed(2) -final class Float32Point extends ffi.Struct { - @Float32() - external double x; - - @Float32() - external double y; -} - -typedef Ptr = ffi.Pointer; -typedef Handle = ffi.Pointer; -typedef Size = ffi.Long; -typedef DartSize = int; -typedef OSErr = SInt16; -typedef OSStatus = SInt32; -typedef LogicalAddress = ffi.Pointer; -typedef ConstLogicalAddress = ffi.Pointer; -typedef PhysicalAddress = ffi.Pointer; -typedef BytePtr = ffi.Pointer; -typedef ByteCount = ffi.UnsignedLong; -typedef DartByteCount = int; -typedef ByteOffset = ffi.UnsignedLong; -typedef DartByteOffset = int; -typedef Duration = SInt32; -typedef AbsoluteTime = UnsignedWide; -typedef OptionBits = UInt32; -typedef ItemCount = ffi.UnsignedLong; -typedef DartItemCount = int; -typedef PBVersion = UInt32; -typedef ScriptCode = SInt16; -typedef LangCode = SInt16; -typedef RegionCode = SInt16; -typedef FourCharCode = UInt32; -typedef OSType = FourCharCode; -typedef ResType = FourCharCode; -typedef OSTypePtr = ffi.Pointer; -typedef ResTypePtr = ffi.Pointer; -typedef Boolean = ffi.UnsignedChar; -typedef DartBoolean = int; -typedef ProcPtrFunction = ffi.Long Function(); -typedef DartProcPtrFunction = int Function(); -typedef ProcPtr = ffi.Pointer>; -typedef Register68kProcPtrFunction = ffi.Void Function(); -typedef DartRegister68kProcPtrFunction = void Function(); -typedef Register68kProcPtr = - ffi.Pointer>; -typedef UniversalProcPtr = ProcPtr; -typedef ProcHandle = ffi.Pointer; -typedef UniversalProcHandle = ffi.Pointer; -typedef PRefCon = ffi.Pointer; -typedef URefCon = ffi.Pointer; -typedef SRefCon = ffi.Pointer; -typedef UnicodeScalarValue = UInt32; -typedef UTF32Char = UInt32; -typedef UniChar = UInt16; -typedef UTF16Char = UInt16; -typedef UTF8Char = UInt8; -typedef UniCharPtr = ffi.Pointer; -typedef UniCharCount = ffi.UnsignedLong; -typedef DartUniCharCount = int; -typedef UniCharCountPtr = ffi.Pointer; -typedef StringPtr = ffi.Pointer; -typedef StringHandle = ffi.Pointer; -typedef ConstStringPtr = ffi.Pointer; -typedef ConstStr255Param = ffi.Pointer; -typedef ConstStr63Param = ffi.Pointer; -typedef ConstStr32Param = ffi.Pointer; -typedef ConstStr31Param = ffi.Pointer; -typedef ConstStr27Param = ffi.Pointer; -typedef ConstStr15Param = ffi.Pointer; -typedef ConstStrFileNameParam = ConstStr63Param; - -@ffi.Packed(2) -final class ProcessSerialNumber extends ffi.Struct { - @UInt32() - external int highLongOfPSN; - - @UInt32() - external int lowLongOfPSN; -} - -typedef ProcessSerialNumberPtr = ffi.Pointer; - -final class Point extends ffi.Struct { - @ffi.Short() - external int v; - - @ffi.Short() - external int h; -} - -typedef PointPtr = ffi.Pointer; - -final class Rect extends ffi.Struct { - @ffi.Short() - external int top; - - @ffi.Short() - external int left; - - @ffi.Short() - external int bottom; - - @ffi.Short() - external int right; -} - -typedef RectPtr = ffi.Pointer; - -@ffi.Packed(2) -final class FixedPoint extends ffi.Struct { - @Fixed() - external int x; - - @Fixed() - external int y; -} - -@ffi.Packed(2) -final class FixedRect extends ffi.Struct { - @Fixed() - external int left; - - @Fixed() - external int top; - - @Fixed() - external int right; - - @Fixed() - external int bottom; -} - -typedef CharParameter = ffi.Short; -typedef DartCharParameter = int; -typedef Style = ffi.UnsignedChar; -typedef DartStyle = int; -typedef StyleParameter = ffi.Short; -typedef DartStyleParameter = int; -typedef StyleField = Style; -typedef TimeValue = SInt32; -typedef TimeScale = SInt32; -typedef CompTimeValue = wide; -typedef TimeValue64 = SInt64; - -final class TimeBaseRecord extends ffi.Opaque {} - -typedef TimeBase = ffi.Pointer; - -@ffi.Packed(2) -final class TimeRecord extends ffi.Struct { - external CompTimeValue value; - - @TimeScale() - external int scale; - - external TimeBase base; -} - -final class NumVersion extends ffi.Struct { - @UInt8() - external int nonRelRev; - - @UInt8() - external int stage; - - @UInt8() - external int minorAndBugRev; - - @UInt8() - external int majorRev; -} - -final class NumVersionVariant extends ffi.Union { - external NumVersion parts; - - @UInt32() - external int whole; -} - -typedef NumVersionVariantPtr = ffi.Pointer; -typedef NumVersionVariantHandle = ffi.Pointer; - -final class VersRec extends ffi.Struct { - external NumVersion numericVersion; - - @ffi.Short() - external int countryCode; - - @ffi.Array.multi([256]) - external ffi.Array shortVersion; - - @ffi.Array.multi([256]) - external ffi.Array reserved; -} - -typedef VersRecPtr = ffi.Pointer; -typedef VersRecHndl = ffi.Pointer; -typedef Byte = UInt8; -typedef SignedByte = SInt8; -typedef WidePtr = ffi.Pointer; -typedef UnsignedWidePtr = ffi.Pointer; -typedef extended80 = Float80; -typedef extended96 = Float96; -typedef VHSelect = SInt8; -typedef CFAllocatorTypeID = ffi.UnsignedLongLong; -typedef DartCFAllocatorTypeID = int; -typedef CFTypeID = ffi.UnsignedLong; -typedef DartCFTypeID = int; -typedef CFOptionFlags = ffi.UnsignedLong; -typedef DartCFOptionFlags = int; -typedef CFHashCode = ffi.UnsignedLong; -typedef DartCFHashCode = int; -typedef CFIndex = ffi.Long; -typedef DartCFIndex = int; -typedef CFTypeRef = ffi.Pointer; -typedef CFStringRef = ffi.Pointer; -typedef CFMutableStringRef = ffi.Pointer; -typedef CFPropertyListRef = CFTypeRef; - -enum CFComparisonResult { - kCFCompareLessThan(-1), - kCFCompareEqualTo(0), - kCFCompareGreaterThan(1); - - final int value; - const CFComparisonResult(this.value); - - static CFComparisonResult fromValue(int value) => switch (value) { - -1 => kCFCompareLessThan, - 0 => kCFCompareEqualTo, - 1 => kCFCompareGreaterThan, - _ => throw ArgumentError('Unknown value for CFComparisonResult: $value'), - }; -} - -typedef CFComparatorFunctionFunction = - CFIndex Function( - ffi.Pointer val1, - ffi.Pointer val2, - ffi.Pointer context, - ); -typedef DartCFComparatorFunctionFunction = - CFComparisonResult Function( - ffi.Pointer val1, - ffi.Pointer val2, - ffi.Pointer context, - ); -typedef CFComparatorFunction = - ffi.Pointer>; - -final class CFRange extends ffi.Struct { - @CFIndex() - external int location; - - @CFIndex() - external int length; -} - -final class __CFNull extends ffi.Opaque {} - -typedef CFNullRef = ffi.Pointer<__CFNull>; - -final class __CFAllocator extends ffi.Opaque {} - -typedef CFAllocatorRef = ffi.Pointer<__CFAllocator>; -typedef CFAllocatorRetainCallBackFunction = - ffi.Pointer Function(ffi.Pointer info); -typedef CFAllocatorRetainCallBack = - ffi.Pointer>; -typedef CFAllocatorReleaseCallBackFunction = - ffi.Void Function(ffi.Pointer info); -typedef DartCFAllocatorReleaseCallBackFunction = - void Function(ffi.Pointer info); -typedef CFAllocatorReleaseCallBack = - ffi.Pointer>; -typedef CFAllocatorCopyDescriptionCallBackFunction = - CFStringRef Function(ffi.Pointer info); -typedef CFAllocatorCopyDescriptionCallBack = - ffi.Pointer>; -typedef CFAllocatorAllocateCallBackFunction = - ffi.Pointer Function( - CFIndex allocSize, - CFOptionFlags hint, - ffi.Pointer info, - ); -typedef DartCFAllocatorAllocateCallBackFunction = - ffi.Pointer Function( - DartCFIndex allocSize, - DartCFOptionFlags hint, - ffi.Pointer info, - ); -typedef CFAllocatorAllocateCallBack = - ffi.Pointer>; -typedef CFAllocatorReallocateCallBackFunction = - ffi.Pointer Function( - ffi.Pointer ptr, - CFIndex newsize, - CFOptionFlags hint, - ffi.Pointer info, - ); -typedef DartCFAllocatorReallocateCallBackFunction = - ffi.Pointer Function( - ffi.Pointer ptr, - DartCFIndex newsize, - DartCFOptionFlags hint, - ffi.Pointer info, - ); -typedef CFAllocatorReallocateCallBack = - ffi.Pointer>; -typedef CFAllocatorDeallocateCallBackFunction = - ffi.Void Function(ffi.Pointer ptr, ffi.Pointer info); -typedef DartCFAllocatorDeallocateCallBackFunction = - void Function(ffi.Pointer ptr, ffi.Pointer info); -typedef CFAllocatorDeallocateCallBack = - ffi.Pointer>; -typedef CFAllocatorPreferredSizeCallBackFunction = - CFIndex Function( - CFIndex size, - CFOptionFlags hint, - ffi.Pointer info, - ); -typedef DartCFAllocatorPreferredSizeCallBackFunction = - DartCFIndex Function( - DartCFIndex size, - DartCFOptionFlags hint, - ffi.Pointer info, - ); -typedef CFAllocatorPreferredSizeCallBack = - ffi.Pointer>; - -final class CFAllocatorContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external CFAllocatorRetainCallBack retain; - - external CFAllocatorReleaseCallBack release; - - external CFAllocatorCopyDescriptionCallBack copyDescription; - - external CFAllocatorAllocateCallBack allocate; - - external CFAllocatorReallocateCallBack reallocate; - - external CFAllocatorDeallocateCallBack deallocate; - - external CFAllocatorPreferredSizeCallBack preferredSize; -} - -typedef NSZone = objc.NSZone; -late final _class_NSObject = objc.getClass("NSObject"); -late final _sel_version = objc.registerName("version"); -final _objc_msgSend_1hz7y9r = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Long Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setVersion_ = objc.registerName("setVersion:"); -final _objc_msgSend_4sp4xj = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_classForCoder = objc.registerName("classForCoder"); -final _objc_msgSend_151sglz = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_replacementObjectForCoder_ = objc.registerName( - "replacementObjectForCoder:", -); -final _objc_msgSend_1sotr3r = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_awakeAfterUsingCoder_ = objc.registerName( - "awakeAfterUsingCoder:", -); - -/// NSCoderMethods -extension NSCoderMethods on objc.NSObject { - /// awakeAfterUsingCoder: - objc.ObjCObject? awakeAfterUsingCoder(objc.NSCoder coder) { - objc.checkOsVersionInternal( - 'NSObject.awakeAfterUsingCoder:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_awakeAfterUsingCoder_, - coder.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: false, release: true); - } - - /// classForCoder - objc.ObjCObject get classForCoder { - objc.checkOsVersionInternal( - 'NSObject.classForCoder', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_classForCoder); - return objc.ObjCObject($ret, retain: true, release: true); - } - - /// replacementObjectForCoder: - objc.ObjCObject? replacementObjectForCoder(objc.NSCoder coder) { - objc.checkOsVersionInternal( - 'NSObject.replacementObjectForCoder:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_replacementObjectForCoder_, - coder.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: true, release: true); - } - - /// setVersion: - static void setVersion(DartNSInteger aVersion) { - objc.checkOsVersionInternal( - 'NSObject.setVersion:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_4sp4xj(_class_NSObject, _sel_setVersion_, aVersion); - } - - /// version - static DartNSInteger version() { - objc.checkOsVersionInternal( - 'NSObject.version', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1hz7y9r(_class_NSObject, _sel_version); - } -} - -late final _sel_poseAsClass_ = objc.registerName("poseAsClass:"); -final _objc_msgSend_xtuoz7 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// NSDeprecatedMethods -extension NSDeprecatedMethods on objc.NSObject { - /// poseAsClass: - static void poseAsClass(objc.ObjCObject aClass) { - objc.checkOsVersionInternal( - 'NSObject.poseAsClass:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_xtuoz7( - _class_NSObject, - _sel_poseAsClass_, - aClass.ref.pointer, - ); - } -} - -late final _sel_autoContentAccessingProxy = objc.registerName( - "autoContentAccessingProxy", -); - -/// NSDiscardableContentProxy -extension NSDiscardableContentProxy on objc.NSObject { - /// autoContentAccessingProxy - objc.ObjCObject get autoContentAccessingProxy { - objc.checkOsVersionInternal( - 'NSObject.autoContentAccessingProxy', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_autoContentAccessingProxy, - ); - return objc.ObjCObject($ret, retain: true, release: true); - } -} - -/// ! -/// @enum NSURLCacheStoragePolicy -/// -/// @discussion The NSURLCacheStoragePolicy enum defines constants that -/// can be used to specify the type of storage that is allowable for an -/// NSCachedURLResponse object that is to be stored in an NSURLCache. -/// -/// @constant NSURLCacheStorageAllowed Specifies that storage in an -/// NSURLCache is allowed without restriction. -/// -/// @constant NSURLCacheStorageAllowedInMemoryOnly Specifies that -/// storage in an NSURLCache is allowed; however storage should be -/// done in memory only, no disk storage should be done. -/// -/// @constant NSURLCacheStorageNotAllowed Specifies that storage in an -/// NSURLCache is not allowed in any fashion, either in memory or on -/// disk. -enum NSURLCacheStoragePolicy { - NSURLCacheStorageAllowed(0), - NSURLCacheStorageAllowedInMemoryOnly(1), - NSURLCacheStorageNotAllowed(2); - - final int value; - const NSURLCacheStoragePolicy(this.value); - - static NSURLCacheStoragePolicy fromValue(int value) => switch (value) { - 0 => NSURLCacheStorageAllowed, - 1 => NSURLCacheStorageAllowedInMemoryOnly, - 2 => NSURLCacheStorageNotAllowed, - _ => throw ArgumentError( - 'Unknown value for NSURLCacheStoragePolicy: $value', - ), - }; -} - -/// WARNING: NSCachedURLResponse is a stub. To generate bindings for this class, include -/// NSCachedURLResponse in your config's objc-interfaces list. -/// -/// ! -/// @class NSCachedURLResponse -/// NSCachedURLResponse is a class whose objects functions as a wrapper for -/// objects that are stored in the framework's caching system. -/// It is used to maintain characteristics and attributes of a cached -/// object. -extension type NSCachedURLResponse._(objc.ObjCObject object$) - implements - objc.ObjCObject, - objc.NSObject, - objc.NSSecureCoding, - objc.NSCopying { - /// Constructs a [NSCachedURLResponse] that points to the same underlying object as [other]. - NSCachedURLResponse.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSCachedURLResponse', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - } - - /// Constructs a [NSCachedURLResponse] that wraps the given raw object pointer. - NSCachedURLResponse.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSCachedURLResponse', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - } -} - -late final _class_NSURLCache = objc.getClass("NSURLCache"); -late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); -final _objc_msgSend_19nvye5 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_sharedURLCache = objc.registerName("sharedURLCache"); -late final _sel_setSharedURLCache_ = objc.registerName("setSharedURLCache:"); -typedef instancetype = ffi.Pointer; -typedef Dartinstancetype = objc.ObjCObject; -late final _sel_initWithMemoryCapacity_diskCapacity_diskPath_ = objc - .registerName("initWithMemoryCapacity:diskCapacity:diskPath:"); -final _objc_msgSend_1dqnse5 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ffi.Pointer, - ) - >(); -late final _sel_initWithMemoryCapacity_diskCapacity_directoryURL_ = objc - .registerName("initWithMemoryCapacity:diskCapacity:directoryURL:"); -late final _class_NSURLRequest = objc.getClass("NSURLRequest"); -late final _sel_requestWithURL_ = objc.registerName("requestWithURL:"); -late final _sel_supportsSecureCoding = objc.registerName( - "supportsSecureCoding", -); -final _objc_msgSend_91o635 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_bool_ffiVoid { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock)> fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction arg0)> - > - ptr, - ) => objc.ObjCBlock)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock)> fromFunction( - bool Function(ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock)>( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn(arg0), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static bool _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast arg0)>>() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline, false) - .cast(); - static bool _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => (objc.getBlockClosure(block) as bool Function(ffi.Pointer))( - arg0, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline, false) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_bool_ffiVoid$CallExtension - on objc.ObjCBlock)> { - bool call(ffi.Pointer arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - bool Function(ffi.Pointer, ffi.Pointer) - >()(ref.pointer, arg0); -} - -/// ! -/// @enum NSURLRequestCachePolicy -/// -/// @discussion The NSURLRequestCachePolicy enum defines constants that -/// can be used to specify the type of interactions that take place with -/// the caching system when the URL loading system processes a request. -/// Specifically, these constants cover interactions that have to do -/// with whether already-existing cache data is returned to satisfy a -/// URL load request. -/// -/// @constant NSURLRequestUseProtocolCachePolicy Specifies that the -/// caching logic defined in the protocol implementation, if any, is -/// used for a particular URL load request. This is the default policy -/// for URL load requests. -/// -/// @constant NSURLRequestReloadIgnoringLocalCacheData Specifies that the -/// data for the URL load should be loaded from the origin source. No -/// existing local cache data, regardless of its freshness or validity, -/// should be used to satisfy a URL load request. -/// -/// @constant NSURLRequestReloadIgnoringLocalAndRemoteCacheData Specifies that -/// not only should the local cache data be ignored, but that proxies and -/// other intermediates should be instructed to disregard their caches -/// so far as the protocol allows. -/// -/// @constant NSURLRequestReloadIgnoringCacheData Older name for -/// NSURLRequestReloadIgnoringLocalCacheData. -/// -/// @constant NSURLRequestReturnCacheDataElseLoad Specifies that the -/// existing cache data should be used to satisfy a URL load request, -/// regardless of its age or expiration date. However, if there is no -/// existing data in the cache corresponding to a URL load request, -/// the URL is loaded from the origin source. -/// -/// @constant NSURLRequestReturnCacheDataDontLoad Specifies that the -/// existing cache data should be used to satisfy a URL load request, -/// regardless of its age or expiration date. However, if there is no -/// existing data in the cache corresponding to a URL load request, no -/// attempt is made to load the URL from the origin source, and the -/// load is considered to have failed. This constant specifies a -/// behavior that is similar to an "offline" mode. -/// -/// @constant NSURLRequestReloadRevalidatingCacheData Specifies that -/// the existing cache data may be used provided the origin source -/// confirms its validity, otherwise the URL is loaded from the -/// origin source. -enum NSURLRequestCachePolicy { - NSURLRequestUseProtocolCachePolicy(0), - NSURLRequestReloadIgnoringLocalCacheData(1), - NSURLRequestReloadIgnoringLocalAndRemoteCacheData(4), - NSURLRequestReturnCacheDataElseLoad(2), - NSURLRequestReturnCacheDataDontLoad(3), - NSURLRequestReloadRevalidatingCacheData(5); - - static const NSURLRequestReloadIgnoringCacheData = - NSURLRequestReloadIgnoringLocalCacheData; - - final int value; - const NSURLRequestCachePolicy(this.value); - - static NSURLRequestCachePolicy fromValue(int value) => switch (value) { - 0 => NSURLRequestUseProtocolCachePolicy, - 1 => NSURLRequestReloadIgnoringLocalCacheData, - 4 => NSURLRequestReloadIgnoringLocalAndRemoteCacheData, - 2 => NSURLRequestReturnCacheDataElseLoad, - 3 => NSURLRequestReturnCacheDataDontLoad, - 5 => NSURLRequestReloadRevalidatingCacheData, - _ => throw ArgumentError( - 'Unknown value for NSURLRequestCachePolicy: $value', - ), - }; - - @override - String toString() { - if (this == NSURLRequestReloadIgnoringLocalCacheData) - return "NSURLRequestCachePolicy.NSURLRequestReloadIgnoringLocalCacheData, NSURLRequestCachePolicy.NSURLRequestReloadIgnoringCacheData"; - return super.toString(); - } -} - -typedef NSTimeInterval = ffi.Double; -typedef DartNSTimeInterval = double; -late final _sel_requestWithURL_cachePolicy_timeoutInterval_ = objc.registerName( - "requestWithURL:cachePolicy:timeoutInterval:", -); -final _objc_msgSend_1ajs603 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ffi.Double, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - double, - ) - >(); -late final _sel_initWithURL_ = objc.registerName("initWithURL:"); -late final _sel_initWithURL_cachePolicy_timeoutInterval_ = objc.registerName( - "initWithURL:cachePolicy:timeoutInterval:", -); -late final _sel_URL = objc.registerName("URL"); -late final _sel_cachePolicy = objc.registerName("cachePolicy"); -final _objc_msgSend_8jm3uo = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSUInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_timeoutInterval = objc.registerName("timeoutInterval"); -final _objc_msgSend_1ukqyt8 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Double Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - double Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -final _objc_msgSend_1ukqyt8Fpret = objc.msgSendFpretPointer - .cast< - ffi.NativeFunction< - ffi.Double Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - double Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_mainDocumentURL = objc.registerName("mainDocumentURL"); - -/// ! -/// @enum NSURLRequestNetworkServiceType -/// -/// @discussion The NSURLRequestNetworkServiceType enum defines constants that -/// can be used to specify the service type to associate with this request. The -/// service type is used to provide the networking layers a hint of the purpose -/// of the request. -/// -/// @constant NSURLNetworkServiceTypeDefault Is the default value for an NSURLRequest -/// when created. This value should be left unchanged for the vast majority of requests. -/// -/// @constant NSURLNetworkServiceTypeVoIP Specifies that the request is for voice over IP -/// control traffic. -/// -/// @constant NSURLNetworkServiceTypeVideo Specifies that the request is for video -/// traffic. -/// -/// @constant NSURLNetworkServiceTypeBackground Specifies that the request is for background -/// traffic (such as a file download). -/// -/// @constant NSURLNetworkServiceTypeVoice Specifies that the request is for voice data. -/// -/// @constant NSURLNetworkServiceTypeResponsiveData Specifies that the request is for responsive (time sensitive) data. -/// -/// @constant NSURLNetworkServiceTypeAVStreaming Specifies that the request is streaming audio/video data. -/// -/// @constant NSURLNetworkServiceTypeResponsiveAV Specifies that the request is for responsive (time sensitive) audio/video data. -/// -/// @constant NSURLNetworkServiceTypeCallSignaling Specifies that the request is for call signaling. -enum NSURLRequestNetworkServiceType { - /// Standard internet traffic - NSURLNetworkServiceTypeDefault(0), - - /// Voice over IP control traffic - NSURLNetworkServiceTypeVoIP(1), - - /// Video traffic - NSURLNetworkServiceTypeVideo(2), - - /// Background traffic - NSURLNetworkServiceTypeBackground(3), - - /// Voice data - NSURLNetworkServiceTypeVoice(4), - - /// Responsive data - NSURLNetworkServiceTypeResponsiveData(6), - - /// Multimedia Audio/Video Streaming - NSURLNetworkServiceTypeAVStreaming(8), - - /// Responsive Multimedia Audio/Video - NSURLNetworkServiceTypeResponsiveAV(9), - - /// Call Signaling - NSURLNetworkServiceTypeCallSignaling(11); - - final int value; - const NSURLRequestNetworkServiceType(this.value); - - static NSURLRequestNetworkServiceType fromValue(int value) => switch (value) { - 0 => NSURLNetworkServiceTypeDefault, - 1 => NSURLNetworkServiceTypeVoIP, - 2 => NSURLNetworkServiceTypeVideo, - 3 => NSURLNetworkServiceTypeBackground, - 4 => NSURLNetworkServiceTypeVoice, - 6 => NSURLNetworkServiceTypeResponsiveData, - 8 => NSURLNetworkServiceTypeAVStreaming, - 9 => NSURLNetworkServiceTypeResponsiveAV, - 11 => NSURLNetworkServiceTypeCallSignaling, - _ => throw ArgumentError( - 'Unknown value for NSURLRequestNetworkServiceType: $value', - ), - }; -} - -late final _sel_networkServiceType = objc.registerName("networkServiceType"); -final _objc_msgSend_t4uaw1 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSUInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_allowsCellularAccess = objc.registerName( - "allowsCellularAccess", -); -late final _sel_allowsExpensiveNetworkAccess = objc.registerName( - "allowsExpensiveNetworkAccess", -); -late final _sel_allowsConstrainedNetworkAccess = objc.registerName( - "allowsConstrainedNetworkAccess", -); -late final _sel_assumesHTTP3Capable = objc.registerName("assumesHTTP3Capable"); - -/// ! -/// @enum NSURLRequestAttribution -/// -/// @discussion The NSURLRequestAttribution enum is used to indicate whether the -/// user or developer specified the URL. -/// -/// @constant NSURLRequestAttributionDeveloper Indicates that the URL was specified -/// by the developer. This is the default value for an NSURLRequest when created. -/// -/// @constant NSURLRequestAttributionUser Indicates that the URL was specified by -/// the user. -enum NSURLRequestAttribution { - NSURLRequestAttributionDeveloper(0), - NSURLRequestAttributionUser(1); - - final int value; - const NSURLRequestAttribution(this.value); - - static NSURLRequestAttribution fromValue(int value) => switch (value) { - 0 => NSURLRequestAttributionDeveloper, - 1 => NSURLRequestAttributionUser, - _ => throw ArgumentError( - 'Unknown value for NSURLRequestAttribution: $value', - ), - }; -} - -late final _sel_attribution = objc.registerName("attribution"); -final _objc_msgSend_i3avs9 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSUInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_requiresDNSSECValidation = objc.registerName( - "requiresDNSSECValidation", -); -late final _sel_allowsPersistentDNS = objc.registerName("allowsPersistentDNS"); -late final _sel_cookiePartitionIdentifier = objc.registerName( - "cookiePartitionIdentifier", -); -late final _sel_init = objc.registerName("init"); -late final _sel_new = objc.registerName("new"); -late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); -final _objc_msgSend_1cwp428 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_alloc = objc.registerName("alloc"); -late final _sel_encodeWithCoder_ = objc.registerName("encodeWithCoder:"); - -/// Construction methods for `objc.ObjCBlock, objc.NSCoder)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock, objc.NSCoder)> - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock, objc.NSCoder)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock, objc.NSCoder)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => objc.ObjCBlock, objc.NSCoder)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock, objc.NSCoder)> - fromFunction( - void Function(ffi.Pointer, objc.NSCoder) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock, objc.NSCoder)>( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, objc.NSCoder.fromPointer(arg1, retain: true, release: true)), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock, objc.NSCoder)> - listener( - void Function(ffi.Pointer, objc.NSCoder) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, - objc.NSCoder.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_18v1jvf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, objc.NSCoder) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock, objc.NSCoder)> - blocking( - void Function(ffi.Pointer, objc.NSCoder) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, - objc.NSCoder.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, - objc.NSCoder.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, objc.NSCoder) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, objc.NSCoder)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSCoder$CallExtension - on objc.ObjCBlock, objc.NSCoder)> { - void call(ffi.Pointer arg0, objc.NSCoder arg1) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer); -} - -late final _sel_initWithCoder_ = objc.registerName("initWithCoder:"); - -/// Construction methods for `objc.ObjCBlock?> Function(ffi.Pointer, objc.NSCoder)>`. -abstract final class ObjCBlock_instancetype_ffiVoid_NSCoder { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, - objc.NSCoder, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, - objc.NSCoder, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, - objc.NSCoder, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, - objc.NSCoder, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, - objc.NSCoder, - ) - > - fromFunction( - Dartinstancetype? Function(ffi.Pointer, objc.NSCoder) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, - objc.NSCoder, - ) - >( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn( - arg0, - objc.NSCoder.fromPointer(arg1, retain: true, release: true), - )?.ref.retainAndReturnPointer() ?? - ffi.nullptr, - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static instancetype _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static instancetype _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as instancetype Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock?> Function(ffi.Pointer, objc.NSCoder)>`. -extension ObjCBlock_instancetype_ffiVoid_NSCoder$CallExtension - on - objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, - objc.NSCoder, - ) - > { - Dartinstancetype? call(ffi.Pointer arg0, objc.NSCoder arg1) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer) - .address == - 0 - ? null - : objc.ObjCObject( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer), - retain: false, - release: true, - ); -} - -late final _sel_HTTPMethod = objc.registerName("HTTPMethod"); -late final _sel_allHTTPHeaderFields = objc.registerName("allHTTPHeaderFields"); -late final _sel_valueForHTTPHeaderField_ = objc.registerName( - "valueForHTTPHeaderField:", -); -late final _sel_HTTPBody = objc.registerName("HTTPBody"); -late final _sel_HTTPBodyStream = objc.registerName("HTTPBodyStream"); -late final _sel_HTTPShouldHandleCookies = objc.registerName( - "HTTPShouldHandleCookies", -); -late final _sel_HTTPShouldUsePipelining = objc.registerName( - "HTTPShouldUsePipelining", -); - -/// ! -/// @category NSURLRequest(NSHTTPURLRequest) -/// The NSHTTPURLRequest on NSURLRequest provides methods for accessing -/// information specific to HTTP protocol requests. -extension NSHTTPURLRequest on NSURLRequest { - /// ! - /// @abstract Returns the request body data of the receiver. - /// @discussion This data is sent as the message body of the request, as - /// in done in an HTTP POST request. - /// @result The request body data of the receiver. - objc.NSData? get HTTPBody { - objc.checkOsVersionInternal( - 'NSURLRequest.HTTPBody', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPBody); - return $ret.address == 0 - ? null - : objc.NSData.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Returns the request body stream of the receiver - /// if any has been set - /// @discussion The stream is returned for examination only; it is - /// not safe for the caller to manipulate the stream in any way. Also - /// note that the HTTPBodyStream and HTTPBody are mutually exclusive - only - /// one can be set on a given request. Also note that the body stream is - /// preserved across copies, but is LOST when the request is coded via the - /// NSCoding protocol - /// @result The request body stream of the receiver. - objc.NSInputStream? get HTTPBodyStream { - objc.checkOsVersionInternal( - 'NSURLRequest.HTTPBodyStream', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_HTTPBodyStream, - ); - return $ret.address == 0 - ? null - : objc.NSInputStream.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Returns the HTTP request method of the receiver. - /// @result the HTTP request method of the receiver. - objc.NSString? get HTTPMethod { - objc.checkOsVersionInternal( - 'NSURLRequest.HTTPMethod', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPMethod); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Determine whether default cookie handling will happen for - /// this request. - /// @discussion NOTE: This value is not used prior to 10.3 - /// @result YES if cookies will be sent with and set for this request; - /// otherwise NO. - bool get HTTPShouldHandleCookies { - objc.checkOsVersionInternal( - 'NSURLRequest.HTTPShouldHandleCookies', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldHandleCookies, - ); - } - - /// ! - /// @abstract Reports whether the receiver is not expected to wait for the - /// previous response before transmitting. - /// @result YES if the receiver should transmit before the previous response - /// is received. NO if the receiver should wait for the previous response - /// before transmitting. - bool get HTTPShouldUsePipelining { - objc.checkOsVersionInternal( - 'NSURLRequest.HTTPShouldUsePipelining', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 7, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldUsePipelining, - ); - } - - /// ! - /// @abstract Returns a dictionary containing all the HTTP header fields - /// of the receiver. - /// @result a dictionary containing all the HTTP header fields of the - /// receiver. - objc.NSDictionary? get allHTTPHeaderFields { - objc.checkOsVersionInternal( - 'NSURLRequest.allHTTPHeaderFields', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_allHTTPHeaderFields, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @method valueForHTTPHeaderField: - /// @abstract Returns the value which corresponds to the given header - /// field. Note that, in keeping with the HTTP RFC, HTTP header field - /// names are case-insensitive. - /// @param field the header field name to use for the lookup - /// (case-insensitive). - /// @result the value associated with the given header field, or nil if - /// there is no value associated with the given header field. - objc.NSString? valueForHTTPHeaderField(objc.NSString field) { - objc.checkOsVersionInternal( - 'NSURLRequest.valueForHTTPHeaderField:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_valueForHTTPHeaderField_, - field.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } -} - -/// NSURLRequest -extension type NSURLRequest._(objc.ObjCObject object$) - implements - objc.ObjCObject, - objc.NSObject, - objc.NSSecureCoding, - objc.NSCopying, - objc.NSMutableCopying { - /// Constructs a [NSURLRequest] that points to the same underlying object as [other]. - NSURLRequest.as(objc.ObjCObject other) : object$ = other { - assert(isA(object$)); - } - - /// Constructs a [NSURLRequest] that wraps the given raw object pointer. - NSURLRequest.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLRequest]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLRequest, - ); - - /// alloc - static NSURLRequest alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSURLRequest, _sel_alloc); - return NSURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSURLRequest allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLRequest, - _sel_allocWithZone_, - zone, - ); - return NSURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// new - static NSURLRequest new$() { - final $ret = _objc_msgSend_151sglz(_class_NSURLRequest, _sel_new); - return NSURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method requestWithURL: - /// @abstract Allocates and initializes an NSURLRequest with the given - /// URL. - /// @discussion Default values are used for cache policy - /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 - /// seconds). - /// @param URL The URL for the request. - /// @result A newly-created and autoreleased NSURLRequest instance. - static NSURLRequest requestWithURL(objc.NSURL URL) { - objc.checkOsVersionInternal( - 'NSURLRequest.requestWithURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSURLRequest, - _sel_requestWithURL_, - URL.ref.pointer, - ); - return NSURLRequest.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @method requestWithURL:cachePolicy:timeoutInterval: - /// @abstract Allocates and initializes a NSURLRequest with the given - /// URL and cache policy. - /// @param URL The URL for the request. - /// @param cachePolicy The cache policy for the request. - /// @param timeoutInterval The timeout interval for the request. See the - /// commentary for the timeoutInterval for more information on - /// timeout intervals. - /// @result A newly-created and autoreleased NSURLRequest instance. - static NSURLRequest requestWithURL$1( - objc.NSURL URL, { - required NSURLRequestCachePolicy cachePolicy, - required DartNSTimeInterval timeoutInterval, - }) { - objc.checkOsVersionInternal( - 'NSURLRequest.requestWithURL:cachePolicy:timeoutInterval:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1ajs603( - _class_NSURLRequest, - _sel_requestWithURL_cachePolicy_timeoutInterval_, - URL.ref.pointer, - cachePolicy.value, - timeoutInterval, - ); - return NSURLRequest.fromPointer($ret, retain: true, release: true); - } - - /// supportsSecureCoding - static bool getSupportsSecureCoding() { - return _objc_msgSend_91o635(_class_NSURLRequest, _sel_supportsSecureCoding); - } - - /// Returns a new instance of NSURLRequest constructed with the default `new` method. - NSURLRequest() : this.as(new$().object$); -} - -extension NSURLRequest$Methods on NSURLRequest { - /// ! - /// @abstract Returns the URL of the receiver. - /// @result The URL of the receiver. - objc.NSURL? get URL { - objc.checkOsVersionInternal( - 'NSURLRequest.URL', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URL); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract returns whether a connection created with this request is allowed to use - /// the built in cellular radios (if present). - /// @result YES if the receiver is allowed to use the built in cellular radios to - /// satisfy the request, NO otherwise. - bool get allowsCellularAccess { - objc.checkOsVersionInternal( - 'NSURLRequest.allowsCellularAccess', - iOS: (false, (6, 0, 0)), - macOS: (false, (10, 8, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsCellularAccess); - } - - /// ! - /// @abstract returns whether a connection created with this request is allowed to use - /// network interfaces which have been marked as constrained. - /// @result YES if the receiver is allowed to use an interface marked as constrained to - /// satisfy the request, NO otherwise. - bool get allowsConstrainedNetworkAccess { - objc.checkOsVersionInternal( - 'NSURLRequest.allowsConstrainedNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsConstrainedNetworkAccess, - ); - } - - /// ! - /// @abstract returns whether a connection created with this request is allowed to use - /// network interfaces which have been marked as expensive. - /// @result YES if the receiver is allowed to use an interface marked as expensive to - /// satisfy the request, NO otherwise. - bool get allowsExpensiveNetworkAccess { - objc.checkOsVersionInternal( - 'NSURLRequest.allowsExpensiveNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsExpensiveNetworkAccess, - ); - } - - /// ! - /// @abstract Allows storing and usage of DNS answers, potentially beyond TTL expiry, - /// in a persistent per-process cache. This should only be set for hostnames whose resolutions - /// are not expected to change across networks. - /// @discussion YES, if the DNS lookup for this request is allowed to use a persistent per-process cache, - /// NO otherwise. Defaults to NO. - bool get allowsPersistentDNS { - objc.checkOsVersionInternal( - 'NSURLRequest.allowsPersistentDNS', - iOS: (false, (18, 0, 0)), - macOS: (false, (15, 0, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsPersistentDNS); - } - - /// ! - /// @abstract returns whether we assume that server supports HTTP/3. Enables QUIC - /// racing without HTTP/3 service discovery. - /// @result YES if server endpoint is known to support HTTP/3. Defaults to NO. - /// The default may be YES in a future OS update. - bool get assumesHTTP3Capable { - objc.checkOsVersionInternal( - 'NSURLRequest.assumesHTTP3Capable', - iOS: (false, (14, 5, 0)), - macOS: (false, (11, 3, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_assumesHTTP3Capable); - } - - /// ! - /// @abstract Returns the NSURLRequestAttribution associated with this request. - /// @discussion This will return NSURLRequestAttributionDeveloper for requests that - /// have not explicitly set an attribution. - /// @result The NSURLRequestAttribution associated with this request. - NSURLRequestAttribution get attribution { - objc.checkOsVersionInternal( - 'NSURLRequest.attribution', - iOS: (false, (15, 0, 0)), - macOS: (false, (12, 0, 0)), - ); - final $ret = _objc_msgSend_i3avs9(object$.ref.pointer, _sel_attribution); - return NSURLRequestAttribution.fromValue($ret); - } - - /// ! - /// @abstract Returns the cache policy of the receiver. - /// @result The cache policy of the receiver. - NSURLRequestCachePolicy get cachePolicy { - objc.checkOsVersionInternal( - 'NSURLRequest.cachePolicy', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_8jm3uo(object$.ref.pointer, _sel_cachePolicy); - return NSURLRequestCachePolicy.fromValue($ret); - } - - /// Cookie partition identifier used for cookie storage and retrieval. - objc.NSString? get cookiePartitionIdentifier { - objc.checkOsVersionInternal( - 'NSURLRequest.cookiePartitionIdentifier', - iOS: (false, (18, 2, 0)), - macOS: (false, (15, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_cookiePartitionIdentifier, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// encodeWithCoder: - void encodeWithCoder(objc.NSCoder coder) { - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_encodeWithCoder_, - coder.ref.pointer, - ); - } - - /// init - NSURLRequest init() { - objc.checkOsVersionInternal( - 'NSURLRequest.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// initWithCoder: - NSURLRequest? initWithCoder(objc.NSCoder coder) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithCoder_, - coder.ref.pointer, - ); - return $ret.address == 0 - ? null - : NSURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithURL: - /// @abstract Initializes an NSURLRequest with the given URL. - /// @discussion Default values are used for cache policy - /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 - /// seconds). - /// @param URL The URL for the request. - /// @result An initialized NSURLRequest. - NSURLRequest initWithURL(objc.NSURL URL) { - objc.checkOsVersionInternal( - 'NSURLRequest.initWithURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithURL_, - URL.ref.pointer, - ); - return NSURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithURL: - /// @abstract Initializes an NSURLRequest with the given URL and - /// cache policy. - /// @discussion This is the designated initializer for the - /// NSURLRequest class. - /// @param URL The URL for the request. - /// @param cachePolicy The cache policy for the request. - /// @param timeoutInterval The timeout interval for the request. See the - /// commentary for the timeoutInterval for more information on - /// timeout intervals. - /// @result An initialized NSURLRequest. - NSURLRequest initWithURL$1( - objc.NSURL URL, { - required NSURLRequestCachePolicy cachePolicy, - required DartNSTimeInterval timeoutInterval, - }) { - objc.checkOsVersionInternal( - 'NSURLRequest.initWithURL:cachePolicy:timeoutInterval:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1ajs603( - object$.ref.retainAndReturnPointer(), - _sel_initWithURL_cachePolicy_timeoutInterval_, - URL.ref.pointer, - cachePolicy.value, - timeoutInterval, - ); - return NSURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @abstract The main document URL associated with this load. - /// @discussion This URL is used for the cookie "same domain as main - /// document" policy, and attributing the request as a sub-resource - /// of a user-specified URL. There may also be other future uses. - /// See setMainDocumentURL: - /// @result The main document URL. - objc.NSURL? get mainDocumentURL { - objc.checkOsVersionInternal( - 'NSURLRequest.mainDocumentURL', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_mainDocumentURL, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Returns the NSURLRequestNetworkServiceType associated with this request. - /// @discussion This will return NSURLNetworkServiceTypeDefault for requests that have - /// not explicitly set a networkServiceType (using the setNetworkServiceType method). - /// @result The NSURLRequestNetworkServiceType associated with this request. - NSURLRequestNetworkServiceType get networkServiceType { - objc.checkOsVersionInternal( - 'NSURLRequest.networkServiceType', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 7, 0)), - ); - final $ret = _objc_msgSend_t4uaw1( - object$.ref.pointer, - _sel_networkServiceType, - ); - return NSURLRequestNetworkServiceType.fromValue($ret); - } - - /// ! - /// @abstract sets whether a request is required to do DNSSEC validation during DNS lookup. - /// @discussion YES, if the DNS lookup for this request should require DNSSEC validation, - /// No otherwise. Defaults to NO. - bool get requiresDNSSECValidation { - objc.checkOsVersionInternal( - 'NSURLRequest.requiresDNSSECValidation', - iOS: (false, (16, 1, 0)), - macOS: (false, (13, 0, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_requiresDNSSECValidation, - ); - } - - /// ! - /// @abstract Returns the timeout interval of the receiver. - /// @discussion The timeout interval specifies the limit on the idle - /// interval allotted to a request in the process of loading. The "idle - /// interval" is defined as the period of time that has passed since the - /// last instance of load activity occurred for a request that is in the - /// process of loading. Hence, when an instance of load activity occurs - /// (e.g. bytes are received from the network for a request), the idle - /// interval for a request is reset to 0. If the idle interval ever - /// becomes greater than or equal to the timeout interval, the request - /// is considered to have timed out. This timeout interval is measured - /// in seconds. - /// @result The timeout interval of the receiver. - DartNSTimeInterval get timeoutInterval { - objc.checkOsVersionInternal( - 'NSURLRequest.timeoutInterval', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return objc.useMsgSendVariants - ? _objc_msgSend_1ukqyt8Fpret(object$.ref.pointer, _sel_timeoutInterval) - : _objc_msgSend_1ukqyt8(object$.ref.pointer, _sel_timeoutInterval); - } -} - -late final _sel_cachedResponseForRequest_ = objc.registerName( - "cachedResponseForRequest:", -); -late final _sel_storeCachedResponse_forRequest_ = objc.registerName( - "storeCachedResponse:forRequest:", -); -final _objc_msgSend_pfv6jd = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_removeCachedResponseForRequest_ = objc.registerName( - "removeCachedResponseForRequest:", -); -late final _sel_removeAllCachedResponses = objc.registerName( - "removeAllCachedResponses", -); -final _objc_msgSend_1pl9qdv = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_removeCachedResponsesSinceDate_ = objc.registerName( - "removeCachedResponsesSinceDate:", -); -late final _sel_memoryCapacity = objc.registerName("memoryCapacity"); -final _objc_msgSend_xw2lbc = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setMemoryCapacity_ = objc.registerName("setMemoryCapacity:"); -final _objc_msgSend_1i9r4xy = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_diskCapacity = objc.registerName("diskCapacity"); -late final _sel_setDiskCapacity_ = objc.registerName("setDiskCapacity:"); -late final _sel_currentMemoryUsage = objc.registerName("currentMemoryUsage"); -late final _sel_currentDiskUsage = objc.registerName("currentDiskUsage"); - -/// WARNING: NSURLSessionDataTask is a stub. To generate bindings for this class, include -/// NSURLSessionDataTask in your config's objc-interfaces list. -/// -/// NSURLSessionDataTask -extension type NSURLSessionDataTask._(objc.ObjCObject object$) - implements objc.ObjCObject, NSURLSessionTask { - /// Constructs a [NSURLSessionDataTask] that points to the same underlying object as [other]. - NSURLSessionDataTask.as(objc.ObjCObject other) : object$ = other {} - - /// Constructs a [NSURLSessionDataTask] that wraps the given raw object pointer. - NSURLSessionDataTask.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} -} - -late final _sel_storeCachedResponse_forDataTask_ = objc.registerName( - "storeCachedResponse:forDataTask:", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSCachedURLResponse { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(NSCachedURLResponse?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : NSCachedURLResponse.fromPointer( - arg0, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(NSCachedURLResponse?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : NSCachedURLResponse.fromPointer( - arg0, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(NSCachedURLResponse?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : NSCachedURLResponse.fromPointer( - arg0, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : NSCachedURLResponse.fromPointer( - arg0, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ) { - try { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - >() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSCachedURLResponse$CallExtension - on objc.ObjCBlock { - void call(NSCachedURLResponse? arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); -} - -late final _sel_getCachedResponseForDataTask_completionHandler_ = objc - .registerName("getCachedResponseForDataTask:completionHandler:"); -final _objc_msgSend_o762yo = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_removeCachedResponseForDataTask_ = objc.registerName( - "removeCachedResponseForDataTask:", -); - -/// NSURLSessionTaskAdditions -extension NSURLSessionTaskAdditions on NSURLCache { - /// getCachedResponseForDataTask:completionHandler: - void getCachedResponseForDataTask( - NSURLSessionDataTask dataTask, { - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLCache.getCachedResponseForDataTask:completionHandler:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_o762yo( - object$.ref.pointer, - _sel_getCachedResponseForDataTask_completionHandler_, - dataTask.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// removeCachedResponseForDataTask: - void removeCachedResponseForDataTask(NSURLSessionDataTask dataTask) { - objc.checkOsVersionInternal( - 'NSURLCache.removeCachedResponseForDataTask:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_removeCachedResponseForDataTask_, - dataTask.ref.pointer, - ); - } - - /// storeCachedResponse:forDataTask: - void storeCachedResponse$1( - NSCachedURLResponse cachedResponse, { - required NSURLSessionDataTask forDataTask, - }) { - objc.checkOsVersionInternal( - 'NSURLCache.storeCachedResponse:forDataTask:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_storeCachedResponse_forDataTask_, - cachedResponse.ref.pointer, - forDataTask.ref.pointer, - ); - } -} - -/// NSURLCache -extension type NSURLCache._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject { - /// Constructs a [NSURLCache] that points to the same underlying object as [other]. - NSURLCache.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLCache', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSURLCache] that wraps the given raw object pointer. - NSURLCache.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLCache', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLCache]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLCache, - ); - - /// alloc - static NSURLCache alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSURLCache, _sel_alloc); - return NSURLCache.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSURLCache allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLCache, - _sel_allocWithZone_, - zone, - ); - return NSURLCache.fromPointer($ret, retain: false, release: true); - } - - /// new - static NSURLCache new$() { - final $ret = _objc_msgSend_151sglz(_class_NSURLCache, _sel_new); - return NSURLCache.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @property sharedURLCache - /// @abstract Returns the shared NSURLCache instance or - /// sets the NSURLCache instance shared by all clients of - /// the current process. This will be the new object returned when - /// calls to the sharedURLCache method are made. - /// @discussion Unless set explicitly through a call to - /// +setSharedURLCache:, this method returns an NSURLCache - /// instance created with the following default values: - ///
    - ///
  • Memory capacity: 4 megabytes (4 * 1024 * 1024 bytes) - ///
  • Disk capacity: 20 megabytes (20 * 1024 * 1024 bytes) - ///
  • Disk path: (user home directory)/Library/Caches/(application bundle id) - ///
- ///

Users who do not have special caching requirements or - /// constraints should find the default shared cache instance - /// acceptable. If this default shared cache instance is not - /// acceptable, +setSharedURLCache: can be called to set a - /// different NSURLCache instance to be returned from this method. - /// Callers should take care to ensure that the setter is called - /// at a time when no other caller has a reference to the previously-set - /// shared URL cache. This is to prevent storing cache data from - /// becoming unexpectedly unretrievable. - /// @result the shared NSURLCache instance. - static void setSharedURLCache(NSURLCache value) { - objc.checkOsVersionInternal( - 'NSURLCache.setSharedURLCache:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_xtuoz7( - _class_NSURLCache, - _sel_setSharedURLCache_, - value.ref.pointer, - ); - } - - /// ! - /// @property sharedURLCache - /// @abstract Returns the shared NSURLCache instance or - /// sets the NSURLCache instance shared by all clients of - /// the current process. This will be the new object returned when - /// calls to the sharedURLCache method are made. - /// @discussion Unless set explicitly through a call to - /// +setSharedURLCache:, this method returns an NSURLCache - /// instance created with the following default values: - ///

    - ///
  • Memory capacity: 4 megabytes (4 * 1024 * 1024 bytes) - ///
  • Disk capacity: 20 megabytes (20 * 1024 * 1024 bytes) - ///
  • Disk path: (user home directory)/Library/Caches/(application bundle id) - ///
- ///

Users who do not have special caching requirements or - /// constraints should find the default shared cache instance - /// acceptable. If this default shared cache instance is not - /// acceptable, +setSharedURLCache: can be called to set a - /// different NSURLCache instance to be returned from this method. - /// Callers should take care to ensure that the setter is called - /// at a time when no other caller has a reference to the previously-set - /// shared URL cache. This is to prevent storing cache data from - /// becoming unexpectedly unretrievable. - /// @result the shared NSURLCache instance. - static NSURLCache getSharedURLCache() { - objc.checkOsVersionInternal( - 'NSURLCache.sharedURLCache', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(_class_NSURLCache, _sel_sharedURLCache); - return NSURLCache.fromPointer($ret, retain: true, release: true); - } - - /// Returns a new instance of NSURLCache constructed with the default `new` method. - NSURLCache() : this.as(new$().object$); -} - -extension NSURLCache$Methods on NSURLCache { - /// ! - /// @method cachedResponseForRequest: - /// @abstract Returns the NSCachedURLResponse stored in the cache with - /// the given request. - /// @discussion The method returns nil if there is no - /// NSCachedURLResponse stored using the given request. - /// @param request the NSURLRequest to use as a key for the lookup. - /// @result The NSCachedURLResponse stored in the cache with the given - /// request, or nil if there is no NSCachedURLResponse stored with the - /// given request. - NSCachedURLResponse? cachedResponseForRequest(NSURLRequest request) { - objc.checkOsVersionInternal( - 'NSURLCache.cachedResponseForRequest:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_cachedResponseForRequest_, - request.ref.pointer, - ); - return $ret.address == 0 - ? null - : NSCachedURLResponse.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Returns the current amount of space consumed by the - /// on-disk cache of the receiver. - /// @discussion This size, measured in bytes, indicates the current - /// usage of the on-disk cache. - /// @result the current usage of the on-disk cache of the receiver. - DartNSUInteger get currentDiskUsage { - objc.checkOsVersionInternal( - 'NSURLCache.currentDiskUsage', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_currentDiskUsage); - } - - /// ! - /// @abstract Returns the current amount of space consumed by the - /// in-memory cache of the receiver. - /// @discussion This size, measured in bytes, indicates the current - /// usage of the in-memory cache. - /// @result the current usage of the in-memory cache of the receiver. - DartNSUInteger get currentMemoryUsage { - objc.checkOsVersionInternal( - 'NSURLCache.currentMemoryUsage', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_currentMemoryUsage); - } - - /// ! - /// @abstract The on-disk capacity of the receiver. - /// @discussion The on-disk capacity, measured in bytes, for the receiver. On mutation the on-disk cache will truncate its contents to the size given, if necessary. - DartNSUInteger get diskCapacity { - objc.checkOsVersionInternal( - 'NSURLCache.diskCapacity', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_diskCapacity); - } - - /// init - NSURLCache init() { - objc.checkOsVersionInternal( - 'NSURLCache.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLCache.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithMemoryCapacity:diskCapacity:directoryURL: - /// @abstract Initializes an NSURLCache with the given capacity and directory. - /// @param memoryCapacity the capacity, measured in bytes, for the cache in memory. Or 0 to disable memory cache. - /// @param diskCapacity the capacity, measured in bytes, for the cache on disk. Or 0 to disable disk cache. - /// @param directoryURL the path to a directory on disk where the cache data is stored. Or nil for default directory. - /// @result an initialized NSURLCache, with the given capacity, optionally backed by disk. - NSURLCache initWithMemoryCapacity( - DartNSUInteger memoryCapacity, { - required DartNSUInteger diskCapacity, - objc.NSURL? directoryURL, - }) { - objc.checkOsVersionInternal( - 'NSURLCache.initWithMemoryCapacity:diskCapacity:directoryURL:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1dqnse5( - object$.ref.retainAndReturnPointer(), - _sel_initWithMemoryCapacity_diskCapacity_directoryURL_, - memoryCapacity, - diskCapacity, - directoryURL?.ref.pointer ?? ffi.nullptr, - ); - return NSURLCache.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithMemoryCapacity:diskCapacity:diskPath: - /// @abstract Initializes an NSURLCache with the given capacity and - /// path. - /// @discussion The returned NSURLCache is backed by disk, so - /// developers can be more liberal with space when choosing the - /// capacity for this kind of cache. A disk cache measured in the tens - /// of megabytes should be acceptable in most cases. - /// @param memoryCapacity the capacity, measured in bytes, for the cache in memory. - /// @param diskCapacity the capacity, measured in bytes, for the cache on disk. - /// @param path the path on disk where the cache data is stored. - /// @result an initialized NSURLCache, with the given capacity, backed - /// by disk. - NSURLCache initWithMemoryCapacity$1( - DartNSUInteger memoryCapacity, { - required DartNSUInteger diskCapacity, - objc.NSString? diskPath, - }) { - objc.checkOsVersionInternal( - 'NSURLCache.initWithMemoryCapacity:diskCapacity:diskPath:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1dqnse5( - object$.ref.retainAndReturnPointer(), - _sel_initWithMemoryCapacity_diskCapacity_diskPath_, - memoryCapacity, - diskCapacity, - diskPath?.ref.pointer ?? ffi.nullptr, - ); - return NSURLCache.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @abstract In-memory capacity of the receiver. - /// @discussion At the time this call is made, the in-memory cache will truncate its contents to the size given, if necessary. - /// @result The in-memory capacity, measured in bytes, for the receiver. - DartNSUInteger get memoryCapacity { - objc.checkOsVersionInternal( - 'NSURLCache.memoryCapacity', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_memoryCapacity); - } - - /// ! - /// @method removeAllCachedResponses - /// @abstract Clears the given cache, removing all NSCachedURLResponse - /// objects that it stores. - void removeAllCachedResponses() { - objc.checkOsVersionInternal( - 'NSURLCache.removeAllCachedResponses', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_removeAllCachedResponses); - } - - /// ! - /// @method removeCachedResponseForRequest: - /// @abstract Removes the NSCachedURLResponse from the cache that is - /// stored using the given request. - /// @discussion No action is taken if there is no NSCachedURLResponse - /// stored with the given request. - /// @param request the NSURLRequest to use as a key for the lookup. - void removeCachedResponseForRequest(NSURLRequest request) { - objc.checkOsVersionInternal( - 'NSURLCache.removeCachedResponseForRequest:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_removeCachedResponseForRequest_, - request.ref.pointer, - ); - } - - /// ! - /// @method removeCachedResponsesSince: - /// @abstract Clears the given cache of any cached responses since the provided date. - void removeCachedResponsesSinceDate(objc.NSDate date) { - objc.checkOsVersionInternal( - 'NSURLCache.removeCachedResponsesSinceDate:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_removeCachedResponsesSinceDate_, - date.ref.pointer, - ); - } - - /// ! - /// @abstract The on-disk capacity of the receiver. - /// @discussion The on-disk capacity, measured in bytes, for the receiver. On mutation the on-disk cache will truncate its contents to the size given, if necessary. - set diskCapacity(DartNSUInteger value) { - objc.checkOsVersionInternal( - 'NSURLCache.setDiskCapacity:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_1i9r4xy(object$.ref.pointer, _sel_setDiskCapacity_, value); - } - - /// ! - /// @abstract In-memory capacity of the receiver. - /// @discussion At the time this call is made, the in-memory cache will truncate its contents to the size given, if necessary. - /// @result The in-memory capacity, measured in bytes, for the receiver. - set memoryCapacity(DartNSUInteger value) { - objc.checkOsVersionInternal( - 'NSURLCache.setMemoryCapacity:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_1i9r4xy(object$.ref.pointer, _sel_setMemoryCapacity_, value); - } - - /// ! - /// @method storeCachedResponse:forRequest: - /// @abstract Stores the given NSCachedURLResponse in the cache using - /// the given request. - /// @param cachedResponse The cached response to store. - /// @param request the NSURLRequest to use as a key for the storage. - void storeCachedResponse( - NSCachedURLResponse cachedResponse, { - required NSURLRequest forRequest, - }) { - objc.checkOsVersionInternal( - 'NSURLCache.storeCachedResponse:forRequest:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_storeCachedResponse_forRequest_, - cachedResponse.ref.pointer, - forRequest.ref.pointer, - ); - } -} - -typedef NSNotificationName = ffi.Pointer; -typedef DartNSNotificationName = objc.NSString; -late final _class_NSNotification = objc.getClass("NSNotification"); -late final _sel_notificationWithName_object_ = objc.registerName( - "notificationWithName:object:", -); -final _objc_msgSend_15qeuct = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_notificationWithName_object_userInfo_ = objc.registerName( - "notificationWithName:object:userInfo:", -); -final _objc_msgSend_11spmsz = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// NSNotificationCreation -extension NSNotificationCreation on objc.NSNotification { - /// init - objc.NSNotification init$1() { - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return objc.NSNotification.fromPointer($ret, retain: false, release: true); - } - - /// notificationWithName:object: - static objc.NSNotification notificationWithName( - DartNSNotificationName aName, { - objc.ObjCObject? object, - }) { - final $ret = _objc_msgSend_15qeuct( - _class_NSNotification, - _sel_notificationWithName_object_, - aName.ref.pointer, - object?.ref.pointer ?? ffi.nullptr, - ); - return objc.NSNotification.fromPointer($ret, retain: true, release: true); - } - - /// notificationWithName:object:userInfo: - static objc.NSNotification notificationWithName$1( - DartNSNotificationName aName, { - objc.ObjCObject? object, - objc.NSDictionary? userInfo, - }) { - final $ret = _objc_msgSend_11spmsz( - _class_NSNotification, - _sel_notificationWithName_object_userInfo_, - aName.ref.pointer, - object?.ref.pointer ?? ffi.nullptr, - userInfo?.ref.pointer ?? ffi.nullptr, - ); - return objc.NSNotification.fromPointer($ret, retain: true, release: true); - } -} - -late final _class_NSDate = objc.getClass("NSDate"); -late final _sel_date = objc.registerName("date"); -late final _sel_dateWithTimeIntervalSinceNow_ = objc.registerName( - "dateWithTimeIntervalSinceNow:", -); -final _objc_msgSend_oa8mke = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Double, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - double, - ) - >(); -late final _sel_dateWithTimeIntervalSinceReferenceDate_ = objc.registerName( - "dateWithTimeIntervalSinceReferenceDate:", -); -late final _sel_dateWithTimeIntervalSince1970_ = objc.registerName( - "dateWithTimeIntervalSince1970:", -); -late final _sel_dateWithTimeInterval_sinceDate_ = objc.registerName( - "dateWithTimeInterval:sinceDate:", -); -final _objc_msgSend_1ozwf6k = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Double, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - double, - ffi.Pointer, - ) - >(); -late final _sel_distantFuture = objc.registerName("distantFuture"); -late final _sel_distantPast = objc.registerName("distantPast"); -late final _sel_now = objc.registerName("now"); -late final _sel_initWithTimeIntervalSinceNow_ = objc.registerName( - "initWithTimeIntervalSinceNow:", -); -late final _sel_initWithTimeIntervalSince1970_ = objc.registerName( - "initWithTimeIntervalSince1970:", -); -late final _sel_initWithTimeInterval_sinceDate_ = objc.registerName( - "initWithTimeInterval:sinceDate:", -); - -/// NSDateCreation -extension NSDateCreation on objc.NSDate { - /// initWithTimeInterval:sinceDate: - objc.NSDate initWithTimeInterval( - DartNSTimeInterval secsToBeAdded, { - required objc.NSDate sinceDate, - }) { - final $ret = _objc_msgSend_1ozwf6k( - object$.ref.retainAndReturnPointer(), - _sel_initWithTimeInterval_sinceDate_, - secsToBeAdded, - sinceDate.ref.pointer, - ); - return objc.NSDate.fromPointer($ret, retain: false, release: true); - } - - /// initWithTimeIntervalSince1970: - objc.NSDate initWithTimeIntervalSince1970(DartNSTimeInterval secs) { - final $ret = _objc_msgSend_oa8mke( - object$.ref.retainAndReturnPointer(), - _sel_initWithTimeIntervalSince1970_, - secs, - ); - return objc.NSDate.fromPointer($ret, retain: false, release: true); - } - - /// initWithTimeIntervalSinceNow: - objc.NSDate initWithTimeIntervalSinceNow(DartNSTimeInterval secs) { - final $ret = _objc_msgSend_oa8mke( - object$.ref.retainAndReturnPointer(), - _sel_initWithTimeIntervalSinceNow_, - secs, - ); - return objc.NSDate.fromPointer($ret, retain: false, release: true); - } - - /// date - static objc.NSDate date() { - final $ret = _objc_msgSend_151sglz(_class_NSDate, _sel_date); - return objc.NSDate.fromPointer($ret, retain: true, release: true); - } - - /// dateWithTimeInterval:sinceDate: - static objc.NSDate dateWithTimeInterval( - DartNSTimeInterval secsToBeAdded, { - required objc.NSDate sinceDate, - }) { - final $ret = _objc_msgSend_1ozwf6k( - _class_NSDate, - _sel_dateWithTimeInterval_sinceDate_, - secsToBeAdded, - sinceDate.ref.pointer, - ); - return objc.NSDate.fromPointer($ret, retain: true, release: true); - } - - /// dateWithTimeIntervalSince1970: - static objc.NSDate dateWithTimeIntervalSince1970(DartNSTimeInterval secs) { - final $ret = _objc_msgSend_oa8mke( - _class_NSDate, - _sel_dateWithTimeIntervalSince1970_, - secs, - ); - return objc.NSDate.fromPointer($ret, retain: true, release: true); - } - - /// dateWithTimeIntervalSinceNow: - static objc.NSDate dateWithTimeIntervalSinceNow(DartNSTimeInterval secs) { - final $ret = _objc_msgSend_oa8mke( - _class_NSDate, - _sel_dateWithTimeIntervalSinceNow_, - secs, - ); - return objc.NSDate.fromPointer($ret, retain: true, release: true); - } - - /// dateWithTimeIntervalSinceReferenceDate: - static objc.NSDate dateWithTimeIntervalSinceReferenceDate( - DartNSTimeInterval ti, - ) { - final $ret = _objc_msgSend_oa8mke( - _class_NSDate, - _sel_dateWithTimeIntervalSinceReferenceDate_, - ti, - ); - return objc.NSDate.fromPointer($ret, retain: true, release: true); - } - - /// distantFuture - static objc.NSDate getDistantFuture() { - final $ret = _objc_msgSend_151sglz(_class_NSDate, _sel_distantFuture); - return objc.NSDate.fromPointer($ret, retain: true, release: true); - } - - /// distantPast - static objc.NSDate getDistantPast() { - final $ret = _objc_msgSend_151sglz(_class_NSDate, _sel_distantPast); - return objc.NSDate.fromPointer($ret, retain: true, release: true); - } - - /// now - static objc.NSDate getNow() { - objc.checkOsVersionInternal( - 'NSDate.now', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_151sglz(_class_NSDate, _sel_now); - return objc.NSDate.fromPointer($ret, retain: true, release: true); - } -} - -late final _class_NSMutableURLRequest = objc.getClass("NSMutableURLRequest"); -late final _sel_setURL_ = objc.registerName("setURL:"); -late final _sel_setCachePolicy_ = objc.registerName("setCachePolicy:"); -final _objc_msgSend_1yjxuv2 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_setTimeoutInterval_ = objc.registerName("setTimeoutInterval:"); -final _objc_msgSend_hwm8nu = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Double, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - double, - ) - >(); -late final _sel_setMainDocumentURL_ = objc.registerName("setMainDocumentURL:"); -late final _sel_setNetworkServiceType_ = objc.registerName( - "setNetworkServiceType:", -); -final _objc_msgSend_1mse4s1 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_setAllowsCellularAccess_ = objc.registerName( - "setAllowsCellularAccess:", -); -final _objc_msgSend_1s56lr9 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - bool, - ) - >(); -late final _sel_setAllowsExpensiveNetworkAccess_ = objc.registerName( - "setAllowsExpensiveNetworkAccess:", -); -late final _sel_setAllowsConstrainedNetworkAccess_ = objc.registerName( - "setAllowsConstrainedNetworkAccess:", -); -late final _sel_setAssumesHTTP3Capable_ = objc.registerName( - "setAssumesHTTP3Capable:", -); -late final _sel_setAttribution_ = objc.registerName("setAttribution:"); -final _objc_msgSend_1nw1jep = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_setRequiresDNSSECValidation_ = objc.registerName( - "setRequiresDNSSECValidation:", -); -late final _sel_setAllowsPersistentDNS_ = objc.registerName( - "setAllowsPersistentDNS:", -); -late final _sel_setCookiePartitionIdentifier_ = objc.registerName( - "setCookiePartitionIdentifier:", -); -late final _sel_setHTTPMethod_ = objc.registerName("setHTTPMethod:"); -late final _sel_setAllHTTPHeaderFields_ = objc.registerName( - "setAllHTTPHeaderFields:", -); -late final _sel_setValue_forHTTPHeaderField_ = objc.registerName( - "setValue:forHTTPHeaderField:", -); -late final _sel_addValue_forHTTPHeaderField_ = objc.registerName( - "addValue:forHTTPHeaderField:", -); -late final _sel_setHTTPBody_ = objc.registerName("setHTTPBody:"); -late final _sel_setHTTPBodyStream_ = objc.registerName("setHTTPBodyStream:"); -late final _sel_setHTTPShouldHandleCookies_ = objc.registerName( - "setHTTPShouldHandleCookies:", -); -late final _sel_setHTTPShouldUsePipelining_ = objc.registerName( - "setHTTPShouldUsePipelining:", -); - -/// ! -/// @category NSMutableURLRequest(NSMutableHTTPURLRequest) -/// The NSMutableHTTPURLRequest on NSMutableURLRequest provides methods -/// for configuring information specific to HTTP protocol requests. -extension NSMutableHTTPURLRequest on NSMutableURLRequest { - /// ! - /// @abstract Sets the request body data of the receiver. - /// @discussion This data is sent as the message body of the request, as - /// in done in an HTTP POST request. - objc.NSData? get HTTPBody { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.HTTPBody', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPBody); - return $ret.address == 0 - ? null - : objc.NSData.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Sets the request body to be the contents of the given stream. - /// @discussion The provided stream should be unopened; the request will take - /// over the stream's delegate. The entire stream's contents will be - /// transmitted as the HTTP body of the request. Note that the body stream - /// and the body data (set by setHTTPBody:, above) are mutually exclusive - /// - setting one will clear the other. - objc.NSInputStream? get HTTPBodyStream { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.HTTPBodyStream', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_HTTPBodyStream, - ); - return $ret.address == 0 - ? null - : objc.NSInputStream.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Sets the HTTP request method of the receiver. - objc.NSString get HTTPMethod { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.HTTPMethod', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPMethod); - return objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Decide whether default cookie handling will happen for - /// this request (YES if cookies should be sent with and set for this request; - /// otherwise NO). - /// @discussion The default is YES - in other words, cookies are sent from and - /// stored to the cookie manager by default. - /// NOTE: In releases prior to 10.3, this value is ignored - bool get HTTPShouldHandleCookies { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.HTTPShouldHandleCookies', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldHandleCookies, - ); - } - - /// ! - /// @abstract Sets whether the request should not wait for the previous response - /// before transmitting (YES if the receiver should transmit before the previous response is - /// received. NO to wait for the previous response before transmitting) - /// @discussion Calling this method with a YES value does not guarantee HTTP - /// pipelining behavior. This method may have no effect if an HTTP proxy is - /// configured, or if the HTTP request uses an unsafe request method (e.g., POST - /// requests will not pipeline). Pipelining behavior also may not begin until - /// the second request on a given TCP connection. There may be other situations - /// where pipelining does not occur even though YES was set. - /// HTTP 1.1 allows the client to send multiple requests to the server without - /// waiting for a response. Though HTTP 1.1 requires support for pipelining, - /// some servers report themselves as being HTTP 1.1 but do not support - /// pipelining (disconnecting, sending resources misordered, omitting part of - /// a resource, etc.). - bool get HTTPShouldUsePipelining { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.HTTPShouldUsePipelining', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 7, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldUsePipelining, - ); - } - - /// ! - /// @method addValue:forHTTPHeaderField: - /// @abstract Adds an HTTP header field in the current header - /// dictionary. - /// @discussion This method provides a way to add values to header - /// fields incrementally. If a value was previously set for the given - /// header field, the given value is appended to the previously-existing - /// value. The appropriate field delimiter, a comma in the case of HTTP, - /// is added by the implementation, and should not be added to the given - /// value by the caller. Note that, in keeping with the HTTP RFC, HTTP - /// header field names are case-insensitive. - /// @param value the header field value. - /// @param field the header field name (case-insensitive). - void addValue( - objc.NSString value, { - required objc.NSString forHTTPHeaderField, - }) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.addValue:forHTTPHeaderField:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_addValue_forHTTPHeaderField_, - value.ref.pointer, - forHTTPHeaderField.ref.pointer, - ); - } - - /// ! - /// @abstract Sets the HTTP header fields of the receiver to the given - /// dictionary. - /// @discussion This method replaces all header fields that may have - /// existed before this method call. - ///

Since HTTP header fields must be string values, each object and - /// key in the dictionary passed to this method must answer YES when - /// sent an -isKindOfClass:[NSString class] message. If either - /// the key or value for a key-value pair answers NO when sent this - /// message, the key-value pair is skipped. - objc.NSDictionary? get allHTTPHeaderFields { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.allHTTPHeaderFields', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_allHTTPHeaderFields, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Sets the HTTP header fields of the receiver to the given - /// dictionary. - /// @discussion This method replaces all header fields that may have - /// existed before this method call. - ///

Since HTTP header fields must be string values, each object and - /// key in the dictionary passed to this method must answer YES when - /// sent an -isKindOfClass:[NSString class] message. If either - /// the key or value for a key-value pair answers NO when sent this - /// message, the key-value pair is skipped. - set allHTTPHeaderFields(objc.NSDictionary? value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setAllHTTPHeaderFields:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setAllHTTPHeaderFields_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// ! - /// @abstract Sets the request body data of the receiver. - /// @discussion This data is sent as the message body of the request, as - /// in done in an HTTP POST request. - set HTTPBody(objc.NSData? value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPBody:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPBody_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// ! - /// @abstract Sets the request body to be the contents of the given stream. - /// @discussion The provided stream should be unopened; the request will take - /// over the stream's delegate. The entire stream's contents will be - /// transmitted as the HTTP body of the request. Note that the body stream - /// and the body data (set by setHTTPBody:, above) are mutually exclusive - /// - setting one will clear the other. - set HTTPBodyStream(objc.NSInputStream? value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPBodyStream:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPBodyStream_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// ! - /// @abstract Sets the HTTP request method of the receiver. - set HTTPMethod(objc.NSString value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPMethod:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPMethod_, - value.ref.pointer, - ); - } - - /// ! - /// @abstract Decide whether default cookie handling will happen for - /// this request (YES if cookies should be sent with and set for this request; - /// otherwise NO). - /// @discussion The default is YES - in other words, cookies are sent from and - /// stored to the cookie manager by default. - /// NOTE: In releases prior to 10.3, this value is ignored - set HTTPShouldHandleCookies(bool value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPShouldHandleCookies:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setHTTPShouldHandleCookies_, - value, - ); - } - - /// ! - /// @abstract Sets whether the request should not wait for the previous response - /// before transmitting (YES if the receiver should transmit before the previous response is - /// received. NO to wait for the previous response before transmitting) - /// @discussion Calling this method with a YES value does not guarantee HTTP - /// pipelining behavior. This method may have no effect if an HTTP proxy is - /// configured, or if the HTTP request uses an unsafe request method (e.g., POST - /// requests will not pipeline). Pipelining behavior also may not begin until - /// the second request on a given TCP connection. There may be other situations - /// where pipelining does not occur even though YES was set. - /// HTTP 1.1 allows the client to send multiple requests to the server without - /// waiting for a response. Though HTTP 1.1 requires support for pipelining, - /// some servers report themselves as being HTTP 1.1 but do not support - /// pipelining (disconnecting, sending resources misordered, omitting part of - /// a resource, etc.). - set HTTPShouldUsePipelining(bool value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPShouldUsePipelining:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 7, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setHTTPShouldUsePipelining_, - value, - ); - } - - /// ! - /// @method setValue:forHTTPHeaderField: - /// @abstract Sets the value of the given HTTP header field. - /// @discussion If a value was previously set for the given header - /// field, that value is replaced with the given value. Note that, in - /// keeping with the HTTP RFC, HTTP header field names are - /// case-insensitive. - /// @param value the header field value. - /// @param field the header field name (case-insensitive). - void setValue( - objc.NSString? value, { - required objc.NSString forHTTPHeaderField, - }) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setValue:forHTTPHeaderField:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_setValue_forHTTPHeaderField_, - value?.ref.pointer ?? ffi.nullptr, - forHTTPHeaderField.ref.pointer, - ); - } -} - -/// ! -/// @class NSMutableURLRequest -/// -/// @abstract An NSMutableURLRequest object represents a mutable URL load -/// request in a manner independent of protocol and URL scheme. -/// -/// @discussion This specialization of NSURLRequest is provided to aid -/// developers who may find it more convenient to mutate a single request -/// object for a series of URL loads instead of creating an immutable -/// NSURLRequest for each load. This programming model is supported by -/// the following contract stipulation between NSMutableURLRequest and -/// NSURLConnection: NSURLConnection makes a deep copy of each -/// NSMutableURLRequest object passed to one of its initializers. -///

NSMutableURLRequest is designed to be extended to support -/// protocol-specific data by adding categories to access a property -/// object provided in an interface targeted at protocol implementors. -///

    -///
  • Protocol implementors should direct their attention to the -/// NSMutableURLRequestExtensibility category on -/// NSMutableURLRequest for more information on how to provide -/// extensions on NSMutableURLRequest to support protocol-specific -/// request information. -///
  • Clients of this API who wish to create NSMutableURLRequest -/// objects to load URL content should consult the protocol-specific -/// NSMutableURLRequest categories that are available. The -/// NSMutableHTTPURLRequest category on NSMutableURLRequest is an -/// example. -///
-extension type NSMutableURLRequest._(objc.ObjCObject object$) - implements objc.ObjCObject, NSURLRequest { - /// Constructs a [NSMutableURLRequest] that points to the same underlying object as [other]. - NSMutableURLRequest.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSMutableURLRequest', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSMutableURLRequest] that wraps the given raw object pointer. - NSMutableURLRequest.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSMutableURLRequest]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMutableURLRequest, - ); - - /// alloc - static NSMutableURLRequest alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSMutableURLRequest, _sel_alloc); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSMutableURLRequest allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSMutableURLRequest, - _sel_allocWithZone_, - zone, - ); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// new - static NSMutableURLRequest new$() { - final $ret = _objc_msgSend_151sglz(_class_NSMutableURLRequest, _sel_new); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method requestWithURL: - /// @abstract Allocates and initializes an NSURLRequest with the given - /// URL. - /// @discussion Default values are used for cache policy - /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 - /// seconds). - /// @param URL The URL for the request. - /// @result A newly-created and autoreleased NSURLRequest instance. - static NSMutableURLRequest requestWithURL(objc.NSURL URL) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.requestWithURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSMutableURLRequest, - _sel_requestWithURL_, - URL.ref.pointer, - ); - return NSMutableURLRequest.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @method requestWithURL:cachePolicy:timeoutInterval: - /// @abstract Allocates and initializes a NSURLRequest with the given - /// URL and cache policy. - /// @param URL The URL for the request. - /// @param cachePolicy The cache policy for the request. - /// @param timeoutInterval The timeout interval for the request. See the - /// commentary for the timeoutInterval for more information on - /// timeout intervals. - /// @result A newly-created and autoreleased NSURLRequest instance. - static NSMutableURLRequest requestWithURL$1( - objc.NSURL URL, { - required NSURLRequestCachePolicy cachePolicy, - required DartNSTimeInterval timeoutInterval, - }) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.requestWithURL:cachePolicy:timeoutInterval:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1ajs603( - _class_NSMutableURLRequest, - _sel_requestWithURL_cachePolicy_timeoutInterval_, - URL.ref.pointer, - cachePolicy.value, - timeoutInterval, - ); - return NSMutableURLRequest.fromPointer($ret, retain: true, release: true); - } - - /// supportsSecureCoding - static bool getSupportsSecureCoding() { - return _objc_msgSend_91o635( - _class_NSMutableURLRequest, - _sel_supportsSecureCoding, - ); - } - - /// Returns a new instance of NSMutableURLRequest constructed with the default `new` method. - NSMutableURLRequest() : this.as(new$().object$); -} - -extension NSMutableURLRequest$Methods on NSMutableURLRequest { - /// ! - /// @abstract The URL of the receiver. - objc.NSURL? get URL { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.URL', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URL); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract sets whether a connection created with this request is allowed to use - /// the built in cellular radios (if present). - /// @discussion NO if the receiver should not be allowed to use the built in - /// cellular radios to satisfy the request, YES otherwise. The default is YES. - bool get allowsCellularAccess { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.allowsCellularAccess', - iOS: (false, (6, 0, 0)), - macOS: (false, (10, 8, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsCellularAccess); - } - - /// ! - /// @abstract sets whether a connection created with this request is allowed to use - /// network interfaces which have been marked as constrained. - /// @discussion NO if the receiver should not be allowed to use an interface marked as constrained to - /// satisfy the request, YES otherwise. - bool get allowsConstrainedNetworkAccess { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.allowsConstrainedNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsConstrainedNetworkAccess, - ); - } - - /// ! - /// @abstract sets whether a connection created with this request is allowed to use - /// network interfaces which have been marked as expensive. - /// @discussion NO if the receiver should not be allowed to use an interface marked as expensive to - /// satisfy the request, YES otherwise. - bool get allowsExpensiveNetworkAccess { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.allowsExpensiveNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsExpensiveNetworkAccess, - ); - } - - /// ! - /// @abstract Allows storing and usage of DNS answers, potentially beyond TTL expiry, - /// in a persistent per-process cache. This should only be set for hostnames whose resolutions - /// are not expected to change across networks. - /// @discussion YES, if the DNS lookup for this request is allowed to use a persistent per-process cache, - /// NO otherwise. Defaults to NO. - bool get allowsPersistentDNS { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.allowsPersistentDNS', - iOS: (false, (18, 0, 0)), - macOS: (false, (15, 0, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsPersistentDNS); - } - - /// ! - /// @abstract returns whether we assume that server supports HTTP/3. Enables QUIC - /// racing without HTTP/3 service discovery. - /// @result YES if server endpoint is known to support HTTP/3. Defaults to NO. - /// The default may be YES in a future OS update. - bool get assumesHTTP3Capable { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.assumesHTTP3Capable', - iOS: (false, (14, 5, 0)), - macOS: (false, (11, 3, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_assumesHTTP3Capable); - } - - /// ! - /// @abstract Sets the NSURLRequestAttribution to associate with this request. - /// @discussion Set to NSURLRequestAttributionUser if the URL was specified by the - /// user. Defaults to NSURLRequestAttributionDeveloper. - NSURLRequestAttribution get attribution { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.attribution', - iOS: (false, (15, 0, 0)), - macOS: (false, (12, 0, 0)), - ); - final $ret = _objc_msgSend_i3avs9(object$.ref.pointer, _sel_attribution); - return NSURLRequestAttribution.fromValue($ret); - } - - /// ! - /// @abstract The cache policy of the receiver. - NSURLRequestCachePolicy get cachePolicy { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.cachePolicy', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_8jm3uo(object$.ref.pointer, _sel_cachePolicy); - return NSURLRequestCachePolicy.fromValue($ret); - } - - /// Cookie partition identifier used for cookie storage and retrieval. - objc.NSString? get cookiePartitionIdentifier { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.cookiePartitionIdentifier', - iOS: (false, (18, 2, 0)), - macOS: (false, (15, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_cookiePartitionIdentifier, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// init - NSMutableURLRequest init() { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// initWithCoder: - NSMutableURLRequest? initWithCoder(objc.NSCoder coder) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithCoder_, - coder.ref.pointer, - ); - return $ret.address == 0 - ? null - : NSMutableURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithURL: - /// @abstract Initializes an NSURLRequest with the given URL. - /// @discussion Default values are used for cache policy - /// (NSURLRequestUseProtocolCachePolicy) and timeout interval (60 - /// seconds). - /// @param URL The URL for the request. - /// @result An initialized NSURLRequest. - NSMutableURLRequest initWithURL(objc.NSURL URL) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.initWithURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithURL_, - URL.ref.pointer, - ); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithURL: - /// @abstract Initializes an NSURLRequest with the given URL and - /// cache policy. - /// @discussion This is the designated initializer for the - /// NSURLRequest class. - /// @param URL The URL for the request. - /// @param cachePolicy The cache policy for the request. - /// @param timeoutInterval The timeout interval for the request. See the - /// commentary for the timeoutInterval for more information on - /// timeout intervals. - /// @result An initialized NSURLRequest. - NSMutableURLRequest initWithURL$1( - objc.NSURL URL, { - required NSURLRequestCachePolicy cachePolicy, - required DartNSTimeInterval timeoutInterval, - }) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.initWithURL:cachePolicy:timeoutInterval:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_1ajs603( - object$.ref.retainAndReturnPointer(), - _sel_initWithURL_cachePolicy_timeoutInterval_, - URL.ref.pointer, - cachePolicy.value, - timeoutInterval, - ); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @abstract Sets the main document URL - /// @discussion The caller should pass the URL for an appropriate main - /// document, if known. For example, when loading a web page, the URL - /// of the main html document for the top-level frame should be - /// passed. This main document is used to implement the cookie "only - /// from same domain as main document" policy, attributing this request - /// as a sub-resource of a user-specified URL, and possibly other things - /// in the future. - objc.NSURL? get mainDocumentURL { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.mainDocumentURL', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_mainDocumentURL, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Sets the NSURLRequestNetworkServiceType to associate with this request - /// @discussion This method is used to provide the network layers with a hint as to the purpose - /// of the request. Most clients should not need to use this method. - NSURLRequestNetworkServiceType get networkServiceType { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.networkServiceType', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 7, 0)), - ); - final $ret = _objc_msgSend_t4uaw1( - object$.ref.pointer, - _sel_networkServiceType, - ); - return NSURLRequestNetworkServiceType.fromValue($ret); - } - - /// ! - /// @abstract sets whether a request is required to do DNSSEC validation during DNS lookup. - /// @discussion YES, if the DNS lookup for this request should require DNSSEC validation, - /// No otherwise. Defaults to NO. - bool get requiresDNSSECValidation { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.requiresDNSSECValidation', - iOS: (false, (16, 1, 0)), - macOS: (false, (13, 0, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_requiresDNSSECValidation, - ); - } - - /// ! - /// @abstract sets whether a connection created with this request is allowed to use - /// the built in cellular radios (if present). - /// @discussion NO if the receiver should not be allowed to use the built in - /// cellular radios to satisfy the request, YES otherwise. The default is YES. - set allowsCellularAccess$1(bool value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setAllowsCellularAccess:', - iOS: (false, (6, 0, 0)), - macOS: (false, (10, 8, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsCellularAccess_, - value, - ); - } - - /// ! - /// @abstract sets whether a connection created with this request is allowed to use - /// network interfaces which have been marked as constrained. - /// @discussion NO if the receiver should not be allowed to use an interface marked as constrained to - /// satisfy the request, YES otherwise. - set allowsConstrainedNetworkAccess$1(bool value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setAllowsConstrainedNetworkAccess:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsConstrainedNetworkAccess_, - value, - ); - } - - /// ! - /// @abstract sets whether a connection created with this request is allowed to use - /// network interfaces which have been marked as expensive. - /// @discussion NO if the receiver should not be allowed to use an interface marked as expensive to - /// satisfy the request, YES otherwise. - set allowsExpensiveNetworkAccess$1(bool value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setAllowsExpensiveNetworkAccess:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsExpensiveNetworkAccess_, - value, - ); - } - - /// ! - /// @abstract Allows storing and usage of DNS answers, potentially beyond TTL expiry, - /// in a persistent per-process cache. This should only be set for hostnames whose resolutions - /// are not expected to change across networks. - /// @discussion YES, if the DNS lookup for this request is allowed to use a persistent per-process cache, - /// NO otherwise. Defaults to NO. - set allowsPersistentDNS$1(bool value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setAllowsPersistentDNS:', - iOS: (false, (18, 0, 0)), - macOS: (false, (15, 0, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsPersistentDNS_, - value, - ); - } - - /// ! - /// @abstract returns whether we assume that server supports HTTP/3. Enables QUIC - /// racing without HTTP/3 service discovery. - /// @result YES if server endpoint is known to support HTTP/3. Defaults to NO. - /// The default may be YES in a future OS update. - set assumesHTTP3Capable$1(bool value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setAssumesHTTP3Capable:', - iOS: (false, (14, 5, 0)), - macOS: (false, (11, 3, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAssumesHTTP3Capable_, - value, - ); - } - - /// ! - /// @abstract Sets the NSURLRequestAttribution to associate with this request. - /// @discussion Set to NSURLRequestAttributionUser if the URL was specified by the - /// user. Defaults to NSURLRequestAttributionDeveloper. - set attribution$1(NSURLRequestAttribution value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setAttribution:', - iOS: (false, (15, 0, 0)), - macOS: (false, (12, 0, 0)), - ); - _objc_msgSend_1nw1jep( - object$.ref.pointer, - _sel_setAttribution_, - value.value, - ); - } - - /// ! - /// @abstract The cache policy of the receiver. - set cachePolicy$1(NSURLRequestCachePolicy value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setCachePolicy:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_1yjxuv2( - object$.ref.pointer, - _sel_setCachePolicy_, - value.value, - ); - } - - /// Cookie partition identifier used for cookie storage and retrieval. - set cookiePartitionIdentifier$1(objc.NSString? value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setCookiePartitionIdentifier:', - iOS: (false, (18, 2, 0)), - macOS: (false, (15, 2, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setCookiePartitionIdentifier_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// ! - /// @abstract Sets the main document URL - /// @discussion The caller should pass the URL for an appropriate main - /// document, if known. For example, when loading a web page, the URL - /// of the main html document for the top-level frame should be - /// passed. This main document is used to implement the cookie "only - /// from same domain as main document" policy, attributing this request - /// as a sub-resource of a user-specified URL, and possibly other things - /// in the future. - set mainDocumentURL$1(objc.NSURL? value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setMainDocumentURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setMainDocumentURL_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// ! - /// @abstract Sets the NSURLRequestNetworkServiceType to associate with this request - /// @discussion This method is used to provide the network layers with a hint as to the purpose - /// of the request. Most clients should not need to use this method. - set networkServiceType$1(NSURLRequestNetworkServiceType value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setNetworkServiceType:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 7, 0)), - ); - _objc_msgSend_1mse4s1( - object$.ref.pointer, - _sel_setNetworkServiceType_, - value.value, - ); - } - - /// ! - /// @abstract sets whether a request is required to do DNSSEC validation during DNS lookup. - /// @discussion YES, if the DNS lookup for this request should require DNSSEC validation, - /// No otherwise. Defaults to NO. - set requiresDNSSECValidation$1(bool value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setRequiresDNSSECValidation:', - iOS: (false, (16, 1, 0)), - macOS: (false, (13, 0, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setRequiresDNSSECValidation_, - value, - ); - } - - /// ! - /// @abstract Sets the timeout interval of the receiver. - /// @discussion The timeout interval specifies the limit on the idle - /// interval allotted to a request in the process of loading. The "idle - /// interval" is defined as the period of time that has passed since the - /// last instance of load activity occurred for a request that is in the - /// process of loading. Hence, when an instance of load activity occurs - /// (e.g. bytes are received from the network for a request), the idle - /// interval for a request is reset to 0. If the idle interval ever - /// becomes greater than or equal to the timeout interval, the request - /// is considered to have timed out. This timeout interval is measured - /// in seconds. - set timeoutInterval$1(DartNSTimeInterval value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setTimeoutInterval:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_hwm8nu(object$.ref.pointer, _sel_setTimeoutInterval_, value); - } - - /// ! - /// @abstract The URL of the receiver. - set URL$1(objc.NSURL? value) { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.setURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setURL_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// ! - /// @abstract Sets the timeout interval of the receiver. - /// @discussion The timeout interval specifies the limit on the idle - /// interval allotted to a request in the process of loading. The "idle - /// interval" is defined as the period of time that has passed since the - /// last instance of load activity occurred for a request that is in the - /// process of loading. Hence, when an instance of load activity occurs - /// (e.g. bytes are received from the network for a request), the idle - /// interval for a request is reset to 0. If the idle interval ever - /// becomes greater than or equal to the timeout interval, the request - /// is considered to have timed out. This timeout interval is measured - /// in seconds. - DartNSTimeInterval get timeoutInterval { - objc.checkOsVersionInternal( - 'NSMutableURLRequest.timeoutInterval', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return objc.useMsgSendVariants - ? _objc_msgSend_1ukqyt8Fpret(object$.ref.pointer, _sel_timeoutInterval) - : _objc_msgSend_1ukqyt8(object$.ref.pointer, _sel_timeoutInterval); - } -} - -enum NSHTTPCookieAcceptPolicy { - NSHTTPCookieAcceptPolicyAlways(0), - NSHTTPCookieAcceptPolicyNever(1), - NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain(2); - - final int value; - const NSHTTPCookieAcceptPolicy(this.value); - - static NSHTTPCookieAcceptPolicy fromValue(int value) => switch (value) { - 0 => NSHTTPCookieAcceptPolicyAlways, - 1 => NSHTTPCookieAcceptPolicyNever, - 2 => NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, - _ => throw ArgumentError( - 'Unknown value for NSHTTPCookieAcceptPolicy: $value', - ), - }; -} - -/// WARNING: NSHTTPCookieStorage is a stub. To generate bindings for this class, include -/// NSHTTPCookieStorage in your config's objc-interfaces list. -/// -/// NSHTTPCookieStorage -extension type NSHTTPCookieStorage._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject { - /// Constructs a [NSHTTPCookieStorage] that points to the same underlying object as [other]. - NSHTTPCookieStorage.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSHTTPCookieStorage', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - } - - /// Constructs a [NSHTTPCookieStorage] that wraps the given raw object pointer. - NSHTTPCookieStorage.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSHTTPCookieStorage', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - } -} - -late final _class_NSHTTPCookieStorage = objc.getClass("NSHTTPCookieStorage"); -late final _class_NSURLSessionTask = objc.getClass("NSURLSessionTask"); -late final _sel_taskIdentifier = objc.registerName("taskIdentifier"); -late final _sel_originalRequest = objc.registerName("originalRequest"); -late final _sel_currentRequest = objc.registerName("currentRequest"); -late final _class_NSURLResponse = objc.getClass("NSURLResponse"); -late final _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_ = - objc.registerName( - "initWithURL:MIMEType:expectedContentLength:textEncodingName:", - ); -final _objc_msgSend_l9ppnx = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); -late final _sel_MIMEType = objc.registerName("MIMEType"); -late final _sel_expectedContentLength = objc.registerName( - "expectedContentLength", -); -final _objc_msgSend_1k101e3 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.LongLong Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_textEncodingName = objc.registerName("textEncodingName"); -late final _sel_suggestedFilename = objc.registerName("suggestedFilename"); - -/// NSURLResponse -extension type NSURLResponse._(objc.ObjCObject object$) - implements - objc.ObjCObject, - objc.NSObject, - objc.NSSecureCoding, - objc.NSCopying { - /// Constructs a [NSURLResponse] that points to the same underlying object as [other]. - NSURLResponse.as(objc.ObjCObject other) : object$ = other { - assert(isA(object$)); - } - - /// Constructs a [NSURLResponse] that wraps the given raw object pointer. - NSURLResponse.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLResponse]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLResponse, - ); - - /// alloc - static NSURLResponse alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSURLResponse, _sel_alloc); - return NSURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSURLResponse allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLResponse, - _sel_allocWithZone_, - zone, - ); - return NSURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// new - static NSURLResponse new$() { - final $ret = _objc_msgSend_151sglz(_class_NSURLResponse, _sel_new); - return NSURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// supportsSecureCoding - static bool getSupportsSecureCoding() { - return _objc_msgSend_91o635( - _class_NSURLResponse, - _sel_supportsSecureCoding, - ); - } - - /// Returns a new instance of NSURLResponse constructed with the default `new` method. - NSURLResponse() : this.as(new$().object$); -} - -extension NSURLResponse$Methods on NSURLResponse { - /// ! - /// @abstract Returns the MIME type of the receiver. - /// @discussion The MIME type is based on the information provided - /// from an origin source. However, that value may be changed or - /// corrected by a protocol implementation if it can be determined - /// that the origin server or source reported the information - /// incorrectly or imprecisely. An attempt to guess the MIME type may - /// be made if the origin source did not report any such information. - /// @result The MIME type of the receiver. - objc.NSString? get MIMEType { - objc.checkOsVersionInternal( - 'NSURLResponse.MIMEType', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_MIMEType); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Returns the URL of the receiver. - /// @result The URL of the receiver. - objc.NSURL? get URL { - objc.checkOsVersionInternal( - 'NSURLResponse.URL', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URL); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// encodeWithCoder: - void encodeWithCoder(objc.NSCoder coder) { - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_encodeWithCoder_, - coder.ref.pointer, - ); - } - - /// ! - /// @abstract Returns the expected content length of the receiver. - /// @discussion Some protocol implementations report a content length - /// as part of delivering load metadata, but not all protocols - /// guarantee the amount of data that will be delivered in actuality. - /// Hence, this method returns an expected amount. Clients should use - /// this value as an advisory, and should be prepared to deal with - /// either more or less data. - /// @result The expected content length of the receiver, or -1 if - /// there is no expectation that can be arrived at regarding expected - /// content length. - int get expectedContentLength { - objc.checkOsVersionInternal( - 'NSURLResponse.expectedContentLength', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return _objc_msgSend_1k101e3( - object$.ref.pointer, - _sel_expectedContentLength, - ); - } - - /// init - NSURLResponse init() { - objc.checkOsVersionInternal( - 'NSURLResponse.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// initWithCoder: - NSURLResponse? initWithCoder(objc.NSCoder coder) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithCoder_, - coder.ref.pointer, - ); - return $ret.address == 0 - ? null - : NSURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithURL:MIMEType:expectedContentLength:textEncodingName: - /// @abstract Initialize an NSURLResponse with the provided values. - /// @param URL the URL - /// @param MIMEType the MIME content type of the response - /// @param length the expected content length of the associated data - /// @param name the name of the text encoding for the associated data, if applicable, else nil - /// @result The initialized NSURLResponse. - /// @discussion This is the designated initializer for NSURLResponse. - NSURLResponse initWithUrlAndMIMEType( - objc.NSURL URL, { - objc.NSString? MIMEType, - required DartNSInteger length, - objc.NSString? name, - }) { - objc.checkOsVersionInternal( - 'NSURLResponse.initWithURL:MIMEType:expectedContentLength:textEncodingName:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_l9ppnx( - object$.ref.retainAndReturnPointer(), - _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_, - URL.ref.pointer, - MIMEType?.ref.pointer ?? ffi.nullptr, - length, - name?.ref.pointer ?? ffi.nullptr, - ); - return NSURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @abstract Returns a suggested filename if the resource were saved to disk. - /// @discussion The method first checks if the server has specified a filename using the - /// content disposition header. If no valid filename is specified using that mechanism, - /// this method checks the last path component of the URL. If no valid filename can be - /// obtained using the last path component, this method uses the URL's host as the filename. - /// If the URL's host can't be converted to a valid filename, the filename "unknown" is used. - /// In most cases, this method appends the proper file extension based on the MIME type. - /// This method always returns a valid filename. - /// @result A suggested filename to use if saving the resource to disk. - objc.NSString? get suggestedFilename { - objc.checkOsVersionInternal( - 'NSURLResponse.suggestedFilename', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_suggestedFilename, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// ! - /// @abstract Returns the name of the text encoding of the receiver. - /// @discussion This name will be the actual string reported by the - /// origin source during the course of performing a protocol-specific - /// URL load. Clients can inspect this string and convert it to an - /// NSStringEncoding or CFStringEncoding using the methods and - /// functions made available in the appropriate framework. - /// @result The name of the text encoding of the receiver, or nil if no - /// text encoding was specified. - objc.NSString? get textEncodingName { - objc.checkOsVersionInternal( - 'NSURLResponse.textEncodingName', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_textEncodingName, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_response = objc.registerName("response"); - -/// WARNING: NSURLSessionTaskDelegate is a stub. To generate bindings for this class, include -/// NSURLSessionTaskDelegate in your config's objc-protocols list. -/// -/// Messages related to the operation of a specific task. -extension type NSURLSessionTaskDelegate._(objc.ObjCProtocol object$) - implements objc.ObjCProtocol, NSURLSessionDelegate { - /// Constructs a [NSURLSessionTaskDelegate] that points to the same underlying object as [other]. - NSURLSessionTaskDelegate.as(objc.ObjCObject other) : object$ = other; - - /// Constructs a [NSURLSessionTaskDelegate] that wraps the given raw object pointer. - NSURLSessionTaskDelegate.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); -} - -late final _sel_delegate = objc.registerName("delegate"); -late final _sel_setDelegate_ = objc.registerName("setDelegate:"); -late final _sel_progress = objc.registerName("progress"); - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_NSProgress_ffiVoid { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock)> - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock)> - fromFunction( - objc.NSProgress Function(ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock)>( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn(arg0).ref.retainAndAutorelease(), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static ffi.Pointer _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer arg0) - > - >() - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static ffi.Pointer _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as ffi.Pointer Function(ffi.Pointer))( - arg0, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_NSProgress_ffiVoid$CallExtension - on objc.ObjCBlock)> { - objc.NSProgress call(ffi.Pointer arg0) => - objc.NSProgress.fromPointer( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0), - retain: true, - release: true, - ); -} - -late final _sel_earliestBeginDate = objc.registerName("earliestBeginDate"); -late final _sel_setEarliestBeginDate_ = objc.registerName( - "setEarliestBeginDate:", -); -late final _sel_countOfBytesClientExpectsToSend = objc.registerName( - "countOfBytesClientExpectsToSend", -); -final _objc_msgSend_pysgoz = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setCountOfBytesClientExpectsToSend_ = objc.registerName( - "setCountOfBytesClientExpectsToSend:", -); -final _objc_msgSend_17gvxvj = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_countOfBytesClientExpectsToReceive = objc.registerName( - "countOfBytesClientExpectsToReceive", -); -late final _sel_setCountOfBytesClientExpectsToReceive_ = objc.registerName( - "setCountOfBytesClientExpectsToReceive:", -); -late final _sel_countOfBytesSent = objc.registerName("countOfBytesSent"); -late final _sel_countOfBytesReceived = objc.registerName( - "countOfBytesReceived", -); -late final _sel_countOfBytesExpectedToSend = objc.registerName( - "countOfBytesExpectedToSend", -); -late final _sel_countOfBytesExpectedToReceive = objc.registerName( - "countOfBytesExpectedToReceive", -); -late final _sel_taskDescription = objc.registerName("taskDescription"); -late final _sel_setTaskDescription_ = objc.registerName("setTaskDescription:"); -late final _sel_cancel = objc.registerName("cancel"); - -enum NSURLSessionTaskState { - /// The task is currently being serviced by the session - NSURLSessionTaskStateRunning(0), - NSURLSessionTaskStateSuspended(1), - - /// The task has been told to cancel. The session will receive a URLSession:task:didCompleteWithError: message. - NSURLSessionTaskStateCanceling(2), - - /// The task has completed and the session will receive no more delegate notifications - NSURLSessionTaskStateCompleted(3); - - final int value; - const NSURLSessionTaskState(this.value); - - static NSURLSessionTaskState fromValue(int value) => switch (value) { - 0 => NSURLSessionTaskStateRunning, - 1 => NSURLSessionTaskStateSuspended, - 2 => NSURLSessionTaskStateCanceling, - 3 => NSURLSessionTaskStateCompleted, - _ => throw ArgumentError('Unknown value for NSURLSessionTaskState: $value'), - }; -} - -late final _sel_state = objc.registerName("state"); -final _objc_msgSend_1vze0g9 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_error = objc.registerName("error"); -late final _sel_suspend = objc.registerName("suspend"); -late final _sel_resume = objc.registerName("resume"); -late final _sel_priority = objc.registerName("priority"); -final _objc_msgSend_2cgrxl = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Float Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - double Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -final _objc_msgSend_2cgrxlFpret = objc.msgSendFpretPointer - .cast< - ffi.NativeFunction< - ffi.Float Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - double Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setPriority_ = objc.registerName("setPriority:"); -final _objc_msgSend_v5hmet = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Float, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - double, - ) - >(); -late final _sel_prefersIncrementalDelivery = objc.registerName( - "prefersIncrementalDelivery", -); -late final _sel_setPrefersIncrementalDelivery_ = objc.registerName( - "setPrefersIncrementalDelivery:", -); - -/// WARNING: NSProgressReporting is a stub. To generate bindings for this class, include -/// NSProgressReporting in your config's objc-protocols list. -/// -/// NSProgressReporting -extension type NSProgressReporting._(objc.ObjCProtocol object$) - implements objc.ObjCProtocol, objc.NSObjectProtocol { - /// Constructs a [NSProgressReporting] that points to the same underlying object as [other]. - NSProgressReporting.as(objc.ObjCObject other) : object$ = other; - - /// Constructs a [NSProgressReporting] that wraps the given raw object pointer. - NSProgressReporting.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); -} - -/// NSURLSessionTask - a cancelable object that refers to the lifetime -/// of processing a given request. -extension type NSURLSessionTask._(objc.ObjCObject object$) - implements - objc.ObjCObject, - objc.NSObject, - objc.NSCopying, - NSProgressReporting { - /// Constructs a [NSURLSessionTask] that points to the same underlying object as [other]. - NSURLSessionTask.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSessionTask', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSURLSessionTask] that wraps the given raw object pointer. - NSURLSessionTask.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSessionTask', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLSessionTask]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLSessionTask, - ); - - /// alloc - static NSURLSessionTask alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSURLSessionTask, _sel_alloc); - return NSURLSessionTask.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSURLSessionTask allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSessionTask, - _sel_allocWithZone_, - zone, - ); - return NSURLSessionTask.fromPointer($ret, retain: false, release: true); - } - - /// new - static NSURLSessionTask new$() { - final $ret = _objc_msgSend_151sglz(_class_NSURLSessionTask, _sel_new); - return NSURLSessionTask.fromPointer($ret, retain: false, release: true); - } - - /// Returns a new instance of NSURLSessionTask constructed with the default `new` method. - NSURLSessionTask() : this.as(new$().object$); -} - -extension NSURLSessionTask$Methods on NSURLSessionTask { - /// -cancel returns immediately, but marks a task as being canceled. - /// The task will signal -URLSession:task:didCompleteWithError: with an - /// error value of { NSURLErrorDomain, NSURLErrorCancelled }. In some - /// cases, the task may signal other work before it acknowledges the - /// cancelation. -cancel may be sent to a task that has been suspended. - void cancel() { - objc.checkOsVersionInternal( - 'NSURLSessionTask.cancel', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_cancel); - } - - /// countOfBytesClientExpectsToReceive - int get countOfBytesClientExpectsToReceive { - objc.checkOsVersionInternal( - 'NSURLSessionTask.countOfBytesClientExpectsToReceive', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - return _objc_msgSend_pysgoz( - object$.ref.pointer, - _sel_countOfBytesClientExpectsToReceive, - ); - } - - /// The number of bytes that the client expects (a best-guess upper-bound) will - /// be sent and received by this task. These values are used by system scheduling - /// policy. If unspecified, NSURLSessionTransferSizeUnknown is used. - int get countOfBytesClientExpectsToSend { - objc.checkOsVersionInternal( - 'NSURLSessionTask.countOfBytesClientExpectsToSend', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - return _objc_msgSend_pysgoz( - object$.ref.pointer, - _sel_countOfBytesClientExpectsToSend, - ); - } - - /// number of byte bytes we expect to receive, usually derived from the Content-Length header of an HTTP response. - int get countOfBytesExpectedToReceive { - objc.checkOsVersionInternal( - 'NSURLSessionTask.countOfBytesExpectedToReceive', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_pysgoz( - object$.ref.pointer, - _sel_countOfBytesExpectedToReceive, - ); - } - - /// number of body bytes we expect to send, derived from the Content-Length of the HTTP request - int get countOfBytesExpectedToSend { - objc.checkOsVersionInternal( - 'NSURLSessionTask.countOfBytesExpectedToSend', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_pysgoz( - object$.ref.pointer, - _sel_countOfBytesExpectedToSend, - ); - } - - /// number of body bytes already received - int get countOfBytesReceived { - objc.checkOsVersionInternal( - 'NSURLSessionTask.countOfBytesReceived', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_pysgoz(object$.ref.pointer, _sel_countOfBytesReceived); - } - - /// number of body bytes already sent - int get countOfBytesSent { - objc.checkOsVersionInternal( - 'NSURLSessionTask.countOfBytesSent', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_pysgoz(object$.ref.pointer, _sel_countOfBytesSent); - } - - /// may differ from originalRequest due to http server redirection - NSURLRequest? get currentRequest { - objc.checkOsVersionInternal( - 'NSURLSessionTask.currentRequest', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_currentRequest, - ); - return $ret.address == 0 - ? null - : NSURLRequest.fromPointer($ret, retain: true, release: true); - } - - /// Sets a task-specific delegate. Methods not implemented on this delegate will - /// still be forwarded to the session delegate. - /// - /// Cannot be modified after task resumes. Not supported on background session. - /// - /// Delegate is strongly referenced until the task completes, after which it is - /// reset to `nil`. - NSURLSessionTaskDelegate? get delegate { - objc.checkOsVersionInternal( - 'NSURLSessionTask.delegate', - iOS: (false, (15, 0, 0)), - macOS: (false, (12, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_delegate); - return $ret.address == 0 - ? null - : NSURLSessionTaskDelegate.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Start the network load for this task no earlier than the specified date. If - /// not specified, no start delay is used. - /// - /// Only applies to tasks created from background NSURLSession instances; has no - /// effect for tasks created from other session types. - objc.NSDate? get earliestBeginDate { - objc.checkOsVersionInternal( - 'NSURLSessionTask.earliestBeginDate', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_earliestBeginDate, - ); - return $ret.address == 0 - ? null - : objc.NSDate.fromPointer($ret, retain: true, release: true); - } - - /// The error, if any, delivered via -URLSession:task:didCompleteWithError: - /// This property will be nil in the event that no error occurred. - objc.NSError? get error { - objc.checkOsVersionInternal( - 'NSURLSessionTask.error', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_error); - return $ret.address == 0 - ? null - : objc.NSError.fromPointer($ret, retain: true, release: true); - } - - /// init - NSURLSessionTask init() { - objc.checkOsVersionInternal( - 'NSURLSessionTask.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLSessionTask.fromPointer($ret, retain: false, release: true); - } - - /// may be nil if this is a stream task - NSURLRequest? get originalRequest { - objc.checkOsVersionInternal( - 'NSURLSessionTask.originalRequest', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_originalRequest, - ); - return $ret.address == 0 - ? null - : NSURLRequest.fromPointer($ret, retain: true, release: true); - } - - /// Provides a hint indicating if incremental delivery of a partial response body - /// would be useful for the application, or if it cannot process the response - /// until it is complete. Indicating that incremental delivery is not desired may - /// improve task performance. For example, if a response cannot be decoded until - /// the entire content is received, set this property to false. - /// - /// Defaults to true unless this task is created with completion-handler based - /// convenience methods, or if it is a download task. - bool get prefersIncrementalDelivery { - objc.checkOsVersionInternal( - 'NSURLSessionTask.prefersIncrementalDelivery', - iOS: (false, (14, 5, 0)), - macOS: (false, (11, 3, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_prefersIncrementalDelivery, - ); - } - - /// Sets a scaling factor for the priority of the task. The scaling factor is a - /// value between 0.0 and 1.0 (inclusive), where 0.0 is considered the lowest - /// priority and 1.0 is considered the highest. - /// - /// The priority is a hint and not a hard requirement of task performance. The - /// priority of a task may be changed using this API at any time, but not all - /// protocols support this; in these cases, the last priority that took effect - /// will be used. - /// - /// If no priority is specified, the task will operate with the default priority - /// as defined by the constant NSURLSessionTaskPriorityDefault. Two additional - /// priority levels are provided: NSURLSessionTaskPriorityLow and - /// NSURLSessionTaskPriorityHigh, but use is not restricted to these. - double get priority { - objc.checkOsVersionInternal( - 'NSURLSessionTask.priority', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - return objc.useMsgSendVariants - ? _objc_msgSend_2cgrxlFpret(object$.ref.pointer, _sel_priority) - : _objc_msgSend_2cgrxl(object$.ref.pointer, _sel_priority); - } - - /// progress - objc.NSProgress get progress { - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_progress); - return objc.NSProgress.fromPointer($ret, retain: true, release: true); - } - - /// may be nil if no response has been received - NSURLResponse? get response { - objc.checkOsVersionInternal( - 'NSURLSessionTask.response', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_response); - return $ret.address == 0 - ? null - : NSURLResponse.fromPointer($ret, retain: true, release: true); - } - - /// resume - void resume() { - objc.checkOsVersionInternal( - 'NSURLSessionTask.resume', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_resume); - } - - /// setCountOfBytesClientExpectsToReceive: - set countOfBytesClientExpectsToReceive(int value) { - objc.checkOsVersionInternal( - 'NSURLSessionTask.setCountOfBytesClientExpectsToReceive:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - _objc_msgSend_17gvxvj( - object$.ref.pointer, - _sel_setCountOfBytesClientExpectsToReceive_, - value, - ); - } - - /// The number of bytes that the client expects (a best-guess upper-bound) will - /// be sent and received by this task. These values are used by system scheduling - /// policy. If unspecified, NSURLSessionTransferSizeUnknown is used. - set countOfBytesClientExpectsToSend(int value) { - objc.checkOsVersionInternal( - 'NSURLSessionTask.setCountOfBytesClientExpectsToSend:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - _objc_msgSend_17gvxvj( - object$.ref.pointer, - _sel_setCountOfBytesClientExpectsToSend_, - value, - ); - } - - /// Sets a task-specific delegate. Methods not implemented on this delegate will - /// still be forwarded to the session delegate. - /// - /// Cannot be modified after task resumes. Not supported on background session. - /// - /// Delegate is strongly referenced until the task completes, after which it is - /// reset to `nil`. - set delegate(NSURLSessionTaskDelegate? value) { - objc.checkOsVersionInternal( - 'NSURLSessionTask.setDelegate:', - iOS: (false, (15, 0, 0)), - macOS: (false, (12, 0, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setDelegate_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Start the network load for this task no earlier than the specified date. If - /// not specified, no start delay is used. - /// - /// Only applies to tasks created from background NSURLSession instances; has no - /// effect for tasks created from other session types. - set earliestBeginDate(objc.NSDate? value) { - objc.checkOsVersionInternal( - 'NSURLSessionTask.setEarliestBeginDate:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setEarliestBeginDate_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Provides a hint indicating if incremental delivery of a partial response body - /// would be useful for the application, or if it cannot process the response - /// until it is complete. Indicating that incremental delivery is not desired may - /// improve task performance. For example, if a response cannot be decoded until - /// the entire content is received, set this property to false. - /// - /// Defaults to true unless this task is created with completion-handler based - /// convenience methods, or if it is a download task. - set prefersIncrementalDelivery(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionTask.setPrefersIncrementalDelivery:', - iOS: (false, (14, 5, 0)), - macOS: (false, (11, 3, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setPrefersIncrementalDelivery_, - value, - ); - } - - /// Sets a scaling factor for the priority of the task. The scaling factor is a - /// value between 0.0 and 1.0 (inclusive), where 0.0 is considered the lowest - /// priority and 1.0 is considered the highest. - /// - /// The priority is a hint and not a hard requirement of task performance. The - /// priority of a task may be changed using this API at any time, but not all - /// protocols support this; in these cases, the last priority that took effect - /// will be used. - /// - /// If no priority is specified, the task will operate with the default priority - /// as defined by the constant NSURLSessionTaskPriorityDefault. Two additional - /// priority levels are provided: NSURLSessionTaskPriorityLow and - /// NSURLSessionTaskPriorityHigh, but use is not restricted to these. - set priority(double value) { - objc.checkOsVersionInternal( - 'NSURLSessionTask.setPriority:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_v5hmet(object$.ref.pointer, _sel_setPriority_, value); - } - - /// The taskDescription property is available for the developer to - /// provide a descriptive label for the task. - set taskDescription(objc.NSString? value) { - objc.checkOsVersionInternal( - 'NSURLSessionTask.setTaskDescription:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setTaskDescription_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// The current state of the task within the session. - NSURLSessionTaskState get state { - objc.checkOsVersionInternal( - 'NSURLSessionTask.state', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1vze0g9(object$.ref.pointer, _sel_state); - return NSURLSessionTaskState.fromValue($ret); - } - - /// Suspending a task will prevent the NSURLSession from continuing to - /// load data. There may still be delegate calls made on behalf of - /// this task (for instance, to report data received while suspending) - /// but no further transmissions will be made on behalf of the task - /// until -resume is sent. The timeout timer associated with the task - /// will be disabled while a task is suspended. -suspend and -resume are - /// nestable. - void suspend() { - objc.checkOsVersionInternal( - 'NSURLSessionTask.suspend', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_suspend); - } - - /// The taskDescription property is available for the developer to - /// provide a descriptive label for the task. - objc.NSString? get taskDescription { - objc.checkOsVersionInternal( - 'NSURLSessionTask.taskDescription', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_taskDescription, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// an identifier for this task, assigned by and unique to the owning session - DartNSUInteger get taskIdentifier { - objc.checkOsVersionInternal( - 'NSURLSessionTask.taskIdentifier', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_taskIdentifier); - } -} - -late final _sel_storeCookies_forTask_ = objc.registerName( - "storeCookies:forTask:", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSArray$1 { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(objc.NSArray?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSArray.fromPointer(arg0, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(objc.NSArray?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSArray.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(objc.NSArray?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSArray.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSArray.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ) { - try { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - >() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSArray$1$CallExtension - on objc.ObjCBlock { - void call(objc.NSArray? arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); -} - -late final _sel_getCookiesForTask_completionHandler_ = objc.registerName( - "getCookiesForTask:completionHandler:", -); - -/// NSURLSessionTaskAdditions -extension NSURLSessionTaskAdditions$1 on NSHTTPCookieStorage { - /// getCookiesForTask:completionHandler: - void getCookiesForTask( - NSURLSessionTask task, { - required objc.ObjCBlock completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSHTTPCookieStorage.getCookiesForTask:completionHandler:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_o762yo( - object$.ref.pointer, - _sel_getCookiesForTask_completionHandler_, - task.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// storeCookies:forTask: - void storeCookies(objc.NSArray cookies, {required NSURLSessionTask forTask}) { - objc.checkOsVersionInternal( - 'NSHTTPCookieStorage.storeCookies:forTask:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_storeCookies_forTask_, - cookies.ref.pointer, - forTask.ref.pointer, - ); - } -} - -late final _class_NSDictionary = objc.getClass("NSDictionary"); -late final _sel_getObjects_andKeys_ = objc.registerName("getObjects:andKeys:"); -final _objc_msgSend_hefmm1 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer>, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer>, - ) - >(); -late final _sel_dictionaryWithContentsOfFile_ = objc.registerName( - "dictionaryWithContentsOfFile:", -); -late final _sel_dictionaryWithContentsOfURL_ = objc.registerName( - "dictionaryWithContentsOfURL:", -); -late final _sel_initWithContentsOfFile_ = objc.registerName( - "initWithContentsOfFile:", -); -late final _sel_initWithContentsOfURL_ = objc.registerName( - "initWithContentsOfURL:", -); -late final _sel_writeToFile_atomically_ = objc.registerName( - "writeToFile:atomically:", -); -final _objc_msgSend_1iyq28l = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - bool, - ) - >(); -late final _sel_writeToURL_atomically_ = objc.registerName( - "writeToURL:atomically:", -); - -/// NSDeprecated -extension NSDeprecated on objc.NSDictionary { - /// getObjects:andKeys: - void getObjects( - ffi.Pointer> objects, { - required ffi.Pointer> andKeys, - }) { - objc.checkOsVersionInternal( - 'NSDictionary.getObjects:andKeys:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_hefmm1( - object$.ref.pointer, - _sel_getObjects_andKeys_, - objects, - andKeys, - ); - } - - /// initWithContentsOfFile: - objc.NSDictionary? initWithContentsOfFile(objc.NSString path) { - objc.checkOsVersionInternal( - 'NSDictionary.initWithContentsOfFile:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: false, release: true); - } - - /// initWithContentsOfURL: - objc.NSDictionary? initWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSDictionary.initWithContentsOfURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: false, release: true); - } - - /// writeToFile:atomically: - bool writeToFile(objc.NSString path, {required bool atomically}) { - objc.checkOsVersionInternal( - 'NSDictionary.writeToFile:atomically:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1iyq28l( - object$.ref.pointer, - _sel_writeToFile_atomically_, - path.ref.pointer, - atomically, - ); - } - - /// writeToURL:atomically: - bool writeToURL(objc.NSURL url, {required bool atomically}) { - objc.checkOsVersionInternal( - 'NSDictionary.writeToURL:atomically:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1iyq28l( - object$.ref.pointer, - _sel_writeToURL_atomically_, - url.ref.pointer, - atomically, - ); - } - - /// dictionaryWithContentsOfFile: - static objc.NSDictionary? dictionaryWithContentsOfFile(objc.NSString path) { - objc.checkOsVersionInternal( - 'NSDictionary.dictionaryWithContentsOfFile:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSDictionary, - _sel_dictionaryWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// dictionaryWithContentsOfURL: - static objc.NSDictionary? dictionaryWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSDictionary.dictionaryWithContentsOfURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSDictionary, - _sel_dictionaryWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_dictionary = objc.registerName("dictionary"); -late final _sel_dictionaryWithObject_forKey_ = objc.registerName( - "dictionaryWithObject:forKey:", -); -late final _sel_dictionaryWithObjects_forKeys_count_ = objc.registerName( - "dictionaryWithObjects:forKeys:count:", -); -final _objc_msgSend_1dydpdi = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer>, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer>, - int, - ) - >(); -late final _sel_dictionaryWithObjectsAndKeys_ = objc.registerName( - "dictionaryWithObjectsAndKeys:", -); -late final _sel_dictionaryWithDictionary_ = objc.registerName( - "dictionaryWithDictionary:", -); -late final _sel_dictionaryWithObjects_forKeys_ = objc.registerName( - "dictionaryWithObjects:forKeys:", -); -late final _sel_initWithObjectsAndKeys_ = objc.registerName( - "initWithObjectsAndKeys:", -); -late final _sel_initWithDictionary_ = objc.registerName("initWithDictionary:"); -late final _sel_initWithDictionary_copyItems_ = objc.registerName( - "initWithDictionary:copyItems:", -); -final _objc_msgSend_17amj0z = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - bool, - ) - >(); -late final _sel_initWithObjects_forKeys_ = objc.registerName( - "initWithObjects:forKeys:", -); -late final _sel_initWithContentsOfURL_error_ = objc.registerName( - "initWithContentsOfURL:error:", -); -final _objc_msgSend_1lhpu4m = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >(); -late final _sel_dictionaryWithContentsOfURL_error_ = objc.registerName( - "dictionaryWithContentsOfURL:error:", -); - -/// NSDictionaryCreation -extension NSDictionaryCreation on objc.NSDictionary { - /// initWithContentsOfURL:error: - objc.NSDictionary? initWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSDictionary.initWithContentsOfURL:error:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1lhpu4m( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfURL_error_, - url.ref.pointer, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: false, release: true); - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// initWithDictionary: - objc.NSDictionary initWithDictionary(objc.NSDictionary otherDictionary) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithDictionary_, - otherDictionary.ref.pointer, - ); - return objc.NSDictionary.fromPointer($ret, retain: false, release: true); - } - - /// initWithDictionary:copyItems: - objc.NSDictionary initWithDictionary$1( - objc.NSDictionary otherDictionary, { - required bool copyItems, - }) { - final $ret = _objc_msgSend_17amj0z( - object$.ref.retainAndReturnPointer(), - _sel_initWithDictionary_copyItems_, - otherDictionary.ref.pointer, - copyItems, - ); - return objc.NSDictionary.fromPointer($ret, retain: false, release: true); - } - - /// initWithObjects:forKeys: - objc.NSDictionary initWithObjects$1( - objc.NSArray objects, { - required objc.NSArray forKeys, - }) { - final $ret = _objc_msgSend_15qeuct( - object$.ref.retainAndReturnPointer(), - _sel_initWithObjects_forKeys_, - objects.ref.pointer, - forKeys.ref.pointer, - ); - return objc.NSDictionary.fromPointer($ret, retain: false, release: true); - } - - /// initWithObjectsAndKeys: - objc.NSDictionary initWithObjectsAndKeys(objc.ObjCObject firstObject) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithObjectsAndKeys_, - firstObject.ref.pointer, - ); - return objc.NSDictionary.fromPointer($ret, retain: false, release: true); - } - - /// dictionary - static objc.NSDictionary dictionary() { - final $ret = _objc_msgSend_151sglz(_class_NSDictionary, _sel_dictionary); - return objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// dictionaryWithContentsOfURL:error: - static objc.NSDictionary? dictionaryWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSDictionary.dictionaryWithContentsOfURL:error:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1lhpu4m( - _class_NSDictionary, - _sel_dictionaryWithContentsOfURL_error_, - url.ref.pointer, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// dictionaryWithDictionary: - static objc.NSDictionary dictionaryWithDictionary(objc.NSDictionary dict) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSDictionary, - _sel_dictionaryWithDictionary_, - dict.ref.pointer, - ); - return objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// dictionaryWithObject:forKey: - static objc.NSDictionary dictionaryWithObject( - objc.ObjCObject object, { - required objc.ObjCObject forKey, - }) { - final $ret = _objc_msgSend_15qeuct( - _class_NSDictionary, - _sel_dictionaryWithObject_forKey_, - object.ref.pointer, - forKey.ref.pointer, - ); - return objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// dictionaryWithObjects:forKeys: - static objc.NSDictionary dictionaryWithObjects( - objc.NSArray objects, { - required objc.NSArray forKeys, - }) { - final $ret = _objc_msgSend_15qeuct( - _class_NSDictionary, - _sel_dictionaryWithObjects_forKeys_, - objects.ref.pointer, - forKeys.ref.pointer, - ); - return objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// dictionaryWithObjects:forKeys:count: - static objc.NSDictionary dictionaryWithObjects$1( - ffi.Pointer> objects, { - required ffi.Pointer> forKeys, - required DartNSUInteger count, - }) { - final $ret = _objc_msgSend_1dydpdi( - _class_NSDictionary, - _sel_dictionaryWithObjects_forKeys_count_, - objects, - forKeys, - count, - ); - return objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// dictionaryWithObjectsAndKeys: - static objc.NSDictionary dictionaryWithObjectsAndKeys( - objc.ObjCObject firstObject, - ) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSDictionary, - _sel_dictionaryWithObjectsAndKeys_, - firstObject.ref.pointer, - ); - return objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } -} - -late final _class_NSMutableDictionary = objc.getClass("NSMutableDictionary"); -late final _sel_dictionaryWithCapacity_ = objc.registerName( - "dictionaryWithCapacity:", -); -final _objc_msgSend_14hpxwa = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - -/// NSMutableDictionaryCreation -extension NSMutableDictionaryCreation on objc.NSMutableDictionary { - /// initWithContentsOfFile: - objc.NSMutableDictionary? initWithContentsOfFile(objc.NSString path) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSMutableDictionary.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// initWithContentsOfURL: - objc.NSMutableDictionary? initWithContentsOfURL(objc.NSURL url) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSMutableDictionary.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// dictionaryWithCapacity: - static objc.NSMutableDictionary dictionaryWithCapacity( - DartNSUInteger numItems, - ) { - final $ret = _objc_msgSend_14hpxwa( - _class_NSMutableDictionary, - _sel_dictionaryWithCapacity_, - numItems, - ); - return objc.NSMutableDictionary.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// dictionaryWithContentsOfFile: - static objc.NSMutableDictionary? dictionaryWithContentsOfFile( - objc.NSString path, - ) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSMutableDictionary, - _sel_dictionaryWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSMutableDictionary.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// dictionaryWithContentsOfURL: - static objc.NSMutableDictionary? dictionaryWithContentsOfURL(objc.NSURL url) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSMutableDictionary, - _sel_dictionaryWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSMutableDictionary.fromPointer( - $ret, - retain: true, - release: true, - ); - } -} - -late final _sel_sharedKeySetForKeys_ = objc.registerName( - "sharedKeySetForKeys:", -); - -/// NSSharedKeySetDictionary -extension NSSharedKeySetDictionary on objc.NSDictionary { - /// sharedKeySetForKeys: - static objc.ObjCObject sharedKeySetForKeys(objc.NSArray keys) { - objc.checkOsVersionInternal( - 'NSDictionary.sharedKeySetForKeys:', - iOS: (false, (6, 0, 0)), - macOS: (false, (10, 8, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSDictionary, - _sel_sharedKeySetForKeys_, - keys.ref.pointer, - ); - return objc.ObjCObject($ret, retain: true, release: true); - } -} - -late final _sel_dictionaryWithSharedKeySet_ = objc.registerName( - "dictionaryWithSharedKeySet:", -); - -/// NSSharedKeySetDictionary -extension NSSharedKeySetDictionary$1 on objc.NSMutableDictionary { - /// dictionaryWithSharedKeySet: - static objc.NSMutableDictionary dictionaryWithSharedKeySet( - objc.ObjCObject keyset, - ) { - objc.checkOsVersionInternal( - 'NSMutableDictionary.dictionaryWithSharedKeySet:', - iOS: (false, (6, 0, 0)), - macOS: (false, (10, 8, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSMutableDictionary, - _sel_dictionaryWithSharedKeySet_, - keyset.ref.pointer, - ); - return objc.NSMutableDictionary.fromPointer( - $ret, - retain: true, - release: true, - ); - } -} - -late final _sel_countByEnumeratingWithState_objects_count_ = objc.registerName( - "countByEnumeratingWithState:objects:count:", -); -final _objc_msgSend_1b5ysjl = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)>`. -abstract final class ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObjectImpl_NSUInteger { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - NSUInteger Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - NSUInteger arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - > - fromFunction( - DartNSUInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - DartNSUInteger, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - int arg3, - ) => fn(arg0, arg1, arg2, arg3), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static int _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - int arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - NSUInteger Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - NSUInteger arg3, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - int, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - NSUInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - NSUInteger, - ) - >(_fnPtrTrampoline, 0) - .cast(); - static int _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - int arg3, - ) => - (objc.getBlockClosure(block) - as int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - int, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - NSUInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - NSUInteger, - ) - >(_closureTrampoline, 0) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)>`. -extension ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObjectImpl_NSUInteger$CallExtension - on - objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - > { - DartNSUInteger call( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - DartNSUInteger arg3, - ) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - NSUInteger Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - NSUInteger arg3, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - int, - ) - >()(ref.pointer, arg0, arg1, arg2, arg3); -} - -/// NSGenericFastEnumeration -extension NSGenericFastEnumeration on objc.NSDictionary { - /// countByEnumeratingWithState:objects:count: - DartNSUInteger countByEnumeratingWithState( - ffi.Pointer state, { - required ffi.Pointer> objects, - required DartNSUInteger count, - }) { - return _objc_msgSend_1b5ysjl( - object$.ref.pointer, - _sel_countByEnumeratingWithState_objects_count_, - state, - objects, - count, - ); - } -} - -typedef NSProgressKind = ffi.Pointer; -typedef DartNSProgressKind = objc.NSString; -typedef NSProgressUserInfoKey = ffi.Pointer; -typedef DartNSProgressUserInfoKey = objc.NSString; -typedef NSProgressFileOperationKind = ffi.Pointer; -typedef DartNSProgressFileOperationKind = objc.NSString; -typedef NSProgressUnpublishingHandler = ffi.Pointer; -typedef DartNSProgressUnpublishingHandler = objc.ObjCBlock; - -/// Construction methods for `objc.ObjCBlock? Function(objc.NSProgress)>`. -abstract final class ObjCBlock_NSProgressUnpublishingHandler_NSProgress { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - NSProgressUnpublishingHandler Function( - ffi.Pointer arg0, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - > - fromFunction( - DartNSProgressUnpublishingHandler? Function(objc.NSProgress) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - >( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => - fn( - objc.NSProgress.fromPointer(arg0, retain: true, release: true), - )?.ref.retainAndAutorelease() ?? - ffi.nullptr, - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static NSProgressUnpublishingHandler _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - NSProgressUnpublishingHandler Function( - ffi.Pointer arg0, - ) - > - >() - .asFunction< - NSProgressUnpublishingHandler Function(ffi.Pointer) - >()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - NSProgressUnpublishingHandler Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static NSProgressUnpublishingHandler _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as NSProgressUnpublishingHandler Function( - ffi.Pointer, - ))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - NSProgressUnpublishingHandler Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock? Function(objc.NSProgress)>`. -extension ObjCBlock_NSProgressUnpublishingHandler_NSProgress$CallExtension - on - objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - > { - DartNSProgressUnpublishingHandler? call(objc.NSProgress arg0) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - NSProgressUnpublishingHandler Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - NSProgressUnpublishingHandler Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0.ref.pointer) - .address == - 0 - ? null - : ObjCBlock_ffiVoid.fromPointer( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - NSProgressUnpublishingHandler Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - NSProgressUnpublishingHandler Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0.ref.pointer), - retain: true, - release: true, - ); -} - -typedef NSProgressPublishingHandler = ffi.Pointer; -typedef DartNSProgressPublishingHandler = - objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - >; -typedef CFArrayRetainCallBackFunction = - ffi.Pointer Function( - CFAllocatorRef allocator, - ffi.Pointer value, - ); -typedef CFArrayRetainCallBack = - ffi.Pointer>; -typedef CFArrayReleaseCallBackFunction = - ffi.Void Function(CFAllocatorRef allocator, ffi.Pointer value); -typedef DartCFArrayReleaseCallBackFunction = - void Function(CFAllocatorRef allocator, ffi.Pointer value); -typedef CFArrayReleaseCallBack = - ffi.Pointer>; -typedef CFArrayCopyDescriptionCallBackFunction = - CFStringRef Function(ffi.Pointer value); -typedef CFArrayCopyDescriptionCallBack = - ffi.Pointer>; -typedef CFArrayEqualCallBackFunction = - Boolean Function( - ffi.Pointer value1, - ffi.Pointer value2, - ); -typedef DartCFArrayEqualCallBackFunction = - DartBoolean Function( - ffi.Pointer value1, - ffi.Pointer value2, - ); -typedef CFArrayEqualCallBack = - ffi.Pointer>; - -final class CFArrayCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFArrayRetainCallBack retain; - - external CFArrayReleaseCallBack release; - - external CFArrayCopyDescriptionCallBack copyDescription; - - external CFArrayEqualCallBack equal; -} - -typedef CFArrayApplierFunctionFunction = - ffi.Void Function( - ffi.Pointer value, - ffi.Pointer context, - ); -typedef DartCFArrayApplierFunctionFunction = - void Function(ffi.Pointer value, ffi.Pointer context); -typedef CFArrayApplierFunction = - ffi.Pointer>; - -final class __CFArray extends ffi.Opaque {} - -typedef CFArrayRef = ffi.Pointer<__CFArray>; -typedef CFMutableArrayRef = ffi.Pointer<__CFArray>; -typedef os_function_tFunction = ffi.Void Function(ffi.Pointer); -typedef Dartos_function_tFunction = void Function(ffi.Pointer); -typedef os_function_t = ffi.Pointer>; -typedef os_block_t = ffi.Pointer; -typedef Dartos_block_t = objc.ObjCBlock; - -/// WARNING: OS_object is a stub. To generate bindings for this class, include -/// OS_object in your config's objc-interfaces list. -/// -/// OS_object -extension type OS_object._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject { - /// Constructs a [OS_object] that points to the same underlying object as [other]. - OS_object.as(objc.ObjCObject other) : object$ = other {} - - /// Constructs a [OS_object] that wraps the given raw object pointer. - OS_object.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} -} - -typedef sec_object_t = ffi.Pointer; -typedef Dartsec_object_t = objc.NSObject; - -final class __SecCertificate extends ffi.Opaque {} - -typedef SecCertificateRef = ffi.Pointer<__SecCertificate>; -typedef OpaqueSecCertificateRef = __SecCertificate; - -final class __SecIdentity extends ffi.Opaque {} - -typedef SecIdentityRef = ffi.Pointer<__SecIdentity>; -typedef OpaqueSecIdentityRef = __SecIdentity; - -final class __SecKey extends ffi.Opaque {} - -typedef SecKeyRef = ffi.Pointer<__SecKey>; -typedef OpaqueSecKeyRef = __SecKey; - -final class __SecPolicy extends ffi.Opaque {} - -typedef SecPolicyRef = ffi.Pointer<__SecPolicy>; - -final class __SecAccessControl extends ffi.Opaque {} - -typedef SecAccessControlRef = ffi.Pointer<__SecAccessControl>; - -final class __SecKeychain extends ffi.Opaque {} - -typedef SecKeychainRef = ffi.Pointer<__SecKeychain>; - -final class __SecKeychainItem extends ffi.Opaque {} - -typedef SecKeychainItemRef = ffi.Pointer<__SecKeychainItem>; - -final class __SecKeychainSearch extends ffi.Opaque {} - -typedef SecKeychainSearchRef = ffi.Pointer<__SecKeychainSearch>; -typedef SecKeychainAttrType = OSType; - -final class SecKeychainAttribute extends ffi.Struct { - @SecKeychainAttrType() - external int tag; - - @UInt32() - external int length; - - external ffi.Pointer data; -} - -typedef SecKeychainAttributePtr = ffi.Pointer; - -final class SecKeychainAttributeList extends ffi.Struct { - @UInt32() - external int count; - - external ffi.Pointer attr; -} - -typedef SecKeychainStatus = UInt32; - -final class __SecTrustedApplication extends ffi.Opaque {} - -typedef SecTrustedApplicationRef = ffi.Pointer<__SecTrustedApplication>; - -final class __SecAccess extends ffi.Opaque {} - -typedef SecAccessRef = ffi.Pointer<__SecAccess>; -typedef OpaqueSecAccessRef = __SecAccess; - -final class __SecACL extends ffi.Opaque {} - -typedef SecACLRef = ffi.Pointer<__SecACL>; - -final class __SecPassword extends ffi.Opaque {} - -typedef SecPasswordRef = ffi.Pointer<__SecPassword>; - -final class SecKeychainAttributeInfo extends ffi.Struct { - @UInt32() - external int count; - - external ffi.Pointer tag; - - external ffi.Pointer format; -} - -typedef wint_t = __darwin_wint_t; - -final class _RuneEntry extends ffi.Struct { - @__darwin_rune_t() - external int __min; - - @__darwin_rune_t() - external int __max; - - @__darwin_rune_t() - external int __map; - - external ffi.Pointer<__uint32_t> __types; -} - -final class _RuneRange extends ffi.Struct { - @ffi.Int() - external int __nranges; - - external ffi.Pointer<_RuneEntry> __ranges; -} - -final class _RuneCharClass extends ffi.Struct { - @ffi.Array.multi([14]) - external ffi.Array __name; - - @__uint32_t() - external int __mask; -} - -final class _RuneLocale extends ffi.Struct { - @ffi.Array.multi([8]) - external ffi.Array __magic; - - @ffi.Array.multi([32]) - external ffi.Array __encoding; - - external ffi.Pointer< - ffi.NativeFunction< - __darwin_rune_t Function( - ffi.Pointer, - __darwin_size_t, - ffi.Pointer>, - ) - > - > - __sgetrune; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - __darwin_rune_t, - ffi.Pointer, - __darwin_size_t, - ffi.Pointer>, - ) - > - > - __sputrune; - - @__darwin_rune_t() - external int __invalid_rune; - - @ffi.Array.multi([256]) - external ffi.Array<__uint32_t> __runetype; - - @ffi.Array.multi([256]) - external ffi.Array<__darwin_rune_t> __maplower; - - @ffi.Array.multi([256]) - external ffi.Array<__darwin_rune_t> __mapupper; - - external _RuneRange __runetype_ext; - - external _RuneRange __maplower_ext; - - external _RuneRange __mapupper_ext; - - external ffi.Pointer __variable; - - @ffi.Int() - external int __variable_len; - - @ffi.Int() - external int __ncharclasses; - - external ffi.Pointer<_RuneCharClass> __charclasses; -} - -final class _xlocale extends ffi.Opaque {} - -typedef locale_t = ffi.Pointer<_xlocale>; - -final class lconv extends ffi.Struct { - external ffi.Pointer decimal_point; - - external ffi.Pointer thousands_sep; - - external ffi.Pointer grouping; - - external ffi.Pointer int_curr_symbol; - - external ffi.Pointer currency_symbol; - - external ffi.Pointer mon_decimal_point; - - external ffi.Pointer mon_thousands_sep; - - external ffi.Pointer mon_grouping; - - external ffi.Pointer positive_sign; - - external ffi.Pointer negative_sign; - - @ffi.Char() - external int int_frac_digits; - - @ffi.Char() - external int frac_digits; - - @ffi.Char() - external int p_cs_precedes; - - @ffi.Char() - external int p_sep_by_space; - - @ffi.Char() - external int n_cs_precedes; - - @ffi.Char() - external int n_sep_by_space; - - @ffi.Char() - external int p_sign_posn; - - @ffi.Char() - external int n_sign_posn; - - @ffi.Char() - external int int_p_cs_precedes; - - @ffi.Char() - external int int_n_cs_precedes; - - @ffi.Char() - external int int_p_sep_by_space; - - @ffi.Char() - external int int_n_sep_by_space; - - @ffi.Char() - external int int_p_sign_posn; - - @ffi.Char() - external int int_n_sign_posn; -} - -typedef float_t = ffi.Float; -typedef Dartfloat_t = double; -typedef double_t = ffi.Double; -typedef Dartdouble_t = double; - -final class __float2 extends ffi.Struct { - @ffi.Float() - external double __sinval; - - @ffi.Float() - external double __cosval; -} - -final class __double2 extends ffi.Struct { - @ffi.Double() - external double __sinval; - - @ffi.Double() - external double __cosval; -} - -final class exception extends ffi.Struct { - @ffi.Int() - external int type; - - external ffi.Pointer name; - - @ffi.Double() - external double arg1; - - @ffi.Double() - external double arg2; - - @ffi.Double() - external double retval; -} - -typedef fpos_t = __darwin_off_t; - -final class __sbuf extends ffi.Struct { - external ffi.Pointer _base; - - @ffi.Int() - external int _size; -} - -final class __sFILEX extends ffi.Opaque {} - -final class __sFILE extends ffi.Struct { - external ffi.Pointer _p; - - @ffi.Int() - external int _r; - - @ffi.Int() - external int _w; - - @ffi.Short() - external int _flags; - - @ffi.Short() - external int _file; - - external __sbuf _bf; - - @ffi.Int() - external int _lbfsize; - - external ffi.Pointer _cookie; - - external ffi.Pointer< - ffi.NativeFunction)> - > - _close; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int) - > - > - _read; - - external ffi.Pointer< - ffi.NativeFunction, fpos_t, ffi.Int)> - > - _seek; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int) - > - > - _write; - - external __sbuf _ub; - - external ffi.Pointer<__sFILEX> _extra; - - @ffi.Int() - external int _ur; - - @ffi.Array.multi([3]) - external ffi.Array _ubuf; - - @ffi.Array.multi([1]) - external ffi.Array _nbuf; - - external __sbuf _lb; - - @ffi.Int() - external int _blksize; - - @fpos_t() - external int _offset; -} - -typedef FILE = __sFILE; - -final class timespec extends ffi.Struct { - @__darwin_time_t() - external int tv_sec; - - @ffi.Long() - external int tv_nsec; -} - -final class tm extends ffi.Struct { - @ffi.Int() - external int tm_sec; - - @ffi.Int() - external int tm_min; - - @ffi.Int() - external int tm_hour; - - @ffi.Int() - external int tm_mday; - - @ffi.Int() - external int tm_mon; - - @ffi.Int() - external int tm_year; - - @ffi.Int() - external int tm_wday; - - @ffi.Int() - external int tm_yday; - - @ffi.Int() - external int tm_isdst; - - @ffi.Long() - external int tm_gmtoff; - - external ffi.Pointer tm_zone; -} - -enum clockid_t { - _CLOCK_REALTIME(0), - _CLOCK_MONOTONIC(6), - _CLOCK_MONOTONIC_RAW(4), - _CLOCK_MONOTONIC_RAW_APPROX(5), - _CLOCK_UPTIME_RAW(8), - _CLOCK_UPTIME_RAW_APPROX(9), - _CLOCK_PROCESS_CPUTIME_ID(12), - _CLOCK_THREAD_CPUTIME_ID(16); - - final int value; - const clockid_t(this.value); - - static clockid_t fromValue(int value) => switch (value) { - 0 => _CLOCK_REALTIME, - 6 => _CLOCK_MONOTONIC, - 4 => _CLOCK_MONOTONIC_RAW, - 5 => _CLOCK_MONOTONIC_RAW_APPROX, - 8 => _CLOCK_UPTIME_RAW, - 9 => _CLOCK_UPTIME_RAW_APPROX, - 12 => _CLOCK_PROCESS_CPUTIME_ID, - 16 => _CLOCK_THREAD_CPUTIME_ID, - _ => throw ArgumentError('Unknown value for clockid_t: $value'), - }; -} - -final class imaxdiv_t extends ffi.Struct { - @intmax_t() - external int quot; - - @intmax_t() - external int rem; -} - -typedef CFBagRetainCallBackFunction = - ffi.Pointer Function( - CFAllocatorRef allocator, - ffi.Pointer value, - ); -typedef CFBagRetainCallBack = - ffi.Pointer>; -typedef CFBagReleaseCallBackFunction = - ffi.Void Function(CFAllocatorRef allocator, ffi.Pointer value); -typedef DartCFBagReleaseCallBackFunction = - void Function(CFAllocatorRef allocator, ffi.Pointer value); -typedef CFBagReleaseCallBack = - ffi.Pointer>; -typedef CFBagCopyDescriptionCallBackFunction = - CFStringRef Function(ffi.Pointer value); -typedef CFBagCopyDescriptionCallBack = - ffi.Pointer>; -typedef CFBagEqualCallBackFunction = - Boolean Function( - ffi.Pointer value1, - ffi.Pointer value2, - ); -typedef DartCFBagEqualCallBackFunction = - DartBoolean Function( - ffi.Pointer value1, - ffi.Pointer value2, - ); -typedef CFBagEqualCallBack = - ffi.Pointer>; -typedef CFBagHashCallBackFunction = - CFHashCode Function(ffi.Pointer value); -typedef DartCFBagHashCallBackFunction = - DartCFHashCode Function(ffi.Pointer value); -typedef CFBagHashCallBack = - ffi.Pointer>; - -final class CFBagCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFBagRetainCallBack retain; - - external CFBagReleaseCallBack release; - - external CFBagCopyDescriptionCallBack copyDescription; - - external CFBagEqualCallBack equal; - - external CFBagHashCallBack hash; -} - -typedef CFBagApplierFunctionFunction = - ffi.Void Function( - ffi.Pointer value, - ffi.Pointer context, - ); -typedef DartCFBagApplierFunctionFunction = - void Function(ffi.Pointer value, ffi.Pointer context); -typedef CFBagApplierFunction = - ffi.Pointer>; - -final class __CFBag extends ffi.Opaque {} - -typedef CFBagRef = ffi.Pointer<__CFBag>; -typedef CFMutableBagRef = ffi.Pointer<__CFBag>; - -final class CFBinaryHeapCompareContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; -} - -final class CFBinaryHeapCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - CFAllocatorRef allocator, - ffi.Pointer ptr, - ) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(CFAllocatorRef allocator, ffi.Pointer ptr) - > - > - release; - - external ffi.Pointer< - ffi.NativeFunction ptr)> - > - copyDescription; - - external ffi.Pointer< - ffi.NativeFunction< - CFIndex Function( - ffi.Pointer ptr1, - ffi.Pointer ptr2, - ffi.Pointer context, - ) - > - > - compare; -} - -typedef CFBinaryHeapApplierFunctionFunction = - ffi.Void Function(ffi.Pointer val, ffi.Pointer context); -typedef DartCFBinaryHeapApplierFunctionFunction = - void Function(ffi.Pointer val, ffi.Pointer context); -typedef CFBinaryHeapApplierFunction = - ffi.Pointer>; - -final class __CFBinaryHeap extends ffi.Opaque {} - -typedef CFBinaryHeapRef = ffi.Pointer<__CFBinaryHeap>; -typedef CFBit = UInt32; - -final class __CFBitVector extends ffi.Opaque {} - -typedef CFBitVectorRef = ffi.Pointer<__CFBitVector>; -typedef CFMutableBitVectorRef = ffi.Pointer<__CFBitVector>; - -@ffi.Packed(1) -final class _OSUnalignedU16 extends ffi.Struct { - @ffi.Uint16() - external int __val; -} - -@ffi.Packed(1) -final class _OSUnalignedU32 extends ffi.Struct { - @ffi.Uint32() - external int __val; -} - -@ffi.Packed(1) -final class _OSUnalignedU64 extends ffi.Struct { - @ffi.Uint64() - external int __val; -} - -typedef CFByteOrder = CFIndex; - -final class CFSwappedFloat32 extends ffi.Struct { - @ffi.Uint32() - external int v; -} - -final class CFSwappedFloat64 extends ffi.Struct { - @ffi.Uint64() - external int v; -} - -typedef CFDictionaryRetainCallBackFunction = - ffi.Pointer Function( - CFAllocatorRef allocator, - ffi.Pointer value, - ); -typedef CFDictionaryRetainCallBack = - ffi.Pointer>; -typedef CFDictionaryReleaseCallBackFunction = - ffi.Void Function(CFAllocatorRef allocator, ffi.Pointer value); -typedef DartCFDictionaryReleaseCallBackFunction = - void Function(CFAllocatorRef allocator, ffi.Pointer value); -typedef CFDictionaryReleaseCallBack = - ffi.Pointer>; -typedef CFDictionaryCopyDescriptionCallBackFunction = - CFStringRef Function(ffi.Pointer value); -typedef CFDictionaryCopyDescriptionCallBack = - ffi.Pointer< - ffi.NativeFunction - >; -typedef CFDictionaryEqualCallBackFunction = - Boolean Function( - ffi.Pointer value1, - ffi.Pointer value2, - ); -typedef DartCFDictionaryEqualCallBackFunction = - DartBoolean Function( - ffi.Pointer value1, - ffi.Pointer value2, - ); -typedef CFDictionaryEqualCallBack = - ffi.Pointer>; -typedef CFDictionaryHashCallBackFunction = - CFHashCode Function(ffi.Pointer value); -typedef DartCFDictionaryHashCallBackFunction = - DartCFHashCode Function(ffi.Pointer value); -typedef CFDictionaryHashCallBack = - ffi.Pointer>; - -final class CFDictionaryKeyCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFDictionaryRetainCallBack retain; - - external CFDictionaryReleaseCallBack release; - - external CFDictionaryCopyDescriptionCallBack copyDescription; - - external CFDictionaryEqualCallBack equal; - - external CFDictionaryHashCallBack hash; -} - -final class CFDictionaryValueCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFDictionaryRetainCallBack retain; - - external CFDictionaryReleaseCallBack release; - - external CFDictionaryCopyDescriptionCallBack copyDescription; - - external CFDictionaryEqualCallBack equal; -} - -typedef CFDictionaryApplierFunctionFunction = - ffi.Void Function( - ffi.Pointer key, - ffi.Pointer value, - ffi.Pointer context, - ); -typedef DartCFDictionaryApplierFunctionFunction = - void Function( - ffi.Pointer key, - ffi.Pointer value, - ffi.Pointer context, - ); -typedef CFDictionaryApplierFunction = - ffi.Pointer>; - -final class __CFDictionary extends ffi.Opaque {} - -typedef CFDictionaryRef = ffi.Pointer<__CFDictionary>; -typedef CFMutableDictionaryRef = ffi.Pointer<__CFDictionary>; -typedef CFNotificationName = CFStringRef; - -final class __CFNotificationCenter extends ffi.Opaque {} - -typedef CFNotificationCenterRef = ffi.Pointer<__CFNotificationCenter>; -typedef CFNotificationCallbackFunction = - ffi.Void Function( - CFNotificationCenterRef center, - ffi.Pointer observer, - CFNotificationName name, - ffi.Pointer object, - CFDictionaryRef userInfo, - ); -typedef DartCFNotificationCallbackFunction = - void Function( - CFNotificationCenterRef center, - ffi.Pointer observer, - CFNotificationName name, - ffi.Pointer object, - CFDictionaryRef userInfo, - ); -typedef CFNotificationCallback = - ffi.Pointer>; - -enum CFNotificationSuspensionBehavior { - CFNotificationSuspensionBehaviorDrop(1), - CFNotificationSuspensionBehaviorCoalesce(2), - CFNotificationSuspensionBehaviorHold(3), - CFNotificationSuspensionBehaviorDeliverImmediately(4); - - final int value; - const CFNotificationSuspensionBehavior(this.value); - - static CFNotificationSuspensionBehavior fromValue(int value) => - switch (value) { - 1 => CFNotificationSuspensionBehaviorDrop, - 2 => CFNotificationSuspensionBehaviorCoalesce, - 3 => CFNotificationSuspensionBehaviorHold, - 4 => CFNotificationSuspensionBehaviorDeliverImmediately, - _ => throw ArgumentError( - 'Unknown value for CFNotificationSuspensionBehavior: $value', - ), - }; -} - -typedef CFLocaleIdentifier = CFStringRef; -typedef CFLocaleKey = CFStringRef; - -final class __CFLocale extends ffi.Opaque {} - -typedef CFLocaleRef = ffi.Pointer<__CFLocale>; - -enum CFLocaleLanguageDirection { - kCFLocaleLanguageDirectionUnknown(0), - kCFLocaleLanguageDirectionLeftToRight(1), - kCFLocaleLanguageDirectionRightToLeft(2), - kCFLocaleLanguageDirectionTopToBottom(3), - kCFLocaleLanguageDirectionBottomToTop(4); - - final int value; - const CFLocaleLanguageDirection(this.value); - - static CFLocaleLanguageDirection fromValue(int value) => switch (value) { - 0 => kCFLocaleLanguageDirectionUnknown, - 1 => kCFLocaleLanguageDirectionLeftToRight, - 2 => kCFLocaleLanguageDirectionRightToLeft, - 3 => kCFLocaleLanguageDirectionTopToBottom, - 4 => kCFLocaleLanguageDirectionBottomToTop, - _ => throw ArgumentError( - 'Unknown value for CFLocaleLanguageDirection: $value', - ), - }; -} - -typedef CFCalendarIdentifier = CFStringRef; -typedef CFTimeInterval = ffi.Double; -typedef DartCFTimeInterval = double; -typedef CFAbsoluteTime = CFTimeInterval; - -final class __CFDate extends ffi.Opaque {} - -typedef CFDateRef = ffi.Pointer<__CFDate>; - -final class __CFTimeZone extends ffi.Opaque {} - -typedef CFTimeZoneRef = ffi.Pointer<__CFTimeZone>; - -final class CFGregorianDate extends ffi.Struct { - @SInt32() - external int year; - - @SInt8() - external int month; - - @SInt8() - external int day; - - @SInt8() - external int hour; - - @SInt8() - external int minute; - - @ffi.Double() - external double second; -} - -final class CFGregorianUnits extends ffi.Struct { - @SInt32() - external int years; - - @SInt32() - external int months; - - @SInt32() - external int days; - - @SInt32() - external int hours; - - @SInt32() - external int minutes; - - @ffi.Double() - external double seconds; -} - -final class __CFData extends ffi.Opaque {} - -typedef CFDataRef = ffi.Pointer<__CFData>; -typedef CFMutableDataRef = ffi.Pointer<__CFData>; - -sealed class CFDataSearchFlags { - static const kCFDataSearchBackwards = 1; - static const kCFDataSearchAnchored = 2; -} - -final class __CFCharacterSet extends ffi.Opaque {} - -typedef CFCharacterSetRef = ffi.Pointer<__CFCharacterSet>; -typedef CFMutableCharacterSetRef = ffi.Pointer<__CFCharacterSet>; - -enum CFCharacterSetPredefinedSet { - kCFCharacterSetControl(1), - kCFCharacterSetWhitespace(2), - kCFCharacterSetWhitespaceAndNewline(3), - kCFCharacterSetDecimalDigit(4), - kCFCharacterSetLetter(5), - kCFCharacterSetLowercaseLetter(6), - kCFCharacterSetUppercaseLetter(7), - kCFCharacterSetNonBase(8), - kCFCharacterSetDecomposable(9), - kCFCharacterSetAlphaNumeric(10), - kCFCharacterSetPunctuation(11), - kCFCharacterSetCapitalizedLetter(13), - kCFCharacterSetSymbol(14), - kCFCharacterSetNewline(15), - kCFCharacterSetIllegal(12); - - final int value; - const CFCharacterSetPredefinedSet(this.value); - - static CFCharacterSetPredefinedSet fromValue(int value) => switch (value) { - 1 => kCFCharacterSetControl, - 2 => kCFCharacterSetWhitespace, - 3 => kCFCharacterSetWhitespaceAndNewline, - 4 => kCFCharacterSetDecimalDigit, - 5 => kCFCharacterSetLetter, - 6 => kCFCharacterSetLowercaseLetter, - 7 => kCFCharacterSetUppercaseLetter, - 8 => kCFCharacterSetNonBase, - 9 => kCFCharacterSetDecomposable, - 10 => kCFCharacterSetAlphaNumeric, - 11 => kCFCharacterSetPunctuation, - 13 => kCFCharacterSetCapitalizedLetter, - 14 => kCFCharacterSetSymbol, - 15 => kCFCharacterSetNewline, - 12 => kCFCharacterSetIllegal, - _ => throw ArgumentError( - 'Unknown value for CFCharacterSetPredefinedSet: $value', - ), - }; -} - -typedef CFErrorDomain = CFStringRef; - -final class __CFError extends ffi.Opaque {} - -typedef CFErrorRef = ffi.Pointer<__CFError>; -typedef CFStringEncoding = UInt32; - -sealed class CFStringCompareFlags { - static const kCFCompareCaseInsensitive = 1; - static const kCFCompareBackwards = 4; - static const kCFCompareAnchored = 8; - static const kCFCompareNonliteral = 16; - static const kCFCompareLocalized = 32; - static const kCFCompareNumerically = 64; - static const kCFCompareDiacriticInsensitive = 128; - static const kCFCompareWidthInsensitive = 256; - static const kCFCompareForcedOrdering = 512; -} - -enum CFStringNormalizationForm { - kCFStringNormalizationFormD(0), - kCFStringNormalizationFormKD(1), - kCFStringNormalizationFormC(2), - kCFStringNormalizationFormKC(3); - - final int value; - const CFStringNormalizationForm(this.value); - - static CFStringNormalizationForm fromValue(int value) => switch (value) { - 0 => kCFStringNormalizationFormD, - 1 => kCFStringNormalizationFormKD, - 2 => kCFStringNormalizationFormC, - 3 => kCFStringNormalizationFormKC, - _ => throw ArgumentError( - 'Unknown value for CFStringNormalizationForm: $value', - ), - }; -} - -final class CFStringInlineBuffer extends ffi.Struct { - @ffi.Array.multi([64]) - external ffi.Array buffer; - - external CFStringRef theString; - - external ffi.Pointer directUniCharBuffer; - - external ffi.Pointer directCStringBuffer; - - external CFRange rangeToBuffer; - - @CFIndex() - external int bufferedRangeStart; - - @CFIndex() - external int bufferedRangeEnd; -} - -enum CFTimeZoneNameStyle { - kCFTimeZoneNameStyleStandard(0), - kCFTimeZoneNameStyleShortStandard(1), - kCFTimeZoneNameStyleDaylightSaving(2), - kCFTimeZoneNameStyleShortDaylightSaving(3), - kCFTimeZoneNameStyleGeneric(4), - kCFTimeZoneNameStyleShortGeneric(5); - - final int value; - const CFTimeZoneNameStyle(this.value); - - static CFTimeZoneNameStyle fromValue(int value) => switch (value) { - 0 => kCFTimeZoneNameStyleStandard, - 1 => kCFTimeZoneNameStyleShortStandard, - 2 => kCFTimeZoneNameStyleDaylightSaving, - 3 => kCFTimeZoneNameStyleShortDaylightSaving, - 4 => kCFTimeZoneNameStyleGeneric, - 5 => kCFTimeZoneNameStyleShortGeneric, - _ => throw ArgumentError('Unknown value for CFTimeZoneNameStyle: $value'), - }; -} - -final class __CFCalendar extends ffi.Opaque {} - -typedef CFCalendarRef = ffi.Pointer<__CFCalendar>; - -sealed class CFCalendarUnit { - static const kCFCalendarUnitEra = 2; - static const kCFCalendarUnitYear = 4; - static const kCFCalendarUnitMonth = 8; - static const kCFCalendarUnitDay = 16; - static const kCFCalendarUnitHour = 32; - static const kCFCalendarUnitMinute = 64; - static const kCFCalendarUnitSecond = 128; - static const kCFCalendarUnitWeek = 256; - static const kCFCalendarUnitWeekday = 512; - static const kCFCalendarUnitWeekdayOrdinal = 1024; - static const kCFCalendarUnitQuarter = 2048; - static const kCFCalendarUnitWeekOfMonth = 4096; - static const kCFCalendarUnitWeekOfYear = 8192; - static const kCFCalendarUnitYearForWeekOfYear = 16384; - static const kCFCalendarUnitDayOfYear = 65536; -} - -typedef CGFloat = ffi.Double; -typedef DartCGFloat = double; - -final class CGVector extends ffi.Struct { - @CGFloat() - external double dx; - - @CGFloat() - external double dy; -} - -final class CGAffineTransform extends ffi.Struct { - @CGFloat() - external double a; - - @CGFloat() - external double b; - - @CGFloat() - external double c; - - @CGFloat() - external double d; - - @CGFloat() - external double tx; - - @CGFloat() - external double ty; -} - -final class CGAffineTransformComponents extends ffi.Struct { - external objc.CGSize scale; - - @CGFloat() - external double horizontalShear; - - @CGFloat() - external double rotation; - - external CGVector translation; -} - -typedef CFDateFormatterKey = CFStringRef; - -final class __CFDateFormatter extends ffi.Opaque {} - -typedef CFDateFormatterRef = ffi.Pointer<__CFDateFormatter>; - -enum CFDateFormatterStyle { - kCFDateFormatterNoStyle(0), - kCFDateFormatterShortStyle(1), - kCFDateFormatterMediumStyle(2), - kCFDateFormatterLongStyle(3), - kCFDateFormatterFullStyle(4); - - final int value; - const CFDateFormatterStyle(this.value); - - static CFDateFormatterStyle fromValue(int value) => switch (value) { - 0 => kCFDateFormatterNoStyle, - 1 => kCFDateFormatterShortStyle, - 2 => kCFDateFormatterMediumStyle, - 3 => kCFDateFormatterLongStyle, - 4 => kCFDateFormatterFullStyle, - _ => throw ArgumentError('Unknown value for CFDateFormatterStyle: $value'), - }; -} - -sealed class CFISO8601DateFormatOptions { - static const kCFISO8601DateFormatWithYear = 1; - static const kCFISO8601DateFormatWithMonth = 2; - static const kCFISO8601DateFormatWithWeekOfYear = 4; - static const kCFISO8601DateFormatWithDay = 16; - static const kCFISO8601DateFormatWithTime = 32; - static const kCFISO8601DateFormatWithTimeZone = 64; - static const kCFISO8601DateFormatWithSpaceBetweenDateAndTime = 128; - static const kCFISO8601DateFormatWithDashSeparatorInDate = 256; - static const kCFISO8601DateFormatWithColonSeparatorInTime = 512; - static const kCFISO8601DateFormatWithColonSeparatorInTimeZone = 1024; - static const kCFISO8601DateFormatWithFractionalSeconds = 2048; - static const kCFISO8601DateFormatWithFullDate = 275; - static const kCFISO8601DateFormatWithFullTime = 1632; - static const kCFISO8601DateFormatWithInternetDateTime = 1907; -} - -final class __CFBoolean extends ffi.Opaque {} - -typedef CFBooleanRef = ffi.Pointer<__CFBoolean>; - -enum CFNumberType { - kCFNumberSInt8Type(1), - kCFNumberSInt16Type(2), - kCFNumberSInt32Type(3), - kCFNumberSInt64Type(4), - kCFNumberFloat32Type(5), - kCFNumberFloat64Type(6), - kCFNumberCharType(7), - kCFNumberShortType(8), - kCFNumberIntType(9), - kCFNumberLongType(10), - kCFNumberLongLongType(11), - kCFNumberFloatType(12), - kCFNumberDoubleType(13), - kCFNumberCFIndexType(14), - kCFNumberNSIntegerType(15), - kCFNumberCGFloatType(16); - - static const kCFNumberMaxType = kCFNumberCGFloatType; - - final int value; - const CFNumberType(this.value); - - static CFNumberType fromValue(int value) => switch (value) { - 1 => kCFNumberSInt8Type, - 2 => kCFNumberSInt16Type, - 3 => kCFNumberSInt32Type, - 4 => kCFNumberSInt64Type, - 5 => kCFNumberFloat32Type, - 6 => kCFNumberFloat64Type, - 7 => kCFNumberCharType, - 8 => kCFNumberShortType, - 9 => kCFNumberIntType, - 10 => kCFNumberLongType, - 11 => kCFNumberLongLongType, - 12 => kCFNumberFloatType, - 13 => kCFNumberDoubleType, - 14 => kCFNumberCFIndexType, - 15 => kCFNumberNSIntegerType, - 16 => kCFNumberCGFloatType, - _ => throw ArgumentError('Unknown value for CFNumberType: $value'), - }; - - @override - String toString() { - if (this == kCFNumberCGFloatType) - return "CFNumberType.kCFNumberCGFloatType, CFNumberType.kCFNumberMaxType"; - return super.toString(); - } -} - -final class __CFNumber extends ffi.Opaque {} - -typedef CFNumberRef = ffi.Pointer<__CFNumber>; -typedef CFNumberFormatterKey = CFStringRef; - -final class __CFNumberFormatter extends ffi.Opaque {} - -typedef CFNumberFormatterRef = ffi.Pointer<__CFNumberFormatter>; - -enum CFNumberFormatterStyle { - kCFNumberFormatterNoStyle(0), - kCFNumberFormatterDecimalStyle(1), - kCFNumberFormatterCurrencyStyle(2), - kCFNumberFormatterPercentStyle(3), - kCFNumberFormatterScientificStyle(4), - kCFNumberFormatterSpellOutStyle(5), - kCFNumberFormatterOrdinalStyle(6), - kCFNumberFormatterCurrencyISOCodeStyle(8), - kCFNumberFormatterCurrencyPluralStyle(9), - kCFNumberFormatterCurrencyAccountingStyle(10); - - final int value; - const CFNumberFormatterStyle(this.value); - - static CFNumberFormatterStyle fromValue(int value) => switch (value) { - 0 => kCFNumberFormatterNoStyle, - 1 => kCFNumberFormatterDecimalStyle, - 2 => kCFNumberFormatterCurrencyStyle, - 3 => kCFNumberFormatterPercentStyle, - 4 => kCFNumberFormatterScientificStyle, - 5 => kCFNumberFormatterSpellOutStyle, - 6 => kCFNumberFormatterOrdinalStyle, - 8 => kCFNumberFormatterCurrencyISOCodeStyle, - 9 => kCFNumberFormatterCurrencyPluralStyle, - 10 => kCFNumberFormatterCurrencyAccountingStyle, - _ => throw ArgumentError( - 'Unknown value for CFNumberFormatterStyle: $value', - ), - }; -} - -enum CFURLPathStyle { - kCFURLPOSIXPathStyle(0), - kCFURLHFSPathStyle(1), - kCFURLWindowsPathStyle(2); - - final int value; - const CFURLPathStyle(this.value); - - static CFURLPathStyle fromValue(int value) => switch (value) { - 0 => kCFURLPOSIXPathStyle, - 1 => kCFURLHFSPathStyle, - 2 => kCFURLWindowsPathStyle, - _ => throw ArgumentError('Unknown value for CFURLPathStyle: $value'), - }; -} - -final class __CFURL extends ffi.Opaque {} - -typedef CFURLRef = ffi.Pointer<__CFURL>; - -enum CFURLComponentType { - kCFURLComponentScheme(1), - kCFURLComponentNetLocation(2), - kCFURLComponentPath(3), - kCFURLComponentResourceSpecifier(4), - kCFURLComponentUser(5), - kCFURLComponentPassword(6), - kCFURLComponentUserInfo(7), - kCFURLComponentHost(8), - kCFURLComponentPort(9), - kCFURLComponentParameterString(10), - kCFURLComponentQuery(11), - kCFURLComponentFragment(12); - - final int value; - const CFURLComponentType(this.value); - - static CFURLComponentType fromValue(int value) => switch (value) { - 1 => kCFURLComponentScheme, - 2 => kCFURLComponentNetLocation, - 3 => kCFURLComponentPath, - 4 => kCFURLComponentResourceSpecifier, - 5 => kCFURLComponentUser, - 6 => kCFURLComponentPassword, - 7 => kCFURLComponentUserInfo, - 8 => kCFURLComponentHost, - 9 => kCFURLComponentPort, - 10 => kCFURLComponentParameterString, - 11 => kCFURLComponentQuery, - 12 => kCFURLComponentFragment, - _ => throw ArgumentError('Unknown value for CFURLComponentType: $value'), - }; -} - -final class FSRef extends ffi.Opaque {} - -sealed class CFURLBookmarkCreationOptions { - static const kCFURLBookmarkCreationMinimalBookmarkMask = 512; - static const kCFURLBookmarkCreationSuitableForBookmarkFile = 1024; - static const kCFURLBookmarkCreationWithSecurityScope = 2048; - static const kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess = 4096; - static const kCFURLBookmarkCreationWithoutImplicitSecurityScope = 536870912; - static const kCFURLBookmarkCreationPreferFileIDResolutionMask = 256; -} - -sealed class CFURLBookmarkResolutionOptions { - static const kCFURLBookmarkResolutionWithoutUIMask = 256; - static const kCFURLBookmarkResolutionWithoutMountingMask = 512; - static const kCFURLBookmarkResolutionWithSecurityScope = 1024; - static const kCFURLBookmarkResolutionWithoutImplicitStartAccessing = 32768; - static const kCFBookmarkResolutionWithoutUIMask = 256; - static const kCFBookmarkResolutionWithoutMountingMask = 512; -} - -typedef CFURLBookmarkFileCreationOptions = CFOptionFlags; -typedef boolean_t = ffi.Int; -typedef Dartboolean_t = int; -typedef natural_t = __darwin_natural_t; -typedef integer_t = ffi.Int; -typedef Dartinteger_t = int; -typedef vm_offset_t = ffi.UintPtr; -typedef Dartvm_offset_t = int; -typedef vm_size_t = ffi.UintPtr; -typedef Dartvm_size_t = int; -typedef mach_vm_address_t = ffi.Uint64; -typedef Dartmach_vm_address_t = int; -typedef mach_vm_offset_t = ffi.Uint64; -typedef Dartmach_vm_offset_t = int; -typedef mach_vm_size_t = ffi.Uint64; -typedef Dartmach_vm_size_t = int; -typedef vm_map_offset_t = ffi.Uint64; -typedef Dartvm_map_offset_t = int; -typedef vm_map_address_t = ffi.Uint64; -typedef Dartvm_map_address_t = int; -typedef vm_map_size_t = ffi.Uint64; -typedef Dartvm_map_size_t = int; -typedef vm32_offset_t = ffi.Uint32; -typedef Dartvm32_offset_t = int; -typedef vm32_address_t = ffi.Uint32; -typedef Dartvm32_address_t = int; -typedef vm32_size_t = ffi.Uint32; -typedef Dartvm32_size_t = int; -typedef mach_port_context_t = vm_offset_t; -typedef mach_port_name_t = natural_t; -typedef mach_port_name_array_t = ffi.Pointer; -typedef mach_port_t = __darwin_mach_port_t; -typedef mach_port_array_t = ffi.Pointer; -typedef mach_port_right_t = natural_t; -typedef mach_port_type_t = natural_t; -typedef mach_port_type_array_t = ffi.Pointer; -typedef mach_port_urefs_t = natural_t; -typedef mach_port_delta_t = integer_t; -typedef mach_port_seqno_t = natural_t; -typedef mach_port_mscount_t = natural_t; -typedef mach_port_msgcount_t = natural_t; -typedef mach_port_rights_t = natural_t; -typedef mach_port_srights_t = ffi.UnsignedInt; -typedef Dartmach_port_srights_t = int; - -final class mach_port_status extends ffi.Struct { - @mach_port_rights_t() - external int mps_pset; - - @mach_port_seqno_t() - external int mps_seqno; - - @mach_port_mscount_t() - external int mps_mscount; - - @mach_port_msgcount_t() - external int mps_qlimit; - - @mach_port_msgcount_t() - external int mps_msgcount; - - @mach_port_rights_t() - external int mps_sorights; - - @boolean_t() - external int mps_srights; - - @boolean_t() - external int mps_pdrequest; - - @boolean_t() - external int mps_nsrequest; - - @natural_t() - external int mps_flags; -} - -typedef mach_port_status_t = mach_port_status; - -final class mach_port_limits extends ffi.Struct { - @mach_port_msgcount_t() - external int mpl_qlimit; -} - -typedef mach_port_limits_t = mach_port_limits; - -final class mach_port_info_ext extends ffi.Struct { - external mach_port_status_t mpie_status; - - @mach_port_msgcount_t() - external int mpie_boost_cnt; - - @ffi.Array.multi([6]) - external ffi.Array reserved; -} - -typedef mach_port_info_ext_t = mach_port_info_ext; - -final class mach_port_guard_info extends ffi.Struct { - @ffi.Uint64() - external int mpgi_guard; -} - -typedef mach_port_guard_info_t = mach_port_guard_info; -typedef mach_port_info_t = ffi.Pointer; -typedef mach_port_flavor_t = ffi.Int; -typedef Dartmach_port_flavor_t = int; - -final class mach_port_qos extends ffi.Opaque {} - -typedef mach_port_qos_t = mach_port_qos; - -final class mach_service_port_info extends ffi.Struct { - @ffi.Array.multi([255]) - external ffi.Array mspi_string_name; - - @ffi.Uint8() - external int mspi_domain_type; -} - -typedef mach_service_port_info_data_t = mach_service_port_info; -typedef mach_service_port_info_t = ffi.Pointer; - -final class UnnamedUnion$4 extends ffi.Union { - @ffi.Array.multi([2]) - external ffi.Array reserved; - - @mach_port_name_t() - external int work_interval_port; - - external mach_service_port_info_t service_port_info; - - @mach_port_name_t() - external int service_port_name; -} - -final class mach_port_options extends ffi.Struct { - @ffi.Uint32() - external int flags; - - external mach_port_limits_t mpl; - - external UnnamedUnion$4 unnamed; -} - -typedef mach_port_options_t = mach_port_options; -typedef mach_port_options_ptr_t = ffi.Pointer; -typedef CFRunLoopMode = CFStringRef; -typedef CFRunLoopRef = ffi.Pointer; - -final class __CFRunLoopSource extends ffi.Opaque {} - -typedef CFRunLoopSourceRef = ffi.Pointer<__CFRunLoopSource>; - -final class __CFRunLoopObserver extends ffi.Opaque {} - -typedef CFRunLoopObserverRef = ffi.Pointer<__CFRunLoopObserver>; - -final class __CFRunLoopTimer extends ffi.Opaque {} - -typedef CFRunLoopTimerRef = ffi.Pointer<__CFRunLoopTimer>; - -enum CFRunLoopRunResult { - kCFRunLoopRunFinished(1), - kCFRunLoopRunStopped(2), - kCFRunLoopRunTimedOut(3), - kCFRunLoopRunHandledSource(4); - - final int value; - const CFRunLoopRunResult(this.value); - - static CFRunLoopRunResult fromValue(int value) => switch (value) { - 1 => kCFRunLoopRunFinished, - 2 => kCFRunLoopRunStopped, - 3 => kCFRunLoopRunTimedOut, - 4 => kCFRunLoopRunHandledSource, - _ => throw ArgumentError('Unknown value for CFRunLoopRunResult: $value'), - }; -} - -sealed class CFRunLoopActivity { - static const kCFRunLoopEntry = 1; - static const kCFRunLoopBeforeTimers = 2; - static const kCFRunLoopBeforeSources = 4; - static const kCFRunLoopBeforeWaiting = 32; - static const kCFRunLoopAfterWaiting = 64; - static const kCFRunLoopExit = 128; - static const kCFRunLoopAllActivities = 268435455; -} - -final class CFRunLoopSourceContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; - - external ffi.Pointer< - ffi.NativeFunction< - Boolean Function(ffi.Pointer info1, ffi.Pointer info2) - > - > - equal; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - hash; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer info, - CFRunLoopRef rl, - CFRunLoopMode mode, - ) - > - > - schedule; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer info, - CFRunLoopRef rl, - CFRunLoopMode mode, - ) - > - > - cancel; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - perform; -} - -final class CFRunLoopSourceContext1 extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; - - external ffi.Pointer< - ffi.NativeFunction< - Boolean Function(ffi.Pointer info1, ffi.Pointer info2) - > - > - equal; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - hash; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - getPort; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer msg, - CFIndex size, - CFAllocatorRef allocator, - ffi.Pointer info, - ) - > - > - perform; -} - -final class CFRunLoopObserverContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; -} - -typedef CFRunLoopObserverCallBackFunction = - ffi.Void Function( - CFRunLoopObserverRef observer, - CFOptionFlags activity, - ffi.Pointer info, - ); -typedef DartCFRunLoopObserverCallBackFunction = - void Function( - CFRunLoopObserverRef observer, - DartCFOptionFlags activity, - ffi.Pointer info, - ); -typedef CFRunLoopObserverCallBack = - ffi.Pointer>; - -/// Construction methods for `objc.ObjCBlock, CFOptionFlags)>`. -abstract final class ObjCBlock_ffiVoid_CFRunLoopObserverRef_CFRunLoopActivity { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(CFRunLoopObserverRef arg0, CFOptionFlags arg1) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - > - fromFunction( - void Function(CFRunLoopObserverRef, DartCFOptionFlags) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - >( - objc.newClosureBlock( - _closureCallable, - (CFRunLoopObserverRef arg0, int arg1) => fn(arg0, arg1), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - > - listener( - void Function(CFRunLoopObserverRef, DartCFOptionFlags) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (CFRunLoopObserverRef arg0, int arg1) => fn(arg0, arg1), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_tg5tbv(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - > - blocking( - void Function(CFRunLoopObserverRef, DartCFOptionFlags) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (CFRunLoopObserverRef arg0, int arg1) => fn(arg0, arg1), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (CFRunLoopObserverRef arg0, int arg1) => fn(arg0, arg1), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_tg5tbv( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - CFRunLoopObserverRef arg0, - int arg1, - ) { - (objc.getBlockClosure(block) as void Function(CFRunLoopObserverRef, int))( - arg0, - arg1, - ); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - CFRunLoopObserverRef, - CFOptionFlags, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - CFRunLoopObserverRef, - CFOptionFlags, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - CFRunLoopObserverRef arg0, - int arg1, - ) { - try { - (objc.getBlockClosure(block) as void Function(CFRunLoopObserverRef, int))( - arg0, - arg1, - ); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - CFRunLoopObserverRef, - CFOptionFlags, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - CFRunLoopObserverRef, - CFOptionFlags, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - CFRunLoopObserverRef, - CFOptionFlags, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - CFRunLoopObserverRef, - CFOptionFlags, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - CFRunLoopObserverRef arg0, - int arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(CFRunLoopObserverRef arg0, CFOptionFlags arg1) - > - >() - .asFunction()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - CFRunLoopObserverRef, - CFOptionFlags, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - CFRunLoopObserverRef arg0, - int arg1, - ) => - (objc.getBlockClosure(block) as void Function(CFRunLoopObserverRef, int))( - arg0, - arg1, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - CFRunLoopObserverRef, - CFOptionFlags, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, CFOptionFlags)>`. -extension ObjCBlock_ffiVoid_CFRunLoopObserverRef_CFRunLoopActivity$CallExtension - on - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__CFRunLoopObserver>, CFOptionFlags) - > { - void call(CFRunLoopObserverRef arg0, DartCFOptionFlags arg1) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - CFRunLoopObserverRef arg0, - CFOptionFlags arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - CFRunLoopObserverRef, - int, - ) - >()(ref.pointer, arg0, arg1); -} - -final class CFRunLoopTimerContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; -} - -typedef CFRunLoopTimerCallBackFunction = - ffi.Void Function(CFRunLoopTimerRef timer, ffi.Pointer info); -typedef DartCFRunLoopTimerCallBackFunction = - void Function(CFRunLoopTimerRef timer, ffi.Pointer info); -typedef CFRunLoopTimerCallBack = - ffi.Pointer>; - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_CFRunLoopTimerRef { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock)> - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock)> - fromFunctionPointer( - ffi.Pointer> - ptr, - ) => objc.ObjCBlock)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock)> - fromFunction( - void Function(CFRunLoopTimerRef) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock)>( - objc.newClosureBlock( - _closureCallable, - (CFRunLoopTimerRef arg0) => fn(arg0), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock)> - listener( - void Function(CFRunLoopTimerRef) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (CFRunLoopTimerRef arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1dqvvol(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock)>( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock)> - blocking( - void Function(CFRunLoopTimerRef) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (CFRunLoopTimerRef arg0) => fn(arg0), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (CFRunLoopTimerRef arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1dqvvol( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock)>( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - CFRunLoopTimerRef arg0, - ) { - (objc.getBlockClosure(block) as void Function(CFRunLoopTimerRef))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, CFRunLoopTimerRef) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, CFRunLoopTimerRef) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - CFRunLoopTimerRef arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(CFRunLoopTimerRef))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - CFRunLoopTimerRef, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - CFRunLoopTimerRef, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - CFRunLoopTimerRef, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - CFRunLoopTimerRef, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - CFRunLoopTimerRef arg0, - ) => block.ref.target - .cast>() - .asFunction()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - CFRunLoopTimerRef, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - CFRunLoopTimerRef arg0, - ) => (objc.getBlockClosure(block) as void Function(CFRunLoopTimerRef))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - CFRunLoopTimerRef, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_CFRunLoopTimerRef$CallExtension - on objc.ObjCBlock)> { - void call(CFRunLoopTimerRef arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - CFRunLoopTimerRef arg0, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, CFRunLoopTimerRef) - >()(ref.pointer, arg0); -} - -final class __CFSocket extends ffi.Opaque {} - -typedef CFSocketRef = ffi.Pointer<__CFSocket>; - -enum CFSocketError { - kCFSocketSuccess(0), - kCFSocketError(-1), - kCFSocketTimeout(-2); - - final int value; - const CFSocketError(this.value); - - static CFSocketError fromValue(int value) => switch (value) { - 0 => kCFSocketSuccess, - -1 => kCFSocketError, - -2 => kCFSocketTimeout, - _ => throw ArgumentError('Unknown value for CFSocketError: $value'), - }; -} - -final class CFSocketSignature extends ffi.Struct { - @SInt32() - external int protocolFamily; - - @SInt32() - external int socketType; - - @SInt32() - external int protocol; - - external CFDataRef address; -} - -sealed class CFSocketCallBackType { - static const kCFSocketNoCallBack = 0; - static const kCFSocketReadCallBack = 1; - static const kCFSocketAcceptCallBack = 2; - static const kCFSocketDataCallBack = 3; - static const kCFSocketConnectCallBack = 4; - static const kCFSocketWriteCallBack = 8; -} - -typedef CFSocketCallBackFunction = - ffi.Void Function( - CFSocketRef s, - CFOptionFlags type, - CFDataRef address, - ffi.Pointer data, - ffi.Pointer info, - ); -typedef DartCFSocketCallBackFunction = - void Function( - CFSocketRef s, - DartCFOptionFlags type, - CFDataRef address, - ffi.Pointer data, - ffi.Pointer info, - ); -typedef CFSocketCallBack = - ffi.Pointer>; - -final class CFSocketContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; -} - -typedef CFSocketNativeHandle = ffi.Int; -typedef DartCFSocketNativeHandle = int; - -final class accessx_descriptor extends ffi.Struct { - @ffi.UnsignedInt() - external int ad_name_offset; - - @ffi.Int() - external int ad_flags; - - @ffi.Array.multi([2]) - external ffi.Array ad_pad; -} - -final class fssearchblock extends ffi.Opaque {} - -final class searchstate extends ffi.Opaque {} - -final class flock$1 extends ffi.Struct { - @off_t() - external int l_start; - - @off_t() - external int l_len; - - @pid_t() - external int l_pid; - - @ffi.Short() - external int l_type; - - @ffi.Short() - external int l_whence; -} - -final class flocktimeout extends ffi.Struct { - external flock$1 fl; - - external timespec timeout; -} - -final class radvisory extends ffi.Struct { - @off_t() - external int ra_offset; - - @ffi.Int() - external int ra_count; -} - -final class fsignatures extends ffi.Struct { - @off_t() - external int fs_file_start; - - external ffi.Pointer fs_blob_start; - - @ffi.Size() - external int fs_blob_size; - - @ffi.Size() - external int fs_fsignatures_size; - - @ffi.Array.multi([20]) - external ffi.Array fs_cdhash; - - @ffi.Int() - external int fs_hash_type; -} - -typedef fsignatures_t = fsignatures; - -final class fsupplement extends ffi.Struct { - @off_t() - external int fs_file_start; - - @off_t() - external int fs_blob_start; - - @ffi.Size() - external int fs_blob_size; - - @ffi.Int() - external int fs_orig_fd; -} - -typedef fsupplement_t = fsupplement; - -final class fchecklv extends ffi.Struct { - @off_t() - external int lv_file_start; - - @ffi.Size() - external int lv_error_message_size; - - external ffi.Pointer lv_error_message; -} - -typedef fchecklv_t = fchecklv; - -final class fgetsigsinfo extends ffi.Struct { - @off_t() - external int fg_file_start; - - @ffi.Int() - external int fg_info_request; - - @ffi.Int() - external int fg_sig_is_platform; -} - -typedef fgetsigsinfo_t = fgetsigsinfo; - -final class fstore extends ffi.Struct { - @ffi.UnsignedInt() - external int fst_flags; - - @ffi.Int() - external int fst_posmode; - - @off_t() - external int fst_offset; - - @off_t() - external int fst_length; - - @off_t() - external int fst_bytesalloc; -} - -typedef fstore_t = fstore; - -final class fpunchhole extends ffi.Struct { - @ffi.UnsignedInt() - external int fp_flags; - - @ffi.UnsignedInt() - external int reserved; - - @off_t() - external int fp_offset; - - @off_t() - external int fp_length; -} - -typedef fpunchhole_t = fpunchhole; - -final class ftrimactivefile extends ffi.Struct { - @off_t() - external int fta_offset; - - @off_t() - external int fta_length; -} - -typedef ftrimactivefile_t = ftrimactivefile; - -final class fspecread extends ffi.Struct { - @ffi.UnsignedInt() - external int fsr_flags; - - @ffi.UnsignedInt() - external int reserved; - - @off_t() - external int fsr_offset; - - @off_t() - external int fsr_length; -} - -typedef fspecread_t = fspecread; - -final class fattributiontag extends ffi.Struct { - @ffi.UnsignedInt() - external int ft_flags; - - @ffi.UnsignedLongLong() - external int ft_hash; - - @ffi.Array.multi([255]) - external ffi.Array ft_attribution_name; -} - -typedef fattributiontag_t = fattributiontag; - -@ffi.Packed(4) -final class log2phys extends ffi.Struct { - @ffi.UnsignedInt() - external int l2p_flags; - - @off_t() - external int l2p_contigbytes; - - @off_t() - external int l2p_devoffset; -} - -final class _filesec extends ffi.Opaque {} - -typedef filesec_t = ffi.Pointer<_filesec>; - -enum filesec_property_t { - FILESEC_OWNER(1), - FILESEC_GROUP(2), - FILESEC_UUID(3), - FILESEC_MODE(4), - FILESEC_ACL(5), - FILESEC_GRPUUID(6), - FILESEC_ACL_RAW(100), - FILESEC_ACL_ALLOCSIZE(101); - - final int value; - const filesec_property_t(this.value); - - static filesec_property_t fromValue(int value) => switch (value) { - 1 => FILESEC_OWNER, - 2 => FILESEC_GROUP, - 3 => FILESEC_UUID, - 4 => FILESEC_MODE, - 5 => FILESEC_ACL, - 6 => FILESEC_GRPUUID, - 100 => FILESEC_ACL_RAW, - 101 => FILESEC_ACL_ALLOCSIZE, - _ => throw ArgumentError('Unknown value for filesec_property_t: $value'), - }; -} - -final class os_workgroup_attr_opaque_s extends ffi.Struct { - @ffi.Uint32() - external int sig; - - @ffi.Array.multi([60]) - external ffi.Array opaque; -} - -final class os_workgroup_interval_data_opaque_s extends ffi.Struct { - @ffi.Uint32() - external int sig; - - @ffi.Array.multi([56]) - external ffi.Array opaque; -} - -final class os_workgroup_join_token_opaque_s extends ffi.Struct { - @ffi.Uint32() - external int sig; - - @ffi.Array.multi([36]) - external ffi.Array opaque; -} - -/// WARNING: OS_os_workgroup is a stub. To generate bindings for this class, include -/// OS_os_workgroup in your config's objc-interfaces list. -/// -/// OS_os_workgroup -extension type OS_os_workgroup._(objc.ObjCObject object$) - implements objc.ObjCObject, OS_object { - /// Constructs a [OS_os_workgroup] that points to the same underlying object as [other]. - OS_os_workgroup.as(objc.ObjCObject other) : object$ = other {} - - /// Constructs a [OS_os_workgroup] that wraps the given raw object pointer. - OS_os_workgroup.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} -} - -typedef os_workgroup_t = ffi.Pointer; -typedef Dartos_workgroup_t = OS_os_workgroup; -typedef os_workgroup_attr_s = os_workgroup_attr_opaque_s; -typedef os_workgroup_attr_t = ffi.Pointer; -typedef os_workgroup_join_token_s = os_workgroup_join_token_opaque_s; -typedef os_workgroup_join_token_t = - ffi.Pointer; -typedef os_workgroup_index = ffi.Uint32; -typedef Dartos_workgroup_index = int; -typedef os_workgroup_working_arena_destructor_tFunction = - ffi.Void Function(ffi.Pointer); -typedef Dartos_workgroup_working_arena_destructor_tFunction = - void Function(ffi.Pointer); -typedef os_workgroup_working_arena_destructor_t = - ffi.Pointer< - ffi.NativeFunction - >; - -final class os_workgroup_max_parallel_threads_attr_s extends ffi.Opaque {} - -typedef os_workgroup_mpt_attr_s = os_workgroup_max_parallel_threads_attr_s; -typedef os_workgroup_mpt_attr_t = - ffi.Pointer; -typedef os_workgroup_interval_t = ffi.Pointer; -typedef Dartos_workgroup_interval_t = OS_os_workgroup; -typedef os_workgroup_interval_data_s = os_workgroup_interval_data_opaque_s; -typedef os_workgroup_interval_data_t = - ffi.Pointer; -typedef os_workgroup_parallel_t = ffi.Pointer; -typedef Dartos_workgroup_parallel_t = OS_os_workgroup; -typedef dispatch_function_tFunction = ffi.Void Function(ffi.Pointer); -typedef Dartdispatch_function_tFunction = void Function(ffi.Pointer); -typedef dispatch_function_t = - ffi.Pointer>; - -final class time_value extends ffi.Struct { - @integer_t() - external int seconds; - - @integer_t() - external int microseconds; -} - -typedef time_value_t = time_value; -typedef alarm_type_t = ffi.Int; -typedef Dartalarm_type_t = int; -typedef sleep_type_t = ffi.Int; -typedef Dartsleep_type_t = int; -typedef clock_id_t = ffi.Int; -typedef Dartclock_id_t = int; -typedef clock_flavor_t = ffi.Int; -typedef Dartclock_flavor_t = int; -typedef clock_attr_t = ffi.Pointer; -typedef clock_res_t = ffi.Int; -typedef Dartclock_res_t = int; - -final class mach_timespec extends ffi.Struct { - @ffi.UnsignedInt() - external int tv_sec; - - @clock_res_t() - external int tv_nsec; -} - -typedef mach_timespec_t = mach_timespec; -typedef dispatch_time_t = ffi.Uint64; -typedef Dartdispatch_time_t = int; - -enum qos_class_t { - QOS_CLASS_USER_INTERACTIVE(33), - QOS_CLASS_USER_INITIATED(25), - QOS_CLASS_DEFAULT(21), - QOS_CLASS_UTILITY(17), - QOS_CLASS_BACKGROUND(9), - QOS_CLASS_UNSPECIFIED(0); - - final int value; - const qos_class_t(this.value); - - static qos_class_t fromValue(int value) => switch (value) { - 33 => QOS_CLASS_USER_INTERACTIVE, - 25 => QOS_CLASS_USER_INITIATED, - 21 => QOS_CLASS_DEFAULT, - 17 => QOS_CLASS_UTILITY, - 9 => QOS_CLASS_BACKGROUND, - 0 => QOS_CLASS_UNSPECIFIED, - _ => throw ArgumentError('Unknown value for qos_class_t: $value'), - }; -} - -typedef dispatch_object_t = ffi.Pointer; -typedef Dartdispatch_object_t = objc.NSObject; -typedef dispatch_block_t = ffi.Pointer; -typedef Dartdispatch_block_t = objc.ObjCBlock; -typedef dispatch_queue_t = ffi.Pointer; -typedef Dartdispatch_queue_t = objc.NSObject; -typedef dispatch_queue_global_t = ffi.Pointer; -typedef Dartdispatch_queue_global_t = objc.NSObject; -typedef dispatch_queue_serial_executor_t = ffi.Pointer; -typedef Dartdispatch_queue_serial_executor_t = objc.NSObject; -typedef dispatch_queue_serial_t = ffi.Pointer; -typedef Dartdispatch_queue_serial_t = objc.NSObject; -typedef dispatch_queue_main_t = ffi.Pointer; -typedef Dartdispatch_queue_main_t = objc.NSObject; -typedef dispatch_queue_concurrent_t = ffi.Pointer; -typedef Dartdispatch_queue_concurrent_t = objc.NSObject; - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_ffiSize { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer> ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (int arg0) => fn(arg0), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_6enxqz(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_6enxqz( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - int arg0, - ) { - (objc.getBlockClosure(block) as void Function(int))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Size) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Size) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - int arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(int))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - int arg0, - ) => block.ref.target - .cast>() - .asFunction()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Size) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - int arg0, - ) => (objc.getBlockClosure(block) as void Function(int))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Size) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_ffiSize$CallExtension - on objc.ObjCBlock { - void call(int arg0) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Size arg0, - ) - > - >() - .asFunction, int)>()( - ref.pointer, - arg0, - ); -} - -final class dispatch_queue_s extends ffi.Opaque {} - -typedef dispatch_queue_priority_t = ffi.Long; -typedef Dartdispatch_queue_priority_t = int; -typedef dispatch_queue_attr_t = ffi.Pointer; -typedef Dartdispatch_queue_attr_t = objc.NSObject; - -final class dispatch_queue_attr_s extends ffi.Opaque {} - -enum dispatch_autorelease_frequency_t { - DISPATCH_AUTORELEASE_FREQUENCY_INHERIT(0), - DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM(1), - DISPATCH_AUTORELEASE_FREQUENCY_NEVER(2); - - final int value; - const dispatch_autorelease_frequency_t(this.value); - - static dispatch_autorelease_frequency_t fromValue(int value) => - switch (value) { - 0 => DISPATCH_AUTORELEASE_FREQUENCY_INHERIT, - 1 => DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM, - 2 => DISPATCH_AUTORELEASE_FREQUENCY_NEVER, - _ => throw ArgumentError( - 'Unknown value for dispatch_autorelease_frequency_t: $value', - ), - }; -} - -sealed class dispatch_block_flags_t { - static const DISPATCH_BLOCK_BARRIER = 1; - static const DISPATCH_BLOCK_DETACHED = 2; - static const DISPATCH_BLOCK_ASSIGN_CURRENT = 4; - static const DISPATCH_BLOCK_NO_QOS_CLASS = 8; - static const DISPATCH_BLOCK_INHERIT_QOS_CLASS = 16; - static const DISPATCH_BLOCK_ENFORCE_QOS_CLASS = 32; -} - -typedef kern_return_t = ffi.Int; -typedef Dartkern_return_t = int; -typedef mach_msg_timeout_t = natural_t; -typedef mach_msg_bits_t = ffi.UnsignedInt; -typedef Dartmach_msg_bits_t = int; -typedef mach_msg_size_t = natural_t; -typedef mach_msg_id_t = integer_t; -typedef mach_msg_priority_t = ffi.UnsignedInt; -typedef Dartmach_msg_priority_t = int; -typedef mach_msg_type_name_t = ffi.UnsignedInt; -typedef Dartmach_msg_type_name_t = int; -typedef mach_msg_copy_options_t = ffi.UnsignedInt; -typedef Dartmach_msg_copy_options_t = int; -typedef mach_msg_guard_flags_t = ffi.UnsignedInt; -typedef Dartmach_msg_guard_flags_t = int; -typedef mach_msg_descriptor_type_t = ffi.UnsignedInt; -typedef Dartmach_msg_descriptor_type_t = int; - -final class mach_msg_type_descriptor_t extends ffi.Opaque {} - -final class mach_msg_port_descriptor_t extends ffi.Opaque {} - -final class mach_msg_ool_descriptor32_t extends ffi.Opaque {} - -final class mach_msg_ool_descriptor64_t extends ffi.Opaque {} - -final class mach_msg_ool_descriptor_t extends ffi.Opaque {} - -final class mach_msg_ool_ports_descriptor32_t extends ffi.Opaque {} - -final class mach_msg_ool_ports_descriptor64_t extends ffi.Opaque {} - -final class mach_msg_ool_ports_descriptor_t extends ffi.Opaque {} - -final class mach_msg_guarded_port_descriptor32_t extends ffi.Opaque {} - -final class mach_msg_guarded_port_descriptor64_t extends ffi.Opaque {} - -final class mach_msg_guarded_port_descriptor_t extends ffi.Opaque {} - -final class mach_msg_descriptor_t extends ffi.Opaque {} - -final class mach_msg_body_t extends ffi.Struct { - @mach_msg_size_t() - external int msgh_descriptor_count; -} - -final class mach_msg_header_t extends ffi.Struct { - @mach_msg_bits_t() - external int msgh_bits; - - @mach_msg_size_t() - external int msgh_size; - - @mach_port_t() - external int msgh_remote_port; - - @mach_port_t() - external int msgh_local_port; - - @mach_port_name_t() - external int msgh_voucher_port; - - @mach_msg_id_t() - external int msgh_id; -} - -final class mach_msg_base_t extends ffi.Struct { - external mach_msg_header_t header; - - external mach_msg_body_t body; -} - -typedef mach_msg_trailer_type_t = ffi.UnsignedInt; -typedef Dartmach_msg_trailer_type_t = int; -typedef mach_msg_trailer_size_t = ffi.UnsignedInt; -typedef Dartmach_msg_trailer_size_t = int; -typedef mach_msg_trailer_info_t = ffi.Pointer; - -final class mach_msg_trailer_t extends ffi.Struct { - @mach_msg_trailer_type_t() - external int msgh_trailer_type; - - @mach_msg_trailer_size_t() - external int msgh_trailer_size; -} - -final class mach_msg_seqno_trailer_t extends ffi.Struct { - @mach_msg_trailer_type_t() - external int msgh_trailer_type; - - @mach_msg_trailer_size_t() - external int msgh_trailer_size; - - @mach_port_seqno_t() - external int msgh_seqno; -} - -final class security_token_t extends ffi.Struct { - @ffi.Array.multi([2]) - external ffi.Array val; -} - -final class mach_msg_security_trailer_t extends ffi.Struct { - @mach_msg_trailer_type_t() - external int msgh_trailer_type; - - @mach_msg_trailer_size_t() - external int msgh_trailer_size; - - @mach_port_seqno_t() - external int msgh_seqno; - - external security_token_t msgh_sender; -} - -final class audit_token_t extends ffi.Struct { - @ffi.Array.multi([8]) - external ffi.Array val; -} - -final class mach_msg_audit_trailer_t extends ffi.Struct { - @mach_msg_trailer_type_t() - external int msgh_trailer_type; - - @mach_msg_trailer_size_t() - external int msgh_trailer_size; - - @mach_port_seqno_t() - external int msgh_seqno; - - external security_token_t msgh_sender; - - external audit_token_t msgh_audit; -} - -@ffi.Packed(4) -final class mach_msg_context_trailer_t extends ffi.Struct { - @mach_msg_trailer_type_t() - external int msgh_trailer_type; - - @mach_msg_trailer_size_t() - external int msgh_trailer_size; - - @mach_port_seqno_t() - external int msgh_seqno; - - external security_token_t msgh_sender; - - external audit_token_t msgh_audit; - - @mach_port_context_t() - external int msgh_context; -} - -final class msg_labels_t extends ffi.Struct { - @mach_port_name_t() - external int sender; -} - -typedef mach_msg_filter_id = ffi.Int; -typedef Dartmach_msg_filter_id = int; - -@ffi.Packed(4) -final class mach_msg_mac_trailer_t extends ffi.Struct { - @mach_msg_trailer_type_t() - external int msgh_trailer_type; - - @mach_msg_trailer_size_t() - external int msgh_trailer_size; - - @mach_port_seqno_t() - external int msgh_seqno; - - external security_token_t msgh_sender; - - external audit_token_t msgh_audit; - - @mach_port_context_t() - external int msgh_context; - - @mach_msg_filter_id() - external int msgh_ad; - - external msg_labels_t msgh_labels; -} - -typedef mach_msg_max_trailer_t = mach_msg_mac_trailer_t; -typedef mach_msg_format_0_trailer_t = mach_msg_security_trailer_t; -typedef mach_msg_options_t = integer_t; - -final class mach_msg_empty_send_t extends ffi.Struct { - external mach_msg_header_t header; -} - -final class mach_msg_empty_rcv_t extends ffi.Struct { - external mach_msg_header_t header; - - external mach_msg_trailer_t trailer; -} - -final class mach_msg_empty_t extends ffi.Union { - external mach_msg_empty_send_t send; - - external mach_msg_empty_rcv_t rcv; -} - -typedef mach_msg_type_size_t = natural_t; -typedef mach_msg_type_number_t = natural_t; -typedef mach_msg_option_t = integer_t; -typedef mach_msg_return_t = kern_return_t; -typedef dispatch_source_t = ffi.Pointer; -typedef Dartdispatch_source_t = objc.NSObject; - -final class dispatch_source_type_s extends ffi.Opaque {} - -typedef dispatch_source_type_t = ffi.Pointer; -typedef dispatch_source_mach_send_flags_t = ffi.UnsignedLong; -typedef Dartdispatch_source_mach_send_flags_t = int; -typedef dispatch_source_mach_recv_flags_t = ffi.UnsignedLong; -typedef Dartdispatch_source_mach_recv_flags_t = int; -typedef dispatch_source_memorypressure_flags_t = ffi.UnsignedLong; -typedef Dartdispatch_source_memorypressure_flags_t = int; -typedef dispatch_source_proc_flags_t = ffi.UnsignedLong; -typedef Dartdispatch_source_proc_flags_t = int; -typedef dispatch_source_vnode_flags_t = ffi.UnsignedLong; -typedef Dartdispatch_source_vnode_flags_t = int; -typedef dispatch_source_timer_flags_t = ffi.UnsignedLong; -typedef Dartdispatch_source_timer_flags_t = int; -typedef dispatch_group_t = ffi.Pointer; -typedef Dartdispatch_group_t = objc.NSObject; -typedef dispatch_semaphore_t = ffi.Pointer; -typedef Dartdispatch_semaphore_t = objc.NSObject; -typedef dispatch_once_t = ffi.IntPtr; -typedef Dartdispatch_once_t = int; -typedef dispatch_data_t = ffi.Pointer; -typedef Dartdispatch_data_t = objc.NSObject; - -final class dispatch_data_s extends ffi.Opaque {} - -/// Construction methods for `objc.ObjCBlock, ffi.Size)>`. -abstract final class ObjCBlock_bool_dispatchdatat_ffiSize_ffiVoid_ffiSize { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Bool Function(objc.NSObject, ffi.Size, ffi.Pointer, ffi.Size) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Bool Function( - objc.NSObject, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Bool Function(objc.NSObject, ffi.Size, ffi.Pointer, ffi.Size) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Bool Function( - dispatch_data_t arg0, - ffi.Size arg1, - ffi.Pointer arg2, - ffi.Size arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Bool Function( - objc.NSObject, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Bool Function(objc.NSObject, ffi.Size, ffi.Pointer, ffi.Size) - > - fromFunction( - bool Function(Dartdispatch_data_t, int, ffi.Pointer, int) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Bool Function( - objc.NSObject, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - dispatch_data_t arg0, - int arg1, - ffi.Pointer arg2, - int arg3, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: true, release: true), - arg1, - arg2, - arg3, - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static bool _fnPtrTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - int arg1, - ffi.Pointer arg2, - int arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Bool Function( - dispatch_data_t arg0, - ffi.Size arg1, - ffi.Pointer arg2, - ffi.Size arg3, - ) - > - >() - .asFunction< - bool Function(dispatch_data_t, int, ffi.Pointer, int) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function( - ffi.Pointer, - dispatch_data_t, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - >(_fnPtrTrampoline, false) - .cast(); - static bool _closureTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - int arg1, - ffi.Pointer arg2, - int arg3, - ) => - (objc.getBlockClosure(block) - as bool Function(dispatch_data_t, int, ffi.Pointer, int))( - arg0, - arg1, - arg2, - arg3, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function( - ffi.Pointer, - dispatch_data_t, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - >(_closureTrampoline, false) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, ffi.Size)>`. -extension ObjCBlock_bool_dispatchdatat_ffiSize_ffiVoid_ffiSize$CallExtension - on - objc.ObjCBlock< - ffi.Bool Function( - objc.NSObject, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - > { - bool call( - Dartdispatch_data_t arg0, - int arg1, - ffi.Pointer arg2, - int arg3, - ) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer block, - dispatch_data_t arg0, - ffi.Size arg1, - ffi.Pointer arg2, - ffi.Size arg3, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - dispatch_data_t, - int, - ffi.Pointer, - int, - ) - >()(ref.pointer, arg0.ref.pointer, arg1, arg2, arg3); -} - -typedef dispatch_data_applier_t = ffi.Pointer; -typedef Dartdispatch_data_applier_t = - objc.ObjCBlock< - ffi.Bool Function( - objc.NSObject, - ffi.Size, - ffi.Pointer, - ffi.Size, - ) - >; -typedef dispatch_fd_t = ffi.Int; -typedef Dartdispatch_fd_t = int; - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_dispatchdatat_ffiInt { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(Dartdispatch_data_t, int) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (dispatch_data_t arg0, int arg1) => fn( - objc.NSObject.fromPointer(arg0, retain: true, release: true), - arg1, - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(Dartdispatch_data_t, int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (dispatch_data_t arg0, int arg1) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_18kzm6a(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(Dartdispatch_data_t, int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (dispatch_data_t arg0, int arg1) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1, - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (dispatch_data_t arg0, int arg1) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18kzm6a( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - int arg1, - ) { - (objc.getBlockClosure(block) as void Function(dispatch_data_t, int))( - arg0, - arg1, - ); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, dispatch_data_t, ffi.Int) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - dispatch_data_t arg0, - int arg1, - ) { - try { - (objc.getBlockClosure(block) as void Function(dispatch_data_t, int))( - arg0, - arg1, - ); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - int arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(dispatch_data_t arg0, ffi.Int arg1) - > - >() - .asFunction()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - int arg1, - ) => (objc.getBlockClosure(block) as void Function(dispatch_data_t, int))( - arg0, - arg1, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_dispatchdatat_ffiInt$CallExtension - on objc.ObjCBlock { - void call(Dartdispatch_data_t arg0, int arg1) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - dispatch_data_t arg0, - ffi.Int arg1, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, dispatch_data_t, int) - >()(ref.pointer, arg0.ref.pointer, arg1); -} - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_dispatchdatat_ffiInt$1 { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - fromFunction( - void Function(Dartdispatch_data_t?, int) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (dispatch_data_t arg0, int arg1) => fn( - arg0.address == 0 - ? null - : objc.NSObject.fromPointer(arg0, retain: true, release: true), - arg1, - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(Dartdispatch_data_t?, int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (dispatch_data_t arg0, int arg1) => fn( - arg0.address == 0 - ? null - : objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_18kzm6a(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(Dartdispatch_data_t?, int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (dispatch_data_t arg0, int arg1) => fn( - arg0.address == 0 - ? null - : objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1, - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (dispatch_data_t arg0, int arg1) => fn( - arg0.address == 0 - ? null - : objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18kzm6a( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - int arg1, - ) { - (objc.getBlockClosure(block) as void Function(dispatch_data_t, int))( - arg0, - arg1, - ); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, dispatch_data_t, ffi.Int) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - dispatch_data_t arg0, - int arg1, - ) { - try { - (objc.getBlockClosure(block) as void Function(dispatch_data_t, int))( - arg0, - arg1, - ); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - int arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(dispatch_data_t arg0, ffi.Int arg1) - > - >() - .asFunction()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - int arg1, - ) => (objc.getBlockClosure(block) as void Function(dispatch_data_t, int))( - arg0, - arg1, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - ffi.Int, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_dispatchdatat_ffiInt$1$CallExtension - on objc.ObjCBlock { - void call(Dartdispatch_data_t? arg0, int arg1) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - dispatch_data_t arg0, - ffi.Int arg1, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, dispatch_data_t, int) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr, arg1); -} - -typedef dispatch_io_t = ffi.Pointer; -typedef Dartdispatch_io_t = objc.NSObject; -typedef dispatch_io_type_t = ffi.UnsignedLong; -typedef Dartdispatch_io_type_t = int; - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_ffiInt { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer> ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (int arg0) => fn(arg0), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_9o8504(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_9o8504( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - int arg0, - ) { - (objc.getBlockClosure(block) as void Function(int))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Int) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Int) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - int arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(int))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - int arg0, - ) => block.ref.target - .cast>() - .asFunction()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Int) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - int arg0, - ) => (objc.getBlockClosure(block) as void Function(int))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Int) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_ffiInt$CallExtension - on objc.ObjCBlock { - void call(int arg0) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Int arg0, - ) - > - >() - .asFunction, int)>()( - ref.pointer, - arg0, - ); -} - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_bool_dispatchdatat_ffiInt { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Bool arg0, dispatch_data_t arg1, ffi.Int arg2) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - fromFunction( - void Function(bool, Dartdispatch_data_t?, int) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (bool arg0, dispatch_data_t arg1, int arg2) => fn( - arg0, - arg1.address == 0 - ? null - : objc.NSObject.fromPointer(arg1, retain: true, release: true), - arg2, - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - listener( - void Function(bool, Dartdispatch_data_t?, int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (bool arg0, dispatch_data_t arg1, int arg2) => fn( - arg0, - arg1.address == 0 - ? null - : objc.NSObject.fromPointer(arg1, retain: false, release: true), - arg2, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_og5b6y(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock - blocking( - void Function(bool, Dartdispatch_data_t?, int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (bool arg0, dispatch_data_t arg1, int arg2) => fn( - arg0, - arg1.address == 0 - ? null - : objc.NSObject.fromPointer(arg1, retain: false, release: true), - arg2, - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (bool arg0, dispatch_data_t arg1, int arg2) => fn( - arg0, - arg1.address == 0 - ? null - : objc.NSObject.fromPointer(arg1, retain: false, release: true), - arg2, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_og5b6y( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - bool arg0, - dispatch_data_t arg1, - int arg2, - ) { - (objc.getBlockClosure(block) as void Function(bool, dispatch_data_t, int))( - arg0, - arg1, - arg2, - ); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Bool, - dispatch_data_t, - ffi.Int, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Bool, - dispatch_data_t, - ffi.Int, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - bool arg0, - dispatch_data_t arg1, - int arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function(bool, dispatch_data_t, int))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - dispatch_data_t, - ffi.Int, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - dispatch_data_t, - ffi.Int, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - dispatch_data_t, - ffi.Int, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - dispatch_data_t, - ffi.Int, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - bool arg0, - dispatch_data_t arg1, - int arg2, - ) => - block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Bool arg0, - dispatch_data_t arg1, - ffi.Int arg2, - ) - > - >() - .asFunction()( - arg0, - arg1, - arg2, - ); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Bool, - dispatch_data_t, - ffi.Int, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - bool arg0, - dispatch_data_t arg1, - int arg2, - ) => - (objc.getBlockClosure(block) - as void Function(bool, dispatch_data_t, int))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Bool, - dispatch_data_t, - ffi.Int, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_bool_dispatchdatat_ffiInt$CallExtension - on objc.ObjCBlock { - void call(bool arg0, Dartdispatch_data_t? arg1, int arg2) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Bool arg0, - dispatch_data_t arg1, - ffi.Int arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - bool, - dispatch_data_t, - int, - ) - >()(ref.pointer, arg0, arg1?.ref.pointer ?? ffi.nullptr, arg2); -} - -typedef dispatch_io_handler_t = ffi.Pointer; -typedef Dartdispatch_io_handler_t = - objc.ObjCBlock; -typedef dispatch_io_close_flags_t = ffi.UnsignedLong; -typedef Dartdispatch_io_close_flags_t = int; -typedef dispatch_io_interval_flags_t = ffi.UnsignedLong; -typedef Dartdispatch_io_interval_flags_t = int; -typedef dispatch_workloop_t = ffi.Pointer; -typedef Dartdispatch_workloop_t = objc.NSObject; - -final class CFStreamError extends ffi.Struct { - @CFIndex() - external int domain; - - @SInt32() - external int error; -} - -typedef CFStreamPropertyKey = CFStringRef; - -enum CFStreamStatus { - kCFStreamStatusNotOpen(0), - kCFStreamStatusOpening(1), - kCFStreamStatusOpen(2), - kCFStreamStatusReading(3), - kCFStreamStatusWriting(4), - kCFStreamStatusAtEnd(5), - kCFStreamStatusClosed(6), - kCFStreamStatusError(7); - - final int value; - const CFStreamStatus(this.value); - - static CFStreamStatus fromValue(int value) => switch (value) { - 0 => kCFStreamStatusNotOpen, - 1 => kCFStreamStatusOpening, - 2 => kCFStreamStatusOpen, - 3 => kCFStreamStatusReading, - 4 => kCFStreamStatusWriting, - 5 => kCFStreamStatusAtEnd, - 6 => kCFStreamStatusClosed, - 7 => kCFStreamStatusError, - _ => throw ArgumentError('Unknown value for CFStreamStatus: $value'), - }; -} - -sealed class CFStreamEventType { - static const kCFStreamEventNone = 0; - static const kCFStreamEventOpenCompleted = 1; - static const kCFStreamEventHasBytesAvailable = 2; - static const kCFStreamEventCanAcceptBytes = 4; - static const kCFStreamEventErrorOccurred = 8; - static const kCFStreamEventEndEncountered = 16; -} - -final class CFStreamClientContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; -} - -final class __CFReadStream extends ffi.Opaque {} - -typedef CFReadStreamRef = ffi.Pointer<__CFReadStream>; - -final class __CFWriteStream extends ffi.Opaque {} - -typedef CFWriteStreamRef = ffi.Pointer<__CFWriteStream>; -typedef CFReadStreamClientCallBackFunction = - ffi.Void Function( - CFReadStreamRef stream, - CFOptionFlags type, - ffi.Pointer clientCallBackInfo, - ); -typedef DartCFReadStreamClientCallBackFunction = - void Function( - CFReadStreamRef stream, - DartCFOptionFlags type, - ffi.Pointer clientCallBackInfo, - ); -typedef CFReadStreamClientCallBack = - ffi.Pointer>; -typedef CFWriteStreamClientCallBackFunction = - ffi.Void Function( - CFWriteStreamRef stream, - CFOptionFlags type, - ffi.Pointer clientCallBackInfo, - ); -typedef DartCFWriteStreamClientCallBackFunction = - void Function( - CFWriteStreamRef stream, - DartCFOptionFlags type, - ffi.Pointer clientCallBackInfo, - ); -typedef CFWriteStreamClientCallBack = - ffi.Pointer>; - -enum CFPropertyListFormat { - kCFPropertyListOpenStepFormat(1), - kCFPropertyListXMLFormat_v1_0(100), - kCFPropertyListBinaryFormat_v1_0(200); - - final int value; - const CFPropertyListFormat(this.value); - - static CFPropertyListFormat fromValue(int value) => switch (value) { - 1 => kCFPropertyListOpenStepFormat, - 100 => kCFPropertyListXMLFormat_v1_0, - 200 => kCFPropertyListBinaryFormat_v1_0, - _ => throw ArgumentError('Unknown value for CFPropertyListFormat: $value'), - }; -} - -typedef CFSetRetainCallBackFunction = - ffi.Pointer Function( - CFAllocatorRef allocator, - ffi.Pointer value, - ); -typedef CFSetRetainCallBack = - ffi.Pointer>; -typedef CFSetReleaseCallBackFunction = - ffi.Void Function(CFAllocatorRef allocator, ffi.Pointer value); -typedef DartCFSetReleaseCallBackFunction = - void Function(CFAllocatorRef allocator, ffi.Pointer value); -typedef CFSetReleaseCallBack = - ffi.Pointer>; -typedef CFSetCopyDescriptionCallBackFunction = - CFStringRef Function(ffi.Pointer value); -typedef CFSetCopyDescriptionCallBack = - ffi.Pointer>; -typedef CFSetEqualCallBackFunction = - Boolean Function( - ffi.Pointer value1, - ffi.Pointer value2, - ); -typedef DartCFSetEqualCallBackFunction = - DartBoolean Function( - ffi.Pointer value1, - ffi.Pointer value2, - ); -typedef CFSetEqualCallBack = - ffi.Pointer>; -typedef CFSetHashCallBackFunction = - CFHashCode Function(ffi.Pointer value); -typedef DartCFSetHashCallBackFunction = - DartCFHashCode Function(ffi.Pointer value); -typedef CFSetHashCallBack = - ffi.Pointer>; - -final class CFSetCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFSetRetainCallBack retain; - - external CFSetReleaseCallBack release; - - external CFSetCopyDescriptionCallBack copyDescription; - - external CFSetEqualCallBack equal; - - external CFSetHashCallBack hash; -} - -typedef CFSetApplierFunctionFunction = - ffi.Void Function( - ffi.Pointer value, - ffi.Pointer context, - ); -typedef DartCFSetApplierFunctionFunction = - void Function(ffi.Pointer value, ffi.Pointer context); -typedef CFSetApplierFunction = - ffi.Pointer>; - -final class __CFSet extends ffi.Opaque {} - -typedef CFSetRef = ffi.Pointer<__CFSet>; -typedef CFMutableSetRef = ffi.Pointer<__CFSet>; -typedef CFTreeRetainCallBackFunction = - ffi.Pointer Function(ffi.Pointer info); -typedef CFTreeRetainCallBack = - ffi.Pointer>; -typedef CFTreeReleaseCallBackFunction = - ffi.Void Function(ffi.Pointer info); -typedef DartCFTreeReleaseCallBackFunction = - void Function(ffi.Pointer info); -typedef CFTreeReleaseCallBack = - ffi.Pointer>; -typedef CFTreeCopyDescriptionCallBackFunction = - CFStringRef Function(ffi.Pointer info); -typedef CFTreeCopyDescriptionCallBack = - ffi.Pointer>; - -final class CFTreeContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external CFTreeRetainCallBack retain; - - external CFTreeReleaseCallBack release; - - external CFTreeCopyDescriptionCallBack copyDescription; -} - -typedef CFTreeApplierFunctionFunction = - ffi.Void Function( - ffi.Pointer value, - ffi.Pointer context, - ); -typedef DartCFTreeApplierFunctionFunction = - void Function(ffi.Pointer value, ffi.Pointer context); -typedef CFTreeApplierFunction = - ffi.Pointer>; - -final class __CFTree extends ffi.Opaque {} - -typedef CFTreeRef = ffi.Pointer<__CFTree>; - -final class __CFUUID extends ffi.Opaque {} - -typedef CFUUIDRef = ffi.Pointer<__CFUUID>; - -final class CFUUIDBytes extends ffi.Struct { - @UInt8() - external int byte0; - - @UInt8() - external int byte1; - - @UInt8() - external int byte2; - - @UInt8() - external int byte3; - - @UInt8() - external int byte4; - - @UInt8() - external int byte5; - - @UInt8() - external int byte6; - - @UInt8() - external int byte7; - - @UInt8() - external int byte8; - - @UInt8() - external int byte9; - - @UInt8() - external int byte10; - - @UInt8() - external int byte11; - - @UInt8() - external int byte12; - - @UInt8() - external int byte13; - - @UInt8() - external int byte14; - - @UInt8() - external int byte15; -} - -typedef cpu_type_t = integer_t; -typedef cpu_subtype_t = integer_t; -typedef cpu_threadtype_t = integer_t; - -final class __CFBundle extends ffi.Opaque {} - -typedef CFBundleRef = ffi.Pointer<__CFBundle>; -typedef CFPlugInRef = ffi.Pointer<__CFBundle>; -typedef CFBundleRefNum = ffi.Int; -typedef DartCFBundleRefNum = int; - -final class __CFMessagePort extends ffi.Opaque {} - -typedef CFMessagePortRef = ffi.Pointer<__CFMessagePort>; - -final class CFMessagePortContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; -} - -typedef CFMessagePortCallBackFunction = - CFDataRef Function( - CFMessagePortRef local, - SInt32 msgid, - CFDataRef data, - ffi.Pointer info, - ); -typedef DartCFMessagePortCallBackFunction = - CFDataRef Function( - CFMessagePortRef local, - DartSInt32 msgid, - CFDataRef data, - ffi.Pointer info, - ); -typedef CFMessagePortCallBack = - ffi.Pointer>; -typedef CFMessagePortInvalidationCallBackFunction = - ffi.Void Function(CFMessagePortRef ms, ffi.Pointer info); -typedef DartCFMessagePortInvalidationCallBackFunction = - void Function(CFMessagePortRef ms, ffi.Pointer info); -typedef CFMessagePortInvalidationCallBack = - ffi.Pointer>; -typedef CFPlugInDynamicRegisterFunctionFunction = - ffi.Void Function(CFPlugInRef plugIn); -typedef DartCFPlugInDynamicRegisterFunctionFunction = - void Function(CFPlugInRef plugIn); -typedef CFPlugInDynamicRegisterFunction = - ffi.Pointer>; -typedef CFPlugInUnloadFunctionFunction = ffi.Void Function(CFPlugInRef plugIn); -typedef DartCFPlugInUnloadFunctionFunction = void Function(CFPlugInRef plugIn); -typedef CFPlugInUnloadFunction = - ffi.Pointer>; -typedef CFPlugInFactoryFunctionFunction = - ffi.Pointer Function( - CFAllocatorRef allocator, - CFUUIDRef typeUUID, - ); -typedef CFPlugInFactoryFunction = - ffi.Pointer>; - -final class __CFPlugInInstance extends ffi.Opaque {} - -typedef CFPlugInInstanceRef = ffi.Pointer<__CFPlugInInstance>; -typedef CFPlugInInstanceGetInterfaceFunctionFunction = - Boolean Function( - CFPlugInInstanceRef instance, - CFStringRef interfaceName, - ffi.Pointer> ftbl, - ); -typedef DartCFPlugInInstanceGetInterfaceFunctionFunction = - DartBoolean Function( - CFPlugInInstanceRef instance, - CFStringRef interfaceName, - ffi.Pointer> ftbl, - ); -typedef CFPlugInInstanceGetInterfaceFunction = - ffi.Pointer< - ffi.NativeFunction - >; -typedef CFPlugInInstanceDeallocateInstanceDataFunctionFunction = - ffi.Void Function(ffi.Pointer instanceData); -typedef DartCFPlugInInstanceDeallocateInstanceDataFunctionFunction = - void Function(ffi.Pointer instanceData); -typedef CFPlugInInstanceDeallocateInstanceDataFunction = - ffi.Pointer< - ffi.NativeFunction - >; - -final class __CFMachPort extends ffi.Opaque {} - -typedef CFMachPortRef = ffi.Pointer<__CFMachPort>; - -final class CFMachPortContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; -} - -typedef CFMachPortCallBackFunction = - ffi.Void Function( - CFMachPortRef port, - ffi.Pointer msg, - CFIndex size, - ffi.Pointer info, - ); -typedef DartCFMachPortCallBackFunction = - void Function( - CFMachPortRef port, - ffi.Pointer msg, - DartCFIndex size, - ffi.Pointer info, - ); -typedef CFMachPortCallBack = - ffi.Pointer>; -typedef CFMachPortInvalidationCallBackFunction = - ffi.Void Function(CFMachPortRef port, ffi.Pointer info); -typedef DartCFMachPortInvalidationCallBackFunction = - void Function(CFMachPortRef port, ffi.Pointer info); -typedef CFMachPortInvalidationCallBack = - ffi.Pointer>; - -final class __CFAttributedString extends ffi.Opaque {} - -typedef CFAttributedStringRef = ffi.Pointer<__CFAttributedString>; -typedef CFMutableAttributedStringRef = ffi.Pointer<__CFAttributedString>; - -final class __CFURLEnumerator extends ffi.Opaque {} - -typedef CFURLEnumeratorRef = ffi.Pointer<__CFURLEnumerator>; - -sealed class CFURLEnumeratorOptions { - static const kCFURLEnumeratorDefaultBehavior = 0; - static const kCFURLEnumeratorDescendRecursively = 1; - static const kCFURLEnumeratorSkipInvisibles = 2; - static const kCFURLEnumeratorGenerateFileReferenceURLs = 4; - static const kCFURLEnumeratorSkipPackageContents = 8; - static const kCFURLEnumeratorIncludeDirectoriesPreOrder = 16; - static const kCFURLEnumeratorIncludeDirectoriesPostOrder = 32; - static const kCFURLEnumeratorGenerateRelativePathURLs = 64; -} - -enum CFURLEnumeratorResult { - kCFURLEnumeratorSuccess(1), - kCFURLEnumeratorEnd(2), - kCFURLEnumeratorError(3), - kCFURLEnumeratorDirectoryPostOrderSuccess(4); - - final int value; - const CFURLEnumeratorResult(this.value); - - static CFURLEnumeratorResult fromValue(int value) => switch (value) { - 1 => kCFURLEnumeratorSuccess, - 2 => kCFURLEnumeratorEnd, - 3 => kCFURLEnumeratorError, - 4 => kCFURLEnumeratorDirectoryPostOrderSuccess, - _ => throw ArgumentError('Unknown value for CFURLEnumeratorResult: $value'), - }; -} - -final class guid_t extends ffi.Union { - @ffi.Array.multi([16]) - external ffi.Array g_guid; - - @ffi.Array.multi([4]) - external ffi.Array g_guid_asint; -} - -@ffi.Packed(1) -final class ntsid_t extends ffi.Struct { - @u_int8_t() - external int sid_kind; - - @u_int8_t() - external int sid_authcount; - - @ffi.Array.multi([6]) - external ffi.Array sid_authority; - - @ffi.Array.multi([16]) - external ffi.Array sid_authorities; -} - -final class kauth_identity_extlookup extends ffi.Struct { - @u_int32_t() - external int el_seqno; - - @u_int32_t() - external int el_result; - - @u_int32_t() - external int el_flags; - - @__darwin_pid_t() - external int el_info_pid; - - @u_int64_t() - external int el_extend; - - @u_int32_t() - external int el_info_reserved_1; - - @uid_t() - external int el_uid; - - external guid_t el_uguid; - - @u_int32_t() - external int el_uguid_valid; - - external ntsid_t el_usid; - - @u_int32_t() - external int el_usid_valid; - - @gid_t() - external int el_gid; - - external guid_t el_gguid; - - @u_int32_t() - external int el_gguid_valid; - - external ntsid_t el_gsid; - - @u_int32_t() - external int el_gsid_valid; - - @u_int32_t() - external int el_member_valid; - - @u_int32_t() - external int el_sup_grp_cnt; - - @ffi.Array.multi([16]) - external ffi.Array el_sup_groups; -} - -final class kauth_cache_sizes extends ffi.Struct { - @u_int32_t() - external int kcs_group_size; - - @u_int32_t() - external int kcs_id_size; -} - -typedef kauth_ace_rights_t = u_int32_t; - -final class kauth_ace extends ffi.Struct { - external guid_t ace_applicable; - - @u_int32_t() - external int ace_flags; - - @kauth_ace_rights_t() - external int ace_rights; -} - -typedef kauth_ace_t = ffi.Pointer; - -final class kauth_acl extends ffi.Struct { - @u_int32_t() - external int acl_entrycount; - - @u_int32_t() - external int acl_flags; - - @ffi.Array.multi([1]) - external ffi.Array acl_ace; -} - -typedef kauth_acl_t = ffi.Pointer; - -final class kauth_filesec extends ffi.Struct { - @u_int32_t() - external int fsec_magic; - - external guid_t fsec_owner; - - external guid_t fsec_group; - - external kauth_acl fsec_acl; -} - -typedef kauth_filesec_t = ffi.Pointer; - -enum acl_perm_t { - ACL_READ_DATA(2), - ACL_WRITE_DATA(4), - ACL_EXECUTE(8), - ACL_DELETE(16), - ACL_APPEND_DATA(32), - ACL_DELETE_CHILD(64), - ACL_READ_ATTRIBUTES(128), - ACL_WRITE_ATTRIBUTES(256), - ACL_READ_EXTATTRIBUTES(512), - ACL_WRITE_EXTATTRIBUTES(1024), - ACL_READ_SECURITY(2048), - ACL_WRITE_SECURITY(4096), - ACL_CHANGE_OWNER(8192), - ACL_SYNCHRONIZE(1048576); - - static const ACL_LIST_DIRECTORY = ACL_READ_DATA; - static const ACL_ADD_FILE = ACL_WRITE_DATA; - static const ACL_SEARCH = ACL_EXECUTE; - static const ACL_ADD_SUBDIRECTORY = ACL_APPEND_DATA; - - final int value; - const acl_perm_t(this.value); - - static acl_perm_t fromValue(int value) => switch (value) { - 2 => ACL_READ_DATA, - 4 => ACL_WRITE_DATA, - 8 => ACL_EXECUTE, - 16 => ACL_DELETE, - 32 => ACL_APPEND_DATA, - 64 => ACL_DELETE_CHILD, - 128 => ACL_READ_ATTRIBUTES, - 256 => ACL_WRITE_ATTRIBUTES, - 512 => ACL_READ_EXTATTRIBUTES, - 1024 => ACL_WRITE_EXTATTRIBUTES, - 2048 => ACL_READ_SECURITY, - 4096 => ACL_WRITE_SECURITY, - 8192 => ACL_CHANGE_OWNER, - 1048576 => ACL_SYNCHRONIZE, - _ => throw ArgumentError('Unknown value for acl_perm_t: $value'), - }; - - @override - String toString() { - if (this == ACL_READ_DATA) - return "acl_perm_t.ACL_READ_DATA, acl_perm_t.ACL_LIST_DIRECTORY"; - if (this == ACL_WRITE_DATA) - return "acl_perm_t.ACL_WRITE_DATA, acl_perm_t.ACL_ADD_FILE"; - if (this == ACL_EXECUTE) - return "acl_perm_t.ACL_EXECUTE, acl_perm_t.ACL_SEARCH"; - if (this == ACL_APPEND_DATA) - return "acl_perm_t.ACL_APPEND_DATA, acl_perm_t.ACL_ADD_SUBDIRECTORY"; - return super.toString(); - } -} - -enum acl_tag_t { - ACL_UNDEFINED_TAG(0), - ACL_EXTENDED_ALLOW(1), - ACL_EXTENDED_DENY(2); - - final int value; - const acl_tag_t(this.value); - - static acl_tag_t fromValue(int value) => switch (value) { - 0 => ACL_UNDEFINED_TAG, - 1 => ACL_EXTENDED_ALLOW, - 2 => ACL_EXTENDED_DENY, - _ => throw ArgumentError('Unknown value for acl_tag_t: $value'), - }; -} - -enum acl_type_t { - ACL_TYPE_EXTENDED(256), - ACL_TYPE_ACCESS(0), - ACL_TYPE_DEFAULT(1), - ACL_TYPE_AFS(2), - ACL_TYPE_CODA(3), - ACL_TYPE_NTFS(4), - ACL_TYPE_NWFS(5); - - final int value; - const acl_type_t(this.value); - - static acl_type_t fromValue(int value) => switch (value) { - 256 => ACL_TYPE_EXTENDED, - 0 => ACL_TYPE_ACCESS, - 1 => ACL_TYPE_DEFAULT, - 2 => ACL_TYPE_AFS, - 3 => ACL_TYPE_CODA, - 4 => ACL_TYPE_NTFS, - 5 => ACL_TYPE_NWFS, - _ => throw ArgumentError('Unknown value for acl_type_t: $value'), - }; -} - -enum acl_flag_t { - ACL_FLAG_DEFER_INHERIT(1), - ACL_FLAG_NO_INHERIT(131072), - ACL_ENTRY_INHERITED(16), - ACL_ENTRY_FILE_INHERIT(32), - ACL_ENTRY_DIRECTORY_INHERIT(64), - ACL_ENTRY_LIMIT_INHERIT(128), - ACL_ENTRY_ONLY_INHERIT(256); - - final int value; - const acl_flag_t(this.value); - - static acl_flag_t fromValue(int value) => switch (value) { - 1 => ACL_FLAG_DEFER_INHERIT, - 131072 => ACL_FLAG_NO_INHERIT, - 16 => ACL_ENTRY_INHERITED, - 32 => ACL_ENTRY_FILE_INHERIT, - 64 => ACL_ENTRY_DIRECTORY_INHERIT, - 128 => ACL_ENTRY_LIMIT_INHERIT, - 256 => ACL_ENTRY_ONLY_INHERIT, - _ => throw ArgumentError('Unknown value for acl_flag_t: $value'), - }; -} - -final class _acl extends ffi.Opaque {} - -final class _acl_entry extends ffi.Opaque {} - -final class _acl_permset extends ffi.Opaque {} - -final class _acl_flagset extends ffi.Opaque {} - -typedef acl_t = ffi.Pointer<_acl>; -typedef acl_entry_t = ffi.Pointer<_acl_entry>; -typedef acl_permset_t = ffi.Pointer<_acl_permset>; -typedef acl_flagset_t = ffi.Pointer<_acl_flagset>; -typedef acl_permset_mask_t = u_int64_t; - -final class __CFFileSecurity extends ffi.Opaque {} - -typedef CFFileSecurityRef = ffi.Pointer<__CFFileSecurity>; - -sealed class CFFileSecurityClearOptions { - static const kCFFileSecurityClearOwner = 1; - static const kCFFileSecurityClearGroup = 2; - static const kCFFileSecurityClearMode = 4; - static const kCFFileSecurityClearOwnerUUID = 8; - static const kCFFileSecurityClearGroupUUID = 16; - static const kCFFileSecurityClearAccessControlList = 32; -} - -final class __CFStringTokenizer extends ffi.Opaque {} - -typedef CFStringTokenizerRef = ffi.Pointer<__CFStringTokenizer>; - -sealed class CFStringTokenizerTokenType { - static const kCFStringTokenizerTokenNone = 0; - static const kCFStringTokenizerTokenNormal = 1; - static const kCFStringTokenizerTokenHasSubTokensMask = 2; - static const kCFStringTokenizerTokenHasDerivedSubTokensMask = 4; - static const kCFStringTokenizerTokenHasHasNumbersMask = 8; - static const kCFStringTokenizerTokenHasNonLettersMask = 16; - static const kCFStringTokenizerTokenIsCJWordMask = 32; -} - -typedef CFFileDescriptorNativeDescriptor = ffi.Int; -typedef DartCFFileDescriptorNativeDescriptor = int; - -final class __CFFileDescriptor extends ffi.Opaque {} - -typedef CFFileDescriptorRef = ffi.Pointer<__CFFileDescriptor>; -typedef CFFileDescriptorCallBackFunction = - ffi.Void Function( - CFFileDescriptorRef f, - CFOptionFlags callBackTypes, - ffi.Pointer info, - ); -typedef DartCFFileDescriptorCallBackFunction = - void Function( - CFFileDescriptorRef f, - DartCFOptionFlags callBackTypes, - ffi.Pointer info, - ); -typedef CFFileDescriptorCallBack = - ffi.Pointer>; - -final class CFFileDescriptorContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer info) - > - > - retain; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - release; - - external ffi.Pointer< - ffi.NativeFunction info)> - > - copyDescription; -} - -final class __CFUserNotification extends ffi.Opaque {} - -typedef CFUserNotificationRef = ffi.Pointer<__CFUserNotification>; -typedef CFUserNotificationCallBackFunction = - ffi.Void Function( - CFUserNotificationRef userNotification, - CFOptionFlags responseFlags, - ); -typedef DartCFUserNotificationCallBackFunction = - void Function( - CFUserNotificationRef userNotification, - DartCFOptionFlags responseFlags, - ); -typedef CFUserNotificationCallBack = - ffi.Pointer>; - -final class __CFXMLNode extends ffi.Opaque {} - -typedef CFXMLNodeRef = ffi.Pointer<__CFXMLNode>; -typedef CFXMLTreeRef = CFTreeRef; - -enum CFXMLNodeTypeCode { - kCFXMLNodeTypeDocument(1), - kCFXMLNodeTypeElement(2), - kCFXMLNodeTypeAttribute(3), - kCFXMLNodeTypeProcessingInstruction(4), - kCFXMLNodeTypeComment(5), - kCFXMLNodeTypeText(6), - kCFXMLNodeTypeCDATASection(7), - kCFXMLNodeTypeDocumentFragment(8), - kCFXMLNodeTypeEntity(9), - kCFXMLNodeTypeEntityReference(10), - kCFXMLNodeTypeDocumentType(11), - kCFXMLNodeTypeWhitespace(12), - kCFXMLNodeTypeNotation(13), - kCFXMLNodeTypeElementTypeDeclaration(14), - kCFXMLNodeTypeAttributeListDeclaration(15); - - final int value; - const CFXMLNodeTypeCode(this.value); - - static CFXMLNodeTypeCode fromValue(int value) => switch (value) { - 1 => kCFXMLNodeTypeDocument, - 2 => kCFXMLNodeTypeElement, - 3 => kCFXMLNodeTypeAttribute, - 4 => kCFXMLNodeTypeProcessingInstruction, - 5 => kCFXMLNodeTypeComment, - 6 => kCFXMLNodeTypeText, - 7 => kCFXMLNodeTypeCDATASection, - 8 => kCFXMLNodeTypeDocumentFragment, - 9 => kCFXMLNodeTypeEntity, - 10 => kCFXMLNodeTypeEntityReference, - 11 => kCFXMLNodeTypeDocumentType, - 12 => kCFXMLNodeTypeWhitespace, - 13 => kCFXMLNodeTypeNotation, - 14 => kCFXMLNodeTypeElementTypeDeclaration, - 15 => kCFXMLNodeTypeAttributeListDeclaration, - _ => throw ArgumentError('Unknown value for CFXMLNodeTypeCode: $value'), - }; -} - -final class CFXMLElementInfo extends ffi.Struct { - external CFDictionaryRef attributes; - - external CFArrayRef attributeOrder; - - @Boolean() - external int isEmpty; - - @ffi.Array.multi([3]) - external ffi.Array _reserved; -} - -final class CFXMLProcessingInstructionInfo extends ffi.Struct { - external CFStringRef dataString; -} - -final class CFXMLDocumentInfo extends ffi.Struct { - external CFURLRef sourceURL; - - @CFStringEncoding() - external int encoding; -} - -final class CFXMLExternalID extends ffi.Struct { - external CFURLRef systemID; - - external CFStringRef publicID; -} - -final class CFXMLDocumentTypeInfo extends ffi.Struct { - external CFXMLExternalID externalID; -} - -final class CFXMLNotationInfo extends ffi.Struct { - external CFXMLExternalID externalID; -} - -final class CFXMLElementTypeDeclarationInfo extends ffi.Struct { - external CFStringRef contentDescription; -} - -final class CFXMLAttributeDeclarationInfo extends ffi.Struct { - external CFStringRef attributeName; - - external CFStringRef typeString; - - external CFStringRef defaultString; -} - -final class CFXMLAttributeListDeclarationInfo extends ffi.Struct { - @CFIndex() - external int numberOfAttributes; - - external ffi.Pointer attributes; -} - -enum CFXMLEntityTypeCode { - kCFXMLEntityTypeParameter(0), - kCFXMLEntityTypeParsedInternal(1), - kCFXMLEntityTypeParsedExternal(2), - kCFXMLEntityTypeUnparsed(3), - kCFXMLEntityTypeCharacter(4); - - final int value; - const CFXMLEntityTypeCode(this.value); - - static CFXMLEntityTypeCode fromValue(int value) => switch (value) { - 0 => kCFXMLEntityTypeParameter, - 1 => kCFXMLEntityTypeParsedInternal, - 2 => kCFXMLEntityTypeParsedExternal, - 3 => kCFXMLEntityTypeUnparsed, - 4 => kCFXMLEntityTypeCharacter, - _ => throw ArgumentError('Unknown value for CFXMLEntityTypeCode: $value'), - }; -} - -final class CFXMLEntityInfo extends ffi.Struct { - @CFIndex() - external int entityTypeAsInt; - - CFXMLEntityTypeCode get entityType => - CFXMLEntityTypeCode.fromValue(entityTypeAsInt); - - external CFStringRef replacementText; - - external CFXMLExternalID entityID; - - external CFStringRef notationName; -} - -final class CFXMLEntityReferenceInfo extends ffi.Struct { - @CFIndex() - external int entityTypeAsInt; - - CFXMLEntityTypeCode get entityType => - CFXMLEntityTypeCode.fromValue(entityTypeAsInt); -} - -final class __CFXMLParser extends ffi.Opaque {} - -typedef CFXMLParserRef = ffi.Pointer<__CFXMLParser>; - -sealed class CFXMLParserStatusCode { - static const kCFXMLStatusParseNotBegun = -2; - static const kCFXMLStatusParseInProgress = -1; - static const kCFXMLStatusParseSuccessful = 0; - static const kCFXMLErrorUnexpectedEOF = 1; - static const kCFXMLErrorUnknownEncoding = 2; - static const kCFXMLErrorEncodingConversionFailure = 3; - static const kCFXMLErrorMalformedProcessingInstruction = 4; - static const kCFXMLErrorMalformedDTD = 5; - static const kCFXMLErrorMalformedName = 6; - static const kCFXMLErrorMalformedCDSect = 7; - static const kCFXMLErrorMalformedCloseTag = 8; - static const kCFXMLErrorMalformedStartTag = 9; - static const kCFXMLErrorMalformedDocument = 10; - static const kCFXMLErrorElementlessDocument = 11; - static const kCFXMLErrorMalformedComment = 12; - static const kCFXMLErrorMalformedCharacterReference = 13; - static const kCFXMLErrorMalformedParsedCharacterData = 14; - static const kCFXMLErrorNoData = 15; -} - -typedef CFXMLParserCreateXMLStructureCallBackFunction = - ffi.Pointer Function( - CFXMLParserRef parser, - CFXMLNodeRef nodeDesc, - ffi.Pointer info, - ); -typedef CFXMLParserCreateXMLStructureCallBack = - ffi.Pointer< - ffi.NativeFunction - >; -typedef CFXMLParserAddChildCallBackFunction = - ffi.Void Function( - CFXMLParserRef parser, - ffi.Pointer parent, - ffi.Pointer child, - ffi.Pointer info, - ); -typedef DartCFXMLParserAddChildCallBackFunction = - void Function( - CFXMLParserRef parser, - ffi.Pointer parent, - ffi.Pointer child, - ffi.Pointer info, - ); -typedef CFXMLParserAddChildCallBack = - ffi.Pointer>; -typedef CFXMLParserEndXMLStructureCallBackFunction = - ffi.Void Function( - CFXMLParserRef parser, - ffi.Pointer xmlType, - ffi.Pointer info, - ); -typedef DartCFXMLParserEndXMLStructureCallBackFunction = - void Function( - CFXMLParserRef parser, - ffi.Pointer xmlType, - ffi.Pointer info, - ); -typedef CFXMLParserEndXMLStructureCallBack = - ffi.Pointer>; -typedef CFXMLParserResolveExternalEntityCallBackFunction = - CFDataRef Function( - CFXMLParserRef parser, - ffi.Pointer extID, - ffi.Pointer info, - ); -typedef CFXMLParserResolveExternalEntityCallBack = - ffi.Pointer< - ffi.NativeFunction - >; -typedef CFXMLParserHandleErrorCallBackFunction = - Boolean Function( - CFXMLParserRef parser, - CFIndex error, - ffi.Pointer info, - ); -typedef DartCFXMLParserHandleErrorCallBackFunction = - DartBoolean Function( - CFXMLParserRef parser, - DartCFIndex error, - ffi.Pointer info, - ); -typedef CFXMLParserHandleErrorCallBack = - ffi.Pointer>; - -final class CFXMLParserCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFXMLParserCreateXMLStructureCallBack createXMLStructure; - - external CFXMLParserAddChildCallBack addChild; - - external CFXMLParserEndXMLStructureCallBack endXMLStructure; - - external CFXMLParserResolveExternalEntityCallBack resolveExternalEntity; - - external CFXMLParserHandleErrorCallBack handleError; -} - -typedef CFXMLParserRetainCallBackFunction = - ffi.Pointer Function(ffi.Pointer info); -typedef CFXMLParserRetainCallBack = - ffi.Pointer>; -typedef CFXMLParserReleaseCallBackFunction = - ffi.Void Function(ffi.Pointer info); -typedef DartCFXMLParserReleaseCallBackFunction = - void Function(ffi.Pointer info); -typedef CFXMLParserReleaseCallBack = - ffi.Pointer>; -typedef CFXMLParserCopyDescriptionCallBackFunction = - CFStringRef Function(ffi.Pointer info); -typedef CFXMLParserCopyDescriptionCallBack = - ffi.Pointer>; - -final class CFXMLParserContext extends ffi.Struct { - @CFIndex() - external int version; - - external ffi.Pointer info; - - external CFXMLParserRetainCallBack retain; - - external CFXMLParserReleaseCallBack release; - - external CFXMLParserCopyDescriptionCallBack copyDescription; -} - -typedef sint64 = ffi.Int64; -typedef Dartsint64 = int; -typedef uint64 = ffi.Uint64; -typedef Dartuint64 = int; -typedef sint32 = ffi.Int32; -typedef Dartsint32 = int; -typedef sint16 = ffi.Int16; -typedef Dartsint16 = int; -typedef sint8 = ffi.Int8; -typedef Dartsint8 = int; -typedef uint32 = ffi.Uint32; -typedef Dartuint32 = int; -typedef uint16 = ffi.Uint16; -typedef Dartuint16 = int; -typedef uint8 = ffi.Uint8; -typedef Dartuint8 = int; -typedef CSSM_INTPTR = ffi.IntPtr; -typedef DartCSSM_INTPTR = int; -typedef CSSM_SIZE = ffi.Size; -typedef DartCSSM_SIZE = int; - -final class cssm_data extends ffi.Struct { - @ffi.Size() - external int Length; - - external ffi.Pointer Data; -} - -typedef SecAsn1Item = cssm_data; -typedef SecAsn1Oid = cssm_data; - -final class SecAsn1AlgId extends ffi.Struct { - external SecAsn1Oid algorithm; - - external SecAsn1Item parameters; -} - -final class SecAsn1PubKeyInfo extends ffi.Struct { - external SecAsn1AlgId algorithm; - - external SecAsn1Item subjectPublicKey; -} - -final class SecAsn1Template_struct extends ffi.Struct { - @ffi.Uint32() - external int kind; - - @ffi.Uint32() - external int offset; - - external ffi.Pointer sub; - - @ffi.Uint32() - external int size; -} - -typedef SecAsn1Template = SecAsn1Template_struct; -typedef SecAsn1TemplateChooser = - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer arg, - Boolean enc, - ffi.Pointer buf, - ffi.Size len, - ffi.Pointer dest, - ) - >; -typedef SecAsn1TemplateChooserPtr = ffi.Pointer; -typedef CSSM_HANDLE = CSSM_INTPTR; -typedef CSSM_HANDLE_PTR = ffi.Pointer; -typedef CSSM_LONG_HANDLE = uint64; -typedef CSSM_LONG_HANDLE_PTR = ffi.Pointer; -typedef CSSM_MODULE_HANDLE = CSSM_HANDLE; -typedef CSSM_MODULE_HANDLE_PTR = ffi.Pointer; -typedef CSSM_CC_HANDLE = CSSM_LONG_HANDLE; -typedef CSSM_CSP_HANDLE = CSSM_MODULE_HANDLE; -typedef CSSM_TP_HANDLE = CSSM_MODULE_HANDLE; -typedef CSSM_AC_HANDLE = CSSM_MODULE_HANDLE; -typedef CSSM_CL_HANDLE = CSSM_MODULE_HANDLE; -typedef CSSM_DL_HANDLE = CSSM_MODULE_HANDLE; -typedef CSSM_DB_HANDLE = CSSM_MODULE_HANDLE; -typedef CSSM_BOOL = sint32; -typedef CSSM_RETURN = sint32; -typedef CSSM_DATA_PTR = ffi.Pointer; - -final class cssm_guid extends ffi.Struct { - @uint32() - external int Data1; - - @uint16() - external int Data2; - - @uint16() - external int Data3; - - @ffi.Array.multi([8]) - external ffi.Array Data4; -} - -typedef CSSM_GUID = cssm_guid; -typedef CSSM_GUID_PTR = ffi.Pointer; -typedef CSSM_BITMASK = uint32; -typedef CSSM_KEY_HIERARCHY = CSSM_BITMASK; -typedef CSSM_PVC_MODE = CSSM_BITMASK; -typedef CSSM_PRIVILEGE_SCOPE = uint32; - -final class cssm_version extends ffi.Struct { - @uint32() - external int Major; - - @uint32() - external int Minor; -} - -typedef CSSM_VERSION = cssm_version; -typedef CSSM_VERSION_PTR = ffi.Pointer; -typedef CSSM_SERVICE_MASK = uint32; -typedef CSSM_SERVICE_TYPE = CSSM_SERVICE_MASK; - -final class cssm_subservice_uid extends ffi.Struct { - external CSSM_GUID Guid; - - external CSSM_VERSION Version; - - @uint32() - external int SubserviceId; - - @CSSM_SERVICE_TYPE() - external int SubserviceType; -} - -typedef CSSM_SUBSERVICE_UID = cssm_subservice_uid; -typedef CSSM_SUBSERVICE_UID_PTR = ffi.Pointer; -typedef CSSM_MODULE_EVENT = uint32; -typedef CSSM_MODULE_EVENT_PTR = ffi.Pointer; -typedef CSSM_API_ModuleEventHandlerFunction = - CSSM_RETURN Function( - ffi.Pointer ModuleGuid, - ffi.Pointer AppNotifyCallbackCtx, - uint32 SubserviceId, - CSSM_SERVICE_TYPE ServiceType, - CSSM_MODULE_EVENT EventType, - ); -typedef DartCSSM_API_ModuleEventHandlerFunction = - Dartsint32 Function( - ffi.Pointer ModuleGuid, - ffi.Pointer AppNotifyCallbackCtx, - Dartuint32 SubserviceId, - Dartuint32 ServiceType, - Dartuint32 EventType, - ); -typedef CSSM_API_ModuleEventHandler = - ffi.Pointer>; -typedef CSSM_ATTACH_FLAGS = uint32; -typedef CSSM_PRIVILEGE = uint64; -typedef CSSM_USEE_TAG = CSSM_PRIVILEGE; -typedef CSSM_NET_ADDRESS_TYPE = uint32; - -final class cssm_net_address extends ffi.Struct { - @CSSM_NET_ADDRESS_TYPE() - external int AddressType; - - external SecAsn1Item Address; -} - -typedef CSSM_NET_ADDRESS = cssm_net_address; -typedef CSSM_NET_ADDRESS_PTR = ffi.Pointer; -typedef CSSM_NET_PROTOCOL = uint32; -typedef CSSM_CALLBACKFunction = - CSSM_RETURN Function( - CSSM_DATA_PTR OutData, - ffi.Pointer CallerCtx, - ); -typedef DartCSSM_CALLBACKFunction = - Dartsint32 Function(CSSM_DATA_PTR OutData, ffi.Pointer CallerCtx); -typedef CSSM_CALLBACK = ffi.Pointer>; - -final class cssm_crypto_data extends ffi.Struct { - external SecAsn1Item Param; - - external CSSM_CALLBACK Callback; - - external ffi.Pointer CallerCtx; -} - -typedef CSSM_CRYPTO_DATA = cssm_crypto_data; -typedef CSSM_CRYPTO_DATA_PTR = ffi.Pointer; -typedef CSSM_WORDID_TYPE = sint32; -typedef CSSM_LIST_ELEMENT_TYPE = uint32; -typedef CSSM_LIST_ELEMENT_TYPE_PTR = ffi.Pointer; -typedef CSSM_LIST_TYPE = uint32; -typedef CSSM_LIST_TYPE_PTR = ffi.Pointer; -typedef CSSM_LIST_ELEMENT_PTR = ffi.Pointer; - -final class cssm_list extends ffi.Struct { - @CSSM_LIST_TYPE() - external int ListType; - - external CSSM_LIST_ELEMENT_PTR Head; - - external CSSM_LIST_ELEMENT_PTR Tail; -} - -typedef CSSM_LIST = cssm_list; - -final class UnnamedUnion$1 extends ffi.Union { - external CSSM_LIST Sublist; - - external SecAsn1Item Word; -} - -final class cssm_list_element extends ffi.Struct { - external ffi.Pointer NextElement; - - @CSSM_WORDID_TYPE() - external int WordID; - - @CSSM_LIST_ELEMENT_TYPE() - external int ElementType; - - external UnnamedUnion$1 Element; -} - -typedef CSSM_LIST_PTR = ffi.Pointer; -typedef CSSM_LIST_ELEMENT = cssm_list_element; - -final class CSSM_TUPLE extends ffi.Struct { - external CSSM_LIST Issuer; - - external CSSM_LIST Subject; - - @CSSM_BOOL() - external int Delegate; - - external CSSM_LIST AuthorizationTag; - - external CSSM_LIST ValidityPeriod; -} - -typedef CSSM_TUPLE_PTR = ffi.Pointer; - -final class cssm_tuplegroup extends ffi.Struct { - @uint32() - external int NumberOfTuples; - - external CSSM_TUPLE_PTR Tuples; -} - -typedef CSSM_TUPLEGROUP = cssm_tuplegroup; -typedef CSSM_TUPLEGROUP_PTR = ffi.Pointer; -typedef CSSM_SAMPLE_TYPE = CSSM_WORDID_TYPE; - -final class cssm_sample extends ffi.Struct { - external CSSM_LIST TypedSample; - - external ffi.Pointer Verifier; -} - -typedef CSSM_SAMPLE = cssm_sample; -typedef CSSM_SAMPLE_PTR = ffi.Pointer; - -final class cssm_samplegroup extends ffi.Struct { - @uint32() - external int NumberOfSamples; - - external ffi.Pointer Samples; -} - -typedef CSSM_SAMPLEGROUP = cssm_samplegroup; -typedef CSSM_SAMPLEGROUP_PTR = ffi.Pointer; -typedef CSSM_MALLOCFunction = - ffi.Pointer Function( - CSSM_SIZE size, - ffi.Pointer allocref, - ); -typedef DartCSSM_MALLOCFunction = - ffi.Pointer Function( - DartCSSM_SIZE size, - ffi.Pointer allocref, - ); -typedef CSSM_MALLOC = ffi.Pointer>; -typedef CSSM_FREEFunction = - ffi.Void Function( - ffi.Pointer memblock, - ffi.Pointer allocref, - ); -typedef DartCSSM_FREEFunction = - void Function( - ffi.Pointer memblock, - ffi.Pointer allocref, - ); -typedef CSSM_FREE = ffi.Pointer>; -typedef CSSM_REALLOCFunction = - ffi.Pointer Function( - ffi.Pointer memblock, - CSSM_SIZE size, - ffi.Pointer allocref, - ); -typedef DartCSSM_REALLOCFunction = - ffi.Pointer Function( - ffi.Pointer memblock, - DartCSSM_SIZE size, - ffi.Pointer allocref, - ); -typedef CSSM_REALLOC = ffi.Pointer>; -typedef CSSM_CALLOCFunction = - ffi.Pointer Function( - uint32 num, - CSSM_SIZE size, - ffi.Pointer allocref, - ); -typedef DartCSSM_CALLOCFunction = - ffi.Pointer Function( - Dartuint32 num, - DartCSSM_SIZE size, - ffi.Pointer allocref, - ); -typedef CSSM_CALLOC = ffi.Pointer>; - -final class cssm_memory_funcs extends ffi.Struct { - external CSSM_MALLOC malloc_func; - - external CSSM_FREE free_func; - - external CSSM_REALLOC realloc_func; - - external CSSM_CALLOC calloc_func; - - external ffi.Pointer AllocRef; -} - -typedef CSSM_MEMORY_FUNCS = cssm_memory_funcs; -typedef CSSM_MEMORY_FUNCS_PTR = ffi.Pointer; -typedef CSSM_API_MEMORY_FUNCS = CSSM_MEMORY_FUNCS; -typedef CSSM_API_MEMORY_FUNCS_PTR = ffi.Pointer; -typedef CSSM_CHALLENGE_CALLBACKFunction = - CSSM_RETURN Function( - ffi.Pointer Challenge, - CSSM_SAMPLEGROUP_PTR Response, - ffi.Pointer CallerCtx, - ffi.Pointer MemFuncs, - ); -typedef DartCSSM_CHALLENGE_CALLBACKFunction = - Dartsint32 Function( - ffi.Pointer Challenge, - CSSM_SAMPLEGROUP_PTR Response, - ffi.Pointer CallerCtx, - ffi.Pointer MemFuncs, - ); -typedef CSSM_CHALLENGE_CALLBACK = - ffi.Pointer>; -typedef CSSM_CERT_TYPE = uint32; -typedef CSSM_CERT_TYPE_PTR = ffi.Pointer; -typedef CSSM_CERT_ENCODING = uint32; -typedef CSSM_CERT_ENCODING_PTR = ffi.Pointer; - -final class cssm_encoded_cert extends ffi.Struct { - @CSSM_CERT_TYPE() - external int CertType; - - @CSSM_CERT_ENCODING() - external int CertEncoding; - - external SecAsn1Item CertBlob; -} - -typedef CSSM_ENCODED_CERT = cssm_encoded_cert; -typedef CSSM_ENCODED_CERT_PTR = ffi.Pointer; -typedef CSSM_CERT_PARSE_FORMAT = uint32; -typedef CSSM_CERT_PARSE_FORMAT_PTR = ffi.Pointer; - -final class cssm_parsed_cert extends ffi.Struct { - @CSSM_CERT_TYPE() - external int CertType; - - @CSSM_CERT_PARSE_FORMAT() - external int ParsedCertFormat; - - external ffi.Pointer ParsedCert; -} - -typedef CSSM_PARSED_CERT = cssm_parsed_cert; -typedef CSSM_PARSED_CERT_PTR = ffi.Pointer; - -final class cssm_cert_pair extends ffi.Struct { - external CSSM_ENCODED_CERT EncodedCert; - - external CSSM_PARSED_CERT ParsedCert; -} - -typedef CSSM_CERT_PAIR = cssm_cert_pair; -typedef CSSM_CERT_PAIR_PTR = ffi.Pointer; -typedef CSSM_CERTGROUP_TYPE = uint32; -typedef CSSM_CERTGROUP_TYPE_PTR = ffi.Pointer; - -final class UnnamedUnion$2 extends ffi.Union { - external CSSM_DATA_PTR CertList; - - external CSSM_ENCODED_CERT_PTR EncodedCertList; - - external CSSM_PARSED_CERT_PTR ParsedCertList; - - external CSSM_CERT_PAIR_PTR PairCertList; -} - -final class cssm_certgroup extends ffi.Struct { - @CSSM_CERT_TYPE() - external int CertType; - - @CSSM_CERT_ENCODING() - external int CertEncoding; - - @uint32() - external int NumCerts; - - external UnnamedUnion$2 GroupList; - - @CSSM_CERTGROUP_TYPE() - external int CertGroupType; - - external ffi.Pointer Reserved; -} - -typedef CSSM_CERTGROUP = cssm_certgroup; -typedef CSSM_CERTGROUP_PTR = ffi.Pointer; - -final class cssm_base_certs extends ffi.Struct { - @CSSM_TP_HANDLE() - external int TPHandle; - - @CSSM_CL_HANDLE() - external int CLHandle; - - external CSSM_CERTGROUP Certs; -} - -typedef CSSM_BASE_CERTS = cssm_base_certs; -typedef CSSM_BASE_CERTS_PTR = ffi.Pointer; - -final class cssm_access_credentials extends ffi.Struct { - @ffi.Array.multi([68]) - external ffi.Array EntryTag; - - external CSSM_BASE_CERTS BaseCerts; - - external CSSM_SAMPLEGROUP Samples; - - external CSSM_CHALLENGE_CALLBACK Callback; - - external ffi.Pointer CallerCtx; -} - -typedef CSSM_ACCESS_CREDENTIALS = cssm_access_credentials; -typedef CSSM_ACCESS_CREDENTIALS_PTR = ffi.Pointer; -typedef CSSM_ACL_SUBJECT_TYPE = sint32; -typedef CSSM_ACL_AUTHORIZATION_TAG = sint32; - -final class cssm_authorizationgroup extends ffi.Struct { - @uint32() - external int NumberOfAuthTags; - - external ffi.Pointer AuthTags; -} - -typedef CSSM_AUTHORIZATIONGROUP = cssm_authorizationgroup; -typedef CSSM_AUTHORIZATIONGROUP_PTR = ffi.Pointer; - -final class cssm_acl_validity_period extends ffi.Struct { - external SecAsn1Item StartDate; - - external SecAsn1Item EndDate; -} - -typedef CSSM_ACL_VALIDITY_PERIOD = cssm_acl_validity_period; -typedef CSSM_ACL_VALIDITY_PERIOD_PTR = ffi.Pointer; - -final class cssm_acl_entry_prototype extends ffi.Struct { - external CSSM_LIST TypedSubject; - - @CSSM_BOOL() - external int Delegate; - - external CSSM_AUTHORIZATIONGROUP Authorization; - - external CSSM_ACL_VALIDITY_PERIOD TimeRange; - - @ffi.Array.multi([68]) - external ffi.Array EntryTag; -} - -typedef CSSM_ACL_ENTRY_PROTOTYPE = cssm_acl_entry_prototype; -typedef CSSM_ACL_ENTRY_PROTOTYPE_PTR = ffi.Pointer; - -final class cssm_acl_owner_prototype extends ffi.Struct { - external CSSM_LIST TypedSubject; - - @CSSM_BOOL() - external int Delegate; -} - -typedef CSSM_ACL_OWNER_PROTOTYPE = cssm_acl_owner_prototype; -typedef CSSM_ACL_OWNER_PROTOTYPE_PTR = ffi.Pointer; -typedef CSSM_ACL_SUBJECT_CALLBACKFunction = - CSSM_RETURN Function( - ffi.Pointer SubjectRequest, - CSSM_LIST_PTR SubjectResponse, - ffi.Pointer CallerContext, - ffi.Pointer MemFuncs, - ); -typedef DartCSSM_ACL_SUBJECT_CALLBACKFunction = - Dartsint32 Function( - ffi.Pointer SubjectRequest, - CSSM_LIST_PTR SubjectResponse, - ffi.Pointer CallerContext, - ffi.Pointer MemFuncs, - ); -typedef CSSM_ACL_SUBJECT_CALLBACK = - ffi.Pointer>; - -final class cssm_acl_entry_input extends ffi.Struct { - external CSSM_ACL_ENTRY_PROTOTYPE Prototype; - - external CSSM_ACL_SUBJECT_CALLBACK Callback; - - external ffi.Pointer CallerContext; -} - -typedef CSSM_ACL_ENTRY_INPUT = cssm_acl_entry_input; -typedef CSSM_ACL_ENTRY_INPUT_PTR = ffi.Pointer; - -final class cssm_resource_control_context extends ffi.Struct { - external CSSM_ACCESS_CREDENTIALS_PTR AccessCred; - - external CSSM_ACL_ENTRY_INPUT InitialAclEntry; -} - -typedef CSSM_RESOURCE_CONTROL_CONTEXT = cssm_resource_control_context; -typedef CSSM_RESOURCE_CONTROL_CONTEXT_PTR = - ffi.Pointer; -typedef CSSM_ACL_HANDLE = CSSM_HANDLE; - -final class cssm_acl_entry_info extends ffi.Struct { - external CSSM_ACL_ENTRY_PROTOTYPE EntryPublicInfo; - - @CSSM_ACL_HANDLE() - external int EntryHandle; -} - -typedef CSSM_ACL_ENTRY_INFO = cssm_acl_entry_info; -typedef CSSM_ACL_ENTRY_INFO_PTR = ffi.Pointer; -typedef CSSM_ACL_EDIT_MODE = uint32; - -final class cssm_acl_edit extends ffi.Struct { - @CSSM_ACL_EDIT_MODE() - external int EditMode; - - @CSSM_ACL_HANDLE() - external int OldEntryHandle; - - external ffi.Pointer NewEntry; -} - -typedef CSSM_ACL_EDIT = cssm_acl_edit; -typedef CSSM_ACL_EDIT_PTR = ffi.Pointer; -typedef CSSM_PROC_ADDRFunction = ffi.Void Function(); -typedef DartCSSM_PROC_ADDRFunction = void Function(); -typedef CSSM_PROC_ADDR = - ffi.Pointer>; -typedef CSSM_PROC_ADDR_PTR = ffi.Pointer; - -final class cssm_func_name_addr extends ffi.Struct { - @ffi.Array.multi([68]) - external ffi.Array Name; - - external CSSM_PROC_ADDR Address; -} - -typedef CSSM_FUNC_NAME_ADDR = cssm_func_name_addr; -typedef CSSM_FUNC_NAME_ADDR_PTR = ffi.Pointer; - -final class cssm_date extends ffi.Struct { - @ffi.Array.multi([4]) - external ffi.Array Year; - - @ffi.Array.multi([2]) - external ffi.Array Month; - - @ffi.Array.multi([2]) - external ffi.Array Day; -} - -typedef CSSM_DATE = cssm_date; -typedef CSSM_DATE_PTR = ffi.Pointer; - -final class cssm_range extends ffi.Struct { - @uint32() - external int Min; - - @uint32() - external int Max; -} - -typedef CSSM_RANGE = cssm_range; -typedef CSSM_RANGE_PTR = ffi.Pointer; - -final class cssm_query_size_data extends ffi.Struct { - @uint32() - external int SizeInputBlock; - - @uint32() - external int SizeOutputBlock; -} - -typedef CSSM_QUERY_SIZE_DATA = cssm_query_size_data; -typedef CSSM_QUERY_SIZE_DATA_PTR = ffi.Pointer; -typedef CSSM_HEADERVERSION = uint32; - -final class cssm_key_size extends ffi.Struct { - @uint32() - external int LogicalKeySizeInBits; - - @uint32() - external int EffectiveKeySizeInBits; -} - -typedef CSSM_KEY_SIZE = cssm_key_size; -typedef CSSM_KEY_SIZE_PTR = ffi.Pointer; -typedef CSSM_KEYBLOB_TYPE = uint32; -typedef CSSM_KEYBLOB_FORMAT = uint32; -typedef CSSM_KEYCLASS = uint32; -typedef CSSM_KEYATTR_FLAGS = uint32; -typedef CSSM_KEYUSE = uint32; -typedef CSSM_ALGORITHMS = uint32; -typedef CSSM_ENCRYPT_MODE = uint32; - -final class cssm_keyheader extends ffi.Struct { - @CSSM_HEADERVERSION() - external int HeaderVersion; - - external CSSM_GUID CspId; - - @CSSM_KEYBLOB_TYPE() - external int BlobType; - - @CSSM_KEYBLOB_FORMAT() - external int Format; - - @CSSM_ALGORITHMS() - external int AlgorithmId; - - @CSSM_KEYCLASS() - external int KeyClass; - - @uint32() - external int LogicalKeySizeInBits; - - @CSSM_KEYATTR_FLAGS() - external int KeyAttr; - - @CSSM_KEYUSE() - external int KeyUsage; - - external CSSM_DATE StartDate; - - external CSSM_DATE EndDate; - - @CSSM_ALGORITHMS() - external int WrapAlgorithmId; - - @CSSM_ENCRYPT_MODE() - external int WrapMode; - - @uint32() - external int Reserved; -} - -typedef CSSM_KEYHEADER = cssm_keyheader; -typedef CSSM_KEYHEADER_PTR = ffi.Pointer; - -final class cssm_key extends ffi.Struct { - external CSSM_KEYHEADER KeyHeader; - - external SecAsn1Item KeyData; -} - -typedef CSSM_KEY = cssm_key; -typedef CSSM_KEY_PTR = ffi.Pointer; -typedef CSSM_WRAP_KEY = CSSM_KEY; -typedef CSSM_WRAP_KEY_PTR = ffi.Pointer; -typedef CSSM_CSPTYPE = uint32; - -final class cssm_dl_db_handle extends ffi.Struct { - @CSSM_DL_HANDLE() - external int DLHandle; - - @CSSM_DB_HANDLE() - external int DBHandle; -} - -typedef CSSM_DL_DB_HANDLE = cssm_dl_db_handle; -typedef CSSM_DL_DB_HANDLE_PTR = ffi.Pointer; -typedef CSSM_CONTEXT_TYPE = uint32; -typedef CSSM_ATTRIBUTE_TYPE = uint32; -typedef CSSM_PADDING = uint32; -typedef CSSM_KEY_TYPE = CSSM_ALGORITHMS; - -final class cssm_kr_profile extends ffi.Opaque {} - -final class cssm_context_attribute_value extends ffi.Union { - external ffi.Pointer String; - - @uint32() - external int Uint32; - - external CSSM_ACCESS_CREDENTIALS_PTR AccessCredentials; - - external CSSM_KEY_PTR Key; - - external CSSM_DATA_PTR Data; - - @CSSM_PADDING() - external int Padding; - - external CSSM_DATE_PTR Date; - - external CSSM_RANGE_PTR Range; - - external CSSM_CRYPTO_DATA_PTR CryptoData; - - external CSSM_VERSION_PTR Version; - - external CSSM_DL_DB_HANDLE_PTR DLDBHandle; - - external ffi.Pointer KRProfile; -} - -final class cssm_context_attribute extends ffi.Struct { - @CSSM_ATTRIBUTE_TYPE() - external int AttributeType; - - @uint32() - external int AttributeLength; - - external cssm_context_attribute_value Attribute; -} - -typedef CSSM_CONTEXT_ATTRIBUTE = cssm_context_attribute; -typedef CSSM_CONTEXT_ATTRIBUTE_PTR = ffi.Pointer; - -final class cssm_context extends ffi.Struct { - @CSSM_CONTEXT_TYPE() - external int ContextType; - - @CSSM_ALGORITHMS() - external int AlgorithmType; - - @uint32() - external int NumberOfAttributes; - - external CSSM_CONTEXT_ATTRIBUTE_PTR ContextAttributes; - - @CSSM_CSP_HANDLE() - external int CSPHandle; - - @CSSM_BOOL() - external int Privileged; - - @uint32() - external int EncryptionProhibited; - - @uint32() - external int WorkFactor; - - @uint32() - external int Reserved; -} - -typedef CSSM_CONTEXT = cssm_context; -typedef CSSM_CONTEXT_PTR = ffi.Pointer; -typedef CSSM_SC_FLAGS = uint32; -typedef CSSM_CSP_READER_FLAGS = uint32; -typedef CSSM_CSP_FLAGS = uint32; -typedef CSSM_PKCS_OAEP_MGF = uint32; -typedef CSSM_PKCS_OAEP_PSOURCE = uint32; - -final class cssm_pkcs1_oaep_params extends ffi.Struct { - @uint32() - external int HashAlgorithm; - - external SecAsn1Item HashParams; - - @CSSM_PKCS_OAEP_MGF() - external int MGF; - - external SecAsn1Item MGFParams; - - @CSSM_PKCS_OAEP_PSOURCE() - external int PSource; - - external SecAsn1Item PSourceParams; -} - -typedef CSSM_PKCS1_OAEP_PARAMS = cssm_pkcs1_oaep_params; -typedef CSSM_PKCS1_OAEP_PARAMS_PTR = ffi.Pointer; - -final class cssm_csp_operational_statistics extends ffi.Struct { - @CSSM_BOOL() - external int UserAuthenticated; - - @CSSM_CSP_FLAGS() - external int DeviceFlags; - - @uint32() - external int TokenMaxSessionCount; - - @uint32() - external int TokenOpenedSessionCount; - - @uint32() - external int TokenMaxRWSessionCount; - - @uint32() - external int TokenOpenedRWSessionCount; - - @uint32() - external int TokenTotalPublicMem; - - @uint32() - external int TokenFreePublicMem; - - @uint32() - external int TokenTotalPrivateMem; - - @uint32() - external int TokenFreePrivateMem; -} - -typedef CSSM_CSP_OPERATIONAL_STATISTICS = cssm_csp_operational_statistics; -typedef CSSM_CSP_OPERATIONAL_STATISTICS_PTR = - ffi.Pointer; - -final class cssm_pkcs5_pbkdf1_params extends ffi.Struct { - external SecAsn1Item Passphrase; - - external SecAsn1Item InitVector; -} - -typedef CSSM_PKCS5_PBKDF1_PARAMS = cssm_pkcs5_pbkdf1_params; -typedef CSSM_PKCS5_PBKDF1_PARAMS_PTR = ffi.Pointer; -typedef CSSM_PKCS5_PBKDF2_PRF = uint32; - -final class cssm_pkcs5_pbkdf2_params extends ffi.Struct { - external SecAsn1Item Passphrase; - - @CSSM_PKCS5_PBKDF2_PRF() - external int PseudoRandomFunction; -} - -typedef CSSM_PKCS5_PBKDF2_PARAMS = cssm_pkcs5_pbkdf2_params; -typedef CSSM_PKCS5_PBKDF2_PARAMS_PTR = ffi.Pointer; - -final class cssm_kea_derive_params extends ffi.Struct { - external SecAsn1Item Rb; - - external SecAsn1Item Yb; -} - -typedef CSSM_KEA_DERIVE_PARAMS = cssm_kea_derive_params; -typedef CSSM_KEA_DERIVE_PARAMS_PTR = ffi.Pointer; - -final class cssm_tp_authority_id extends ffi.Struct { - external ffi.Pointer AuthorityCert; - - external CSSM_NET_ADDRESS_PTR AuthorityLocation; -} - -typedef CSSM_TP_AUTHORITY_ID = cssm_tp_authority_id; -typedef CSSM_TP_AUTHORITY_ID_PTR = ffi.Pointer; -typedef CSSM_TP_AUTHORITY_REQUEST_TYPE = uint32; -typedef CSSM_TP_AUTHORITY_REQUEST_TYPE_PTR = ffi.Pointer; -typedef CSSM_TP_VERIFICATION_RESULTS_CALLBACKFunction = - CSSM_RETURN Function( - CSSM_MODULE_HANDLE ModuleHandle, - ffi.Pointer CallerCtx, - CSSM_DATA_PTR VerifiedCert, - ); -typedef DartCSSM_TP_VERIFICATION_RESULTS_CALLBACKFunction = - Dartsint32 Function( - DartCSSM_INTPTR ModuleHandle, - ffi.Pointer CallerCtx, - CSSM_DATA_PTR VerifiedCert, - ); -typedef CSSM_TP_VERIFICATION_RESULTS_CALLBACK = - ffi.Pointer< - ffi.NativeFunction - >; -typedef CSSM_OID_PTR = ffi.Pointer; - -final class cssm_field extends ffi.Struct { - external SecAsn1Oid FieldOid; - - external SecAsn1Item FieldValue; -} - -typedef CSSM_FIELD = cssm_field; -typedef CSSM_FIELD_PTR = ffi.Pointer; - -final class cssm_tp_policyinfo extends ffi.Struct { - @uint32() - external int NumberOfPolicyIds; - - external CSSM_FIELD_PTR PolicyIds; - - external ffi.Pointer PolicyControl; -} - -typedef CSSM_TP_POLICYINFO = cssm_tp_policyinfo; -typedef CSSM_TP_POLICYINFO_PTR = ffi.Pointer; -typedef CSSM_TP_SERVICES = uint32; -typedef CSSM_TP_ACTION = uint32; -typedef CSSM_TP_STOP_ON = uint32; -typedef CSSM_TIMESTRING = ffi.Pointer; - -final class cssm_dl_db_list extends ffi.Struct { - @uint32() - external int NumHandles; - - external CSSM_DL_DB_HANDLE_PTR DLDBHandle; -} - -typedef CSSM_DL_DB_LIST = cssm_dl_db_list; -typedef CSSM_DL_DB_LIST_PTR = ffi.Pointer; - -final class cssm_tp_callerauth_context extends ffi.Struct { - external CSSM_TP_POLICYINFO Policy; - - external CSSM_TIMESTRING VerifyTime; - - @CSSM_TP_STOP_ON() - external int VerificationAbortOn; - - external CSSM_TP_VERIFICATION_RESULTS_CALLBACK CallbackWithVerifiedCert; - - @uint32() - external int NumberOfAnchorCerts; - - external CSSM_DATA_PTR AnchorCerts; - - external CSSM_DL_DB_LIST_PTR DBList; - - external CSSM_ACCESS_CREDENTIALS_PTR CallerCredentials; -} - -typedef CSSM_TP_CALLERAUTH_CONTEXT = cssm_tp_callerauth_context; -typedef CSSM_TP_CALLERAUTH_CONTEXT_PTR = - ffi.Pointer; -typedef CSSM_CRL_PARSE_FORMAT = uint32; -typedef CSSM_CRL_PARSE_FORMAT_PTR = ffi.Pointer; -typedef CSSM_CRL_TYPE = uint32; -typedef CSSM_CRL_TYPE_PTR = ffi.Pointer; -typedef CSSM_CRL_ENCODING = uint32; -typedef CSSM_CRL_ENCODING_PTR = ffi.Pointer; - -final class cssm_encoded_crl extends ffi.Struct { - @CSSM_CRL_TYPE() - external int CrlType; - - @CSSM_CRL_ENCODING() - external int CrlEncoding; - - external SecAsn1Item CrlBlob; -} - -typedef CSSM_ENCODED_CRL = cssm_encoded_crl; -typedef CSSM_ENCODED_CRL_PTR = ffi.Pointer; - -final class cssm_parsed_crl extends ffi.Struct { - @CSSM_CRL_TYPE() - external int CrlType; - - @CSSM_CRL_PARSE_FORMAT() - external int ParsedCrlFormat; - - external ffi.Pointer ParsedCrl; -} - -typedef CSSM_PARSED_CRL = cssm_parsed_crl; -typedef CSSM_PARSED_CRL_PTR = ffi.Pointer; - -final class cssm_crl_pair extends ffi.Struct { - external CSSM_ENCODED_CRL EncodedCrl; - - external CSSM_PARSED_CRL ParsedCrl; -} - -typedef CSSM_CRL_PAIR = cssm_crl_pair; -typedef CSSM_CRL_PAIR_PTR = ffi.Pointer; -typedef CSSM_CRLGROUP_TYPE = uint32; -typedef CSSM_CRLGROUP_TYPE_PTR = ffi.Pointer; - -final class UnnamedUnion$3 extends ffi.Union { - external CSSM_DATA_PTR CrlList; - - external CSSM_ENCODED_CRL_PTR EncodedCrlList; - - external CSSM_PARSED_CRL_PTR ParsedCrlList; - - external CSSM_CRL_PAIR_PTR PairCrlList; -} - -final class cssm_crlgroup extends ffi.Struct { - @CSSM_CRL_TYPE() - external int CrlType; - - @CSSM_CRL_ENCODING() - external int CrlEncoding; - - @uint32() - external int NumberOfCrls; - - external UnnamedUnion$3 GroupCrlList; - - @CSSM_CRLGROUP_TYPE() - external int CrlGroupType; -} - -typedef CSSM_CRLGROUP = cssm_crlgroup; -typedef CSSM_CRLGROUP_PTR = ffi.Pointer; - -final class cssm_fieldgroup extends ffi.Struct { - @ffi.Int() - external int NumberOfFields; - - external CSSM_FIELD_PTR Fields; -} - -typedef CSSM_FIELDGROUP = cssm_fieldgroup; -typedef CSSM_FIELDGROUP_PTR = ffi.Pointer; -typedef CSSM_EVIDENCE_FORM = uint32; - -final class cssm_evidence extends ffi.Struct { - @CSSM_EVIDENCE_FORM() - external int EvidenceForm; - - external ffi.Pointer Evidence; -} - -typedef CSSM_EVIDENCE = cssm_evidence; -typedef CSSM_EVIDENCE_PTR = ffi.Pointer; - -final class cssm_tp_verify_context extends ffi.Struct { - @CSSM_TP_ACTION() - external int Action; - - external SecAsn1Item ActionData; - - external CSSM_CRLGROUP Crls; - - external CSSM_TP_CALLERAUTH_CONTEXT_PTR Cred; -} - -typedef CSSM_TP_VERIFY_CONTEXT = cssm_tp_verify_context; -typedef CSSM_TP_VERIFY_CONTEXT_PTR = ffi.Pointer; - -final class cssm_tp_verify_context_result extends ffi.Struct { - @uint32() - external int NumberOfEvidences; - - external CSSM_EVIDENCE_PTR Evidence; -} - -typedef CSSM_TP_VERIFY_CONTEXT_RESULT = cssm_tp_verify_context_result; -typedef CSSM_TP_VERIFY_CONTEXT_RESULT_PTR = - ffi.Pointer; - -final class cssm_tp_request_set extends ffi.Struct { - @uint32() - external int NumberOfRequests; - - external ffi.Pointer Requests; -} - -typedef CSSM_TP_REQUEST_SET = cssm_tp_request_set; -typedef CSSM_TP_REQUEST_SET_PTR = ffi.Pointer; - -final class cssm_tp_result_set extends ffi.Struct { - @uint32() - external int NumberOfResults; - - external ffi.Pointer Results; -} - -typedef CSSM_TP_RESULT_SET = cssm_tp_result_set; -typedef CSSM_TP_RESULT_SET_PTR = ffi.Pointer; -typedef CSSM_TP_CONFIRM_STATUS = uint32; -typedef CSSM_TP_CONFIRM_STATUS_PTR = ffi.Pointer; - -final class cssm_tp_confirm_response extends ffi.Struct { - @uint32() - external int NumberOfResponses; - - external CSSM_TP_CONFIRM_STATUS_PTR Responses; -} - -typedef CSSM_TP_CONFIRM_RESPONSE = cssm_tp_confirm_response; -typedef CSSM_TP_CONFIRM_RESPONSE_PTR = ffi.Pointer; - -final class cssm_tp_certissue_input extends ffi.Struct { - external CSSM_SUBSERVICE_UID CSPSubserviceUid; - - @CSSM_CL_HANDLE() - external int CLHandle; - - @uint32() - external int NumberOfTemplateFields; - - external CSSM_FIELD_PTR SubjectCertFields; - - @CSSM_TP_SERVICES() - external int MoreServiceRequests; - - @uint32() - external int NumberOfServiceControls; - - external CSSM_FIELD_PTR ServiceControls; - - external CSSM_ACCESS_CREDENTIALS_PTR UserCredentials; -} - -typedef CSSM_TP_CERTISSUE_INPUT = cssm_tp_certissue_input; -typedef CSSM_TP_CERTISSUE_INPUT_PTR = ffi.Pointer; -typedef CSSM_TP_CERTISSUE_STATUS = uint32; - -final class cssm_tp_certissue_output extends ffi.Struct { - @CSSM_TP_CERTISSUE_STATUS() - external int IssueStatus; - - external CSSM_CERTGROUP_PTR CertGroup; - - @CSSM_TP_SERVICES() - external int PerformedServiceRequests; -} - -typedef CSSM_TP_CERTISSUE_OUTPUT = cssm_tp_certissue_output; -typedef CSSM_TP_CERTISSUE_OUTPUT_PTR = ffi.Pointer; -typedef CSSM_TP_CERTCHANGE_ACTION = uint32; -typedef CSSM_TP_CERTCHANGE_REASON = uint32; - -final class cssm_tp_certchange_input extends ffi.Struct { - @CSSM_TP_CERTCHANGE_ACTION() - external int Action; - - @CSSM_TP_CERTCHANGE_REASON() - external int Reason; - - @CSSM_CL_HANDLE() - external int CLHandle; - - external CSSM_DATA_PTR Cert; - - external CSSM_FIELD_PTR ChangeInfo; - - external CSSM_TIMESTRING StartTime; - - external CSSM_ACCESS_CREDENTIALS_PTR CallerCredentials; -} - -typedef CSSM_TP_CERTCHANGE_INPUT = cssm_tp_certchange_input; -typedef CSSM_TP_CERTCHANGE_INPUT_PTR = ffi.Pointer; -typedef CSSM_TP_CERTCHANGE_STATUS = uint32; - -final class cssm_tp_certchange_output extends ffi.Struct { - @CSSM_TP_CERTCHANGE_STATUS() - external int ActionStatus; - - external CSSM_FIELD RevokeInfo; -} - -typedef CSSM_TP_CERTCHANGE_OUTPUT = cssm_tp_certchange_output; -typedef CSSM_TP_CERTCHANGE_OUTPUT_PTR = ffi.Pointer; - -final class cssm_tp_certverify_input extends ffi.Struct { - @CSSM_CL_HANDLE() - external int CLHandle; - - external CSSM_DATA_PTR Cert; - - external CSSM_TP_VERIFY_CONTEXT_PTR VerifyContext; -} - -typedef CSSM_TP_CERTVERIFY_INPUT = cssm_tp_certverify_input; -typedef CSSM_TP_CERTVERIFY_INPUT_PTR = ffi.Pointer; -typedef CSSM_TP_CERTVERIFY_STATUS = uint32; - -final class cssm_tp_certverify_output extends ffi.Struct { - @CSSM_TP_CERTVERIFY_STATUS() - external int VerifyStatus; - - @uint32() - external int NumberOfEvidence; - - external CSSM_EVIDENCE_PTR Evidence; -} - -typedef CSSM_TP_CERTVERIFY_OUTPUT = cssm_tp_certverify_output; -typedef CSSM_TP_CERTVERIFY_OUTPUT_PTR = ffi.Pointer; - -final class cssm_tp_certnotarize_input extends ffi.Struct { - @CSSM_CL_HANDLE() - external int CLHandle; - - @uint32() - external int NumberOfFields; - - external CSSM_FIELD_PTR MoreFields; - - external CSSM_FIELD_PTR SignScope; - - @uint32() - external int ScopeSize; - - @CSSM_TP_SERVICES() - external int MoreServiceRequests; - - @uint32() - external int NumberOfServiceControls; - - external CSSM_FIELD_PTR ServiceControls; - - external CSSM_ACCESS_CREDENTIALS_PTR UserCredentials; -} - -typedef CSSM_TP_CERTNOTARIZE_INPUT = cssm_tp_certnotarize_input; -typedef CSSM_TP_CERTNOTARIZE_INPUT_PTR = - ffi.Pointer; -typedef CSSM_TP_CERTNOTARIZE_STATUS = uint32; - -final class cssm_tp_certnotarize_output extends ffi.Struct { - @CSSM_TP_CERTNOTARIZE_STATUS() - external int NotarizeStatus; - - external CSSM_CERTGROUP_PTR NotarizedCertGroup; - - @CSSM_TP_SERVICES() - external int PerformedServiceRequests; -} - -typedef CSSM_TP_CERTNOTARIZE_OUTPUT = cssm_tp_certnotarize_output; -typedef CSSM_TP_CERTNOTARIZE_OUTPUT_PTR = - ffi.Pointer; - -final class cssm_tp_certreclaim_input extends ffi.Struct { - @CSSM_CL_HANDLE() - external int CLHandle; - - @uint32() - external int NumberOfSelectionFields; - - external CSSM_FIELD_PTR SelectionFields; - - external CSSM_ACCESS_CREDENTIALS_PTR UserCredentials; -} - -typedef CSSM_TP_CERTRECLAIM_INPUT = cssm_tp_certreclaim_input; -typedef CSSM_TP_CERTRECLAIM_INPUT_PTR = ffi.Pointer; -typedef CSSM_TP_CERTRECLAIM_STATUS = uint32; - -final class cssm_tp_certreclaim_output extends ffi.Struct { - @CSSM_TP_CERTRECLAIM_STATUS() - external int ReclaimStatus; - - external CSSM_CERTGROUP_PTR ReclaimedCertGroup; - - @CSSM_LONG_HANDLE() - external int KeyCacheHandle; -} - -typedef CSSM_TP_CERTRECLAIM_OUTPUT = cssm_tp_certreclaim_output; -typedef CSSM_TP_CERTRECLAIM_OUTPUT_PTR = - ffi.Pointer; - -final class cssm_tp_crlissue_input extends ffi.Struct { - @CSSM_CL_HANDLE() - external int CLHandle; - - @uint32() - external int CrlIdentifier; - - external CSSM_TIMESTRING CrlThisTime; - - external CSSM_FIELD_PTR PolicyIdentifier; - - external CSSM_ACCESS_CREDENTIALS_PTR CallerCredentials; -} - -typedef CSSM_TP_CRLISSUE_INPUT = cssm_tp_crlissue_input; -typedef CSSM_TP_CRLISSUE_INPUT_PTR = ffi.Pointer; -typedef CSSM_TP_CRLISSUE_STATUS = uint32; - -final class cssm_tp_crlissue_output extends ffi.Struct { - @CSSM_TP_CRLISSUE_STATUS() - external int IssueStatus; - - external CSSM_ENCODED_CRL_PTR Crl; - - external CSSM_TIMESTRING CrlNextTime; -} - -typedef CSSM_TP_CRLISSUE_OUTPUT = cssm_tp_crlissue_output; -typedef CSSM_TP_CRLISSUE_OUTPUT_PTR = ffi.Pointer; -typedef CSSM_TP_FORM_TYPE = uint32; -typedef CSSM_CL_TEMPLATE_TYPE = uint32; -typedef CSSM_CERT_BUNDLE_TYPE = uint32; -typedef CSSM_CERT_BUNDLE_ENCODING = uint32; - -final class cssm_cert_bundle_header extends ffi.Struct { - @CSSM_CERT_BUNDLE_TYPE() - external int BundleType; - - @CSSM_CERT_BUNDLE_ENCODING() - external int BundleEncoding; -} - -typedef CSSM_CERT_BUNDLE_HEADER = cssm_cert_bundle_header; -typedef CSSM_CERT_BUNDLE_HEADER_PTR = ffi.Pointer; - -final class cssm_cert_bundle extends ffi.Struct { - external CSSM_CERT_BUNDLE_HEADER BundleHeader; - - external SecAsn1Item Bundle; -} - -typedef CSSM_CERT_BUNDLE = cssm_cert_bundle; -typedef CSSM_CERT_BUNDLE_PTR = ffi.Pointer; -typedef CSSM_DB_ATTRIBUTE_NAME_FORMAT = uint32; -typedef CSSM_DB_ATTRIBUTE_NAME_FORMAT_PTR = ffi.Pointer; -typedef CSSM_DB_ATTRIBUTE_FORMAT = uint32; -typedef CSSM_DB_ATTRIBUTE_FORMAT_PTR = ffi.Pointer; - -final class cssm_db_attribute_label extends ffi.Union { - external ffi.Pointer AttributeName; - - external SecAsn1Oid AttributeOID; - - @uint32() - external int AttributeID; -} - -final class cssm_db_attribute_info extends ffi.Struct { - @CSSM_DB_ATTRIBUTE_NAME_FORMAT() - external int AttributeNameFormat; - - external cssm_db_attribute_label Label; - - @CSSM_DB_ATTRIBUTE_FORMAT() - external int AttributeFormat; -} - -typedef CSSM_DB_ATTRIBUTE_INFO = cssm_db_attribute_info; -typedef CSSM_DB_ATTRIBUTE_INFO_PTR = ffi.Pointer; - -final class cssm_db_attribute_data extends ffi.Struct { - external CSSM_DB_ATTRIBUTE_INFO Info; - - @uint32() - external int NumberOfValues; - - external CSSM_DATA_PTR Value; -} - -typedef CSSM_DB_ATTRIBUTE_DATA = cssm_db_attribute_data; -typedef CSSM_DB_ATTRIBUTE_DATA_PTR = ffi.Pointer; -typedef CSSM_DB_RECORDTYPE = uint32; - -final class cssm_db_record_attribute_info extends ffi.Struct { - @CSSM_DB_RECORDTYPE() - external int DataRecordType; - - @uint32() - external int NumberOfAttributes; - - external CSSM_DB_ATTRIBUTE_INFO_PTR AttributeInfo; -} - -typedef CSSM_DB_RECORD_ATTRIBUTE_INFO = cssm_db_record_attribute_info; -typedef CSSM_DB_RECORD_ATTRIBUTE_INFO_PTR = - ffi.Pointer; - -final class cssm_db_record_attribute_data extends ffi.Struct { - @CSSM_DB_RECORDTYPE() - external int DataRecordType; - - @uint32() - external int SemanticInformation; - - @uint32() - external int NumberOfAttributes; - - external CSSM_DB_ATTRIBUTE_DATA_PTR AttributeData; -} - -typedef CSSM_DB_RECORD_ATTRIBUTE_DATA = cssm_db_record_attribute_data; -typedef CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR = - ffi.Pointer; - -final class cssm_db_parsing_module_info extends ffi.Struct { - @CSSM_DB_RECORDTYPE() - external int RecordType; - - external CSSM_SUBSERVICE_UID ModuleSubserviceUid; -} - -typedef CSSM_DB_PARSING_MODULE_INFO = cssm_db_parsing_module_info; -typedef CSSM_DB_PARSING_MODULE_INFO_PTR = - ffi.Pointer; -typedef CSSM_DB_INDEX_TYPE = uint32; -typedef CSSM_DB_INDEXED_DATA_LOCATION = uint32; - -final class cssm_db_index_info extends ffi.Struct { - @CSSM_DB_INDEX_TYPE() - external int IndexType; - - @CSSM_DB_INDEXED_DATA_LOCATION() - external int IndexedDataLocation; - - external CSSM_DB_ATTRIBUTE_INFO Info; -} - -typedef CSSM_DB_INDEX_INFO = cssm_db_index_info; -typedef CSSM_DB_INDEX_INFO_PTR = ffi.Pointer; - -final class cssm_db_unique_record extends ffi.Struct { - external CSSM_DB_INDEX_INFO RecordLocator; - - external SecAsn1Item RecordIdentifier; -} - -typedef CSSM_DB_UNIQUE_RECORD = cssm_db_unique_record; -typedef CSSM_DB_UNIQUE_RECORD_PTR = ffi.Pointer; - -final class cssm_db_record_index_info extends ffi.Struct { - @CSSM_DB_RECORDTYPE() - external int DataRecordType; - - @uint32() - external int NumberOfIndexes; - - external CSSM_DB_INDEX_INFO_PTR IndexInfo; -} - -typedef CSSM_DB_RECORD_INDEX_INFO = cssm_db_record_index_info; -typedef CSSM_DB_RECORD_INDEX_INFO_PTR = ffi.Pointer; -typedef CSSM_DB_ACCESS_TYPE = uint32; -typedef CSSM_DB_ACCESS_TYPE_PTR = ffi.Pointer; -typedef CSSM_DB_MODIFY_MODE = uint32; - -final class cssm_dbinfo extends ffi.Struct { - @uint32() - external int NumberOfRecordTypes; - - external CSSM_DB_PARSING_MODULE_INFO_PTR DefaultParsingModules; - - external CSSM_DB_RECORD_ATTRIBUTE_INFO_PTR RecordAttributeNames; - - external CSSM_DB_RECORD_INDEX_INFO_PTR RecordIndexes; - - @CSSM_BOOL() - external int IsLocal; - - external ffi.Pointer AccessPath; - - external ffi.Pointer Reserved; -} - -typedef CSSM_DBINFO = cssm_dbinfo; -typedef CSSM_DBINFO_PTR = ffi.Pointer; -typedef CSSM_DB_OPERATOR = uint32; -typedef CSSM_DB_OPERATOR_PTR = ffi.Pointer; -typedef CSSM_DB_CONJUNCTIVE = uint32; -typedef CSSM_DB_CONJUNCTIVE_PTR = ffi.Pointer; - -final class cssm_selection_predicate extends ffi.Struct { - @CSSM_DB_OPERATOR() - external int DbOperator; - - external CSSM_DB_ATTRIBUTE_DATA Attribute; -} - -typedef CSSM_SELECTION_PREDICATE = cssm_selection_predicate; -typedef CSSM_SELECTION_PREDICATE_PTR = ffi.Pointer; - -final class cssm_query_limits extends ffi.Struct { - @uint32() - external int TimeLimit; - - @uint32() - external int SizeLimit; -} - -typedef CSSM_QUERY_LIMITS = cssm_query_limits; -typedef CSSM_QUERY_LIMITS_PTR = ffi.Pointer; -typedef CSSM_QUERY_FLAGS = uint32; - -final class cssm_query extends ffi.Struct { - @CSSM_DB_RECORDTYPE() - external int RecordType; - - @CSSM_DB_CONJUNCTIVE() - external int Conjunctive; - - @uint32() - external int NumSelectionPredicates; - - external CSSM_SELECTION_PREDICATE_PTR SelectionPredicate; - - external CSSM_QUERY_LIMITS QueryLimits; - - @CSSM_QUERY_FLAGS() - external int QueryFlags; -} - -typedef CSSM_QUERY = cssm_query; -typedef CSSM_QUERY_PTR = ffi.Pointer; -typedef CSSM_DLTYPE = uint32; -typedef CSSM_DLTYPE_PTR = ffi.Pointer; -typedef CSSM_DL_CUSTOM_ATTRIBUTES = ffi.Pointer; -typedef CSSM_DL_LDAP_ATTRIBUTES = ffi.Pointer; -typedef CSSM_DL_ODBC_ATTRIBUTES = ffi.Pointer; -typedef CSSM_DL_FFS_ATTRIBUTES = ffi.Pointer; - -final class cssm_dl_pkcs11_attributes extends ffi.Struct { - @uint32() - external int DeviceAccessFlags; -} - -typedef CSSM_DL_PKCS11_ATTRIBUTE = ffi.Pointer; -typedef CSSM_DL_PKCS11_ATTRIBUTE_PTR = ffi.Pointer; - -final class cssm_name_list extends ffi.Struct { - @uint32() - external int NumStrings; - - external ffi.Pointer> String; -} - -typedef CSSM_NAME_LIST = cssm_name_list; -typedef CSSM_NAME_LIST_PTR = ffi.Pointer; -typedef CSSM_DB_RETRIEVAL_MODES = uint32; - -final class cssm_db_schema_attribute_info extends ffi.Struct { - @uint32() - external int AttributeId; - - external ffi.Pointer AttributeName; - - external SecAsn1Oid AttributeNameID; - - @CSSM_DB_ATTRIBUTE_FORMAT() - external int DataType; -} - -typedef CSSM_DB_SCHEMA_ATTRIBUTE_INFO = cssm_db_schema_attribute_info; -typedef CSSM_DB_SCHEMA_ATTRIBUTE_INFO_PTR = - ffi.Pointer; - -final class cssm_db_schema_index_info extends ffi.Struct { - @uint32() - external int AttributeId; - - @uint32() - external int IndexId; - - @CSSM_DB_INDEX_TYPE() - external int IndexType; - - @CSSM_DB_INDEXED_DATA_LOCATION() - external int IndexedDataLocation; -} - -typedef CSSM_DB_SCHEMA_INDEX_INFO = cssm_db_schema_index_info; -typedef CSSM_DB_SCHEMA_INDEX_INFO_PTR = ffi.Pointer; -typedef CSSM_BER_TAG = uint8; -typedef CSSM_X509_ALGORITHM_IDENTIFIER_PTR = ffi.Pointer; - -final class cssm_x509_type_value_pair extends ffi.Struct { - external SecAsn1Oid type; - - @CSSM_BER_TAG() - external int valueType; - - external SecAsn1Item value; -} - -typedef CSSM_X509_TYPE_VALUE_PAIR = cssm_x509_type_value_pair; -typedef CSSM_X509_TYPE_VALUE_PAIR_PTR = ffi.Pointer; - -final class cssm_x509_rdn extends ffi.Struct { - @uint32() - external int numberOfPairs; - - external CSSM_X509_TYPE_VALUE_PAIR_PTR AttributeTypeAndValue; -} - -typedef CSSM_X509_RDN = cssm_x509_rdn; -typedef CSSM_X509_RDN_PTR = ffi.Pointer; - -final class cssm_x509_name extends ffi.Struct { - @uint32() - external int numberOfRDNs; - - external CSSM_X509_RDN_PTR RelativeDistinguishedName; -} - -typedef CSSM_X509_NAME = cssm_x509_name; -typedef CSSM_X509_NAME_PTR = ffi.Pointer; -typedef CSSM_X509_SUBJECT_PUBLIC_KEY_INFO_PTR = ffi.Pointer; - -final class cssm_x509_time extends ffi.Struct { - @CSSM_BER_TAG() - external int timeType; - - external SecAsn1Item time$1; -} - -typedef CSSM_X509_TIME = cssm_x509_time; -typedef CSSM_X509_TIME_PTR = ffi.Pointer; - -final class x509_validity extends ffi.Struct { - external CSSM_X509_TIME notBefore; - - external CSSM_X509_TIME notAfter; -} - -typedef CSSM_X509_VALIDITY = x509_validity; -typedef CSSM_X509_VALIDITY_PTR = ffi.Pointer; -typedef CSSM_X509_OPTION = CSSM_BOOL; - -final class cssm_x509ext_basicConstraints extends ffi.Struct { - @CSSM_BOOL() - external int cA; - - @CSSM_X509_OPTION() - external int pathLenConstraintPresent; - - @uint32() - external int pathLenConstraint; -} - -typedef CSSM_X509EXT_BASICCONSTRAINTS = cssm_x509ext_basicConstraints; -typedef CSSM_X509EXT_BASICCONSTRAINTS_PTR = - ffi.Pointer; - -enum extension_data_format { - CSSM_X509_DATAFORMAT_ENCODED(0), - CSSM_X509_DATAFORMAT_PARSED(1), - CSSM_X509_DATAFORMAT_PAIR(2); - - final int value; - const extension_data_format(this.value); - - static extension_data_format fromValue(int value) => switch (value) { - 0 => CSSM_X509_DATAFORMAT_ENCODED, - 1 => CSSM_X509_DATAFORMAT_PARSED, - 2 => CSSM_X509_DATAFORMAT_PAIR, - _ => throw ArgumentError('Unknown value for extension_data_format: $value'), - }; -} - -final class cssm_x509_extensionTagAndValue extends ffi.Struct { - @CSSM_BER_TAG() - external int type; - - external SecAsn1Item value; -} - -typedef CSSM_X509EXT_TAGandVALUE = cssm_x509_extensionTagAndValue; -typedef CSSM_X509EXT_TAGandVALUE_PTR = - ffi.Pointer; - -final class cssm_x509ext_pair extends ffi.Struct { - external CSSM_X509EXT_TAGandVALUE tagAndValue; - - external ffi.Pointer parsedValue; -} - -typedef CSSM_X509EXT_PAIR = cssm_x509ext_pair; -typedef CSSM_X509EXT_PAIR_PTR = ffi.Pointer; - -final class cssm_x509ext_value extends ffi.Union { - external ffi.Pointer tagAndValue; - - external ffi.Pointer parsedValue; - - external ffi.Pointer valuePair; -} - -final class cssm_x509_extension extends ffi.Struct { - external SecAsn1Oid extnId; - - @CSSM_BOOL() - external int critical; - - @ffi.UnsignedInt() - external int formatAsInt; - - extension_data_format get format => - extension_data_format.fromValue(formatAsInt); - - external cssm_x509ext_value value; - - external SecAsn1Item BERvalue; -} - -typedef CSSM_X509_EXTENSION = cssm_x509_extension; -typedef CSSM_X509_EXTENSION_PTR = ffi.Pointer; - -final class cssm_x509_extensions extends ffi.Struct { - @uint32() - external int numberOfExtensions; - - external CSSM_X509_EXTENSION_PTR extensions; -} - -typedef CSSM_X509_EXTENSIONS = cssm_x509_extensions; -typedef CSSM_X509_EXTENSIONS_PTR = ffi.Pointer; - -final class cssm_x509_tbs_certificate extends ffi.Struct { - external SecAsn1Item version; - - external SecAsn1Item serialNumber; - - external SecAsn1AlgId signature; - - external CSSM_X509_NAME issuer; - - external CSSM_X509_VALIDITY validity; - - external CSSM_X509_NAME subject; - - external SecAsn1PubKeyInfo subjectPublicKeyInfo; - - external SecAsn1Item issuerUniqueIdentifier; - - external SecAsn1Item subjectUniqueIdentifier; - - external CSSM_X509_EXTENSIONS extensions; -} - -typedef CSSM_X509_TBS_CERTIFICATE = cssm_x509_tbs_certificate; -typedef CSSM_X509_TBS_CERTIFICATE_PTR = ffi.Pointer; - -final class cssm_x509_signature extends ffi.Struct { - external SecAsn1AlgId algorithmIdentifier; - - external SecAsn1Item encrypted; -} - -typedef CSSM_X509_SIGNATURE = cssm_x509_signature; -typedef CSSM_X509_SIGNATURE_PTR = ffi.Pointer; - -final class cssm_x509_signed_certificate extends ffi.Struct { - external CSSM_X509_TBS_CERTIFICATE certificate; - - external CSSM_X509_SIGNATURE signature; -} - -typedef CSSM_X509_SIGNED_CERTIFICATE = cssm_x509_signed_certificate; -typedef CSSM_X509_SIGNED_CERTIFICATE_PTR = - ffi.Pointer; - -final class cssm_x509ext_policyQualifierInfo extends ffi.Struct { - external SecAsn1Oid policyQualifierId; - - external SecAsn1Item value; -} - -typedef CSSM_X509EXT_POLICYQUALIFIERINFO = cssm_x509ext_policyQualifierInfo; -typedef CSSM_X509EXT_POLICYQUALIFIERINFO_PTR = - ffi.Pointer; - -final class cssm_x509ext_policyQualifiers extends ffi.Struct { - @uint32() - external int numberOfPolicyQualifiers; - - external ffi.Pointer policyQualifier; -} - -typedef CSSM_X509EXT_POLICYQUALIFIERS = cssm_x509ext_policyQualifiers; -typedef CSSM_X509EXT_POLICYQUALIFIERS_PTR = - ffi.Pointer; - -final class cssm_x509ext_policyInfo extends ffi.Struct { - external SecAsn1Oid policyIdentifier; - - external CSSM_X509EXT_POLICYQUALIFIERS policyQualifiers; -} - -typedef CSSM_X509EXT_POLICYINFO = cssm_x509ext_policyInfo; -typedef CSSM_X509EXT_POLICYINFO_PTR = ffi.Pointer; - -final class cssm_x509_revoked_cert_entry extends ffi.Struct { - external SecAsn1Item certificateSerialNumber; - - external CSSM_X509_TIME revocationDate; - - external CSSM_X509_EXTENSIONS extensions; -} - -typedef CSSM_X509_REVOKED_CERT_ENTRY = cssm_x509_revoked_cert_entry; -typedef CSSM_X509_REVOKED_CERT_ENTRY_PTR = - ffi.Pointer; - -final class cssm_x509_revoked_cert_list extends ffi.Struct { - @uint32() - external int numberOfRevokedCertEntries; - - external CSSM_X509_REVOKED_CERT_ENTRY_PTR revokedCertEntry; -} - -typedef CSSM_X509_REVOKED_CERT_LIST = cssm_x509_revoked_cert_list; -typedef CSSM_X509_REVOKED_CERT_LIST_PTR = - ffi.Pointer; - -final class cssm_x509_tbs_certlist extends ffi.Struct { - external SecAsn1Item version; - - external SecAsn1AlgId signature; - - external CSSM_X509_NAME issuer; - - external CSSM_X509_TIME thisUpdate; - - external CSSM_X509_TIME nextUpdate; - - external CSSM_X509_REVOKED_CERT_LIST_PTR revokedCertificates; - - external CSSM_X509_EXTENSIONS extensions; -} - -typedef CSSM_X509_TBS_CERTLIST = cssm_x509_tbs_certlist; -typedef CSSM_X509_TBS_CERTLIST_PTR = ffi.Pointer; - -final class cssm_x509_signed_crl extends ffi.Struct { - external CSSM_X509_TBS_CERTLIST tbsCertList; - - external CSSM_X509_SIGNATURE signature; -} - -typedef CSSM_X509_SIGNED_CRL = cssm_x509_signed_crl; -typedef CSSM_X509_SIGNED_CRL_PTR = ffi.Pointer; - -enum __CE_GeneralNameType { - GNT_OtherName(0), - GNT_RFC822Name(1), - GNT_DNSName(2), - GNT_X400Address(3), - GNT_DirectoryName(4), - GNT_EdiPartyName(5), - GNT_URI(6), - GNT_IPAddress(7), - GNT_RegisteredID(8); - - final int value; - const __CE_GeneralNameType(this.value); - - static __CE_GeneralNameType fromValue(int value) => switch (value) { - 0 => GNT_OtherName, - 1 => GNT_RFC822Name, - 2 => GNT_DNSName, - 3 => GNT_X400Address, - 4 => GNT_DirectoryName, - 5 => GNT_EdiPartyName, - 6 => GNT_URI, - 7 => GNT_IPAddress, - 8 => GNT_RegisteredID, - _ => throw ArgumentError('Unknown value for __CE_GeneralNameType: $value'), - }; -} - -final class __CE_OtherName extends ffi.Struct { - external SecAsn1Oid typeId; - - external SecAsn1Item value; -} - -typedef CE_OtherName = __CE_OtherName; - -final class __CE_GeneralName extends ffi.Struct { - @ffi.UnsignedInt() - external int nameTypeAsInt; - - __CE_GeneralNameType get nameType => - __CE_GeneralNameType.fromValue(nameTypeAsInt); - - @CSSM_BOOL() - external int berEncoded; - - external SecAsn1Item name; -} - -typedef CE_GeneralName = __CE_GeneralName; - -final class __CE_GeneralNames extends ffi.Struct { - @uint32() - external int numNames; - - external ffi.Pointer generalName; -} - -typedef CE_GeneralNames = __CE_GeneralNames; - -final class __CE_AuthorityKeyID extends ffi.Struct { - @CSSM_BOOL() - external int keyIdentifierPresent; - - external SecAsn1Item keyIdentifier; - - @CSSM_BOOL() - external int generalNamesPresent; - - external ffi.Pointer generalNames; - - @CSSM_BOOL() - external int serialNumberPresent; - - external SecAsn1Item serialNumber; -} - -typedef CE_AuthorityKeyID = __CE_AuthorityKeyID; -typedef CE_SubjectKeyID = SecAsn1Item; -typedef CE_KeyUsage = uint16; -typedef CE_CrlReason = uint32; - -final class __CE_ExtendedKeyUsage extends ffi.Struct { - @uint32() - external int numPurposes; - - external CSSM_OID_PTR purposes; -} - -typedef CE_ExtendedKeyUsage = __CE_ExtendedKeyUsage; - -final class __CE_BasicConstraints extends ffi.Struct { - @CSSM_BOOL() - external int cA; - - @CSSM_BOOL() - external int pathLenConstraintPresent; - - @uint32() - external int pathLenConstraint; -} - -typedef CE_BasicConstraints = __CE_BasicConstraints; - -final class __CE_PolicyQualifierInfo extends ffi.Struct { - external SecAsn1Oid policyQualifierId; - - external SecAsn1Item qualifier; -} - -typedef CE_PolicyQualifierInfo = __CE_PolicyQualifierInfo; - -final class __CE_PolicyInformation extends ffi.Struct { - external SecAsn1Oid certPolicyId; - - @uint32() - external int numPolicyQualifiers; - - external ffi.Pointer policyQualifiers; -} - -typedef CE_PolicyInformation = __CE_PolicyInformation; - -final class __CE_CertPolicies extends ffi.Struct { - @uint32() - external int numPolicies; - - external ffi.Pointer policies; -} - -typedef CE_CertPolicies = __CE_CertPolicies; -typedef CE_NetscapeCertType = uint16; -typedef CE_CrlDistReasonFlags = uint8; - -enum __CE_CrlDistributionPointNameType { - CE_CDNT_FullName(0), - CE_CDNT_NameRelativeToCrlIssuer(1); - - final int value; - const __CE_CrlDistributionPointNameType(this.value); - - static __CE_CrlDistributionPointNameType fromValue(int value) => - switch (value) { - 0 => CE_CDNT_FullName, - 1 => CE_CDNT_NameRelativeToCrlIssuer, - _ => throw ArgumentError( - 'Unknown value for __CE_CrlDistributionPointNameType: $value', - ), - }; -} - -final class UnnamedUnion extends ffi.Union { - external ffi.Pointer fullName; - - external CSSM_X509_RDN_PTR rdn; -} - -final class __CE_DistributionPointName extends ffi.Struct { - @ffi.UnsignedInt() - external int nameTypeAsInt; - - __CE_CrlDistributionPointNameType get nameType => - __CE_CrlDistributionPointNameType.fromValue(nameTypeAsInt); - - external UnnamedUnion dpn; -} - -typedef CE_DistributionPointName = __CE_DistributionPointName; - -final class __CE_CRLDistributionPoint extends ffi.Struct { - external ffi.Pointer distPointName; - - @CSSM_BOOL() - external int reasonsPresent; - - @CE_CrlDistReasonFlags() - external int reasons; - - external ffi.Pointer crlIssuer; -} - -typedef CE_CRLDistributionPoint = __CE_CRLDistributionPoint; - -final class __CE_CRLDistPointsSyntax extends ffi.Struct { - @uint32() - external int numDistPoints; - - external ffi.Pointer distPoints; -} - -typedef CE_CRLDistPointsSyntax = __CE_CRLDistPointsSyntax; - -final class __CE_AccessDescription extends ffi.Struct { - external SecAsn1Oid accessMethod; - - external CE_GeneralName accessLocation; -} - -typedef CE_AccessDescription = __CE_AccessDescription; - -final class __CE_AuthorityInfoAccess extends ffi.Struct { - @uint32() - external int numAccessDescriptions; - - external ffi.Pointer accessDescriptions; -} - -typedef CE_AuthorityInfoAccess = __CE_AuthorityInfoAccess; -typedef CE_NameRegistrationAuthorities = CE_GeneralNames; - -final class __CE_SemanticsInformation extends ffi.Struct { - external ffi.Pointer semanticsIdentifier; - - external ffi.Pointer - nameRegistrationAuthorities; -} - -typedef CE_SemanticsInformation = __CE_SemanticsInformation; - -final class __CE_QC_Statement extends ffi.Struct { - external SecAsn1Oid statementId; - - external ffi.Pointer semanticsInfo; - - external ffi.Pointer otherInfo; -} - -typedef CE_QC_Statement = __CE_QC_Statement; - -final class __CE_QC_Statements extends ffi.Struct { - @uint32() - external int numQCStatements; - - external ffi.Pointer qcStatements; -} - -typedef CE_QC_Statements = __CE_QC_Statements; -typedef CE_CrlNumber = uint32; -typedef CE_DeltaCrl = uint32; - -final class __CE_IssuingDistributionPoint extends ffi.Struct { - external ffi.Pointer distPointName; - - @CSSM_BOOL() - external int onlyUserCertsPresent; - - @CSSM_BOOL() - external int onlyUserCerts; - - @CSSM_BOOL() - external int onlyCACertsPresent; - - @CSSM_BOOL() - external int onlyCACerts; - - @CSSM_BOOL() - external int onlySomeReasonsPresent; - - @CE_CrlDistReasonFlags() - external int onlySomeReasons; - - @CSSM_BOOL() - external int indirectCrlPresent; - - @CSSM_BOOL() - external int indirectCrl; -} - -typedef CE_IssuingDistributionPoint = __CE_IssuingDistributionPoint; - -final class __CE_GeneralSubtree extends ffi.Struct { - external ffi.Pointer base; - - @uint32() - external int minimum; - - @CSSM_BOOL() - external int maximumPresent; - - @uint32() - external int maximum; -} - -typedef CE_GeneralSubtree = __CE_GeneralSubtree; - -final class __CE_GeneralSubtrees extends ffi.Struct { - @uint32() - external int numSubtrees; - - external ffi.Pointer subtrees; -} - -typedef CE_GeneralSubtrees = __CE_GeneralSubtrees; - -final class __CE_NameConstraints extends ffi.Struct { - external ffi.Pointer permitted; - - external ffi.Pointer excluded; -} - -typedef CE_NameConstraints = __CE_NameConstraints; - -final class __CE_PolicyMapping extends ffi.Struct { - external SecAsn1Oid issuerDomainPolicy; - - external SecAsn1Oid subjectDomainPolicy; -} - -typedef CE_PolicyMapping = __CE_PolicyMapping; - -final class __CE_PolicyMappings extends ffi.Struct { - @uint32() - external int numPolicyMappings; - - external ffi.Pointer policyMappings; -} - -typedef CE_PolicyMappings = __CE_PolicyMappings; - -final class __CE_PolicyConstraints extends ffi.Struct { - @CSSM_BOOL() - external int requireExplicitPolicyPresent; - - @uint32() - external int requireExplicitPolicy; - - @CSSM_BOOL() - external int inhibitPolicyMappingPresent; - - @uint32() - external int inhibitPolicyMapping; -} - -typedef CE_PolicyConstraints = __CE_PolicyConstraints; -typedef CE_InhibitAnyPolicy = uint32; - -enum __CE_DataType { - DT_AuthorityKeyID(0), - DT_SubjectKeyID(1), - DT_KeyUsage(2), - DT_SubjectAltName(3), - DT_IssuerAltName(4), - DT_ExtendedKeyUsage(5), - DT_BasicConstraints(6), - DT_CertPolicies(7), - DT_NetscapeCertType(8), - DT_CrlNumber(9), - DT_DeltaCrl(10), - DT_CrlReason(11), - DT_CrlDistributionPoints(12), - DT_IssuingDistributionPoint(13), - DT_AuthorityInfoAccess(14), - DT_Other(15), - DT_QC_Statements(16), - DT_NameConstraints(17), - DT_PolicyMappings(18), - DT_PolicyConstraints(19), - DT_InhibitAnyPolicy(20); - - final int value; - const __CE_DataType(this.value); - - static __CE_DataType fromValue(int value) => switch (value) { - 0 => DT_AuthorityKeyID, - 1 => DT_SubjectKeyID, - 2 => DT_KeyUsage, - 3 => DT_SubjectAltName, - 4 => DT_IssuerAltName, - 5 => DT_ExtendedKeyUsage, - 6 => DT_BasicConstraints, - 7 => DT_CertPolicies, - 8 => DT_NetscapeCertType, - 9 => DT_CrlNumber, - 10 => DT_DeltaCrl, - 11 => DT_CrlReason, - 12 => DT_CrlDistributionPoints, - 13 => DT_IssuingDistributionPoint, - 14 => DT_AuthorityInfoAccess, - 15 => DT_Other, - 16 => DT_QC_Statements, - 17 => DT_NameConstraints, - 18 => DT_PolicyMappings, - 19 => DT_PolicyConstraints, - 20 => DT_InhibitAnyPolicy, - _ => throw ArgumentError('Unknown value for __CE_DataType: $value'), - }; -} - -final class CE_Data extends ffi.Union { - external CE_AuthorityKeyID authorityKeyID; - - external CE_SubjectKeyID subjectKeyID; - - @CE_KeyUsage() - external int keyUsage; - - external CE_GeneralNames subjectAltName; - - external CE_GeneralNames issuerAltName; - - external CE_ExtendedKeyUsage extendedKeyUsage; - - external CE_BasicConstraints basicConstraints; - - external CE_CertPolicies certPolicies; - - @CE_NetscapeCertType() - external int netscapeCertType; - - @CE_CrlNumber() - external int crlNumber; - - @CE_DeltaCrl() - external int deltaCrl; - - @CE_CrlReason() - external int crlReason; - - external CE_CRLDistPointsSyntax crlDistPoints; - - external CE_IssuingDistributionPoint issuingDistPoint; - - external CE_AuthorityInfoAccess authorityInfoAccess; - - external CE_QC_Statements qualifiedCertStatements; - - external CE_NameConstraints nameConstraints; - - external CE_PolicyMappings policyMappings; - - external CE_PolicyConstraints policyConstraints; - - @CE_InhibitAnyPolicy() - external int inhibitAnyPolicy; - - external SecAsn1Item rawData; -} - -final class __CE_DataAndType extends ffi.Struct { - @ffi.UnsignedInt() - external int typeAsInt; - - __CE_DataType get type => __CE_DataType.fromValue(typeAsInt); - - external CE_Data extension; - - @CSSM_BOOL() - external int critical; -} - -typedef CE_DataAndType = __CE_DataAndType; - -final class cssm_acl_process_subject_selector extends ffi.Struct { - @uint16() - external int version; - - @uint16() - external int mask; - - @uint32() - external int uid; - - @uint32() - external int gid; -} - -typedef CSSM_ACL_PROCESS_SUBJECT_SELECTOR = cssm_acl_process_subject_selector; - -final class cssm_acl_keychain_prompt_selector extends ffi.Struct { - @uint16() - external int version; - - @uint16() - external int flags; -} - -typedef CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR = cssm_acl_keychain_prompt_selector; -typedef CSSM_ACL_PREAUTH_TRACKING_STATE = uint32; - -final class cssm_appledl_open_parameters extends ffi.Struct { - @uint32() - external int length; - - @uint32() - external int version; - - @CSSM_BOOL() - external int autoCommit; - - @uint32() - external int mask; - - @mode_t() - external int mode; -} - -typedef CSSM_APPLEDL_OPEN_PARAMETERS = cssm_appledl_open_parameters; -typedef CSSM_APPLEDL_OPEN_PARAMETERS_PTR = - ffi.Pointer; - -final class cssm_applecspdl_db_settings_parameters extends ffi.Struct { - @uint32() - external int idleTimeout; - - @uint8() - external int lockOnSleep; -} - -typedef CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS = - cssm_applecspdl_db_settings_parameters; -typedef CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR = - ffi.Pointer; - -final class cssm_applecspdl_db_is_locked_parameters extends ffi.Struct { - @uint8() - external int isLocked; -} - -typedef CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS = - cssm_applecspdl_db_is_locked_parameters; -typedef CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR = - ffi.Pointer; - -final class cssm_applecspdl_db_change_password_parameters extends ffi.Struct { - external ffi.Pointer accessCredentials; -} - -typedef CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS = - cssm_applecspdl_db_change_password_parameters; -typedef CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS_PTR = - ffi.Pointer; - -final class CSSM_APPLE_TP_NAME_OID extends ffi.Struct { - external ffi.Pointer string; - - external ffi.Pointer oid; -} - -final class CSSM_APPLE_TP_CERT_REQUEST extends ffi.Struct { - @CSSM_CSP_HANDLE() - external int cspHand; - - @CSSM_CL_HANDLE() - external int clHand; - - @uint32() - external int serialNumber; - - @uint32() - external int numSubjectNames; - - external ffi.Pointer subjectNames; - - @uint32() - external int numIssuerNames; - - external ffi.Pointer issuerNames; - - external CSSM_X509_NAME_PTR issuerNameX509; - - external ffi.Pointer certPublicKey; - - external ffi.Pointer issuerPrivateKey; - - @CSSM_ALGORITHMS() - external int signatureAlg; - - external SecAsn1Oid signatureOid; - - @uint32() - external int notBefore; - - @uint32() - external int notAfter; - - @uint32() - external int numExtensions; - - external ffi.Pointer extensions; - - external ffi.Pointer challengeString; -} - -final class CSSM_APPLE_TP_SSL_OPTIONS extends ffi.Struct { - @uint32() - external int Version; - - @uint32() - external int ServerNameLen; - - external ffi.Pointer ServerName; - - @uint32() - external int Flags; -} - -typedef CSSM_APPLE_TP_CRL_OPT_FLAGS = uint32; - -final class CSSM_APPLE_TP_CRL_OPTIONS extends ffi.Struct { - @uint32() - external int Version; - - @CSSM_APPLE_TP_CRL_OPT_FLAGS() - external int CrlFlags; - - external CSSM_DL_DB_HANDLE_PTR crlStore; -} - -final class CSSM_APPLE_TP_SMIME_OPTIONS extends ffi.Struct { - @uint32() - external int Version; - - @CE_KeyUsage() - external int IntendedUsage; - - @uint32() - external int SenderEmailLen; - - external ffi.Pointer SenderEmail; -} - -typedef CSSM_APPLE_TP_ACTION_FLAGS = uint32; - -final class CSSM_APPLE_TP_ACTION_DATA extends ffi.Struct { - @uint32() - external int Version; - - @CSSM_APPLE_TP_ACTION_FLAGS() - external int ActionFlags; -} - -typedef CSSM_TP_APPLE_CERT_STATUS = uint32; - -final class CSSM_TP_APPLE_EVIDENCE_INFO extends ffi.Struct { - @CSSM_TP_APPLE_CERT_STATUS() - external int StatusBits; - - @uint32() - external int NumStatusCodes; - - external ffi.Pointer StatusCodes; - - @uint32() - external int Index; - - external CSSM_DL_DB_HANDLE DlDbHandle; - - external CSSM_DB_UNIQUE_RECORD_PTR UniqueRecord; -} - -final class CSSM_TP_APPLE_EVIDENCE_HEADER extends ffi.Struct { - @uint32() - external int Version; -} - -final class CSSM_APPLE_CL_CSR_REQUEST extends ffi.Struct { - external CSSM_X509_NAME_PTR subjectNameX509; - - @CSSM_ALGORITHMS() - external int signatureAlg; - - external SecAsn1Oid signatureOid; - - @CSSM_CSP_HANDLE() - external int cspHand; - - external ffi.Pointer subjectPublicKey; - - external ffi.Pointer subjectPrivateKey; - - external ffi.Pointer challengeString; -} - -enum SecTrustResultType { - kSecTrustResultInvalid(0), - kSecTrustResultProceed(1), - kSecTrustResultConfirm(2), - kSecTrustResultDeny(3), - kSecTrustResultUnspecified(4), - kSecTrustResultRecoverableTrustFailure(5), - kSecTrustResultFatalTrustFailure(6), - kSecTrustResultOtherError(7); - - final int value; - const SecTrustResultType(this.value); - - static SecTrustResultType fromValue(int value) => switch (value) { - 0 => kSecTrustResultInvalid, - 1 => kSecTrustResultProceed, - 2 => kSecTrustResultConfirm, - 3 => kSecTrustResultDeny, - 4 => kSecTrustResultUnspecified, - 5 => kSecTrustResultRecoverableTrustFailure, - 6 => kSecTrustResultFatalTrustFailure, - 7 => kSecTrustResultOtherError, - _ => throw ArgumentError('Unknown value for SecTrustResultType: $value'), - }; -} - -final class __SecTrust extends ffi.Opaque {} - -typedef SecTrustRef = ffi.Pointer<__SecTrust>; - -/// Construction methods for `objc.ObjCBlock, ffi.Uint32)>`. -abstract final class ObjCBlock_ffiVoid_SecTrustRef_SecTrustResultType { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock, ffi.Uint32)> - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock, ffi.Uint32)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock, ffi.Uint32)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction - > - ptr, - ) => objc.ObjCBlock, ffi.Uint32)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock, ffi.Uint32)> - fromFunction( - void Function(SecTrustRef, SecTrustResultType) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock, ffi.Uint32)>( - objc.newClosureBlock( - _closureCallable, - (SecTrustRef arg0, int arg1) => - fn(arg0, SecTrustResultType.fromValue(arg1)), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock, ffi.Uint32)> - listener( - void Function(SecTrustRef, SecTrustResultType) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (SecTrustRef arg0, int arg1) => - fn(arg0, SecTrustResultType.fromValue(arg1)), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_gwxhxt(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__SecTrust>, ffi.Uint32) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock, ffi.Uint32)> - blocking( - void Function(SecTrustRef, SecTrustResultType) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (SecTrustRef arg0, int arg1) => - fn(arg0, SecTrustResultType.fromValue(arg1)), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (SecTrustRef arg0, int arg1) => - fn(arg0, SecTrustResultType.fromValue(arg1)), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_gwxhxt( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__SecTrust>, ffi.Uint32) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - SecTrustRef arg0, - int arg1, - ) { - (objc.getBlockClosure(block) as void Function(SecTrustRef, int))( - arg0, - arg1, - ); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, SecTrustRef, ffi.Uint32) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - SecTrustRef, - ffi.Uint32, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - SecTrustRef arg0, - int arg1, - ) { - try { - (objc.getBlockClosure(block) as void Function(SecTrustRef, int))( - arg0, - arg1, - ); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - SecTrustRef, - ffi.Uint32, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - SecTrustRef, - ffi.Uint32, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - SecTrustRef, - ffi.Uint32, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - SecTrustRef, - ffi.Uint32, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - SecTrustRef arg0, - int arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction - >() - .asFunction()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - SecTrustRef, - ffi.Uint32, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - SecTrustRef arg0, - int arg1, - ) => (objc.getBlockClosure(block) as void Function(SecTrustRef, int))( - arg0, - arg1, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - SecTrustRef, - ffi.Uint32, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, ffi.Uint32)>`. -extension ObjCBlock_ffiVoid_SecTrustRef_SecTrustResultType$CallExtension - on objc.ObjCBlock, ffi.Uint32)> { - void call(SecTrustRef arg0, SecTrustResultType arg1) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - SecTrustRef arg0, - ffi.Uint32 arg1, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, SecTrustRef, int) - >()(ref.pointer, arg0, arg1.value); -} - -typedef SecTrustCallback = ffi.Pointer; -typedef DartSecTrustCallback = - objc.ObjCBlock, ffi.Uint32)>; - -/// Construction methods for `objc.ObjCBlock, ffi.Bool, ffi.Pointer<__CFError>)>`. -abstract final class ObjCBlock_ffiVoid_SecTrustRef_bool_CFErrorRef { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__SecTrust>, ffi.Bool, ffi.Pointer<__CFError>) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer<__SecTrust>, - ffi.Bool, - ffi.Pointer<__CFError>, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__SecTrust>, ffi.Bool, ffi.Pointer<__CFError>) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(SecTrustRef arg0, ffi.Bool arg1, CFErrorRef arg2) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer<__SecTrust>, - ffi.Bool, - ffi.Pointer<__CFError>, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__SecTrust>, ffi.Bool, ffi.Pointer<__CFError>) - > - fromFunction( - void Function(SecTrustRef, bool, CFErrorRef) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer<__SecTrust>, - ffi.Bool, - ffi.Pointer<__CFError>, - ) - >( - objc.newClosureBlock( - _closureCallable, - (SecTrustRef arg0, bool arg1, CFErrorRef arg2) => - fn(arg0, arg1, arg2), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__SecTrust>, ffi.Bool, ffi.Pointer<__CFError>) - > - listener( - void Function(SecTrustRef, bool, CFErrorRef) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (SecTrustRef arg0, bool arg1, CFErrorRef arg2) => fn(arg0, arg1, arg2), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_k73ff5(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer<__SecTrust>, - ffi.Bool, - ffi.Pointer<__CFError>, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer<__SecTrust>, ffi.Bool, ffi.Pointer<__CFError>) - > - blocking( - void Function(SecTrustRef, bool, CFErrorRef) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (SecTrustRef arg0, bool arg1, CFErrorRef arg2) => fn(arg0, arg1, arg2), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (SecTrustRef arg0, bool arg1, CFErrorRef arg2) => fn(arg0, arg1, arg2), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_k73ff5( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer<__SecTrust>, - ffi.Bool, - ffi.Pointer<__CFError>, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - SecTrustRef arg0, - bool arg1, - CFErrorRef arg2, - ) { - (objc.getBlockClosure(block) - as void Function(SecTrustRef, bool, CFErrorRef))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - SecTrustRef, - ffi.Bool, - CFErrorRef, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - SecTrustRef, - ffi.Bool, - CFErrorRef, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - SecTrustRef arg0, - bool arg1, - CFErrorRef arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function(SecTrustRef, bool, CFErrorRef))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - SecTrustRef, - ffi.Bool, - CFErrorRef, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - SecTrustRef, - ffi.Bool, - CFErrorRef, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - SecTrustRef, - ffi.Bool, - CFErrorRef, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - SecTrustRef, - ffi.Bool, - CFErrorRef, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - SecTrustRef arg0, - bool arg1, - CFErrorRef arg2, - ) => - block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - SecTrustRef arg0, - ffi.Bool arg1, - CFErrorRef arg2, - ) - > - >() - .asFunction()( - arg0, - arg1, - arg2, - ); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - SecTrustRef, - ffi.Bool, - CFErrorRef, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - SecTrustRef arg0, - bool arg1, - CFErrorRef arg2, - ) => - (objc.getBlockClosure(block) - as void Function(SecTrustRef, bool, CFErrorRef))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - SecTrustRef, - ffi.Bool, - CFErrorRef, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, ffi.Bool, ffi.Pointer<__CFError>)>`. -extension ObjCBlock_ffiVoid_SecTrustRef_bool_CFErrorRef$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer<__SecTrust>, - ffi.Bool, - ffi.Pointer<__CFError>, - ) - > { - void call(SecTrustRef arg0, bool arg1, CFErrorRef arg2) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - SecTrustRef arg0, - ffi.Bool arg1, - CFErrorRef arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - SecTrustRef, - bool, - CFErrorRef, - ) - >()(ref.pointer, arg0, arg1, arg2); -} - -typedef SecTrustWithErrorCallback = ffi.Pointer; -typedef DartSecTrustWithErrorCallback = - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer<__SecTrust>, - ffi.Bool, - ffi.Pointer<__CFError>, - ) - >; - -sealed class SecTrustOptionFlags { - static const kSecTrustOptionAllowExpired = 1; - static const kSecTrustOptionLeafIsCA = 2; - static const kSecTrustOptionFetchIssuerFromNet = 4; - static const kSecTrustOptionAllowExpiredRoot = 8; - static const kSecTrustOptionRequireRevPerCert = 16; - static const kSecTrustOptionUseTrustSettings = 32; - static const kSecTrustOptionImplicitAnchors = 64; -} - -typedef SSLCipherSuite = ffi.Uint16; -typedef DartSSLCipherSuite = int; - -enum SSLCiphersuiteGroup { - kSSLCiphersuiteGroupDefault(0), - kSSLCiphersuiteGroupCompatibility(1), - kSSLCiphersuiteGroupLegacy(2), - kSSLCiphersuiteGroupATS(3), - kSSLCiphersuiteGroupATSCompatibility(4); - - final int value; - const SSLCiphersuiteGroup(this.value); - - static SSLCiphersuiteGroup fromValue(int value) => switch (value) { - 0 => kSSLCiphersuiteGroupDefault, - 1 => kSSLCiphersuiteGroupCompatibility, - 2 => kSSLCiphersuiteGroupLegacy, - 3 => kSSLCiphersuiteGroupATS, - 4 => kSSLCiphersuiteGroupATSCompatibility, - _ => throw ArgumentError('Unknown value for SSLCiphersuiteGroup: $value'), - }; -} - -typedef sec_trust_t = ffi.Pointer; -typedef Dartsec_trust_t = objc.NSObject; -typedef sec_identity_t = ffi.Pointer; -typedef Dartsec_identity_t = objc.NSObject; -typedef sec_certificate_t = ffi.Pointer; -typedef Dartsec_certificate_t = objc.NSObject; - -enum tls_protocol_version_t { - tls_protocol_version_TLSv10(769), - tls_protocol_version_TLSv11(770), - tls_protocol_version_TLSv12(771), - tls_protocol_version_TLSv13(772), - tls_protocol_version_DTLSv10(-257), - tls_protocol_version_DTLSv12(-259); - - final int value; - const tls_protocol_version_t(this.value); - - static tls_protocol_version_t fromValue(int value) => switch (value) { - 769 => tls_protocol_version_TLSv10, - 770 => tls_protocol_version_TLSv11, - 771 => tls_protocol_version_TLSv12, - 772 => tls_protocol_version_TLSv13, - -257 => tls_protocol_version_DTLSv10, - -259 => tls_protocol_version_DTLSv12, - _ => throw ArgumentError( - 'Unknown value for tls_protocol_version_t: $value', - ), - }; -} - -enum tls_ciphersuite_t { - tls_ciphersuite_RSA_WITH_3DES_EDE_CBC_SHA(10), - tls_ciphersuite_RSA_WITH_AES_128_CBC_SHA(47), - tls_ciphersuite_RSA_WITH_AES_256_CBC_SHA(53), - tls_ciphersuite_RSA_WITH_AES_128_GCM_SHA256(156), - tls_ciphersuite_RSA_WITH_AES_256_GCM_SHA384(157), - tls_ciphersuite_RSA_WITH_AES_128_CBC_SHA256(60), - tls_ciphersuite_RSA_WITH_AES_256_CBC_SHA256(61), - tls_ciphersuite_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA(-16376), - tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_CBC_SHA(-16375), - tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_CBC_SHA(-16374), - tls_ciphersuite_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA(-16366), - tls_ciphersuite_ECDHE_RSA_WITH_AES_128_CBC_SHA(-16365), - tls_ciphersuite_ECDHE_RSA_WITH_AES_256_CBC_SHA(-16364), - tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256(-16349), - tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384(-16348), - tls_ciphersuite_ECDHE_RSA_WITH_AES_128_CBC_SHA256(-16345), - tls_ciphersuite_ECDHE_RSA_WITH_AES_256_CBC_SHA384(-16344), - tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256(-16341), - tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384(-16340), - tls_ciphersuite_ECDHE_RSA_WITH_AES_128_GCM_SHA256(-16337), - tls_ciphersuite_ECDHE_RSA_WITH_AES_256_GCM_SHA384(-16336), - tls_ciphersuite_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256(-13144), - tls_ciphersuite_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256(-13143), - tls_ciphersuite_AES_128_GCM_SHA256(4865), - tls_ciphersuite_AES_256_GCM_SHA384(4866), - tls_ciphersuite_CHACHA20_POLY1305_SHA256(4867); - - final int value; - const tls_ciphersuite_t(this.value); - - static tls_ciphersuite_t fromValue(int value) => switch (value) { - 10 => tls_ciphersuite_RSA_WITH_3DES_EDE_CBC_SHA, - 47 => tls_ciphersuite_RSA_WITH_AES_128_CBC_SHA, - 53 => tls_ciphersuite_RSA_WITH_AES_256_CBC_SHA, - 156 => tls_ciphersuite_RSA_WITH_AES_128_GCM_SHA256, - 157 => tls_ciphersuite_RSA_WITH_AES_256_GCM_SHA384, - 60 => tls_ciphersuite_RSA_WITH_AES_128_CBC_SHA256, - 61 => tls_ciphersuite_RSA_WITH_AES_256_CBC_SHA256, - -16376 => tls_ciphersuite_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, - -16375 => tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - -16374 => tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - -16366 => tls_ciphersuite_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - -16365 => tls_ciphersuite_ECDHE_RSA_WITH_AES_128_CBC_SHA, - -16364 => tls_ciphersuite_ECDHE_RSA_WITH_AES_256_CBC_SHA, - -16349 => tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, - -16348 => tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, - -16345 => tls_ciphersuite_ECDHE_RSA_WITH_AES_128_CBC_SHA256, - -16344 => tls_ciphersuite_ECDHE_RSA_WITH_AES_256_CBC_SHA384, - -16341 => tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, - -16340 => tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, - -16337 => tls_ciphersuite_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - -16336 => tls_ciphersuite_ECDHE_RSA_WITH_AES_256_GCM_SHA384, - -13144 => tls_ciphersuite_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, - -13143 => tls_ciphersuite_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, - 4865 => tls_ciphersuite_AES_128_GCM_SHA256, - 4866 => tls_ciphersuite_AES_256_GCM_SHA384, - 4867 => tls_ciphersuite_CHACHA20_POLY1305_SHA256, - _ => throw ArgumentError('Unknown value for tls_ciphersuite_t: $value'), - }; -} - -enum tls_ciphersuite_group_t { - tls_ciphersuite_group_default(0), - tls_ciphersuite_group_compatibility(1), - tls_ciphersuite_group_legacy(2), - tls_ciphersuite_group_ats(3), - tls_ciphersuite_group_ats_compatibility(4); - - final int value; - const tls_ciphersuite_group_t(this.value); - - static tls_ciphersuite_group_t fromValue(int value) => switch (value) { - 0 => tls_ciphersuite_group_default, - 1 => tls_ciphersuite_group_compatibility, - 2 => tls_ciphersuite_group_legacy, - 3 => tls_ciphersuite_group_ats, - 4 => tls_ciphersuite_group_ats_compatibility, - _ => throw ArgumentError( - 'Unknown value for tls_ciphersuite_group_t: $value', - ), - }; -} - -enum SSLProtocol { - kSSLProtocolUnknown(0), - kTLSProtocol1(4), - kTLSProtocol11(7), - kTLSProtocol12(8), - kDTLSProtocol1(9), - kTLSProtocol13(10), - kDTLSProtocol12(11), - kTLSProtocolMaxSupported(999), - kSSLProtocol2(1), - kSSLProtocol3(2), - kSSLProtocol3Only(3), - kTLSProtocol1Only(5), - kSSLProtocolAll(6); - - final int value; - const SSLProtocol(this.value); - - static SSLProtocol fromValue(int value) => switch (value) { - 0 => kSSLProtocolUnknown, - 4 => kTLSProtocol1, - 7 => kTLSProtocol11, - 8 => kTLSProtocol12, - 9 => kDTLSProtocol1, - 10 => kTLSProtocol13, - 11 => kDTLSProtocol12, - 999 => kTLSProtocolMaxSupported, - 1 => kSSLProtocol2, - 2 => kSSLProtocol3, - 3 => kSSLProtocol3Only, - 5 => kTLSProtocol1Only, - 6 => kSSLProtocolAll, - _ => throw ArgumentError('Unknown value for SSLProtocol: $value'), - }; -} - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_seccertificatet { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer> - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(Dartsec_certificate_t) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (sec_certificate_t arg0) => - fn(objc.NSObject.fromPointer(arg0, retain: true, release: true)), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(Dartsec_certificate_t) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (sec_certificate_t arg0) => - fn(objc.NSObject.fromPointer(arg0, retain: false, release: true)), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(Dartsec_certificate_t) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (sec_certificate_t arg0) => - fn(objc.NSObject.fromPointer(arg0, retain: false, release: true)), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (sec_certificate_t arg0) => - fn(objc.NSObject.fromPointer(arg0, retain: false, release: true)), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - sec_certificate_t arg0, - ) { - (objc.getBlockClosure(block) as void Function(sec_certificate_t))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, sec_certificate_t) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, sec_certificate_t) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - sec_certificate_t arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(sec_certificate_t))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_certificate_t, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_certificate_t, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_certificate_t, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_certificate_t, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - sec_certificate_t arg0, - ) => block.ref.target - .cast>() - .asFunction()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_certificate_t, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - sec_certificate_t arg0, - ) => (objc.getBlockClosure(block) as void Function(sec_certificate_t))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_certificate_t, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_seccertificatet$CallExtension - on objc.ObjCBlock { - void call(Dartsec_certificate_t arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - sec_certificate_t arg0, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, sec_certificate_t) - >()(ref.pointer, arg0.ref.pointer); -} - -typedef sec_protocol_metadata_t = ffi.Pointer; -typedef Dartsec_protocol_metadata_t = objc.NSObject; - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_Uint16 { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer> ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (int arg0) => fn(arg0), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_15f11yh(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(int) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (int arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_15f11yh( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - int arg0, - ) { - (objc.getBlockClosure(block) as void Function(int))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Uint16) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Uint16) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - int arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(int))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint16, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint16, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint16, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint16, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - int arg0, - ) => block.ref.target - .cast>() - .asFunction()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Uint16) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - int arg0, - ) => (objc.getBlockClosure(block) as void Function(int))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Uint16) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_Uint16$CallExtension - on objc.ObjCBlock { - void call(int arg0) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Uint16 arg0, - ) - > - >() - .asFunction, int)>()( - ref.pointer, - arg0, - ); -} - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_dispatchdatat_dispatchdatat { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(dispatch_data_t arg0, dispatch_data_t arg1) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - fromFunction( - void Function(Dartdispatch_data_t, Dartdispatch_data_t) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (dispatch_data_t arg0, dispatch_data_t arg1) => fn( - objc.NSObject.fromPointer(arg0, retain: true, release: true), - objc.NSObject.fromPointer(arg1, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - listener( - void Function(Dartdispatch_data_t, Dartdispatch_data_t) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (dispatch_data_t arg0, dispatch_data_t arg1) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - objc.NSObject.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_pfv6jd(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock - blocking( - void Function(Dartdispatch_data_t, Dartdispatch_data_t) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (dispatch_data_t arg0, dispatch_data_t arg1) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - objc.NSObject.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (dispatch_data_t arg0, dispatch_data_t arg1) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - objc.NSObject.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - dispatch_data_t arg1, - ) { - (objc.getBlockClosure(block) - as void Function(dispatch_data_t, dispatch_data_t))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - dispatch_data_t arg0, - dispatch_data_t arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function(dispatch_data_t, dispatch_data_t))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - dispatch_data_t arg1, - ) => - block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(dispatch_data_t arg0, dispatch_data_t arg1) - > - >() - .asFunction()( - arg0, - arg1, - ); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - dispatch_data_t arg1, - ) => - (objc.getBlockClosure(block) - as void Function(dispatch_data_t, dispatch_data_t))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_dispatchdatat_dispatchdatat$CallExtension - on objc.ObjCBlock { - void call(Dartdispatch_data_t arg0, Dartdispatch_data_t arg1) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - dispatch_data_t arg0, - dispatch_data_t arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - dispatch_data_t, - dispatch_data_t, - ) - >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer); -} - -typedef sec_protocol_options_t = ffi.Pointer; -typedef Dartsec_protocol_options_t = objc.NSObject; - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_dispatchdatat { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer> - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(Dartdispatch_data_t?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (dispatch_data_t arg0) => fn( - arg0.address == 0 - ? null - : objc.NSObject.fromPointer(arg0, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(Dartdispatch_data_t?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (dispatch_data_t arg0) => fn( - arg0.address == 0 - ? null - : objc.NSObject.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(Dartdispatch_data_t?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (dispatch_data_t arg0) => fn( - arg0.address == 0 - ? null - : objc.NSObject.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (dispatch_data_t arg0) => fn( - arg0.address == 0 - ? null - : objc.NSObject.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - ) { - (objc.getBlockClosure(block) as void Function(dispatch_data_t))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, dispatch_data_t) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, dispatch_data_t) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - dispatch_data_t arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(dispatch_data_t))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - dispatch_data_t, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - ) => block.ref.target - .cast>() - .asFunction()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, dispatch_data_t) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - dispatch_data_t arg0, - ) => (objc.getBlockClosure(block) as void Function(dispatch_data_t))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, dispatch_data_t) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_dispatchdatat$CallExtension - on objc.ObjCBlock { - void call(Dartdispatch_data_t? arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - dispatch_data_t arg0, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, dispatch_data_t) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); -} - -typedef sec_protocol_pre_shared_key_selection_complete_t = - ffi.Pointer; -typedef Dartsec_protocol_pre_shared_key_selection_complete_t = - objc.ObjCBlock; - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_secprotocolmetadatat_dispatchdatat_secprotocolpresharedkeyselectioncompletet { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - Dartsec_protocol_metadata_t, - Dartdispatch_data_t?, - Dartsec_protocol_pre_shared_key_selection_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: true, release: true), - arg1.address == 0 - ? null - : objc.NSObject.fromPointer(arg1, retain: true, release: true), - ObjCBlock_ffiVoid_dispatchdatat.fromPointer( - arg2, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - > - listener( - void Function( - Dartsec_protocol_metadata_t, - Dartdispatch_data_t?, - Dartsec_protocol_pre_shared_key_selection_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : objc.NSObject.fromPointer(arg1, retain: false, release: true), - ObjCBlock_ffiVoid_dispatchdatat.fromPointer( - arg2, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_18qun1e(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - > - blocking( - void Function( - Dartsec_protocol_metadata_t, - Dartdispatch_data_t?, - Dartsec_protocol_pre_shared_key_selection_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : objc.NSObject.fromPointer(arg1, retain: false, release: true), - ObjCBlock_ffiVoid_dispatchdatat.fromPointer( - arg2, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : objc.NSObject.fromPointer(arg1, retain: false, release: true), - ObjCBlock_ffiVoid_dispatchdatat.fromPointer( - arg2, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18qun1e( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) - > - >() - .asFunction< - void Function( - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_secprotocolmetadatat_dispatchdatat_secprotocolpresharedkeyselectioncompletet$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - > { - void call( - Dartsec_protocol_metadata_t arg0, - Dartdispatch_data_t? arg1, - Dartsec_protocol_pre_shared_key_selection_complete_t arg2, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - dispatch_data_t arg1, - sec_protocol_pre_shared_key_selection_complete_t arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - sec_protocol_metadata_t, - dispatch_data_t, - sec_protocol_pre_shared_key_selection_complete_t, - ) - >()( - ref.pointer, - arg0.ref.pointer, - arg1?.ref.pointer ?? ffi.nullptr, - arg2.ref.pointer, - ); -} - -typedef sec_protocol_pre_shared_key_selection_t = - ffi.Pointer; -typedef Dartsec_protocol_pre_shared_key_selection_t = - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject?, - objc.ObjCBlock, - ) - >; -typedef sec_protocol_key_update_complete_t = ffi.Pointer; -typedef Dartsec_protocol_key_update_complete_t = - objc.ObjCBlock; - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_secprotocolmetadatat_secprotocolkeyupdatecompletet { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - sec_protocol_metadata_t arg0, - sec_protocol_key_update_complete_t arg1, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - > - fromFunction( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_protocol_key_update_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - >( - objc.newClosureBlock( - _closureCallable, - ( - sec_protocol_metadata_t arg0, - sec_protocol_key_update_complete_t arg1, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: true, release: true), - ObjCBlock_ffiVoid.fromPointer(arg1, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - > - listener( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_protocol_key_update_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (sec_protocol_metadata_t arg0, sec_protocol_key_update_complete_t arg1) => - fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - ObjCBlock_ffiVoid.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_o762yo(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - > - blocking( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_protocol_key_update_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (sec_protocol_metadata_t arg0, sec_protocol_key_update_complete_t arg1) => - fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - ObjCBlock_ffiVoid.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (sec_protocol_metadata_t arg0, sec_protocol_key_update_complete_t arg1) => - fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - ObjCBlock_ffiVoid.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_o762yo( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_protocol_key_update_complete_t arg1, - ) { - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - sec_protocol_metadata_t arg0, - sec_protocol_key_update_complete_t arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_protocol_key_update_complete_t arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - sec_protocol_metadata_t arg0, - sec_protocol_key_update_complete_t arg1, - ) - > - >() - .asFunction< - void Function( - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_protocol_key_update_complete_t arg1, - ) => - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_secprotocolmetadatat_secprotocolkeyupdatecompletet$CallExtension - on - objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - > { - void call( - Dartsec_protocol_metadata_t arg0, - Dartsec_protocol_key_update_complete_t arg1, - ) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_protocol_key_update_complete_t arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_key_update_complete_t, - ) - >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer); -} - -typedef sec_protocol_key_update_t = ffi.Pointer; -typedef Dartsec_protocol_key_update_t = - objc.ObjCBlock< - ffi.Void Function(objc.NSObject, objc.ObjCBlock) - >; -typedef sec_protocol_challenge_complete_t = ffi.Pointer; -typedef Dartsec_protocol_challenge_complete_t = - objc.ObjCBlock; - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_secprotocolmetadatat_secprotocolchallengecompletet { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - sec_protocol_metadata_t arg0, - sec_protocol_challenge_complete_t arg1, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_protocol_challenge_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - sec_protocol_metadata_t arg0, - sec_protocol_challenge_complete_t arg1, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: true, release: true), - ObjCBlock_ffiVoid_dispatchdatat.fromPointer( - arg1, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - > - listener( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_protocol_challenge_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (sec_protocol_metadata_t arg0, sec_protocol_challenge_complete_t arg1) => - fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - ObjCBlock_ffiVoid_dispatchdatat.fromPointer( - arg1, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_o762yo(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - > - blocking( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_protocol_challenge_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (sec_protocol_metadata_t arg0, sec_protocol_challenge_complete_t arg1) => - fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - ObjCBlock_ffiVoid_dispatchdatat.fromPointer( - arg1, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (sec_protocol_metadata_t arg0, sec_protocol_challenge_complete_t arg1) => - fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - ObjCBlock_ffiVoid_dispatchdatat.fromPointer( - arg1, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_o762yo( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_protocol_challenge_complete_t arg1, - ) { - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - sec_protocol_metadata_t arg0, - sec_protocol_challenge_complete_t arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_protocol_challenge_complete_t arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - sec_protocol_metadata_t arg0, - sec_protocol_challenge_complete_t arg1, - ) - > - >() - .asFunction< - void Function( - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_protocol_challenge_complete_t arg1, - ) => - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_secprotocolmetadatat_secprotocolchallengecompletet$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - > { - void call( - Dartsec_protocol_metadata_t arg0, - Dartsec_protocol_challenge_complete_t arg1, - ) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_protocol_challenge_complete_t arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_protocol_challenge_complete_t, - ) - >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer); -} - -typedef sec_protocol_challenge_t = ffi.Pointer; -typedef Dartsec_protocol_challenge_t = - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.ObjCBlock, - ) - >; - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_bool { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer> ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(bool) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (bool arg0) => fn(arg0), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(bool) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (bool arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1s56lr9(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(bool) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (bool arg0) => fn(arg0), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (bool arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1s56lr9( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - bool arg0, - ) { - (objc.getBlockClosure(block) as void Function(bool))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Bool) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Bool) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - bool arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(bool))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - bool arg0, - ) => block.ref.target - .cast>() - .asFunction()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Bool) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - bool arg0, - ) => (objc.getBlockClosure(block) as void Function(bool))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Bool) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_bool$CallExtension - on objc.ObjCBlock { - void call(bool arg0) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Bool arg0, - ) - > - >() - .asFunction, bool)>()( - ref.pointer, - arg0, - ); -} - -typedef sec_protocol_verify_complete_t = ffi.Pointer; -typedef Dartsec_protocol_verify_complete_t = - objc.ObjCBlock; - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_secprotocolmetadatat_sectrustt_secprotocolverifycompletet { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_trust_t, - Dartsec_protocol_verify_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: true, release: true), - objc.NSObject.fromPointer(arg1, retain: true, release: true), - ObjCBlock_ffiVoid_bool.fromPointer( - arg2, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - > - listener( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_trust_t, - Dartsec_protocol_verify_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - objc.NSObject.fromPointer(arg1, retain: false, release: true), - ObjCBlock_ffiVoid_bool.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_18qun1e(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - > - blocking( - void Function( - Dartsec_protocol_metadata_t, - Dartsec_trust_t, - Dartsec_protocol_verify_complete_t, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - objc.NSObject.fromPointer(arg1, retain: false, release: true), - ObjCBlock_ffiVoid_bool.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) => fn( - objc.NSObject.fromPointer(arg0, retain: false, release: true), - objc.NSObject.fromPointer(arg1, retain: false, release: true), - ObjCBlock_ffiVoid_bool.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18qun1e( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) - > - >() - .asFunction< - void Function( - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_secprotocolmetadatat_sectrustt_secprotocolverifycompletet$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - > { - void call( - Dartsec_protocol_metadata_t arg0, - Dartsec_trust_t arg1, - Dartsec_protocol_verify_complete_t arg2, - ) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - sec_protocol_metadata_t arg0, - sec_trust_t arg1, - sec_protocol_verify_complete_t arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - sec_protocol_metadata_t, - sec_trust_t, - sec_protocol_verify_complete_t, - ) - >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2.ref.pointer); -} - -typedef sec_protocol_verify_t = ffi.Pointer; -typedef Dartsec_protocol_verify_t = - objc.ObjCBlock< - ffi.Void Function( - objc.NSObject, - objc.NSObject, - objc.ObjCBlock, - ) - >; - -final class SSLContext extends ffi.Opaque {} - -typedef SSLContextRef = ffi.Pointer; -typedef SSLConnectionRef = ffi.Pointer; - -enum SSLSessionOption { - kSSLSessionOptionBreakOnServerAuth(0), - kSSLSessionOptionBreakOnCertRequested(1), - kSSLSessionOptionBreakOnClientAuth(2), - kSSLSessionOptionFalseStart(3), - kSSLSessionOptionSendOneByteRecord(4), - kSSLSessionOptionAllowServerIdentityChange(5), - kSSLSessionOptionFallback(6), - kSSLSessionOptionBreakOnClientHello(7), - kSSLSessionOptionAllowRenegotiation(8), - kSSLSessionOptionEnableSessionTickets(9); - - final int value; - const SSLSessionOption(this.value); - - static SSLSessionOption fromValue(int value) => switch (value) { - 0 => kSSLSessionOptionBreakOnServerAuth, - 1 => kSSLSessionOptionBreakOnCertRequested, - 2 => kSSLSessionOptionBreakOnClientAuth, - 3 => kSSLSessionOptionFalseStart, - 4 => kSSLSessionOptionSendOneByteRecord, - 5 => kSSLSessionOptionAllowServerIdentityChange, - 6 => kSSLSessionOptionFallback, - 7 => kSSLSessionOptionBreakOnClientHello, - 8 => kSSLSessionOptionAllowRenegotiation, - 9 => kSSLSessionOptionEnableSessionTickets, - _ => throw ArgumentError('Unknown value for SSLSessionOption: $value'), - }; -} - -enum SSLSessionState { - kSSLIdle(0), - kSSLHandshake(1), - kSSLConnected(2), - kSSLClosed(3), - kSSLAborted(4); - - final int value; - const SSLSessionState(this.value); - - static SSLSessionState fromValue(int value) => switch (value) { - 0 => kSSLIdle, - 1 => kSSLHandshake, - 2 => kSSLConnected, - 3 => kSSLClosed, - 4 => kSSLAborted, - _ => throw ArgumentError('Unknown value for SSLSessionState: $value'), - }; -} - -enum SSLClientCertificateState { - kSSLClientCertNone(0), - kSSLClientCertRequested(1), - kSSLClientCertSent(2), - kSSLClientCertRejected(3); - - final int value; - const SSLClientCertificateState(this.value); - - static SSLClientCertificateState fromValue(int value) => switch (value) { - 0 => kSSLClientCertNone, - 1 => kSSLClientCertRequested, - 2 => kSSLClientCertSent, - 3 => kSSLClientCertRejected, - _ => throw ArgumentError( - 'Unknown value for SSLClientCertificateState: $value', - ), - }; -} - -typedef SSLReadFuncFunction = - OSStatus Function( - SSLConnectionRef connection, - ffi.Pointer data, - ffi.Pointer dataLength, - ); -typedef DartSSLReadFuncFunction = - DartSInt32 Function( - SSLConnectionRef connection, - ffi.Pointer data, - ffi.Pointer dataLength, - ); -typedef SSLReadFunc = ffi.Pointer>; -typedef SSLWriteFuncFunction = - OSStatus Function( - SSLConnectionRef connection, - ffi.Pointer data, - ffi.Pointer dataLength, - ); -typedef DartSSLWriteFuncFunction = - DartSInt32 Function( - SSLConnectionRef connection, - ffi.Pointer data, - ffi.Pointer dataLength, - ); -typedef SSLWriteFunc = ffi.Pointer>; - -enum SSLProtocolSide { - kSSLServerSide(0), - kSSLClientSide(1); - - final int value; - const SSLProtocolSide(this.value); - - static SSLProtocolSide fromValue(int value) => switch (value) { - 0 => kSSLServerSide, - 1 => kSSLClientSide, - _ => throw ArgumentError('Unknown value for SSLProtocolSide: $value'), - }; -} - -enum SSLConnectionType { - kSSLStreamType(0), - kSSLDatagramType(1); - - final int value; - const SSLConnectionType(this.value); - - static SSLConnectionType fromValue(int value) => switch (value) { - 0 => kSSLStreamType, - 1 => kSSLDatagramType, - _ => throw ArgumentError('Unknown value for SSLConnectionType: $value'), - }; -} - -enum SSLAuthenticate { - kNeverAuthenticate(0), - kAlwaysAuthenticate(1), - kTryAuthenticate(2); - - final int value; - const SSLAuthenticate(this.value); - - static SSLAuthenticate fromValue(int value) => switch (value) { - 0 => kNeverAuthenticate, - 1 => kAlwaysAuthenticate, - 2 => kTryAuthenticate, - _ => throw ArgumentError('Unknown value for SSLAuthenticate: $value'), - }; -} - -late final _class_NSURLSession = objc.getClass("NSURLSession"); -late final _sel_sharedSession = objc.registerName("sharedSession"); -late final _class_NSURLSessionConfiguration = objc.getClass( - "NSURLSessionConfiguration", -); -late final _sel_defaultSessionConfiguration = objc.registerName( - "defaultSessionConfiguration", -); -late final _sel_ephemeralSessionConfiguration = objc.registerName( - "ephemeralSessionConfiguration", -); -late final _sel_backgroundSessionConfigurationWithIdentifier_ = objc - .registerName("backgroundSessionConfigurationWithIdentifier:"); -late final _sel_identifier = objc.registerName("identifier"); -late final _sel_requestCachePolicy = objc.registerName("requestCachePolicy"); -late final _sel_setRequestCachePolicy_ = objc.registerName( - "setRequestCachePolicy:", -); -late final _sel_timeoutIntervalForRequest = objc.registerName( - "timeoutIntervalForRequest", -); -late final _sel_setTimeoutIntervalForRequest_ = objc.registerName( - "setTimeoutIntervalForRequest:", -); -late final _sel_timeoutIntervalForResource = objc.registerName( - "timeoutIntervalForResource", -); -late final _sel_setTimeoutIntervalForResource_ = objc.registerName( - "setTimeoutIntervalForResource:", -); -late final _sel_waitsForConnectivity = objc.registerName( - "waitsForConnectivity", -); -late final _sel_setWaitsForConnectivity_ = objc.registerName( - "setWaitsForConnectivity:", -); -late final _sel_isDiscretionary = objc.registerName("isDiscretionary"); -late final _sel_setDiscretionary_ = objc.registerName("setDiscretionary:"); -late final _sel_sharedContainerIdentifier = objc.registerName( - "sharedContainerIdentifier", -); -late final _sel_setSharedContainerIdentifier_ = objc.registerName( - "setSharedContainerIdentifier:", -); -late final _sel_sessionSendsLaunchEvents = objc.registerName( - "sessionSendsLaunchEvents", -); -late final _sel_setSessionSendsLaunchEvents_ = objc.registerName( - "setSessionSendsLaunchEvents:", -); -late final _sel_connectionProxyDictionary = objc.registerName( - "connectionProxyDictionary", -); -late final _sel_setConnectionProxyDictionary_ = objc.registerName( - "setConnectionProxyDictionary:", -); -late final _sel_TLSMinimumSupportedProtocol = objc.registerName( - "TLSMinimumSupportedProtocol", -); -final _objc_msgSend_cbopi9 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.UnsignedInt Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setTLSMinimumSupportedProtocol_ = objc.registerName( - "setTLSMinimumSupportedProtocol:", -); -final _objc_msgSend_268k8x = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_TLSMaximumSupportedProtocol = objc.registerName( - "TLSMaximumSupportedProtocol", -); -late final _sel_setTLSMaximumSupportedProtocol_ = objc.registerName( - "setTLSMaximumSupportedProtocol:", -); -late final _sel_TLSMinimumSupportedProtocolVersion = objc.registerName( - "TLSMinimumSupportedProtocolVersion", -); -final _objc_msgSend_9jpwfb = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Uint16 Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setTLSMinimumSupportedProtocolVersion_ = objc.registerName( - "setTLSMinimumSupportedProtocolVersion:", -); -final _objc_msgSend_1mvuct7 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint16, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_TLSMaximumSupportedProtocolVersion = objc.registerName( - "TLSMaximumSupportedProtocolVersion", -); -late final _sel_setTLSMaximumSupportedProtocolVersion_ = objc.registerName( - "setTLSMaximumSupportedProtocolVersion:", -); -late final _sel_HTTPShouldSetCookies = objc.registerName( - "HTTPShouldSetCookies", -); -late final _sel_setHTTPShouldSetCookies_ = objc.registerName( - "setHTTPShouldSetCookies:", -); -late final _sel_HTTPCookieAcceptPolicy = objc.registerName( - "HTTPCookieAcceptPolicy", -); -final _objc_msgSend_104dkoq = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSUInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setHTTPCookieAcceptPolicy_ = objc.registerName( - "setHTTPCookieAcceptPolicy:", -); -final _objc_msgSend_3q55ys = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_HTTPAdditionalHeaders = objc.registerName( - "HTTPAdditionalHeaders", -); -late final _sel_setHTTPAdditionalHeaders_ = objc.registerName( - "setHTTPAdditionalHeaders:", -); -late final _sel_HTTPMaximumConnectionsPerHost = objc.registerName( - "HTTPMaximumConnectionsPerHost", -); -late final _sel_setHTTPMaximumConnectionsPerHost_ = objc.registerName( - "setHTTPMaximumConnectionsPerHost:", -); -late final _sel_HTTPCookieStorage = objc.registerName("HTTPCookieStorage"); -late final _sel_setHTTPCookieStorage_ = objc.registerName( - "setHTTPCookieStorage:", -); - -/// WARNING: NSURLCredentialStorage is a stub. To generate bindings for this class, include -/// NSURLCredentialStorage in your config's objc-interfaces list. -/// -/// NSURLCredentialStorage -extension type NSURLCredentialStorage._(objc.ObjCObject object$) - implements objc.ObjCObject { - /// Constructs a [NSURLCredentialStorage] that points to the same underlying object as [other]. - NSURLCredentialStorage.as(objc.ObjCObject other) : object$ = other {} - - /// Constructs a [NSURLCredentialStorage] that wraps the given raw object pointer. - NSURLCredentialStorage.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} -} - -late final _sel_URLCredentialStorage = objc.registerName( - "URLCredentialStorage", -); -late final _sel_setURLCredentialStorage_ = objc.registerName( - "setURLCredentialStorage:", -); -late final _sel_URLCache = objc.registerName("URLCache"); -late final _sel_setURLCache_ = objc.registerName("setURLCache:"); -late final _sel_shouldUseExtendedBackgroundIdleMode = objc.registerName( - "shouldUseExtendedBackgroundIdleMode", -); -late final _sel_setShouldUseExtendedBackgroundIdleMode_ = objc.registerName( - "setShouldUseExtendedBackgroundIdleMode:", -); -late final _sel_protocolClasses = objc.registerName("protocolClasses"); -late final _sel_setProtocolClasses_ = objc.registerName("setProtocolClasses:"); - -/// ! -/// @enum NSURLSessionMultipathServiceType -/// -/// @discussion The NSURLSessionMultipathServiceType enum defines constants that -/// can be used to specify the multipath service type to associate an NSURLSession. The -/// multipath service type determines whether multipath TCP should be attempted and the conditions -/// for creating and switching between subflows. Using these service types requires the appropriate entitlement. Any connection attempt will fail if the process does not have the required entitlement. -/// A primary interface is a generally less expensive interface in terms of both cost and power (such as WiFi or ethernet). A secondary interface is more expensive (such as 3G or LTE). -/// -/// @constant NSURLSessionMultipathServiceTypeNone Specifies that multipath tcp should not be used. Connections will use a single flow. -/// This is the default value. No entitlement is required to set this value. -/// -/// @constant NSURLSessionMultipathServiceTypeHandover Specifies that a secondary subflow should only be used -/// when the primary subflow is not performing adequately. Requires the com.apple.developer.networking.multipath entitlement. -/// -/// @constant NSURLSessionMultipathServiceTypeInteractive Specifies that a secondary subflow should be used if the -/// primary subflow is not performing adequately (packet loss, high round trip times, bandwidth issues). The secondary -/// subflow will be created more aggressively than with NSURLSessionMultipathServiceTypeHandover. Requires the com.apple.developer.networking.multipath entitlement. -/// -/// @constant NSURLSessionMultipathServiceTypeAggregate Specifies that multiple subflows across multiple interfaces should be -/// used for better bandwidth. This mode is only available for experimentation on devices configured for development use. -/// It can be enabled in the Developer section of the Settings app. -enum NSURLSessionMultipathServiceType { - /// None - no multipath (default) - NSURLSessionMultipathServiceTypeNone(0), - - /// Handover - secondary flows brought up when primary flow is not performing adequately. - NSURLSessionMultipathServiceTypeHandover(1), - - /// Interactive - secondary flows created more aggressively. - NSURLSessionMultipathServiceTypeInteractive(2), - - /// Aggregate - multiple subflows used for greater bandwidth. - NSURLSessionMultipathServiceTypeAggregate(3); - - final int value; - const NSURLSessionMultipathServiceType(this.value); - - static NSURLSessionMultipathServiceType fromValue(int value) => - switch (value) { - 0 => NSURLSessionMultipathServiceTypeNone, - 1 => NSURLSessionMultipathServiceTypeHandover, - 2 => NSURLSessionMultipathServiceTypeInteractive, - 3 => NSURLSessionMultipathServiceTypeAggregate, - _ => throw ArgumentError( - 'Unknown value for NSURLSessionMultipathServiceType: $value', - ), - }; -} - -late final _sel_multipathServiceType = objc.registerName( - "multipathServiceType", -); -final _objc_msgSend_1wxwnc0 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setMultipathServiceType_ = objc.registerName( - "setMultipathServiceType:", -); -final _objc_msgSend_1hx005a = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_usesClassicLoadingMode = objc.registerName( - "usesClassicLoadingMode", -); -late final _sel_setUsesClassicLoadingMode_ = objc.registerName( - "setUsesClassicLoadingMode:", -); -late final _sel_enablesEarlyData = objc.registerName("enablesEarlyData"); -late final _sel_setEnablesEarlyData_ = objc.registerName( - "setEnablesEarlyData:", -); -late final _sel_backgroundSessionConfiguration_ = objc.registerName( - "backgroundSessionConfiguration:", -); - -/// NSURLSessionDeprecated -extension NSURLSessionDeprecated on NSURLSessionConfiguration { - /// backgroundSessionConfiguration: - static NSURLSessionConfiguration backgroundSessionConfiguration( - objc.NSString identifier, - ) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.backgroundSessionConfiguration:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSURLSessionConfiguration, - _sel_backgroundSessionConfiguration_, - identifier.ref.pointer, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: true, - release: true, - ); - } -} - -/// Configuration options for an NSURLSession. When a session is -/// created, a copy of the configuration object is made - you cannot -/// modify the configuration of a session after it has been created. -/// -/// The shared session uses the global credential, cache and cookie -/// storage objects. -/// -/// An ephemeral session has no persistent disk storage for cookies, -/// cache or credentials. -/// -/// A background session can be used to perform networking operations -/// on behalf of a suspended application, within certain constraints. -extension type NSURLSessionConfiguration._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject, objc.NSCopying { - /// Constructs a [NSURLSessionConfiguration] that points to the same underlying object as [other]. - NSURLSessionConfiguration.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSURLSessionConfiguration] that wraps the given raw object pointer. - NSURLSessionConfiguration.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLSessionConfiguration]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLSessionConfiguration, - ); - - /// alloc - static NSURLSessionConfiguration alloc() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionConfiguration, - _sel_alloc, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// allocWithZone: - static NSURLSessionConfiguration allocWithZone( - ffi.Pointer zone, - ) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSessionConfiguration, - _sel_allocWithZone_, - zone, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// backgroundSessionConfigurationWithIdentifier: - static NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier( - objc.NSString identifier, - ) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSURLSessionConfiguration, - _sel_backgroundSessionConfigurationWithIdentifier_, - identifier.ref.pointer, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// defaultSessionConfiguration - static NSURLSessionConfiguration getDefaultSessionConfiguration() { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.defaultSessionConfiguration', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionConfiguration, - _sel_defaultSessionConfiguration, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// ephemeralSessionConfiguration - static NSURLSessionConfiguration getEphemeralSessionConfiguration() { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.ephemeralSessionConfiguration', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionConfiguration, - _sel_ephemeralSessionConfiguration, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// new - static NSURLSessionConfiguration new$() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionConfiguration, - _sel_new, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// Returns a new instance of NSURLSessionConfiguration constructed with the default `new` method. - NSURLSessionConfiguration() : this.as(new$().object$); -} - -extension NSURLSessionConfiguration$Methods on NSURLSessionConfiguration { - /// Specifies additional headers which will be set on outgoing requests. - /// Note that these headers are added to the request only if not already present. - objc.NSDictionary? get HTTPAdditionalHeaders { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPAdditionalHeaders', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_HTTPAdditionalHeaders, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// Policy for accepting cookies. This overrides the policy otherwise specified by the cookie storage. - NSHTTPCookieAcceptPolicy get HTTPCookieAcceptPolicy { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPCookieAcceptPolicy', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_104dkoq( - object$.ref.pointer, - _sel_HTTPCookieAcceptPolicy, - ); - return NSHTTPCookieAcceptPolicy.fromValue($ret); - } - - /// The cookie storage object to use, or nil to indicate that no cookies should be handled - NSHTTPCookieStorage? get HTTPCookieStorage { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPCookieStorage', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_HTTPCookieStorage, - ); - return $ret.address == 0 - ? null - : NSHTTPCookieStorage.fromPointer($ret, retain: true, release: true); - } - - /// The maximum number of simultaneous persistent connections per host - DartNSInteger get HTTPMaximumConnectionsPerHost { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPMaximumConnectionsPerHost', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_1hz7y9r( - object$.ref.pointer, - _sel_HTTPMaximumConnectionsPerHost, - ); - } - - /// Allow the session to set cookies on requests - bool get HTTPShouldSetCookies { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPShouldSetCookies', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_HTTPShouldSetCookies); - } - - /// Allow the use of HTTP pipelining - bool get HTTPShouldUsePipelining { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPShouldUsePipelining', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldUsePipelining, - ); - } - - /// The maximum allowable versions of the TLS protocol, from - SSLProtocol get TLSMaximumSupportedProtocol { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.TLSMaximumSupportedProtocol', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_cbopi9( - object$.ref.pointer, - _sel_TLSMaximumSupportedProtocol, - ); - return SSLProtocol.fromValue($ret); - } - - /// The maximum allowable versions of the TLS protocol, from - tls_protocol_version_t get TLSMaximumSupportedProtocolVersion { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.TLSMaximumSupportedProtocolVersion', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_9jpwfb( - object$.ref.pointer, - _sel_TLSMaximumSupportedProtocolVersion, - ); - return tls_protocol_version_t.fromValue($ret); - } - - /// The minimum allowable versions of the TLS protocol, from - SSLProtocol get TLSMinimumSupportedProtocol { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.TLSMinimumSupportedProtocol', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_cbopi9( - object$.ref.pointer, - _sel_TLSMinimumSupportedProtocol, - ); - return SSLProtocol.fromValue($ret); - } - - /// The minimum allowable versions of the TLS protocol, from - tls_protocol_version_t get TLSMinimumSupportedProtocolVersion { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.TLSMinimumSupportedProtocolVersion', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_9jpwfb( - object$.ref.pointer, - _sel_TLSMinimumSupportedProtocolVersion, - ); - return tls_protocol_version_t.fromValue($ret); - } - - /// The URL resource cache, or nil to indicate that no caching is to be performed - NSURLCache? get URLCache { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.URLCache', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URLCache); - return $ret.address == 0 - ? null - : NSURLCache.fromPointer($ret, retain: true, release: true); - } - - /// The credential storage object, or nil to indicate that no credential storage is to be used - NSURLCredentialStorage? get URLCredentialStorage { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.URLCredentialStorage', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_URLCredentialStorage, - ); - return $ret.address == 0 - ? null - : NSURLCredentialStorage.fromPointer($ret, retain: true, release: true); - } - - /// allow request to route over cellular. - bool get allowsCellularAccess { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.allowsCellularAccess', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsCellularAccess); - } - - /// allow request to route over networks in constrained mode. Defaults to YES. - bool get allowsConstrainedNetworkAccess { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.allowsConstrainedNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsConstrainedNetworkAccess, - ); - } - - /// allow request to route over expensive networks. Defaults to YES. - bool get allowsExpensiveNetworkAccess { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.allowsExpensiveNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsExpensiveNetworkAccess, - ); - } - - /// The proxy dictionary, as described by - objc.NSDictionary? get connectionProxyDictionary { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.connectionProxyDictionary', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_connectionProxyDictionary, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// Enables HTTP/3 0-RTT early data transmission of safe requests (GET or HEAD - /// requests). - /// - /// WARNING: Inclusion in TLS early data changes the security guarantees offered - /// by TLS. - /// - /// Requests sent in early data are not covered by anti-replay security - /// protections. Early data must be idempotent and the impact of adversarial - /// replays must be carefully evaluated, as the data may be replayed. Early data - /// also does not provide full forward secrecy; data transmitted is more - /// susceptible to data breach and security compromise of the server, even if - /// the breach happens after the data was transmitted. - /// - /// See Section 8 of RFC8446 for more details. - /// - /// https://datatracker.ietf.org/doc/html/rfc8446#section-8 - /// - /// See RFC8470 for additional discussion and security considerations. - /// - /// https://datatracker.ietf.org/doc/html/rfc8470 - /// - /// If these risks are acceptable for your use case, set this property to YES. - /// If unsure, NO is the safest option. - /// - /// NOTE: Not supported in the classic loading mode. - /// - /// Defaults to NO. - bool get enablesEarlyData { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.enablesEarlyData', - iOS: (false, (26, 0, 0)), - macOS: (false, (26, 0, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_enablesEarlyData); - } - - /// identifier for the background session configuration - objc.NSString? get identifier { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.identifier', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_identifier); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// init - NSURLSessionConfiguration init() { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// allows background tasks to be scheduled at the discretion of the system for optimal performance. - bool get isDiscretionary { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.isDiscretionary', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_isDiscretionary); - } - - /// multipath service type to use for connections. The default is NSURLSessionMultipathServiceTypeNone - NSURLSessionMultipathServiceType get multipathServiceType { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.multipathServiceType', - iOS: (false, (11, 0, 0)), - macOS: (true, null), - ); - final $ret = _objc_msgSend_1wxwnc0( - object$.ref.pointer, - _sel_multipathServiceType, - ); - return NSURLSessionMultipathServiceType.fromValue($ret); - } - - /// type of service for requests. - NSURLRequestNetworkServiceType get networkServiceType { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.networkServiceType', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_t4uaw1( - object$.ref.pointer, - _sel_networkServiceType, - ); - return NSURLRequestNetworkServiceType.fromValue($ret); - } - - /// An optional array of Class objects which subclass NSURLProtocol. - /// The Class will be sent +canInitWithRequest: when determining if - /// an instance of the class can be used for a given URL scheme. - /// You should not use +[NSURLProtocol registerClass:], as that - /// method will register your class with the default session rather - /// than with an instance of NSURLSession. - /// Custom NSURLProtocol subclasses are not available to background - /// sessions. - objc.NSArray? get protocolClasses { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.protocolClasses', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_protocolClasses, - ); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// default cache policy for requests - NSURLRequestCachePolicy get requestCachePolicy { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.requestCachePolicy', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_8jm3uo( - object$.ref.pointer, - _sel_requestCachePolicy, - ); - return NSURLRequestCachePolicy.fromValue($ret); - } - - /// requires requests from the session to be made with DNSSEC validation enabled. Defaults to NO. - bool get requiresDNSSECValidation { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.requiresDNSSECValidation', - iOS: (false, (16, 0, 0)), - macOS: (false, (13, 0, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_requiresDNSSECValidation, - ); - } - - /// Allows the app to be resumed or launched in the background when tasks in background sessions complete - /// or when auth is required. This only applies to configurations created with +backgroundSessionConfigurationWithIdentifier: - /// and the default value is YES. - /// - /// NOTE: macOS apps based on AppKit do not support background launch. - bool get sessionSendsLaunchEvents { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.sessionSendsLaunchEvents', - iOS: (false, (7, 0, 0)), - macOS: (false, (11, 0, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_sessionSendsLaunchEvents, - ); - } - - /// allow request to route over cellular. - set allowsCellularAccess(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setAllowsCellularAccess:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsCellularAccess_, - value, - ); - } - - /// allow request to route over networks in constrained mode. Defaults to YES. - set allowsConstrainedNetworkAccess(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setAllowsConstrainedNetworkAccess:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsConstrainedNetworkAccess_, - value, - ); - } - - /// allow request to route over expensive networks. Defaults to YES. - set allowsExpensiveNetworkAccess(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setAllowsExpensiveNetworkAccess:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsExpensiveNetworkAccess_, - value, - ); - } - - /// The proxy dictionary, as described by - set connectionProxyDictionary(objc.NSDictionary? value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setConnectionProxyDictionary:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setConnectionProxyDictionary_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// allows background tasks to be scheduled at the discretion of the system for optimal performance. - set isDiscretionary(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setDiscretionary:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_1s56lr9(object$.ref.pointer, _sel_setDiscretionary_, value); - } - - /// Enables HTTP/3 0-RTT early data transmission of safe requests (GET or HEAD - /// requests). - /// - /// WARNING: Inclusion in TLS early data changes the security guarantees offered - /// by TLS. - /// - /// Requests sent in early data are not covered by anti-replay security - /// protections. Early data must be idempotent and the impact of adversarial - /// replays must be carefully evaluated, as the data may be replayed. Early data - /// also does not provide full forward secrecy; data transmitted is more - /// susceptible to data breach and security compromise of the server, even if - /// the breach happens after the data was transmitted. - /// - /// See Section 8 of RFC8446 for more details. - /// - /// https://datatracker.ietf.org/doc/html/rfc8446#section-8 - /// - /// See RFC8470 for additional discussion and security considerations. - /// - /// https://datatracker.ietf.org/doc/html/rfc8470 - /// - /// If these risks are acceptable for your use case, set this property to YES. - /// If unsure, NO is the safest option. - /// - /// NOTE: Not supported in the classic loading mode. - /// - /// Defaults to NO. - set enablesEarlyData(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setEnablesEarlyData:', - iOS: (false, (26, 0, 0)), - macOS: (false, (26, 0, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setEnablesEarlyData_, - value, - ); - } - - /// Specifies additional headers which will be set on outgoing requests. - /// Note that these headers are added to the request only if not already present. - set HTTPAdditionalHeaders(objc.NSDictionary? value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPAdditionalHeaders:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPAdditionalHeaders_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Policy for accepting cookies. This overrides the policy otherwise specified by the cookie storage. - set HTTPCookieAcceptPolicy(NSHTTPCookieAcceptPolicy value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPCookieAcceptPolicy:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_3q55ys( - object$.ref.pointer, - _sel_setHTTPCookieAcceptPolicy_, - value.value, - ); - } - - /// The cookie storage object to use, or nil to indicate that no cookies should be handled - set HTTPCookieStorage(NSHTTPCookieStorage? value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPCookieStorage:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPCookieStorage_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// The maximum number of simultaneous persistent connections per host - set HTTPMaximumConnectionsPerHost(DartNSInteger value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPMaximumConnectionsPerHost:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_4sp4xj( - object$.ref.pointer, - _sel_setHTTPMaximumConnectionsPerHost_, - value, - ); - } - - /// Allow the session to set cookies on requests - set HTTPShouldSetCookies(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPShouldSetCookies:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setHTTPShouldSetCookies_, - value, - ); - } - - /// Allow the use of HTTP pipelining - set HTTPShouldUsePipelining(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPShouldUsePipelining:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setHTTPShouldUsePipelining_, - value, - ); - } - - /// multipath service type to use for connections. The default is NSURLSessionMultipathServiceTypeNone - set multipathServiceType(NSURLSessionMultipathServiceType value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setMultipathServiceType:', - iOS: (false, (11, 0, 0)), - macOS: (true, null), - ); - _objc_msgSend_1hx005a( - object$.ref.pointer, - _sel_setMultipathServiceType_, - value.value, - ); - } - - /// type of service for requests. - set networkServiceType(NSURLRequestNetworkServiceType value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setNetworkServiceType:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1mse4s1( - object$.ref.pointer, - _sel_setNetworkServiceType_, - value.value, - ); - } - - /// An optional array of Class objects which subclass NSURLProtocol. - /// The Class will be sent +canInitWithRequest: when determining if - /// an instance of the class can be used for a given URL scheme. - /// You should not use +[NSURLProtocol registerClass:], as that - /// method will register your class with the default session rather - /// than with an instance of NSURLSession. - /// Custom NSURLProtocol subclasses are not available to background - /// sessions. - set protocolClasses(objc.NSArray? value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setProtocolClasses:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setProtocolClasses_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// default cache policy for requests - set requestCachePolicy(NSURLRequestCachePolicy value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setRequestCachePolicy:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1yjxuv2( - object$.ref.pointer, - _sel_setRequestCachePolicy_, - value.value, - ); - } - - /// requires requests from the session to be made with DNSSEC validation enabled. Defaults to NO. - set requiresDNSSECValidation(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setRequiresDNSSECValidation:', - iOS: (false, (16, 0, 0)), - macOS: (false, (13, 0, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setRequiresDNSSECValidation_, - value, - ); - } - - /// Allows the app to be resumed or launched in the background when tasks in background sessions complete - /// or when auth is required. This only applies to configurations created with +backgroundSessionConfigurationWithIdentifier: - /// and the default value is YES. - /// - /// NOTE: macOS apps based on AppKit do not support background launch. - set sessionSendsLaunchEvents(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setSessionSendsLaunchEvents:', - iOS: (false, (7, 0, 0)), - macOS: (false, (11, 0, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setSessionSendsLaunchEvents_, - value, - ); - } - - /// The identifier of the shared data container into which files in background sessions should be downloaded. - /// App extensions wishing to use background sessions *must* set this property to a valid container identifier, or - /// all transfers in that session will fail with NSURLErrorBackgroundSessionRequiresSharedContainer. - set sharedContainerIdentifier(objc.NSString? value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setSharedContainerIdentifier:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setSharedContainerIdentifier_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// setShouldUseExtendedBackgroundIdleMode: - set shouldUseExtendedBackgroundIdleMode(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setShouldUseExtendedBackgroundIdleMode:', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setShouldUseExtendedBackgroundIdleMode_, - value, - ); - } - - /// The maximum allowable versions of the TLS protocol, from - set TLSMaximumSupportedProtocol(SSLProtocol value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setTLSMaximumSupportedProtocol:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_268k8x( - object$.ref.pointer, - _sel_setTLSMaximumSupportedProtocol_, - value.value, - ); - } - - /// The maximum allowable versions of the TLS protocol, from - set TLSMaximumSupportedProtocolVersion(tls_protocol_version_t value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setTLSMaximumSupportedProtocolVersion:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_1mvuct7( - object$.ref.pointer, - _sel_setTLSMaximumSupportedProtocolVersion_, - value.value, - ); - } - - /// The minimum allowable versions of the TLS protocol, from - set TLSMinimumSupportedProtocol(SSLProtocol value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setTLSMinimumSupportedProtocol:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_268k8x( - object$.ref.pointer, - _sel_setTLSMinimumSupportedProtocol_, - value.value, - ); - } - - /// The minimum allowable versions of the TLS protocol, from - set TLSMinimumSupportedProtocolVersion(tls_protocol_version_t value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setTLSMinimumSupportedProtocolVersion:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_1mvuct7( - object$.ref.pointer, - _sel_setTLSMinimumSupportedProtocolVersion_, - value.value, - ); - } - - /// default timeout for requests. This will cause a timeout if no data is transmitted for the given timeout value, and is reset whenever data is transmitted. - set timeoutIntervalForRequest(DartNSTimeInterval value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setTimeoutIntervalForRequest:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_hwm8nu( - object$.ref.pointer, - _sel_setTimeoutIntervalForRequest_, - value, - ); - } - - /// default timeout for requests. This will cause a timeout if a resource is not able to be retrieved within a given timeout. - set timeoutIntervalForResource(DartNSTimeInterval value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setTimeoutIntervalForResource:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_hwm8nu( - object$.ref.pointer, - _sel_setTimeoutIntervalForResource_, - value, - ); - } - - /// The URL resource cache, or nil to indicate that no caching is to be performed - set URLCache(NSURLCache? value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setURLCache:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setURLCache_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// The credential storage object, or nil to indicate that no credential storage is to be used - set URLCredentialStorage(NSURLCredentialStorage? value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setURLCredentialStorage:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setURLCredentialStorage_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Uses the classic network loader. - /// - /// NOTE: FTP and HTTP/1 pipelining are only supported in the classic loading mode. - /// - /// Defaults to YES. The default may be NO in a future OS update. - set usesClassicLoadingMode(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setUsesClassicLoadingMode:', - iOS: (false, (18, 4, 0)), - macOS: (false, (15, 4, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setUsesClassicLoadingMode_, - value, - ); - } - - /// Causes tasks to wait for network connectivity to become available, rather - /// than immediately failing with an error (such as NSURLErrorNotConnectedToInternet) - /// when it is not. When waiting for connectivity, the timeoutIntervalForRequest - /// property does not apply, but the timeoutIntervalForResource property does. - /// - /// Unsatisfactory connectivity (that requires waiting) includes cases where the - /// device has limited or insufficient connectivity for a task (e.g., only has a - /// cellular connection but the allowsCellularAccess property is NO, or requires - /// a VPN connection in order to reach the desired host). - /// - /// Default value is NO. Ignored by background sessions, as background sessions - /// always wait for connectivity. - set waitsForConnectivity(bool value) { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setWaitsForConnectivity:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setWaitsForConnectivity_, - value, - ); - } - - /// The identifier of the shared data container into which files in background sessions should be downloaded. - /// App extensions wishing to use background sessions *must* set this property to a valid container identifier, or - /// all transfers in that session will fail with NSURLErrorBackgroundSessionRequiresSharedContainer. - objc.NSString? get sharedContainerIdentifier { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.sharedContainerIdentifier', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_sharedContainerIdentifier, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// shouldUseExtendedBackgroundIdleMode - bool get shouldUseExtendedBackgroundIdleMode { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.shouldUseExtendedBackgroundIdleMode', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_shouldUseExtendedBackgroundIdleMode, - ); - } - - /// default timeout for requests. This will cause a timeout if no data is transmitted for the given timeout value, and is reset whenever data is transmitted. - DartNSTimeInterval get timeoutIntervalForRequest { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.timeoutIntervalForRequest', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return objc.useMsgSendVariants - ? _objc_msgSend_1ukqyt8Fpret( - object$.ref.pointer, - _sel_timeoutIntervalForRequest, - ) - : _objc_msgSend_1ukqyt8( - object$.ref.pointer, - _sel_timeoutIntervalForRequest, - ); - } - - /// default timeout for requests. This will cause a timeout if a resource is not able to be retrieved within a given timeout. - DartNSTimeInterval get timeoutIntervalForResource { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.timeoutIntervalForResource', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - return objc.useMsgSendVariants - ? _objc_msgSend_1ukqyt8Fpret( - object$.ref.pointer, - _sel_timeoutIntervalForResource, - ) - : _objc_msgSend_1ukqyt8( - object$.ref.pointer, - _sel_timeoutIntervalForResource, - ); - } - - /// Uses the classic network loader. - /// - /// NOTE: FTP and HTTP/1 pipelining are only supported in the classic loading mode. - /// - /// Defaults to YES. The default may be NO in a future OS update. - bool get usesClassicLoadingMode { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.usesClassicLoadingMode', - iOS: (false, (18, 4, 0)), - macOS: (false, (15, 4, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_usesClassicLoadingMode, - ); - } - - /// Causes tasks to wait for network connectivity to become available, rather - /// than immediately failing with an error (such as NSURLErrorNotConnectedToInternet) - /// when it is not. When waiting for connectivity, the timeoutIntervalForRequest - /// property does not apply, but the timeoutIntervalForResource property does. - /// - /// Unsatisfactory connectivity (that requires waiting) includes cases where the - /// device has limited or insufficient connectivity for a task (e.g., only has a - /// cellular connection but the allowsCellularAccess property is NO, or requires - /// a VPN connection in order to reach the desired host). - /// - /// Default value is NO. Ignored by background sessions, as background sessions - /// always wait for connectivity. - bool get waitsForConnectivity { - objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.waitsForConnectivity', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_waitsForConnectivity); - } -} - -late final _sel_sessionWithConfiguration_ = objc.registerName( - "sessionWithConfiguration:", -); - -/// WARNING: NSURLSessionDelegate is a stub. To generate bindings for this class, include -/// NSURLSessionDelegate in your config's objc-protocols list. -/// -/// Messages related to the URL session as a whole -extension type NSURLSessionDelegate._(objc.ObjCProtocol object$) - implements objc.ObjCProtocol, objc.NSObjectProtocol { - /// Constructs a [NSURLSessionDelegate] that points to the same underlying object as [other]. - NSURLSessionDelegate.as(objc.ObjCObject other) : object$ = other; - - /// Constructs a [NSURLSessionDelegate] that wraps the given raw object pointer. - NSURLSessionDelegate.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); -} - -late final _class_NSOperationQueue = objc.getClass("NSOperationQueue"); - -/// WARNING: NSOperation is a stub. To generate bindings for this class, include -/// NSOperation in your config's objc-interfaces list. -/// -/// NSOperation -extension type NSOperation._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject { - /// Constructs a [NSOperation] that points to the same underlying object as [other]. - NSOperation.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSOperation', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - } - - /// Constructs a [NSOperation] that wraps the given raw object pointer. - NSOperation.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSOperation', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - } -} - -late final _sel_addOperation_ = objc.registerName("addOperation:"); -late final _sel_addOperations_waitUntilFinished_ = objc.registerName( - "addOperations:waitUntilFinished:", -); -final _objc_msgSend_6p7ndb = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - bool, - ) - >(); -late final _sel_addOperationWithBlock_ = objc.registerName( - "addOperationWithBlock:", -); -final _objc_msgSend_f167m6 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_addBarrierBlock_ = objc.registerName("addBarrierBlock:"); -late final _sel_maxConcurrentOperationCount = objc.registerName( - "maxConcurrentOperationCount", -); -late final _sel_setMaxConcurrentOperationCount_ = objc.registerName( - "setMaxConcurrentOperationCount:", -); -late final _sel_isSuspended = objc.registerName("isSuspended"); -late final _sel_setSuspended_ = objc.registerName("setSuspended:"); -late final _sel_name = objc.registerName("name"); -late final _sel_setName_ = objc.registerName("setName:"); -late final _sel_qualityOfService = objc.registerName("qualityOfService"); -final _objc_msgSend_oi8iq9 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setQualityOfService_ = objc.registerName( - "setQualityOfService:", -); -final _objc_msgSend_n2da1l = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_underlyingQueue = objc.registerName("underlyingQueue"); -late final _sel_setUnderlyingQueue_ = objc.registerName("setUnderlyingQueue:"); -late final _sel_cancelAllOperations = objc.registerName("cancelAllOperations"); -late final _sel_waitUntilAllOperationsAreFinished = objc.registerName( - "waitUntilAllOperationsAreFinished", -); -late final _sel_currentQueue = objc.registerName("currentQueue"); -late final _sel_mainQueue = objc.registerName("mainQueue"); -late final _sel_operations = objc.registerName("operations"); -late final _sel_operationCount = objc.registerName("operationCount"); - -/// NSDeprecated -extension NSDeprecated$3 on NSOperationQueue { - /// operationCount - DartNSUInteger get operationCount { - objc.checkOsVersionInternal( - 'NSOperationQueue.operationCount', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_operationCount); - } - - /// These two functions are inherently a race condition and should be avoided if possible - objc.NSArray get operations { - objc.checkOsVersionInternal( - 'NSOperationQueue.operations', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_operations); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } -} - -/// NSOperationQueue -extension type NSOperationQueue._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject, NSProgressReporting { - /// Constructs a [NSOperationQueue] that points to the same underlying object as [other]. - NSOperationQueue.as(objc.ObjCObject other) : object$ = other { - assert(isA(object$)); - } - - /// Constructs a [NSOperationQueue] that wraps the given raw object pointer. - NSOperationQueue.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSOperationQueue]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSOperationQueue, - ); - - /// alloc - static NSOperationQueue alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSOperationQueue, _sel_alloc); - return NSOperationQueue.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSOperationQueue allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSOperationQueue, - _sel_allocWithZone_, - zone, - ); - return NSOperationQueue.fromPointer($ret, retain: false, release: true); - } - - /// currentQueue - static NSOperationQueue? getCurrentQueue() { - objc.checkOsVersionInternal( - 'NSOperationQueue.currentQueue', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSOperationQueue, - _sel_currentQueue, - ); - return $ret.address == 0 - ? null - : NSOperationQueue.fromPointer($ret, retain: true, release: true); - } - - /// mainQueue - static NSOperationQueue getMainQueue() { - objc.checkOsVersionInternal( - 'NSOperationQueue.mainQueue', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz(_class_NSOperationQueue, _sel_mainQueue); - return NSOperationQueue.fromPointer($ret, retain: true, release: true); - } - - /// new - static NSOperationQueue new$() { - final $ret = _objc_msgSend_151sglz(_class_NSOperationQueue, _sel_new); - return NSOperationQueue.fromPointer($ret, retain: false, release: true); - } - - /// Returns a new instance of NSOperationQueue constructed with the default `new` method. - NSOperationQueue() : this.as(new$().object$); -} - -extension NSOperationQueue$Methods on NSOperationQueue { - /// @method addBarrierBlock: - /// @param barrier A block to execute - /// @discussion The `addBarrierBlock:` method executes the block when the NSOperationQueue has finished all enqueued operations and - /// prevents any subsequent operations to be executed until the barrier has been completed. This acts similarly to the - /// `dispatch_barrier_async` function. - void addBarrierBlock(objc.ObjCBlock barrier) { - objc.checkOsVersionInternal( - 'NSOperationQueue.addBarrierBlock:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_addBarrierBlock_, - barrier.ref.pointer, - ); - } - - /// addOperation: - void addOperation(NSOperation op) { - objc.checkOsVersionInternal( - 'NSOperationQueue.addOperation:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_addOperation_, - op.ref.pointer, - ); - } - - /// addOperationWithBlock: - void addOperationWithBlock(objc.ObjCBlock block) { - objc.checkOsVersionInternal( - 'NSOperationQueue.addOperationWithBlock:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_addOperationWithBlock_, - block.ref.pointer, - ); - } - - /// addOperations:waitUntilFinished: - void addOperations(objc.NSArray ops, {required bool waitUntilFinished}) { - objc.checkOsVersionInternal( - 'NSOperationQueue.addOperations:waitUntilFinished:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - _objc_msgSend_6p7ndb( - object$.ref.pointer, - _sel_addOperations_waitUntilFinished_, - ops.ref.pointer, - waitUntilFinished, - ); - } - - /// cancelAllOperations - void cancelAllOperations() { - objc.checkOsVersionInternal( - 'NSOperationQueue.cancelAllOperations', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_cancelAllOperations); - } - - /// init - NSOperationQueue init() { - objc.checkOsVersionInternal( - 'NSOperationQueue.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSOperationQueue.fromPointer($ret, retain: false, release: true); - } - - /// isSuspended - bool get isSuspended { - objc.checkOsVersionInternal( - 'NSOperationQueue.isSuspended', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_isSuspended); - } - - /// maxConcurrentOperationCount - DartNSInteger get maxConcurrentOperationCount { - objc.checkOsVersionInternal( - 'NSOperationQueue.maxConcurrentOperationCount', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - return _objc_msgSend_1hz7y9r( - object$.ref.pointer, - _sel_maxConcurrentOperationCount, - ); - } - - /// name - objc.NSString? get name { - objc.checkOsVersionInternal( - 'NSOperationQueue.name', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_name); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// progress - objc.NSProgress get progress { - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_progress); - return objc.NSProgress.fromPointer($ret, retain: true, release: true); - } - - /// qualityOfService - objc.NSQualityOfService get qualityOfService { - objc.checkOsVersionInternal( - 'NSOperationQueue.qualityOfService', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - final $ret = _objc_msgSend_oi8iq9( - object$.ref.pointer, - _sel_qualityOfService, - ); - return objc.NSQualityOfService.fromValue($ret); - } - - /// setMaxConcurrentOperationCount: - set maxConcurrentOperationCount(DartNSInteger value) { - objc.checkOsVersionInternal( - 'NSOperationQueue.setMaxConcurrentOperationCount:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_4sp4xj( - object$.ref.pointer, - _sel_setMaxConcurrentOperationCount_, - value, - ); - } - - /// setName: - set name(objc.NSString? value) { - objc.checkOsVersionInternal( - 'NSOperationQueue.setName:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setName_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// setQualityOfService: - set qualityOfService(objc.NSQualityOfService value) { - objc.checkOsVersionInternal( - 'NSOperationQueue.setQualityOfService:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_n2da1l( - object$.ref.pointer, - _sel_setQualityOfService_, - value.value, - ); - } - - /// setSuspended: - set isSuspended(bool value) { - objc.checkOsVersionInternal( - 'NSOperationQueue.setSuspended:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_1s56lr9(object$.ref.pointer, _sel_setSuspended_, value); - } - - /// actually retain - set underlyingQueue(Dartdispatch_queue_t? value) { - objc.checkOsVersionInternal( - 'NSOperationQueue.setUnderlyingQueue:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setUnderlyingQueue_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// actually retain - Dartdispatch_queue_t? get underlyingQueue { - objc.checkOsVersionInternal( - 'NSOperationQueue.underlyingQueue', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_underlyingQueue, - ); - return $ret.address == 0 - ? null - : objc.NSObject.fromPointer($ret, retain: true, release: true); - } - - /// waitUntilAllOperationsAreFinished - void waitUntilAllOperationsAreFinished() { - objc.checkOsVersionInternal( - 'NSOperationQueue.waitUntilAllOperationsAreFinished', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_1pl9qdv( - object$.ref.pointer, - _sel_waitUntilAllOperationsAreFinished, - ); - } -} - -late final _sel_sessionWithConfiguration_delegate_delegateQueue_ = objc - .registerName("sessionWithConfiguration:delegate:delegateQueue:"); -late final _sel_delegateQueue = objc.registerName("delegateQueue"); -late final _sel_configuration = objc.registerName("configuration"); -late final _sel_sessionDescription = objc.registerName("sessionDescription"); -late final _sel_setSessionDescription_ = objc.registerName( - "setSessionDescription:", -); -late final _sel_finishTasksAndInvalidate = objc.registerName( - "finishTasksAndInvalidate", -); -late final _sel_invalidateAndCancel = objc.registerName("invalidateAndCancel"); -late final _sel_resetWithCompletionHandler_ = objc.registerName( - "resetWithCompletionHandler:", -); -late final _sel_flushWithCompletionHandler_ = objc.registerName( - "flushWithCompletionHandler:", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSArray_NSArray_NSArray { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - > - fromFunction( - void Function(objc.NSArray, objc.NSArray, objc.NSArray) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - objc.NSArray.fromPointer(arg0, retain: true, release: true), - objc.NSArray.fromPointer(arg1, retain: true, release: true), - objc.NSArray.fromPointer(arg2, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - > - listener( - void Function(objc.NSArray, objc.NSArray, objc.NSArray) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - objc.NSArray.fromPointer(arg0, retain: false, release: true), - objc.NSArray.fromPointer(arg1, retain: false, release: true), - objc.NSArray.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - > - blocking( - void Function(objc.NSArray, objc.NSArray, objc.NSArray) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - objc.NSArray.fromPointer(arg0, retain: false, release: true), - objc.NSArray.fromPointer(arg1, retain: false, release: true), - objc.NSArray.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - objc.NSArray.fromPointer(arg0, retain: false, release: true), - objc.NSArray.fromPointer(arg1, retain: false, release: true), - objc.NSArray.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSArray_NSArray_NSArray$CallExtension - on - objc.ObjCBlock< - ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) - > { - void call(objc.NSArray arg0, objc.NSArray arg1, objc.NSArray arg2) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2.ref.pointer); -} - -late final _sel_getTasksWithCompletionHandler_ = objc.registerName( - "getTasksWithCompletionHandler:", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSArray { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(objc.NSArray) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => - fn(objc.NSArray.fromPointer(arg0, retain: true, release: true)), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(objc.NSArray) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => - fn(objc.NSArray.fromPointer(arg0, retain: false, release: true)), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(objc.NSArray) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => - fn(objc.NSArray.fromPointer(arg0, retain: false, release: true)), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => - fn(objc.NSArray.fromPointer(arg0, retain: false, release: true)), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ) { - try { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - >() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSArray$CallExtension - on objc.ObjCBlock { - void call(objc.NSArray arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0.ref.pointer); -} - -late final _sel_getAllTasksWithCompletionHandler_ = objc.registerName( - "getAllTasksWithCompletionHandler:", -); -late final _sel_dataTaskWithRequest_ = objc.registerName( - "dataTaskWithRequest:", -); -late final _sel_dataTaskWithURL_ = objc.registerName("dataTaskWithURL:"); - -/// WARNING: NSURLSessionUploadTask is a stub. To generate bindings for this class, include -/// NSURLSessionUploadTask in your config's objc-interfaces list. -/// -/// An NSURLSessionUploadTask does not currently provide any additional -/// functionality over an NSURLSessionDataTask. All delegate messages -/// that may be sent referencing an NSURLSessionDataTask equally apply -/// to NSURLSessionUploadTasks. -extension type NSURLSessionUploadTask._(objc.ObjCObject object$) - implements objc.ObjCObject, NSURLSessionDataTask { - /// Constructs a [NSURLSessionUploadTask] that points to the same underlying object as [other]. - NSURLSessionUploadTask.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSessionUploadTask', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - } - - /// Constructs a [NSURLSessionUploadTask] that wraps the given raw object pointer. - NSURLSessionUploadTask.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSessionUploadTask', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - } -} - -late final _sel_uploadTaskWithRequest_fromFile_ = objc.registerName( - "uploadTaskWithRequest:fromFile:", -); -late final _sel_uploadTaskWithRequest_fromData_ = objc.registerName( - "uploadTaskWithRequest:fromData:", -); -late final _sel_uploadTaskWithResumeData_ = objc.registerName( - "uploadTaskWithResumeData:", -); -late final _sel_uploadTaskWithStreamedRequest_ = objc.registerName( - "uploadTaskWithStreamedRequest:", -); -late final _class_NSURLSessionDownloadTask = objc.getClass( - "NSURLSessionDownloadTask", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSData { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(objc.NSData?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(objc.NSData?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(objc.NSData?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ) { - try { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - >() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSData$CallExtension - on objc.ObjCBlock { - void call(objc.NSData? arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); -} - -late final _sel_cancelByProducingResumeData_ = objc.registerName( - "cancelByProducingResumeData:", -); - -/// NSURLSessionDownloadTask is a task that represents a download to -/// local storage. -extension type NSURLSessionDownloadTask._(objc.ObjCObject object$) - implements objc.ObjCObject, NSURLSessionTask { - /// Constructs a [NSURLSessionDownloadTask] that points to the same underlying object as [other]. - NSURLSessionDownloadTask.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadTask', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSURLSessionDownloadTask] that wraps the given raw object pointer. - NSURLSessionDownloadTask.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadTask', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLSessionDownloadTask]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLSessionDownloadTask, - ); - - /// alloc - static NSURLSessionDownloadTask alloc() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionDownloadTask, - _sel_alloc, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// allocWithZone: - static NSURLSessionDownloadTask allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSessionDownloadTask, - _sel_allocWithZone_, - zone, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// new - static NSURLSessionDownloadTask new$() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionDownloadTask, - _sel_new, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// Returns a new instance of NSURLSessionDownloadTask constructed with the default `new` method. - NSURLSessionDownloadTask() : this.as(new$().object$); -} - -extension NSURLSessionDownloadTask$Methods on NSURLSessionDownloadTask { - /// Cancel the download (and calls the superclass -cancel). If - /// conditions will allow for resuming the download in the future, the - /// callback will be called with an opaque data blob, which may be used - /// with -downloadTaskWithResumeData: to attempt to resume the download. - /// If resume data cannot be created, the completion handler will be - /// called with nil resumeData. - void cancelByProducingResumeData( - objc.ObjCBlock completionHandler, - ) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadTask.cancelByProducingResumeData:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_cancelByProducingResumeData_, - completionHandler.ref.pointer, - ); - } - - /// init - NSURLSessionDownloadTask init() { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadTask.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: false, - release: true, - ); - } -} - -late final _sel_downloadTaskWithRequest_ = objc.registerName( - "downloadTaskWithRequest:", -); -late final _sel_downloadTaskWithURL_ = objc.registerName( - "downloadTaskWithURL:", -); -late final _sel_downloadTaskWithResumeData_ = objc.registerName( - "downloadTaskWithResumeData:", -); - -/// WARNING: NSURLSessionStreamTask is a stub. To generate bindings for this class, include -/// NSURLSessionStreamTask in your config's objc-interfaces list. -/// -/// An NSURLSessionStreamTask provides an interface to perform reads -/// and writes to a TCP/IP stream created via NSURLSession. This task -/// may be explicitly created from an NSURLSession, or created as a -/// result of the appropriate disposition response to a -/// -URLSession:dataTask:didReceiveResponse: delegate message. -/// -/// NSURLSessionStreamTask can be used to perform asynchronous reads -/// and writes. Reads and writes are enqueued and executed serially, -/// with the completion handler being invoked on the sessions delegate -/// queue. If an error occurs, or the task is canceled, all -/// outstanding read and write calls will have their completion -/// handlers invoked with an appropriate error. -/// -/// It is also possible to create NSInputStream and NSOutputStream -/// instances from an NSURLSessionTask by sending -/// -captureStreams to the task. All outstanding reads and writes are -/// completed before the streams are created. Once the streams are -/// delivered to the session delegate, the task is considered complete -/// and will receive no more messages. These streams are -/// disassociated from the underlying session. -extension type NSURLSessionStreamTask._(objc.ObjCObject object$) - implements objc.ObjCObject, NSURLSessionTask { - /// Constructs a [NSURLSessionStreamTask] that points to the same underlying object as [other]. - NSURLSessionStreamTask.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSessionStreamTask', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - } - - /// Constructs a [NSURLSessionStreamTask] that wraps the given raw object pointer. - NSURLSessionStreamTask.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSessionStreamTask', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - } -} - -late final _sel_streamTaskWithHostName_port_ = objc.registerName( - "streamTaskWithHostName:port:", -); -final _objc_msgSend_9slupp = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - -/// WARNING: NSNetService is a stub. To generate bindings for this class, include -/// NSNetService in your config's objc-interfaces list. -/// -/// NSNetService -extension type NSNetService._(objc.ObjCObject object$) - implements objc.ObjCObject { - /// Constructs a [NSNetService] that points to the same underlying object as [other]. - NSNetService.as(objc.ObjCObject other) : object$ = other {} - - /// Constructs a [NSNetService] that wraps the given raw object pointer. - NSNetService.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} -} - -late final _sel_streamTaskWithNetService_ = objc.registerName( - "streamTaskWithNetService:", -); -late final _class_NSURLSessionWebSocketTask = objc.getClass( - "NSURLSessionWebSocketTask", -); -late final _class_NSURLSessionWebSocketMessage = objc.getClass( - "NSURLSessionWebSocketMessage", -); -late final _sel_initWithData_ = objc.registerName("initWithData:"); -late final _sel_initWithString_ = objc.registerName("initWithString:"); - -enum NSURLSessionWebSocketMessageType { - NSURLSessionWebSocketMessageTypeData(0), - NSURLSessionWebSocketMessageTypeString(1); - - final int value; - const NSURLSessionWebSocketMessageType(this.value); - - static NSURLSessionWebSocketMessageType fromValue(int value) => - switch (value) { - 0 => NSURLSessionWebSocketMessageTypeData, - 1 => NSURLSessionWebSocketMessageTypeString, - _ => throw ArgumentError( - 'Unknown value for NSURLSessionWebSocketMessageType: $value', - ), - }; -} - -late final _sel_type = objc.registerName("type"); -final _objc_msgSend_1qouven = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_data = objc.registerName("data"); -late final _sel_string = objc.registerName("string"); - -/// The client can create a WebSocket message object that will be passed to the send calls -/// and will be delivered from the receive calls. The message can be initialized with data or string. -/// If initialized with data, the string property will be nil and vice versa. -extension type NSURLSessionWebSocketMessage._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject { - /// Constructs a [NSURLSessionWebSocketMessage] that points to the same underlying object as [other]. - NSURLSessionWebSocketMessage.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSURLSessionWebSocketMessage] that wraps the given raw object pointer. - NSURLSessionWebSocketMessage.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLSessionWebSocketMessage]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLSessionWebSocketMessage, - ); - - /// alloc - static NSURLSessionWebSocketMessage alloc() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionWebSocketMessage, - _sel_alloc, - ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// allocWithZone: - static NSURLSessionWebSocketMessage allocWithZone( - ffi.Pointer zone, - ) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSessionWebSocketMessage, - _sel_allocWithZone_, - zone, - ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// new - static NSURLSessionWebSocketMessage new$() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionWebSocketMessage, - _sel_new, - ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// Returns a new instance of NSURLSessionWebSocketMessage constructed with the default `new` method. - NSURLSessionWebSocketMessage() : this.as(new$().object$); -} - -extension NSURLSessionWebSocketMessage$Methods on NSURLSessionWebSocketMessage { - /// data - objc.NSData? get data { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage.data', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_data); - return $ret.address == 0 - ? null - : objc.NSData.fromPointer($ret, retain: true, release: true); - } - - /// init - NSURLSessionWebSocketMessage init() { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// Create a message with data type - NSURLSessionWebSocketMessage initWithData(objc.NSData data) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage.initWithData:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithData_, - data.ref.pointer, - ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// Create a message with string type - NSURLSessionWebSocketMessage initWithString(objc.NSString string) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage.initWithString:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithString_, - string.ref.pointer, - ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// string - objc.NSString? get string { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage.string', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_string); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// type - NSURLSessionWebSocketMessageType get type { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage.type', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1qouven(object$.ref.pointer, _sel_type); - return NSURLSessionWebSocketMessageType.fromValue($ret); - } -} - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSError.fromPointer(arg0, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSError.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSError.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSError.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ) { - try { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - >() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSError$CallExtension - on objc.ObjCBlock { - void call(objc.NSError? arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); -} - -late final _sel_sendMessage_completionHandler_ = objc.registerName( - "sendMessage:completionHandler:", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSURLSessionWebSocketMessage_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - > - fromFunction( - void Function(NSURLSessionWebSocketMessage?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : NSURLSessionWebSocketMessage.fromPointer( - arg0, - retain: true, - release: true, - ), - arg1.address == 0 - ? null - : objc.NSError.fromPointer(arg1, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - > - listener( - void Function(NSURLSessionWebSocketMessage?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : NSURLSessionWebSocketMessage.fromPointer( - arg0, - retain: false, - release: true, - ), - arg1.address == 0 - ? null - : objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_pfv6jd(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - > - blocking( - void Function(NSURLSessionWebSocketMessage?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : NSURLSessionWebSocketMessage.fromPointer( - arg0, - retain: false, - release: true, - ), - arg1.address == 0 - ? null - : objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : NSURLSessionWebSocketMessage.fromPointer( - arg0, - retain: false, - release: true, - ), - arg1.address == 0 - ? null - : objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSURLSessionWebSocketMessage_NSError$CallExtension - on - objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - > { - void call(NSURLSessionWebSocketMessage? arg0, objc.NSError? arg1) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0?.ref.pointer ?? ffi.nullptr, - arg1?.ref.pointer ?? ffi.nullptr, - ); -} - -late final _sel_receiveMessageWithCompletionHandler_ = objc.registerName( - "receiveMessageWithCompletionHandler:", -); -late final _sel_sendPingWithPongReceiveHandler_ = objc.registerName( - "sendPingWithPongReceiveHandler:", -); - -/// The WebSocket close codes follow the close codes given in the RFC -sealed class NSURLSessionWebSocketCloseCode { - static const NSURLSessionWebSocketCloseCodeInvalid = 0; - static const NSURLSessionWebSocketCloseCodeNormalClosure = 1000; - static const NSURLSessionWebSocketCloseCodeGoingAway = 1001; - static const NSURLSessionWebSocketCloseCodeProtocolError = 1002; - static const NSURLSessionWebSocketCloseCodeUnsupportedData = 1003; - static const NSURLSessionWebSocketCloseCodeNoStatusReceived = 1005; - static const NSURLSessionWebSocketCloseCodeAbnormalClosure = 1006; - static const NSURLSessionWebSocketCloseCodeInvalidFramePayloadData = 1007; - static const NSURLSessionWebSocketCloseCodePolicyViolation = 1008; - static const NSURLSessionWebSocketCloseCodeMessageTooBig = 1009; - static const NSURLSessionWebSocketCloseCodeMandatoryExtensionMissing = 1010; - static const NSURLSessionWebSocketCloseCodeInternalServerError = 1011; - static const NSURLSessionWebSocketCloseCodeTLSHandshakeFailure = 1015; -} - -late final _sel_cancelWithCloseCode_reason_ = objc.registerName( - "cancelWithCloseCode:reason:", -); -final _objc_msgSend_tqzk0b = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); -late final _sel_maximumMessageSize = objc.registerName("maximumMessageSize"); -late final _sel_setMaximumMessageSize_ = objc.registerName( - "setMaximumMessageSize:", -); -late final _sel_closeCode = objc.registerName("closeCode"); -final _objc_msgSend_1rhk8uh = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_closeReason = objc.registerName("closeReason"); - -/// A WebSocket task can be created with a ws or wss url. A client can also provide -/// a list of protocols it wishes to advertise during the WebSocket handshake phase. -/// Once the handshake is successfully completed the client will be notified through an optional delegate. -/// All reads and writes enqueued before the completion of the handshake will be queued up and -/// executed once the handshake succeeds. Before the handshake completes, the client can be called to handle -/// redirection or authentication using the same delegates as NSURLSessionTask. WebSocket task will also provide -/// support for cookies and will store cookies to the cookie storage on the session and will attach cookies to -/// outgoing HTTP handshake requests. -extension type NSURLSessionWebSocketTask._(objc.ObjCObject object$) - implements objc.ObjCObject, NSURLSessionTask { - /// Constructs a [NSURLSessionWebSocketTask] that points to the same underlying object as [other]. - NSURLSessionWebSocketTask.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSURLSessionWebSocketTask] that wraps the given raw object pointer. - NSURLSessionWebSocketTask.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLSessionWebSocketTask]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLSessionWebSocketTask, - ); - - /// alloc - static NSURLSessionWebSocketTask alloc() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionWebSocketTask, - _sel_alloc, - ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// allocWithZone: - static NSURLSessionWebSocketTask allocWithZone( - ffi.Pointer zone, - ) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSessionWebSocketTask, - _sel_allocWithZone_, - zone, - ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// new - static NSURLSessionWebSocketTask new$() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionWebSocketTask, - _sel_new, - ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// Returns a new instance of NSURLSessionWebSocketTask constructed with the default `new` method. - NSURLSessionWebSocketTask() : this.as(new$().object$); -} - -extension NSURLSessionWebSocketTask$Methods on NSURLSessionWebSocketTask { - /// Sends a close frame with the given closeCode. An optional reason can be provided while sending the close frame. - /// Simply calling cancel on the task will result in a cancellation frame being sent without any reason. - void cancelWithCloseCode(DartNSInteger closeCode, {objc.NSData? reason}) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.cancelWithCloseCode:reason:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_tqzk0b( - object$.ref.pointer, - _sel_cancelWithCloseCode_reason_, - closeCode, - reason?.ref.pointer ?? ffi.nullptr, - ); - } - - /// A task can be queried for it's close code at any point. When the task is not closed, it will be set to NSURLSessionWebSocketCloseCodeInvalid - DartNSInteger get closeCode { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.closeCode', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_1rhk8uh(object$.ref.pointer, _sel_closeCode); - } - - /// A task can be queried for it's close reason at any point. A nil value indicates no closeReason or that the task is still running - objc.NSData? get closeReason { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.closeReason', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_closeReason); - return $ret.address == 0 - ? null - : objc.NSData.fromPointer($ret, retain: true, release: true); - } - - /// init - NSURLSessionWebSocketTask init() { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: false, - release: true, - ); - } - - /// The maximum number of bytes to be buffered before erroring out. This includes the sum of all bytes from continuation frames. Receive calls will error out if this value is reached - DartNSInteger get maximumMessageSize { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.maximumMessageSize', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_1hz7y9r(object$.ref.pointer, _sel_maximumMessageSize); - } - - /// Reads a WebSocket message once all the frames of the message are available. - /// If the maximumMessage size is hit while buffering the frames, the receiveMessage call will error out - /// and all outstanding work will also fail resulting in the end of the task. - void receiveMessageWithCompletionHandler( - objc.ObjCBlock< - ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) - > - completionHandler, - ) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.receiveMessageWithCompletionHandler:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_receiveMessageWithCompletionHandler_, - completionHandler.ref.pointer, - ); - } - - /// Sends a WebSocket message. If an error occurs, any outstanding work will also fail. - /// Note that invocation of the completion handler does not - /// guarantee that the remote side has received all the bytes, only - /// that they have been written to the kernel. - void sendMessage( - NSURLSessionWebSocketMessage message, { - required objc.ObjCBlock completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.sendMessage:completionHandler:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_o762yo( - object$.ref.pointer, - _sel_sendMessage_completionHandler_, - message.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sends a ping frame from the client side. The pongReceiveHandler is invoked when the client - /// receives a pong from the server endpoint. If a connection is lost or an error occurs before receiving - /// the pong from the endpoint, the pongReceiveHandler block will be invoked with an error. - /// Note - the pongReceiveHandler will always be called in the order in which the pings were sent. - void sendPingWithPongReceiveHandler( - objc.ObjCBlock pongReceiveHandler, - ) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.sendPingWithPongReceiveHandler:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_sendPingWithPongReceiveHandler_, - pongReceiveHandler.ref.pointer, - ); - } - - /// The maximum number of bytes to be buffered before erroring out. This includes the sum of all bytes from continuation frames. Receive calls will error out if this value is reached - set maximumMessageSize(DartNSInteger value) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.setMaximumMessageSize:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_4sp4xj( - object$.ref.pointer, - _sel_setMaximumMessageSize_, - value, - ); - } -} - -late final _sel_webSocketTaskWithURL_ = objc.registerName( - "webSocketTaskWithURL:", -); -late final _sel_webSocketTaskWithURL_protocols_ = objc.registerName( - "webSocketTaskWithURL:protocols:", -); -late final _sel_webSocketTaskWithRequest_ = objc.registerName( - "webSocketTaskWithRequest:", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSData_NSURLResponse_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - fromFunction( - void Function(objc.NSData?, NSURLResponse?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: true, release: true), - arg1.address == 0 - ? null - : NSURLResponse.fromPointer(arg1, retain: true, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - listener( - void Function(objc.NSData?, NSURLResponse?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : NSURLResponse.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - blocking( - void Function(objc.NSData?, NSURLResponse?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : NSURLResponse.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : NSURLResponse.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSData_NSURLResponse_NSError$CallExtension - on - objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > { - void call(objc.NSData? arg0, NSURLResponse? arg1, objc.NSError? arg2) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0?.ref.pointer ?? ffi.nullptr, - arg1?.ref.pointer ?? ffi.nullptr, - arg2?.ref.pointer ?? ffi.nullptr, - ); -} - -late final _sel_dataTaskWithRequest_completionHandler_ = objc.registerName( - "dataTaskWithRequest:completionHandler:", -); -final _objc_msgSend_r0bo0s = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_dataTaskWithURL_completionHandler_ = objc.registerName( - "dataTaskWithURL:completionHandler:", -); -late final _sel_uploadTaskWithRequest_fromFile_completionHandler_ = objc - .registerName("uploadTaskWithRequest:fromFile:completionHandler:"); -final _objc_msgSend_2wiv66 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_uploadTaskWithRequest_fromData_completionHandler_ = objc - .registerName("uploadTaskWithRequest:fromData:completionHandler:"); -late final _sel_uploadTaskWithResumeData_completionHandler_ = objc.registerName( - "uploadTaskWithResumeData:completionHandler:", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSURL_NSURLResponse_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > - fromFunction( - void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0.address == 0 - ? null - : objc.NSURL.fromPointer(arg0, retain: true, release: true), - arg1.address == 0 - ? null - : NSURLResponse.fromPointer(arg1, retain: true, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > - listener( - void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0.address == 0 - ? null - : objc.NSURL.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : NSURLResponse.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > - blocking( - void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0.address == 0 - ? null - : objc.NSURL.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : NSURLResponse.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0.address == 0 - ? null - : objc.NSURL.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : NSURLResponse.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSURL_NSURLResponse_NSError$CallExtension - on - objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > { - void call(objc.NSURL? arg0, NSURLResponse? arg1, objc.NSError? arg2) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0?.ref.pointer ?? ffi.nullptr, - arg1?.ref.pointer ?? ffi.nullptr, - arg2?.ref.pointer ?? ffi.nullptr, - ); -} - -late final _sel_downloadTaskWithRequest_completionHandler_ = objc.registerName( - "downloadTaskWithRequest:completionHandler:", -); -late final _sel_downloadTaskWithURL_completionHandler_ = objc.registerName( - "downloadTaskWithURL:completionHandler:", -); -late final _sel_downloadTaskWithResumeData_completionHandler_ = objc - .registerName("downloadTaskWithResumeData:completionHandler:"); - -/// NSURLSession convenience routines deliver results to -/// a completion handler block. These convenience routines -/// are not available to NSURLSessions that are configured -/// as background sessions. -/// -/// Task objects are always created in a suspended state and -/// must be sent the -resume message before they will execute. -extension NSURLSessionAsynchronousConvenience on NSURLSession { - /// data task convenience methods. These methods create tasks that - /// bypass the normal delegate calls for response and data delivery, - /// and provide a simple cancelable asynchronous interface to receiving - /// data. Errors will be returned in the NSURLErrorDomain, - /// see . The delegate, if any, will still be - /// called for authentication challenges. - NSURLSessionDataTask dataTaskWithRequest$1( - NSURLRequest request, { - required objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.dataTaskWithRequest:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_r0bo0s( - object$.ref.pointer, - _sel_dataTaskWithRequest_completionHandler_, - request.ref.pointer, - completionHandler.ref.pointer, - ); - return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); - } - - /// dataTaskWithURL:completionHandler: - NSURLSessionDataTask dataTaskWithURL$1( - objc.NSURL url, { - required objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.dataTaskWithURL:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_r0bo0s( - object$.ref.pointer, - _sel_dataTaskWithURL_completionHandler_, - url.ref.pointer, - completionHandler.ref.pointer, - ); - return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); - } - - /// download task convenience methods. When a download successfully - /// completes, the NSURL will point to a file that must be read or - /// copied during the invocation of the completion routine. The file - /// will be removed automatically. - NSURLSessionDownloadTask downloadTaskWithRequest$1( - NSURLRequest request, { - required objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.downloadTaskWithRequest:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_r0bo0s( - object$.ref.pointer, - _sel_downloadTaskWithRequest_completionHandler_, - request.ref.pointer, - completionHandler.ref.pointer, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// downloadTaskWithResumeData:completionHandler: - NSURLSessionDownloadTask downloadTaskWithResumeData$1( - objc.NSData resumeData, { - required objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.downloadTaskWithResumeData:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_r0bo0s( - object$.ref.pointer, - _sel_downloadTaskWithResumeData_completionHandler_, - resumeData.ref.pointer, - completionHandler.ref.pointer, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// downloadTaskWithURL:completionHandler: - NSURLSessionDownloadTask downloadTaskWithURL$1( - objc.NSURL url, { - required objc.ObjCBlock< - ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) - > - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.downloadTaskWithURL:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_r0bo0s( - object$.ref.pointer, - _sel_downloadTaskWithURL_completionHandler_, - url.ref.pointer, - completionHandler.ref.pointer, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// uploadTaskWithRequest:fromData:completionHandler: - NSURLSessionUploadTask uploadTaskWithRequest$2( - NSURLRequest request, { - objc.NSData? fromData, - required objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithRequest:fromData:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_2wiv66( - object$.ref.pointer, - _sel_uploadTaskWithRequest_fromData_completionHandler_, - request.ref.pointer, - fromData?.ref.pointer ?? ffi.nullptr, - completionHandler.ref.pointer, - ); - return NSURLSessionUploadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// upload convenience method. - NSURLSessionUploadTask uploadTaskWithRequest$3( - NSURLRequest request, { - required objc.NSURL fromFile, - required objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithRequest:fromFile:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_2wiv66( - object$.ref.pointer, - _sel_uploadTaskWithRequest_fromFile_completionHandler_, - request.ref.pointer, - fromFile.ref.pointer, - completionHandler.ref.pointer, - ); - return NSURLSessionUploadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates a URLSessionUploadTask from a resume data blob. If resuming from an upload - /// file, the file must still exist and be unmodified. - /// - /// - Parameter resumeData: Resume data blob from an incomplete upload, such as data returned by the cancelByProducingResumeData: method. - /// - Parameter completionHandler: The completion handler to call when the load request is complete. - /// - Returns: A new session upload task, or nil if the resumeData is invalid. - NSURLSessionUploadTask uploadTaskWithResumeData$1( - objc.NSData resumeData, { - required objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) - > - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithResumeData:completionHandler:', - iOS: (false, (17, 0, 0)), - macOS: (false, (14, 0, 0)), - ); - final $ret = _objc_msgSend_r0bo0s( - object$.ref.pointer, - _sel_uploadTaskWithResumeData_completionHandler_, - resumeData.ref.pointer, - completionHandler.ref.pointer, - ); - return NSURLSessionUploadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } -} - -/// NSURLSession is a replacement API for NSURLConnection. It provides -/// options that affect the policy of, and various aspects of the -/// mechanism by which NSURLRequest objects are retrieved from the -/// network. -/// -/// An NSURLSession may be bound to a delegate object. The delegate is -/// invoked for certain events during the lifetime of a session, such as -/// server authentication or determining whether a resource to be loaded -/// should be converted into a download. -/// -/// NSURLSession instances are thread-safe. -/// -/// The default NSURLSession uses a system provided delegate and is -/// appropriate to use in place of existing code that uses -/// +[NSURLConnection sendAsynchronousRequest:queue:completionHandler:] -/// -/// An NSURLSession creates NSURLSessionTask objects which represent the -/// action of a resource being loaded. These are analogous to -/// NSURLConnection objects but provide for more control and a unified -/// delegate model. -/// -/// NSURLSessionTask objects are always created in a suspended state and -/// must be sent the -resume message before they will execute. -/// -/// Subclasses of NSURLSessionTask are used to syntactically -/// differentiate between data and file downloads. -/// -/// An NSURLSessionDataTask receives the resource as a series of calls to -/// the URLSession:dataTask:didReceiveData: delegate method. This is type of -/// task most commonly associated with retrieving objects for immediate parsing -/// by the consumer. -/// -/// An NSURLSessionUploadTask differs from an NSURLSessionDataTask -/// in how its instance is constructed. Upload tasks are explicitly created -/// by referencing a file or data object to upload, or by utilizing the -/// -URLSession:task:needNewBodyStream: delegate message to supply an upload -/// body. -/// -/// An NSURLSessionDownloadTask will directly write the response data to -/// a temporary file. When completed, the delegate is sent -/// URLSession:downloadTask:didFinishDownloadingToURL: and given an opportunity -/// to move this file to a permanent location in its sandboxed container, or to -/// otherwise read the file. If canceled, an NSURLSessionDownloadTask can -/// produce a data blob that can be used to resume a download at a later -/// time. -/// -/// Beginning with iOS 9 and Mac OS X 10.11, NSURLSessionStream is -/// available as a task type. This allows for direct TCP/IP connection -/// to a given host and port with optional secure handshaking and -/// navigation of proxies. Data tasks may also be upgraded to a -/// NSURLSessionStream task via the HTTP Upgrade: header and appropriate -/// use of the pipelining option of NSURLSessionConfiguration. See RFC -/// 2817 and RFC 6455 for information about the Upgrade: header, and -/// comments below on turning data tasks into stream tasks. -/// -/// An NSURLSessionWebSocketTask is a task that allows clients to connect to servers supporting -/// WebSocket. The task will perform the HTTP handshake to upgrade the connection -/// and once the WebSocket handshake is successful, the client can read and write -/// messages that will be framed using the WebSocket protocol by the framework. -extension type NSURLSession._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject { - /// Constructs a [NSURLSession] that points to the same underlying object as [other]. - NSURLSession.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSession', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSURLSession] that wraps the given raw object pointer. - NSURLSession.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSession', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSURLSession]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLSession, - ); - - /// alloc - static NSURLSession alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSURLSession, _sel_alloc); - return NSURLSession.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSURLSession allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSession, - _sel_allocWithZone_, - zone, - ); - return NSURLSession.fromPointer($ret, retain: false, release: true); - } - - /// new - static NSURLSession new$() { - final $ret = _objc_msgSend_151sglz(_class_NSURLSession, _sel_new); - return NSURLSession.fromPointer($ret, retain: false, release: true); - } - - /// Customization of NSURLSession occurs during creation of a new session. - /// If you only need to use the convenience routines with custom - /// configuration options it is not necessary to specify a delegate. - /// If you do specify a delegate, the delegate will be retained until after - /// the delegate has been sent the URLSession:didBecomeInvalidWithError: message. - static NSURLSession sessionWithConfiguration( - NSURLSessionConfiguration configuration, - ) { - objc.checkOsVersionInternal( - 'NSURLSession.sessionWithConfiguration:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSURLSession, - _sel_sessionWithConfiguration_, - configuration.ref.pointer, - ); - return NSURLSession.fromPointer($ret, retain: true, release: true); - } - - /// sessionWithConfiguration:delegate:delegateQueue: - static NSURLSession sessionWithConfiguration$1( - NSURLSessionConfiguration configuration, { - NSURLSessionDelegate? delegate, - NSOperationQueue? delegateQueue, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.sessionWithConfiguration:delegate:delegateQueue:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_11spmsz( - _class_NSURLSession, - _sel_sessionWithConfiguration_delegate_delegateQueue_, - configuration.ref.pointer, - delegate?.ref.pointer ?? ffi.nullptr, - delegateQueue?.ref.pointer ?? ffi.nullptr, - ); - return NSURLSession.fromPointer($ret, retain: true, release: true); - } - - /// The shared session uses the currently set global NSURLCache, - /// NSHTTPCookieStorage and NSURLCredentialStorage objects. - static NSURLSession getSharedSession() { - objc.checkOsVersionInternal( - 'NSURLSession.sharedSession', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz(_class_NSURLSession, _sel_sharedSession); - return NSURLSession.fromPointer($ret, retain: true, release: true); - } - - /// Returns a new instance of NSURLSession constructed with the default `new` method. - NSURLSession() : this.as(new$().object$); -} - -extension NSURLSession$Methods on NSURLSession { - /// configuration - NSURLSessionConfiguration get configuration { - objc.checkOsVersionInternal( - 'NSURLSession.configuration', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_configuration); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates a data task with the given request. The request may have a body stream. - NSURLSessionDataTask dataTaskWithRequest(NSURLRequest request) { - objc.checkOsVersionInternal( - 'NSURLSession.dataTaskWithRequest:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_dataTaskWithRequest_, - request.ref.pointer, - ); - return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); - } - - /// Creates a data task to retrieve the contents of the given URL. - NSURLSessionDataTask dataTaskWithURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSURLSession.dataTaskWithURL:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_dataTaskWithURL_, - url.ref.pointer, - ); - return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); - } - - /// delegate - NSURLSessionDelegate? get delegate { - objc.checkOsVersionInternal( - 'NSURLSession.delegate', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_delegate); - return $ret.address == 0 - ? null - : NSURLSessionDelegate.fromPointer($ret, retain: true, release: true); - } - - /// delegateQueue - NSOperationQueue get delegateQueue { - objc.checkOsVersionInternal( - 'NSURLSession.delegateQueue', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_delegateQueue); - return NSOperationQueue.fromPointer($ret, retain: true, release: true); - } - - /// Creates a download task with the given request. - NSURLSessionDownloadTask downloadTaskWithRequest(NSURLRequest request) { - objc.checkOsVersionInternal( - 'NSURLSession.downloadTaskWithRequest:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_downloadTaskWithRequest_, - request.ref.pointer, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates a download task with the resume data. If the download cannot be successfully resumed, URLSession:task:didCompleteWithError: will be called. - NSURLSessionDownloadTask downloadTaskWithResumeData(objc.NSData resumeData) { - objc.checkOsVersionInternal( - 'NSURLSession.downloadTaskWithResumeData:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_downloadTaskWithResumeData_, - resumeData.ref.pointer, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates a download task to download the contents of the given URL. - NSURLSessionDownloadTask downloadTaskWithURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSURLSession.downloadTaskWithURL:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_downloadTaskWithURL_, - url.ref.pointer, - ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// -finishTasksAndInvalidate returns immediately and existing tasks will be allowed - /// to run to completion. New tasks may not be created. The session - /// will continue to make delegate callbacks until URLSession:didBecomeInvalidWithError: - /// has been issued. - /// - /// -finishTasksAndInvalidate and -invalidateAndCancel do not - /// have any effect on the shared session instance. - /// - /// When invalidating a background session, it is not safe to create another background - /// session with the same identifier until URLSession:didBecomeInvalidWithError: has - /// been issued. - void finishTasksAndInvalidate() { - objc.checkOsVersionInternal( - 'NSURLSession.finishTasksAndInvalidate', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_finishTasksAndInvalidate); - } - - /// flush storage to disk and clear transient network caches. Invokes completionHandler() on the delegate queue. - void flushWithCompletionHandler( - objc.ObjCBlock completionHandler, - ) { - objc.checkOsVersionInternal( - 'NSURLSession.flushWithCompletionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_flushWithCompletionHandler_, - completionHandler.ref.pointer, - ); - } - - /// invokes completionHandler with all outstanding tasks. - void getAllTasksWithCompletionHandler( - objc.ObjCBlock completionHandler, - ) { - objc.checkOsVersionInternal( - 'NSURLSession.getAllTasksWithCompletionHandler:', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_getAllTasksWithCompletionHandler_, - completionHandler.ref.pointer, - ); - } - - /// invokes completionHandler with outstanding data, upload and download tasks. - void getTasksWithCompletionHandler( - objc.ObjCBlock - completionHandler, - ) { - objc.checkOsVersionInternal( - 'NSURLSession.getTasksWithCompletionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_getTasksWithCompletionHandler_, - completionHandler.ref.pointer, - ); - } - - /// init - NSURLSession init() { - objc.checkOsVersionInternal( - 'NSURLSession.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSURLSession.fromPointer($ret, retain: false, release: true); - } - - /// -invalidateAndCancel acts as -finishTasksAndInvalidate, but issues - /// -cancel to all outstanding tasks for this session. Note task - /// cancellation is subject to the state of the task, and some tasks may - /// have already have completed at the time they are sent -cancel. - void invalidateAndCancel() { - objc.checkOsVersionInternal( - 'NSURLSession.invalidateAndCancel', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_invalidateAndCancel); - } - - /// empty all cookies, cache and credential stores, removes disk files, issues -flushWithCompletionHandler:. Invokes completionHandler() on the delegate queue. - void resetWithCompletionHandler( - objc.ObjCBlock completionHandler, - ) { - objc.checkOsVersionInternal( - 'NSURLSession.resetWithCompletionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_resetWithCompletionHandler_, - completionHandler.ref.pointer, - ); - } - - /// The sessionDescription property is available for the developer to - /// provide a descriptive label for the session. - objc.NSString? get sessionDescription { - objc.checkOsVersionInternal( - 'NSURLSession.sessionDescription', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_sessionDescription, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// The sessionDescription property is available for the developer to - /// provide a descriptive label for the session. - set sessionDescription(objc.NSString? value) { - objc.checkOsVersionInternal( - 'NSURLSession.setSessionDescription:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setSessionDescription_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Creates a bidirectional stream task to a given host and port. - NSURLSessionStreamTask streamTaskWithHostName( - objc.NSString hostname, { - required DartNSInteger port, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.streamTaskWithHostName:port:', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - final $ret = _objc_msgSend_9slupp( - object$.ref.pointer, - _sel_streamTaskWithHostName_port_, - hostname.ref.pointer, - port, - ); - return NSURLSessionStreamTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates a bidirectional stream task with an NSNetService to identify the endpoint. - /// The NSNetService will be resolved before any IO completes. - NSURLSessionStreamTask streamTaskWithNetService(NSNetService service) { - objc.checkOsVersionInternal( - 'NSURLSession.streamTaskWithNetService:', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_streamTaskWithNetService_, - service.ref.pointer, - ); - return NSURLSessionStreamTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates an upload task with the given request. The body of the request is provided from the bodyData. - NSURLSessionUploadTask uploadTaskWithRequest( - NSURLRequest request, { - required objc.NSData fromData, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithRequest:fromData:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_15qeuct( - object$.ref.pointer, - _sel_uploadTaskWithRequest_fromData_, - request.ref.pointer, - fromData.ref.pointer, - ); - return NSURLSessionUploadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates an upload task with the given request. The body of the request will be created from the file referenced by fileURL - NSURLSessionUploadTask uploadTaskWithRequest$1( - NSURLRequest request, { - required objc.NSURL fromFile, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithRequest:fromFile:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_15qeuct( - object$.ref.pointer, - _sel_uploadTaskWithRequest_fromFile_, - request.ref.pointer, - fromFile.ref.pointer, - ); - return NSURLSessionUploadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates an upload task from a resume data blob. Requires the server to support the latest resumable uploads - /// Internet-Draft from the HTTP Working Group, found at - /// https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/ - /// If resuming from an upload file, the file must still exist and be unmodified. If the upload cannot be successfully - /// resumed, URLSession:task:didCompleteWithError: will be called. - /// - /// - Parameter resumeData: Resume data blob from an incomplete upload, such as data returned by the cancelByProducingResumeData: method. - /// - Returns: A new session upload task, or nil if the resumeData is invalid. - NSURLSessionUploadTask uploadTaskWithResumeData(objc.NSData resumeData) { - objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithResumeData:', - iOS: (false, (17, 0, 0)), - macOS: (false, (14, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_uploadTaskWithResumeData_, - resumeData.ref.pointer, - ); - return NSURLSessionUploadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates an upload task with the given request. The previously set body stream of the request (if any) is ignored and the URLSession:task:needNewBodyStream: delegate will be called when the body payload is required. - NSURLSessionUploadTask uploadTaskWithStreamedRequest(NSURLRequest request) { - objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithStreamedRequest:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_uploadTaskWithStreamedRequest_, - request.ref.pointer, - ); - return NSURLSessionUploadTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates a WebSocket task given the request. The request properties can be modified and will be used by the task during the HTTP handshake phase. - /// Clients who want to add custom protocols can do so by directly adding headers with the key Sec-WebSocket-Protocol - /// and a comma separated list of protocols they wish to negotiate with the server. The custom HTTP headers provided by the client will remain unchanged for the handshake with the server. - NSURLSessionWebSocketTask webSocketTaskWithRequest(NSURLRequest request) { - objc.checkOsVersionInternal( - 'NSURLSession.webSocketTaskWithRequest:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_webSocketTaskWithRequest_, - request.ref.pointer, - ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates a WebSocket task given the url. The given url must have a ws or wss scheme. - NSURLSessionWebSocketTask webSocketTaskWithURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSURLSession.webSocketTaskWithURL:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_webSocketTaskWithURL_, - url.ref.pointer, - ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// Creates a WebSocket task given the url and an array of protocols. The protocols will be used in the WebSocket handshake to - /// negotiate a preferred protocol with the server - /// Note - The protocol will not affect the WebSocket framing. More details on the protocol can be found by reading the WebSocket RFC - NSURLSessionWebSocketTask webSocketTaskWithURL$1( - objc.NSURL url, { - required objc.NSArray protocols, - }) { - objc.checkOsVersionInternal( - 'NSURLSession.webSocketTaskWithURL:protocols:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_15qeuct( - object$.ref.pointer, - _sel_webSocketTaskWithURL_protocols_, - url.ref.pointer, - protocols.ref.pointer, - ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: true, - release: true, - ); - } -} - -/// Disposition options for various delegate messages -enum NSURLSessionDelayedRequestDisposition { - /// Use the original request provided when the task was created; the request parameter is ignored. - NSURLSessionDelayedRequestContinueLoading(0), - - /// Use the specified request, which may not be nil. - NSURLSessionDelayedRequestUseNewRequest(1), - - /// Cancel the task; the request parameter is ignored. - NSURLSessionDelayedRequestCancel(2); - - final int value; - const NSURLSessionDelayedRequestDisposition(this.value); - - static NSURLSessionDelayedRequestDisposition fromValue(int value) => - switch (value) { - 0 => NSURLSessionDelayedRequestContinueLoading, - 1 => NSURLSessionDelayedRequestUseNewRequest, - 2 => NSURLSessionDelayedRequestCancel, - _ => throw ArgumentError( - 'Unknown value for NSURLSessionDelayedRequestDisposition: $value', - ), - }; -} - -enum NSURLSessionAuthChallengeDisposition { - /// Use the specified credential, which may be nil - NSURLSessionAuthChallengeUseCredential(0), - - /// Default handling for the challenge - as if this delegate were not implemented; the credential parameter is ignored. - NSURLSessionAuthChallengePerformDefaultHandling(1), - - /// The entire request will be canceled; the credential parameter is ignored. - NSURLSessionAuthChallengeCancelAuthenticationChallenge(2), - - /// This challenge is rejected and the next authentication protection space should be tried; the credential parameter is ignored. - NSURLSessionAuthChallengeRejectProtectionSpace(3); - - final int value; - const NSURLSessionAuthChallengeDisposition(this.value); - - static NSURLSessionAuthChallengeDisposition fromValue(int value) => - switch (value) { - 0 => NSURLSessionAuthChallengeUseCredential, - 1 => NSURLSessionAuthChallengePerformDefaultHandling, - 2 => NSURLSessionAuthChallengeCancelAuthenticationChallenge, - 3 => NSURLSessionAuthChallengeRejectProtectionSpace, - _ => throw ArgumentError( - 'Unknown value for NSURLSessionAuthChallengeDisposition: $value', - ), - }; -} - -enum NSURLSessionResponseDisposition { - /// Cancel the load, this is the same as -[task cancel] - NSURLSessionResponseCancel(0), - - /// Allow the load to continue - NSURLSessionResponseAllow(1), - - /// Turn this request into a download - NSURLSessionResponseBecomeDownload(2), - - /// Turn this task into a stream task - NSURLSessionResponseBecomeStream(3); - - final int value; - const NSURLSessionResponseDisposition(this.value); - - static NSURLSessionResponseDisposition fromValue(int value) => - switch (value) { - 0 => NSURLSessionResponseCancel, - 1 => NSURLSessionResponseAllow, - 2 => NSURLSessionResponseBecomeDownload, - 3 => NSURLSessionResponseBecomeStream, - _ => throw ArgumentError( - 'Unknown value for NSURLSessionResponseDisposition: $value', - ), - }; -} - -late final _protocol_NSURLSessionDataDelegate = objc.getProtocol( - "NSURLSessionDataDelegate", -); -late final _sel_conformsToProtocol_ = objc.registerName("conformsToProtocol:"); -final _objc_msgSend_e3qsqz = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSURLSessionResponseDisposition { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer> ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(NSURLSessionResponseDisposition) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(NSURLSessionResponseDisposition) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_16sve1d(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(NSURLSessionResponseDisposition) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_16sve1d( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - int arg0, - ) { - (objc.getBlockClosure(block) as void Function(int))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, NSInteger) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, NSInteger) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - int arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(int))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - int arg0, - ) => block.ref.target - .cast>() - .asFunction()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, NSInteger) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - int arg0, - ) => (objc.getBlockClosure(block) as void Function(int))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, NSInteger) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSURLSessionResponseDisposition$CallExtension - on objc.ObjCBlock { - void call(NSURLSessionResponseDisposition arg0) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - NSInteger arg0, - ) - > - >() - .asFunction, int)>()( - ref.pointer, - arg0.value, - ); -} - -late final _sel_URLSession_dataTask_didReceiveResponse_completionHandler_ = objc - .registerName("URLSession:dataTask:didReceiveResponse:completionHandler:"); -final _objc_msgSend_m7tls4 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(NSInteger arg0, ffi.Pointer arg1) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - fromFunction( - void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (int arg0, ffi.Pointer arg1) => fn( - NSURLSessionDelayedRequestDisposition.fromValue(arg0), - arg1.address == 0 - ? null - : NSURLRequest.fromPointer(arg1, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (int arg0, ffi.Pointer arg1) => fn( - NSURLSessionDelayedRequestDisposition.fromValue(arg0), - arg1.address == 0 - ? null - : NSURLRequest.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1otpo83(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (int arg0, ffi.Pointer arg1) => fn( - NSURLSessionDelayedRequestDisposition.fromValue(arg0), - arg1.address == 0 - ? null - : NSURLRequest.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (int arg0, ffi.Pointer arg1) => fn( - NSURLSessionDelayedRequestDisposition.fromValue(arg0), - arg1.address == 0 - ? null - : NSURLRequest.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1otpo83( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - int arg0, - ffi.Pointer arg1, - ) { - (objc.getBlockClosure(block) - as void Function(int, ffi.Pointer))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - int arg0, - ffi.Pointer arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function(int, ffi.Pointer))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - int arg0, - ffi.Pointer arg1, - ) => - block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - NSInteger arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction)>()( - arg0, - arg1, - ); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - int arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as void Function(int, ffi.Pointer))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest$CallExtension - on objc.ObjCBlock { - void call(NSURLSessionDelayedRequestDisposition arg0, NSURLRequest? arg1) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - NSInteger arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - int, - ffi.Pointer, - ) - >()(ref.pointer, arg0.value, arg1?.ref.pointer ?? ffi.nullptr); -} - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLResponse, objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), - NSURLResponse.fromPointer(arg3, retain: true, release: true), - ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( - arg4, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLResponse.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xx612k(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLResponse.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLResponse.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLResponse, objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLResponse arg3, - objc.ObjCBlock arg4, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - arg4.ref.pointer, - ); -} - -late final _sel_URLSession_dataTask_didBecomeDownloadTask_ = objc.registerName( - "URLSession:dataTask:didBecomeDownloadTask:", -); -final _objc_msgSend_r8gdi7 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _class_NSHTTPURLResponse = objc.getClass("NSHTTPURLResponse"); -late final _sel_initWithURL_statusCode_HTTPVersion_headerFields_ = objc - .registerName("initWithURL:statusCode:HTTPVersion:headerFields:"); -final _objc_msgSend_xw7l5 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_statusCode = objc.registerName("statusCode"); -late final _sel_allHeaderFields = objc.registerName("allHeaderFields"); -late final _sel_localizedStringForStatusCode_ = objc.registerName( - "localizedStringForStatusCode:", -); -final _objc_msgSend_qugqlf = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - -/// NSHTTPURLResponse -extension type NSHTTPURLResponse._(objc.ObjCObject object$) - implements objc.ObjCObject, NSURLResponse { - /// Constructs a [NSHTTPURLResponse] that points to the same underlying object as [other]. - NSHTTPURLResponse.as(objc.ObjCObject other) : object$ = other { - assert(isA(object$)); - } - - /// Constructs a [NSHTTPURLResponse] that wraps the given raw object pointer. - NSHTTPURLResponse.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSHTTPURLResponse]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSHTTPURLResponse, - ); - - /// alloc - static NSHTTPURLResponse alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSHTTPURLResponse, _sel_alloc); - return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSHTTPURLResponse allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSHTTPURLResponse, - _sel_allocWithZone_, - zone, - ); - return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method localizedStringForStatusCode: - /// @abstract Convenience method which returns a localized string - /// corresponding to the status code for this response. - /// @param statusCode the status code to use to produce a localized string. - /// @result A localized string corresponding to the given status code. - static objc.NSString localizedStringForStatusCode(DartNSInteger statusCode) { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.localizedStringForStatusCode:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_qugqlf( - _class_NSHTTPURLResponse, - _sel_localizedStringForStatusCode_, - statusCode, - ); - return objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// new - static NSHTTPURLResponse new$() { - final $ret = _objc_msgSend_151sglz(_class_NSHTTPURLResponse, _sel_new); - return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// supportsSecureCoding - static bool getSupportsSecureCoding() { - return _objc_msgSend_91o635( - _class_NSHTTPURLResponse, - _sel_supportsSecureCoding, - ); - } - - /// Returns a new instance of NSHTTPURLResponse constructed with the default `new` method. - NSHTTPURLResponse() : this.as(new$().object$); -} - -extension NSHTTPURLResponse$Methods on NSHTTPURLResponse { - /// ! - /// @abstract Returns a dictionary containing all the HTTP header fields - /// of the receiver. - /// @discussion By examining this header dictionary, clients can see - /// the "raw" header information which was reported to the protocol - /// implementation by the HTTP server. This may be of use to - /// sophisticated or special-purpose HTTP clients. - /// @result A dictionary containing all the HTTP header fields of the - /// receiver. - objc.NSDictionary get allHeaderFields { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.allHeaderFields', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_allHeaderFields, - ); - return objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } - - /// init - NSHTTPURLResponse init() { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// initWithCoder: - NSHTTPURLResponse? initWithCoder(objc.NSCoder coder) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithCoder_, - coder.ref.pointer, - ); - return $ret.address == 0 - ? null - : NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithURL:MIMEType:expectedContentLength:textEncodingName: - /// @abstract Initialize an NSURLResponse with the provided values. - /// @param URL the URL - /// @param MIMEType the MIME content type of the response - /// @param length the expected content length of the associated data - /// @param name the name of the text encoding for the associated data, if applicable, else nil - /// @result The initialized NSURLResponse. - /// @discussion This is the designated initializer for NSURLResponse. - NSHTTPURLResponse initWithUrlAndMIMEType( - objc.NSURL URL, { - objc.NSString? MIMEType, - required DartNSInteger length, - objc.NSString? name, - }) { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.initWithURL:MIMEType:expectedContentLength:textEncodingName:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - final $ret = _objc_msgSend_l9ppnx( - object$.ref.retainAndReturnPointer(), - _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_, - URL.ref.pointer, - MIMEType?.ref.pointer ?? ffi.nullptr, - length, - name?.ref.pointer ?? ffi.nullptr, - ); - return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @method initWithURL:statusCode:HTTPVersion:headerFields: - /// @abstract initializer for NSHTTPURLResponse objects. - /// @param url the URL from which the response was generated. - /// @param statusCode an HTTP status code. - /// @param HTTPVersion The version of the HTTP response as represented by the server. This is typically represented as "HTTP/1.1". - /// @param headerFields A dictionary representing the header keys and values of the server response. - /// @result the instance of the object, or NULL if an error occurred during initialization. - /// @discussion This API was introduced in Mac OS X 10.7.2 and iOS 5.0 and is not available prior to those releases. - NSHTTPURLResponse? initWithURLAndStatusCode( - objc.NSURL url, { - required DartNSInteger statusCode, - objc.NSString? HTTPVersion, - objc.NSDictionary? headerFields, - }) { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.initWithURL:statusCode:HTTPVersion:headerFields:', - iOS: (false, (5, 0, 0)), - macOS: (false, (10, 7, 0)), - ); - final $ret = _objc_msgSend_xw7l5( - object$.ref.retainAndReturnPointer(), - _sel_initWithURL_statusCode_HTTPVersion_headerFields_, - url.ref.pointer, - statusCode, - HTTPVersion?.ref.pointer ?? ffi.nullptr, - headerFields?.ref.pointer ?? ffi.nullptr, - ); - return $ret.address == 0 - ? null - : NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); - } - - /// ! - /// @abstract Returns the HTTP status code of the receiver. - /// @result The HTTP status code of the receiver. - DartNSInteger get statusCode { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.statusCode', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), - ); - return _objc_msgSend_1hz7y9r(object$.ref.pointer, _sel_statusCode); - } - - /// ! - /// @method valueForHTTPHeaderField: - /// @abstract Returns the value which corresponds to the given header - /// field. Note that, in keeping with the HTTP RFC, HTTP header field - /// names are case-insensitive. - /// @param field the header field name to use for the lookup - /// (case-insensitive). - /// @result the value associated with the given header field, or nil if - /// there is no value associated with the given header field. - objc.NSString? valueForHTTPHeaderField(objc.NSString field) { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.valueForHTTPHeaderField:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_valueForHTTPHeaderField_, - field.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } -} - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), - NSURLSessionDownloadTask.fromPointer( - arg3, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionDownloadTask arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - ); -} - -late final _sel_URLSession_dataTask_didBecomeStreamTask_ = objc.registerName( - "URLSession:dataTask:didBecomeStreamTask:", -); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), - NSURLSessionStreamTask.fromPointer( - arg3, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionStreamTask.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionStreamTask.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionStreamTask.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionStreamTask arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - ); -} - -late final _sel_URLSession_dataTask_didReceiveData_ = objc.registerName( - "URLSession:dataTask:didReceiveData:", -); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, objc.NSData)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), - objc.NSData.fromPointer(arg3, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - objc.NSData.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - objc.NSData.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - objc.NSData.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, objc.NSData)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - objc.NSData, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionDataTask arg2, - objc.NSData arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - ); -} - -late final _sel_URLSession_dataTask_willCacheResponse_completionHandler_ = objc - .registerName("URLSession:dataTask:willCacheResponse:completionHandler:"); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSCachedURLResponse, objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), - NSCachedURLResponse.fromPointer(arg3, retain: true, release: true), - ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( - arg4, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSCachedURLResponse.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xx612k(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSCachedURLResponse.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDataTask.fromPointer(arg2, retain: false, release: true), - NSCachedURLResponse.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDataTask, NSCachedURLResponse, objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSCachedURLResponse arg3, - objc.ObjCBlock arg4, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - arg4.ref.pointer, - ); -} - -late final _sel_URLSession_didCreateTask_ = objc.registerName( - "URLSession:didCreateTask:", -); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - > - fromFunction( - void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - > - listener( - void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_fjrv01(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - > - blocking( - void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_fjrv01( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer); -} - -late final _sel_URLSession_task_willBeginDelayedRequest_completionHandler_ = - objc.registerName( - "URLSession:task:willBeginDelayedRequest:completionHandler:", - ); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLRequest, objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - NSURLRequest.fromPointer(arg3, retain: true, release: true), - ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( - arg4, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLRequest.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xx612k(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLRequest.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLRequest.fromPointer(arg3, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLRequest, objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock arg4, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - arg4.ref.pointer, - ); -} - -late final _sel_URLSession_taskIsWaitingForConnectivity_ = objc.registerName( - "URLSession:taskIsWaitingForConnectivity:", -); - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSURLRequest { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(NSURLRequest?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : NSURLRequest.fromPointer(arg0, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(NSURLRequest?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : NSURLRequest.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(NSURLRequest?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : NSURLRequest.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : NSURLRequest.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ) { - try { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - >() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSURLRequest$CallExtension - on objc.ObjCBlock { - void call(NSURLRequest? arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); -} - -late final _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = - objc.registerName( - "URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:", - ); -final _objc_msgSend_e1wgee = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest, objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - NSHTTPURLResponse.fromPointer(arg3, retain: true, release: true), - NSURLRequest.fromPointer(arg4, retain: true, release: true), - ObjCBlock_ffiVoid_NSURLRequest.fromPointer( - arg5, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), - NSURLRequest.fromPointer(arg4, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLRequest.fromPointer( - arg5, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_l2g8ke(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), - NSURLRequest.fromPointer(arg4, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLRequest.fromPointer( - arg5, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), - NSURLRequest.fromPointer(arg4, retain: false, release: true), - ObjCBlock_ffiVoid_NSURLRequest.fromPointer( - arg5, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_l2g8ke( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3, arg4, arg5); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest, objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ffi.Pointer arg5, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - arg4.ref.pointer, - arg5.ref.pointer, - ); -} - -/// WARNING: NSURLAuthenticationChallenge is a stub. To generate bindings for this class, include -/// NSURLAuthenticationChallenge in your config's objc-interfaces list. -/// -/// NSURLAuthenticationChallenge -extension type NSURLAuthenticationChallenge._(objc.ObjCObject object$) - implements objc.ObjCObject { - /// Constructs a [NSURLAuthenticationChallenge] that points to the same underlying object as [other]. - NSURLAuthenticationChallenge.as(objc.ObjCObject other) : object$ = other {} - - /// Constructs a [NSURLAuthenticationChallenge] that wraps the given raw object pointer. - NSURLAuthenticationChallenge.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} -} - -/// WARNING: NSURLCredential is a stub. To generate bindings for this class, include -/// NSURLCredential in your config's objc-interfaces list. -/// -/// NSURLCredential -extension type NSURLCredential._(objc.ObjCObject object$) - implements objc.ObjCObject { - /// Constructs a [NSURLCredential] that points to the same underlying object as [other]. - NSURLCredential.as(objc.ObjCObject other) : object$ = other {} - - /// Constructs a [NSURLCredential] that wraps the given raw object pointer. - NSURLCredential.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} -} - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(NSInteger arg0, ffi.Pointer arg1) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - fromFunction( - void Function(NSURLSessionAuthChallengeDisposition, NSURLCredential?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (int arg0, ffi.Pointer arg1) => fn( - NSURLSessionAuthChallengeDisposition.fromValue(arg0), - arg1.address == 0 - ? null - : NSURLCredential.fromPointer(arg1, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - listener( - void Function(NSURLSessionAuthChallengeDisposition, NSURLCredential?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (int arg0, ffi.Pointer arg1) => fn( - NSURLSessionAuthChallengeDisposition.fromValue(arg0), - arg1.address == 0 - ? null - : NSURLCredential.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_n8yd09(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock - blocking( - void Function(NSURLSessionAuthChallengeDisposition, NSURLCredential?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (int arg0, ffi.Pointer arg1) => fn( - NSURLSessionAuthChallengeDisposition.fromValue(arg0), - arg1.address == 0 - ? null - : NSURLCredential.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (int arg0, ffi.Pointer arg1) => fn( - NSURLSessionAuthChallengeDisposition.fromValue(arg0), - arg1.address == 0 - ? null - : NSURLCredential.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_n8yd09( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - int arg0, - ffi.Pointer arg1, - ) { - (objc.getBlockClosure(block) - as void Function(int, ffi.Pointer))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - int arg0, - ffi.Pointer arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function(int, ffi.Pointer))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - int arg0, - ffi.Pointer arg1, - ) => - block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - NSInteger arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction)>()( - arg0, - arg1, - ); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - int arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as void Function(int, ffi.Pointer))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential$CallExtension - on objc.ObjCBlock { - void call(NSURLSessionAuthChallengeDisposition arg0, NSURLCredential? arg1) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - NSInteger arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - int, - ffi.Pointer, - ) - >()(ref.pointer, arg0.value, arg1?.ref.pointer ?? ffi.nullptr); -} - -late final _sel_URLSession_task_didReceiveChallenge_completionHandler_ = objc - .registerName("URLSession:task:didReceiveChallenge:completionHandler:"); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLAuthenticationChallenge, objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - NSURLAuthenticationChallenge.fromPointer( - arg3, - retain: true, - release: true, - ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg4, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLAuthenticationChallenge.fromPointer( - arg3, - retain: false, - release: true, - ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xx612k(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLAuthenticationChallenge.fromPointer( - arg3, - retain: false, - release: true, - ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLAuthenticationChallenge.fromPointer( - arg3, - retain: false, - release: true, - ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLAuthenticationChallenge, objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock arg4, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - arg4.ref.pointer, - ); -} - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSInputStream { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock fromFunction( - void Function(objc.NSInputStream?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSInputStream.fromPointer(arg0, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock listener( - void Function(objc.NSInputStream?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSInputStream.fromPointer( - arg0, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock blocking( - void Function(objc.NSInputStream?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSInputStream.fromPointer( - arg0, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSInputStream.fromPointer( - arg0, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ) { - try { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0) - > - >() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSInputStream$CallExtension - on objc.ObjCBlock { - void call(objc.NSInputStream? arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); -} - -late final _sel_URLSession_task_needNewBodyStream_ = objc.registerName( - "URLSession:task:needNewBodyStream:", -); -final _objc_msgSend_18qun1e = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - ObjCBlock_ffiVoid_NSInputStream.fromPointer( - arg3, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - ObjCBlock_ffiVoid_NSInputStream.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_bklti2(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - ObjCBlock_ffiVoid_NSInputStream.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - ObjCBlock_ffiVoid_NSInputStream.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_bklti2( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - ); -} - -late final _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = - objc.registerName( - "URLSession:task:needNewBodyStreamFromOffset:completionHandler:", - ); -final _objc_msgSend_9cddqw = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, ffi.Int64, objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Pointer arg4, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - arg3, - ObjCBlock_ffiVoid_NSInputStream.fromPointer( - arg4, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3, - ObjCBlock_ffiVoid_NSInputStream.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_jyim80(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3, - ObjCBlock_ffiVoid_NSInputStream.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3, - ObjCBlock_ffiVoid_NSInputStream.fromPointer( - arg4, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_jyim80( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, ffi.Int64, objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - objc.ObjCBlock, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3, - arg4.ref.pointer, - ); -} - -late final _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = - objc.registerName( - "URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:", - ); -final _objc_msgSend_1modw1b = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64 { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ffi.Int64 arg5, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - int, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - arg3, - arg4, - arg5, - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - int, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3, - arg4, - arg5, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_h68abb(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - int, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3, - arg4, - arg5, - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3, - arg4, - arg5, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_h68abb( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ffi.Int64 arg5, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ) - >()(arg0, arg1, arg2, arg3, arg4, arg5); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ffi.Int64 arg5, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3, - arg4, - arg5, - ); -} - -late final _sel_URLSession_task_didReceiveInformationalResponse_ = objc - .registerName("URLSession:task:didReceiveInformationalResponse:"); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSHTTPURLResponse)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - NSHTTPURLResponse.fromPointer(arg3, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSHTTPURLResponse.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSHTTPURLResponse)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - ); -} - -/// WARNING: NSURLSessionTaskMetrics is a stub. To generate bindings for this class, include -/// NSURLSessionTaskMetrics in your config's objc-interfaces list. -/// -/// NSURLSessionTaskMetrics -extension type NSURLSessionTaskMetrics._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject { - /// Constructs a [NSURLSessionTaskMetrics] that points to the same underlying object as [other]. - NSURLSessionTaskMetrics.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSURLSessionTaskMetrics', - iOS: (false, (10, 0, 0)), - macOS: (false, (10, 12, 0)), - ); - } - - /// Constructs a [NSURLSessionTaskMetrics] that wraps the given raw object pointer. - NSURLSessionTaskMetrics.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSURLSessionTaskMetrics', - iOS: (false, (10, 0, 0)), - macOS: (false, (10, 12, 0)), - ); - } -} - -late final _sel_URLSession_task_didFinishCollectingMetrics_ = objc.registerName( - "URLSession:task:didFinishCollectingMetrics:", -); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - NSURLSessionTaskMetrics.fromPointer( - arg3, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionTaskMetrics.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionTaskMetrics.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - NSURLSessionTaskMetrics.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - ); -} - -late final _sel_URLSession_task_didCompleteWithError_ = objc.registerName( - "URLSession:task:didCompleteWithError:", -); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, objc.NSError?)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - arg3.address == 0 - ? null - : objc.NSError.fromPointer(arg3, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3.address == 0 - ? null - : objc.NSError.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3.address == 0 - ? null - : objc.NSError.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionTask.fromPointer(arg2, retain: false, release: true), - arg3.address == 0 - ? null - : objc.NSError.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionTask, objc.NSError?)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.NSError?, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3?.ref.pointer ?? ffi.nullptr, - ); -} - -late final _sel_URLSession_didBecomeInvalidWithError_ = objc.registerName( - "URLSession:didBecomeInvalidWithError:", -); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, objc.NSError?)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - > - fromFunction( - void Function(ffi.Pointer, NSURLSession, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - > - listener( - void Function(ffi.Pointer, NSURLSession, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_fjrv01(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - > - blocking( - void Function(ffi.Pointer, NSURLSession, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - arg2.address == 0 - ? null - : objc.NSError.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_fjrv01( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, objc.NSError?)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError$CallExtension - on - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - objc.NSError? arg2, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2?.ref.pointer ?? ffi.nullptr, - ); -} - -late final _sel_URLSession_didReceiveChallenge_completionHandler_ = objc - .registerName("URLSession:didReceiveChallenge:completionHandler:"); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLAuthenticationChallenge, objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLAuthenticationChallenge.fromPointer( - arg2, - retain: true, - release: true, - ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg3, - retain: true, - release: true, - ), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLAuthenticationChallenge.fromPointer( - arg2, - retain: false, - release: true, - ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_bklti2(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLAuthenticationChallenge.fromPointer( - arg2, - retain: false, - release: true, - ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLAuthenticationChallenge.fromPointer( - arg2, - retain: false, - release: true, - ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg3, - retain: false, - release: true, - ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_bklti2( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLAuthenticationChallenge, objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - ); -} - -late final _sel_URLSessionDidFinishEventsForBackgroundURLSession_ = objc - .registerName("URLSessionDidFinishEventsForBackgroundURLSession:"); - -/// Construction methods for `objc.ObjCBlock, NSURLSession)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock, NSURLSession)> - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock, NSURLSession)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock, NSURLSession)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => objc.ObjCBlock, NSURLSession)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock, NSURLSession)> - fromFunction( - void Function(ffi.Pointer, NSURLSession) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock, NSURLSession)>( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, NSURLSession.fromPointer(arg1, retain: true, release: true)), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock, NSURLSession)> - listener( - void Function(ffi.Pointer, NSURLSession) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_18v1jvf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock, NSURLSession)> - blocking( - void Function(ffi.Pointer, NSURLSession) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSURLSession) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession$CallExtension - on objc.ObjCBlock, NSURLSession)> { - void call(ffi.Pointer arg0, NSURLSession arg1) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer); -} - -/// Messages related to the operation of a task that delivers data -/// directly to the delegate. -extension type NSURLSessionDataDelegate._(objc.ObjCProtocol object$) - implements objc.ObjCProtocol, NSURLSessionTaskDelegate { - /// Constructs a [NSURLSessionDataDelegate] that points to the same underlying object as [other]. - NSURLSessionDataDelegate.as(objc.ObjCObject other) : object$ = other; - - /// Constructs a [NSURLSessionDataDelegate] that wraps the given raw object pointer. - NSURLSessionDataDelegate.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); - - /// Returns whether [obj] is an instance of [NSURLSessionDataDelegate]. - static bool conformsTo(objc.ObjCObject obj) { - return _objc_msgSend_e3qsqz( - obj.ref.pointer, - _sel_conformsToProtocol_, - _protocol_NSURLSessionDataDelegate, - ); - } -} - -extension NSURLSessionDataDelegate$Methods on NSURLSessionDataDelegate { - /// Notification that a data task has become a download task. No - /// future messages will be sent to the data task. - void URLSession( - NSURLSession session, { - required NSURLSessionDataTask dataTask, - required NSURLSessionDownloadTask didBecomeDownloadTask, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:dataTask:didBecomeDownloadTask:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_dataTask_didBecomeDownloadTask_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:dataTask:didBecomeDownloadTask:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_dataTask_didBecomeDownloadTask_, - session.ref.pointer, - dataTask.ref.pointer, - didBecomeDownloadTask.ref.pointer, - ); - } - - /// Notification that a data task has become a bidirectional stream - /// task. No future messages will be sent to the data task. The newly - /// created streamTask will carry the original request and response as - /// properties. - /// - /// For requests that were pipelined, the stream object will only allow - /// reading, and the object will immediately issue a - /// -URLSession:writeClosedForStream:. Pipelining can be disabled for - /// all requests in a session, or by the NSURLRequest - /// HTTPShouldUsePipelining property. - /// - /// The underlying connection is no longer considered part of the HTTP - /// connection cache and won't count against the total number of - /// connections per host. - void URLSession$1( - NSURLSession session, { - required NSURLSessionDataTask dataTask, - required NSURLSessionStreamTask didBecomeStreamTask, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:dataTask:didBecomeStreamTask:', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_dataTask_didBecomeStreamTask_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:dataTask:didBecomeStreamTask:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_dataTask_didBecomeStreamTask_, - session.ref.pointer, - dataTask.ref.pointer, - didBecomeStreamTask.ref.pointer, - ); - } - - /// Sent when data is available for the delegate to consume. As the - /// data may be discontiguous, you should use - /// [NSData enumerateByteRangesUsingBlock:] to access it. - void URLSession$2( - NSURLSession session, { - required NSURLSessionDataTask dataTask, - required objc.NSData didReceiveData, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:dataTask:didReceiveData:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_dataTask_didReceiveData_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:dataTask:didReceiveData:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_dataTask_didReceiveData_, - session.ref.pointer, - dataTask.ref.pointer, - didReceiveData.ref.pointer, - ); - } - - /// The task has received a response and no further messages will be - /// received until the completion block is called. The disposition - /// allows you to cancel a request or to turn a data task into a - /// download task. This delegate message is optional - if you do not - /// implement it, you can get the response as a property of the task. - /// - /// This method will not be called for background upload tasks (which cannot be converted to download tasks). - void URLSession$3( - NSURLSession session, { - required NSURLSessionDataTask dataTask, - required NSURLResponse didReceiveResponse, - required objc.ObjCBlock completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:dataTask:didReceiveResponse:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:dataTask:didReceiveResponse:completionHandler:', - ); - } - _objc_msgSend_m7tls4( - object$.ref.pointer, - _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, - session.ref.pointer, - dataTask.ref.pointer, - didReceiveResponse.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Invoke the completion routine with a valid NSCachedURLResponse to - /// allow the resulting data to be cached, or pass nil to prevent - /// caching. Note that there is no guarantee that caching will be - /// attempted for a given resource, and you should not rely on this - /// message to receive the resource data. - void URLSession$4( - NSURLSession session, { - required NSURLSessionDataTask dataTask, - required NSCachedURLResponse willCacheResponse, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:dataTask:willCacheResponse:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_dataTask_willCacheResponse_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:dataTask:willCacheResponse:completionHandler:', - ); - } - _objc_msgSend_m7tls4( - object$.ref.pointer, - _sel_URLSession_dataTask_willCacheResponse_completionHandler_, - session.ref.pointer, - dataTask.ref.pointer, - willCacheResponse.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// The last message a session receives. A session will only become - /// invalid because of a systemic error or when it has been - /// explicitly invalidated, in which case the error parameter will be nil. - void URLSession$5( - NSURLSession session, { - objc.NSError? didBecomeInvalidWithError, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:didBecomeInvalidWithError:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didBecomeInvalidWithError_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:didBecomeInvalidWithError:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_didBecomeInvalidWithError_, - session.ref.pointer, - didBecomeInvalidWithError?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Notification that a task has been created. This method is the first message - /// a task sends, providing a place to configure the task before it is resumed. - /// - /// This delegate callback is *NOT* dispatched to the delegate queue. It is - /// invoked synchronously before the task creation method returns. - void URLSession$6( - NSURLSession session, { - required NSURLSessionTask didCreateTask, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:didCreateTask:', - iOS: (false, (16, 0, 0)), - macOS: (false, (13, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didCreateTask_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:didCreateTask:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_didCreateTask_, - session.ref.pointer, - didCreateTask.ref.pointer, - ); - } - - /// If implemented, when a connection level authentication challenge - /// has occurred, this delegate will be given the opportunity to - /// provide authentication credentials to the underlying - /// connection. Some types of authentication will apply to more than - /// one request on a given connection to a server (SSL Server Trust - /// challenges). If this delegate message is not implemented, the - /// behavior will be to use the default handling, which may involve user - /// interaction. - void URLSession$7( - NSURLSession session, { - required NSURLAuthenticationChallenge didReceiveChallenge, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:didReceiveChallenge:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didReceiveChallenge_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:didReceiveChallenge:completionHandler:', - ); - } - _objc_msgSend_18qun1e( - object$.ref.pointer, - _sel_URLSession_didReceiveChallenge_completionHandler_, - session.ref.pointer, - didReceiveChallenge.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent as the last message related to a specific task. Error may be - /// nil, which implies that no error occurred and this task is complete. - void URLSession$8( - NSURLSession session, { - required NSURLSessionTask task, - objc.NSError? didCompleteWithError, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:didCompleteWithError:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didCompleteWithError_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:didCompleteWithError:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didCompleteWithError_, - session.ref.pointer, - task.ref.pointer, - didCompleteWithError?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Sent when complete statistics information has been collected for the task. - void URLSession$9( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLSessionTaskMetrics didFinishCollectingMetrics, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:didFinishCollectingMetrics:', - iOS: (false, (10, 0, 0)), - macOS: (false, (10, 12, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didFinishCollectingMetrics_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:didFinishCollectingMetrics:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didFinishCollectingMetrics_, - session.ref.pointer, - task.ref.pointer, - didFinishCollectingMetrics.ref.pointer, - ); - } - - /// The task has received a request specific authentication challenge. - /// If this delegate is not implemented, the session specific authentication challenge - /// will *NOT* be called and the behavior will be the same as using the default handling - /// disposition. - void URLSession$10( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLAuthenticationChallenge didReceiveChallenge, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:didReceiveChallenge:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:didReceiveChallenge:completionHandler:', - ); - } - _objc_msgSend_m7tls4( - object$.ref.pointer, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - session.ref.pointer, - task.ref.pointer, - didReceiveChallenge.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent for each informational response received except 101 switching protocols. - void URLSession$11( - NSURLSession session, { - required NSURLSessionTask task, - required NSHTTPURLResponse didReceiveInformationalResponse, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:didReceiveInformationalResponse:', - iOS: (false, (17, 0, 0)), - macOS: (false, (14, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didReceiveInformationalResponse_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:didReceiveInformationalResponse:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didReceiveInformationalResponse_, - session.ref.pointer, - task.ref.pointer, - didReceiveInformationalResponse.ref.pointer, - ); - } - - /// Sent periodically to notify the delegate of upload progress. This - /// information is also available as properties of the task. - void URLSession$12( - NSURLSession session, { - required NSURLSessionTask task, - required int didSendBodyData, - required int totalBytesSent, - required int totalBytesExpectedToSend, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', - ); - } - _objc_msgSend_1modw1b( - object$.ref.pointer, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - session.ref.pointer, - task.ref.pointer, - didSendBodyData, - totalBytesSent, - totalBytesExpectedToSend, - ); - } - - /// Sent if a task requires a new, unopened body stream. This may be - /// necessary when authentication has failed for any request that - /// involves a body stream. - void URLSession$13( - NSURLSession session, { - required NSURLSessionTask task, - required objc.ObjCBlock - needNewBodyStream, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:needNewBodyStream:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStream_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:needNewBodyStream:', - ); - } - _objc_msgSend_18qun1e( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStream_, - session.ref.pointer, - task.ref.pointer, - needNewBodyStream.ref.pointer, - ); - } - - /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be - /// necessary when resuming a failed upload task. - /// - /// - Parameter session: The session containing the task that needs a new body stream from the given offset. - /// - Parameter task: The task that needs a new body stream. - /// - Parameter offset: The starting offset required for the body stream. - /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. - void URLSession$14( - NSURLSession session, { - required NSURLSessionTask task, - required int needNewBodyStreamFromOffset, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', - iOS: (false, (17, 0, 0)), - macOS: (false, (14, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', - ); - } - _objc_msgSend_9cddqw( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - session.ref.pointer, - task.ref.pointer, - needNewBodyStreamFromOffset, - completionHandler.ref.pointer, - ); - } - - /// Sent when the system is ready to begin work for a task with a delayed start - /// time set (using the earliestBeginDate property). The completionHandler must - /// be invoked in order for loading to proceed. The disposition provided to the - /// completion handler continues the load with the original request provided to - /// the task, replaces the request with the specified task, or cancels the task. - /// If this delegate is not implemented, loading will proceed with the original - /// request. - /// - /// Recommendation: only implement this delegate if tasks that have the - /// earliestBeginDate property set may become stale and require alteration prior - /// to starting the network load. - /// - /// If a new request is specified, the allowsExpensiveNetworkAccess, - /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties - /// from the new request will not be used; the properties from the - /// original request will continue to be used. - /// - /// Canceling the task is equivalent to calling the task's cancel method; the - /// URLSession:task:didCompleteWithError: task delegate will be called with error - /// NSURLErrorCancelled. - void URLSession$15( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLRequest willBeginDelayedRequest, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:willBeginDelayedRequest:completionHandler:', - ); - } - _objc_msgSend_m7tls4( - object$.ref.pointer, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - session.ref.pointer, - task.ref.pointer, - willBeginDelayedRequest.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// An HTTP request is attempting to perform a redirection to a different - /// URL. You must invoke the completion routine to allow the - /// redirection, allow the redirection with a modified request, or - /// pass nil to the completionHandler to cause the body of the redirection - /// response to be delivered as the payload of this request. The default - /// is to follow redirections. - /// - /// For tasks in background sessions, redirections will always be followed and this method will not be called. - void URLSession$16( - NSURLSession session, { - required NSURLSessionTask task, - required NSHTTPURLResponse willPerformHTTPRedirection, - required NSURLRequest newRequest, - required objc.ObjCBlock completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', - ); - } - _objc_msgSend_e1wgee( - object$.ref.pointer, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - session.ref.pointer, - task.ref.pointer, - willPerformHTTPRedirection.ref.pointer, - newRequest.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent when a task cannot start the network loading process because the current - /// network connectivity is not available or sufficient for the task's request. - /// - /// This delegate will be called at most one time per task, and is only called if - /// the waitsForConnectivity property in the NSURLSessionConfiguration has been - /// set to YES. - /// - /// This delegate callback will never be called for background sessions, because - /// the waitForConnectivity property is ignored by those sessions. - void URLSession$17( - NSURLSession session, { - required NSURLSessionTask taskIsWaitingForConnectivity, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:taskIsWaitingForConnectivity:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_taskIsWaitingForConnectivity_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSession:taskIsWaitingForConnectivity:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_taskIsWaitingForConnectivity_, - session.ref.pointer, - taskIsWaitingForConnectivity.ref.pointer, - ); - } - - /// If an application has received an - /// -application:handleEventsForBackgroundURLSession:completionHandler: - /// message, the session delegate will receive this message to indicate - /// that all messages previously enqueued for this session have been - /// delivered. At this time it is safe to invoke the previously stored - /// completion handler, or to begin any internal updates that will - /// result in invoking the completion handler. - void URLSessionDidFinishEventsForBackgroundURLSession(NSURLSession session) { - objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', - iOS: (false, (7, 0, 0)), - macOS: (false, (11, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDataDelegate', - 'URLSessionDidFinishEventsForBackgroundURLSession:', - ); - } - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - session.ref.pointer, - ); - } -} - -interface class NSURLSessionDataDelegate$Builder { - /// Returns the [objc.Protocol] object for this protocol. - static objc.Protocol get $protocol => - objc.Protocol.fromPointer(_protocol_NSURLSessionDataDelegate.cast()); - - /// Builds an object that implements the NSURLSessionDataDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionDataDelegate implement({ - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? - URLSession_dataTask_didBecomeDownloadTask_, - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? - URLSession_dataTask_didBecomeStreamTask_, - void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? - URLSession_dataTask_didReceiveData_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_didReceiveResponse_completionHandler_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_willCacheResponse_completionHandler_, - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionDataDelegate', - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeDownloadTask_.implement( - builder, - URLSession_dataTask_didBecomeDownloadTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeStreamTask_.implement( - builder, - URLSession_dataTask_didBecomeStreamTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveData_.implement( - builder, - URLSession_dataTask_didReceiveData_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveResponse_completionHandler_.implement( - builder, - URLSession_dataTask_didReceiveResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_willCacheResponse_completionHandler_.implement( - builder, - URLSession_dataTask_willCacheResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implement( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDataDelegate$Builder.URLSession_didCreateTask_.implement( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didCompleteWithError_.implement( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implement( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implement( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStream_.implement( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implement( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDataDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implement( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionDataDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilder( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? - URLSession_dataTask_didBecomeDownloadTask_, - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? - URLSession_dataTask_didBecomeStreamTask_, - void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? - URLSession_dataTask_didReceiveData_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_didReceiveResponse_completionHandler_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_willCacheResponse_completionHandler_, - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeDownloadTask_.implement( - builder, - URLSession_dataTask_didBecomeDownloadTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeStreamTask_.implement( - builder, - URLSession_dataTask_didBecomeStreamTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveData_.implement( - builder, - URLSession_dataTask_didReceiveData_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveResponse_completionHandler_.implement( - builder, - URLSession_dataTask_didReceiveResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_willCacheResponse_completionHandler_.implement( - builder, - URLSession_dataTask_willCacheResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implement( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDataDelegate$Builder.URLSession_didCreateTask_.implement( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didCompleteWithError_.implement( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implement( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implement( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStream_.implement( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implement( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDataDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implement( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// Builds an object that implements the NSURLSessionDataDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All - /// methods that can be implemented as listeners will be. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionDataDelegate implementAsListener({ - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? - URLSession_dataTask_didBecomeDownloadTask_, - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? - URLSession_dataTask_didBecomeStreamTask_, - void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? - URLSession_dataTask_didReceiveData_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_didReceiveResponse_completionHandler_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_willCacheResponse_completionHandler_, - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionDataDelegate', - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeDownloadTask_.implementAsListener( - builder, - URLSession_dataTask_didBecomeDownloadTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeStreamTask_.implementAsListener( - builder, - URLSession_dataTask_didBecomeStreamTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveData_.implementAsListener( - builder, - URLSession_dataTask_didReceiveData_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsListener( - builder, - URLSession_dataTask_didReceiveResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsListener( - builder, - URLSession_dataTask_willCacheResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsListener( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didCreateTask_.implementAsListener( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsListener( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsListener( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsListener( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsListener( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsListener( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDataDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionDataDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will - /// be. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilderAsListener( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? - URLSession_dataTask_didBecomeDownloadTask_, - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? - URLSession_dataTask_didBecomeStreamTask_, - void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? - URLSession_dataTask_didReceiveData_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_didReceiveResponse_completionHandler_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_willCacheResponse_completionHandler_, - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeDownloadTask_.implementAsListener( - builder, - URLSession_dataTask_didBecomeDownloadTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeStreamTask_.implementAsListener( - builder, - URLSession_dataTask_didBecomeStreamTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveData_.implementAsListener( - builder, - URLSession_dataTask_didReceiveData_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsListener( - builder, - URLSession_dataTask_didReceiveResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsListener( - builder, - URLSession_dataTask_willCacheResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsListener( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didCreateTask_.implementAsListener( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsListener( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsListener( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsListener( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsListener( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsListener( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDataDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// Builds an object that implements the NSURLSessionDataDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All - /// methods that can be implemented as blocking listeners will be. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionDataDelegate implementAsBlocking({ - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? - URLSession_dataTask_didBecomeDownloadTask_, - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? - URLSession_dataTask_didBecomeStreamTask_, - void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? - URLSession_dataTask_didReceiveData_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_didReceiveResponse_completionHandler_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_willCacheResponse_completionHandler_, - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionDataDelegate', - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeDownloadTask_.implementAsBlocking( - builder, - URLSession_dataTask_didBecomeDownloadTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeStreamTask_.implementAsBlocking( - builder, - URLSession_dataTask_didBecomeStreamTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveData_.implementAsBlocking( - builder, - URLSession_dataTask_didReceiveData_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsBlocking( - builder, - URLSession_dataTask_didReceiveResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsBlocking( - builder, - URLSession_dataTask_willCacheResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsBlocking( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didCreateTask_.implementAsBlocking( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsBlocking( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDataDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionDataDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking - /// listeners will be. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilderAsBlocking( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask)? - URLSession_dataTask_didBecomeDownloadTask_, - void Function(NSURLSession, NSURLSessionDataTask, NSURLSessionStreamTask)? - URLSession_dataTask_didBecomeStreamTask_, - void Function(NSURLSession, NSURLSessionDataTask, objc.NSData)? - URLSession_dataTask_didReceiveData_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_didReceiveResponse_completionHandler_, - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - )? - URLSession_dataTask_willCacheResponse_completionHandler_, - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeDownloadTask_.implementAsBlocking( - builder, - URLSession_dataTask_didBecomeDownloadTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didBecomeStreamTask_.implementAsBlocking( - builder, - URLSession_dataTask_didBecomeStreamTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveData_.implementAsBlocking( - builder, - URLSession_dataTask_didReceiveData_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsBlocking( - builder, - URLSession_dataTask_didReceiveResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsBlocking( - builder, - URLSession_dataTask_willCacheResponse_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsBlocking( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didCreateTask_.implementAsBlocking( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsBlocking( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDataDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDataDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// Notification that a data task has become a download task. No - /// future messages will be sent to the data task. - static final URLSession_dataTask_didBecomeDownloadTask_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_didBecomeDownloadTask_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_didBecomeDownloadTask_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionDownloadTask arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionDownloadTask arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionDownloadTask arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Notification that a data task has become a bidirectional stream - /// task. No future messages will be sent to the data task. The newly - /// created streamTask will carry the original request and response as - /// properties. - /// - /// For requests that were pipelined, the stream object will only allow - /// reading, and the object will immediately issue a - /// -URLSession:writeClosedForStream:. Pipelining can be disabled for - /// all requests in a session, or by the NSURLRequest - /// HTTPShouldUsePipelining property. - /// - /// The underlying connection is no longer considered part of the HTTP - /// connection cache and won't count against the total number of - /// connections per host. - static final URLSession_dataTask_didBecomeStreamTask_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_didBecomeStreamTask_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_didBecomeStreamTask_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionStreamTask arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionStreamTask arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionStreamTask arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent when data is available for the delegate to consume. As the - /// data may be discontiguous, you should use - /// [NSData enumerateByteRangesUsingBlock:] to access it. - static final URLSession_dataTask_didReceiveData_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionDataTask, objc.NSData) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_didReceiveData_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_didReceiveData_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionDataTask, objc.NSData) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - objc.NSData arg3, - ) => func(arg1, arg2, arg3), - ), - (void Function(NSURLSession, NSURLSessionDataTask, objc.NSData) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - objc.NSData arg3, - ) => func(arg1, arg2, arg3), - ), - (void Function(NSURLSession, NSURLSessionDataTask, objc.NSData) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSData.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - objc.NSData arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// The task has received a response and no further messages will be - /// received until the completion block is called. The disposition - /// allows you to cancel a request or to turn a data task into a - /// download task. This delegate message is optional - if you do not - /// implement it, you can get the response as a property of the task. - /// - /// This method will not be called for background upload tasks (which cannot be converted to download tasks). - static final URLSession_dataTask_didReceiveResponse_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_xx612k) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLResponse arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLResponse arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLResponse_ffiVoidNSURLSessionResponseDisposition.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLResponse arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Invoke the completion routine with a valid NSCachedURLResponse to - /// allow the resulting data to be cached, or pass nil to prevent - /// caching. Note that there is no guarantee that caching will be - /// attempted for a given resource, and you should not rely on this - /// message to receive the resource data. - static final URLSession_dataTask_willCacheResponse_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_willCacheResponse_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_xx612k) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_dataTask_willCacheResponse_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSCachedURLResponse arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSCachedURLResponse arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSCachedURLResponse_ffiVoidNSCachedURLResponse.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSCachedURLResponse arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// The last message a session receives. A session will only become - /// invalid because of a systemic error or when it has been - /// explicitly invalidated, in which case the error parameter will be nil. - static final URLSession_didBecomeInvalidWithError_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, objc.NSError?) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_didBecomeInvalidWithError_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_didBecomeInvalidWithError_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - ); - - /// Notification that a task has been created. This method is the first message - /// a task sends, providing a place to configure the task before it is resumed. - /// - /// This delegate callback is *NOT* dispatched to the delegate queue. It is - /// invoked synchronously before the task creation method returns. - static final URLSession_didCreateTask_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_didCreateTask_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_didCreateTask_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - ); - - /// If implemented, when a connection level authentication challenge - /// has occurred, this delegate will be given the opportunity to - /// provide authentication credentials to the underlying - /// connection. Some types of authentication will apply to more than - /// one request on a given connection to a server (SSL Server Trust - /// challenges). If this delegate message is not implemented, the - /// behavior will be to use the default handling, which may involve user - /// interaction. - static final URLSession_didReceiveChallenge_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_didReceiveChallenge_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_bklti2) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_didReceiveChallenge_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent as the last message related to a specific task. Error may be - /// nil, which implies that no error occurred and this task is complete. - static final URLSession_task_didCompleteWithError_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, objc.NSError?) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didCompleteWithError_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didCompleteWithError_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent when complete statistics information has been collected for the task. - static final URLSession_task_didFinishCollectingMetrics_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didFinishCollectingMetrics_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didFinishCollectingMetrics_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// The task has received a request specific authentication challenge. - /// If this delegate is not implemented, the session specific authentication challenge - /// will *NOT* be called and the behavior will be the same as using the default handling - /// disposition. - static final URLSession_task_didReceiveChallenge_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_xx612k) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Sent for each informational response received except 101 switching protocols. - static final URLSession_task_didReceiveInformationalResponse_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didReceiveInformationalResponse_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didReceiveInformationalResponse_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent periodically to notify the delegate of upload progress. This - /// information is also available as properties of the task. - static final URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, int, int, int) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_h68abb) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ); - - /// Sent if a task requires a new, unopened body stream. This may be - /// necessary when authentication has failed for any request that - /// involves a body stream. - static final URLSession_task_needNewBodyStream_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_needNewBodyStream_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_bklti2) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_needNewBodyStream_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be - /// necessary when resuming a failed upload task. - /// - /// - Parameter session: The session containing the task that needs a new body stream from the given offset. - /// - Parameter task: The task that needs a new body stream. - /// - Parameter offset: The starting offset required for the body stream. - /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. - static final URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_jyim80) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Sent when the system is ready to begin work for a task with a delayed start - /// time set (using the earliestBeginDate property). The completionHandler must - /// be invoked in order for loading to proceed. The disposition provided to the - /// completion handler continues the load with the original request provided to - /// the task, replaces the request with the specified task, or cancels the task. - /// If this delegate is not implemented, loading will proceed with the original - /// request. - /// - /// Recommendation: only implement this delegate if tasks that have the - /// earliestBeginDate property set may become stale and require alteration prior - /// to starting the network load. - /// - /// If a new request is specified, the allowsExpensiveNetworkAccess, - /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties - /// from the new request will not be used; the properties from the - /// original request will continue to be used. - /// - /// Canceling the task is equivalent to calling the task's cancel method; the - /// URLSession:task:didCompleteWithError: task delegate will be called with error - /// NSURLErrorCancelled. - static final URLSession_task_willBeginDelayedRequest_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_xx612k) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// An HTTP request is attempting to perform a redirection to a different - /// URL. You must invoke the completion routine to allow the - /// redirection, allow the redirection with a modified request, or - /// pass nil to the completionHandler to cause the body of the redirection - /// response to be delivered as the payload of this request. The default - /// is to follow redirections. - /// - /// For tasks in background sessions, redirections will always be followed and this method will not be called. - static final URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_l2g8ke) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ); - - /// Sent when a task cannot start the network loading process because the current - /// network connectivity is not available or sufficient for the task's request. - /// - /// This delegate will be called at most one time per task, and is only called if - /// the waitsForConnectivity property in the NSURLSessionConfiguration has been - /// set to YES. - /// - /// This delegate callback will never be called for background sessions, because - /// the waitForConnectivity property is ignored by those sessions. - static final URLSession_taskIsWaitingForConnectivity_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask) - >( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_taskIsWaitingForConnectivity_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSession_taskIsWaitingForConnectivity_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - ); - - /// If an application has received an - /// -application:handleEventsForBackgroundURLSession:completionHandler: - /// message, the session delegate will receive this message to indicate - /// that all messages previously enqueued for this session have been - /// delivered. At this time it is safe to invoke the previously stored - /// completion handler, or to begin any internal updates that will - /// result in invoking the completion handler. - static final URLSessionDidFinishEventsForBackgroundURLSession_ = - objc.ObjCProtocolListenableMethod( - _protocol_NSURLSessionDataDelegate, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_18v1jvf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDataDelegate, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.fromFunction( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.listener( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.blocking( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - ); -} - -late final _protocol_NSURLSessionDownloadDelegate = objc.getProtocol( - "NSURLSessionDownloadDelegate", -); -late final _sel_URLSession_downloadTask_didFinishDownloadingToURL_ = objc - .registerName("URLSession:downloadTask:didFinishDownloadingToURL:"); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, objc.NSURL)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: true, - release: true, - ), - objc.NSURL.fromPointer(arg3, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - objc.NSURL.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - objc.NSURL.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - objc.NSURL.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, objc.NSURL)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - objc.NSURL arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3.ref.pointer, - ); -} - -late final _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_ = - objc.registerName( - "URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:", - ); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64 { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ffi.Int64 arg5, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: true, - release: true, - ), - arg3, - arg4, - arg5, - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4, - arg5, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_h68abb(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4, - arg5, - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4, - arg5, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_h68abb( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ffi.Int64 arg5, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ) - >()(arg0, arg1, arg2, arg3, arg4, arg5); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - int arg5, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4, arg5); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - int arg3, - int arg4, - int arg5, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ffi.Int64 arg5, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3, - arg4, - arg5, - ); -} - -late final _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_ = - objc.registerName( - "URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:", - ); -final _objc_msgSend_fm5719 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64 { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: true, - release: true, - ), - arg3, - arg4, - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_ly2579(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4, - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4, - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_ly2579( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >()(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - int arg4, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ))(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - int arg3, - int arg4, - ) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer, arg3, arg4); -} - -/// Messages related to the operation of a task that writes data to a -/// file and notifies the delegate upon completion. -extension type NSURLSessionDownloadDelegate._(objc.ObjCProtocol object$) - implements objc.ObjCProtocol, NSURLSessionTaskDelegate { - /// Constructs a [NSURLSessionDownloadDelegate] that points to the same underlying object as [other]. - NSURLSessionDownloadDelegate.as(objc.ObjCObject other) : object$ = other; - - /// Constructs a [NSURLSessionDownloadDelegate] that wraps the given raw object pointer. - NSURLSessionDownloadDelegate.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); - - /// Returns whether [obj] is an instance of [NSURLSessionDownloadDelegate]. - static bool conformsTo(objc.ObjCObject obj) { - return _objc_msgSend_e3qsqz( - obj.ref.pointer, - _sel_conformsToProtocol_, - _protocol_NSURLSessionDownloadDelegate, - ); - } -} - -extension NSURLSessionDownloadDelegate$Methods on NSURLSessionDownloadDelegate { - /// The last message a session receives. A session will only become - /// invalid because of a systemic error or when it has been - /// explicitly invalidated, in which case the error parameter will be nil. - void URLSession$5( - NSURLSession session, { - objc.NSError? didBecomeInvalidWithError, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:didBecomeInvalidWithError:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didBecomeInvalidWithError_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:didBecomeInvalidWithError:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_didBecomeInvalidWithError_, - session.ref.pointer, - didBecomeInvalidWithError?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Notification that a task has been created. This method is the first message - /// a task sends, providing a place to configure the task before it is resumed. - /// - /// This delegate callback is *NOT* dispatched to the delegate queue. It is - /// invoked synchronously before the task creation method returns. - void URLSession$6( - NSURLSession session, { - required NSURLSessionTask didCreateTask, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:didCreateTask:', - iOS: (false, (16, 0, 0)), - macOS: (false, (13, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didCreateTask_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:didCreateTask:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_didCreateTask_, - session.ref.pointer, - didCreateTask.ref.pointer, - ); - } - - /// If implemented, when a connection level authentication challenge - /// has occurred, this delegate will be given the opportunity to - /// provide authentication credentials to the underlying - /// connection. Some types of authentication will apply to more than - /// one request on a given connection to a server (SSL Server Trust - /// challenges). If this delegate message is not implemented, the - /// behavior will be to use the default handling, which may involve user - /// interaction. - void URLSession$7( - NSURLSession session, { - required NSURLAuthenticationChallenge didReceiveChallenge, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:didReceiveChallenge:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didReceiveChallenge_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:didReceiveChallenge:completionHandler:', - ); - } - _objc_msgSend_18qun1e( - object$.ref.pointer, - _sel_URLSession_didReceiveChallenge_completionHandler_, - session.ref.pointer, - didReceiveChallenge.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent when a download task that has completed a download. The delegate should - /// copy or move the file at the given location to a new location as it will be - /// removed when the delegate message returns. URLSession:task:didCompleteWithError: will - /// still be called. - void URLSession( - NSURLSession session, { - required NSURLSessionDownloadTask downloadTask, - required objc.NSURL didFinishDownloadingToURL, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didFinishDownloadingToURL:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_downloadTask_didFinishDownloadingToURL_, - session.ref.pointer, - downloadTask.ref.pointer, - didFinishDownloadingToURL.ref.pointer, - ); - } - - /// Sent when a download has been resumed. If a download failed with an - /// error, the -userInfo dictionary of the error will contain an - /// NSURLSessionDownloadTaskResumeData key, whose value is the resume - /// data. - void URLSession$1( - NSURLSession session, { - required NSURLSessionDownloadTask downloadTask, - required int didResumeAtOffset, - required int expectedTotalBytes, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:', - ); - } - _objc_msgSend_fm5719( - object$.ref.pointer, - _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - session.ref.pointer, - downloadTask.ref.pointer, - didResumeAtOffset, - expectedTotalBytes, - ); - } - - /// Sent periodically to notify the delegate of download progress. - void URLSession$2( - NSURLSession session, { - required NSURLSessionDownloadTask downloadTask, - required int didWriteData, - required int totalBytesWritten, - required int totalBytesExpectedToWrite, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:', - ); - } - _objc_msgSend_1modw1b( - object$.ref.pointer, - _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - session.ref.pointer, - downloadTask.ref.pointer, - didWriteData, - totalBytesWritten, - totalBytesExpectedToWrite, - ); - } - - /// Sent as the last message related to a specific task. Error may be - /// nil, which implies that no error occurred and this task is complete. - void URLSession$8( - NSURLSession session, { - required NSURLSessionTask task, - objc.NSError? didCompleteWithError, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:didCompleteWithError:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didCompleteWithError_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:didCompleteWithError:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didCompleteWithError_, - session.ref.pointer, - task.ref.pointer, - didCompleteWithError?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Sent when complete statistics information has been collected for the task. - void URLSession$9( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLSessionTaskMetrics didFinishCollectingMetrics, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:didFinishCollectingMetrics:', - iOS: (false, (10, 0, 0)), - macOS: (false, (10, 12, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didFinishCollectingMetrics_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:didFinishCollectingMetrics:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didFinishCollectingMetrics_, - session.ref.pointer, - task.ref.pointer, - didFinishCollectingMetrics.ref.pointer, - ); - } - - /// The task has received a request specific authentication challenge. - /// If this delegate is not implemented, the session specific authentication challenge - /// will *NOT* be called and the behavior will be the same as using the default handling - /// disposition. - void URLSession$10( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLAuthenticationChallenge didReceiveChallenge, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:didReceiveChallenge:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:didReceiveChallenge:completionHandler:', - ); - } - _objc_msgSend_m7tls4( - object$.ref.pointer, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - session.ref.pointer, - task.ref.pointer, - didReceiveChallenge.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent for each informational response received except 101 switching protocols. - void URLSession$11( - NSURLSession session, { - required NSURLSessionTask task, - required NSHTTPURLResponse didReceiveInformationalResponse, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:didReceiveInformationalResponse:', - iOS: (false, (17, 0, 0)), - macOS: (false, (14, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didReceiveInformationalResponse_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:didReceiveInformationalResponse:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didReceiveInformationalResponse_, - session.ref.pointer, - task.ref.pointer, - didReceiveInformationalResponse.ref.pointer, - ); - } - - /// Sent periodically to notify the delegate of upload progress. This - /// information is also available as properties of the task. - void URLSession$12( - NSURLSession session, { - required NSURLSessionTask task, - required int didSendBodyData, - required int totalBytesSent, - required int totalBytesExpectedToSend, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', - ); - } - _objc_msgSend_1modw1b( - object$.ref.pointer, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - session.ref.pointer, - task.ref.pointer, - didSendBodyData, - totalBytesSent, - totalBytesExpectedToSend, - ); - } - - /// Sent if a task requires a new, unopened body stream. This may be - /// necessary when authentication has failed for any request that - /// involves a body stream. - void URLSession$13( - NSURLSession session, { - required NSURLSessionTask task, - required objc.ObjCBlock - needNewBodyStream, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:needNewBodyStream:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStream_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:needNewBodyStream:', - ); - } - _objc_msgSend_18qun1e( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStream_, - session.ref.pointer, - task.ref.pointer, - needNewBodyStream.ref.pointer, - ); - } - - /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be - /// necessary when resuming a failed upload task. - /// - /// - Parameter session: The session containing the task that needs a new body stream from the given offset. - /// - Parameter task: The task that needs a new body stream. - /// - Parameter offset: The starting offset required for the body stream. - /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. - void URLSession$14( - NSURLSession session, { - required NSURLSessionTask task, - required int needNewBodyStreamFromOffset, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', - iOS: (false, (17, 0, 0)), - macOS: (false, (14, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', - ); - } - _objc_msgSend_9cddqw( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - session.ref.pointer, - task.ref.pointer, - needNewBodyStreamFromOffset, - completionHandler.ref.pointer, - ); - } - - /// Sent when the system is ready to begin work for a task with a delayed start - /// time set (using the earliestBeginDate property). The completionHandler must - /// be invoked in order for loading to proceed. The disposition provided to the - /// completion handler continues the load with the original request provided to - /// the task, replaces the request with the specified task, or cancels the task. - /// If this delegate is not implemented, loading will proceed with the original - /// request. - /// - /// Recommendation: only implement this delegate if tasks that have the - /// earliestBeginDate property set may become stale and require alteration prior - /// to starting the network load. - /// - /// If a new request is specified, the allowsExpensiveNetworkAccess, - /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties - /// from the new request will not be used; the properties from the - /// original request will continue to be used. - /// - /// Canceling the task is equivalent to calling the task's cancel method; the - /// URLSession:task:didCompleteWithError: task delegate will be called with error - /// NSURLErrorCancelled. - void URLSession$15( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLRequest willBeginDelayedRequest, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:willBeginDelayedRequest:completionHandler:', - ); - } - _objc_msgSend_m7tls4( - object$.ref.pointer, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - session.ref.pointer, - task.ref.pointer, - willBeginDelayedRequest.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// An HTTP request is attempting to perform a redirection to a different - /// URL. You must invoke the completion routine to allow the - /// redirection, allow the redirection with a modified request, or - /// pass nil to the completionHandler to cause the body of the redirection - /// response to be delivered as the payload of this request. The default - /// is to follow redirections. - /// - /// For tasks in background sessions, redirections will always be followed and this method will not be called. - void URLSession$16( - NSURLSession session, { - required NSURLSessionTask task, - required NSHTTPURLResponse willPerformHTTPRedirection, - required NSURLRequest newRequest, - required objc.ObjCBlock completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', - ); - } - _objc_msgSend_e1wgee( - object$.ref.pointer, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - session.ref.pointer, - task.ref.pointer, - willPerformHTTPRedirection.ref.pointer, - newRequest.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent when a task cannot start the network loading process because the current - /// network connectivity is not available or sufficient for the task's request. - /// - /// This delegate will be called at most one time per task, and is only called if - /// the waitsForConnectivity property in the NSURLSessionConfiguration has been - /// set to YES. - /// - /// This delegate callback will never be called for background sessions, because - /// the waitForConnectivity property is ignored by those sessions. - void URLSession$17( - NSURLSession session, { - required NSURLSessionTask taskIsWaitingForConnectivity, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSession:taskIsWaitingForConnectivity:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_taskIsWaitingForConnectivity_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSession:taskIsWaitingForConnectivity:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_taskIsWaitingForConnectivity_, - session.ref.pointer, - taskIsWaitingForConnectivity.ref.pointer, - ); - } - - /// If an application has received an - /// -application:handleEventsForBackgroundURLSession:completionHandler: - /// message, the session delegate will receive this message to indicate - /// that all messages previously enqueued for this session have been - /// delivered. At this time it is safe to invoke the previously stored - /// completion handler, or to begin any internal updates that will - /// result in invoking the completion handler. - void URLSessionDidFinishEventsForBackgroundURLSession(NSURLSession session) { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', - iOS: (false, (7, 0, 0)), - macOS: (false, (11, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionDownloadDelegate', - 'URLSessionDidFinishEventsForBackgroundURLSession:', - ); - } - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - session.ref.pointer, - ); - } -} - -interface class NSURLSessionDownloadDelegate$Builder { - /// Returns the [objc.Protocol] object for this protocol. - static objc.Protocol get $protocol => - objc.Protocol.fromPointer(_protocol_NSURLSessionDownloadDelegate.cast()); - - /// Builds an object that implements the NSURLSessionDownloadDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionDownloadDelegate implement({ - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - URLSession_downloadTask_didFinishDownloadingToURL_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionDownloadDelegate', - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implement( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDownloadDelegate$Builder.URLSession_didCreateTask_.implement( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didFinishDownloadingToURL_.implement( - builder, - URLSession_downloadTask_didFinishDownloadingToURL_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implement( - builder, - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implement( - builder, - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didCompleteWithError_.implement( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implement( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implement( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStream_.implement( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implement( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implement( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionDownloadDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilder( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - URLSession_downloadTask_didFinishDownloadingToURL_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionDownloadDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implement( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDownloadDelegate$Builder.URLSession_didCreateTask_.implement( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didFinishDownloadingToURL_.implement( - builder, - URLSession_downloadTask_didFinishDownloadingToURL_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implement( - builder, - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implement( - builder, - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didCompleteWithError_.implement( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implement( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implement( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStream_.implement( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implement( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implement( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// Builds an object that implements the NSURLSessionDownloadDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All - /// methods that can be implemented as listeners will be. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionDownloadDelegate implementAsListener({ - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - URLSession_downloadTask_didFinishDownloadingToURL_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionDownloadDelegate', - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsListener( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didCreateTask_.implementAsListener( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsListener( - builder, - URLSession_downloadTask_didFinishDownloadingToURL_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsListener( - builder, - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsListener( - builder, - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsListener( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsListener( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsListener( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsListener( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsListener( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionDownloadDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will - /// be. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilderAsListener( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - URLSession_downloadTask_didFinishDownloadingToURL_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionDownloadDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsListener( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didCreateTask_.implementAsListener( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsListener( - builder, - URLSession_downloadTask_didFinishDownloadingToURL_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsListener( - builder, - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsListener( - builder, - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsListener( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsListener( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsListener( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsListener( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsListener( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// Builds an object that implements the NSURLSessionDownloadDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All - /// methods that can be implemented as blocking listeners will be. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionDownloadDelegate implementAsBlocking({ - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - URLSession_downloadTask_didFinishDownloadingToURL_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionDownloadDelegate', - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsBlocking( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didCreateTask_.implementAsBlocking( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsBlocking( - builder, - URLSession_downloadTask_didFinishDownloadingToURL_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsBlocking( - builder, - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsBlocking( - builder, - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsBlocking( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionDownloadDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking - /// listeners will be. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilderAsBlocking( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - required void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - URLSession_downloadTask_didFinishDownloadingToURL_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int)? - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int)? - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionDownloadDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsBlocking( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didCreateTask_.implementAsBlocking( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsBlocking( - builder, - URLSession_downloadTask_didFinishDownloadingToURL_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsBlocking( - builder, - URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsBlocking( - builder, - URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsBlocking( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionDownloadDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// The last message a session receives. A session will only become - /// invalid because of a systemic error or when it has been - /// explicitly invalidated, in which case the error parameter will be nil. - static final URLSession_didBecomeInvalidWithError_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, objc.NSError?) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_didBecomeInvalidWithError_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_didBecomeInvalidWithError_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - ); - - /// Notification that a task has been created. This method is the first message - /// a task sends, providing a place to configure the task before it is resumed. - /// - /// This delegate callback is *NOT* dispatched to the delegate queue. It is - /// invoked synchronously before the task creation method returns. - static final URLSession_didCreateTask_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_didCreateTask_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_didCreateTask_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - ); - - /// If implemented, when a connection level authentication challenge - /// has occurred, this delegate will be given the opportunity to - /// provide authentication credentials to the underlying - /// connection. Some types of authentication will apply to more than - /// one request on a given connection to a server (SSL Server Trust - /// challenges). If this delegate message is not implemented, the - /// behavior will be to use the default handling, which may involve user - /// interaction. - static final URLSession_didReceiveChallenge_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_didReceiveChallenge_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_bklti2) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_didReceiveChallenge_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent when a download task that has completed a download. The delegate should - /// copy or move the file at the given location to a new location as it will be - /// removed when the delegate message returns. URLSession:task:didCompleteWithError: will - /// still be called. - static final URLSession_downloadTask_didFinishDownloadingToURL_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_downloadTask_didFinishDownloadingToURL_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_downloadTask_didFinishDownloadingToURL_, - isRequired: true, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - objc.NSURL arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - objc.NSURL arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - objc.NSURL arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent when a download has been resumed. If a download failed with an - /// error, the -userInfo dictionary of the error will contain an - /// NSURLSessionDownloadTaskResumeData key, whose value is the resume - /// data. - static final URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionDownloadTask, int, int) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_ly2579) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, int, int) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - int arg3, - int arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, int, int) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - int arg3, - int arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, int, int) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - int arg3, - int arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Sent periodically to notify the delegate of download progress. - static final URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_h68abb) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ( - void Function(NSURLSession, NSURLSessionDownloadTask, int, int, int) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDownloadTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ); - - /// Sent as the last message related to a specific task. Error may be - /// nil, which implies that no error occurred and this task is complete. - static final URLSession_task_didCompleteWithError_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, objc.NSError?) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didCompleteWithError_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didCompleteWithError_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent when complete statistics information has been collected for the task. - static final URLSession_task_didFinishCollectingMetrics_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didFinishCollectingMetrics_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didFinishCollectingMetrics_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// The task has received a request specific authentication challenge. - /// If this delegate is not implemented, the session specific authentication challenge - /// will *NOT* be called and the behavior will be the same as using the default handling - /// disposition. - static final URLSession_task_didReceiveChallenge_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_xx612k) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Sent for each informational response received except 101 switching protocols. - static final URLSession_task_didReceiveInformationalResponse_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didReceiveInformationalResponse_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didReceiveInformationalResponse_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent periodically to notify the delegate of upload progress. This - /// information is also available as properties of the task. - static final URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, int, int, int) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_h68abb) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ); - - /// Sent if a task requires a new, unopened body stream. This may be - /// necessary when authentication has failed for any request that - /// involves a body stream. - static final URLSession_task_needNewBodyStream_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_needNewBodyStream_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_bklti2) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_needNewBodyStream_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be - /// necessary when resuming a failed upload task. - /// - /// - Parameter session: The session containing the task that needs a new body stream from the given offset. - /// - Parameter task: The task that needs a new body stream. - /// - Parameter offset: The starting offset required for the body stream. - /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. - static final URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_jyim80) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Sent when the system is ready to begin work for a task with a delayed start - /// time set (using the earliestBeginDate property). The completionHandler must - /// be invoked in order for loading to proceed. The disposition provided to the - /// completion handler continues the load with the original request provided to - /// the task, replaces the request with the specified task, or cancels the task. - /// If this delegate is not implemented, loading will proceed with the original - /// request. - /// - /// Recommendation: only implement this delegate if tasks that have the - /// earliestBeginDate property set may become stale and require alteration prior - /// to starting the network load. - /// - /// If a new request is specified, the allowsExpensiveNetworkAccess, - /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties - /// from the new request will not be used; the properties from the - /// original request will continue to be used. - /// - /// Canceling the task is equivalent to calling the task's cancel method; the - /// URLSession:task:didCompleteWithError: task delegate will be called with error - /// NSURLErrorCancelled. - static final URLSession_task_willBeginDelayedRequest_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_xx612k) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// An HTTP request is attempting to perform a redirection to a different - /// URL. You must invoke the completion routine to allow the - /// redirection, allow the redirection with a modified request, or - /// pass nil to the completionHandler to cause the body of the redirection - /// response to be delivered as the payload of this request. The default - /// is to follow redirections. - /// - /// For tasks in background sessions, redirections will always be followed and this method will not be called. - static final URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_l2g8ke) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ); - - /// Sent when a task cannot start the network loading process because the current - /// network connectivity is not available or sufficient for the task's request. - /// - /// This delegate will be called at most one time per task, and is only called if - /// the waitsForConnectivity property in the NSURLSessionConfiguration has been - /// set to YES. - /// - /// This delegate callback will never be called for background sessions, because - /// the waitForConnectivity property is ignored by those sessions. - static final URLSession_taskIsWaitingForConnectivity_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask) - >( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_taskIsWaitingForConnectivity_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSession_taskIsWaitingForConnectivity_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - ); - - /// If an application has received an - /// -application:handleEventsForBackgroundURLSession:completionHandler: - /// message, the session delegate will receive this message to indicate - /// that all messages previously enqueued for this session have been - /// delivered. At this time it is safe to invoke the previously stored - /// completion handler, or to begin any internal updates that will - /// result in invoking the completion handler. - static final URLSessionDidFinishEventsForBackgroundURLSession_ = - objc.ObjCProtocolListenableMethod( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_18v1jvf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionDownloadDelegate, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.fromFunction( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.listener( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.blocking( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - ); -} - -late final _protocol_NSURLSessionWebSocketDelegate = objc.getProtocol( - "NSURLSessionWebSocketDelegate", -); -late final _sel_URLSession_webSocketTask_didOpenWithProtocol_ = objc - .registerName("URLSession:webSocketTask:didOpenWithProtocol:"); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionWebSocketTask.fromPointer( - arg2, - retain: true, - release: true, - ), - arg3.address == 0 - ? null - : objc.NSString.fromPointer(arg3, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionWebSocketTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3.address == 0 - ? null - : objc.NSString.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1tz5yf(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionWebSocketTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3.address == 0 - ? null - : objc.NSString.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionWebSocketTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3.address == 0 - ? null - : objc.NSString.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionWebSocketTask arg2, - objc.NSString? arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3?.ref.pointer ?? ffi.nullptr, - ); -} - -late final _sel_URLSession_webSocketTask_didCloseWithCode_reason_ = objc - .registerName("URLSession:webSocketTask:didCloseWithCode:reason:"); -final _objc_msgSend_d9bpjb = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, NSInteger, objc.NSData?)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - NSInteger arg3, - ffi.Pointer arg4, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - > - fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionWebSocketTask.fromPointer( - arg2, - retain: true, - release: true, - ), - arg3, - arg4.address == 0 - ? null - : objc.NSData.fromPointer(arg4, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - > - listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionWebSocketTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4.address == 0 - ? null - : objc.NSData.fromPointer(arg4, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1lx650f(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - > - blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionWebSocketTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4.address == 0 - ? null - : objc.NSData.fromPointer(arg4, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionWebSocketTask.fromPointer( - arg2, - retain: false, - release: true, - ), - arg3, - arg4.address == 0 - ? null - : objc.NSData.fromPointer(arg4, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1lx650f( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - NSInteger arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >()(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, NSInteger, objc.NSData?)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionWebSocketTask, - NSInteger, - objc.NSData?, - ) - > { - void call( - ffi.Pointer arg0, - NSURLSession arg1, - NSURLSessionWebSocketTask arg2, - DartNSInteger arg3, - objc.NSData? arg4, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - NSInteger arg3, - ffi.Pointer arg4, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3, - arg4?.ref.pointer ?? ffi.nullptr, - ); -} - -/// NSURLSessionWebSocketDelegate -extension type NSURLSessionWebSocketDelegate._(objc.ObjCProtocol object$) - implements objc.ObjCProtocol, NSURLSessionTaskDelegate { - /// Constructs a [NSURLSessionWebSocketDelegate] that points to the same underlying object as [other]. - NSURLSessionWebSocketDelegate.as(objc.ObjCObject other) : object$ = other; - - /// Constructs a [NSURLSessionWebSocketDelegate] that wraps the given raw object pointer. - NSURLSessionWebSocketDelegate.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); - - /// Returns whether [obj] is an instance of [NSURLSessionWebSocketDelegate]. - static bool conformsTo(objc.ObjCObject obj) { - return _objc_msgSend_e3qsqz( - obj.ref.pointer, - _sel_conformsToProtocol_, - _protocol_NSURLSessionWebSocketDelegate, - ); - } -} - -extension NSURLSessionWebSocketDelegate$Methods - on NSURLSessionWebSocketDelegate { - /// The last message a session receives. A session will only become - /// invalid because of a systemic error or when it has been - /// explicitly invalidated, in which case the error parameter will be nil. - void URLSession$5( - NSURLSession session, { - objc.NSError? didBecomeInvalidWithError, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:didBecomeInvalidWithError:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didBecomeInvalidWithError_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:didBecomeInvalidWithError:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_didBecomeInvalidWithError_, - session.ref.pointer, - didBecomeInvalidWithError?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Notification that a task has been created. This method is the first message - /// a task sends, providing a place to configure the task before it is resumed. - /// - /// This delegate callback is *NOT* dispatched to the delegate queue. It is - /// invoked synchronously before the task creation method returns. - void URLSession$6( - NSURLSession session, { - required NSURLSessionTask didCreateTask, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:didCreateTask:', - iOS: (false, (16, 0, 0)), - macOS: (false, (13, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didCreateTask_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:didCreateTask:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_didCreateTask_, - session.ref.pointer, - didCreateTask.ref.pointer, - ); - } - - /// If implemented, when a connection level authentication challenge - /// has occurred, this delegate will be given the opportunity to - /// provide authentication credentials to the underlying - /// connection. Some types of authentication will apply to more than - /// one request on a given connection to a server (SSL Server Trust - /// challenges). If this delegate message is not implemented, the - /// behavior will be to use the default handling, which may involve user - /// interaction. - void URLSession$7( - NSURLSession session, { - required NSURLAuthenticationChallenge didReceiveChallenge, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:didReceiveChallenge:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_didReceiveChallenge_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:didReceiveChallenge:completionHandler:', - ); - } - _objc_msgSend_18qun1e( - object$.ref.pointer, - _sel_URLSession_didReceiveChallenge_completionHandler_, - session.ref.pointer, - didReceiveChallenge.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent as the last message related to a specific task. Error may be - /// nil, which implies that no error occurred and this task is complete. - void URLSession$8( - NSURLSession session, { - required NSURLSessionTask task, - objc.NSError? didCompleteWithError, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:didCompleteWithError:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didCompleteWithError_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:didCompleteWithError:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didCompleteWithError_, - session.ref.pointer, - task.ref.pointer, - didCompleteWithError?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Sent when complete statistics information has been collected for the task. - void URLSession$9( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLSessionTaskMetrics didFinishCollectingMetrics, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:didFinishCollectingMetrics:', - iOS: (false, (10, 0, 0)), - macOS: (false, (10, 12, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didFinishCollectingMetrics_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:didFinishCollectingMetrics:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didFinishCollectingMetrics_, - session.ref.pointer, - task.ref.pointer, - didFinishCollectingMetrics.ref.pointer, - ); - } - - /// The task has received a request specific authentication challenge. - /// If this delegate is not implemented, the session specific authentication challenge - /// will *NOT* be called and the behavior will be the same as using the default handling - /// disposition. - void URLSession$10( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLAuthenticationChallenge didReceiveChallenge, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:didReceiveChallenge:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:didReceiveChallenge:completionHandler:', - ); - } - _objc_msgSend_m7tls4( - object$.ref.pointer, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - session.ref.pointer, - task.ref.pointer, - didReceiveChallenge.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent for each informational response received except 101 switching protocols. - void URLSession$11( - NSURLSession session, { - required NSURLSessionTask task, - required NSHTTPURLResponse didReceiveInformationalResponse, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:didReceiveInformationalResponse:', - iOS: (false, (17, 0, 0)), - macOS: (false, (14, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didReceiveInformationalResponse_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:didReceiveInformationalResponse:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_task_didReceiveInformationalResponse_, - session.ref.pointer, - task.ref.pointer, - didReceiveInformationalResponse.ref.pointer, - ); - } - - /// Sent periodically to notify the delegate of upload progress. This - /// information is also available as properties of the task. - void URLSession$12( - NSURLSession session, { - required NSURLSessionTask task, - required int didSendBodyData, - required int totalBytesSent, - required int totalBytesExpectedToSend, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', - ); - } - _objc_msgSend_1modw1b( - object$.ref.pointer, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - session.ref.pointer, - task.ref.pointer, - didSendBodyData, - totalBytesSent, - totalBytesExpectedToSend, - ); - } - - /// Sent if a task requires a new, unopened body stream. This may be - /// necessary when authentication has failed for any request that - /// involves a body stream. - void URLSession$13( - NSURLSession session, { - required NSURLSessionTask task, - required objc.ObjCBlock - needNewBodyStream, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:needNewBodyStream:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStream_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:needNewBodyStream:', - ); - } - _objc_msgSend_18qun1e( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStream_, - session.ref.pointer, - task.ref.pointer, - needNewBodyStream.ref.pointer, - ); - } - - /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be - /// necessary when resuming a failed upload task. - /// - /// - Parameter session: The session containing the task that needs a new body stream from the given offset. - /// - Parameter task: The task that needs a new body stream. - /// - Parameter offset: The starting offset required for the body stream. - /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. - void URLSession$14( - NSURLSession session, { - required NSURLSessionTask task, - required int needNewBodyStreamFromOffset, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', - iOS: (false, (17, 0, 0)), - macOS: (false, (14, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', - ); - } - _objc_msgSend_9cddqw( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - session.ref.pointer, - task.ref.pointer, - needNewBodyStreamFromOffset, - completionHandler.ref.pointer, - ); - } - - /// Sent when the system is ready to begin work for a task with a delayed start - /// time set (using the earliestBeginDate property). The completionHandler must - /// be invoked in order for loading to proceed. The disposition provided to the - /// completion handler continues the load with the original request provided to - /// the task, replaces the request with the specified task, or cancels the task. - /// If this delegate is not implemented, loading will proceed with the original - /// request. - /// - /// Recommendation: only implement this delegate if tasks that have the - /// earliestBeginDate property set may become stale and require alteration prior - /// to starting the network load. - /// - /// If a new request is specified, the allowsExpensiveNetworkAccess, - /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties - /// from the new request will not be used; the properties from the - /// original request will continue to be used. - /// - /// Canceling the task is equivalent to calling the task's cancel method; the - /// URLSession:task:didCompleteWithError: task delegate will be called with error - /// NSURLErrorCancelled. - void URLSession$15( - NSURLSession session, { - required NSURLSessionTask task, - required NSURLRequest willBeginDelayedRequest, - required objc.ObjCBlock - completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:willBeginDelayedRequest:completionHandler:', - ); - } - _objc_msgSend_m7tls4( - object$.ref.pointer, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - session.ref.pointer, - task.ref.pointer, - willBeginDelayedRequest.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// An HTTP request is attempting to perform a redirection to a different - /// URL. You must invoke the completion routine to allow the - /// redirection, allow the redirection with a modified request, or - /// pass nil to the completionHandler to cause the body of the redirection - /// response to be delivered as the payload of this request. The default - /// is to follow redirections. - /// - /// For tasks in background sessions, redirections will always be followed and this method will not be called. - void URLSession$16( - NSURLSession session, { - required NSURLSessionTask task, - required NSHTTPURLResponse willPerformHTTPRedirection, - required NSURLRequest newRequest, - required objc.ObjCBlock completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', - ); - } - _objc_msgSend_e1wgee( - object$.ref.pointer, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - session.ref.pointer, - task.ref.pointer, - willPerformHTTPRedirection.ref.pointer, - newRequest.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// Sent when a task cannot start the network loading process because the current - /// network connectivity is not available or sufficient for the task's request. - /// - /// This delegate will be called at most one time per task, and is only called if - /// the waitsForConnectivity property in the NSURLSessionConfiguration has been - /// set to YES. - /// - /// This delegate callback will never be called for background sessions, because - /// the waitForConnectivity property is ignored by those sessions. - void URLSession$17( - NSURLSession session, { - required NSURLSessionTask taskIsWaitingForConnectivity, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:taskIsWaitingForConnectivity:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_taskIsWaitingForConnectivity_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:taskIsWaitingForConnectivity:', - ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_taskIsWaitingForConnectivity_, - session.ref.pointer, - taskIsWaitingForConnectivity.ref.pointer, - ); - } - - /// Indicates that the WebSocket has received a close frame from the server endpoint. - /// The close code and the close reason may be provided by the delegate if the server elects to send - /// this information in the close frame - void URLSession( - NSURLSession session, { - required NSURLSessionWebSocketTask webSocketTask, - required DartNSInteger didCloseWithCode, - objc.NSData? reason, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:webSocketTask:didCloseWithCode:reason:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_webSocketTask_didCloseWithCode_reason_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:webSocketTask:didCloseWithCode:reason:', - ); - } - _objc_msgSend_d9bpjb( - object$.ref.pointer, - _sel_URLSession_webSocketTask_didCloseWithCode_reason_, - session.ref.pointer, - webSocketTask.ref.pointer, - didCloseWithCode, - reason?.ref.pointer ?? ffi.nullptr, - ); - } - - /// Indicates that the WebSocket handshake was successful and the connection has been upgraded to webSockets. - /// It will also provide the protocol that is picked in the handshake. If the handshake fails, this delegate will not be invoked. - void URLSession$1( - NSURLSession session, { - required NSURLSessionWebSocketTask webSocketTask, - objc.NSString? didOpenWithProtocol, - }) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSession:webSocketTask:didOpenWithProtocol:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSession_webSocketTask_didOpenWithProtocol_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSession:webSocketTask:didOpenWithProtocol:', - ); - } - _objc_msgSend_r8gdi7( - object$.ref.pointer, - _sel_URLSession_webSocketTask_didOpenWithProtocol_, - session.ref.pointer, - webSocketTask.ref.pointer, - didOpenWithProtocol?.ref.pointer ?? ffi.nullptr, - ); - } - - /// If an application has received an - /// -application:handleEventsForBackgroundURLSession:completionHandler: - /// message, the session delegate will receive this message to indicate - /// that all messages previously enqueued for this session have been - /// delivered. At this time it is safe to invoke the previously stored - /// completion handler, or to begin any internal updates that will - /// result in invoking the completion handler. - void URLSessionDidFinishEventsForBackgroundURLSession(NSURLSession session) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', - iOS: (false, (7, 0, 0)), - macOS: (false, (11, 0, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURLSessionWebSocketDelegate', - 'URLSessionDidFinishEventsForBackgroundURLSession:', - ); - } - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - session.ref.pointer, - ); - } -} - -interface class NSURLSessionWebSocketDelegate$Builder { - /// Returns the [objc.Protocol] object for this protocol. - static objc.Protocol get $protocol => - objc.Protocol.fromPointer(_protocol_NSURLSessionWebSocketDelegate.cast()); - - /// Builds an object that implements the NSURLSessionWebSocketDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionWebSocketDelegate implement({ - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - )? - URLSession_webSocketTask_didCloseWithCode_reason_, - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? - URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionWebSocketDelegate', - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implement( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionWebSocketDelegate$Builder.URLSession_didCreateTask_.implement( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didCompleteWithError_.implement( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implement( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implement( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStream_.implement( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implement( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didCloseWithCode_reason_.implement( - builder, - URLSession_webSocketTask_didCloseWithCode_reason_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didOpenWithProtocol_.implement( - builder, - URLSession_webSocketTask_didOpenWithProtocol_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implement( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionWebSocketDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilder( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - )? - URLSession_webSocketTask_didCloseWithCode_reason_, - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? - URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionWebSocketDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implement( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionWebSocketDelegate$Builder.URLSession_didCreateTask_.implement( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didCompleteWithError_.implement( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implement( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implement( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implement( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStream_.implement( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implement( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didCloseWithCode_reason_.implement( - builder, - URLSession_webSocketTask_didCloseWithCode_reason_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didOpenWithProtocol_.implement( - builder, - URLSession_webSocketTask_didOpenWithProtocol_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implement( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// Builds an object that implements the NSURLSessionWebSocketDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All - /// methods that can be implemented as listeners will be. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionWebSocketDelegate implementAsListener({ - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - )? - URLSession_webSocketTask_didCloseWithCode_reason_, - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? - URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionWebSocketDelegate', - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsListener( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didCreateTask_.implementAsListener( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsListener( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsListener( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsListener( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsListener( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsListener( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didCloseWithCode_reason_.implementAsListener( - builder, - URLSession_webSocketTask_didCloseWithCode_reason_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didOpenWithProtocol_.implementAsListener( - builder, - URLSession_webSocketTask_didOpenWithProtocol_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionWebSocketDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will - /// be. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilderAsListener( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - )? - URLSession_webSocketTask_didCloseWithCode_reason_, - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? - URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionWebSocketDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsListener( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didCreateTask_.implementAsListener( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsListener( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsListener( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsListener( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsListener( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsListener( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didCloseWithCode_reason_.implementAsListener( - builder, - URLSession_webSocketTask_didCloseWithCode_reason_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didOpenWithProtocol_.implementAsListener( - builder, - URLSession_webSocketTask_didOpenWithProtocol_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// Builds an object that implements the NSURLSessionWebSocketDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All - /// methods that can be implemented as blocking listeners will be. - /// - /// If `$keepIsolateAlive` is true, this protocol will keep this isolate - /// alive until it is garbage collected by both Dart and ObjC. - static NSURLSessionWebSocketDelegate implementAsBlocking({ - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - )? - URLSession_webSocketTask_didCloseWithCode_reason_, - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? - URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionWebSocketDelegate', - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsBlocking( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didCreateTask_.implementAsBlocking( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsBlocking( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didCloseWithCode_reason_.implementAsBlocking( - builder, - URLSession_webSocketTask_didCloseWithCode_reason_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didOpenWithProtocol_.implementAsBlocking( - builder, - URLSession_webSocketTask_didOpenWithProtocol_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - return NSURLSessionWebSocketDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), - ); - } - - /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking - /// listeners will be. - /// - /// Note: You cannot call this method after you have called `builder.build`. - static void addToBuilderAsBlocking( - objc.ObjCProtocolBuilder builder, { - void Function(NSURLSession, objc.NSError?)? - URLSession_didBecomeInvalidWithError_, - void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - )? - URLSession_webSocketTask_didCloseWithCode_reason_, - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? - URLSession_webSocketTask_didOpenWithProtocol_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, - }) { - NSURLSessionWebSocketDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsBlocking( - builder, - URLSession_didBecomeInvalidWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didCreateTask_.implementAsBlocking( - builder, - URLSession_didCreateTask_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didCompleteWithError_.implementAsBlocking( - builder, - URLSession_task_didCompleteWithError_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( - builder, - URLSession_task_didFinishCollectingMetrics_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( - builder, - URLSession_task_didReceiveChallenge_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( - builder, - URLSession_task_didReceiveInformationalResponse_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( - builder, - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStream_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStream_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( - builder, - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willBeginDelayedRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( - builder, - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( - builder, - URLSession_taskIsWaitingForConnectivity_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didCloseWithCode_reason_.implementAsBlocking( - builder, - URLSession_webSocketTask_didCloseWithCode_reason_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSession_webSocketTask_didOpenWithProtocol_.implementAsBlocking( - builder, - URLSession_webSocketTask_didOpenWithProtocol_, - ); - NSURLSessionWebSocketDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, - ); - builder.addProtocol($protocol); - } - - /// The last message a session receives. A session will only become - /// invalid because of a systemic error or when it has been - /// explicitly invalidated, in which case the error parameter will be nil. - static final URLSession_didBecomeInvalidWithError_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, objc.NSError?) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_didBecomeInvalidWithError_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_didBecomeInvalidWithError_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - objc.NSError? arg2, - ) => func(arg1, arg2), - ), - ); - - /// Notification that a task has been created. This method is the first message - /// a task sends, providing a place to configure the task before it is resumed. - /// - /// This delegate callback is *NOT* dispatched to the delegate queue. It is - /// invoked synchronously before the task creation method returns. - static final URLSession_didCreateTask_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_didCreateTask_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_didCreateTask_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - ); - - /// If implemented, when a connection level authentication challenge - /// has occurred, this delegate will be given the opportunity to - /// provide authentication credentials to the underlying - /// connection. Some types of authentication will apply to more than - /// one request on a given connection to a server (SSL Server Trust - /// challenges). If this delegate message is not implemented, the - /// behavior will be to use the default handling, which may involve user - /// interaction. - static final URLSession_didReceiveChallenge_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_didReceiveChallenge_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_bklti2) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_didReceiveChallenge_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent as the last message related to a specific task. Error may be - /// nil, which implies that no error occurred and this task is complete. - static final URLSession_task_didCompleteWithError_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, objc.NSError?) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didCompleteWithError_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didCompleteWithError_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.NSError? arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent when complete statistics information has been collected for the task. - static final URLSession_task_didFinishCollectingMetrics_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didFinishCollectingMetrics_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didFinishCollectingMetrics_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLSessionTaskMetrics arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// The task has received a request specific authentication challenge. - /// If this delegate is not implemented, the session specific authentication challenge - /// will *NOT* be called and the behavior will be the same as using the default handling - /// disposition. - static final URLSession_task_didReceiveChallenge_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_xx612k) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didReceiveChallenge_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLAuthenticationChallenge arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Sent for each informational response received except 101 switching protocols. - static final URLSession_task_didReceiveInformationalResponse_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didReceiveInformationalResponse_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didReceiveInformationalResponse_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Sent periodically to notify the delegate of upload progress. This - /// information is also available as properties of the task. - static final URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask, int, int, int) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_h68abb) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - int arg4, - int arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ); - - /// Sent if a task requires a new, unopened body stream. This may be - /// necessary when authentication has failed for any request that - /// involves a body stream. - static final URLSession_task_needNewBodyStream_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_needNewBodyStream_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_bklti2) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_needNewBodyStream_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - objc.ObjCBlock arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be - /// necessary when resuming a failed upload task. - /// - /// - Parameter session: The session containing the task that needs a new body stream from the given offset. - /// - Parameter task: The task that needs a new body stream. - /// - Parameter offset: The starting offset required for the body stream. - /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. - static final URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_jyim80) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - int arg3, - objc.ObjCBlock arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Sent when the system is ready to begin work for a task with a delayed start - /// time set (using the earliestBeginDate property). The completionHandler must - /// be invoked in order for loading to proceed. The disposition provided to the - /// completion handler continues the load with the original request provided to - /// the task, replaces the request with the specified task, or cancels the task. - /// If this delegate is not implemented, loading will proceed with the original - /// request. - /// - /// Recommendation: only implement this delegate if tasks that have the - /// earliestBeginDate property set may become stale and require alteration prior - /// to starting the network load. - /// - /// If a new request is specified, the allowsExpensiveNetworkAccess, - /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties - /// from the new request will not be used; the properties from the - /// original request will continue to be used. - /// - /// Canceling the task is equivalent to calling the task's cancel method; the - /// URLSession:task:didCompleteWithError: task delegate will be called with error - /// NSURLErrorCancelled. - static final URLSession_task_willBeginDelayedRequest_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_xx612k) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSURLRequest arg3, - objc.ObjCBlock - arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// An HTTP request is attempting to perform a redirection to a different - /// URL. You must invoke the completion routine to allow the - /// redirection, allow the redirection with a modified request, or - /// pass nil to the completionHandler to cause the body of the redirection - /// response to be delivered as the payload of this request. The default - /// is to follow redirections. - /// - /// For tasks in background sessions, redirections will always be followed and this method will not be called. - static final URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_l2g8ke) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ( - void Function( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - NSHTTPURLResponse arg3, - NSURLRequest arg4, - objc.ObjCBlock arg5, - ) => func(arg1, arg2, arg3, arg4, arg5), - ), - ); - - /// Sent when a task cannot start the network loading process because the current - /// network connectivity is not available or sufficient for the task's request. - /// - /// This delegate will be called at most one time per task, and is only called if - /// the waitsForConnectivity property in the NSURLSessionConfiguration has been - /// set to YES. - /// - /// This delegate callback will never be called for background sessions, because - /// the waitForConnectivity property is ignored by those sessions. - static final URLSession_taskIsWaitingForConnectivity_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionTask) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_taskIsWaitingForConnectivity_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_taskIsWaitingForConnectivity_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), - ), - ); - - /// Indicates that the WebSocket has received a close frame from the server endpoint. - /// The close code and the close reason may be provided by the delegate if the server elects to send - /// this information in the close frame - static final URLSession_webSocketTask_didCloseWithCode_reason_ = - objc.ObjCProtocolListenableMethod< - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - ) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_webSocketTask_didCloseWithCode_reason_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSInteger, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1lx650f) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_webSocketTask_didCloseWithCode_reason_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionWebSocketTask arg2, - DartNSInteger arg3, - objc.NSData? arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionWebSocketTask arg2, - DartNSInteger arg3, - objc.NSData? arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ( - void Function( - NSURLSession, - NSURLSessionWebSocketTask, - DartNSInteger, - objc.NSData?, - ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionWebSocketTask arg2, - DartNSInteger arg3, - objc.NSData? arg4, - ) => func(arg1, arg2, arg3, arg4), - ), - ); - - /// Indicates that the WebSocket handshake was successful and the connection has been upgraded to webSockets. - /// It will also provide the protocol that is picked in the handshake. If the handshake fails, this delegate will not be invoked. - static final URLSession_webSocketTask_didOpenWithProtocol_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?) - >( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_webSocketTask_didOpenWithProtocol_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSession_webSocketTask_didOpenWithProtocol_, - isRequired: false, - isInstanceMethod: true, - ), - ( - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString.fromFunction( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionWebSocketTask arg2, - objc.NSString? arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionWebSocketTask arg2, - objc.NSString? arg3, - ) => func(arg1, arg2, arg3), - ), - ( - void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionWebSocketTask arg2, - objc.NSString? arg3, - ) => func(arg1, arg2, arg3), - ), - ); - - /// If an application has received an - /// -application:handleEventsForBackgroundURLSession:completionHandler: - /// message, the session delegate will receive this message to indicate - /// that all messages previously enqueued for this session have been - /// delivered. At this time it is safe to invoke the previously stored - /// completion handler, or to begin any internal updates that will - /// result in invoking the completion handler. - static final URLSessionDidFinishEventsForBackgroundURLSession_ = - objc.ObjCProtocolListenableMethod( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - ffi.Native.addressOf< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >(_NativeCupertinoHttp_protocolTrampoline_18v1jvf) - .cast(), - objc.getProtocolMethodSignature( - _protocol_NSURLSessionWebSocketDelegate, - _sel_URLSessionDidFinishEventsForBackgroundURLSession_, - isRequired: false, - isInstanceMethod: true, - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.fromFunction( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.listener( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - (void Function(NSURLSession) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession.blocking( - (ffi.Pointer _, NSURLSession arg1) => func(arg1), - ), - ); -} - -typedef unichar = ffi.UnsignedShort; -typedef Dartunichar = int; -late final _class_NSValue = objc.getClass("NSValue"); -late final _sel_valueWithBytes_objCType_ = objc.registerName( - "valueWithBytes:objCType:", -); -final _objc_msgSend_e9mncn = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_value_withObjCType_ = objc.registerName("value:withObjCType:"); - -/// NSValueCreation -extension NSValueCreation on objc.NSValue { - /// value:withObjCType: - static objc.NSValue value( - ffi.Pointer value, { - required ffi.Pointer withObjCType, - }) { - final $ret = _objc_msgSend_e9mncn( - _class_NSValue, - _sel_value_withObjCType_, - value, - withObjCType, - ); - return objc.NSValue.fromPointer($ret, retain: true, release: true); - } - - /// valueWithBytes:objCType: - static objc.NSValue valueWithBytes( - ffi.Pointer value, { - required ffi.Pointer objCType, - }) { - final $ret = _objc_msgSend_e9mncn( - _class_NSValue, - _sel_valueWithBytes_objCType_, - value, - objCType, - ); - return objc.NSValue.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_valueWithNonretainedObject_ = objc.registerName( - "valueWithNonretainedObject:", -); -late final _sel_nonretainedObjectValue = objc.registerName( - "nonretainedObjectValue", -); -late final _sel_valueWithPointer_ = objc.registerName("valueWithPointer:"); -final _objc_msgSend_1mbt9g9 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_pointerValue = objc.registerName("pointerValue"); -final _objc_msgSend_6ex6p5 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_isEqualToValue_ = objc.registerName("isEqualToValue:"); - -/// NSValueExtensionMethods -extension NSValueExtensionMethods on objc.NSValue { - /// isEqualToValue: - bool isEqualToValue(objc.NSValue value) { - return _objc_msgSend_19nvye5( - object$.ref.pointer, - _sel_isEqualToValue_, - value.ref.pointer, - ); - } - - /// nonretainedObjectValue - objc.ObjCObject? get nonretainedObjectValue { - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_nonretainedObjectValue, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: true, release: true); - } - - /// pointerValue - ffi.Pointer get pointerValue { - return _objc_msgSend_6ex6p5(object$.ref.pointer, _sel_pointerValue); - } - - /// valueWithNonretainedObject: - static objc.NSValue valueWithNonretainedObject(objc.ObjCObject? anObject) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSValue, - _sel_valueWithNonretainedObject_, - anObject?.ref.pointer ?? ffi.nullptr, - ); - return objc.NSValue.fromPointer($ret, retain: true, release: true); - } - - /// valueWithPointer: - static objc.NSValue valueWithPointer(ffi.Pointer pointer) { - final $ret = _objc_msgSend_1mbt9g9( - _class_NSValue, - _sel_valueWithPointer_, - pointer, - ); - return objc.NSValue.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_getValue_ = objc.registerName("getValue:"); -final _objc_msgSend_ovsamd = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// NSDeprecated -extension NSDeprecated$2 on objc.NSValue { - /// getValue: - void getValue$1(ffi.Pointer value) { - objc.checkOsVersionInternal( - 'NSValue.getValue:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_ovsamd(object$.ref.pointer, _sel_getValue_, value); - } -} - -typedef NSRange = objc.NSRange; -typedef NSRangePointer = ffi.Pointer; -late final _sel_valueWithRange_ = objc.registerName("valueWithRange:"); -final _objc_msgSend_1k1o1s7 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - objc.NSRange, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - objc.NSRange, - ) - >(); -late final _sel_rangeValue = objc.registerName("rangeValue"); -final _objc_msgSend_1u11dbb = objc.msgSendPointer - .cast< - ffi.NativeFunction< - objc.NSRange Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - objc.NSRange Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -final _objc_msgSend_1u11dbbStret = objc.msgSendStretPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// NSValueRangeExtensions -extension NSValueRangeExtensions on objc.NSValue { - /// rangeValue - NSRange get rangeValue { - final $ptr = pkg_ffi.calloc(); - objc.useMsgSendVariants - ? _objc_msgSend_1u11dbbStret($ptr, object$.ref.pointer, _sel_rangeValue) - : $ptr.ref = _objc_msgSend_1u11dbb( - object$.ref.pointer, - _sel_rangeValue, - ); - final $finalizable = $ptr.cast().asTypedList( - ffi.sizeOf(), - finalizer: pkg_ffi.calloc.nativeFree, - ); - return ffi.Struct.create($finalizable); - } - - /// valueWithRange: - static objc.NSValue valueWithRange(NSRange range) { - final $ret = _objc_msgSend_1k1o1s7( - _class_NSValue, - _sel_valueWithRange_, - range, - ); - return objc.NSValue.fromPointer($ret, retain: true, release: true); - } -} - -late final _class_NSArray = objc.getClass("NSArray"); -late final _sel_array = objc.registerName("array"); -late final _sel_arrayWithObject_ = objc.registerName("arrayWithObject:"); -late final _sel_arrayWithObjects_count_ = objc.registerName( - "arrayWithObjects:count:", -); -final _objc_msgSend_zmbtbd = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - int, - ) - >(); -late final _sel_arrayWithObjects_ = objc.registerName("arrayWithObjects:"); -late final _sel_arrayWithArray_ = objc.registerName("arrayWithArray:"); -late final _sel_initWithObjects_ = objc.registerName("initWithObjects:"); -late final _sel_initWithArray_ = objc.registerName("initWithArray:"); -late final _sel_initWithArray_copyItems_ = objc.registerName( - "initWithArray:copyItems:", -); -late final _sel_arrayWithContentsOfURL_error_ = objc.registerName( - "arrayWithContentsOfURL:error:", -); - -/// NSArrayCreation -extension NSArrayCreation on objc.NSArray { - /// initWithArray: - objc.NSArray initWithArray(objc.NSArray array) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithArray_, - array.ref.pointer, - ); - return objc.NSArray.fromPointer($ret, retain: false, release: true); - } - - /// initWithArray:copyItems: - objc.NSArray initWithArray$1(objc.NSArray array, {required bool copyItems}) { - final $ret = _objc_msgSend_17amj0z( - object$.ref.retainAndReturnPointer(), - _sel_initWithArray_copyItems_, - array.ref.pointer, - copyItems, - ); - return objc.NSArray.fromPointer($ret, retain: false, release: true); - } - - /// initWithContentsOfURL:error: - objc.NSArray? initWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSArray.initWithContentsOfURL:error:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1lhpu4m( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfURL_error_, - url.ref.pointer, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: false, release: true); - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// initWithObjects: - objc.NSArray initWithObjects$1(objc.ObjCObject firstObj) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithObjects_, - firstObj.ref.pointer, - ); - return objc.NSArray.fromPointer($ret, retain: false, release: true); - } - - /// array - static objc.NSArray array() { - final $ret = _objc_msgSend_151sglz(_class_NSArray, _sel_array); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// arrayWithArray: - static objc.NSArray arrayWithArray(objc.NSArray array) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSArray, - _sel_arrayWithArray_, - array.ref.pointer, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// arrayWithContentsOfURL:error: - static objc.NSArray? arrayWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSArray.arrayWithContentsOfURL:error:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1lhpu4m( - _class_NSArray, - _sel_arrayWithContentsOfURL_error_, - url.ref.pointer, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: true, release: true); - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// arrayWithObject: - static objc.NSArray arrayWithObject(objc.ObjCObject anObject) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSArray, - _sel_arrayWithObject_, - anObject.ref.pointer, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// arrayWithObjects: - static objc.NSArray arrayWithObjects(objc.ObjCObject firstObj) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSArray, - _sel_arrayWithObjects_, - firstObj.ref.pointer, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// arrayWithObjects:count: - static objc.NSArray arrayWithObjects$1( - ffi.Pointer> objects, { - required DartNSUInteger count, - }) { - final $ret = _objc_msgSend_zmbtbd( - _class_NSArray, - _sel_arrayWithObjects_count_, - objects, - count, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } -} - -/// Construction methods for `objc.ObjCBlock, ffi.Pointer)>`. -abstract final class ObjCBlock_bool_objcObjCObjectImpl_objcObjCObjectImpl { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - > - fromFunction( - bool Function(objc.ObjCObject, objc.ObjCObject) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - objc.ObjCObject(arg0, retain: true, release: true), - objc.ObjCObject(arg1, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static bool _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline, false) - .cast(); - static bool _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as bool Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline, false) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, ffi.Pointer)>`. -extension ObjCBlock_bool_objcObjCObjectImpl_objcObjCObjectImpl$CallExtension - on - objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - > { - bool call(objc.ObjCObject arg0, objc.ObjCObject arg1) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer); -} - -late final _sel_differenceFromArray_withOptions_usingEquivalenceTest_ = objc - .registerName("differenceFromArray:withOptions:usingEquivalenceTest:"); -final _objc_msgSend_1415lvo = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); -late final _sel_differenceFromArray_withOptions_ = objc.registerName( - "differenceFromArray:withOptions:", -); -final _objc_msgSend_1wtpmu7 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSUInteger, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_differenceFromArray_ = objc.registerName( - "differenceFromArray:", -); -late final _sel_arrayByApplyingDifference_ = objc.registerName( - "arrayByApplyingDifference:", -); - -/// NSArrayDiffing -extension NSArrayDiffing on objc.NSArray { - /// arrayByApplyingDifference: - objc.NSArray? arrayByApplyingDifference( - objc.NSOrderedCollectionDifference difference, - ) { - objc.checkOsVersionInternal( - 'NSArray.arrayByApplyingDifference:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_arrayByApplyingDifference_, - difference.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// differenceFromArray: - objc.NSOrderedCollectionDifference differenceFromArray(objc.NSArray other) { - objc.checkOsVersionInternal( - 'NSArray.differenceFromArray:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_differenceFromArray_, - other.ref.pointer, - ); - return objc.NSOrderedCollectionDifference.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// differenceFromArray:withOptions: - objc.NSOrderedCollectionDifference differenceFromArray$1( - objc.NSArray other, { - required DartNSUInteger withOptions, - }) { - objc.checkOsVersionInternal( - 'NSArray.differenceFromArray:withOptions:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1wtpmu7( - object$.ref.pointer, - _sel_differenceFromArray_withOptions_, - other.ref.pointer, - withOptions, - ); - return objc.NSOrderedCollectionDifference.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// differenceFromArray:withOptions:usingEquivalenceTest: - objc.NSOrderedCollectionDifference differenceFromArray$2( - objc.NSArray other, { - required DartNSUInteger withOptions, - required objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ) - > - usingEquivalenceTest, - }) { - objc.checkOsVersionInternal( - 'NSArray.differenceFromArray:withOptions:usingEquivalenceTest:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - final $ret = _objc_msgSend_1415lvo( - object$.ref.pointer, - _sel_differenceFromArray_withOptions_usingEquivalenceTest_, - other.ref.pointer, - withOptions, - usingEquivalenceTest.ref.pointer, - ); - return objc.NSOrderedCollectionDifference.fromPointer( - $ret, - retain: true, - release: true, - ); - } -} - -late final _sel_getObjects_ = objc.registerName("getObjects:"); -final _objc_msgSend_1dau4w = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >(); -late final _sel_arrayWithContentsOfFile_ = objc.registerName( - "arrayWithContentsOfFile:", -); -late final _sel_arrayWithContentsOfURL_ = objc.registerName( - "arrayWithContentsOfURL:", -); - -/// NSDeprecated -extension NSDeprecated$1 on objc.NSArray { - /// getObjects: - void getObjects(ffi.Pointer> objects) { - objc.checkOsVersionInternal( - 'NSArray.getObjects:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_1dau4w(object$.ref.pointer, _sel_getObjects_, objects); - } - - /// initWithContentsOfFile: - objc.NSArray? initWithContentsOfFile(objc.NSString path) { - objc.checkOsVersionInternal( - 'NSArray.initWithContentsOfFile:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: false, release: true); - } - - /// initWithContentsOfURL: - objc.NSArray? initWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSArray.initWithContentsOfURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: false, release: true); - } - - /// writeToFile:atomically: - bool writeToFile(objc.NSString path, {required bool atomically}) { - objc.checkOsVersionInternal( - 'NSArray.writeToFile:atomically:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1iyq28l( - object$.ref.pointer, - _sel_writeToFile_atomically_, - path.ref.pointer, - atomically, - ); - } - - /// writeToURL:atomically: - bool writeToURL(objc.NSURL url, {required bool atomically}) { - objc.checkOsVersionInternal( - 'NSArray.writeToURL:atomically:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1iyq28l( - object$.ref.pointer, - _sel_writeToURL_atomically_, - url.ref.pointer, - atomically, - ); - } - - /// arrayWithContentsOfFile: - static objc.NSArray? arrayWithContentsOfFile(objc.NSString path) { - objc.checkOsVersionInternal( - 'NSArray.arrayWithContentsOfFile:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSArray, - _sel_arrayWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// arrayWithContentsOfURL: - static objc.NSArray? arrayWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSArray.arrayWithContentsOfURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSArray, - _sel_arrayWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: true, release: true); - } -} - -late final _class_NSMutableArray = objc.getClass("NSMutableArray"); -late final _sel_arrayWithCapacity_ = objc.registerName("arrayWithCapacity:"); - -/// NSMutableArrayCreation -extension NSMutableArrayCreation on objc.NSMutableArray { - /// initWithContentsOfFile: - objc.NSMutableArray? initWithContentsOfFile(objc.NSString path) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSMutableArray.fromPointer($ret, retain: false, release: true); - } - - /// initWithContentsOfURL: - objc.NSMutableArray? initWithContentsOfURL(objc.NSURL url) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSMutableArray.fromPointer($ret, retain: false, release: true); - } - - /// arrayWithCapacity: - static objc.NSMutableArray arrayWithCapacity(DartNSUInteger numItems) { - final $ret = _objc_msgSend_14hpxwa( - _class_NSMutableArray, - _sel_arrayWithCapacity_, - numItems, - ); - return objc.NSMutableArray.fromPointer($ret, retain: true, release: true); - } - - /// arrayWithContentsOfFile: - static objc.NSMutableArray? arrayWithContentsOfFile(objc.NSString path) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSMutableArray, - _sel_arrayWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSMutableArray.fromPointer($ret, retain: true, release: true); - } - - /// arrayWithContentsOfURL: - static objc.NSMutableArray? arrayWithContentsOfURL(objc.NSURL url) { - final $ret = _objc_msgSend_1sotr3r( - _class_NSMutableArray, - _sel_arrayWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSMutableArray.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_applyDifference_ = objc.registerName("applyDifference:"); - -/// NSMutableArrayDiffing -extension NSMutableArrayDiffing on objc.NSMutableArray { - /// applyDifference: - void applyDifference(objc.NSOrderedCollectionDifference difference) { - objc.checkOsVersionInternal( - 'NSMutableArray.applyDifference:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_applyDifference_, - difference.ref.pointer, - ); - } -} - -/// Construction methods for `objc.ObjCBlock?, objc.NSError)>`. -abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - > - fromFunction( - void Function(objc.NSSecureCoding?, objc.NSError) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : objc.NSSecureCoding.fromPointer( - arg0, - retain: true, - release: true, - ), - objc.NSError.fromPointer(arg1, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - > - listener( - void Function(objc.NSSecureCoding?, objc.NSError) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : objc.NSSecureCoding.fromPointer( - arg0, - retain: false, - release: true, - ), - objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_pfv6jd(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - > - blocking( - void Function(objc.NSSecureCoding?, objc.NSError) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : objc.NSSecureCoding.fromPointer( - arg0, - retain: false, - release: true, - ), - objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : objc.NSSecureCoding.fromPointer( - arg0, - retain: false, - release: true, - ), - objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock?, objc.NSError)>`. -extension ObjCBlock_ffiVoid_idNSSecureCoding_NSError$CallExtension - on - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - > { - void call(objc.NSSecureCoding? arg0, objc.NSError arg1) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr, arg1.ref.pointer); -} - -typedef NSItemProviderCompletionHandler = ffi.Pointer; -typedef DartNSItemProviderCompletionHandler = - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >; - -/// Construction methods for `objc.ObjCBlock?, objc.NSError)>, ffi.Pointer, objc.NSDictionary)>`. -abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObjectImpl_NSDictionary { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - > - fromFunction( - void Function( - DartNSItemProviderCompletionHandler, - objc.ObjCObject, - objc.NSDictionary, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - ObjCBlock_ffiVoid_idNSSecureCoding_NSError.fromPointer( - arg0, - retain: true, - release: true, - ), - objc.ObjCObject(arg1, retain: true, release: true), - objc.NSDictionary.fromPointer(arg2, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - > - listener( - void Function( - DartNSItemProviderCompletionHandler, - objc.ObjCObject, - objc.NSDictionary, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - ObjCBlock_ffiVoid_idNSSecureCoding_NSError.fromPointer( - arg0, - retain: false, - release: true, - ), - objc.ObjCObject(arg1, retain: false, release: true), - objc.NSDictionary.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1b3bb6a(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - > - blocking( - void Function( - DartNSItemProviderCompletionHandler, - objc.ObjCObject, - objc.NSDictionary, - ) - fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - ObjCBlock_ffiVoid_idNSSecureCoding_NSError.fromPointer( - arg0, - retain: false, - release: true, - ), - objc.ObjCObject(arg1, retain: false, release: true), - objc.NSDictionary.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => fn( - ObjCBlock_ffiVoid_idNSSecureCoding_NSError.fromPointer( - arg0, - retain: false, - release: true, - ), - objc.ObjCObject(arg1, retain: false, release: true), - objc.NSDictionary.fromPointer(arg2, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1b3bb6a( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock?, objc.NSError)>, ffi.Pointer, objc.NSDictionary)>`. -extension ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObjectImpl_NSDictionary$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - > { - void call( - DartNSItemProviderCompletionHandler arg0, - objc.ObjCObject arg1, - objc.NSDictionary arg2, - ) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - NSItemProviderCompletionHandler arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - NSItemProviderCompletionHandler, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2.ref.pointer); -} - -typedef NSItemProviderLoadHandler = ffi.Pointer; -typedef DartNSItemProviderLoadHandler = - objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, objc.NSError) - >, - ffi.Pointer, - objc.NSDictionary, - ) - >; -late final _class_NSItemProvider = objc.getClass("NSItemProvider"); -late final _sel_previewImageHandler = objc.registerName("previewImageHandler"); -final _objc_msgSend_uwvaik = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_setPreviewImageHandler_ = objc.registerName( - "setPreviewImageHandler:", -); -late final _sel_loadPreviewImageWithOptions_completionHandler_ = objc - .registerName("loadPreviewImageWithOptions:completionHandler:"); - -/// NSPreviewSupport -extension NSPreviewSupport on objc.NSItemProvider { - /// loadPreviewImageWithOptions:completionHandler: - void loadPreviewImageWithOptions( - objc.NSDictionary options, { - required DartNSItemProviderCompletionHandler completionHandler, - }) { - objc.checkOsVersionInternal( - 'NSItemProvider.loadPreviewImageWithOptions:completionHandler:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_o762yo( - object$.ref.pointer, - _sel_loadPreviewImageWithOptions_completionHandler_, - options.ref.pointer, - completionHandler.ref.pointer, - ); - } - - /// previewImageHandler - DartNSItemProviderLoadHandler? get previewImageHandler { - objc.checkOsVersionInternal( - 'NSItemProvider.previewImageHandler', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - final $ret = _objc_msgSend_uwvaik( - object$.ref.pointer, - _sel_previewImageHandler, - ); - return $ret.address == 0 - ? null - : ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObjectImpl_NSDictionary.fromPointer( - $ret, - retain: true, - release: true, - ); - } - - /// setPreviewImageHandler: - set previewImageHandler(DartNSItemProviderLoadHandler? value) { - objc.checkOsVersionInternal( - 'NSItemProvider.setPreviewImageHandler:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_setPreviewImageHandler_, - value?.ref.pointer ?? ffi.nullptr, - ); - } -} - -typedef NSStringEncoding = NSUInteger; -typedef NSStringTransform = ffi.Pointer; -typedef DartNSStringTransform = objc.NSString; -typedef NSStringEncodingDetectionOptionsKey = ffi.Pointer; -typedef DartNSStringEncodingDetectionOptionsKey = objc.NSString; -late final _class_NSString = objc.getClass("NSString"); -late final _sel_stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_ = - objc.registerName( - "stringEncodingForData:encodingOptions:convertedString:usedLossyConversion:", - ); -final _objc_msgSend_1q2ox4r = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ) - >(); - -/// NSStringEncodingDetection -extension NSStringEncodingDetection on objc.NSString { - /// stringEncodingForData:encodingOptions:convertedString:usedLossyConversion: - static DartNSUInteger stringEncodingForData( - objc.NSData data, { - objc.NSDictionary? encodingOptions, - required ffi.Pointer> convertedString, - required ffi.Pointer usedLossyConversion, - }) { - objc.checkOsVersionInternal( - 'NSString.stringEncodingForData:encodingOptions:convertedString:usedLossyConversion:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - return _objc_msgSend_1q2ox4r( - _class_NSString, - _sel_stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_, - data.ref.pointer, - encodingOptions?.ref.pointer ?? ffi.nullptr, - convertedString, - usedLossyConversion, - ); - } -} - -late final _sel_readableTypeIdentifiersForItemProvider = objc.registerName( - "readableTypeIdentifiersForItemProvider", -); - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_NSArray_ffiVoid { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock)> - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer arg0) - > - > - ptr, - ) => objc.ObjCBlock)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock)> - fromFunction( - objc.NSArray Function(ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock)>( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn(arg0).ref.retainAndAutorelease(), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static ffi.Pointer _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer arg0) - > - >() - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static ffi.Pointer _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => - (objc.getBlockClosure(block) - as ffi.Pointer Function(ffi.Pointer))( - arg0, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_NSArray_ffiVoid$CallExtension - on objc.ObjCBlock)> { - objc.NSArray call(ffi.Pointer arg0) => objc.NSArray.fromPointer( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0), - retain: true, - release: true, - ); -} - -late final _sel_objectWithItemProviderData_typeIdentifier_error_ = objc - .registerName("objectWithItemProviderData:typeIdentifier:error:"); -final _objc_msgSend_1pnyuds = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >(); - -/// Construction methods for `objc.ObjCBlock? Function(ffi.Pointer, objc.NSData, objc.NSString, ffi.Pointer>)>`. -abstract final class ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Pointer? Function( - ffi.Pointer, - objc.NSData, - objc.NSString, - ffi.Pointer>, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Pointer? Function( - ffi.Pointer, - objc.NSData, - objc.NSString, - ffi.Pointer>, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Pointer? Function( - ffi.Pointer, - objc.NSData, - objc.NSString, - ffi.Pointer>, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Pointer? Function( - ffi.Pointer, - objc.NSData, - objc.NSString, - ffi.Pointer>, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Pointer? Function( - ffi.Pointer, - objc.NSData, - objc.NSString, - ffi.Pointer>, - ) - > - fromFunction( - Dartinstancetype? Function( - ffi.Pointer, - objc.NSData, - objc.NSString, - ffi.Pointer>, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Pointer? Function( - ffi.Pointer, - objc.NSData, - objc.NSString, - ffi.Pointer>, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3, - ) => - fn( - arg0, - objc.NSData.fromPointer(arg1, retain: true, release: true), - objc.NSString.fromPointer(arg2, retain: true, release: true), - arg3, - )?.ref.retainAndAutorelease() ?? - ffi.nullptr, - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static instancetype _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3, - ) => block.ref.target - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3, - ) - > - >() - .asFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >()(arg0, arg1, arg2, arg3); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >(_fnPtrTrampoline) - .cast(); - static instancetype _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3, - ) => - (objc.getBlockClosure(block) - as instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ))(arg0, arg1, arg2, arg3); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock? Function(ffi.Pointer, objc.NSData, objc.NSString, ffi.Pointer>)>`. -extension ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError$CallExtension - on - objc.ObjCBlock< - ffi.Pointer? Function( - ffi.Pointer, - objc.NSData, - objc.NSString, - ffi.Pointer>, - ) - > { - Dartinstancetype? call( - ffi.Pointer arg0, - objc.NSData arg1, - objc.NSString arg2, - ffi.Pointer> arg3, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3, - ) - > - >() - .asFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer, arg3) - .address == - 0 - ? null - : objc.ObjCObject( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3, - ) - > - >() - .asFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer, arg3), - retain: true, - release: true, - ); -} - -late final _sel_writableTypeIdentifiersForItemProvider = objc.registerName( - "writableTypeIdentifiersForItemProvider", -); -late final _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_ = - objc.registerName( - "itemProviderVisibilityForRepresentationWithTypeIdentifier:", - ); -final _objc_msgSend_16fy0up = objc.msgSendPointer - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, objc.NSString)>`. -abstract final class ObjCBlock_NSItemProviderRepresentationVisibility_ffiVoid_NSString { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - NSInteger Function(ffi.Pointer, objc.NSString) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock, objc.NSString)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - NSInteger Function(ffi.Pointer, objc.NSString) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => objc.ObjCBlock, objc.NSString)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - NSInteger Function(ffi.Pointer, objc.NSString) - > - fromFunction( - objc.NSItemProviderRepresentationVisibility Function( - ffi.Pointer, - objc.NSString, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock, objc.NSString)>( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn( - arg0, - objc.NSString.fromPointer(arg1, retain: true, release: true), - ).value, - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static int _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - int Function(ffi.Pointer, ffi.Pointer) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline, 0) - .cast(); - static int _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as int Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - NSInteger Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline, 0) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, objc.NSString)>`. -extension ObjCBlock_NSItemProviderRepresentationVisibility_ffiVoid_NSString$CallExtension - on - objc.ObjCBlock< - NSInteger Function(ffi.Pointer, objc.NSString) - > { - objc.NSItemProviderRepresentationVisibility call( - ffi.Pointer arg0, - objc.NSString arg1, - ) => objc.NSItemProviderRepresentationVisibility.fromValue( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - NSInteger Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer), - ); -} - -/// Construction methods for `objc.ObjCBlock`. -abstract final class ObjCBlock_ffiVoid_NSData_NSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - > - ptr, - ) => objc.ObjCBlock( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - fromFunction( - void Function(objc.NSData?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: true, release: true), - arg1.address == 0 - ? null - : objc.NSError.fromPointer(arg1, retain: true, release: true), - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock - listener( - void Function(objc.NSData?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_pfv6jd(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock - blocking( - void Function(objc.NSData?, objc.NSError?) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - arg1.address == 0 - ? null - : objc.NSError.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock`. -extension ObjCBlock_ffiVoid_NSData_NSError$CallExtension - on objc.ObjCBlock { - void call(objc.NSData? arg0, objc.NSError? arg1) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0?.ref.pointer ?? ffi.nullptr, - arg1?.ref.pointer ?? ffi.nullptr, - ); -} - -late final _sel_loadDataWithTypeIdentifier_forItemProviderCompletionHandler_ = - objc.registerName( - "loadDataWithTypeIdentifier:forItemProviderCompletionHandler:", - ); - -/// Construction methods for `objc.ObjCBlock, objc.NSString, objc.ObjCBlock)>`. -abstract final class ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - objc.NSProgress? Function( - ffi.Pointer, - objc.NSString, - objc.ObjCBlock, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - objc.NSProgress? Function( - ffi.Pointer, - objc.NSString, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - objc.NSProgress? Function( - ffi.Pointer, - objc.NSString, - objc.ObjCBlock, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - objc.NSProgress? Function( - ffi.Pointer, - objc.NSString, - objc.ObjCBlock, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - objc.NSProgress? Function( - ffi.Pointer, - objc.NSString, - objc.ObjCBlock, - ) - > - fromFunction( - objc.NSProgress? Function( - ffi.Pointer, - objc.NSString, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - objc.NSProgress? Function( - ffi.Pointer, - objc.NSString, - objc.ObjCBlock, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => - fn( - arg0, - objc.NSString.fromPointer(arg1, retain: true, release: true), - ObjCBlock_ffiVoid_NSData_NSError.fromPointer( - arg2, - retain: true, - release: true, - ), - )?.ref.retainAndAutorelease() ?? - ffi.nullptr, - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - static ffi.Pointer _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static ffi.Pointer _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) => - (objc.getBlockClosure(block) - as ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, objc.NSString, objc.ObjCBlock)>`. -extension ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError$CallExtension - on - objc.ObjCBlock< - objc.NSProgress? Function( - ffi.Pointer, - objc.NSString, - objc.ObjCBlock, - ) - > { - objc.NSProgress? call( - ffi.Pointer arg0, - objc.NSString arg1, - objc.ObjCBlock arg2, - ) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer) - .address == - 0 - ? null - : objc.NSProgress.fromPointer( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer), - retain: true, - release: true, - ); -} - -/// NSItemProvider -extension NSItemProvider$1 on objc.NSString { - /// itemProviderVisibilityForRepresentationWithTypeIdentifier: - objc.NSItemProviderRepresentationVisibility - itemProviderVisibilityForRepresentationWithTypeIdentifier( - objc.NSString typeIdentifier, - ) { - objc.checkOsVersionInternal( - 'NSString.itemProviderVisibilityForRepresentationWithTypeIdentifier:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSString', - 'itemProviderVisibilityForRepresentationWithTypeIdentifier:', - ); - } - final $ret = _objc_msgSend_16fy0up( - object$.ref.pointer, - _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_, - typeIdentifier.ref.pointer, - ); - return objc.NSItemProviderRepresentationVisibility.fromValue($ret); - } - - /// loadDataWithTypeIdentifier:forItemProviderCompletionHandler: - objc.NSProgress? loadDataWithTypeIdentifier( - objc.NSString typeIdentifier, { - required objc.ObjCBlock - forItemProviderCompletionHandler, - }) { - objc.checkOsVersionInternal( - 'NSString.loadDataWithTypeIdentifier:forItemProviderCompletionHandler:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $ret = _objc_msgSend_r0bo0s( - object$.ref.pointer, - _sel_loadDataWithTypeIdentifier_forItemProviderCompletionHandler_, - typeIdentifier.ref.pointer, - forItemProviderCompletionHandler.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSProgress.fromPointer($ret, retain: true, release: true); - } - - /// writableTypeIdentifiersForItemProvider - objc.NSArray get writableTypeIdentifiersForItemProvider { - objc.checkOsVersionInternal( - 'NSString.writableTypeIdentifiersForItemProvider', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_writableTypeIdentifiersForItemProvider, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSString', - 'writableTypeIdentifiersForItemProvider', - ); - } - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_writableTypeIdentifiersForItemProvider, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// itemProviderVisibilityForRepresentationWithTypeIdentifier: - static objc.NSItemProviderRepresentationVisibility - itemProviderVisibilityForRepresentationWithTypeIdentifier$1( - objc.NSString typeIdentifier, - ) { - objc.checkOsVersionInternal( - 'NSString.itemProviderVisibilityForRepresentationWithTypeIdentifier:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - _class_NSString, - _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSString', - 'itemProviderVisibilityForRepresentationWithTypeIdentifier:', - ); - } - final $ret = _objc_msgSend_16fy0up( - _class_NSString, - _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_, - typeIdentifier.ref.pointer, - ); - return objc.NSItemProviderRepresentationVisibility.fromValue($ret); - } - - /// objectWithItemProviderData:typeIdentifier:error: - static objc.NSString? objectWithItemProviderData( - objc.NSData data, { - required objc.NSString typeIdentifier, - }) { - objc.checkOsVersionInternal( - 'NSString.objectWithItemProviderData:typeIdentifier:error:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1pnyuds( - _class_NSString, - _sel_objectWithItemProviderData_typeIdentifier_error_, - data.ref.pointer, - typeIdentifier.ref.pointer, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// readableTypeIdentifiersForItemProvider - static objc.NSArray getReadableTypeIdentifiersForItemProvider() { - objc.checkOsVersionInternal( - 'NSString.readableTypeIdentifiersForItemProvider', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSString, - _sel_readableTypeIdentifiersForItemProvider, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// writableTypeIdentifiersForItemProvider - static objc.NSArray getWritableTypeIdentifiersForItemProvider$1() { - objc.checkOsVersionInternal( - 'NSString.writableTypeIdentifiersForItemProvider', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSString, - _sel_writableTypeIdentifiersForItemProvider, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } -} - -late final _class_NSMutableString = objc.getClass("NSMutableString"); -late final _sel_insertString_atIndex_ = objc.registerName( - "insertString:atIndex:", -); -final _objc_msgSend_djsa9o = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_deleteCharactersInRange_ = objc.registerName( - "deleteCharactersInRange:", -); -final _objc_msgSend_1e3pm0z = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - objc.NSRange, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - objc.NSRange, - ) - >(); -late final _sel_appendString_ = objc.registerName("appendString:"); -late final _sel_appendFormat_ = objc.registerName("appendFormat:"); -late final _sel_setString_ = objc.registerName("setString:"); -late final _sel_replaceOccurrencesOfString_withString_options_range_ = objc - .registerName("replaceOccurrencesOfString:withString:options:range:"); -final _objc_msgSend_1upeo1d = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - NSUInteger, - objc.NSRange, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - objc.NSRange, - ) - >(); -late final _sel_applyTransform_reverse_range_updatedRange_ = objc.registerName( - "applyTransform:reverse:range:updatedRange:", -); -final _objc_msgSend_zy00wz = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - objc.NSRange, - ffi.Pointer, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - bool, - objc.NSRange, - ffi.Pointer, - ) - >(); -late final _sel_initWithCapacity_ = objc.registerName("initWithCapacity:"); -late final _sel_stringWithCapacity_ = objc.registerName("stringWithCapacity:"); - -/// NSMutableStringExtensionMethods -extension NSMutableStringExtensionMethods on objc.NSMutableString { - /// appendFormat: - void appendFormat(objc.NSString format) { - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_appendFormat_, - format.ref.pointer, - ); - } - - /// appendString: - void appendString(objc.NSString aString) { - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_appendString_, - aString.ref.pointer, - ); - } - - /// applyTransform:reverse:range:updatedRange: - bool applyTransform( - DartNSStringTransform transform, { - required bool reverse, - required NSRange range, - required NSRangePointer updatedRange, - }) { - objc.checkOsVersionInternal( - 'NSMutableString.applyTransform:reverse:range:updatedRange:', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), - ); - return _objc_msgSend_zy00wz( - object$.ref.pointer, - _sel_applyTransform_reverse_range_updatedRange_, - transform.ref.pointer, - reverse, - range, - updatedRange, - ); - } - - /// deleteCharactersInRange: - void deleteCharactersInRange(NSRange range) { - _objc_msgSend_1e3pm0z( - object$.ref.pointer, - _sel_deleteCharactersInRange_, - range, - ); - } - - /// initWithCapacity: - objc.NSMutableString initWithCapacity(DartNSUInteger capacity) { - final $ret = _objc_msgSend_14hpxwa( - object$.ref.retainAndReturnPointer(), - _sel_initWithCapacity_, - capacity, - ); - return objc.NSMutableString.fromPointer($ret, retain: false, release: true); - } - - /// insertString:atIndex: - void insertString(objc.NSString aString, {required DartNSUInteger atIndex}) { - _objc_msgSend_djsa9o( - object$.ref.pointer, - _sel_insertString_atIndex_, - aString.ref.pointer, - atIndex, - ); - } - - /// replaceOccurrencesOfString:withString:options:range: - DartNSUInteger replaceOccurrencesOfString( - objc.NSString target, { - required objc.NSString withString, - required DartNSUInteger options, - required NSRange range, - }) { - return _objc_msgSend_1upeo1d( - object$.ref.pointer, - _sel_replaceOccurrencesOfString_withString_options_range_, - target.ref.pointer, - withString.ref.pointer, - options, - range, - ); - } - - /// setString: - void setString(objc.NSString aString) { - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setString_, - aString.ref.pointer, - ); - } - - /// stringWithCapacity: - static objc.NSMutableString stringWithCapacity(DartNSUInteger capacity) { - final $ret = _objc_msgSend_14hpxwa( - _class_NSMutableString, - _sel_stringWithCapacity_, - capacity, - ); - return objc.NSMutableString.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_propertyList = objc.registerName("propertyList"); -late final _sel_propertyListFromStringsFileFormat = objc.registerName( - "propertyListFromStringsFileFormat", -); - -/// NSExtendedStringPropertyListParsing -extension NSExtendedStringPropertyListParsing on objc.NSString { - /// propertyList - objc.ObjCObject propertyList() { - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_propertyList); - return objc.ObjCObject($ret, retain: true, release: true); - } - - /// propertyListFromStringsFileFormat - objc.NSDictionary? propertyListFromStringsFileFormat() { - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_propertyListFromStringsFileFormat, - ); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_cString = objc.registerName("cString"); -final _objc_msgSend_1fuqfwb = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_lossyCString = objc.registerName("lossyCString"); -late final _sel_cStringLength = objc.registerName("cStringLength"); -late final _sel_getCString_ = objc.registerName("getCString:"); -final _objc_msgSend_1r7ue5f = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_getCString_maxLength_ = objc.registerName( - "getCString:maxLength:", -); -final _objc_msgSend_1h3mito = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_getCString_maxLength_range_remainingRange_ = objc.registerName( - "getCString:maxLength:range:remainingRange:", -); -final _objc_msgSend_3gpdva = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - objc.NSRange, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - objc.NSRange, - ffi.Pointer, - ) - >(); -late final _sel_stringWithContentsOfFile_ = objc.registerName( - "stringWithContentsOfFile:", -); -late final _sel_stringWithContentsOfURL_ = objc.registerName( - "stringWithContentsOfURL:", -); -late final _sel_initWithCStringNoCopy_length_freeWhenDone_ = objc.registerName( - "initWithCStringNoCopy:length:freeWhenDone:", -); -final _objc_msgSend_1ojrli4 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Bool, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - bool, - ) - >(); -late final _sel_initWithCString_length_ = objc.registerName( - "initWithCString:length:", -); -final _objc_msgSend_erqryg = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -late final _sel_initWithCString_ = objc.registerName("initWithCString:"); -final _objc_msgSend_56zxyn = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_stringWithCString_length_ = objc.registerName( - "stringWithCString:length:", -); -late final _sel_stringWithCString_ = objc.registerName("stringWithCString:"); -late final _sel_getCharacters_ = objc.registerName("getCharacters:"); -final _objc_msgSend_g3kdhc = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - -/// NSStringDeprecated -extension NSStringDeprecated on objc.NSString { - /// cString - ffi.Pointer cString() { - objc.checkOsVersionInternal( - 'NSString.cString', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1fuqfwb(object$.ref.pointer, _sel_cString); - } - - /// cStringLength - DartNSUInteger cStringLength() { - objc.checkOsVersionInternal( - 'NSString.cStringLength', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_cStringLength); - } - - /// getCString: - void getCString(ffi.Pointer bytes) { - objc.checkOsVersionInternal( - 'NSString.getCString:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_1r7ue5f(object$.ref.pointer, _sel_getCString_, bytes); - } - - /// getCString:maxLength: - void getCString$1( - ffi.Pointer bytes, { - required DartNSUInteger maxLength, - }) { - objc.checkOsVersionInternal( - 'NSString.getCString:maxLength:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_1h3mito( - object$.ref.pointer, - _sel_getCString_maxLength_, - bytes, - maxLength, - ); - } - - /// getCString:maxLength:range:remainingRange: - void getCString$2( - ffi.Pointer bytes, { - required DartNSUInteger maxLength, - required NSRange range, - required NSRangePointer remainingRange, - }) { - objc.checkOsVersionInternal( - 'NSString.getCString:maxLength:range:remainingRange:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_3gpdva( - object$.ref.pointer, - _sel_getCString_maxLength_range_remainingRange_, - bytes, - maxLength, - range, - remainingRange, - ); - } - - /// getCharacters: - void getCharacters(ffi.Pointer buffer) { - _objc_msgSend_g3kdhc(object$.ref.pointer, _sel_getCharacters_, buffer); - } - - /// initWithCString: - objc.ObjCObject? initWithCString(ffi.Pointer bytes) { - objc.checkOsVersionInternal( - 'NSString.initWithCString:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_56zxyn( - object$.ref.retainAndReturnPointer(), - _sel_initWithCString_, - bytes, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: false, release: true); - } - - /// initWithCString:length: - objc.ObjCObject? initWithCString$1( - ffi.Pointer bytes, { - required DartNSUInteger length, - }) { - objc.checkOsVersionInternal( - 'NSString.initWithCString:length:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_erqryg( - object$.ref.retainAndReturnPointer(), - _sel_initWithCString_length_, - bytes, - length, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: false, release: true); - } - - /// initWithCStringNoCopy:length:freeWhenDone: - objc.ObjCObject? initWithCStringNoCopy( - ffi.Pointer bytes, { - required DartNSUInteger length, - required bool freeWhenDone, - }) { - objc.checkOsVersionInternal( - 'NSString.initWithCStringNoCopy:length:freeWhenDone:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1ojrli4( - object$.ref.retainAndReturnPointer(), - _sel_initWithCStringNoCopy_length_freeWhenDone_, - bytes, - length, - freeWhenDone, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: false, release: true); - } - - /// initWithContentsOfFile: - objc.ObjCObject? initWithContentsOfFile(objc.NSString path) { - objc.checkOsVersionInternal( - 'NSString.initWithContentsOfFile:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: false, release: true); - } - - /// initWithContentsOfURL: - objc.ObjCObject? initWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSString.initWithContentsOfURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: false, release: true); - } - - /// lossyCString - ffi.Pointer lossyCString() { - objc.checkOsVersionInternal( - 'NSString.lossyCString', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1fuqfwb(object$.ref.pointer, _sel_lossyCString); - } - - /// writeToFile:atomically: - bool writeToFile(objc.NSString path, {required bool atomically}) { - objc.checkOsVersionInternal( - 'NSString.writeToFile:atomically:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1iyq28l( - object$.ref.pointer, - _sel_writeToFile_atomically_, - path.ref.pointer, - atomically, - ); - } - - /// writeToURL:atomically: - bool writeToURL(objc.NSURL url, {required bool atomically}) { - objc.checkOsVersionInternal( - 'NSString.writeToURL:atomically:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1iyq28l( - object$.ref.pointer, - _sel_writeToURL_atomically_, - url.ref.pointer, - atomically, - ); - } - - /// stringWithCString: - static objc.ObjCObject? stringWithCString(ffi.Pointer bytes) { - objc.checkOsVersionInternal( - 'NSString.stringWithCString:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_56zxyn( - _class_NSString, - _sel_stringWithCString_, - bytes, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: true, release: true); - } - - /// stringWithCString:length: - static objc.ObjCObject? stringWithCString$1( - ffi.Pointer bytes, { - required DartNSUInteger length, - }) { - objc.checkOsVersionInternal( - 'NSString.stringWithCString:length:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_erqryg( - _class_NSString, - _sel_stringWithCString_length_, - bytes, - length, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: true, release: true); - } - - /// stringWithContentsOfFile: - static objc.ObjCObject? stringWithContentsOfFile(objc.NSString path) { - objc.checkOsVersionInternal( - 'NSString.stringWithContentsOfFile:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSString, - _sel_stringWithContentsOfFile_, - path.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: true, release: true); - } - - /// stringWithContentsOfURL: - static objc.ObjCObject? stringWithContentsOfURL(objc.NSURL url) { - objc.checkOsVersionInternal( - 'NSString.stringWithContentsOfURL:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSString, - _sel_stringWithContentsOfURL_, - url.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: true, release: true); - } -} - -typedef NSURLResourceKey = ffi.Pointer; -typedef DartNSURLResourceKey = objc.NSString; -typedef NSURLFileResourceType = ffi.Pointer; -typedef DartNSURLFileResourceType = objc.NSString; -typedef NSURLThumbnailDictionaryItem = ffi.Pointer; -typedef DartNSURLThumbnailDictionaryItem = objc.NSString; -typedef NSURLFileProtectionType = ffi.Pointer; -typedef DartNSURLFileProtectionType = objc.NSString; -typedef NSURLUbiquitousItemDownloadingStatus = ffi.Pointer; -typedef DartNSURLUbiquitousItemDownloadingStatus = objc.NSString; -typedef NSURLUbiquitousSharedItemRole = ffi.Pointer; -typedef DartNSURLUbiquitousSharedItemRole = objc.NSString; -typedef NSURLUbiquitousSharedItemPermissions = ffi.Pointer; -typedef DartNSURLUbiquitousSharedItemPermissions = objc.NSString; -typedef NSURLBookmarkFileCreationOptions = NSUInteger; -late final _class_NSURL = objc.getClass("NSURL"); -late final _sel_getPromisedItemResourceValue_forKey_error_ = objc.registerName( - "getPromisedItemResourceValue:forKey:error:", -); -final _objc_msgSend_1j9bhml = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer>, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer>, - ) - >(); -late final _sel_promisedItemResourceValuesForKeys_error_ = objc.registerName( - "promisedItemResourceValuesForKeys:error:", -); -late final _sel_checkPromisedItemIsReachableAndReturnError_ = objc.registerName( - "checkPromisedItemIsReachableAndReturnError:", -); -final _objc_msgSend_1dom33q = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >(); - -/// NSPromisedItems -extension NSPromisedItems on objc.NSURL { - /// checkPromisedItemIsReachableAndReturnError: - bool checkPromisedItemIsReachableAndReturnError() { - objc.checkOsVersionInternal( - 'NSURL.checkPromisedItemIsReachableAndReturnError:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1dom33q( - object$.ref.pointer, - _sel_checkPromisedItemIsReachableAndReturnError_, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret; - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// Get resource values from URLs of 'promised' items. A promised item is not guaranteed to have its contents in the file system until you use NSFileCoordinator to perform a coordinated read on its URL, which causes the contents to be downloaded or otherwise generated. Promised item URLs are returned by various APIs, including currently: - /// - NSMetadataQueryUbiquitousDataScope - /// - NSMetadataQueryUbiquitousDocumentsScope - /// - An NSFilePresenter presenting the contents of the directory located by -URLForUbiquitousContainerIdentifier: or a subdirectory thereof - /// - /// The following methods behave identically to their similarly named methods above (-getResourceValue:forKey:error:, etc.), except that they allow you to get resource values and check for presence regardless of whether the promised item's contents currently exist at the URL. You must use these APIs instead of the normal NSURL resource value APIs if and only if any of the following are true: - /// - You are using a URL that you know came directly from one of the above APIs - /// - You are inside the accessor block of a coordinated read or write that used NSFileCoordinatorReadingImmediatelyAvailableMetadataOnly, NSFileCoordinatorWritingForDeleting, NSFileCoordinatorWritingForMoving, or NSFileCoordinatorWritingContentIndependentMetadataOnly - /// - /// Most of the NSURL resource value keys will work with these APIs. However, there are some that are tied to the item's contents that will not work, such as NSURLContentAccessDateKey or NSURLGenerationIdentifierKey. If one of these keys is used, the method will return YES, but the value for the key will be nil. - bool getPromisedItemResourceValue( - ffi.Pointer> value, { - required DartNSURLResourceKey forKey, - }) { - objc.checkOsVersionInternal( - 'NSURL.getPromisedItemResourceValue:forKey:error:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1j9bhml( - object$.ref.pointer, - _sel_getPromisedItemResourceValue_forKey_error_, - value, - forKey.ref.pointer, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret; - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// promisedItemResourceValuesForKeys:error: - objc.NSDictionary? promisedItemResourceValuesForKeys(objc.NSArray keys) { - objc.checkOsVersionInternal( - 'NSURL.promisedItemResourceValuesForKeys:error:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1lhpu4m( - object$.ref.pointer, - _sel_promisedItemResourceValuesForKeys_error_, - keys.ref.pointer, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret.address == 0 - ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); - } finally { - pkg_ffi.calloc.free($err); - } - } -} - -/// NSItemProvider -extension NSItemProvider on objc.NSURL { - /// itemProviderVisibilityForRepresentationWithTypeIdentifier: - objc.NSItemProviderRepresentationVisibility - itemProviderVisibilityForRepresentationWithTypeIdentifier( - objc.NSString typeIdentifier, - ) { - objc.checkOsVersionInternal( - 'NSURL.itemProviderVisibilityForRepresentationWithTypeIdentifier:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURL', - 'itemProviderVisibilityForRepresentationWithTypeIdentifier:', - ); - } - final $ret = _objc_msgSend_16fy0up( - object$.ref.pointer, - _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_, - typeIdentifier.ref.pointer, - ); - return objc.NSItemProviderRepresentationVisibility.fromValue($ret); - } - - /// loadDataWithTypeIdentifier:forItemProviderCompletionHandler: - objc.NSProgress? loadDataWithTypeIdentifier( - objc.NSString typeIdentifier, { - required objc.ObjCBlock - forItemProviderCompletionHandler, - }) { - objc.checkOsVersionInternal( - 'NSURL.loadDataWithTypeIdentifier:forItemProviderCompletionHandler:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $ret = _objc_msgSend_r0bo0s( - object$.ref.pointer, - _sel_loadDataWithTypeIdentifier_forItemProviderCompletionHandler_, - typeIdentifier.ref.pointer, - forItemProviderCompletionHandler.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSProgress.fromPointer($ret, retain: true, release: true); - } - - /// writableTypeIdentifiersForItemProvider - objc.NSArray get writableTypeIdentifiersForItemProvider { - objc.checkOsVersionInternal( - 'NSURL.writableTypeIdentifiersForItemProvider', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - object$.ref.pointer, - _sel_writableTypeIdentifiersForItemProvider, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURL', - 'writableTypeIdentifiersForItemProvider', - ); - } - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_writableTypeIdentifiersForItemProvider, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// itemProviderVisibilityForRepresentationWithTypeIdentifier: - static objc.NSItemProviderRepresentationVisibility - itemProviderVisibilityForRepresentationWithTypeIdentifier$1( - objc.NSString typeIdentifier, - ) { - objc.checkOsVersionInternal( - 'NSURL.itemProviderVisibilityForRepresentationWithTypeIdentifier:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - if (!objc.respondsToSelector( - _class_NSURL, - _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_, - )) { - throw objc.UnimplementedOptionalMethodException( - 'NSURL', - 'itemProviderVisibilityForRepresentationWithTypeIdentifier:', - ); - } - final $ret = _objc_msgSend_16fy0up( - _class_NSURL, - _sel_itemProviderVisibilityForRepresentationWithTypeIdentifier_, - typeIdentifier.ref.pointer, - ); - return objc.NSItemProviderRepresentationVisibility.fromValue($ret); - } - - /// objectWithItemProviderData:typeIdentifier:error: - static objc.NSURL? objectWithItemProviderData( - objc.NSData data, { - required objc.NSString typeIdentifier, - }) { - objc.checkOsVersionInternal( - 'NSURL.objectWithItemProviderData:typeIdentifier:error:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1pnyuds( - _class_NSURL, - _sel_objectWithItemProviderData_typeIdentifier_error_, - data.ref.pointer, - typeIdentifier.ref.pointer, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// readableTypeIdentifiersForItemProvider - static objc.NSArray getReadableTypeIdentifiersForItemProvider() { - objc.checkOsVersionInternal( - 'NSURL.readableTypeIdentifiersForItemProvider', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSURL, - _sel_readableTypeIdentifiersForItemProvider, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// writableTypeIdentifiersForItemProvider - static objc.NSArray getWritableTypeIdentifiersForItemProvider$1() { - objc.checkOsVersionInternal( - 'NSURL.writableTypeIdentifiersForItemProvider', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSURL, - _sel_writableTypeIdentifiersForItemProvider, - ); - return objc.NSArray.fromPointer($ret, retain: true, release: true); - } -} - -late final _class_NSCharacterSet = objc.getClass("NSCharacterSet"); -late final _sel_URLUserAllowedCharacterSet = objc.registerName( - "URLUserAllowedCharacterSet", -); -late final _sel_URLPasswordAllowedCharacterSet = objc.registerName( - "URLPasswordAllowedCharacterSet", -); -late final _sel_URLHostAllowedCharacterSet = objc.registerName( - "URLHostAllowedCharacterSet", -); -late final _sel_URLPathAllowedCharacterSet = objc.registerName( - "URLPathAllowedCharacterSet", -); -late final _sel_URLQueryAllowedCharacterSet = objc.registerName( - "URLQueryAllowedCharacterSet", -); -late final _sel_URLFragmentAllowedCharacterSet = objc.registerName( - "URLFragmentAllowedCharacterSet", -); - -/// NSURLUtilities -extension NSURLUtilities$1 on objc.NSCharacterSet { - /// Returns a character set containing the characters allowed in a URL's fragment component. - static objc.NSCharacterSet getURLFragmentAllowedCharacterSet() { - objc.checkOsVersionInternal( - 'NSCharacterSet.URLFragmentAllowedCharacterSet', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSCharacterSet, - _sel_URLFragmentAllowedCharacterSet, - ); - return objc.NSCharacterSet.fromPointer($ret, retain: true, release: true); - } - - /// Returns a character set containing the characters allowed in a URL's host subcomponent. - static objc.NSCharacterSet getURLHostAllowedCharacterSet() { - objc.checkOsVersionInternal( - 'NSCharacterSet.URLHostAllowedCharacterSet', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSCharacterSet, - _sel_URLHostAllowedCharacterSet, - ); - return objc.NSCharacterSet.fromPointer($ret, retain: true, release: true); - } - - /// Returns a character set containing the characters allowed in a URL's password subcomponent. - static objc.NSCharacterSet getURLPasswordAllowedCharacterSet() { - objc.checkOsVersionInternal( - 'NSCharacterSet.URLPasswordAllowedCharacterSet', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSCharacterSet, - _sel_URLPasswordAllowedCharacterSet, - ); - return objc.NSCharacterSet.fromPointer($ret, retain: true, release: true); - } - - /// Returns a character set containing the characters allowed in a URL's path component. ';' is a legal path character, but it is recommended that it be percent-encoded for best compatibility with NSURL (-stringByAddingPercentEncodingWithAllowedCharacters: will percent-encode any ';' characters if you pass the URLPathAllowedCharacterSet). - static objc.NSCharacterSet getURLPathAllowedCharacterSet() { - objc.checkOsVersionInternal( - 'NSCharacterSet.URLPathAllowedCharacterSet', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSCharacterSet, - _sel_URLPathAllowedCharacterSet, - ); - return objc.NSCharacterSet.fromPointer($ret, retain: true, release: true); - } - - /// Returns a character set containing the characters allowed in a URL's query component. - static objc.NSCharacterSet getURLQueryAllowedCharacterSet() { - objc.checkOsVersionInternal( - 'NSCharacterSet.URLQueryAllowedCharacterSet', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSCharacterSet, - _sel_URLQueryAllowedCharacterSet, - ); - return objc.NSCharacterSet.fromPointer($ret, retain: true, release: true); - } - - /// Returns a character set containing the characters allowed in a URL's user subcomponent. - static objc.NSCharacterSet getURLUserAllowedCharacterSet() { - objc.checkOsVersionInternal( - 'NSCharacterSet.URLUserAllowedCharacterSet', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSCharacterSet, - _sel_URLUserAllowedCharacterSet, - ); - return objc.NSCharacterSet.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_stringByAddingPercentEncodingWithAllowedCharacters_ = objc - .registerName("stringByAddingPercentEncodingWithAllowedCharacters:"); -late final _sel_stringByRemovingPercentEncoding = objc.registerName( - "stringByRemovingPercentEncoding", -); -late final _sel_stringByAddingPercentEscapesUsingEncoding_ = objc.registerName( - "stringByAddingPercentEscapesUsingEncoding:", -); -late final _sel_stringByReplacingPercentEscapesUsingEncoding_ = objc - .registerName("stringByReplacingPercentEscapesUsingEncoding:"); - -/// NSURLUtilities -extension NSURLUtilities on objc.NSString { - /// Returns a new string made from the receiver by replacing all characters not in the allowedCharacters set with percent encoded characters. UTF-8 encoding is used to determine the correct percent encoded characters. Entire URL strings cannot be percent-encoded. This method is intended to percent-encode a URL component or subcomponent string, NOT the entire URL string. Any characters in allowedCharacters outside of the 7-bit ASCII range are ignored. - objc.NSString? stringByAddingPercentEncodingWithAllowedCharacters( - objc.NSCharacterSet allowedCharacters, - ) { - objc.checkOsVersionInternal( - 'NSString.stringByAddingPercentEncodingWithAllowedCharacters:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_stringByAddingPercentEncodingWithAllowedCharacters_, - allowedCharacters.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// stringByAddingPercentEscapesUsingEncoding: - objc.NSString? stringByAddingPercentEscapesUsingEncoding(DartNSUInteger enc) { - objc.checkOsVersionInternal( - 'NSString.stringByAddingPercentEscapesUsingEncoding:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_14hpxwa( - object$.ref.pointer, - _sel_stringByAddingPercentEscapesUsingEncoding_, - enc, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// Returns a new string made from the receiver by replacing all percent encoded sequences with the matching UTF-8 characters. - objc.NSString? get stringByRemovingPercentEncoding { - objc.checkOsVersionInternal( - 'NSString.stringByRemovingPercentEncoding', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_stringByRemovingPercentEncoding, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// stringByReplacingPercentEscapesUsingEncoding: - objc.NSString? stringByReplacingPercentEscapesUsingEncoding( - DartNSUInteger enc, - ) { - objc.checkOsVersionInternal( - 'NSString.stringByReplacingPercentEscapesUsingEncoding:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_14hpxwa( - object$.ref.pointer, - _sel_stringByReplacingPercentEscapesUsingEncoding_, - enc, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_fileURLWithPathComponents_ = objc.registerName( - "fileURLWithPathComponents:", -); -late final _sel_pathComponents = objc.registerName("pathComponents"); -late final _sel_lastPathComponent = objc.registerName("lastPathComponent"); -late final _sel_pathExtension = objc.registerName("pathExtension"); -late final _sel_URLByAppendingPathComponent_ = objc.registerName( - "URLByAppendingPathComponent:", -); -late final _sel_URLByAppendingPathComponent_isDirectory_ = objc.registerName( - "URLByAppendingPathComponent:isDirectory:", -); -late final _sel_URLByDeletingLastPathComponent = objc.registerName( - "URLByDeletingLastPathComponent", -); -late final _sel_URLByAppendingPathExtension_ = objc.registerName( - "URLByAppendingPathExtension:", -); -late final _sel_URLByDeletingPathExtension = objc.registerName( - "URLByDeletingPathExtension", -); -late final _sel_checkResourceIsReachableAndReturnError_ = objc.registerName( - "checkResourceIsReachableAndReturnError:", -); -late final _sel_URLByStandardizingPath = objc.registerName( - "URLByStandardizingPath", -); -late final _sel_URLByResolvingSymlinksInPath = objc.registerName( - "URLByResolvingSymlinksInPath", -); - -/// NSURLPathUtilities -extension NSURLPathUtilities on objc.NSURL { - /// URLByAppendingPathComponent: - objc.NSURL? URLByAppendingPathComponent(objc.NSString pathComponent) { - objc.checkOsVersionInternal( - 'NSURL.URLByAppendingPathComponent:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_URLByAppendingPathComponent_, - pathComponent.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// URLByAppendingPathComponent:isDirectory: - objc.NSURL? URLByAppendingPathComponent$1( - objc.NSString pathComponent, { - required bool isDirectory, - }) { - objc.checkOsVersionInternal( - 'NSURL.URLByAppendingPathComponent:isDirectory:', - iOS: (false, (5, 0, 0)), - macOS: (false, (10, 7, 0)), - ); - final $ret = _objc_msgSend_17amj0z( - object$.ref.pointer, - _sel_URLByAppendingPathComponent_isDirectory_, - pathComponent.ref.pointer, - isDirectory, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// URLByAppendingPathExtension: - objc.NSURL? URLByAppendingPathExtension(objc.NSString pathExtension) { - objc.checkOsVersionInternal( - 'NSURL.URLByAppendingPathExtension:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_URLByAppendingPathExtension_, - pathExtension.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// URLByDeletingLastPathComponent - objc.NSURL? get URLByDeletingLastPathComponent { - objc.checkOsVersionInternal( - 'NSURL.URLByDeletingLastPathComponent', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_URLByDeletingLastPathComponent, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// URLByDeletingPathExtension - objc.NSURL? get URLByDeletingPathExtension { - objc.checkOsVersionInternal( - 'NSURL.URLByDeletingPathExtension', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_URLByDeletingPathExtension, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// URLByResolvingSymlinksInPath - objc.NSURL? get URLByResolvingSymlinksInPath { - objc.checkOsVersionInternal( - 'NSURL.URLByResolvingSymlinksInPath', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_URLByResolvingSymlinksInPath, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// URLByStandardizingPath - objc.NSURL? get URLByStandardizingPath { - objc.checkOsVersionInternal( - 'NSURL.URLByStandardizingPath', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_URLByStandardizingPath, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } - - /// Returns whether the URL's resource exists and is reachable. This method synchronously checks if the resource's backing store is reachable. Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, e.g. periodic maintenance of UI state that depends on the existence of a specific document. When performing operations such as opening a file or copying resource properties, it is more efficient to simply try the operation and handle failures. If this method returns NO, the optional error is populated. This method is currently applicable only to URLs for file system resources. For other URL types, NO is returned. Symbol is present in iOS 4, but performs no operation. - bool checkResourceIsReachableAndReturnError() { - objc.checkOsVersionInternal( - 'NSURL.checkResourceIsReachableAndReturnError:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $err = pkg_ffi.calloc>(); - try { - final $ret = _objc_msgSend_1dom33q( - object$.ref.pointer, - _sel_checkResourceIsReachableAndReturnError_, - $err, - ); - objc.NSErrorException.checkErrorPointer($err.value); - return $ret; - } finally { - pkg_ffi.calloc.free($err); - } - } - - /// lastPathComponent - objc.NSString? get lastPathComponent { - objc.checkOsVersionInternal( - 'NSURL.lastPathComponent', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_lastPathComponent, - ); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// pathComponents - objc.NSArray? get pathComponents { - objc.checkOsVersionInternal( - 'NSURL.pathComponents', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_pathComponents, - ); - return $ret.address == 0 - ? null - : objc.NSArray.fromPointer($ret, retain: true, release: true); - } - - /// pathExtension - objc.NSString? get pathExtension { - objc.checkOsVersionInternal( - 'NSURL.pathExtension', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_pathExtension); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// The following methods work on the path portion of a URL in the same manner that the NSPathUtilities methods on NSString do. - static objc.NSURL? fileURLWithPathComponents(objc.NSArray components) { - objc.checkOsVersionInternal( - 'NSURL.fileURLWithPathComponents:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSURL, - _sel_fileURLWithPathComponents_, - components.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); - } -} - -late final _sel_URL_resourceDataDidBecomeAvailable_ = objc.registerName( - "URL:resourceDataDidBecomeAvailable:", -); -late final _sel_URLResourceDidFinishLoading_ = objc.registerName( - "URLResourceDidFinishLoading:", -); -late final _sel_URLResourceDidCancelLoading_ = objc.registerName( - "URLResourceDidCancelLoading:", -); -late final _sel_URL_resourceDidFailLoadingWithReason_ = objc.registerName( - "URL:resourceDidFailLoadingWithReason:", -); - -/// NSURLClient -extension NSURLClient on objc.NSObject { - /// URL:resourceDataDidBecomeAvailable: - void URL( - objc.NSURL sender, { - required objc.NSData resourceDataDidBecomeAvailable, - }) { - objc.checkOsVersionInternal( - 'NSObject.URL:resourceDataDidBecomeAvailable:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URL_resourceDataDidBecomeAvailable_, - sender.ref.pointer, - resourceDataDidBecomeAvailable.ref.pointer, - ); - } - - /// URL:resourceDidFailLoadingWithReason: - void URL$1( - objc.NSURL sender, { - required objc.NSString resourceDidFailLoadingWithReason, - }) { - objc.checkOsVersionInternal( - 'NSObject.URL:resourceDidFailLoadingWithReason:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URL_resourceDidFailLoadingWithReason_, - sender.ref.pointer, - resourceDidFailLoadingWithReason.ref.pointer, - ); - } - - /// URLResourceDidCancelLoading: - void URLResourceDidCancelLoading(objc.NSURL sender) { - objc.checkOsVersionInternal( - 'NSObject.URLResourceDidCancelLoading:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_URLResourceDidCancelLoading_, - sender.ref.pointer, - ); - } - - /// URLResourceDidFinishLoading: - void URLResourceDidFinishLoading(objc.NSURL sender) { - objc.checkOsVersionInternal( - 'NSObject.URLResourceDidFinishLoading:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_URLResourceDidFinishLoading_, - sender.ref.pointer, - ); - } -} - -late final _sel_resourceDataUsingCache_ = objc.registerName( - "resourceDataUsingCache:", -); -final _objc_msgSend_1t6aok9 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - bool, - ) - >(); -late final _sel_loadResourceDataNotifyingClient_usingCache_ = objc.registerName( - "loadResourceDataNotifyingClient:usingCache:", -); -late final _sel_propertyForKey_ = objc.registerName("propertyForKey:"); -late final _sel_setResourceData_ = objc.registerName("setResourceData:"); -late final _sel_setProperty_forKey_ = objc.registerName("setProperty:forKey:"); -final _objc_msgSend_1lsax7n = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_URLHandleUsingCache_ = objc.registerName( - "URLHandleUsingCache:", -); - -/// NSURLLoading -extension NSURLLoading on objc.NSURL { - /// Sophisticated clients will want to ask for this, then message the handle directly. If shouldUseCache is NO, a newly instantiated handle is returned, even if an equivalent URL has been loaded - objc.NSURLHandle? URLHandleUsingCache(bool shouldUseCache) { - objc.checkOsVersionInternal( - 'NSURL.URLHandleUsingCache:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1t6aok9( - object$.ref.pointer, - _sel_URLHandleUsingCache_, - shouldUseCache, - ); - return $ret.address == 0 - ? null - : objc.NSURLHandle.fromPointer($ret, retain: true, release: true); - } - - /// Starts an asynchronous load of the data, registering delegate to receive notification. Only one such background load can proceed at a time. - void loadResourceDataNotifyingClient( - objc.ObjCObject client, { - required bool usingCache, - }) { - objc.checkOsVersionInternal( - 'NSURL.loadResourceDataNotifyingClient:usingCache:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_6p7ndb( - object$.ref.pointer, - _sel_loadResourceDataNotifyingClient_usingCache_, - client.ref.pointer, - usingCache, - ); - } - - /// propertyForKey: - objc.ObjCObject? propertyForKey(objc.NSString propertyKey) { - objc.checkOsVersionInternal( - 'NSURL.propertyForKey:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_propertyForKey_, - propertyKey.ref.pointer, - ); - return $ret.address == 0 - ? null - : objc.ObjCObject($ret, retain: true, release: true); - } - - /// Blocks to load the data if necessary. If shouldUseCache is YES, then if an equivalent URL has already been loaded and cached, its resource data will be returned immediately. If shouldUseCache is NO, a new load will be started - objc.NSData? resourceDataUsingCache(bool shouldUseCache) { - objc.checkOsVersionInternal( - 'NSURL.resourceDataUsingCache:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_1t6aok9( - object$.ref.pointer, - _sel_resourceDataUsingCache_, - shouldUseCache, - ); - return $ret.address == 0 - ? null - : objc.NSData.fromPointer($ret, retain: true, release: true); - } - - /// setProperty:forKey: - bool setProperty(objc.ObjCObject property, {required objc.NSString forKey}) { - objc.checkOsVersionInternal( - 'NSURL.setProperty:forKey:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_1lsax7n( - object$.ref.pointer, - _sel_setProperty_forKey_, - property.ref.pointer, - forKey.ref.pointer, - ); - } - - /// These attempt to write the given arguments for the resource specified by the URL; they return success or failure - bool setResourceData(objc.NSData data) { - objc.checkOsVersionInternal( - 'NSURL.setResourceData:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_19nvye5( - object$.ref.pointer, - _sel_setResourceData_, - data.ref.pointer, - ); - } -} - -/// WARNING: NSLocking is a stub. To generate bindings for this class, include -/// NSLocking in your config's objc-protocols list. -/// -/// NSLocking -extension type NSLocking._(objc.ObjCProtocol object$) - implements objc.ObjCProtocol { - /// Constructs a [NSLocking] that points to the same underlying object as [other]. - NSLocking.as(objc.ObjCObject other) : object$ = other; - - /// Constructs a [NSLocking] that wraps the given raw object pointer. - NSLocking.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); -} - -late final _class_NSCondition = objc.getClass("NSCondition"); -late final _sel_wait = objc.registerName("wait"); -late final _sel_waitUntilDate_ = objc.registerName("waitUntilDate:"); -late final _sel_signal = objc.registerName("signal"); -late final _sel_broadcast = objc.registerName("broadcast"); -late final _sel_lock = objc.registerName("lock"); - -/// Construction methods for `objc.ObjCBlock)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock)> fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => objc.ObjCBlock)>( - pointer, - retain: retain, - release: release, - ); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction arg0)> - > - ptr, - ) => objc.ObjCBlock)>( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock)> fromFunction( - void Function(ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) => objc.ObjCBlock)>( - objc.newClosureBlock( - _closureCallable, - (ffi.Pointer arg0) => fn(arg0), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock)> listener( - void Function(ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_ovsamd(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock)>( - wrapper, - retain: false, - release: true, - ); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock)> blocking( - void Function(ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn(arg0), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_ovsamd( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock)>( - wrapper, - retain: false, - release: true, - ); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - ) { - try { - (objc.getBlockClosure(block) as void Function(ffi.Pointer))( - arg0, - ); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => block.ref.target - .cast arg0)>>() - .asFunction)>()(arg0); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) => (objc.getBlockClosure(block) as void Function(ffi.Pointer))( - arg0, - ); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid$CallExtension - on objc.ObjCBlock)> { - void call(ffi.Pointer arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ) - > - >() - .asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >()(ref.pointer, arg0); -} - -late final _sel_unlock = objc.registerName("unlock"); - -/// NSCondition -extension type NSCondition._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject, NSLocking { - /// Constructs a [NSCondition] that points to the same underlying object as [other]. - NSCondition.as(objc.ObjCObject other) : object$ = other { - objc.checkOsVersionInternal( - 'NSCondition', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - assert(isA(object$)); - } - - /// Constructs a [NSCondition] that wraps the given raw object pointer. - NSCondition.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - objc.checkOsVersionInternal( - 'NSCondition', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [NSCondition]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSCondition, - ); - - /// alloc - static NSCondition alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSCondition, _sel_alloc); - return NSCondition.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static NSCondition allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSCondition, - _sel_allocWithZone_, - zone, - ); - return NSCondition.fromPointer($ret, retain: false, release: true); - } - - /// new - static NSCondition new$() { - final $ret = _objc_msgSend_151sglz(_class_NSCondition, _sel_new); - return NSCondition.fromPointer($ret, retain: false, release: true); - } - - /// Returns a new instance of NSCondition constructed with the default `new` method. - NSCondition() : this.as(new$().object$); -} - -extension NSCondition$Methods on NSCondition { - /// broadcast - void broadcast() { - objc.checkOsVersionInternal( - 'NSCondition.broadcast', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_broadcast); - } - - /// init - NSCondition init() { - objc.checkOsVersionInternal( - 'NSCondition.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return NSCondition.fromPointer($ret, retain: false, release: true); - } - - /// lock - void lock() { - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_lock); - } - - /// name - objc.NSString? get name { - objc.checkOsVersionInternal( - 'NSCondition.name', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_name); - return $ret.address == 0 - ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); - } - - /// setName: - set name(objc.NSString? value) { - objc.checkOsVersionInternal( - 'NSCondition.setName:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setName_, - value?.ref.pointer ?? ffi.nullptr, - ); - } - - /// signal - void signal$1() { - objc.checkOsVersionInternal( - 'NSCondition.signal', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_signal); - } - - /// unlock - void unlock() { - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_unlock); - } - - /// wait - void wait$2() { - objc.checkOsVersionInternal( - 'NSCondition.wait', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_wait); - } - - /// waitUntilDate: - bool waitUntilDate(objc.NSDate limit) { - objc.checkOsVersionInternal( - 'NSCondition.waitUntilDate:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), - ); - return _objc_msgSend_19nvye5( - object$.ref.pointer, - _sel_waitUntilDate_, - limit.ref.pointer, - ); - } -} - -typedef NSProgressKind$1 = ffi.Pointer; -typedef DartNSProgressKind$1 = objc.NSString; -typedef NSProgressUserInfoKey$1 = ffi.Pointer; -typedef DartNSProgressUserInfoKey$1 = objc.NSString; -typedef NSProgressFileOperationKind$1 = ffi.Pointer; -typedef DartNSProgressFileOperationKind$1 = objc.NSString; -typedef NSProgressUnpublishingHandler$1 = ffi.Pointer; -typedef DartNSProgressUnpublishingHandler$1 = - objc.ObjCBlock; -typedef NSProgressPublishingHandler$1 = ffi.Pointer; -typedef DartNSProgressPublishingHandler$1 = - objc.ObjCBlock< - objc.ObjCBlock? Function(objc.NSProgress) - >; - -/// WARNING: NSException is a stub. To generate bindings for this class, include -/// NSException in your config's objc-interfaces list. -/// -/// NSException -extension type NSException._(objc.ObjCObject object$) - implements - objc.ObjCObject, - objc.NSObject, - objc.NSCopying, - objc.NSSecureCoding { - /// Constructs a [NSException] that points to the same underlying object as [other]. - NSException.as(objc.ObjCObject other) : object$ = other {} - - /// Constructs a [NSException] that wraps the given raw object pointer. - NSException.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) {} -} - -late final _class_NSException = objc.getClass("NSException"); -late final _sel_raise_format_ = objc.registerName("raise:format:"); - -/// NSExceptionRaisingConveniences -extension NSExceptionRaisingConveniences on NSException { - /// raise:format: - static void raise$1( - DartNSExceptionName name, { - required objc.NSString format, - }) { - _objc_msgSend_pfv6jd( - _class_NSException, - _sel_raise_format_, - name.ref.pointer, - format.ref.pointer, - ); - } -} - -typedef NSUncaughtExceptionHandler = - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer exception$1) - >; - -enum NSOperationQueuePriority { - NSOperationQueuePriorityVeryLow(-8), - NSOperationQueuePriorityLow(-4), - NSOperationQueuePriorityNormal(0), - NSOperationQueuePriorityHigh(4), - NSOperationQueuePriorityVeryHigh(8); - - final int value; - const NSOperationQueuePriority(this.value); - - static NSOperationQueuePriority fromValue(int value) => switch (value) { - -8 => NSOperationQueuePriorityVeryLow, - -4 => NSOperationQueuePriorityLow, - 0 => NSOperationQueuePriorityNormal, - 4 => NSOperationQueuePriorityHigh, - 8 => NSOperationQueuePriorityVeryHigh, - _ => throw ArgumentError( - 'Unknown value for NSOperationQueuePriority: $value', - ), - }; -} - -typedef NSErrorDomain = ffi.Pointer; -typedef DartNSErrorDomain = objc.NSString; -typedef NSErrorUserInfoKey = ffi.Pointer; -typedef DartNSErrorUserInfoKey = objc.NSString; -late final _sel_attemptRecoveryFromError_optionIndex_delegate_didRecoverSelector_contextInfo_ = - objc.registerName( - "attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:", - ); -final _objc_msgSend_10txwc9 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_attemptRecoveryFromError_optionIndex_ = objc.registerName( - "attemptRecoveryFromError:optionIndex:", -); -final _objc_msgSend_z7gxsm = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); - -/// NSErrorRecoveryAttempting -extension NSErrorRecoveryAttempting on objc.NSObject { - /// Given that an error alert has been presented applicaton-modally to the user, and the user has chosen one of the error's recovery options, attempt recovery from the error, and return YES if error recovery was completely successful, NO otherwise. The recovery option index is an index into the error's array of localized recovery options. - bool attemptRecoveryFromError( - objc.NSError error, { - required DartNSUInteger optionIndex, - }) { - objc.checkOsVersionInternal( - 'NSObject.attemptRecoveryFromError:optionIndex:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - return _objc_msgSend_z7gxsm( - object$.ref.pointer, - _sel_attemptRecoveryFromError_optionIndex_, - error.ref.pointer, - optionIndex, - ); - } - - /// Given that an error alert has been presented document-modally to the user, and the user has chosen one of the error's recovery options, attempt recovery from the error, and send the selected message to the specified delegate. The option index is an index into the error's array of localized recovery options. The method selected by didRecoverSelector must have the same signature as: - /// - /// - (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void *)contextInfo; - /// - /// The value passed for didRecover must be YES if error recovery was completely successful, NO otherwise. - void attemptRecoveryFromError$1( - objc.NSError error, { - required DartNSUInteger optionIndex, - objc.ObjCObject? delegate, - required ffi.Pointer didRecoverSelector, - required ffi.Pointer contextInfo, - }) { - objc.checkOsVersionInternal( - 'NSObject.attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - _objc_msgSend_10txwc9( - object$.ref.pointer, - _sel_attemptRecoveryFromError_optionIndex_delegate_didRecoverSelector_contextInfo_, - error.ref.pointer, - optionIndex, - delegate?.ref.pointer ?? ffi.nullptr, - didRecoverSelector, - contextInfo, - ); - } -} - -const int noErr = 0; - -const int kNilOptions = 0; - -const int kVariableLengthArray = 1; - -const int kUnknownType = 1061109567; - -const int normal = 0; - -const int bold = 1; - -const int italic = 2; - -const int underline = 4; - -const int outline = 8; - -const int shadow = 16; - -const int condense = 32; - -const int extend = 64; - -const int developStage = 32; - -const int alphaStage = 64; - -const int betaStage = 96; - -const int finalStage = 128; - -const int NSScannedOption = 1; - -const int NSCollectorDisabledOption = 2; - -const int errSecSuccess = 0; - -const int errSecUnimplemented = -4; - -const int errSecDiskFull = -34; - -const int errSecDskFull = -34; - -const int errSecIO = -36; - -const int errSecOpWr = -49; - -const int errSecParam = -50; - -const int errSecWrPerm = -61; - -const int errSecAllocate = -108; - -const int errSecUserCanceled = -128; - -const int errSecBadReq = -909; - -const int errSecInternalComponent = -2070; - -const int errSecCoreFoundationUnknown = -4960; - -const int errSecMissingEntitlement = -34018; - -const int errSecRestrictedAPI = -34020; - -const int errSecNotAvailable = -25291; - -const int errSecReadOnly = -25292; - -const int errSecAuthFailed = -25293; - -const int errSecNoSuchKeychain = -25294; - -const int errSecInvalidKeychain = -25295; - -const int errSecDuplicateKeychain = -25296; - -const int errSecDuplicateCallback = -25297; - -const int errSecInvalidCallback = -25298; - -const int errSecDuplicateItem = -25299; - -const int errSecItemNotFound = -25300; - -const int errSecBufferTooSmall = -25301; - -const int errSecDataTooLarge = -25302; - -const int errSecNoSuchAttr = -25303; - -const int errSecInvalidItemRef = -25304; - -const int errSecInvalidSearchRef = -25305; - -const int errSecNoSuchClass = -25306; - -const int errSecNoDefaultKeychain = -25307; - -const int errSecInteractionNotAllowed = -25308; - -const int errSecReadOnlyAttr = -25309; - -const int errSecWrongSecVersion = -25310; - -const int errSecKeySizeNotAllowed = -25311; - -const int errSecNoStorageModule = -25312; - -const int errSecNoCertificateModule = -25313; - -const int errSecNoPolicyModule = -25314; - -const int errSecInteractionRequired = -25315; - -const int errSecDataNotAvailable = -25316; - -const int errSecDataNotModifiable = -25317; - -const int errSecCreateChainFailed = -25318; - -const int errSecInvalidPrefsDomain = -25319; - -const int errSecInDarkWake = -25320; - -const int errSecACLNotSimple = -25240; - -const int errSecPolicyNotFound = -25241; - -const int errSecInvalidTrustSetting = -25242; - -const int errSecNoAccessForItem = -25243; - -const int errSecInvalidOwnerEdit = -25244; - -const int errSecTrustNotAvailable = -25245; - -const int errSecUnsupportedFormat = -25256; - -const int errSecUnknownFormat = -25257; - -const int errSecKeyIsSensitive = -25258; - -const int errSecMultiplePrivKeys = -25259; - -const int errSecPassphraseRequired = -25260; - -const int errSecInvalidPasswordRef = -25261; - -const int errSecInvalidTrustSettings = -25262; - -const int errSecNoTrustSettings = -25263; - -const int errSecPkcs12VerifyFailure = -25264; - -const int errSecNotSigner = -26267; - -const int errSecDecode = -26275; - -const int errSecServiceNotAvailable = -67585; - -const int errSecInsufficientClientID = -67586; - -const int errSecDeviceReset = -67587; - -const int errSecDeviceFailed = -67588; - -const int errSecAppleAddAppACLSubject = -67589; - -const int errSecApplePublicKeyIncomplete = -67590; - -const int errSecAppleSignatureMismatch = -67591; - -const int errSecAppleInvalidKeyStartDate = -67592; - -const int errSecAppleInvalidKeyEndDate = -67593; - -const int errSecConversionError = -67594; - -const int errSecAppleSSLv2Rollback = -67595; - -const int errSecQuotaExceeded = -67596; - -const int errSecFileTooBig = -67597; - -const int errSecInvalidDatabaseBlob = -67598; - -const int errSecInvalidKeyBlob = -67599; - -const int errSecIncompatibleDatabaseBlob = -67600; - -const int errSecIncompatibleKeyBlob = -67601; - -const int errSecHostNameMismatch = -67602; - -const int errSecUnknownCriticalExtensionFlag = -67603; - -const int errSecNoBasicConstraints = -67604; - -const int errSecNoBasicConstraintsCA = -67605; - -const int errSecInvalidAuthorityKeyID = -67606; - -const int errSecInvalidSubjectKeyID = -67607; - -const int errSecInvalidKeyUsageForPolicy = -67608; - -const int errSecInvalidExtendedKeyUsage = -67609; - -const int errSecInvalidIDLinkage = -67610; - -const int errSecPathLengthConstraintExceeded = -67611; - -const int errSecInvalidRoot = -67612; - -const int errSecCRLExpired = -67613; - -const int errSecCRLNotValidYet = -67614; - -const int errSecCRLNotFound = -67615; - -const int errSecCRLServerDown = -67616; - -const int errSecCRLBadURI = -67617; - -const int errSecUnknownCertExtension = -67618; - -const int errSecUnknownCRLExtension = -67619; - -const int errSecCRLNotTrusted = -67620; - -const int errSecCRLPolicyFailed = -67621; - -const int errSecIDPFailure = -67622; - -const int errSecSMIMEEmailAddressesNotFound = -67623; - -const int errSecSMIMEBadExtendedKeyUsage = -67624; - -const int errSecSMIMEBadKeyUsage = -67625; - -const int errSecSMIMEKeyUsageNotCritical = -67626; - -const int errSecSMIMENoEmailAddress = -67627; - -const int errSecSMIMESubjAltNameNotCritical = -67628; - -const int errSecSSLBadExtendedKeyUsage = -67629; - -const int errSecOCSPBadResponse = -67630; - -const int errSecOCSPBadRequest = -67631; - -const int errSecOCSPUnavailable = -67632; - -const int errSecOCSPStatusUnrecognized = -67633; - -const int errSecEndOfData = -67634; - -const int errSecIncompleteCertRevocationCheck = -67635; - -const int errSecNetworkFailure = -67636; - -const int errSecOCSPNotTrustedToAnchor = -67637; - -const int errSecRecordModified = -67638; - -const int errSecOCSPSignatureError = -67639; - -const int errSecOCSPNoSigner = -67640; - -const int errSecOCSPResponderMalformedReq = -67641; - -const int errSecOCSPResponderInternalError = -67642; - -const int errSecOCSPResponderTryLater = -67643; - -const int errSecOCSPResponderSignatureRequired = -67644; - -const int errSecOCSPResponderUnauthorized = -67645; - -const int errSecOCSPResponseNonceMismatch = -67646; - -const int errSecCodeSigningBadCertChainLength = -67647; - -const int errSecCodeSigningNoBasicConstraints = -67648; - -const int errSecCodeSigningBadPathLengthConstraint = -67649; - -const int errSecCodeSigningNoExtendedKeyUsage = -67650; - -const int errSecCodeSigningDevelopment = -67651; - -const int errSecResourceSignBadCertChainLength = -67652; - -const int errSecResourceSignBadExtKeyUsage = -67653; - -const int errSecTrustSettingDeny = -67654; - -const int errSecInvalidSubjectName = -67655; - -const int errSecUnknownQualifiedCertStatement = -67656; - -const int errSecMobileMeRequestQueued = -67657; - -const int errSecMobileMeRequestRedirected = -67658; - -const int errSecMobileMeServerError = -67659; - -const int errSecMobileMeServerNotAvailable = -67660; - -const int errSecMobileMeServerAlreadyExists = -67661; - -const int errSecMobileMeServerServiceErr = -67662; - -const int errSecMobileMeRequestAlreadyPending = -67663; - -const int errSecMobileMeNoRequestPending = -67664; - -const int errSecMobileMeCSRVerifyFailure = -67665; - -const int errSecMobileMeFailedConsistencyCheck = -67666; - -const int errSecNotInitialized = -67667; - -const int errSecInvalidHandleUsage = -67668; - -const int errSecPVCReferentNotFound = -67669; - -const int errSecFunctionIntegrityFail = -67670; - -const int errSecInternalError = -67671; - -const int errSecMemoryError = -67672; - -const int errSecInvalidData = -67673; - -const int errSecMDSError = -67674; - -const int errSecInvalidPointer = -67675; - -const int errSecSelfCheckFailed = -67676; - -const int errSecFunctionFailed = -67677; - -const int errSecModuleManifestVerifyFailed = -67678; - -const int errSecInvalidGUID = -67679; - -const int errSecInvalidHandle = -67680; - -const int errSecInvalidDBList = -67681; - -const int errSecInvalidPassthroughID = -67682; - -const int errSecInvalidNetworkAddress = -67683; - -const int errSecCRLAlreadySigned = -67684; - -const int errSecInvalidNumberOfFields = -67685; - -const int errSecVerificationFailure = -67686; - -const int errSecUnknownTag = -67687; - -const int errSecInvalidSignature = -67688; - -const int errSecInvalidName = -67689; - -const int errSecInvalidCertificateRef = -67690; - -const int errSecInvalidCertificateGroup = -67691; - -const int errSecTagNotFound = -67692; - -const int errSecInvalidQuery = -67693; - -const int errSecInvalidValue = -67694; - -const int errSecCallbackFailed = -67695; - -const int errSecACLDeleteFailed = -67696; - -const int errSecACLReplaceFailed = -67697; - -const int errSecACLAddFailed = -67698; - -const int errSecACLChangeFailed = -67699; - -const int errSecInvalidAccessCredentials = -67700; - -const int errSecInvalidRecord = -67701; - -const int errSecInvalidACL = -67702; - -const int errSecInvalidSampleValue = -67703; - -const int errSecIncompatibleVersion = -67704; - -const int errSecPrivilegeNotGranted = -67705; - -const int errSecInvalidScope = -67706; - -const int errSecPVCAlreadyConfigured = -67707; - -const int errSecInvalidPVC = -67708; - -const int errSecEMMLoadFailed = -67709; - -const int errSecEMMUnloadFailed = -67710; - -const int errSecAddinLoadFailed = -67711; - -const int errSecInvalidKeyRef = -67712; - -const int errSecInvalidKeyHierarchy = -67713; - -const int errSecAddinUnloadFailed = -67714; - -const int errSecLibraryReferenceNotFound = -67715; - -const int errSecInvalidAddinFunctionTable = -67716; - -const int errSecInvalidServiceMask = -67717; - -const int errSecModuleNotLoaded = -67718; - -const int errSecInvalidSubServiceID = -67719; - -const int errSecAttributeNotInContext = -67720; - -const int errSecModuleManagerInitializeFailed = -67721; - -const int errSecModuleManagerNotFound = -67722; - -const int errSecEventNotificationCallbackNotFound = -67723; - -const int errSecInputLengthError = -67724; - -const int errSecOutputLengthError = -67725; - -const int errSecPrivilegeNotSupported = -67726; - -const int errSecDeviceError = -67727; - -const int errSecAttachHandleBusy = -67728; - -const int errSecNotLoggedIn = -67729; - -const int errSecAlgorithmMismatch = -67730; - -const int errSecKeyUsageIncorrect = -67731; - -const int errSecKeyBlobTypeIncorrect = -67732; - -const int errSecKeyHeaderInconsistent = -67733; - -const int errSecUnsupportedKeyFormat = -67734; - -const int errSecUnsupportedKeySize = -67735; - -const int errSecInvalidKeyUsageMask = -67736; - -const int errSecUnsupportedKeyUsageMask = -67737; - -const int errSecInvalidKeyAttributeMask = -67738; - -const int errSecUnsupportedKeyAttributeMask = -67739; - -const int errSecInvalidKeyLabel = -67740; - -const int errSecUnsupportedKeyLabel = -67741; - -const int errSecInvalidKeyFormat = -67742; - -const int errSecUnsupportedVectorOfBuffers = -67743; - -const int errSecInvalidInputVector = -67744; - -const int errSecInvalidOutputVector = -67745; - -const int errSecInvalidContext = -67746; - -const int errSecInvalidAlgorithm = -67747; - -const int errSecInvalidAttributeKey = -67748; - -const int errSecMissingAttributeKey = -67749; - -const int errSecInvalidAttributeInitVector = -67750; - -const int errSecMissingAttributeInitVector = -67751; - -const int errSecInvalidAttributeSalt = -67752; - -const int errSecMissingAttributeSalt = -67753; - -const int errSecInvalidAttributePadding = -67754; - -const int errSecMissingAttributePadding = -67755; - -const int errSecInvalidAttributeRandom = -67756; - -const int errSecMissingAttributeRandom = -67757; - -const int errSecInvalidAttributeSeed = -67758; - -const int errSecMissingAttributeSeed = -67759; - -const int errSecInvalidAttributePassphrase = -67760; - -const int errSecMissingAttributePassphrase = -67761; - -const int errSecInvalidAttributeKeyLength = -67762; - -const int errSecMissingAttributeKeyLength = -67763; - -const int errSecInvalidAttributeBlockSize = -67764; - -const int errSecMissingAttributeBlockSize = -67765; - -const int errSecInvalidAttributeOutputSize = -67766; - -const int errSecMissingAttributeOutputSize = -67767; - -const int errSecInvalidAttributeRounds = -67768; - -const int errSecMissingAttributeRounds = -67769; - -const int errSecInvalidAlgorithmParms = -67770; - -const int errSecMissingAlgorithmParms = -67771; - -const int errSecInvalidAttributeLabel = -67772; - -const int errSecMissingAttributeLabel = -67773; - -const int errSecInvalidAttributeKeyType = -67774; - -const int errSecMissingAttributeKeyType = -67775; - -const int errSecInvalidAttributeMode = -67776; - -const int errSecMissingAttributeMode = -67777; - -const int errSecInvalidAttributeEffectiveBits = -67778; - -const int errSecMissingAttributeEffectiveBits = -67779; - -const int errSecInvalidAttributeStartDate = -67780; - -const int errSecMissingAttributeStartDate = -67781; - -const int errSecInvalidAttributeEndDate = -67782; - -const int errSecMissingAttributeEndDate = -67783; - -const int errSecInvalidAttributeVersion = -67784; - -const int errSecMissingAttributeVersion = -67785; - -const int errSecInvalidAttributePrime = -67786; - -const int errSecMissingAttributePrime = -67787; - -const int errSecInvalidAttributeBase = -67788; - -const int errSecMissingAttributeBase = -67789; - -const int errSecInvalidAttributeSubprime = -67790; - -const int errSecMissingAttributeSubprime = -67791; - -const int errSecInvalidAttributeIterationCount = -67792; - -const int errSecMissingAttributeIterationCount = -67793; - -const int errSecInvalidAttributeDLDBHandle = -67794; - -const int errSecMissingAttributeDLDBHandle = -67795; - -const int errSecInvalidAttributeAccessCredentials = -67796; - -const int errSecMissingAttributeAccessCredentials = -67797; - -const int errSecInvalidAttributePublicKeyFormat = -67798; - -const int errSecMissingAttributePublicKeyFormat = -67799; - -const int errSecInvalidAttributePrivateKeyFormat = -67800; - -const int errSecMissingAttributePrivateKeyFormat = -67801; - -const int errSecInvalidAttributeSymmetricKeyFormat = -67802; - -const int errSecMissingAttributeSymmetricKeyFormat = -67803; - -const int errSecInvalidAttributeWrappedKeyFormat = -67804; - -const int errSecMissingAttributeWrappedKeyFormat = -67805; - -const int errSecStagedOperationInProgress = -67806; - -const int errSecStagedOperationNotStarted = -67807; - -const int errSecVerifyFailed = -67808; - -const int errSecQuerySizeUnknown = -67809; - -const int errSecBlockSizeMismatch = -67810; - -const int errSecPublicKeyInconsistent = -67811; - -const int errSecDeviceVerifyFailed = -67812; - -const int errSecInvalidLoginName = -67813; - -const int errSecAlreadyLoggedIn = -67814; - -const int errSecInvalidDigestAlgorithm = -67815; - -const int errSecInvalidCRLGroup = -67816; - -const int errSecCertificateCannotOperate = -67817; - -const int errSecCertificateExpired = -67818; - -const int errSecCertificateNotValidYet = -67819; - -const int errSecCertificateRevoked = -67820; - -const int errSecCertificateSuspended = -67821; - -const int errSecInsufficientCredentials = -67822; - -const int errSecInvalidAction = -67823; - -const int errSecInvalidAuthority = -67824; - -const int errSecVerifyActionFailed = -67825; - -const int errSecInvalidCertAuthority = -67826; - -const int errSecInvalidCRLAuthority = -67827; - -const int errSecInvaldCRLAuthority = -67827; - -const int errSecInvalidCRLEncoding = -67828; - -const int errSecInvalidCRLType = -67829; - -const int errSecInvalidCRL = -67830; - -const int errSecInvalidFormType = -67831; - -const int errSecInvalidID = -67832; - -const int errSecInvalidIdentifier = -67833; - -const int errSecInvalidIndex = -67834; - -const int errSecInvalidPolicyIdentifiers = -67835; - -const int errSecInvalidTimeString = -67836; - -const int errSecInvalidReason = -67837; - -const int errSecInvalidRequestInputs = -67838; - -const int errSecInvalidResponseVector = -67839; - -const int errSecInvalidStopOnPolicy = -67840; - -const int errSecInvalidTuple = -67841; - -const int errSecMultipleValuesUnsupported = -67842; - -const int errSecNotTrusted = -67843; - -const int errSecNoDefaultAuthority = -67844; - -const int errSecRejectedForm = -67845; - -const int errSecRequestLost = -67846; - -const int errSecRequestRejected = -67847; - -const int errSecUnsupportedAddressType = -67848; - -const int errSecUnsupportedService = -67849; - -const int errSecInvalidTupleGroup = -67850; - -const int errSecInvalidBaseACLs = -67851; - -const int errSecInvalidTupleCredentials = -67852; - -const int errSecInvalidTupleCredendtials = -67852; - -const int errSecInvalidEncoding = -67853; - -const int errSecInvalidValidityPeriod = -67854; - -const int errSecInvalidRequestor = -67855; - -const int errSecRequestDescriptor = -67856; - -const int errSecInvalidBundleInfo = -67857; - -const int errSecInvalidCRLIndex = -67858; - -const int errSecNoFieldValues = -67859; - -const int errSecUnsupportedFieldFormat = -67860; - -const int errSecUnsupportedIndexInfo = -67861; - -const int errSecUnsupportedLocality = -67862; - -const int errSecUnsupportedNumAttributes = -67863; - -const int errSecUnsupportedNumIndexes = -67864; - -const int errSecUnsupportedNumRecordTypes = -67865; - -const int errSecFieldSpecifiedMultiple = -67866; - -const int errSecIncompatibleFieldFormat = -67867; - -const int errSecInvalidParsingModule = -67868; - -const int errSecDatabaseLocked = -67869; - -const int errSecDatastoreIsOpen = -67870; - -const int errSecMissingValue = -67871; - -const int errSecUnsupportedQueryLimits = -67872; - -const int errSecUnsupportedNumSelectionPreds = -67873; - -const int errSecUnsupportedOperator = -67874; - -const int errSecInvalidDBLocation = -67875; - -const int errSecInvalidAccessRequest = -67876; - -const int errSecInvalidIndexInfo = -67877; - -const int errSecInvalidNewOwner = -67878; - -const int errSecInvalidModifyMode = -67879; - -const int errSecMissingRequiredExtension = -67880; - -const int errSecExtendedKeyUsageNotCritical = -67881; - -const int errSecTimestampMissing = -67882; - -const int errSecTimestampInvalid = -67883; - -const int errSecTimestampNotTrusted = -67884; - -const int errSecTimestampServiceNotAvailable = -67885; - -const int errSecTimestampBadAlg = -67886; - -const int errSecTimestampBadRequest = -67887; - -const int errSecTimestampBadDataFormat = -67888; - -const int errSecTimestampTimeNotAvailable = -67889; - -const int errSecTimestampUnacceptedPolicy = -67890; - -const int errSecTimestampUnacceptedExtension = -67891; - -const int errSecTimestampAddInfoNotAvailable = -67892; - -const int errSecTimestampSystemFailure = -67893; - -const int errSecSigningTimeMissing = -67894; - -const int errSecTimestampRejection = -67895; - -const int errSecTimestampWaiting = -67896; - -const int errSecTimestampRevocationWarning = -67897; - -const int errSecTimestampRevocationNotification = -67898; - -const int errSecCertificatePolicyNotAllowed = -67899; - -const int errSecCertificateNameNotAllowed = -67900; - -const int errSecCertificateValidityPeriodTooLong = -67901; - -const int errSecCertificateIsCA = -67902; - -const int errSecCertificateDuplicateExtension = -67903; - -const int errSecMissingQualifiedCertStatement = -67904; - -const int errSSLProtocol = -9800; - -const int errSSLNegotiation = -9801; - -const int errSSLFatalAlert = -9802; - -const int errSSLWouldBlock = -9803; - -const int errSSLSessionNotFound = -9804; - -const int errSSLClosedGraceful = -9805; - -const int errSSLClosedAbort = -9806; - -const int errSSLXCertChainInvalid = -9807; - -const int errSSLBadCert = -9808; - -const int errSSLCrypto = -9809; - -const int errSSLInternal = -9810; - -const int errSSLModuleAttach = -9811; - -const int errSSLUnknownRootCert = -9812; - -const int errSSLNoRootCert = -9813; - -const int errSSLCertExpired = -9814; - -const int errSSLCertNotYetValid = -9815; - -const int errSSLClosedNoNotify = -9816; - -const int errSSLBufferOverflow = -9817; - -const int errSSLBadCipherSuite = -9818; - -const int errSSLPeerUnexpectedMsg = -9819; - -const int errSSLPeerBadRecordMac = -9820; - -const int errSSLPeerDecryptionFail = -9821; - -const int errSSLPeerRecordOverflow = -9822; - -const int errSSLPeerDecompressFail = -9823; - -const int errSSLPeerHandshakeFail = -9824; - -const int errSSLPeerBadCert = -9825; - -const int errSSLPeerUnsupportedCert = -9826; - -const int errSSLPeerCertRevoked = -9827; - -const int errSSLPeerCertExpired = -9828; - -const int errSSLPeerCertUnknown = -9829; - -const int errSSLIllegalParam = -9830; - -const int errSSLPeerUnknownCA = -9831; - -const int errSSLPeerAccessDenied = -9832; - -const int errSSLPeerDecodeError = -9833; - -const int errSSLPeerDecryptError = -9834; - -const int errSSLPeerExportRestriction = -9835; - -const int errSSLPeerProtocolVersion = -9836; - -const int errSSLPeerInsufficientSecurity = -9837; - -const int errSSLPeerInternalError = -9838; - -const int errSSLPeerUserCancelled = -9839; - -const int errSSLPeerNoRenegotiation = -9840; - -const int errSSLPeerAuthCompleted = -9841; - -const int errSSLClientCertRequested = -9842; - -const int errSSLHostNameMismatch = -9843; - -const int errSSLConnectionRefused = -9844; - -const int errSSLDecryptionFail = -9845; - -const int errSSLBadRecordMac = -9846; - -const int errSSLRecordOverflow = -9847; - -const int errSSLBadConfiguration = -9848; - -const int errSSLUnexpectedRecord = -9849; - -const int errSSLWeakPeerEphemeralDHKey = -9850; - -const int errSSLClientHelloReceived = -9851; - -const int errSSLTransportReset = -9852; - -const int errSSLNetworkTimeout = -9853; - -const int errSSLConfigurationFailed = -9854; - -const int errSSLUnsupportedExtension = -9855; - -const int errSSLUnexpectedMessage = -9856; - -const int errSSLDecompressFail = -9857; - -const int errSSLHandshakeFail = -9858; - -const int errSSLDecodeError = -9859; - -const int errSSLInappropriateFallback = -9860; - -const int errSSLMissingExtension = -9861; - -const int errSSLBadCertificateStatusResponse = -9862; - -const int errSSLCertificateRequired = -9863; - -const int errSSLUnknownPSKIdentity = -9864; - -const int errSSLUnrecognizedName = -9865; - -const int errSSLATSViolation = -9880; - -const int errSSLATSMinimumVersionViolation = -9881; - -const int errSSLATSCiphersuiteViolation = -9882; - -const int errSSLATSMinimumKeySizeViolation = -9883; - -const int errSSLATSLeafCertificateHashAlgorithmViolation = -9884; - -const int errSSLATSCertificateHashAlgorithmViolation = -9885; - -const int errSSLATSCertificateTrustViolation = -9886; - -const int errSSLEarlyDataRejected = -9890; - -const int OSUnknownByteOrder = 0; - -const int OSLittleEndian = 1; - -const int OSBigEndian = 2; - -const int kCFNotificationDeliverImmediately = 1; - -const int kCFNotificationPostToAllSessions = 2; - -const int kCFCalendarComponentsWrap = 1; - -const int kCFSocketAutomaticallyReenableReadCallBack = 1; - -const int kCFSocketAutomaticallyReenableAcceptCallBack = 2; - -const int kCFSocketAutomaticallyReenableDataCallBack = 3; - -const int kCFSocketAutomaticallyReenableWriteCallBack = 8; - -const int kCFSocketLeaveErrors = 64; - -const int kCFSocketCloseOnInvalidate = 128; - -const int DISPATCH_WALLTIME_NOW = -2; - -const int kCFPropertyListReadCorruptError = 3840; - -const int kCFPropertyListReadUnknownVersionError = 3841; - -const int kCFPropertyListReadStreamError = 3842; - -const int kCFPropertyListWriteStreamError = 3851; - -const int kCFBundleExecutableArchitectureI386 = 7; - -const int kCFBundleExecutableArchitecturePPC = 18; - -const int kCFBundleExecutableArchitectureX86_64 = 16777223; - -const int kCFBundleExecutableArchitecturePPC64 = 16777234; - -const int kCFBundleExecutableArchitectureARM64 = 16777228; - -const int kCFMessagePortSuccess = 0; - -const int kCFMessagePortSendTimeout = -1; - -const int kCFMessagePortReceiveTimeout = -2; - -const int kCFMessagePortIsInvalid = -3; - -const int kCFMessagePortTransportError = -4; - -const int kCFMessagePortBecameInvalidError = -5; - -const int kCFStringTokenizerUnitWord = 0; - -const int kCFStringTokenizerUnitSentence = 1; - -const int kCFStringTokenizerUnitParagraph = 2; - -const int kCFStringTokenizerUnitLineBreak = 3; - -const int kCFStringTokenizerUnitWordBoundary = 4; - -const int kCFStringTokenizerAttributeLatinTranscription = 65536; - -const int kCFStringTokenizerAttributeLanguage = 131072; - -const int kCFFileDescriptorReadCallBack = 1; - -const int kCFFileDescriptorWriteCallBack = 2; - -const int kCFUserNotificationStopAlertLevel = 0; - -const int kCFUserNotificationNoteAlertLevel = 1; - -const int kCFUserNotificationCautionAlertLevel = 2; - -const int kCFUserNotificationPlainAlertLevel = 3; - -const int kCFUserNotificationDefaultResponse = 0; - -const int kCFUserNotificationAlternateResponse = 1; - -const int kCFUserNotificationOtherResponse = 2; - -const int kCFUserNotificationCancelResponse = 3; - -const int kCFUserNotificationNoDefaultButtonFlag = 32; - -const int kCFUserNotificationUseRadioButtonsFlag = 64; - -const int kCFXMLNodeCurrentVersion = 1; - -const int CSSM_INVALID_HANDLE = 0; - -const int CSSM_FALSE = 0; - -const int CSSM_TRUE = 1; - -const int CSSM_OK = 0; - -const int CSSM_MODULE_STRING_SIZE = 64; - -const int CSSM_KEY_HIERARCHY_NONE = 0; - -const int CSSM_KEY_HIERARCHY_INTEG = 1; - -const int CSSM_KEY_HIERARCHY_EXPORT = 2; - -const int CSSM_PVC_NONE = 0; - -const int CSSM_PVC_APP = 1; - -const int CSSM_PVC_SP = 2; - -const int CSSM_PRIVILEGE_SCOPE_NONE = 0; - -const int CSSM_PRIVILEGE_SCOPE_PROCESS = 1; - -const int CSSM_PRIVILEGE_SCOPE_THREAD = 2; - -const int CSSM_SERVICE_CSSM = 1; - -const int CSSM_SERVICE_CSP = 2; - -const int CSSM_SERVICE_DL = 4; - -const int CSSM_SERVICE_CL = 8; - -const int CSSM_SERVICE_TP = 16; - -const int CSSM_SERVICE_AC = 32; - -const int CSSM_SERVICE_KR = 64; - -const int CSSM_NOTIFY_INSERT = 1; - -const int CSSM_NOTIFY_REMOVE = 2; - -const int CSSM_NOTIFY_FAULT = 3; - -const int CSSM_ATTACH_READ_ONLY = 1; - -const int CSSM_USEE_LAST = 255; - -const int CSSM_USEE_NONE = 0; - -const int CSSM_USEE_DOMESTIC = 1; - -const int CSSM_USEE_FINANCIAL = 2; - -const int CSSM_USEE_KRLE = 3; - -const int CSSM_USEE_KRENT = 4; - -const int CSSM_USEE_SSL = 5; - -const int CSSM_USEE_AUTHENTICATION = 6; - -const int CSSM_USEE_KEYEXCH = 7; - -const int CSSM_USEE_MEDICAL = 8; - -const int CSSM_USEE_INSURANCE = 9; - -const int CSSM_USEE_WEAK = 10; - -const int CSSM_ADDR_NONE = 0; - -const int CSSM_ADDR_CUSTOM = 1; - -const int CSSM_ADDR_URL = 2; - -const int CSSM_ADDR_SOCKADDR = 3; - -const int CSSM_ADDR_NAME = 4; - -const int CSSM_NET_PROTO_NONE = 0; - -const int CSSM_NET_PROTO_CUSTOM = 1; - -const int CSSM_NET_PROTO_UNSPECIFIED = 2; - -const int CSSM_NET_PROTO_LDAP = 3; - -const int CSSM_NET_PROTO_LDAPS = 4; - -const int CSSM_NET_PROTO_LDAPNS = 5; - -const int CSSM_NET_PROTO_X500DAP = 6; - -const int CSSM_NET_PROTO_FTP = 7; - -const int CSSM_NET_PROTO_FTPS = 8; - -const int CSSM_NET_PROTO_OCSP = 9; - -const int CSSM_NET_PROTO_CMP = 10; - -const int CSSM_NET_PROTO_CMPS = 11; - -const int CSSM_WORDID__UNK_ = -1; - -const int CSSM_WORDID__NLU_ = 0; - -const int CSSM_WORDID__STAR_ = 1; - -const int CSSM_WORDID_A = 2; - -const int CSSM_WORDID_ACL = 3; - -const int CSSM_WORDID_ALPHA = 4; - -const int CSSM_WORDID_B = 5; - -const int CSSM_WORDID_BER = 6; - -const int CSSM_WORDID_BINARY = 7; - -const int CSSM_WORDID_BIOMETRIC = 8; - -const int CSSM_WORDID_C = 9; - -const int CSSM_WORDID_CANCELED = 10; - -const int CSSM_WORDID_CERT = 11; - -const int CSSM_WORDID_COMMENT = 12; - -const int CSSM_WORDID_CRL = 13; - -const int CSSM_WORDID_CUSTOM = 14; - -const int CSSM_WORDID_D = 15; - -const int CSSM_WORDID_DATE = 16; - -const int CSSM_WORDID_DB_DELETE = 17; - -const int CSSM_WORDID_DB_EXEC_STORED_QUERY = 18; - -const int CSSM_WORDID_DB_INSERT = 19; - -const int CSSM_WORDID_DB_MODIFY = 20; - -const int CSSM_WORDID_DB_READ = 21; - -const int CSSM_WORDID_DBS_CREATE = 22; - -const int CSSM_WORDID_DBS_DELETE = 23; - -const int CSSM_WORDID_DECRYPT = 24; - -const int CSSM_WORDID_DELETE = 25; - -const int CSSM_WORDID_DELTA_CRL = 26; - -const int CSSM_WORDID_DER = 27; - -const int CSSM_WORDID_DERIVE = 28; - -const int CSSM_WORDID_DISPLAY = 29; - -const int CSSM_WORDID_DO = 30; - -const int CSSM_WORDID_DSA = 31; - -const int CSSM_WORDID_DSA_SHA1 = 32; - -const int CSSM_WORDID_E = 33; - -const int CSSM_WORDID_ELGAMAL = 34; - -const int CSSM_WORDID_ENCRYPT = 35; - -const int CSSM_WORDID_ENTRY = 36; - -const int CSSM_WORDID_EXPORT_CLEAR = 37; - -const int CSSM_WORDID_EXPORT_WRAPPED = 38; - -const int CSSM_WORDID_G = 39; - -const int CSSM_WORDID_GE = 40; - -const int CSSM_WORDID_GENKEY = 41; - -const int CSSM_WORDID_HASH = 42; - -const int CSSM_WORDID_HASHED_PASSWORD = 43; - -const int CSSM_WORDID_HASHED_SUBJECT = 44; - -const int CSSM_WORDID_HAVAL = 45; - -const int CSSM_WORDID_IBCHASH = 46; - -const int CSSM_WORDID_IMPORT_CLEAR = 47; - -const int CSSM_WORDID_IMPORT_WRAPPED = 48; - -const int CSSM_WORDID_INTEL = 49; - -const int CSSM_WORDID_ISSUER = 50; - -const int CSSM_WORDID_ISSUER_INFO = 51; - -const int CSSM_WORDID_K_OF_N = 52; - -const int CSSM_WORDID_KEA = 53; - -const int CSSM_WORDID_KEYHOLDER = 54; - -const int CSSM_WORDID_L = 55; - -const int CSSM_WORDID_LE = 56; - -const int CSSM_WORDID_LOGIN = 57; - -const int CSSM_WORDID_LOGIN_NAME = 58; - -const int CSSM_WORDID_MAC = 59; - -const int CSSM_WORDID_MD2 = 60; - -const int CSSM_WORDID_MD2WITHRSA = 61; - -const int CSSM_WORDID_MD4 = 62; - -const int CSSM_WORDID_MD5 = 63; - -const int CSSM_WORDID_MD5WITHRSA = 64; - -const int CSSM_WORDID_N = 65; - -const int CSSM_WORDID_NAME = 66; - -const int CSSM_WORDID_NDR = 67; - -const int CSSM_WORDID_NHASH = 68; - -const int CSSM_WORDID_NOT_AFTER = 69; - -const int CSSM_WORDID_NOT_BEFORE = 70; - -const int CSSM_WORDID_NULL = 71; - -const int CSSM_WORDID_NUMERIC = 72; - -const int CSSM_WORDID_OBJECT_HASH = 73; - -const int CSSM_WORDID_ONE_TIME = 74; - -const int CSSM_WORDID_ONLINE = 75; - -const int CSSM_WORDID_OWNER = 76; - -const int CSSM_WORDID_P = 77; - -const int CSSM_WORDID_PAM_NAME = 78; - -const int CSSM_WORDID_PASSWORD = 79; - -const int CSSM_WORDID_PGP = 80; - -const int CSSM_WORDID_PREFIX = 81; - -const int CSSM_WORDID_PRIVATE_KEY = 82; - -const int CSSM_WORDID_PROMPTED_BIOMETRIC = 83; - -const int CSSM_WORDID_PROMPTED_PASSWORD = 84; - -const int CSSM_WORDID_PROPAGATE = 85; - -const int CSSM_WORDID_PROTECTED_BIOMETRIC = 86; - -const int CSSM_WORDID_PROTECTED_PASSWORD = 87; - -const int CSSM_WORDID_PROTECTED_PIN = 88; - -const int CSSM_WORDID_PUBLIC_KEY = 89; - -const int CSSM_WORDID_PUBLIC_KEY_FROM_CERT = 90; - -const int CSSM_WORDID_Q = 91; - -const int CSSM_WORDID_RANGE = 92; - -const int CSSM_WORDID_REVAL = 93; - -const int CSSM_WORDID_RIPEMAC = 94; - -const int CSSM_WORDID_RIPEMD = 95; - -const int CSSM_WORDID_RIPEMD160 = 96; - -const int CSSM_WORDID_RSA = 97; - -const int CSSM_WORDID_RSA_ISO9796 = 98; - -const int CSSM_WORDID_RSA_PKCS = 99; - -const int CSSM_WORDID_RSA_PKCS_MD5 = 100; - -const int CSSM_WORDID_RSA_PKCS_SHA1 = 101; - -const int CSSM_WORDID_RSA_PKCS1 = 102; - -const int CSSM_WORDID_RSA_PKCS1_MD5 = 103; - -const int CSSM_WORDID_RSA_PKCS1_SHA1 = 104; - -const int CSSM_WORDID_RSA_PKCS1_SIG = 105; - -const int CSSM_WORDID_RSA_RAW = 106; - -const int CSSM_WORDID_SDSIV1 = 107; - -const int CSSM_WORDID_SEQUENCE = 108; - -const int CSSM_WORDID_SET = 109; - -const int CSSM_WORDID_SEXPR = 110; - -const int CSSM_WORDID_SHA1 = 111; - -const int CSSM_WORDID_SHA1WITHDSA = 112; - -const int CSSM_WORDID_SHA1WITHECDSA = 113; - -const int CSSM_WORDID_SHA1WITHRSA = 114; - -const int CSSM_WORDID_SIGN = 115; - -const int CSSM_WORDID_SIGNATURE = 116; - -const int CSSM_WORDID_SIGNED_NONCE = 117; - -const int CSSM_WORDID_SIGNED_SECRET = 118; - -const int CSSM_WORDID_SPKI = 119; - -const int CSSM_WORDID_SUBJECT = 120; - -const int CSSM_WORDID_SUBJECT_INFO = 121; - -const int CSSM_WORDID_TAG = 122; - -const int CSSM_WORDID_THRESHOLD = 123; - -const int CSSM_WORDID_TIME = 124; - -const int CSSM_WORDID_URI = 125; - -const int CSSM_WORDID_VERSION = 126; - -const int CSSM_WORDID_X509_ATTRIBUTE = 127; - -const int CSSM_WORDID_X509V1 = 128; - -const int CSSM_WORDID_X509V2 = 129; - -const int CSSM_WORDID_X509V3 = 130; - -const int CSSM_WORDID_X9_ATTRIBUTE = 131; - -const int CSSM_WORDID_VENDOR_START = 65536; - -const int CSSM_WORDID_VENDOR_END = 2147418112; - -const int CSSM_LIST_ELEMENT_DATUM = 0; - -const int CSSM_LIST_ELEMENT_SUBLIST = 1; - -const int CSSM_LIST_ELEMENT_WORDID = 2; - -const int CSSM_LIST_TYPE_UNKNOWN = 0; - -const int CSSM_LIST_TYPE_CUSTOM = 1; - -const int CSSM_LIST_TYPE_SEXPR = 2; - -const int CSSM_SAMPLE_TYPE_PASSWORD = 79; - -const int CSSM_SAMPLE_TYPE_HASHED_PASSWORD = 43; - -const int CSSM_SAMPLE_TYPE_PROTECTED_PASSWORD = 87; - -const int CSSM_SAMPLE_TYPE_PROMPTED_PASSWORD = 84; - -const int CSSM_SAMPLE_TYPE_SIGNED_NONCE = 117; - -const int CSSM_SAMPLE_TYPE_SIGNED_SECRET = 118; - -const int CSSM_SAMPLE_TYPE_BIOMETRIC = 8; - -const int CSSM_SAMPLE_TYPE_PROTECTED_BIOMETRIC = 86; - -const int CSSM_SAMPLE_TYPE_PROMPTED_BIOMETRIC = 83; - -const int CSSM_SAMPLE_TYPE_THRESHOLD = 123; - -const int CSSM_CERT_UNKNOWN = 0; - -const int CSSM_CERT_X_509v1 = 1; - -const int CSSM_CERT_X_509v2 = 2; - -const int CSSM_CERT_X_509v3 = 3; - -const int CSSM_CERT_PGP = 4; - -const int CSSM_CERT_SPKI = 5; - -const int CSSM_CERT_SDSIv1 = 6; - -const int CSSM_CERT_Intel = 8; - -const int CSSM_CERT_X_509_ATTRIBUTE = 9; - -const int CSSM_CERT_X9_ATTRIBUTE = 10; - -const int CSSM_CERT_TUPLE = 11; - -const int CSSM_CERT_ACL_ENTRY = 12; - -const int CSSM_CERT_MULTIPLE = 32766; - -const int CSSM_CERT_LAST = 32767; - -const int CSSM_CL_CUSTOM_CERT_TYPE = 32768; - -const int CSSM_CERT_ENCODING_UNKNOWN = 0; - -const int CSSM_CERT_ENCODING_CUSTOM = 1; - -const int CSSM_CERT_ENCODING_BER = 2; - -const int CSSM_CERT_ENCODING_DER = 3; - -const int CSSM_CERT_ENCODING_NDR = 4; - -const int CSSM_CERT_ENCODING_SEXPR = 5; - -const int CSSM_CERT_ENCODING_PGP = 6; - -const int CSSM_CERT_ENCODING_MULTIPLE = 32766; - -const int CSSM_CERT_ENCODING_LAST = 32767; - -const int CSSM_CL_CUSTOM_CERT_ENCODING = 32768; - -const int CSSM_CERT_PARSE_FORMAT_NONE = 0; - -const int CSSM_CERT_PARSE_FORMAT_CUSTOM = 1; - -const int CSSM_CERT_PARSE_FORMAT_SEXPR = 2; - -const int CSSM_CERT_PARSE_FORMAT_COMPLEX = 3; - -const int CSSM_CERT_PARSE_FORMAT_OID_NAMED = 4; - -const int CSSM_CERT_PARSE_FORMAT_TUPLE = 5; - -const int CSSM_CERT_PARSE_FORMAT_MULTIPLE = 32766; - -const int CSSM_CERT_PARSE_FORMAT_LAST = 32767; - -const int CSSM_CL_CUSTOM_CERT_PARSE_FORMAT = 32768; - -const int CSSM_CERTGROUP_DATA = 0; - -const int CSSM_CERTGROUP_ENCODED_CERT = 1; - -const int CSSM_CERTGROUP_PARSED_CERT = 2; - -const int CSSM_CERTGROUP_CERT_PAIR = 3; - -const int CSSM_ACL_SUBJECT_TYPE_ANY = 1; - -const int CSSM_ACL_SUBJECT_TYPE_THRESHOLD = 123; - -const int CSSM_ACL_SUBJECT_TYPE_PASSWORD = 79; - -const int CSSM_ACL_SUBJECT_TYPE_PROTECTED_PASSWORD = 87; - -const int CSSM_ACL_SUBJECT_TYPE_PROMPTED_PASSWORD = 84; - -const int CSSM_ACL_SUBJECT_TYPE_PUBLIC_KEY = 89; - -const int CSSM_ACL_SUBJECT_TYPE_HASHED_SUBJECT = 44; - -const int CSSM_ACL_SUBJECT_TYPE_BIOMETRIC = 8; - -const int CSSM_ACL_SUBJECT_TYPE_PROTECTED_BIOMETRIC = 86; - -const int CSSM_ACL_SUBJECT_TYPE_PROMPTED_BIOMETRIC = 83; - -const int CSSM_ACL_SUBJECT_TYPE_LOGIN_NAME = 58; - -const int CSSM_ACL_SUBJECT_TYPE_EXT_PAM_NAME = 78; - -const int CSSM_ACL_AUTHORIZATION_TAG_VENDOR_DEFINED_START = 65536; - -const int CSSM_ACL_AUTHORIZATION_ANY = 1; - -const int CSSM_ACL_AUTHORIZATION_LOGIN = 57; - -const int CSSM_ACL_AUTHORIZATION_GENKEY = 41; - -const int CSSM_ACL_AUTHORIZATION_DELETE = 25; - -const int CSSM_ACL_AUTHORIZATION_EXPORT_WRAPPED = 38; - -const int CSSM_ACL_AUTHORIZATION_EXPORT_CLEAR = 37; - -const int CSSM_ACL_AUTHORIZATION_IMPORT_WRAPPED = 48; - -const int CSSM_ACL_AUTHORIZATION_IMPORT_CLEAR = 47; - -const int CSSM_ACL_AUTHORIZATION_SIGN = 115; - -const int CSSM_ACL_AUTHORIZATION_ENCRYPT = 35; - -const int CSSM_ACL_AUTHORIZATION_DECRYPT = 24; - -const int CSSM_ACL_AUTHORIZATION_MAC = 59; - -const int CSSM_ACL_AUTHORIZATION_DERIVE = 28; - -const int CSSM_ACL_AUTHORIZATION_DBS_CREATE = 22; - -const int CSSM_ACL_AUTHORIZATION_DBS_DELETE = 23; - -const int CSSM_ACL_AUTHORIZATION_DB_READ = 21; - -const int CSSM_ACL_AUTHORIZATION_DB_INSERT = 19; - -const int CSSM_ACL_AUTHORIZATION_DB_MODIFY = 20; - -const int CSSM_ACL_AUTHORIZATION_DB_DELETE = 17; - -const int CSSM_ACL_EDIT_MODE_ADD = 1; - -const int CSSM_ACL_EDIT_MODE_DELETE = 2; - -const int CSSM_ACL_EDIT_MODE_REPLACE = 3; - -const int CSSM_KEYHEADER_VERSION = 2; - -const int CSSM_KEYBLOB_RAW = 0; - -const int CSSM_KEYBLOB_REFERENCE = 2; - -const int CSSM_KEYBLOB_WRAPPED = 3; - -const int CSSM_KEYBLOB_OTHER = -1; - -const int CSSM_KEYBLOB_RAW_FORMAT_NONE = 0; - -const int CSSM_KEYBLOB_RAW_FORMAT_PKCS1 = 1; - -const int CSSM_KEYBLOB_RAW_FORMAT_PKCS3 = 2; - -const int CSSM_KEYBLOB_RAW_FORMAT_MSCAPI = 3; - -const int CSSM_KEYBLOB_RAW_FORMAT_PGP = 4; - -const int CSSM_KEYBLOB_RAW_FORMAT_FIPS186 = 5; - -const int CSSM_KEYBLOB_RAW_FORMAT_BSAFE = 6; - -const int CSSM_KEYBLOB_RAW_FORMAT_CCA = 9; - -const int CSSM_KEYBLOB_RAW_FORMAT_PKCS8 = 10; - -const int CSSM_KEYBLOB_RAW_FORMAT_SPKI = 11; - -const int CSSM_KEYBLOB_RAW_FORMAT_OCTET_STRING = 12; - -const int CSSM_KEYBLOB_RAW_FORMAT_OTHER = -1; - -const int CSSM_KEYBLOB_WRAPPED_FORMAT_NONE = 0; - -const int CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS8 = 1; - -const int CSSM_KEYBLOB_WRAPPED_FORMAT_PKCS7 = 2; - -const int CSSM_KEYBLOB_WRAPPED_FORMAT_MSCAPI = 3; - -const int CSSM_KEYBLOB_WRAPPED_FORMAT_OTHER = -1; - -const int CSSM_KEYBLOB_REF_FORMAT_INTEGER = 0; - -const int CSSM_KEYBLOB_REF_FORMAT_STRING = 1; - -const int CSSM_KEYBLOB_REF_FORMAT_SPKI = 2; - -const int CSSM_KEYBLOB_REF_FORMAT_OTHER = -1; - -const int CSSM_KEYCLASS_PUBLIC_KEY = 0; - -const int CSSM_KEYCLASS_PRIVATE_KEY = 1; - -const int CSSM_KEYCLASS_SESSION_KEY = 2; - -const int CSSM_KEYCLASS_SECRET_PART = 3; - -const int CSSM_KEYCLASS_OTHER = -1; - -const int CSSM_KEYATTR_RETURN_DEFAULT = 0; - -const int CSSM_KEYATTR_RETURN_DATA = 268435456; - -const int CSSM_KEYATTR_RETURN_REF = 536870912; - -const int CSSM_KEYATTR_RETURN_NONE = 1073741824; - -const int CSSM_KEYATTR_PERMANENT = 1; - -const int CSSM_KEYATTR_PRIVATE = 2; - -const int CSSM_KEYATTR_MODIFIABLE = 4; - -const int CSSM_KEYATTR_SENSITIVE = 8; - -const int CSSM_KEYATTR_EXTRACTABLE = 32; - -const int CSSM_KEYATTR_ALWAYS_SENSITIVE = 16; - -const int CSSM_KEYATTR_NEVER_EXTRACTABLE = 64; - -const int CSSM_KEYUSE_ANY = -2147483648; - -const int CSSM_KEYUSE_ENCRYPT = 1; - -const int CSSM_KEYUSE_DECRYPT = 2; - -const int CSSM_KEYUSE_SIGN = 4; - -const int CSSM_KEYUSE_VERIFY = 8; - -const int CSSM_KEYUSE_SIGN_RECOVER = 16; - -const int CSSM_KEYUSE_VERIFY_RECOVER = 32; - -const int CSSM_KEYUSE_WRAP = 64; - -const int CSSM_KEYUSE_UNWRAP = 128; - -const int CSSM_KEYUSE_DERIVE = 256; - -const int CSSM_ALGID_NONE = 0; - -const int CSSM_ALGID_CUSTOM = 1; - -const int CSSM_ALGID_DH = 2; - -const int CSSM_ALGID_PH = 3; - -const int CSSM_ALGID_KEA = 4; - -const int CSSM_ALGID_MD2 = 5; - -const int CSSM_ALGID_MD4 = 6; - -const int CSSM_ALGID_MD5 = 7; - -const int CSSM_ALGID_SHA1 = 8; - -const int CSSM_ALGID_NHASH = 9; - -const int CSSM_ALGID_HAVAL = 10; - -const int CSSM_ALGID_RIPEMD = 11; - -const int CSSM_ALGID_IBCHASH = 12; - -const int CSSM_ALGID_RIPEMAC = 13; - -const int CSSM_ALGID_DES = 14; - -const int CSSM_ALGID_DESX = 15; - -const int CSSM_ALGID_RDES = 16; - -const int CSSM_ALGID_3DES_3KEY_EDE = 17; - -const int CSSM_ALGID_3DES_2KEY_EDE = 18; - -const int CSSM_ALGID_3DES_1KEY_EEE = 19; - -const int CSSM_ALGID_3DES_3KEY = 17; - -const int CSSM_ALGID_3DES_3KEY_EEE = 20; - -const int CSSM_ALGID_3DES_2KEY = 18; - -const int CSSM_ALGID_3DES_2KEY_EEE = 21; - -const int CSSM_ALGID_3DES_1KEY = 20; - -const int CSSM_ALGID_IDEA = 22; - -const int CSSM_ALGID_RC2 = 23; - -const int CSSM_ALGID_RC5 = 24; - -const int CSSM_ALGID_RC4 = 25; - -const int CSSM_ALGID_SEAL = 26; - -const int CSSM_ALGID_CAST = 27; - -const int CSSM_ALGID_BLOWFISH = 28; - -const int CSSM_ALGID_SKIPJACK = 29; - -const int CSSM_ALGID_LUCIFER = 30; - -const int CSSM_ALGID_MADRYGA = 31; - -const int CSSM_ALGID_FEAL = 32; - -const int CSSM_ALGID_REDOC = 33; - -const int CSSM_ALGID_REDOC3 = 34; - -const int CSSM_ALGID_LOKI = 35; - -const int CSSM_ALGID_KHUFU = 36; - -const int CSSM_ALGID_KHAFRE = 37; - -const int CSSM_ALGID_MMB = 38; - -const int CSSM_ALGID_GOST = 39; - -const int CSSM_ALGID_SAFER = 40; - -const int CSSM_ALGID_CRAB = 41; - -const int CSSM_ALGID_RSA = 42; - -const int CSSM_ALGID_DSA = 43; - -const int CSSM_ALGID_MD5WithRSA = 44; - -const int CSSM_ALGID_MD2WithRSA = 45; - -const int CSSM_ALGID_ElGamal = 46; - -const int CSSM_ALGID_MD2Random = 47; - -const int CSSM_ALGID_MD5Random = 48; - -const int CSSM_ALGID_SHARandom = 49; - -const int CSSM_ALGID_DESRandom = 50; - -const int CSSM_ALGID_SHA1WithRSA = 51; - -const int CSSM_ALGID_CDMF = 52; - -const int CSSM_ALGID_CAST3 = 53; - -const int CSSM_ALGID_CAST5 = 54; - -const int CSSM_ALGID_GenericSecret = 55; - -const int CSSM_ALGID_ConcatBaseAndKey = 56; - -const int CSSM_ALGID_ConcatKeyAndBase = 57; - -const int CSSM_ALGID_ConcatBaseAndData = 58; - -const int CSSM_ALGID_ConcatDataAndBase = 59; - -const int CSSM_ALGID_XORBaseAndData = 60; - -const int CSSM_ALGID_ExtractFromKey = 61; - -const int CSSM_ALGID_SSL3PrePrimaryGen = 62; - -const int CSSM_ALGID_SSL3PreMasterGen = 62; - -const int CSSM_ALGID_SSL3PrimaryDerive = 63; - -const int CSSM_ALGID_SSL3MasterDerive = 63; - -const int CSSM_ALGID_SSL3KeyAndMacDerive = 64; - -const int CSSM_ALGID_SSL3MD5_MAC = 65; - -const int CSSM_ALGID_SSL3SHA1_MAC = 66; - -const int CSSM_ALGID_PKCS5_PBKDF1_MD5 = 67; - -const int CSSM_ALGID_PKCS5_PBKDF1_MD2 = 68; - -const int CSSM_ALGID_PKCS5_PBKDF1_SHA1 = 69; - -const int CSSM_ALGID_WrapLynks = 70; - -const int CSSM_ALGID_WrapSET_OAEP = 71; - -const int CSSM_ALGID_BATON = 72; - -const int CSSM_ALGID_ECDSA = 73; - -const int CSSM_ALGID_MAYFLY = 74; - -const int CSSM_ALGID_JUNIPER = 75; - -const int CSSM_ALGID_FASTHASH = 76; - -const int CSSM_ALGID_3DES = 77; - -const int CSSM_ALGID_SSL3MD5 = 78; - -const int CSSM_ALGID_SSL3SHA1 = 79; - -const int CSSM_ALGID_FortezzaTimestamp = 80; - -const int CSSM_ALGID_SHA1WithDSA = 81; - -const int CSSM_ALGID_SHA1WithECDSA = 82; - -const int CSSM_ALGID_DSA_BSAFE = 83; - -const int CSSM_ALGID_ECDH = 84; - -const int CSSM_ALGID_ECMQV = 85; - -const int CSSM_ALGID_PKCS12_SHA1_PBE = 86; - -const int CSSM_ALGID_ECNRA = 87; - -const int CSSM_ALGID_SHA1WithECNRA = 88; - -const int CSSM_ALGID_ECES = 89; - -const int CSSM_ALGID_ECAES = 90; - -const int CSSM_ALGID_SHA1HMAC = 91; - -const int CSSM_ALGID_FIPS186Random = 92; - -const int CSSM_ALGID_ECC = 93; - -const int CSSM_ALGID_MQV = 94; - -const int CSSM_ALGID_NRA = 95; - -const int CSSM_ALGID_IntelPlatformRandom = 96; - -const int CSSM_ALGID_UTC = 97; - -const int CSSM_ALGID_HAVAL3 = 98; - -const int CSSM_ALGID_HAVAL4 = 99; - -const int CSSM_ALGID_HAVAL5 = 100; - -const int CSSM_ALGID_TIGER = 101; - -const int CSSM_ALGID_MD5HMAC = 102; - -const int CSSM_ALGID_PKCS5_PBKDF2 = 103; - -const int CSSM_ALGID_RUNNING_COUNTER = 104; - -const int CSSM_ALGID_LAST = 2147483647; - -const int CSSM_ALGID_VENDOR_DEFINED = -2147483648; - -const int CSSM_ALGMODE_NONE = 0; - -const int CSSM_ALGMODE_CUSTOM = 1; - -const int CSSM_ALGMODE_ECB = 2; - -const int CSSM_ALGMODE_ECBPad = 3; - -const int CSSM_ALGMODE_CBC = 4; - -const int CSSM_ALGMODE_CBC_IV8 = 5; - -const int CSSM_ALGMODE_CBCPadIV8 = 6; - -const int CSSM_ALGMODE_CFB = 7; - -const int CSSM_ALGMODE_CFB_IV8 = 8; - -const int CSSM_ALGMODE_CFBPadIV8 = 9; - -const int CSSM_ALGMODE_OFB = 10; - -const int CSSM_ALGMODE_OFB_IV8 = 11; - -const int CSSM_ALGMODE_OFBPadIV8 = 12; - -const int CSSM_ALGMODE_COUNTER = 13; - -const int CSSM_ALGMODE_BC = 14; - -const int CSSM_ALGMODE_PCBC = 15; - -const int CSSM_ALGMODE_CBCC = 16; - -const int CSSM_ALGMODE_OFBNLF = 17; - -const int CSSM_ALGMODE_PBC = 18; - -const int CSSM_ALGMODE_PFB = 19; - -const int CSSM_ALGMODE_CBCPD = 20; - -const int CSSM_ALGMODE_PUBLIC_KEY = 21; - -const int CSSM_ALGMODE_PRIVATE_KEY = 22; - -const int CSSM_ALGMODE_SHUFFLE = 23; - -const int CSSM_ALGMODE_ECB64 = 24; - -const int CSSM_ALGMODE_CBC64 = 25; - -const int CSSM_ALGMODE_OFB64 = 26; - -const int CSSM_ALGMODE_CFB32 = 28; - -const int CSSM_ALGMODE_CFB16 = 29; - -const int CSSM_ALGMODE_CFB8 = 30; - -const int CSSM_ALGMODE_WRAP = 31; - -const int CSSM_ALGMODE_PRIVATE_WRAP = 32; - -const int CSSM_ALGMODE_RELAYX = 33; - -const int CSSM_ALGMODE_ECB128 = 34; - -const int CSSM_ALGMODE_ECB96 = 35; - -const int CSSM_ALGMODE_CBC128 = 36; - -const int CSSM_ALGMODE_OAEP_HASH = 37; - -const int CSSM_ALGMODE_PKCS1_EME_V15 = 38; - -const int CSSM_ALGMODE_PKCS1_EME_OAEP = 39; - -const int CSSM_ALGMODE_PKCS1_EMSA_V15 = 40; - -const int CSSM_ALGMODE_ISO_9796 = 41; - -const int CSSM_ALGMODE_X9_31 = 42; - -const int CSSM_ALGMODE_LAST = 2147483647; - -const int CSSM_ALGMODE_VENDOR_DEFINED = -2147483648; - -const int CSSM_CSP_SOFTWARE = 1; - -const int CSSM_CSP_HARDWARE = 2; - -const int CSSM_CSP_HYBRID = 3; - -const int CSSM_ALGCLASS_NONE = 0; - -const int CSSM_ALGCLASS_CUSTOM = 1; - -const int CSSM_ALGCLASS_SIGNATURE = 2; - -const int CSSM_ALGCLASS_SYMMETRIC = 3; - -const int CSSM_ALGCLASS_DIGEST = 4; - -const int CSSM_ALGCLASS_RANDOMGEN = 5; - -const int CSSM_ALGCLASS_UNIQUEGEN = 6; - -const int CSSM_ALGCLASS_MAC = 7; - -const int CSSM_ALGCLASS_ASYMMETRIC = 8; - -const int CSSM_ALGCLASS_KEYGEN = 9; - -const int CSSM_ALGCLASS_DERIVEKEY = 10; - -const int CSSM_ATTRIBUTE_DATA_NONE = 0; - -const int CSSM_ATTRIBUTE_DATA_UINT32 = 268435456; - -const int CSSM_ATTRIBUTE_DATA_CSSM_DATA = 536870912; - -const int CSSM_ATTRIBUTE_DATA_CRYPTO_DATA = 805306368; - -const int CSSM_ATTRIBUTE_DATA_KEY = 1073741824; - -const int CSSM_ATTRIBUTE_DATA_STRING = 1342177280; - -const int CSSM_ATTRIBUTE_DATA_DATE = 1610612736; - -const int CSSM_ATTRIBUTE_DATA_RANGE = 1879048192; - -const int CSSM_ATTRIBUTE_DATA_ACCESS_CREDENTIALS = -2147483648; - -const int CSSM_ATTRIBUTE_DATA_VERSION = 16777216; - -const int CSSM_ATTRIBUTE_DATA_DL_DB_HANDLE = 33554432; - -const int CSSM_ATTRIBUTE_DATA_KR_PROFILE = 50331648; - -const int CSSM_ATTRIBUTE_TYPE_MASK = -16777216; - -const int CSSM_ATTRIBUTE_NONE = 0; - -const int CSSM_ATTRIBUTE_CUSTOM = 536870913; - -const int CSSM_ATTRIBUTE_DESCRIPTION = 1342177282; - -const int CSSM_ATTRIBUTE_KEY = 1073741827; - -const int CSSM_ATTRIBUTE_INIT_VECTOR = 536870916; - -const int CSSM_ATTRIBUTE_SALT = 536870917; - -const int CSSM_ATTRIBUTE_PADDING = 268435462; - -const int CSSM_ATTRIBUTE_RANDOM = 536870919; - -const int CSSM_ATTRIBUTE_SEED = 805306376; - -const int CSSM_ATTRIBUTE_PASSPHRASE = 805306377; - -const int CSSM_ATTRIBUTE_KEY_LENGTH = 268435466; - -const int CSSM_ATTRIBUTE_KEY_LENGTH_RANGE = 1879048203; - -const int CSSM_ATTRIBUTE_BLOCK_SIZE = 268435468; - -const int CSSM_ATTRIBUTE_OUTPUT_SIZE = 268435469; - -const int CSSM_ATTRIBUTE_ROUNDS = 268435470; - -const int CSSM_ATTRIBUTE_IV_SIZE = 268435471; - -const int CSSM_ATTRIBUTE_ALG_PARAMS = 536870928; - -const int CSSM_ATTRIBUTE_LABEL = 536870929; - -const int CSSM_ATTRIBUTE_KEY_TYPE = 268435474; - -const int CSSM_ATTRIBUTE_MODE = 268435475; - -const int CSSM_ATTRIBUTE_EFFECTIVE_BITS = 268435476; - -const int CSSM_ATTRIBUTE_START_DATE = 1610612757; - -const int CSSM_ATTRIBUTE_END_DATE = 1610612758; - -const int CSSM_ATTRIBUTE_KEYUSAGE = 268435479; - -const int CSSM_ATTRIBUTE_KEYATTR = 268435480; - -const int CSSM_ATTRIBUTE_VERSION = 16777241; - -const int CSSM_ATTRIBUTE_PRIME = 536870938; - -const int CSSM_ATTRIBUTE_BASE = 536870939; - -const int CSSM_ATTRIBUTE_SUBPRIME = 536870940; - -const int CSSM_ATTRIBUTE_ALG_ID = 268435485; - -const int CSSM_ATTRIBUTE_ITERATION_COUNT = 268435486; - -const int CSSM_ATTRIBUTE_ROUNDS_RANGE = 1879048223; - -const int CSSM_ATTRIBUTE_KRPROFILE_LOCAL = 50331680; - -const int CSSM_ATTRIBUTE_KRPROFILE_REMOTE = 50331681; - -const int CSSM_ATTRIBUTE_CSP_HANDLE = 268435490; - -const int CSSM_ATTRIBUTE_DL_DB_HANDLE = 33554467; - -const int CSSM_ATTRIBUTE_ACCESS_CREDENTIALS = -2147483612; - -const int CSSM_ATTRIBUTE_PUBLIC_KEY_FORMAT = 268435493; - -const int CSSM_ATTRIBUTE_PRIVATE_KEY_FORMAT = 268435494; - -const int CSSM_ATTRIBUTE_SYMMETRIC_KEY_FORMAT = 268435495; - -const int CSSM_ATTRIBUTE_WRAPPED_KEY_FORMAT = 268435496; - -const int CSSM_PADDING_NONE = 0; - -const int CSSM_PADDING_CUSTOM = 1; - -const int CSSM_PADDING_ZERO = 2; - -const int CSSM_PADDING_ONE = 3; - -const int CSSM_PADDING_ALTERNATE = 4; - -const int CSSM_PADDING_FF = 5; - -const int CSSM_PADDING_PKCS5 = 6; - -const int CSSM_PADDING_PKCS7 = 7; - -const int CSSM_PADDING_CIPHERSTEALING = 8; - -const int CSSM_PADDING_RANDOM = 9; - -const int CSSM_PADDING_PKCS1 = 10; - -const int CSSM_PADDING_SIGRAW = 11; - -const int CSSM_PADDING_VENDOR_DEFINED = -2147483648; - -const int CSSM_CSP_TOK_RNG = 1; - -const int CSSM_CSP_TOK_CLOCK_EXISTS = 64; - -const int CSSM_CSP_RDR_TOKENPRESENT = 1; - -const int CSSM_CSP_RDR_EXISTS = 2; - -const int CSSM_CSP_RDR_HW = 4; - -const int CSSM_CSP_TOK_WRITE_PROTECTED = 2; - -const int CSSM_CSP_TOK_LOGIN_REQUIRED = 4; - -const int CSSM_CSP_TOK_USER_PIN_INITIALIZED = 8; - -const int CSSM_CSP_TOK_PROT_AUTHENTICATION = 256; - -const int CSSM_CSP_TOK_USER_PIN_EXPIRED = 1048576; - -const int CSSM_CSP_TOK_SESSION_KEY_PASSWORD = 2097152; - -const int CSSM_CSP_TOK_PRIVATE_KEY_PASSWORD = 4194304; - -const int CSSM_CSP_STORES_PRIVATE_KEYS = 16777216; - -const int CSSM_CSP_STORES_PUBLIC_KEYS = 33554432; - -const int CSSM_CSP_STORES_SESSION_KEYS = 67108864; - -const int CSSM_CSP_STORES_CERTIFICATES = 134217728; - -const int CSSM_CSP_STORES_GENERIC = 268435456; - -const int CSSM_PKCS_OAEP_MGF_NONE = 0; - -const int CSSM_PKCS_OAEP_MGF1_SHA1 = 1; - -const int CSSM_PKCS_OAEP_MGF1_MD5 = 2; - -const int CSSM_PKCS_OAEP_PSOURCE_NONE = 0; - -const int CSSM_PKCS_OAEP_PSOURCE_Pspecified = 1; - -const int CSSM_VALUE_NOT_AVAILABLE = -1; - -const int CSSM_PKCS5_PBKDF2_PRF_HMAC_SHA1 = 0; - -const int CSSM_TP_AUTHORITY_REQUEST_CERTISSUE = 1; - -const int CSSM_TP_AUTHORITY_REQUEST_CERTREVOKE = 2; - -const int CSSM_TP_AUTHORITY_REQUEST_CERTSUSPEND = 3; - -const int CSSM_TP_AUTHORITY_REQUEST_CERTRESUME = 4; - -const int CSSM_TP_AUTHORITY_REQUEST_CERTVERIFY = 5; - -const int CSSM_TP_AUTHORITY_REQUEST_CERTNOTARIZE = 6; - -const int CSSM_TP_AUTHORITY_REQUEST_CERTUSERECOVER = 7; - -const int CSSM_TP_AUTHORITY_REQUEST_CRLISSUE = 256; - -const int CSSM_TP_KEY_ARCHIVE = 1; - -const int CSSM_TP_CERT_PUBLISH = 2; - -const int CSSM_TP_CERT_NOTIFY_RENEW = 4; - -const int CSSM_TP_CERT_DIR_UPDATE = 8; - -const int CSSM_TP_CRL_DISTRIBUTE = 16; - -const int CSSM_TP_ACTION_DEFAULT = 0; - -const int CSSM_TP_STOP_ON_POLICY = 0; - -const int CSSM_TP_STOP_ON_NONE = 1; - -const int CSSM_TP_STOP_ON_FIRST_PASS = 2; - -const int CSSM_TP_STOP_ON_FIRST_FAIL = 3; - -const int CSSM_CRL_PARSE_FORMAT_NONE = 0; - -const int CSSM_CRL_PARSE_FORMAT_CUSTOM = 1; - -const int CSSM_CRL_PARSE_FORMAT_SEXPR = 2; - -const int CSSM_CRL_PARSE_FORMAT_COMPLEX = 3; - -const int CSSM_CRL_PARSE_FORMAT_OID_NAMED = 4; - -const int CSSM_CRL_PARSE_FORMAT_TUPLE = 5; - -const int CSSM_CRL_PARSE_FORMAT_MULTIPLE = 32766; - -const int CSSM_CRL_PARSE_FORMAT_LAST = 32767; - -const int CSSM_CL_CUSTOM_CRL_PARSE_FORMAT = 32768; - -const int CSSM_CRL_TYPE_UNKNOWN = 0; - -const int CSSM_CRL_TYPE_X_509v1 = 1; - -const int CSSM_CRL_TYPE_X_509v2 = 2; - -const int CSSM_CRL_TYPE_SPKI = 3; - -const int CSSM_CRL_TYPE_MULTIPLE = 32766; - -const int CSSM_CRL_ENCODING_UNKNOWN = 0; - -const int CSSM_CRL_ENCODING_CUSTOM = 1; - -const int CSSM_CRL_ENCODING_BER = 2; - -const int CSSM_CRL_ENCODING_DER = 3; - -const int CSSM_CRL_ENCODING_BLOOM = 4; - -const int CSSM_CRL_ENCODING_SEXPR = 5; - -const int CSSM_CRL_ENCODING_MULTIPLE = 32766; - -const int CSSM_CRLGROUP_DATA = 0; - -const int CSSM_CRLGROUP_ENCODED_CRL = 1; - -const int CSSM_CRLGROUP_PARSED_CRL = 2; - -const int CSSM_CRLGROUP_CRL_PAIR = 3; - -const int CSSM_EVIDENCE_FORM_UNSPECIFIC = 0; - -const int CSSM_EVIDENCE_FORM_CERT = 1; - -const int CSSM_EVIDENCE_FORM_CRL = 2; - -const int CSSM_EVIDENCE_FORM_CERT_ID = 3; - -const int CSSM_EVIDENCE_FORM_CRL_ID = 4; - -const int CSSM_EVIDENCE_FORM_VERIFIER_TIME = 5; - -const int CSSM_EVIDENCE_FORM_CRL_THISTIME = 6; - -const int CSSM_EVIDENCE_FORM_CRL_NEXTTIME = 7; - -const int CSSM_EVIDENCE_FORM_POLICYINFO = 8; - -const int CSSM_EVIDENCE_FORM_TUPLEGROUP = 9; - -const int CSSM_TP_CONFIRM_STATUS_UNKNOWN = 0; - -const int CSSM_TP_CONFIRM_ACCEPT = 1; - -const int CSSM_TP_CONFIRM_REJECT = 2; - -const int CSSM_ESTIMATED_TIME_UNKNOWN = -1; - -const int CSSM_ELAPSED_TIME_UNKNOWN = -1; - -const int CSSM_ELAPSED_TIME_COMPLETE = -2; - -const int CSSM_TP_CERTISSUE_STATUS_UNKNOWN = 0; - -const int CSSM_TP_CERTISSUE_OK = 1; - -const int CSSM_TP_CERTISSUE_OKWITHCERTMODS = 2; - -const int CSSM_TP_CERTISSUE_OKWITHSERVICEMODS = 3; - -const int CSSM_TP_CERTISSUE_REJECTED = 4; - -const int CSSM_TP_CERTISSUE_NOT_AUTHORIZED = 5; - -const int CSSM_TP_CERTISSUE_WILL_BE_REVOKED = 6; - -const int CSSM_TP_CERTCHANGE_NONE = 0; - -const int CSSM_TP_CERTCHANGE_REVOKE = 1; - -const int CSSM_TP_CERTCHANGE_HOLD = 2; - -const int CSSM_TP_CERTCHANGE_RELEASE = 3; - -const int CSSM_TP_CERTCHANGE_REASON_UNKNOWN = 0; - -const int CSSM_TP_CERTCHANGE_REASON_KEYCOMPROMISE = 1; - -const int CSSM_TP_CERTCHANGE_REASON_CACOMPROMISE = 2; - -const int CSSM_TP_CERTCHANGE_REASON_CEASEOPERATION = 3; - -const int CSSM_TP_CERTCHANGE_REASON_AFFILIATIONCHANGE = 4; - -const int CSSM_TP_CERTCHANGE_REASON_SUPERCEDED = 5; - -const int CSSM_TP_CERTCHANGE_REASON_SUSPECTEDCOMPROMISE = 6; - -const int CSSM_TP_CERTCHANGE_REASON_HOLDRELEASE = 7; - -const int CSSM_TP_CERTCHANGE_STATUS_UNKNOWN = 0; - -const int CSSM_TP_CERTCHANGE_OK = 1; - -const int CSSM_TP_CERTCHANGE_OKWITHNEWTIME = 2; - -const int CSSM_TP_CERTCHANGE_WRONGCA = 3; - -const int CSSM_TP_CERTCHANGE_REJECTED = 4; - -const int CSSM_TP_CERTCHANGE_NOT_AUTHORIZED = 5; - -const int CSSM_TP_CERTVERIFY_UNKNOWN = 0; - -const int CSSM_TP_CERTVERIFY_VALID = 1; - -const int CSSM_TP_CERTVERIFY_INVALID = 2; - -const int CSSM_TP_CERTVERIFY_REVOKED = 3; - -const int CSSM_TP_CERTVERIFY_SUSPENDED = 4; - -const int CSSM_TP_CERTVERIFY_EXPIRED = 5; - -const int CSSM_TP_CERTVERIFY_NOT_VALID_YET = 6; - -const int CSSM_TP_CERTVERIFY_INVALID_AUTHORITY = 7; - -const int CSSM_TP_CERTVERIFY_INVALID_SIGNATURE = 8; - -const int CSSM_TP_CERTVERIFY_INVALID_CERT_VALUE = 9; - -const int CSSM_TP_CERTVERIFY_INVALID_CERTGROUP = 10; - -const int CSSM_TP_CERTVERIFY_INVALID_POLICY = 11; - -const int CSSM_TP_CERTVERIFY_INVALID_POLICY_IDS = 12; - -const int CSSM_TP_CERTVERIFY_INVALID_BASIC_CONSTRAINTS = 13; - -const int CSSM_TP_CERTVERIFY_INVALID_CRL_DIST_PT = 14; - -const int CSSM_TP_CERTVERIFY_INVALID_NAME_TREE = 15; - -const int CSSM_TP_CERTVERIFY_UNKNOWN_CRITICAL_EXT = 16; - -const int CSSM_TP_CERTNOTARIZE_STATUS_UNKNOWN = 0; - -const int CSSM_TP_CERTNOTARIZE_OK = 1; - -const int CSSM_TP_CERTNOTARIZE_OKWITHOUTFIELDS = 2; - -const int CSSM_TP_CERTNOTARIZE_OKWITHSERVICEMODS = 3; - -const int CSSM_TP_CERTNOTARIZE_REJECTED = 4; - -const int CSSM_TP_CERTNOTARIZE_NOT_AUTHORIZED = 5; - -const int CSSM_TP_CERTRECLAIM_STATUS_UNKNOWN = 0; - -const int CSSM_TP_CERTRECLAIM_OK = 1; - -const int CSSM_TP_CERTRECLAIM_NOMATCH = 2; - -const int CSSM_TP_CERTRECLAIM_REJECTED = 3; - -const int CSSM_TP_CERTRECLAIM_NOT_AUTHORIZED = 4; - -const int CSSM_TP_CRLISSUE_STATUS_UNKNOWN = 0; - -const int CSSM_TP_CRLISSUE_OK = 1; - -const int CSSM_TP_CRLISSUE_NOT_CURRENT = 2; - -const int CSSM_TP_CRLISSUE_INVALID_DOMAIN = 3; - -const int CSSM_TP_CRLISSUE_UNKNOWN_IDENTIFIER = 4; - -const int CSSM_TP_CRLISSUE_REJECTED = 5; - -const int CSSM_TP_CRLISSUE_NOT_AUTHORIZED = 6; - -const int CSSM_TP_FORM_TYPE_GENERIC = 0; - -const int CSSM_TP_FORM_TYPE_REGISTRATION = 1; - -const int CSSM_CL_TEMPLATE_INTERMEDIATE_CERT = 1; - -const int CSSM_CL_TEMPLATE_PKIX_CERTTEMPLATE = 2; - -const int CSSM_CERT_BUNDLE_UNKNOWN = 0; - -const int CSSM_CERT_BUNDLE_CUSTOM = 1; - -const int CSSM_CERT_BUNDLE_PKCS7_SIGNED_DATA = 2; - -const int CSSM_CERT_BUNDLE_PKCS7_SIGNED_ENVELOPED_DATA = 3; - -const int CSSM_CERT_BUNDLE_PKCS12 = 4; - -const int CSSM_CERT_BUNDLE_PFX = 5; - -const int CSSM_CERT_BUNDLE_SPKI_SEQUENCE = 6; - -const int CSSM_CERT_BUNDLE_PGP_KEYRING = 7; - -const int CSSM_CERT_BUNDLE_LAST = 32767; - -const int CSSM_CL_CUSTOM_CERT_BUNDLE_TYPE = 32768; - -const int CSSM_CERT_BUNDLE_ENCODING_UNKNOWN = 0; - -const int CSSM_CERT_BUNDLE_ENCODING_CUSTOM = 1; - -const int CSSM_CERT_BUNDLE_ENCODING_BER = 2; - -const int CSSM_CERT_BUNDLE_ENCODING_DER = 3; - -const int CSSM_CERT_BUNDLE_ENCODING_SEXPR = 4; - -const int CSSM_CERT_BUNDLE_ENCODING_PGP = 5; - -const int CSSM_FIELDVALUE_COMPLEX_DATA_TYPE = -1; - -const int CSSM_DB_ATTRIBUTE_NAME_AS_STRING = 0; - -const int CSSM_DB_ATTRIBUTE_NAME_AS_OID = 1; - -const int CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER = 2; - -const int CSSM_DB_ATTRIBUTE_FORMAT_STRING = 0; - -const int CSSM_DB_ATTRIBUTE_FORMAT_SINT32 = 1; - -const int CSSM_DB_ATTRIBUTE_FORMAT_UINT32 = 2; - -const int CSSM_DB_ATTRIBUTE_FORMAT_BIG_NUM = 3; - -const int CSSM_DB_ATTRIBUTE_FORMAT_REAL = 4; - -const int CSSM_DB_ATTRIBUTE_FORMAT_TIME_DATE = 5; - -const int CSSM_DB_ATTRIBUTE_FORMAT_BLOB = 6; - -const int CSSM_DB_ATTRIBUTE_FORMAT_MULTI_UINT32 = 7; - -const int CSSM_DB_ATTRIBUTE_FORMAT_COMPLEX = 8; - -const int CSSM_DB_RECORDTYPE_SCHEMA_START = 0; - -const int CSSM_DB_RECORDTYPE_SCHEMA_END = 4; - -const int CSSM_DB_RECORDTYPE_OPEN_GROUP_START = 10; - -const int CSSM_DB_RECORDTYPE_OPEN_GROUP_END = 18; - -const int CSSM_DB_RECORDTYPE_APP_DEFINED_START = -2147483648; - -const int CSSM_DB_RECORDTYPE_APP_DEFINED_END = -1; - -const int CSSM_DL_DB_SCHEMA_INFO = 0; - -const int CSSM_DL_DB_SCHEMA_INDEXES = 1; - -const int CSSM_DL_DB_SCHEMA_ATTRIBUTES = 2; - -const int CSSM_DL_DB_SCHEMA_PARSING_MODULE = 3; - -const int CSSM_DL_DB_RECORD_ANY = 10; - -const int CSSM_DL_DB_RECORD_CERT = 11; - -const int CSSM_DL_DB_RECORD_CRL = 12; - -const int CSSM_DL_DB_RECORD_POLICY = 13; - -const int CSSM_DL_DB_RECORD_GENERIC = 14; - -const int CSSM_DL_DB_RECORD_PUBLIC_KEY = 15; - -const int CSSM_DL_DB_RECORD_PRIVATE_KEY = 16; - -const int CSSM_DL_DB_RECORD_SYMMETRIC_KEY = 17; - -const int CSSM_DL_DB_RECORD_ALL_KEYS = 18; - -const int CSSM_DB_CERT_USE_TRUSTED = 1; - -const int CSSM_DB_CERT_USE_SYSTEM = 2; - -const int CSSM_DB_CERT_USE_OWNER = 4; - -const int CSSM_DB_CERT_USE_REVOKED = 8; - -const int CSSM_DB_CERT_USE_SIGNING = 16; - -const int CSSM_DB_CERT_USE_PRIVACY = 32; - -const int CSSM_DB_INDEX_UNIQUE = 0; - -const int CSSM_DB_INDEX_NONUNIQUE = 1; - -const int CSSM_DB_INDEX_ON_UNKNOWN = 0; - -const int CSSM_DB_INDEX_ON_ATTRIBUTE = 1; - -const int CSSM_DB_INDEX_ON_RECORD = 2; - -const int CSSM_DB_ACCESS_READ = 1; - -const int CSSM_DB_ACCESS_WRITE = 2; - -const int CSSM_DB_ACCESS_PRIVILEGED = 4; - -const int CSSM_DB_MODIFY_ATTRIBUTE_NONE = 0; - -const int CSSM_DB_MODIFY_ATTRIBUTE_ADD = 1; - -const int CSSM_DB_MODIFY_ATTRIBUTE_DELETE = 2; - -const int CSSM_DB_MODIFY_ATTRIBUTE_REPLACE = 3; - -const int CSSM_DB_EQUAL = 0; - -const int CSSM_DB_NOT_EQUAL = 1; - -const int CSSM_DB_LESS_THAN = 2; - -const int CSSM_DB_GREATER_THAN = 3; - -const int CSSM_DB_CONTAINS = 4; - -const int CSSM_DB_CONTAINS_INITIAL_SUBSTRING = 5; - -const int CSSM_DB_CONTAINS_FINAL_SUBSTRING = 6; - -const int CSSM_DB_NONE = 0; - -const int CSSM_DB_AND = 1; - -const int CSSM_DB_OR = 2; - -const int CSSM_QUERY_TIMELIMIT_NONE = 0; - -const int CSSM_QUERY_SIZELIMIT_NONE = 0; - -const int CSSM_QUERY_RETURN_DATA = 1; - -const int CSSM_DL_UNKNOWN = 0; - -const int CSSM_DL_CUSTOM = 1; - -const int CSSM_DL_LDAP = 2; - -const int CSSM_DL_ODBC = 3; - -const int CSSM_DL_PKCS11 = 4; - -const int CSSM_DL_FFS = 5; - -const int CSSM_DL_MEMORY = 6; - -const int CSSM_DL_REMOTEDIR = 7; - -const int CSSM_DB_DATASTORES_UNKNOWN = -1; - -const int CSSM_DB_TRANSACTIONAL_MODE = 0; - -const int CSSM_DB_FILESYSTEMSCAN_MODE = 1; - -const int CSSM_BASE_ERROR = -2147418112; - -const int CSSM_ERRORCODE_MODULE_EXTENT = 2048; - -const int CSSM_ERRORCODE_CUSTOM_OFFSET = 1024; - -const int CSSM_ERRORCODE_COMMON_EXTENT = 256; - -const int CSSM_CSSM_BASE_ERROR = -2147418112; - -const int CSSM_CSSM_PRIVATE_ERROR = -2147417088; - -const int CSSM_CSP_BASE_ERROR = -2147416064; - -const int CSSM_CSP_PRIVATE_ERROR = -2147415040; - -const int CSSM_DL_BASE_ERROR = -2147414016; - -const int CSSM_DL_PRIVATE_ERROR = -2147412992; - -const int CSSM_CL_BASE_ERROR = -2147411968; - -const int CSSM_CL_PRIVATE_ERROR = -2147410944; - -const int CSSM_TP_BASE_ERROR = -2147409920; - -const int CSSM_TP_PRIVATE_ERROR = -2147408896; - -const int CSSM_KR_BASE_ERROR = -2147407872; - -const int CSSM_KR_PRIVATE_ERROR = -2147406848; - -const int CSSM_AC_BASE_ERROR = -2147405824; - -const int CSSM_AC_PRIVATE_ERROR = -2147404800; - -const int CSSM_MDS_BASE_ERROR = -2147414016; - -const int CSSM_MDS_PRIVATE_ERROR = -2147412992; - -const int CSSMERR_CSSM_INVALID_ADDIN_HANDLE = -2147417855; - -const int CSSMERR_CSSM_NOT_INITIALIZED = -2147417854; - -const int CSSMERR_CSSM_INVALID_HANDLE_USAGE = -2147417853; - -const int CSSMERR_CSSM_PVC_REFERENT_NOT_FOUND = -2147417852; - -const int CSSMERR_CSSM_FUNCTION_INTEGRITY_FAIL = -2147417851; - -const int CSSM_ERRCODE_INTERNAL_ERROR = 1; - -const int CSSM_ERRCODE_MEMORY_ERROR = 2; - -const int CSSM_ERRCODE_MDS_ERROR = 3; - -const int CSSM_ERRCODE_INVALID_POINTER = 4; - -const int CSSM_ERRCODE_INVALID_INPUT_POINTER = 5; - -const int CSSM_ERRCODE_INVALID_OUTPUT_POINTER = 6; - -const int CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED = 7; - -const int CSSM_ERRCODE_SELF_CHECK_FAILED = 8; - -const int CSSM_ERRCODE_OS_ACCESS_DENIED = 9; - -const int CSSM_ERRCODE_FUNCTION_FAILED = 10; - -const int CSSM_ERRCODE_MODULE_MANIFEST_VERIFY_FAILED = 11; - -const int CSSM_ERRCODE_INVALID_GUID = 12; - -const int CSSM_ERRCODE_OPERATION_AUTH_DENIED = 32; - -const int CSSM_ERRCODE_OBJECT_USE_AUTH_DENIED = 33; - -const int CSSM_ERRCODE_OBJECT_MANIP_AUTH_DENIED = 34; - -const int CSSM_ERRCODE_OBJECT_ACL_NOT_SUPPORTED = 35; - -const int CSSM_ERRCODE_OBJECT_ACL_REQUIRED = 36; - -const int CSSM_ERRCODE_INVALID_ACCESS_CREDENTIALS = 37; - -const int CSSM_ERRCODE_INVALID_ACL_BASE_CERTS = 38; - -const int CSSM_ERRCODE_ACL_BASE_CERTS_NOT_SUPPORTED = 39; - -const int CSSM_ERRCODE_INVALID_SAMPLE_VALUE = 40; - -const int CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED = 41; - -const int CSSM_ERRCODE_INVALID_ACL_SUBJECT_VALUE = 42; - -const int CSSM_ERRCODE_ACL_SUBJECT_TYPE_NOT_SUPPORTED = 43; - -const int CSSM_ERRCODE_INVALID_ACL_CHALLENGE_CALLBACK = 44; - -const int CSSM_ERRCODE_ACL_CHALLENGE_CALLBACK_FAILED = 45; - -const int CSSM_ERRCODE_INVALID_ACL_ENTRY_TAG = 46; - -const int CSSM_ERRCODE_ACL_ENTRY_TAG_NOT_FOUND = 47; - -const int CSSM_ERRCODE_INVALID_ACL_EDIT_MODE = 48; - -const int CSSM_ERRCODE_ACL_CHANGE_FAILED = 49; - -const int CSSM_ERRCODE_INVALID_NEW_ACL_ENTRY = 50; - -const int CSSM_ERRCODE_INVALID_NEW_ACL_OWNER = 51; - -const int CSSM_ERRCODE_ACL_DELETE_FAILED = 52; - -const int CSSM_ERRCODE_ACL_REPLACE_FAILED = 53; - -const int CSSM_ERRCODE_ACL_ADD_FAILED = 54; - -const int CSSM_ERRCODE_INVALID_CONTEXT_HANDLE = 64; - -const int CSSM_ERRCODE_INCOMPATIBLE_VERSION = 65; - -const int CSSM_ERRCODE_INVALID_CERTGROUP_POINTER = 66; - -const int CSSM_ERRCODE_INVALID_CERT_POINTER = 67; - -const int CSSM_ERRCODE_INVALID_CRL_POINTER = 68; - -const int CSSM_ERRCODE_INVALID_FIELD_POINTER = 69; - -const int CSSM_ERRCODE_INVALID_DATA = 70; - -const int CSSM_ERRCODE_CRL_ALREADY_SIGNED = 71; - -const int CSSM_ERRCODE_INVALID_NUMBER_OF_FIELDS = 72; - -const int CSSM_ERRCODE_VERIFICATION_FAILURE = 73; - -const int CSSM_ERRCODE_INVALID_DB_HANDLE = 74; - -const int CSSM_ERRCODE_PRIVILEGE_NOT_GRANTED = 75; - -const int CSSM_ERRCODE_INVALID_DB_LIST = 76; - -const int CSSM_ERRCODE_INVALID_DB_LIST_POINTER = 77; - -const int CSSM_ERRCODE_UNKNOWN_FORMAT = 78; - -const int CSSM_ERRCODE_UNKNOWN_TAG = 79; - -const int CSSM_ERRCODE_INVALID_CSP_HANDLE = 80; - -const int CSSM_ERRCODE_INVALID_DL_HANDLE = 81; - -const int CSSM_ERRCODE_INVALID_CL_HANDLE = 82; - -const int CSSM_ERRCODE_INVALID_TP_HANDLE = 83; - -const int CSSM_ERRCODE_INVALID_KR_HANDLE = 84; - -const int CSSM_ERRCODE_INVALID_AC_HANDLE = 85; - -const int CSSM_ERRCODE_INVALID_PASSTHROUGH_ID = 86; - -const int CSSM_ERRCODE_INVALID_NETWORK_ADDR = 87; - -const int CSSM_ERRCODE_INVALID_CRYPTO_DATA = 88; - -const int CSSMERR_CSSM_INTERNAL_ERROR = -2147418111; - -const int CSSMERR_CSSM_MEMORY_ERROR = -2147418110; - -const int CSSMERR_CSSM_MDS_ERROR = -2147418109; - -const int CSSMERR_CSSM_INVALID_POINTER = -2147418108; - -const int CSSMERR_CSSM_INVALID_INPUT_POINTER = -2147418107; - -const int CSSMERR_CSSM_INVALID_OUTPUT_POINTER = -2147418106; - -const int CSSMERR_CSSM_FUNCTION_NOT_IMPLEMENTED = -2147418105; - -const int CSSMERR_CSSM_SELF_CHECK_FAILED = -2147418104; - -const int CSSMERR_CSSM_OS_ACCESS_DENIED = -2147418103; - -const int CSSMERR_CSSM_FUNCTION_FAILED = -2147418102; - -const int CSSMERR_CSSM_MODULE_MANIFEST_VERIFY_FAILED = -2147418101; - -const int CSSMERR_CSSM_INVALID_GUID = -2147418100; - -const int CSSMERR_CSSM_INVALID_CONTEXT_HANDLE = -2147418048; - -const int CSSMERR_CSSM_INCOMPATIBLE_VERSION = -2147418047; - -const int CSSMERR_CSSM_PRIVILEGE_NOT_GRANTED = -2147418037; - -const int CSSM_CSSM_BASE_CSSM_ERROR = -2147417840; - -const int CSSMERR_CSSM_SCOPE_NOT_SUPPORTED = -2147417839; - -const int CSSMERR_CSSM_PVC_ALREADY_CONFIGURED = -2147417838; - -const int CSSMERR_CSSM_INVALID_PVC = -2147417837; - -const int CSSMERR_CSSM_EMM_LOAD_FAILED = -2147417836; - -const int CSSMERR_CSSM_EMM_UNLOAD_FAILED = -2147417835; - -const int CSSMERR_CSSM_ADDIN_LOAD_FAILED = -2147417834; - -const int CSSMERR_CSSM_INVALID_KEY_HIERARCHY = -2147417833; - -const int CSSMERR_CSSM_ADDIN_UNLOAD_FAILED = -2147417832; - -const int CSSMERR_CSSM_LIB_REF_NOT_FOUND = -2147417831; - -const int CSSMERR_CSSM_INVALID_ADDIN_FUNCTION_TABLE = -2147417830; - -const int CSSMERR_CSSM_EMM_AUTHENTICATE_FAILED = -2147417829; - -const int CSSMERR_CSSM_ADDIN_AUTHENTICATE_FAILED = -2147417828; - -const int CSSMERR_CSSM_INVALID_SERVICE_MASK = -2147417827; - -const int CSSMERR_CSSM_MODULE_NOT_LOADED = -2147417826; - -const int CSSMERR_CSSM_INVALID_SUBSERVICEID = -2147417825; - -const int CSSMERR_CSSM_BUFFER_TOO_SMALL = -2147417824; - -const int CSSMERR_CSSM_INVALID_ATTRIBUTE = -2147417823; - -const int CSSMERR_CSSM_ATTRIBUTE_NOT_IN_CONTEXT = -2147417822; - -const int CSSMERR_CSSM_MODULE_MANAGER_INITIALIZE_FAIL = -2147417821; - -const int CSSMERR_CSSM_MODULE_MANAGER_NOT_FOUND = -2147417820; - -const int CSSMERR_CSSM_EVENT_NOTIFICATION_CALLBACK_NOT_FOUND = -2147417819; - -const int CSSMERR_CSP_INTERNAL_ERROR = -2147416063; - -const int CSSMERR_CSP_MEMORY_ERROR = -2147416062; - -const int CSSMERR_CSP_MDS_ERROR = -2147416061; - -const int CSSMERR_CSP_INVALID_POINTER = -2147416060; - -const int CSSMERR_CSP_INVALID_INPUT_POINTER = -2147416059; - -const int CSSMERR_CSP_INVALID_OUTPUT_POINTER = -2147416058; - -const int CSSMERR_CSP_FUNCTION_NOT_IMPLEMENTED = -2147416057; - -const int CSSMERR_CSP_SELF_CHECK_FAILED = -2147416056; - -const int CSSMERR_CSP_OS_ACCESS_DENIED = -2147416055; - -const int CSSMERR_CSP_FUNCTION_FAILED = -2147416054; - -const int CSSMERR_CSP_OPERATION_AUTH_DENIED = -2147416032; - -const int CSSMERR_CSP_OBJECT_USE_AUTH_DENIED = -2147416031; - -const int CSSMERR_CSP_OBJECT_MANIP_AUTH_DENIED = -2147416030; - -const int CSSMERR_CSP_OBJECT_ACL_NOT_SUPPORTED = -2147416029; - -const int CSSMERR_CSP_OBJECT_ACL_REQUIRED = -2147416028; - -const int CSSMERR_CSP_INVALID_ACCESS_CREDENTIALS = -2147416027; - -const int CSSMERR_CSP_INVALID_ACL_BASE_CERTS = -2147416026; - -const int CSSMERR_CSP_ACL_BASE_CERTS_NOT_SUPPORTED = -2147416025; - -const int CSSMERR_CSP_INVALID_SAMPLE_VALUE = -2147416024; - -const int CSSMERR_CSP_SAMPLE_VALUE_NOT_SUPPORTED = -2147416023; - -const int CSSMERR_CSP_INVALID_ACL_SUBJECT_VALUE = -2147416022; - -const int CSSMERR_CSP_ACL_SUBJECT_TYPE_NOT_SUPPORTED = -2147416021; - -const int CSSMERR_CSP_INVALID_ACL_CHALLENGE_CALLBACK = -2147416020; - -const int CSSMERR_CSP_ACL_CHALLENGE_CALLBACK_FAILED = -2147416019; - -const int CSSMERR_CSP_INVALID_ACL_ENTRY_TAG = -2147416018; - -const int CSSMERR_CSP_ACL_ENTRY_TAG_NOT_FOUND = -2147416017; - -const int CSSMERR_CSP_INVALID_ACL_EDIT_MODE = -2147416016; - -const int CSSMERR_CSP_ACL_CHANGE_FAILED = -2147416015; - -const int CSSMERR_CSP_INVALID_NEW_ACL_ENTRY = -2147416014; - -const int CSSMERR_CSP_INVALID_NEW_ACL_OWNER = -2147416013; - -const int CSSMERR_CSP_ACL_DELETE_FAILED = -2147416012; - -const int CSSMERR_CSP_ACL_REPLACE_FAILED = -2147416011; - -const int CSSMERR_CSP_ACL_ADD_FAILED = -2147416010; - -const int CSSMERR_CSP_INVALID_CONTEXT_HANDLE = -2147416000; - -const int CSSMERR_CSP_PRIVILEGE_NOT_GRANTED = -2147415989; - -const int CSSMERR_CSP_INVALID_DATA = -2147415994; - -const int CSSMERR_CSP_INVALID_PASSTHROUGH_ID = -2147415978; - -const int CSSMERR_CSP_INVALID_CRYPTO_DATA = -2147415976; - -const int CSSM_CSP_BASE_CSP_ERROR = -2147415808; - -const int CSSMERR_CSP_INPUT_LENGTH_ERROR = -2147415807; - -const int CSSMERR_CSP_OUTPUT_LENGTH_ERROR = -2147415806; - -const int CSSMERR_CSP_PRIVILEGE_NOT_SUPPORTED = -2147415805; - -const int CSSMERR_CSP_DEVICE_ERROR = -2147415804; - -const int CSSMERR_CSP_DEVICE_MEMORY_ERROR = -2147415803; - -const int CSSMERR_CSP_ATTACH_HANDLE_BUSY = -2147415802; - -const int CSSMERR_CSP_NOT_LOGGED_IN = -2147415801; - -const int CSSMERR_CSP_INVALID_KEY = -2147415792; - -const int CSSMERR_CSP_INVALID_KEY_REFERENCE = -2147415791; - -const int CSSMERR_CSP_INVALID_KEY_CLASS = -2147415790; - -const int CSSMERR_CSP_ALGID_MISMATCH = -2147415789; - -const int CSSMERR_CSP_KEY_USAGE_INCORRECT = -2147415788; - -const int CSSMERR_CSP_KEY_BLOB_TYPE_INCORRECT = -2147415787; - -const int CSSMERR_CSP_KEY_HEADER_INCONSISTENT = -2147415786; - -const int CSSMERR_CSP_UNSUPPORTED_KEY_FORMAT = -2147415785; - -const int CSSMERR_CSP_UNSUPPORTED_KEY_SIZE = -2147415784; - -const int CSSMERR_CSP_INVALID_KEY_POINTER = -2147415783; - -const int CSSMERR_CSP_INVALID_KEYUSAGE_MASK = -2147415782; - -const int CSSMERR_CSP_UNSUPPORTED_KEYUSAGE_MASK = -2147415781; - -const int CSSMERR_CSP_INVALID_KEYATTR_MASK = -2147415780; - -const int CSSMERR_CSP_UNSUPPORTED_KEYATTR_MASK = -2147415779; - -const int CSSMERR_CSP_INVALID_KEY_LABEL = -2147415778; - -const int CSSMERR_CSP_UNSUPPORTED_KEY_LABEL = -2147415777; - -const int CSSMERR_CSP_INVALID_KEY_FORMAT = -2147415776; - -const int CSSMERR_CSP_INVALID_DATA_COUNT = -2147415768; - -const int CSSMERR_CSP_VECTOR_OF_BUFS_UNSUPPORTED = -2147415767; - -const int CSSMERR_CSP_INVALID_INPUT_VECTOR = -2147415766; - -const int CSSMERR_CSP_INVALID_OUTPUT_VECTOR = -2147415765; - -const int CSSMERR_CSP_INVALID_CONTEXT = -2147415760; - -const int CSSMERR_CSP_INVALID_ALGORITHM = -2147415759; - -const int CSSMERR_CSP_INVALID_ATTR_KEY = -2147415754; - -const int CSSMERR_CSP_MISSING_ATTR_KEY = -2147415753; - -const int CSSMERR_CSP_INVALID_ATTR_INIT_VECTOR = -2147415752; - -const int CSSMERR_CSP_MISSING_ATTR_INIT_VECTOR = -2147415751; - -const int CSSMERR_CSP_INVALID_ATTR_SALT = -2147415750; - -const int CSSMERR_CSP_MISSING_ATTR_SALT = -2147415749; - -const int CSSMERR_CSP_INVALID_ATTR_PADDING = -2147415748; - -const int CSSMERR_CSP_MISSING_ATTR_PADDING = -2147415747; - -const int CSSMERR_CSP_INVALID_ATTR_RANDOM = -2147415746; - -const int CSSMERR_CSP_MISSING_ATTR_RANDOM = -2147415745; - -const int CSSMERR_CSP_INVALID_ATTR_SEED = -2147415744; - -const int CSSMERR_CSP_MISSING_ATTR_SEED = -2147415743; - -const int CSSMERR_CSP_INVALID_ATTR_PASSPHRASE = -2147415742; - -const int CSSMERR_CSP_MISSING_ATTR_PASSPHRASE = -2147415741; - -const int CSSMERR_CSP_INVALID_ATTR_KEY_LENGTH = -2147415740; - -const int CSSMERR_CSP_MISSING_ATTR_KEY_LENGTH = -2147415739; - -const int CSSMERR_CSP_INVALID_ATTR_BLOCK_SIZE = -2147415738; - -const int CSSMERR_CSP_MISSING_ATTR_BLOCK_SIZE = -2147415737; - -const int CSSMERR_CSP_INVALID_ATTR_OUTPUT_SIZE = -2147415708; - -const int CSSMERR_CSP_MISSING_ATTR_OUTPUT_SIZE = -2147415707; - -const int CSSMERR_CSP_INVALID_ATTR_ROUNDS = -2147415706; - -const int CSSMERR_CSP_MISSING_ATTR_ROUNDS = -2147415705; - -const int CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS = -2147415704; - -const int CSSMERR_CSP_MISSING_ATTR_ALG_PARAMS = -2147415703; - -const int CSSMERR_CSP_INVALID_ATTR_LABEL = -2147415702; - -const int CSSMERR_CSP_MISSING_ATTR_LABEL = -2147415701; - -const int CSSMERR_CSP_INVALID_ATTR_KEY_TYPE = -2147415700; - -const int CSSMERR_CSP_MISSING_ATTR_KEY_TYPE = -2147415699; - -const int CSSMERR_CSP_INVALID_ATTR_MODE = -2147415698; - -const int CSSMERR_CSP_MISSING_ATTR_MODE = -2147415697; - -const int CSSMERR_CSP_INVALID_ATTR_EFFECTIVE_BITS = -2147415696; - -const int CSSMERR_CSP_MISSING_ATTR_EFFECTIVE_BITS = -2147415695; - -const int CSSMERR_CSP_INVALID_ATTR_START_DATE = -2147415694; - -const int CSSMERR_CSP_MISSING_ATTR_START_DATE = -2147415693; - -const int CSSMERR_CSP_INVALID_ATTR_END_DATE = -2147415692; - -const int CSSMERR_CSP_MISSING_ATTR_END_DATE = -2147415691; - -const int CSSMERR_CSP_INVALID_ATTR_VERSION = -2147415690; - -const int CSSMERR_CSP_MISSING_ATTR_VERSION = -2147415689; - -const int CSSMERR_CSP_INVALID_ATTR_PRIME = -2147415688; - -const int CSSMERR_CSP_MISSING_ATTR_PRIME = -2147415687; - -const int CSSMERR_CSP_INVALID_ATTR_BASE = -2147415686; - -const int CSSMERR_CSP_MISSING_ATTR_BASE = -2147415685; - -const int CSSMERR_CSP_INVALID_ATTR_SUBPRIME = -2147415684; - -const int CSSMERR_CSP_MISSING_ATTR_SUBPRIME = -2147415683; - -const int CSSMERR_CSP_INVALID_ATTR_ITERATION_COUNT = -2147415682; - -const int CSSMERR_CSP_MISSING_ATTR_ITERATION_COUNT = -2147415681; - -const int CSSMERR_CSP_INVALID_ATTR_DL_DB_HANDLE = -2147415680; - -const int CSSMERR_CSP_MISSING_ATTR_DL_DB_HANDLE = -2147415679; - -const int CSSMERR_CSP_INVALID_ATTR_ACCESS_CREDENTIALS = -2147415678; - -const int CSSMERR_CSP_MISSING_ATTR_ACCESS_CREDENTIALS = -2147415677; - -const int CSSMERR_CSP_INVALID_ATTR_PUBLIC_KEY_FORMAT = -2147415676; - -const int CSSMERR_CSP_MISSING_ATTR_PUBLIC_KEY_FORMAT = -2147415675; - -const int CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT = -2147415674; - -const int CSSMERR_CSP_MISSING_ATTR_PRIVATE_KEY_FORMAT = -2147415673; - -const int CSSMERR_CSP_INVALID_ATTR_SYMMETRIC_KEY_FORMAT = -2147415672; - -const int CSSMERR_CSP_MISSING_ATTR_SYMMETRIC_KEY_FORMAT = -2147415671; - -const int CSSMERR_CSP_INVALID_ATTR_WRAPPED_KEY_FORMAT = -2147415670; - -const int CSSMERR_CSP_MISSING_ATTR_WRAPPED_KEY_FORMAT = -2147415669; - -const int CSSMERR_CSP_STAGED_OPERATION_IN_PROGRESS = -2147415736; - -const int CSSMERR_CSP_STAGED_OPERATION_NOT_STARTED = -2147415735; - -const int CSSMERR_CSP_VERIFY_FAILED = -2147415734; - -const int CSSMERR_CSP_INVALID_SIGNATURE = -2147415733; - -const int CSSMERR_CSP_QUERY_SIZE_UNKNOWN = -2147415732; - -const int CSSMERR_CSP_BLOCK_SIZE_MISMATCH = -2147415731; - -const int CSSMERR_CSP_PRIVATE_KEY_NOT_FOUND = -2147415730; - -const int CSSMERR_CSP_PUBLIC_KEY_INCONSISTENT = -2147415729; - -const int CSSMERR_CSP_DEVICE_VERIFY_FAILED = -2147415728; - -const int CSSMERR_CSP_INVALID_LOGIN_NAME = -2147415727; - -const int CSSMERR_CSP_ALREADY_LOGGED_IN = -2147415726; - -const int CSSMERR_CSP_PRIVATE_KEY_ALREADY_EXISTS = -2147415725; - -const int CSSMERR_CSP_KEY_LABEL_ALREADY_EXISTS = -2147415724; - -const int CSSMERR_CSP_INVALID_DIGEST_ALGORITHM = -2147415723; - -const int CSSMERR_CSP_CRYPTO_DATA_CALLBACK_FAILED = -2147415722; - -const int CSSMERR_TP_INTERNAL_ERROR = -2147409919; - -const int CSSMERR_TP_MEMORY_ERROR = -2147409918; - -const int CSSMERR_TP_MDS_ERROR = -2147409917; - -const int CSSMERR_TP_INVALID_POINTER = -2147409916; - -const int CSSMERR_TP_INVALID_INPUT_POINTER = -2147409915; - -const int CSSMERR_TP_INVALID_OUTPUT_POINTER = -2147409914; - -const int CSSMERR_TP_FUNCTION_NOT_IMPLEMENTED = -2147409913; - -const int CSSMERR_TP_SELF_CHECK_FAILED = -2147409912; - -const int CSSMERR_TP_OS_ACCESS_DENIED = -2147409911; - -const int CSSMERR_TP_FUNCTION_FAILED = -2147409910; - -const int CSSMERR_TP_INVALID_CONTEXT_HANDLE = -2147409856; - -const int CSSMERR_TP_INVALID_DATA = -2147409850; - -const int CSSMERR_TP_INVALID_DB_LIST = -2147409844; - -const int CSSMERR_TP_INVALID_CERTGROUP_POINTER = -2147409854; - -const int CSSMERR_TP_INVALID_CERT_POINTER = -2147409853; - -const int CSSMERR_TP_INVALID_CRL_POINTER = -2147409852; - -const int CSSMERR_TP_INVALID_FIELD_POINTER = -2147409851; - -const int CSSMERR_TP_INVALID_NETWORK_ADDR = -2147409833; - -const int CSSMERR_TP_CRL_ALREADY_SIGNED = -2147409849; - -const int CSSMERR_TP_INVALID_NUMBER_OF_FIELDS = -2147409848; - -const int CSSMERR_TP_VERIFICATION_FAILURE = -2147409847; - -const int CSSMERR_TP_INVALID_DB_HANDLE = -2147409846; - -const int CSSMERR_TP_UNKNOWN_FORMAT = -2147409842; - -const int CSSMERR_TP_UNKNOWN_TAG = -2147409841; - -const int CSSMERR_TP_INVALID_PASSTHROUGH_ID = -2147409834; - -const int CSSMERR_TP_INVALID_CSP_HANDLE = -2147409840; - -const int CSSMERR_TP_INVALID_DL_HANDLE = -2147409839; - -const int CSSMERR_TP_INVALID_CL_HANDLE = -2147409838; - -const int CSSMERR_TP_INVALID_DB_LIST_POINTER = -2147409843; - -const int CSSM_TP_BASE_TP_ERROR = -2147409664; - -const int CSSMERR_TP_INVALID_CALLERAUTH_CONTEXT_POINTER = -2147409663; - -const int CSSMERR_TP_INVALID_IDENTIFIER_POINTER = -2147409662; - -const int CSSMERR_TP_INVALID_KEYCACHE_HANDLE = -2147409661; - -const int CSSMERR_TP_INVALID_CERTGROUP = -2147409660; - -const int CSSMERR_TP_INVALID_CRLGROUP = -2147409659; - -const int CSSMERR_TP_INVALID_CRLGROUP_POINTER = -2147409658; - -const int CSSMERR_TP_AUTHENTICATION_FAILED = -2147409657; - -const int CSSMERR_TP_CERTGROUP_INCOMPLETE = -2147409656; - -const int CSSMERR_TP_CERTIFICATE_CANT_OPERATE = -2147409655; - -const int CSSMERR_TP_CERT_EXPIRED = -2147409654; - -const int CSSMERR_TP_CERT_NOT_VALID_YET = -2147409653; - -const int CSSMERR_TP_CERT_REVOKED = -2147409652; - -const int CSSMERR_TP_CERT_SUSPENDED = -2147409651; - -const int CSSMERR_TP_INSUFFICIENT_CREDENTIALS = -2147409650; - -const int CSSMERR_TP_INVALID_ACTION = -2147409649; - -const int CSSMERR_TP_INVALID_ACTION_DATA = -2147409648; - -const int CSSMERR_TP_INVALID_ANCHOR_CERT = -2147409646; - -const int CSSMERR_TP_INVALID_AUTHORITY = -2147409645; - -const int CSSMERR_TP_VERIFY_ACTION_FAILED = -2147409644; - -const int CSSMERR_TP_INVALID_CERTIFICATE = -2147409643; - -const int CSSMERR_TP_INVALID_CERT_AUTHORITY = -2147409642; - -const int CSSMERR_TP_INVALID_CRL_AUTHORITY = -2147409641; - -const int CSSMERR_TP_INVALID_CRL_ENCODING = -2147409640; - -const int CSSMERR_TP_INVALID_CRL_TYPE = -2147409639; - -const int CSSMERR_TP_INVALID_CRL = -2147409638; - -const int CSSMERR_TP_INVALID_FORM_TYPE = -2147409637; - -const int CSSMERR_TP_INVALID_ID = -2147409636; - -const int CSSMERR_TP_INVALID_IDENTIFIER = -2147409635; - -const int CSSMERR_TP_INVALID_INDEX = -2147409634; - -const int CSSMERR_TP_INVALID_NAME = -2147409633; - -const int CSSMERR_TP_INVALID_POLICY_IDENTIFIERS = -2147409632; - -const int CSSMERR_TP_INVALID_TIMESTRING = -2147409631; - -const int CSSMERR_TP_INVALID_REASON = -2147409630; - -const int CSSMERR_TP_INVALID_REQUEST_INPUTS = -2147409629; - -const int CSSMERR_TP_INVALID_RESPONSE_VECTOR = -2147409628; - -const int CSSMERR_TP_INVALID_SIGNATURE = -2147409627; - -const int CSSMERR_TP_INVALID_STOP_ON_POLICY = -2147409626; - -const int CSSMERR_TP_INVALID_CALLBACK = -2147409625; - -const int CSSMERR_TP_INVALID_TUPLE = -2147409624; - -const int CSSMERR_TP_NOT_SIGNER = -2147409623; - -const int CSSMERR_TP_NOT_TRUSTED = -2147409622; - -const int CSSMERR_TP_NO_DEFAULT_AUTHORITY = -2147409621; - -const int CSSMERR_TP_REJECTED_FORM = -2147409620; - -const int CSSMERR_TP_REQUEST_LOST = -2147409619; - -const int CSSMERR_TP_REQUEST_REJECTED = -2147409618; - -const int CSSMERR_TP_UNSUPPORTED_ADDR_TYPE = -2147409617; - -const int CSSMERR_TP_UNSUPPORTED_SERVICE = -2147409616; - -const int CSSMERR_TP_INVALID_TUPLEGROUP_POINTER = -2147409615; - -const int CSSMERR_TP_INVALID_TUPLEGROUP = -2147409614; - -const int CSSMERR_AC_INTERNAL_ERROR = -2147405823; - -const int CSSMERR_AC_MEMORY_ERROR = -2147405822; - -const int CSSMERR_AC_MDS_ERROR = -2147405821; - -const int CSSMERR_AC_INVALID_POINTER = -2147405820; - -const int CSSMERR_AC_INVALID_INPUT_POINTER = -2147405819; - -const int CSSMERR_AC_INVALID_OUTPUT_POINTER = -2147405818; - -const int CSSMERR_AC_FUNCTION_NOT_IMPLEMENTED = -2147405817; - -const int CSSMERR_AC_SELF_CHECK_FAILED = -2147405816; - -const int CSSMERR_AC_OS_ACCESS_DENIED = -2147405815; - -const int CSSMERR_AC_FUNCTION_FAILED = -2147405814; - -const int CSSMERR_AC_INVALID_CONTEXT_HANDLE = -2147405760; - -const int CSSMERR_AC_INVALID_DATA = -2147405754; - -const int CSSMERR_AC_INVALID_DB_LIST = -2147405748; - -const int CSSMERR_AC_INVALID_PASSTHROUGH_ID = -2147405738; - -const int CSSMERR_AC_INVALID_DL_HANDLE = -2147405743; - -const int CSSMERR_AC_INVALID_CL_HANDLE = -2147405742; - -const int CSSMERR_AC_INVALID_TP_HANDLE = -2147405741; - -const int CSSMERR_AC_INVALID_DB_HANDLE = -2147405750; - -const int CSSMERR_AC_INVALID_DB_LIST_POINTER = -2147405747; - -const int CSSM_AC_BASE_AC_ERROR = -2147405568; - -const int CSSMERR_AC_INVALID_BASE_ACLS = -2147405567; - -const int CSSMERR_AC_INVALID_TUPLE_CREDENTIALS = -2147405566; - -const int CSSMERR_AC_INVALID_ENCODING = -2147405565; - -const int CSSMERR_AC_INVALID_VALIDITY_PERIOD = -2147405564; - -const int CSSMERR_AC_INVALID_REQUESTOR = -2147405563; - -const int CSSMERR_AC_INVALID_REQUEST_DESCRIPTOR = -2147405562; - -const int CSSMERR_CL_INTERNAL_ERROR = -2147411967; - -const int CSSMERR_CL_MEMORY_ERROR = -2147411966; - -const int CSSMERR_CL_MDS_ERROR = -2147411965; - -const int CSSMERR_CL_INVALID_POINTER = -2147411964; - -const int CSSMERR_CL_INVALID_INPUT_POINTER = -2147411963; - -const int CSSMERR_CL_INVALID_OUTPUT_POINTER = -2147411962; - -const int CSSMERR_CL_FUNCTION_NOT_IMPLEMENTED = -2147411961; - -const int CSSMERR_CL_SELF_CHECK_FAILED = -2147411960; - -const int CSSMERR_CL_OS_ACCESS_DENIED = -2147411959; - -const int CSSMERR_CL_FUNCTION_FAILED = -2147411958; - -const int CSSMERR_CL_INVALID_CONTEXT_HANDLE = -2147411904; - -const int CSSMERR_CL_INVALID_CERTGROUP_POINTER = -2147411902; - -const int CSSMERR_CL_INVALID_CERT_POINTER = -2147411901; - -const int CSSMERR_CL_INVALID_CRL_POINTER = -2147411900; - -const int CSSMERR_CL_INVALID_FIELD_POINTER = -2147411899; - -const int CSSMERR_CL_INVALID_DATA = -2147411898; - -const int CSSMERR_CL_CRL_ALREADY_SIGNED = -2147411897; - -const int CSSMERR_CL_INVALID_NUMBER_OF_FIELDS = -2147411896; - -const int CSSMERR_CL_VERIFICATION_FAILURE = -2147411895; - -const int CSSMERR_CL_UNKNOWN_FORMAT = -2147411890; - -const int CSSMERR_CL_UNKNOWN_TAG = -2147411889; - -const int CSSMERR_CL_INVALID_PASSTHROUGH_ID = -2147411882; - -const int CSSM_CL_BASE_CL_ERROR = -2147411712; - -const int CSSMERR_CL_INVALID_BUNDLE_POINTER = -2147411711; - -const int CSSMERR_CL_INVALID_CACHE_HANDLE = -2147411710; - -const int CSSMERR_CL_INVALID_RESULTS_HANDLE = -2147411709; - -const int CSSMERR_CL_INVALID_BUNDLE_INFO = -2147411708; - -const int CSSMERR_CL_INVALID_CRL_INDEX = -2147411707; - -const int CSSMERR_CL_INVALID_SCOPE = -2147411706; - -const int CSSMERR_CL_NO_FIELD_VALUES = -2147411705; - -const int CSSMERR_CL_SCOPE_NOT_SUPPORTED = -2147411704; - -const int CSSMERR_DL_INTERNAL_ERROR = -2147414015; - -const int CSSMERR_DL_MEMORY_ERROR = -2147414014; - -const int CSSMERR_DL_MDS_ERROR = -2147414013; - -const int CSSMERR_DL_INVALID_POINTER = -2147414012; - -const int CSSMERR_DL_INVALID_INPUT_POINTER = -2147414011; - -const int CSSMERR_DL_INVALID_OUTPUT_POINTER = -2147414010; - -const int CSSMERR_DL_FUNCTION_NOT_IMPLEMENTED = -2147414009; - -const int CSSMERR_DL_SELF_CHECK_FAILED = -2147414008; - -const int CSSMERR_DL_OS_ACCESS_DENIED = -2147414007; - -const int CSSMERR_DL_FUNCTION_FAILED = -2147414006; - -const int CSSMERR_DL_INVALID_CSP_HANDLE = -2147413936; - -const int CSSMERR_DL_INVALID_DL_HANDLE = -2147413935; - -const int CSSMERR_DL_INVALID_CL_HANDLE = -2147413934; - -const int CSSMERR_DL_INVALID_DB_LIST_POINTER = -2147413939; - -const int CSSMERR_DL_OPERATION_AUTH_DENIED = -2147413984; - -const int CSSMERR_DL_OBJECT_USE_AUTH_DENIED = -2147413983; - -const int CSSMERR_DL_OBJECT_MANIP_AUTH_DENIED = -2147413982; - -const int CSSMERR_DL_OBJECT_ACL_NOT_SUPPORTED = -2147413981; - -const int CSSMERR_DL_OBJECT_ACL_REQUIRED = -2147413980; - -const int CSSMERR_DL_INVALID_ACCESS_CREDENTIALS = -2147413979; - -const int CSSMERR_DL_INVALID_ACL_BASE_CERTS = -2147413978; - -const int CSSMERR_DL_ACL_BASE_CERTS_NOT_SUPPORTED = -2147413977; - -const int CSSMERR_DL_INVALID_SAMPLE_VALUE = -2147413976; - -const int CSSMERR_DL_SAMPLE_VALUE_NOT_SUPPORTED = -2147413975; - -const int CSSMERR_DL_INVALID_ACL_SUBJECT_VALUE = -2147413974; - -const int CSSMERR_DL_ACL_SUBJECT_TYPE_NOT_SUPPORTED = -2147413973; - -const int CSSMERR_DL_INVALID_ACL_CHALLENGE_CALLBACK = -2147413972; - -const int CSSMERR_DL_ACL_CHALLENGE_CALLBACK_FAILED = -2147413971; - -const int CSSMERR_DL_INVALID_ACL_ENTRY_TAG = -2147413970; - -const int CSSMERR_DL_ACL_ENTRY_TAG_NOT_FOUND = -2147413969; - -const int CSSMERR_DL_INVALID_ACL_EDIT_MODE = -2147413968; - -const int CSSMERR_DL_ACL_CHANGE_FAILED = -2147413967; - -const int CSSMERR_DL_INVALID_NEW_ACL_ENTRY = -2147413966; - -const int CSSMERR_DL_INVALID_NEW_ACL_OWNER = -2147413965; - -const int CSSMERR_DL_ACL_DELETE_FAILED = -2147413964; - -const int CSSMERR_DL_ACL_REPLACE_FAILED = -2147413963; - -const int CSSMERR_DL_ACL_ADD_FAILED = -2147413962; - -const int CSSMERR_DL_INVALID_DB_HANDLE = -2147413942; - -const int CSSMERR_DL_INVALID_PASSTHROUGH_ID = -2147413930; - -const int CSSMERR_DL_INVALID_NETWORK_ADDR = -2147413929; - -const int CSSM_DL_BASE_DL_ERROR = -2147413760; - -const int CSSMERR_DL_DATABASE_CORRUPT = -2147413759; - -const int CSSMERR_DL_INVALID_RECORD_INDEX = -2147413752; - -const int CSSMERR_DL_INVALID_RECORDTYPE = -2147413751; - -const int CSSMERR_DL_INVALID_FIELD_NAME = -2147413750; - -const int CSSMERR_DL_UNSUPPORTED_FIELD_FORMAT = -2147413749; - -const int CSSMERR_DL_UNSUPPORTED_INDEX_INFO = -2147413748; - -const int CSSMERR_DL_UNSUPPORTED_LOCALITY = -2147413747; - -const int CSSMERR_DL_UNSUPPORTED_NUM_ATTRIBUTES = -2147413746; - -const int CSSMERR_DL_UNSUPPORTED_NUM_INDEXES = -2147413745; - -const int CSSMERR_DL_UNSUPPORTED_NUM_RECORDTYPES = -2147413744; - -const int CSSMERR_DL_UNSUPPORTED_RECORDTYPE = -2147413743; - -const int CSSMERR_DL_FIELD_SPECIFIED_MULTIPLE = -2147413742; - -const int CSSMERR_DL_INCOMPATIBLE_FIELD_FORMAT = -2147413741; - -const int CSSMERR_DL_INVALID_PARSING_MODULE = -2147413740; - -const int CSSMERR_DL_INVALID_DB_NAME = -2147413738; - -const int CSSMERR_DL_DATASTORE_DOESNOT_EXIST = -2147413737; - -const int CSSMERR_DL_DATASTORE_ALREADY_EXISTS = -2147413736; - -const int CSSMERR_DL_DB_LOCKED = -2147413735; - -const int CSSMERR_DL_DATASTORE_IS_OPEN = -2147413734; - -const int CSSMERR_DL_RECORD_NOT_FOUND = -2147413733; - -const int CSSMERR_DL_MISSING_VALUE = -2147413732; - -const int CSSMERR_DL_UNSUPPORTED_QUERY = -2147413731; - -const int CSSMERR_DL_UNSUPPORTED_QUERY_LIMITS = -2147413730; - -const int CSSMERR_DL_UNSUPPORTED_NUM_SELECTION_PREDS = -2147413729; - -const int CSSMERR_DL_UNSUPPORTED_OPERATOR = -2147413727; - -const int CSSMERR_DL_INVALID_RESULTS_HANDLE = -2147413726; - -const int CSSMERR_DL_INVALID_DB_LOCATION = -2147413725; - -const int CSSMERR_DL_INVALID_ACCESS_REQUEST = -2147413724; - -const int CSSMERR_DL_INVALID_INDEX_INFO = -2147413723; - -const int CSSMERR_DL_INVALID_SELECTION_TAG = -2147413722; - -const int CSSMERR_DL_INVALID_NEW_OWNER = -2147413721; - -const int CSSMERR_DL_INVALID_RECORD_UID = -2147413720; - -const int CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA = -2147413719; - -const int CSSMERR_DL_INVALID_MODIFY_MODE = -2147413718; - -const int CSSMERR_DL_INVALID_OPEN_PARAMETERS = -2147413717; - -const int CSSMERR_DL_RECORD_MODIFIED = -2147413716; - -const int CSSMERR_DL_ENDOFDATA = -2147413715; - -const int CSSMERR_DL_INVALID_QUERY = -2147413714; - -const int CSSMERR_DL_INVALID_VALUE = -2147413713; - -const int CSSMERR_DL_MULTIPLE_VALUES_UNSUPPORTED = -2147413712; - -const int CSSMERR_DL_STALE_UNIQUE_RECORD = -2147413711; - -const int CSSM_WORDID_KEYCHAIN_PROMPT = 65536; - -const int CSSM_WORDID_KEYCHAIN_LOCK = 65537; - -const int CSSM_WORDID_KEYCHAIN_CHANGE_LOCK = 65538; - -const int CSSM_WORDID_PROCESS = 65539; - -const int CSSM_WORDID__RESERVED_1 = 65540; - -const int CSSM_WORDID_SYMMETRIC_KEY = 65541; - -const int CSSM_WORDID_SYSTEM = 65542; - -const int CSSM_WORDID_KEY = 65543; - -const int CSSM_WORDID_PIN = 65544; - -const int CSSM_WORDID_PREAUTH = 65545; - -const int CSSM_WORDID_PREAUTH_SOURCE = 65546; - -const int CSSM_WORDID_ASYMMETRIC_KEY = 65547; - -const int CSSM_WORDID_PARTITION = 65548; - -const int CSSM_WORDID_KEYBAG_KEY = 65549; - -const int CSSM_WORDID__FIRST_UNUSED = 65550; - -const int CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT = 65536; - -const int CSSM_ACL_SUBJECT_TYPE_PROCESS = 65539; - -const int CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE = 116; - -const int CSSM_ACL_SUBJECT_TYPE_COMMENT = 12; - -const int CSSM_ACL_SUBJECT_TYPE_SYMMETRIC_KEY = 65541; - -const int CSSM_ACL_SUBJECT_TYPE_PREAUTH = 65545; - -const int CSSM_ACL_SUBJECT_TYPE_PREAUTH_SOURCE = 65546; - -const int CSSM_ACL_SUBJECT_TYPE_ASYMMETRIC_KEY = 65547; - -const int CSSM_ACL_SUBJECT_TYPE_PARTITION = 65548; - -const int CSSM_SAMPLE_TYPE_KEYCHAIN_PROMPT = 65536; - -const int CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK = 65537; - -const int CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK = 65538; - -const int CSSM_SAMPLE_TYPE_PROCESS = 65539; - -const int CSSM_SAMPLE_TYPE_COMMENT = 12; - -const int CSSM_SAMPLE_TYPE_RETRY_ID = 85; - -const int CSSM_SAMPLE_TYPE_SYMMETRIC_KEY = 65541; - -const int CSSM_SAMPLE_TYPE_PREAUTH = 65545; - -const int CSSM_SAMPLE_TYPE_ASYMMETRIC_KEY = 65547; - -const int CSSM_SAMPLE_TYPE_KEYBAG_KEY = 65549; - -const int CSSM_ACL_AUTHORIZATION_CHANGE_ACL = 65536; - -const int CSSM_ACL_AUTHORIZATION_CHANGE_OWNER = 65537; - -const int CSSM_ACL_AUTHORIZATION_PARTITION_ID = 65538; - -const int CSSM_ACL_AUTHORIZATION_INTEGRITY = 65539; - -const int CSSM_ACL_AUTHORIZATION_PREAUTH_BASE = 16842752; - -const int CSSM_ACL_AUTHORIZATION_PREAUTH_END = 16908288; - -const int CSSM_ACL_CODE_SIGNATURE_INVALID = 0; - -const int CSSM_ACL_CODE_SIGNATURE_OSX = 1; - -const int CSSM_ACL_MATCH_UID = 1; - -const int CSSM_ACL_MATCH_GID = 2; - -const int CSSM_ACL_MATCH_HONOR_ROOT = 256; - -const int CSSM_ACL_MATCH_BITS = 3; - -const int CSSM_ACL_PROCESS_SELECTOR_CURRENT_VERSION = 257; - -const int CSSM_ACL_KEYCHAIN_PROMPT_CURRENT_VERSION = 257; - -const int CSSM_ACL_KEYCHAIN_PROMPT_REQUIRE_PASSPHRASE = 1; - -const int CSSM_ACL_KEYCHAIN_PROMPT_UNSIGNED = 16; - -const int CSSM_ACL_KEYCHAIN_PROMPT_UNSIGNED_ACT = 32; - -const int CSSM_ACL_KEYCHAIN_PROMPT_INVALID = 64; - -const int CSSM_ACL_KEYCHAIN_PROMPT_INVALID_ACT = 128; - -const int CSSM_ACL_PREAUTH_TRACKING_COUNT_MASK = 255; - -const int CSSM_ACL_PREAUTH_TRACKING_BLOCKED = 0; - -const int CSSM_ACL_PREAUTH_TRACKING_UNKNOWN = 1073741824; - -const int CSSM_ACL_PREAUTH_TRACKING_AUTHORIZED = -2147483648; - -const int CSSM_DB_ACCESS_RESET = 65536; - -const int CSSM_ALGID_APPLE_YARROW = -2147483648; - -const int CSSM_ALGID_AES = -2147483647; - -const int CSSM_ALGID_FEE = -2147483646; - -const int CSSM_ALGID_FEE_MD5 = -2147483645; - -const int CSSM_ALGID_FEE_SHA1 = -2147483644; - -const int CSSM_ALGID_FEED = -2147483643; - -const int CSSM_ALGID_FEEDEXP = -2147483642; - -const int CSSM_ALGID_ASC = -2147483641; - -const int CSSM_ALGID_SHA1HMAC_LEGACY = -2147483640; - -const int CSSM_ALGID_KEYCHAIN_KEY = -2147483639; - -const int CSSM_ALGID_PKCS12_PBE_ENCR = -2147483638; - -const int CSSM_ALGID_PKCS12_PBE_MAC = -2147483637; - -const int CSSM_ALGID_SECURE_PASSPHRASE = -2147483636; - -const int CSSM_ALGID_PBE_OPENSSL_MD5 = -2147483635; - -const int CSSM_ALGID_SHA256 = -2147483634; - -const int CSSM_ALGID_SHA384 = -2147483633; - -const int CSSM_ALGID_SHA512 = -2147483632; - -const int CSSM_ALGID_ENTROPY_DEFAULT = -2147483631; - -const int CSSM_ALGID_SHA224 = -2147483630; - -const int CSSM_ALGID_SHA224WithRSA = -2147483629; - -const int CSSM_ALGID_SHA256WithRSA = -2147483628; - -const int CSSM_ALGID_SHA384WithRSA = -2147483627; - -const int CSSM_ALGID_SHA512WithRSA = -2147483626; - -const int CSSM_ALGID_OPENSSH1 = -2147483625; - -const int CSSM_ALGID_SHA224WithECDSA = -2147483624; - -const int CSSM_ALGID_SHA256WithECDSA = -2147483623; - -const int CSSM_ALGID_SHA384WithECDSA = -2147483622; - -const int CSSM_ALGID_SHA512WithECDSA = -2147483621; - -const int CSSM_ALGID_ECDSA_SPECIFIED = -2147483620; - -const int CSSM_ALGID_ECDH_X963_KDF = -2147483619; - -const int CSSM_ALGID__FIRST_UNUSED = -2147483618; - -const int CSSM_PADDING_APPLE_SSLv2 = -2147483648; - -const int CSSM_KEYBLOB_RAW_FORMAT_VENDOR_DEFINED = -2147483648; - -const int CSSM_KEYBLOB_RAW_FORMAT_X509 = -2147483648; - -const int CSSM_KEYBLOB_RAW_FORMAT_OPENSSH = -2147483647; - -const int CSSM_KEYBLOB_RAW_FORMAT_OPENSSL = -2147483646; - -const int CSSM_KEYBLOB_RAW_FORMAT_OPENSSH2 = -2147483645; - -const int CSSM_CUSTOM_COMMON_ERROR_EXTENT = 224; - -const int CSSM_ERRCODE_NO_USER_INTERACTION = 224; - -const int CSSM_ERRCODE_USER_CANCELED = 225; - -const int CSSM_ERRCODE_SERVICE_NOT_AVAILABLE = 226; - -const int CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION = 227; - -const int CSSM_ERRCODE_DEVICE_RESET = 228; - -const int CSSM_ERRCODE_DEVICE_FAILED = 229; - -const int CSSM_ERRCODE_IN_DARK_WAKE = 230; - -const int CSSMERR_CSSM_NO_USER_INTERACTION = -2147417888; - -const int CSSMERR_AC_NO_USER_INTERACTION = -2147405600; - -const int CSSMERR_CSP_NO_USER_INTERACTION = -2147415840; - -const int CSSMERR_CL_NO_USER_INTERACTION = -2147411744; - -const int CSSMERR_DL_NO_USER_INTERACTION = -2147413792; - -const int CSSMERR_TP_NO_USER_INTERACTION = -2147409696; - -const int CSSMERR_CSSM_USER_CANCELED = -2147417887; - -const int CSSMERR_AC_USER_CANCELED = -2147405599; - -const int CSSMERR_CSP_USER_CANCELED = -2147415839; - -const int CSSMERR_CL_USER_CANCELED = -2147411743; - -const int CSSMERR_DL_USER_CANCELED = -2147413791; - -const int CSSMERR_TP_USER_CANCELED = -2147409695; - -const int CSSMERR_CSSM_SERVICE_NOT_AVAILABLE = -2147417886; - -const int CSSMERR_AC_SERVICE_NOT_AVAILABLE = -2147405598; - -const int CSSMERR_CSP_SERVICE_NOT_AVAILABLE = -2147415838; - -const int CSSMERR_CL_SERVICE_NOT_AVAILABLE = -2147411742; - -const int CSSMERR_DL_SERVICE_NOT_AVAILABLE = -2147413790; - -const int CSSMERR_TP_SERVICE_NOT_AVAILABLE = -2147409694; - -const int CSSMERR_CSSM_INSUFFICIENT_CLIENT_IDENTIFICATION = -2147417885; - -const int CSSMERR_AC_INSUFFICIENT_CLIENT_IDENTIFICATION = -2147405597; - -const int CSSMERR_CSP_INSUFFICIENT_CLIENT_IDENTIFICATION = -2147415837; - -const int CSSMERR_CL_INSUFFICIENT_CLIENT_IDENTIFICATION = -2147411741; - -const int CSSMERR_DL_INSUFFICIENT_CLIENT_IDENTIFICATION = -2147413789; - -const int CSSMERR_TP_INSUFFICIENT_CLIENT_IDENTIFICATION = -2147409693; - -const int CSSMERR_CSSM_DEVICE_RESET = -2147417884; - -const int CSSMERR_AC_DEVICE_RESET = -2147405596; - -const int CSSMERR_CSP_DEVICE_RESET = -2147415836; - -const int CSSMERR_CL_DEVICE_RESET = -2147411740; - -const int CSSMERR_DL_DEVICE_RESET = -2147413788; - -const int CSSMERR_TP_DEVICE_RESET = -2147409692; - -const int CSSMERR_CSSM_DEVICE_FAILED = -2147417883; - -const int CSSMERR_AC_DEVICE_FAILED = -2147405595; - -const int CSSMERR_CSP_DEVICE_FAILED = -2147415835; - -const int CSSMERR_CL_DEVICE_FAILED = -2147411739; - -const int CSSMERR_DL_DEVICE_FAILED = -2147413787; - -const int CSSMERR_TP_DEVICE_FAILED = -2147409691; - -const int CSSMERR_CSSM_IN_DARK_WAKE = -2147417882; - -const int CSSMERR_AC_IN_DARK_WAKE = -2147405594; - -const int CSSMERR_CSP_IN_DARK_WAKE = -2147415834; - -const int CSSMERR_CL_IN_DARK_WAKE = -2147411738; - -const int CSSMERR_DL_IN_DARK_WAKE = -2147413786; - -const int CSSMERR_TP_IN_DARK_WAKE = -2147409690; - -const int CSSMERR_CSP_APPLE_ADD_APPLICATION_ACL_SUBJECT = -2147415040; - -const int CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE = -2147415039; - -const int CSSMERR_CSP_APPLE_SIGNATURE_MISMATCH = -2147415038; - -const int CSSMERR_CSP_APPLE_INVALID_KEY_START_DATE = -2147415037; - -const int CSSMERR_CSP_APPLE_INVALID_KEY_END_DATE = -2147415036; - -const int CSSMERR_CSPDL_APPLE_DL_CONVERSION_ERROR = -2147415035; - -const int CSSMERR_CSP_APPLE_SSLv2_ROLLBACK = -2147415034; - -const int CSSM_DL_DB_RECORD_GENERIC_PASSWORD = -2147483648; - -const int CSSM_DL_DB_RECORD_INTERNET_PASSWORD = -2147483647; - -const int CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD = -2147483646; - -const int CSSM_DL_DB_RECORD_X509_CERTIFICATE = -2147479552; - -const int CSSM_DL_DB_RECORD_USER_TRUST = -2147479551; - -const int CSSM_DL_DB_RECORD_X509_CRL = -2147479550; - -const int CSSM_DL_DB_RECORD_UNLOCK_REFERRAL = -2147479549; - -const int CSSM_DL_DB_RECORD_EXTENDED_ATTRIBUTE = -2147479548; - -const int CSSM_DL_DB_RECORD_METADATA = -2147450880; - -const int CSSM_APPLEFILEDL_TOGGLE_AUTOCOMMIT = 0; - -const int CSSM_APPLEFILEDL_COMMIT = 1; - -const int CSSM_APPLEFILEDL_ROLLBACK = 2; - -const int CSSM_APPLEFILEDL_TAKE_FILE_LOCK = 3; - -const int CSSM_APPLEFILEDL_MAKE_BACKUP = 4; - -const int CSSM_APPLEFILEDL_MAKE_COPY = 5; - -const int CSSM_APPLEFILEDL_DELETE_FILE = 6; - -const int CSSM_APPLE_UNLOCK_TYPE_KEY_DIRECT = 1; - -const int CSSM_APPLE_UNLOCK_TYPE_WRAPPED_PRIVATE = 2; - -const int CSSM_APPLE_UNLOCK_TYPE_KEYBAG = 3; - -const int CSSMERR_APPLEDL_INVALID_OPEN_PARAMETERS = -2147412992; - -const int CSSMERR_APPLEDL_DISK_FULL = -2147412991; - -const int CSSMERR_APPLEDL_QUOTA_EXCEEDED = -2147412990; - -const int CSSMERR_APPLEDL_FILE_TOO_BIG = -2147412989; - -const int CSSMERR_APPLEDL_INVALID_DATABASE_BLOB = -2147412988; - -const int CSSMERR_APPLEDL_INVALID_KEY_BLOB = -2147412987; - -const int CSSMERR_APPLEDL_INCOMPATIBLE_DATABASE_BLOB = -2147412986; - -const int CSSMERR_APPLEDL_INCOMPATIBLE_KEY_BLOB = -2147412985; - -const int CSSMERR_APPLETP_HOSTNAME_MISMATCH = -2147408896; - -const int CSSMERR_APPLETP_UNKNOWN_CRITICAL_EXTEN = -2147408895; - -const int CSSMERR_APPLETP_NO_BASIC_CONSTRAINTS = -2147408894; - -const int CSSMERR_APPLETP_INVALID_CA = -2147408893; - -const int CSSMERR_APPLETP_INVALID_AUTHORITY_ID = -2147408892; - -const int CSSMERR_APPLETP_INVALID_SUBJECT_ID = -2147408891; - -const int CSSMERR_APPLETP_INVALID_KEY_USAGE = -2147408890; - -const int CSSMERR_APPLETP_INVALID_EXTENDED_KEY_USAGE = -2147408889; - -const int CSSMERR_APPLETP_INVALID_ID_LINKAGE = -2147408888; - -const int CSSMERR_APPLETP_PATH_LEN_CONSTRAINT = -2147408887; - -const int CSSMERR_APPLETP_INVALID_ROOT = -2147408886; - -const int CSSMERR_APPLETP_CRL_EXPIRED = -2147408885; - -const int CSSMERR_APPLETP_CRL_NOT_VALID_YET = -2147408884; - -const int CSSMERR_APPLETP_CRL_NOT_FOUND = -2147408883; - -const int CSSMERR_APPLETP_CRL_SERVER_DOWN = -2147408882; - -const int CSSMERR_APPLETP_CRL_BAD_URI = -2147408881; - -const int CSSMERR_APPLETP_UNKNOWN_CERT_EXTEN = -2147408880; - -const int CSSMERR_APPLETP_UNKNOWN_CRL_EXTEN = -2147408879; - -const int CSSMERR_APPLETP_CRL_NOT_TRUSTED = -2147408878; - -const int CSSMERR_APPLETP_CRL_INVALID_ANCHOR_CERT = -2147408877; - -const int CSSMERR_APPLETP_CRL_POLICY_FAIL = -2147408876; - -const int CSSMERR_APPLETP_IDP_FAIL = -2147408875; - -const int CSSMERR_APPLETP_CERT_NOT_FOUND_FROM_ISSUER = -2147408874; - -const int CSSMERR_APPLETP_BAD_CERT_FROM_ISSUER = -2147408873; - -const int CSSMERR_APPLETP_SMIME_EMAIL_ADDRS_NOT_FOUND = -2147408872; - -const int CSSMERR_APPLETP_SMIME_BAD_EXT_KEY_USE = -2147408871; - -const int CSSMERR_APPLETP_SMIME_BAD_KEY_USE = -2147408870; - -const int CSSMERR_APPLETP_SMIME_KEYUSAGE_NOT_CRITICAL = -2147408869; - -const int CSSMERR_APPLETP_SMIME_NO_EMAIL_ADDRS = -2147408868; - -const int CSSMERR_APPLETP_SMIME_SUBJ_ALT_NAME_NOT_CRIT = -2147408867; - -const int CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE = -2147408866; - -const int CSSMERR_APPLETP_OCSP_BAD_RESPONSE = -2147408865; - -const int CSSMERR_APPLETP_OCSP_BAD_REQUEST = -2147408864; - -const int CSSMERR_APPLETP_OCSP_UNAVAILABLE = -2147408863; - -const int CSSMERR_APPLETP_OCSP_STATUS_UNRECOGNIZED = -2147408862; - -const int CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK = -2147408861; - -const int CSSMERR_APPLETP_NETWORK_FAILURE = -2147408860; - -const int CSSMERR_APPLETP_OCSP_NOT_TRUSTED = -2147408859; - -const int CSSMERR_APPLETP_OCSP_INVALID_ANCHOR_CERT = -2147408858; - -const int CSSMERR_APPLETP_OCSP_SIG_ERROR = -2147408857; - -const int CSSMERR_APPLETP_OCSP_NO_SIGNER = -2147408856; - -const int CSSMERR_APPLETP_OCSP_RESP_MALFORMED_REQ = -2147408855; - -const int CSSMERR_APPLETP_OCSP_RESP_INTERNAL_ERR = -2147408854; - -const int CSSMERR_APPLETP_OCSP_RESP_TRY_LATER = -2147408853; - -const int CSSMERR_APPLETP_OCSP_RESP_SIG_REQUIRED = -2147408852; - -const int CSSMERR_APPLETP_OCSP_RESP_UNAUTHORIZED = -2147408851; - -const int CSSMERR_APPLETP_OCSP_NONCE_MISMATCH = -2147408850; - -const int CSSMERR_APPLETP_CS_BAD_CERT_CHAIN_LENGTH = -2147408849; - -const int CSSMERR_APPLETP_CS_NO_BASIC_CONSTRAINTS = -2147408848; - -const int CSSMERR_APPLETP_CS_BAD_PATH_LENGTH = -2147408847; - -const int CSSMERR_APPLETP_CS_NO_EXTENDED_KEY_USAGE = -2147408846; - -const int CSSMERR_APPLETP_CODE_SIGN_DEVELOPMENT = -2147408845; - -const int CSSMERR_APPLETP_RS_BAD_CERT_CHAIN_LENGTH = -2147408844; - -const int CSSMERR_APPLETP_RS_BAD_EXTENDED_KEY_USAGE = -2147408843; - -const int CSSMERR_APPLETP_TRUST_SETTING_DENY = -2147408842; - -const int CSSMERR_APPLETP_INVALID_EMPTY_SUBJECT = -2147408841; - -const int CSSMERR_APPLETP_UNKNOWN_QUAL_CERT_STATEMENT = -2147408840; - -const int CSSMERR_APPLETP_MISSING_REQUIRED_EXTENSION = -2147408839; - -const int CSSMERR_APPLETP_EXT_KEYUSAGE_NOT_CRITICAL = -2147408838; - -const int CSSMERR_APPLETP_IDENTIFIER_MISSING = -2147408837; - -const int CSSMERR_APPLETP_CA_PIN_MISMATCH = -2147408836; - -const int CSSMERR_APPLETP_LEAF_PIN_MISMATCH = -2147408835; - -const int CSSMERR_APPLE_DOTMAC_REQ_QUEUED = -2147408796; - -const int CSSMERR_APPLE_DOTMAC_REQ_REDIRECT = -2147408795; - -const int CSSMERR_APPLE_DOTMAC_REQ_SERVER_ERR = -2147408794; - -const int CSSMERR_APPLE_DOTMAC_REQ_SERVER_PARAM = -2147408793; - -const int CSSMERR_APPLE_DOTMAC_REQ_SERVER_AUTH = -2147408792; - -const int CSSMERR_APPLE_DOTMAC_REQ_SERVER_UNIMPL = -2147408791; - -const int CSSMERR_APPLE_DOTMAC_REQ_SERVER_NOT_AVAIL = -2147408790; - -const int CSSMERR_APPLE_DOTMAC_REQ_SERVER_ALREADY_EXIST = -2147408789; - -const int CSSMERR_APPLE_DOTMAC_REQ_SERVER_SERVICE_ERROR = -2147408788; - -const int CSSMERR_APPLE_DOTMAC_REQ_IS_PENDING = -2147408787; - -const int CSSMERR_APPLE_DOTMAC_NO_REQ_PENDING = -2147408786; - -const int CSSMERR_APPLE_DOTMAC_CSR_VERIFY_FAIL = -2147408785; - -const int CSSMERR_APPLE_DOTMAC_FAILED_CONSISTENCY_CHECK = -2147408784; - -const int CSSM_APPLEDL_OPEN_PARAMETERS_VERSION = 1; - -const int CSSM_APPLECSPDL_DB_LOCK = 0; - -const int CSSM_APPLECSPDL_DB_UNLOCK = 1; - -const int CSSM_APPLECSPDL_DB_GET_SETTINGS = 2; - -const int CSSM_APPLECSPDL_DB_SET_SETTINGS = 3; - -const int CSSM_APPLECSPDL_DB_IS_LOCKED = 4; - -const int CSSM_APPLECSPDL_DB_CHANGE_PASSWORD = 5; - -const int CSSM_APPLECSPDL_DB_GET_HANDLE = 6; - -const int CSSM_APPLESCPDL_CSP_GET_KEYHANDLE = 7; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_8 = 8; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_9 = 9; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_10 = 10; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_11 = 11; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_12 = 12; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_13 = 13; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_14 = 14; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_15 = 15; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_16 = 16; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_17 = 17; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_18 = 18; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_19 = 19; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_20 = 20; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_21 = 21; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_22 = 22; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_23 = 23; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_24 = 24; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_25 = 25; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_26 = 26; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_27 = 27; - -const int CSSM_APPLE_PRIVATE_CSPDL_CODE_28 = 28; - -const int CSSM_APPLECSP_KEYDIGEST = 256; - -const int CSSM_APPLECSP_PUBKEY = 257; - -const int CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM = 100; - -const int CSSM_KEYBLOB_WRAPPED_FORMAT_OPENSSL = 101; - -const int CSSM_KEYBLOB_WRAPPED_FORMAT_OPENSSH1 = 102; - -const int CSSM_ATTRIBUTE_VENDOR_DEFINED = 8388608; - -const int CSSM_ATTRIBUTE_PUBLIC_KEY = 1082130432; - -const int CSSM_ATTRIBUTE_FEE_PRIME_TYPE = 276824065; - -const int CSSM_ATTRIBUTE_FEE_CURVE_TYPE = 276824066; - -const int CSSM_ATTRIBUTE_ASC_OPTIMIZATION = 276824067; - -const int CSSM_ATTRIBUTE_RSA_BLINDING = 276824068; - -const int CSSM_ATTRIBUTE_PARAM_KEY = 1082130437; - -const int CSSM_ATTRIBUTE_PROMPT = 545259526; - -const int CSSM_ATTRIBUTE_ALERT_TITLE = 545259527; - -const int CSSM_ATTRIBUTE_VERIFY_PASSPHRASE = 276824072; - -const int CSSM_FEE_PRIME_TYPE_DEFAULT = 0; - -const int CSSM_FEE_PRIME_TYPE_MERSENNE = 1; - -const int CSSM_FEE_PRIME_TYPE_FEE = 2; - -const int CSSM_FEE_PRIME_TYPE_GENERAL = 3; - -const int CSSM_FEE_CURVE_TYPE_DEFAULT = 0; - -const int CSSM_FEE_CURVE_TYPE_MONTGOMERY = 1; - -const int CSSM_FEE_CURVE_TYPE_WEIERSTRASS = 2; - -const int CSSM_FEE_CURVE_TYPE_ANSI_X9_62 = 3; - -const int CSSM_ASC_OPTIMIZE_DEFAULT = 0; - -const int CSSM_ASC_OPTIMIZE_SIZE = 1; - -const int CSSM_ASC_OPTIMIZE_SECURITY = 2; - -const int CSSM_ASC_OPTIMIZE_TIME = 3; - -const int CSSM_ASC_OPTIMIZE_TIME_SIZE = 4; - -const int CSSM_ASC_OPTIMIZE_ASCII = 5; - -const int CSSM_KEYATTR_PARTIAL = 65536; - -const int CSSM_KEYATTR_PUBLIC_KEY_ENCRYPT = 131072; - -const int CSSM_TP_ACTION_REQUIRE_CRL_PER_CERT = 1; - -const int CSSM_TP_ACTION_FETCH_CRL_FROM_NET = 2; - -const int CSSM_TP_ACTION_CRL_SUFFICIENT = 4; - -const int CSSM_TP_ACTION_REQUIRE_CRL_IF_PRESENT = 8; - -const int CSSM_TP_ACTION_ALLOW_EXPIRED = 1; - -const int CSSM_TP_ACTION_LEAF_IS_CA = 2; - -const int CSSM_TP_ACTION_FETCH_CERT_FROM_NET = 4; - -const int CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT = 8; - -const int CSSM_TP_ACTION_REQUIRE_REV_PER_CERT = 16; - -const int CSSM_TP_ACTION_TRUST_SETTINGS = 32; - -const int CSSM_TP_ACTION_IMPLICIT_ANCHORS = 64; - -const int CSSM_CERT_STATUS_EXPIRED = 1; - -const int CSSM_CERT_STATUS_NOT_VALID_YET = 2; - -const int CSSM_CERT_STATUS_IS_IN_INPUT_CERTS = 4; - -const int CSSM_CERT_STATUS_IS_IN_ANCHORS = 8; - -const int CSSM_CERT_STATUS_IS_ROOT = 16; - -const int CSSM_CERT_STATUS_IS_FROM_NET = 32; - -const int CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_USER = 64; - -const int CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_ADMIN = 128; - -const int CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_SYSTEM = 256; - -const int CSSM_CERT_STATUS_TRUST_SETTINGS_TRUST = 512; - -const int CSSM_CERT_STATUS_TRUST_SETTINGS_DENY = 1024; - -const int CSSM_CERT_STATUS_TRUST_SETTINGS_IGNORED_ERROR = 2048; - -const int CSSM_EVIDENCE_FORM_APPLE_HEADER = -2147483648; - -const int CSSM_EVIDENCE_FORM_APPLE_CERTGROUP = -2147483647; - -const int CSSM_EVIDENCE_FORM_APPLE_CERT_INFO = -2147483646; - -const int CSSM_APPLEX509CL_OBTAIN_CSR = 0; - -const int CSSM_APPLEX509CL_VERIFY_CSR = 1; - -const int kSecSubjectItemAttr = 1937072746; - -const int kSecIssuerItemAttr = 1769173877; - -const int kSecSerialNumberItemAttr = 1936614002; - -const int kSecPublicKeyHashItemAttr = 1752198009; - -const int kSecSubjectKeyIdentifierItemAttr = 1936419172; - -const int kSecCertTypeItemAttr = 1668577648; - -const int kSecCertEncodingItemAttr = 1667591779; - -const int SSL_NULL_WITH_NULL_NULL = 0; - -const int SSL_RSA_WITH_NULL_MD5 = 1; - -const int SSL_RSA_WITH_NULL_SHA = 2; - -const int SSL_RSA_EXPORT_WITH_RC4_40_MD5 = 3; - -const int SSL_RSA_WITH_RC4_128_MD5 = 4; - -const int SSL_RSA_WITH_RC4_128_SHA = 5; - -const int SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 6; - -const int SSL_RSA_WITH_IDEA_CBC_SHA = 7; - -const int SSL_RSA_EXPORT_WITH_DES40_CBC_SHA = 8; - -const int SSL_RSA_WITH_DES_CBC_SHA = 9; - -const int SSL_RSA_WITH_3DES_EDE_CBC_SHA = 10; - -const int SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 11; - -const int SSL_DH_DSS_WITH_DES_CBC_SHA = 12; - -const int SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA = 13; - -const int SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 14; - -const int SSL_DH_RSA_WITH_DES_CBC_SHA = 15; - -const int SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA = 16; - -const int SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 17; - -const int SSL_DHE_DSS_WITH_DES_CBC_SHA = 18; - -const int SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 19; - -const int SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 20; - -const int SSL_DHE_RSA_WITH_DES_CBC_SHA = 21; - -const int SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 22; - -const int SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 = 23; - -const int SSL_DH_anon_WITH_RC4_128_MD5 = 24; - -const int SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 25; - -const int SSL_DH_anon_WITH_DES_CBC_SHA = 26; - -const int SSL_DH_anon_WITH_3DES_EDE_CBC_SHA = 27; - -const int SSL_FORTEZZA_DMS_WITH_NULL_SHA = 28; - -const int SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA = 29; - -const int TLS_RSA_WITH_AES_128_CBC_SHA = 47; - -const int TLS_DH_DSS_WITH_AES_128_CBC_SHA = 48; - -const int TLS_DH_RSA_WITH_AES_128_CBC_SHA = 49; - -const int TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 50; - -const int TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 51; - -const int TLS_DH_anon_WITH_AES_128_CBC_SHA = 52; - -const int TLS_RSA_WITH_AES_256_CBC_SHA = 53; - -const int TLS_DH_DSS_WITH_AES_256_CBC_SHA = 54; - -const int TLS_DH_RSA_WITH_AES_256_CBC_SHA = 55; - -const int TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 56; - -const int TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 57; - -const int TLS_DH_anon_WITH_AES_256_CBC_SHA = 58; - -const int TLS_ECDH_ECDSA_WITH_NULL_SHA = -16383; - -const int TLS_ECDH_ECDSA_WITH_RC4_128_SHA = -16382; - -const int TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA = -16381; - -const int TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA = -16380; - -const int TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA = -16379; - -const int TLS_ECDHE_ECDSA_WITH_NULL_SHA = -16378; - -const int TLS_ECDHE_ECDSA_WITH_RC4_128_SHA = -16377; - -const int TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA = -16376; - -const int TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = -16375; - -const int TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = -16374; - -const int TLS_ECDH_RSA_WITH_NULL_SHA = -16373; - -const int TLS_ECDH_RSA_WITH_RC4_128_SHA = -16372; - -const int TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA = -16371; - -const int TLS_ECDH_RSA_WITH_AES_128_CBC_SHA = -16370; - -const int TLS_ECDH_RSA_WITH_AES_256_CBC_SHA = -16369; - -const int TLS_ECDHE_RSA_WITH_NULL_SHA = -16368; - -const int TLS_ECDHE_RSA_WITH_RC4_128_SHA = -16367; - -const int TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA = -16366; - -const int TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = -16365; - -const int TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = -16364; - -const int TLS_ECDH_anon_WITH_NULL_SHA = -16363; - -const int TLS_ECDH_anon_WITH_RC4_128_SHA = -16362; - -const int TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA = -16361; - -const int TLS_ECDH_anon_WITH_AES_128_CBC_SHA = -16360; - -const int TLS_ECDH_anon_WITH_AES_256_CBC_SHA = -16359; - -const int TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA = -16331; - -const int TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA = -16330; - -const int TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 = -13141; - -const int TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 = -13140; - -const int TLS_NULL_WITH_NULL_NULL = 0; - -const int TLS_RSA_WITH_NULL_MD5 = 1; - -const int TLS_RSA_WITH_NULL_SHA = 2; - -const int TLS_RSA_WITH_RC4_128_MD5 = 4; - -const int TLS_RSA_WITH_RC4_128_SHA = 5; - -const int TLS_RSA_WITH_3DES_EDE_CBC_SHA = 10; - -const int TLS_RSA_WITH_NULL_SHA256 = 59; - -const int TLS_RSA_WITH_AES_128_CBC_SHA256 = 60; - -const int TLS_RSA_WITH_AES_256_CBC_SHA256 = 61; - -const int TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 13; - -const int TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 16; - -const int TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 19; - -const int TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 22; - -const int TLS_DH_DSS_WITH_AES_128_CBC_SHA256 = 62; - -const int TLS_DH_RSA_WITH_AES_128_CBC_SHA256 = 63; - -const int TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 64; - -const int TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 103; - -const int TLS_DH_DSS_WITH_AES_256_CBC_SHA256 = 104; - -const int TLS_DH_RSA_WITH_AES_256_CBC_SHA256 = 105; - -const int TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 106; - -const int TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 107; - -const int TLS_DH_anon_WITH_RC4_128_MD5 = 24; - -const int TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 27; - -const int TLS_DH_anon_WITH_AES_128_CBC_SHA256 = 108; - -const int TLS_DH_anon_WITH_AES_256_CBC_SHA256 = 109; - -const int TLS_PSK_WITH_RC4_128_SHA = 138; - -const int TLS_PSK_WITH_3DES_EDE_CBC_SHA = 139; - -const int TLS_PSK_WITH_AES_128_CBC_SHA = 140; - -const int TLS_PSK_WITH_AES_256_CBC_SHA = 141; - -const int TLS_DHE_PSK_WITH_RC4_128_SHA = 142; - -const int TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA = 143; - -const int TLS_DHE_PSK_WITH_AES_128_CBC_SHA = 144; - -const int TLS_DHE_PSK_WITH_AES_256_CBC_SHA = 145; - -const int TLS_RSA_PSK_WITH_RC4_128_SHA = 146; - -const int TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA = 147; - -const int TLS_RSA_PSK_WITH_AES_128_CBC_SHA = 148; - -const int TLS_RSA_PSK_WITH_AES_256_CBC_SHA = 149; - -const int TLS_PSK_WITH_NULL_SHA = 44; - -const int TLS_DHE_PSK_WITH_NULL_SHA = 45; - -const int TLS_RSA_PSK_WITH_NULL_SHA = 46; - -const int TLS_RSA_WITH_AES_128_GCM_SHA256 = 156; - -const int TLS_RSA_WITH_AES_256_GCM_SHA384 = 157; - -const int TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 = 158; - -const int TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = 159; - -const int TLS_DH_RSA_WITH_AES_128_GCM_SHA256 = 160; - -const int TLS_DH_RSA_WITH_AES_256_GCM_SHA384 = 161; - -const int TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 = 162; - -const int TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 = 163; - -const int TLS_DH_DSS_WITH_AES_128_GCM_SHA256 = 164; - -const int TLS_DH_DSS_WITH_AES_256_GCM_SHA384 = 165; - -const int TLS_DH_anon_WITH_AES_128_GCM_SHA256 = 166; - -const int TLS_DH_anon_WITH_AES_256_GCM_SHA384 = 167; - -const int TLS_PSK_WITH_AES_128_GCM_SHA256 = 168; - -const int TLS_PSK_WITH_AES_256_GCM_SHA384 = 169; - -const int TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 = 170; - -const int TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 = 171; - -const int TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 = 172; - -const int TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 = 173; - -const int TLS_PSK_WITH_AES_128_CBC_SHA256 = 174; - -const int TLS_PSK_WITH_AES_256_CBC_SHA384 = 175; - -const int TLS_PSK_WITH_NULL_SHA256 = 176; - -const int TLS_PSK_WITH_NULL_SHA384 = 177; - -const int TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 = 178; - -const int TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 = 179; - -const int TLS_DHE_PSK_WITH_NULL_SHA256 = 180; - -const int TLS_DHE_PSK_WITH_NULL_SHA384 = 181; - -const int TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 = 182; - -const int TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 = 183; - -const int TLS_RSA_PSK_WITH_NULL_SHA256 = 184; - -const int TLS_RSA_PSK_WITH_NULL_SHA384 = 185; - -const int TLS_AES_128_GCM_SHA256 = 4865; - -const int TLS_AES_256_GCM_SHA384 = 4866; - -const int TLS_CHACHA20_POLY1305_SHA256 = 4867; - -const int TLS_AES_128_CCM_SHA256 = 4868; - -const int TLS_AES_128_CCM_8_SHA256 = 4869; - -const int TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = -16349; - -const int TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = -16348; - -const int TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 = -16347; - -const int TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 = -16346; - -const int TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = -16345; - -const int TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = -16344; - -const int TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 = -16343; - -const int TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 = -16342; - -const int TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = -16341; - -const int TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = -16340; - -const int TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 = -16339; - -const int TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 = -16338; - -const int TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = -16337; - -const int TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = -16336; - -const int TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 = -16335; - -const int TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 = -16334; - -const int TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = -13144; - -const int TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = -13143; - -const int TLS_EMPTY_RENEGOTIATION_INFO_SCSV = 255; - -const int SSL_RSA_WITH_RC2_CBC_MD5 = -128; - -const int SSL_RSA_WITH_IDEA_CBC_MD5 = -127; - -const int SSL_RSA_WITH_DES_CBC_MD5 = -126; - -const int SSL_RSA_WITH_3DES_EDE_CBC_MD5 = -125; - -const int SSL_NO_SUCH_CIPHERSUITE = -1; - -const int NSASCIIStringEncoding = 1; - -const int NSNEXTSTEPStringEncoding = 2; - -const int NSJapaneseEUCStringEncoding = 3; - -const int NSUTF8StringEncoding = 4; - -const int NSISOLatin1StringEncoding = 5; - -const int NSSymbolStringEncoding = 6; - -const int NSNonLossyASCIIStringEncoding = 7; - -const int NSShiftJISStringEncoding = 8; - -const int NSISOLatin2StringEncoding = 9; - -const int NSUnicodeStringEncoding = 10; - -const int NSWindowsCP1251StringEncoding = 11; - -const int NSWindowsCP1252StringEncoding = 12; - -const int NSWindowsCP1253StringEncoding = 13; - -const int NSWindowsCP1254StringEncoding = 14; - -const int NSWindowsCP1250StringEncoding = 15; - -const int NSISO2022JPStringEncoding = 21; - -const int NSMacOSRomanStringEncoding = 30; - -const int NSUTF16StringEncoding = 10; - -const int NSUTF16BigEndianStringEncoding = 2415919360; - -const int NSUTF16LittleEndianStringEncoding = 2483028224; - -const int NSUTF32StringEncoding = 2348810496; - -const int NSUTF32BigEndianStringEncoding = 2550137088; - -const int NSUTF32LittleEndianStringEncoding = 2617245952; - -const int NSProprietaryStringEncoding = 65536; - -const int NSOpenStepUnicodeReservedBase = 62464; - -const int __API_TO_BE_DEPRECATED = 100000; - -const int __API_TO_BE_DEPRECATED_MACOS = 100000; - -const int __API_TO_BE_DEPRECATED_MACOSAPPLICATIONEXTENSION = 100000; - -const int __API_TO_BE_DEPRECATED_IOS = 100000; - -const int __API_TO_BE_DEPRECATED_IOSAPPLICATIONEXTENSION = 100000; - -const int __API_TO_BE_DEPRECATED_MACCATALYST = 100000; - -const int __API_TO_BE_DEPRECATED_MACCATALYSTAPPLICATIONEXTENSION = 100000; - -const int __API_TO_BE_DEPRECATED_WATCHOS = 100000; - -const int __API_TO_BE_DEPRECATED_WATCHOSAPPLICATIONEXTENSION = 100000; - -const int __API_TO_BE_DEPRECATED_TVOS = 100000; - -const int __API_TO_BE_DEPRECATED_TVOSAPPLICATIONEXTENSION = 100000; - -const int __API_TO_BE_DEPRECATED_DRIVERKIT = 100000; - -const int __API_TO_BE_DEPRECATED_VISIONOS = 100000; - -const int __API_TO_BE_DEPRECATED_VISIONOSAPPLICATIONEXTENSION = 100000; - -const int __API_TO_BE_DEPRECATED_KERNELKIT = 100000; - -const int __MAC_10_0 = 1000; - -const int __MAC_10_1 = 1010; - -const int __MAC_10_2 = 1020; - -const int __MAC_10_3 = 1030; - -const int __MAC_10_4 = 1040; - -const int __MAC_10_5 = 1050; - -const int __MAC_10_6 = 1060; - -const int __MAC_10_7 = 1070; - -const int __MAC_10_8 = 1080; - -const int __MAC_10_9 = 1090; - -const int __MAC_10_10 = 101000; - -const int __MAC_10_10_2 = 101002; - -const int __MAC_10_10_3 = 101003; - -const int __MAC_10_11 = 101100; - -const int __MAC_10_11_2 = 101102; - -const int __MAC_10_11_3 = 101103; - -const int __MAC_10_11_4 = 101104; - -const int __MAC_10_12 = 101200; - -const int __MAC_10_12_1 = 101201; - -const int __MAC_10_12_2 = 101202; - -const int __MAC_10_12_4 = 101204; - -const int __MAC_10_13 = 101300; - -const int __MAC_10_13_1 = 101301; - -const int __MAC_10_13_2 = 101302; - -const int __MAC_10_13_4 = 101304; - -const int __MAC_10_14 = 101400; - -const int __MAC_10_14_1 = 101401; - -const int __MAC_10_14_4 = 101404; - -const int __MAC_10_14_5 = 101405; - -const int __MAC_10_14_6 = 101406; - -const int __MAC_10_15 = 101500; - -const int __MAC_10_15_1 = 101501; - -const int __MAC_10_15_4 = 101504; - -const int __MAC_10_16 = 101600; - -const int __MAC_11_0 = 110000; - -const int __MAC_11_1 = 110100; - -const int __MAC_11_3 = 110300; - -const int __MAC_11_4 = 110400; - -const int __MAC_11_5 = 110500; - -const int __MAC_11_6 = 110600; - -const int __MAC_12_0 = 120000; - -const int __MAC_12_1 = 120100; - -const int __MAC_12_2 = 120200; - -const int __MAC_12_3 = 120300; - -const int __MAC_12_4 = 120400; - -const int __MAC_12_5 = 120500; - -const int __MAC_12_6 = 120600; - -const int __MAC_12_7 = 120700; - -const int __MAC_13_0 = 130000; - -const int __MAC_13_1 = 130100; - -const int __MAC_13_2 = 130200; - -const int __MAC_13_3 = 130300; - -const int __MAC_13_4 = 130400; - -const int __MAC_13_5 = 130500; - -const int __MAC_13_6 = 130600; - -const int __MAC_13_7 = 130700; - -const int __MAC_14_0 = 140000; - -const int __MAC_14_1 = 140100; - -const int __MAC_14_2 = 140200; - -const int __MAC_14_3 = 140300; - -const int __MAC_14_4 = 140400; - -const int __MAC_14_5 = 140500; - -const int __MAC_14_6 = 140600; - -const int __MAC_14_7 = 140700; - -const int __MAC_15_0 = 150000; - -const int __MAC_15_1 = 150100; - -const int __MAC_15_2 = 150200; - -const int __MAC_15_3 = 150300; - -const int __MAC_15_4 = 150400; - -const int __MAC_15_5 = 150500; - -const int __MAC_15_6 = 150600; - -const int __MAC_16_0 = 160000; - -const int __MAC_26_0 = 260000; - -const int __IPHONE_2_0 = 20000; - -const int __IPHONE_2_1 = 20100; - -const int __IPHONE_2_2 = 20200; - -const int __IPHONE_3_0 = 30000; - -const int __IPHONE_3_1 = 30100; - -const int __IPHONE_3_2 = 30200; - -const int __IPHONE_4_0 = 40000; - -const int __IPHONE_4_1 = 40100; - -const int __IPHONE_4_2 = 40200; - -const int __IPHONE_4_3 = 40300; - -const int __IPHONE_5_0 = 50000; - -const int __IPHONE_5_1 = 50100; - -const int __IPHONE_6_0 = 60000; - -const int __IPHONE_6_1 = 60100; - -const int __IPHONE_7_0 = 70000; - -const int __IPHONE_7_1 = 70100; - -const int __IPHONE_8_0 = 80000; - -const int __IPHONE_8_1 = 80100; - -const int __IPHONE_8_2 = 80200; - -const int __IPHONE_8_3 = 80300; - -const int __IPHONE_8_4 = 80400; - -const int __IPHONE_9_0 = 90000; - -const int __IPHONE_9_1 = 90100; - -const int __IPHONE_9_2 = 90200; - -const int __IPHONE_9_3 = 90300; - -const int __IPHONE_10_0 = 100000; - -const int __IPHONE_10_1 = 100100; - -const int __IPHONE_10_2 = 100200; - -const int __IPHONE_10_3 = 100300; - -const int __IPHONE_11_0 = 110000; - -const int __IPHONE_11_1 = 110100; - -const int __IPHONE_11_2 = 110200; - -const int __IPHONE_11_3 = 110300; - -const int __IPHONE_11_4 = 110400; - -const int __IPHONE_12_0 = 120000; - -const int __IPHONE_12_1 = 120100; - -const int __IPHONE_12_2 = 120200; - -const int __IPHONE_12_3 = 120300; - -const int __IPHONE_12_4 = 120400; - -const int __IPHONE_13_0 = 130000; - -const int __IPHONE_13_1 = 130100; - -const int __IPHONE_13_2 = 130200; - -const int __IPHONE_13_3 = 130300; - -const int __IPHONE_13_4 = 130400; - -const int __IPHONE_13_5 = 130500; - -const int __IPHONE_13_6 = 130600; - -const int __IPHONE_13_7 = 130700; - -const int __IPHONE_14_0 = 140000; - -const int __IPHONE_14_1 = 140100; - -const int __IPHONE_14_2 = 140200; - -const int __IPHONE_14_3 = 140300; - -const int __IPHONE_14_5 = 140500; - -const int __IPHONE_14_6 = 140600; - -const int __IPHONE_14_7 = 140700; - -const int __IPHONE_14_8 = 140800; - -const int __IPHONE_15_0 = 150000; - -const int __IPHONE_15_1 = 150100; - -const int __IPHONE_15_2 = 150200; - -const int __IPHONE_15_3 = 150300; - -const int __IPHONE_15_4 = 150400; - -const int __IPHONE_15_5 = 150500; - -const int __IPHONE_15_6 = 150600; - -const int __IPHONE_15_7 = 150700; - -const int __IPHONE_15_8 = 150800; - -const int __IPHONE_16_0 = 160000; - -const int __IPHONE_16_1 = 160100; - -const int __IPHONE_16_2 = 160200; - -const int __IPHONE_16_3 = 160300; - -const int __IPHONE_16_4 = 160400; - -const int __IPHONE_16_5 = 160500; - -const int __IPHONE_16_6 = 160600; - -const int __IPHONE_16_7 = 160700; - -const int __IPHONE_17_0 = 170000; - -const int __IPHONE_17_1 = 170100; - -const int __IPHONE_17_2 = 170200; - -const int __IPHONE_17_3 = 170300; - -const int __IPHONE_17_4 = 170400; - -const int __IPHONE_17_5 = 170500; - -const int __IPHONE_17_6 = 170600; - -const int __IPHONE_17_7 = 170700; - -const int __IPHONE_18_0 = 180000; - -const int __IPHONE_18_1 = 180100; - -const int __IPHONE_18_2 = 180200; - -const int __IPHONE_18_3 = 180300; - -const int __IPHONE_18_4 = 180400; - -const int __IPHONE_18_5 = 180500; - -const int __IPHONE_18_6 = 180600; - -const int __IPHONE_19_0 = 190000; - -const int __IPHONE_26_0 = 260000; - -const int __WATCHOS_1_0 = 10000; - -const int __WATCHOS_2_0 = 20000; - -const int __WATCHOS_2_1 = 20100; - -const int __WATCHOS_2_2 = 20200; - -const int __WATCHOS_3_0 = 30000; - -const int __WATCHOS_3_1 = 30100; - -const int __WATCHOS_3_1_1 = 30101; - -const int __WATCHOS_3_2 = 30200; - -const int __WATCHOS_4_0 = 40000; - -const int __WATCHOS_4_1 = 40100; - -const int __WATCHOS_4_2 = 40200; - -const int __WATCHOS_4_3 = 40300; - -const int __WATCHOS_5_0 = 50000; - -const int __WATCHOS_5_1 = 50100; - -const int __WATCHOS_5_2 = 50200; - -const int __WATCHOS_5_3 = 50300; - -const int __WATCHOS_6_0 = 60000; - -const int __WATCHOS_6_1 = 60100; - -const int __WATCHOS_6_2 = 60200; - -const int __WATCHOS_7_0 = 70000; - -const int __WATCHOS_7_1 = 70100; - -const int __WATCHOS_7_2 = 70200; - -const int __WATCHOS_7_3 = 70300; - -const int __WATCHOS_7_4 = 70400; - -const int __WATCHOS_7_5 = 70500; - -const int __WATCHOS_7_6 = 70600; - -const int __WATCHOS_8_0 = 80000; - -const int __WATCHOS_8_1 = 80100; - -const int __WATCHOS_8_3 = 80300; - -const int __WATCHOS_8_4 = 80400; - -const int __WATCHOS_8_5 = 80500; - -const int __WATCHOS_8_6 = 80600; - -const int __WATCHOS_8_7 = 80700; - -const int __WATCHOS_8_8 = 80800; - -const int __WATCHOS_9_0 = 90000; - -const int __WATCHOS_9_1 = 90100; - -const int __WATCHOS_9_2 = 90200; - -const int __WATCHOS_9_3 = 90300; - -const int __WATCHOS_9_4 = 90400; - -const int __WATCHOS_9_5 = 90500; - -const int __WATCHOS_9_6 = 90600; - -const int __WATCHOS_10_0 = 100000; - -const int __WATCHOS_10_1 = 100100; - -const int __WATCHOS_10_2 = 100200; - -const int __WATCHOS_10_3 = 100300; - -const int __WATCHOS_10_4 = 100400; - -const int __WATCHOS_10_5 = 100500; - -const int __WATCHOS_10_6 = 100600; - -const int __WATCHOS_10_7 = 100700; - -const int __WATCHOS_11_0 = 110000; - -const int __WATCHOS_11_1 = 110100; - -const int __WATCHOS_11_2 = 110200; - -const int __WATCHOS_11_3 = 110300; - -const int __WATCHOS_11_4 = 110400; - -const int __WATCHOS_11_5 = 110500; - -const int __WATCHOS_11_6 = 110600; - -const int __WATCHOS_12_0 = 120000; - -const int __WATCHOS_26_0 = 260000; - -const int __TVOS_9_0 = 90000; - -const int __TVOS_9_1 = 90100; - -const int __TVOS_9_2 = 90200; - -const int __TVOS_10_0 = 100000; - -const int __TVOS_10_0_1 = 100001; - -const int __TVOS_10_1 = 100100; - -const int __TVOS_10_2 = 100200; - -const int __TVOS_11_0 = 110000; - -const int __TVOS_11_1 = 110100; - -const int __TVOS_11_2 = 110200; - -const int __TVOS_11_3 = 110300; - -const int __TVOS_11_4 = 110400; - -const int __TVOS_12_0 = 120000; - -const int __TVOS_12_1 = 120100; - -const int __TVOS_12_2 = 120200; - -const int __TVOS_12_3 = 120300; - -const int __TVOS_12_4 = 120400; - -const int __TVOS_13_0 = 130000; - -const int __TVOS_13_2 = 130200; - -const int __TVOS_13_3 = 130300; - -const int __TVOS_13_4 = 130400; - -const int __TVOS_14_0 = 140000; - -const int __TVOS_14_1 = 140100; - -const int __TVOS_14_2 = 140200; - -const int __TVOS_14_3 = 140300; - -const int __TVOS_14_5 = 140500; - -const int __TVOS_14_6 = 140600; - -const int __TVOS_14_7 = 140700; - -const int __TVOS_15_0 = 150000; - -const int __TVOS_15_1 = 150100; - -const int __TVOS_15_2 = 150200; - -const int __TVOS_15_3 = 150300; - -const int __TVOS_15_4 = 150400; - -const int __TVOS_15_5 = 150500; - -const int __TVOS_15_6 = 150600; - -const int __TVOS_16_0 = 160000; - -const int __TVOS_16_1 = 160100; - -const int __TVOS_16_2 = 160200; - -const int __TVOS_16_3 = 160300; - -const int __TVOS_16_4 = 160400; - -const int __TVOS_16_5 = 160500; - -const int __TVOS_16_6 = 160600; - -const int __TVOS_17_0 = 170000; - -const int __TVOS_17_1 = 170100; - -const int __TVOS_17_2 = 170200; - -const int __TVOS_17_3 = 170300; - -const int __TVOS_17_4 = 170400; - -const int __TVOS_17_5 = 170500; - -const int __TVOS_17_6 = 170600; - -const int __TVOS_18_0 = 180000; - -const int __TVOS_18_1 = 180100; - -const int __TVOS_18_2 = 180200; - -const int __TVOS_18_3 = 180300; - -const int __TVOS_18_4 = 180400; - -const int __TVOS_18_5 = 180500; - -const int __TVOS_18_6 = 180600; - -const int __TVOS_19_0 = 190000; - -const int __TVOS_26_0 = 260000; - -const int __BRIDGEOS_2_0 = 20000; - -const int __BRIDGEOS_3_0 = 30000; - -const int __BRIDGEOS_3_1 = 30100; - -const int __BRIDGEOS_3_4 = 30400; - -const int __BRIDGEOS_4_0 = 40000; - -const int __BRIDGEOS_4_1 = 40100; - -const int __BRIDGEOS_5_0 = 50000; - -const int __BRIDGEOS_5_1 = 50100; - -const int __BRIDGEOS_5_3 = 50300; - -const int __BRIDGEOS_6_0 = 60000; - -const int __BRIDGEOS_6_2 = 60200; - -const int __BRIDGEOS_6_4 = 60400; - -const int __BRIDGEOS_6_5 = 60500; - -const int __BRIDGEOS_6_6 = 60600; - -const int __BRIDGEOS_7_0 = 70000; - -const int __BRIDGEOS_7_1 = 70100; - -const int __BRIDGEOS_7_2 = 70200; - -const int __BRIDGEOS_7_3 = 70300; - -const int __BRIDGEOS_7_4 = 70400; - -const int __BRIDGEOS_7_6 = 70600; - -const int __BRIDGEOS_8_0 = 80000; - -const int __BRIDGEOS_8_1 = 80100; - -const int __BRIDGEOS_8_2 = 80200; - -const int __BRIDGEOS_8_3 = 80300; - -const int __BRIDGEOS_8_4 = 80400; - -const int __BRIDGEOS_8_5 = 80500; - -const int __BRIDGEOS_8_6 = 80600; - -const int __BRIDGEOS_9_0 = 90000; - -const int __BRIDGEOS_9_1 = 90100; - -const int __BRIDGEOS_9_2 = 90200; - -const int __BRIDGEOS_9_3 = 90300; - -const int __BRIDGEOS_9_4 = 90400; - -const int __BRIDGEOS_9_5 = 90500; - -const int __BRIDGEOS_9_6 = 90600; - -const int __BRIDGEOS_10_0 = 100000; - -const int __DRIVERKIT_19_0 = 190000; - -const int __DRIVERKIT_20_0 = 200000; - -const int __DRIVERKIT_21_0 = 210000; - -const int __DRIVERKIT_22_0 = 220000; - -const int __DRIVERKIT_22_4 = 220400; - -const int __DRIVERKIT_22_5 = 220500; - -const int __DRIVERKIT_22_6 = 220600; - -const int __DRIVERKIT_23_0 = 230000; - -const int __DRIVERKIT_23_1 = 230100; - -const int __DRIVERKIT_23_2 = 230200; - -const int __DRIVERKIT_23_3 = 230300; - -const int __DRIVERKIT_23_4 = 230400; - -const int __DRIVERKIT_23_5 = 230500; - -const int __DRIVERKIT_23_6 = 230600; - -const int __DRIVERKIT_24_0 = 240000; - -const int __DRIVERKIT_24_1 = 240100; - -const int __DRIVERKIT_24_2 = 240200; - -const int __DRIVERKIT_24_3 = 240300; - -const int __DRIVERKIT_24_4 = 240400; - -const int __DRIVERKIT_24_5 = 240500; - -const int __DRIVERKIT_24_6 = 240600; - -const int __DRIVERKIT_25_0 = 250000; - -const int __VISIONOS_1_0 = 10000; - -const int __VISIONOS_1_1 = 10100; - -const int __VISIONOS_1_2 = 10200; - -const int __VISIONOS_1_3 = 10300; - -const int __VISIONOS_2_0 = 20000; - -const int __VISIONOS_2_1 = 20100; - -const int __VISIONOS_2_2 = 20200; - -const int __VISIONOS_2_3 = 20300; - -const int __VISIONOS_2_4 = 20400; - -const int __VISIONOS_2_5 = 20500; - -const int __VISIONOS_2_6 = 20600; - -const int __VISIONOS_3_0 = 30000; - -const int __VISIONOS_26_0 = 260000; - -const int MAC_OS_X_VERSION_10_0 = 1000; - -const int MAC_OS_X_VERSION_10_1 = 1010; - -const int MAC_OS_X_VERSION_10_2 = 1020; - -const int MAC_OS_X_VERSION_10_3 = 1030; - -const int MAC_OS_X_VERSION_10_4 = 1040; - -const int MAC_OS_X_VERSION_10_5 = 1050; - -const int MAC_OS_X_VERSION_10_6 = 1060; - -const int MAC_OS_X_VERSION_10_7 = 1070; - -const int MAC_OS_X_VERSION_10_8 = 1080; - -const int MAC_OS_X_VERSION_10_9 = 1090; - -const int MAC_OS_X_VERSION_10_10 = 101000; - -const int MAC_OS_X_VERSION_10_10_2 = 101002; - -const int MAC_OS_X_VERSION_10_10_3 = 101003; - -const int MAC_OS_X_VERSION_10_11 = 101100; - -const int MAC_OS_X_VERSION_10_11_2 = 101102; - -const int MAC_OS_X_VERSION_10_11_3 = 101103; - -const int MAC_OS_X_VERSION_10_11_4 = 101104; - -const int MAC_OS_X_VERSION_10_12 = 101200; - -const int MAC_OS_X_VERSION_10_12_1 = 101201; - -const int MAC_OS_X_VERSION_10_12_2 = 101202; - -const int MAC_OS_X_VERSION_10_12_4 = 101204; - -const int MAC_OS_X_VERSION_10_13 = 101300; - -const int MAC_OS_X_VERSION_10_13_1 = 101301; - -const int MAC_OS_X_VERSION_10_13_2 = 101302; - -const int MAC_OS_X_VERSION_10_13_4 = 101304; - -const int MAC_OS_X_VERSION_10_14 = 101400; - -const int MAC_OS_X_VERSION_10_14_1 = 101401; - -const int MAC_OS_X_VERSION_10_14_4 = 101404; - -const int MAC_OS_X_VERSION_10_14_5 = 101405; - -const int MAC_OS_X_VERSION_10_14_6 = 101406; - -const int MAC_OS_X_VERSION_10_15 = 101500; - -const int MAC_OS_X_VERSION_10_15_1 = 101501; - -const int MAC_OS_X_VERSION_10_15_4 = 101504; - -const int MAC_OS_X_VERSION_10_16 = 101600; - -const int MAC_OS_VERSION_11_0 = 110000; - -const int MAC_OS_VERSION_11_1 = 110100; - -const int MAC_OS_VERSION_11_3 = 110300; - -const int MAC_OS_VERSION_11_4 = 110400; - -const int MAC_OS_VERSION_11_5 = 110500; - -const int MAC_OS_VERSION_11_6 = 110600; - -const int MAC_OS_VERSION_12_0 = 120000; - -const int MAC_OS_VERSION_12_1 = 120100; - -const int MAC_OS_VERSION_12_2 = 120200; - -const int MAC_OS_VERSION_12_3 = 120300; - -const int MAC_OS_VERSION_12_4 = 120400; - -const int MAC_OS_VERSION_12_5 = 120500; - -const int MAC_OS_VERSION_12_6 = 120600; - -const int MAC_OS_VERSION_12_7 = 120700; - -const int MAC_OS_VERSION_13_0 = 130000; - -const int MAC_OS_VERSION_13_1 = 130100; - -const int MAC_OS_VERSION_13_2 = 130200; - -const int MAC_OS_VERSION_13_3 = 130300; - -const int MAC_OS_VERSION_13_4 = 130400; - -const int MAC_OS_VERSION_13_5 = 130500; - -const int MAC_OS_VERSION_13_6 = 130600; - -const int MAC_OS_VERSION_13_7 = 130700; - -const int MAC_OS_VERSION_14_0 = 140000; - -const int MAC_OS_VERSION_14_1 = 140100; - -const int MAC_OS_VERSION_14_2 = 140200; - -const int MAC_OS_VERSION_14_3 = 140300; - -const int MAC_OS_VERSION_14_4 = 140400; - -const int MAC_OS_VERSION_14_5 = 140500; - -const int MAC_OS_VERSION_14_6 = 140600; - -const int MAC_OS_VERSION_14_7 = 140700; - -const int MAC_OS_VERSION_15_0 = 150000; - -const int MAC_OS_VERSION_15_1 = 150100; - -const int MAC_OS_VERSION_15_2 = 150200; - -const int MAC_OS_VERSION_15_3 = 150300; - -const int MAC_OS_VERSION_15_4 = 150400; - -const int MAC_OS_VERSION_15_5 = 150500; - -const int MAC_OS_VERSION_15_6 = 150600; - -const int MAC_OS_VERSION_16_0 = 160000; - -const int MAC_OS_VERSION_26_0 = 260000; - -const int __AVAILABILITY_VERSIONS_VERSION_HASH = 93585900; - -const String __AVAILABILITY_VERSIONS_VERSION_STRING = 'Local'; - -const String __AVAILABILITY_FILE = 'AvailabilityVersions.h'; - -const int __MAC_OS_X_VERSION_MIN_REQUIRED = 160000; - -const int __MAC_OS_X_VERSION_MAX_ALLOWED = 260000; - -const int __ENABLE_LEGACY_MAC_AVAILABILITY = 1; - -const int __has_safe_buffers = 1; - -const int __DARWIN_ONLY_64_BIT_INO_T = 1; - -const int __DARWIN_ONLY_UNIX_CONFORMANCE = 1; - -const int __DARWIN_ONLY_VERS_1050 = 1; - -const int __DARWIN_UNIX03 = 1; - -const int __DARWIN_64_BIT_INO_T = 1; - -const int __DARWIN_VERS_1050 = 1; - -const int __DARWIN_NON_CANCELABLE = 0; - -const String __DARWIN_SUF_EXTSN = '\$DARWIN_EXTSN'; - -const int __DARWIN_C_ANSI = 4096; - -const int __DARWIN_C_FULL = 900000; - -const int __DARWIN_C_LEVEL = 900000; - -const int __STDC_WANT_LIB_EXT1__ = 1; - -const int __DARWIN_NO_LONG_LONG = 0; - -const int _DARWIN_FEATURE_64_BIT_INODE = 1; - -const int _DARWIN_FEATURE_ONLY_64_BIT_INODE = 1; - -const int _DARWIN_FEATURE_ONLY_VERS_1050 = 1; - -const int _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1; - -const int _DARWIN_FEATURE_UNIX_CONFORMANCE = 3; - -const int __has_ptrcheck = 0; - -const int __has_bounds_safety_attributes = 0; - -const int __DARWIN_NULL = 0; - -const int __PTHREAD_SIZE__ = 8176; - -const int __PTHREAD_ATTR_SIZE__ = 56; - -const int __PTHREAD_MUTEXATTR_SIZE__ = 8; - -const int __PTHREAD_MUTEX_SIZE__ = 56; - -const int __PTHREAD_CONDATTR_SIZE__ = 8; - -const int __PTHREAD_COND_SIZE__ = 40; - -const int __PTHREAD_ONCE_SIZE__ = 8; - -const int __PTHREAD_RWLOCK_SIZE__ = 192; - -const int __PTHREAD_RWLOCKATTR_SIZE__ = 16; - -const int __DARWIN_WCHAR_MAX = 2147483647; - -const int __DARWIN_WCHAR_MIN = -2147483648; - -const int __DARWIN_WEOF = -1; - -const int _FORTIFY_SOURCE = 2; - -const int __DARWIN_NSIG = 32; - -const int NSIG = 32; - -const int _ARM_SIGNAL_ = 1; - -const int SIGHUP = 1; - -const int SIGINT = 2; - -const int SIGQUIT = 3; - -const int SIGILL = 4; - -const int SIGTRAP = 5; - -const int SIGABRT = 6; - -const int SIGIOT = 6; - -const int SIGEMT = 7; - -const int SIGFPE = 8; - -const int SIGKILL = 9; - -const int SIGBUS = 10; - -const int SIGSEGV = 11; - -const int SIGSYS = 12; - -const int SIGPIPE = 13; - -const int SIGALRM = 14; - -const int SIGTERM = 15; - -const int SIGURG = 16; - -const int SIGSTOP = 17; - -const int SIGTSTP = 18; - -const int SIGCONT = 19; - -const int SIGCHLD = 20; - -const int SIGTTIN = 21; - -const int SIGTTOU = 22; - -const int SIGIO = 23; - -const int SIGXCPU = 24; - -const int SIGXFSZ = 25; - -const int SIGVTALRM = 26; - -const int SIGPROF = 27; - -const int SIGWINCH = 28; - -const int SIGINFO = 29; - -const int SIGUSR1 = 30; - -const int SIGUSR2 = 31; - -const int USER_ADDR_NULL = 0; - -const int __DARWIN_OPAQUE_ARM_THREAD_STATE64 = 0; - -const int SIGEV_NONE = 0; - -const int SIGEV_SIGNAL = 1; - -const int SIGEV_THREAD = 3; - -const int SIGEV_KEVENT = 4; - -const int ILL_NOOP = 0; - -const int ILL_ILLOPC = 1; - -const int ILL_ILLTRP = 2; - -const int ILL_PRVOPC = 3; - -const int ILL_ILLOPN = 4; - -const int ILL_ILLADR = 5; - -const int ILL_PRVREG = 6; - -const int ILL_COPROC = 7; - -const int ILL_BADSTK = 8; - -const int FPE_NOOP = 0; - -const int FPE_FLTDIV = 1; - -const int FPE_FLTOVF = 2; - -const int FPE_FLTUND = 3; - -const int FPE_FLTRES = 4; - -const int FPE_FLTINV = 5; - -const int FPE_FLTSUB = 6; - -const int FPE_INTDIV = 7; - -const int FPE_INTOVF = 8; - -const int SEGV_NOOP = 0; - -const int SEGV_MAPERR = 1; - -const int SEGV_ACCERR = 2; - -const int BUS_NOOP = 0; - -const int BUS_ADRALN = 1; - -const int BUS_ADRERR = 2; - -const int BUS_OBJERR = 3; - -const int TRAP_BRKPT = 1; - -const int TRAP_TRACE = 2; - -const int CLD_NOOP = 0; - -const int CLD_EXITED = 1; - -const int CLD_KILLED = 2; - -const int CLD_DUMPED = 3; - -const int CLD_TRAPPED = 4; - -const int CLD_STOPPED = 5; - -const int CLD_CONTINUED = 6; - -const int POLL_IN = 1; - -const int POLL_OUT = 2; - -const int POLL_MSG = 3; - -const int POLL_ERR = 4; - -const int POLL_PRI = 5; - -const int POLL_HUP = 6; - -const int SA_ONSTACK = 1; - -const int SA_RESTART = 2; - -const int SA_RESETHAND = 4; - -const int SA_NOCLDSTOP = 8; - -const int SA_NODEFER = 16; - -const int SA_NOCLDWAIT = 32; - -const int SA_SIGINFO = 64; - -const int SA_USERTRAMP = 256; - -const int SA_64REGSET = 512; - -const int SA_USERSPACE_MASK = 127; - -const int SIG_BLOCK = 1; - -const int SIG_UNBLOCK = 2; - -const int SIG_SETMASK = 3; - -const int SI_USER = 65537; - -const int SI_QUEUE = 65538; - -const int SI_TIMER = 65539; - -const int SI_ASYNCIO = 65540; - -const int SI_MESGQ = 65541; - -const int SS_ONSTACK = 1; - -const int SS_DISABLE = 4; - -const int MINSIGSTKSZ = 32768; - -const int SIGSTKSZ = 131072; - -const int SV_ONSTACK = 1; - -const int SV_INTERRUPT = 2; - -const int SV_RESETHAND = 4; - -const int SV_NODEFER = 16; - -const int SV_NOCLDSTOP = 8; - -const int SV_SIGINFO = 64; - -const int __WORDSIZE = 64; - -const int INT8_MAX = 127; - -const int INT16_MAX = 32767; - -const int INT32_MAX = 2147483647; - -const int INT64_MAX = 9223372036854775807; - -const int INT8_MIN = -128; - -const int INT16_MIN = -32768; - -const int INT32_MIN = -2147483648; - -const int INT64_MIN = -9223372036854775808; - -const int UINT8_MAX = 255; - -const int UINT16_MAX = 65535; - -const int UINT32_MAX = 4294967295; - -const int UINT64_MAX = -1; - -const int INT_LEAST8_MIN = -128; - -const int INT_LEAST16_MIN = -32768; - -const int INT_LEAST32_MIN = -2147483648; - -const int INT_LEAST64_MIN = -9223372036854775808; - -const int INT_LEAST8_MAX = 127; - -const int INT_LEAST16_MAX = 32767; - -const int INT_LEAST32_MAX = 2147483647; - -const int INT_LEAST64_MAX = 9223372036854775807; - -const int UINT_LEAST8_MAX = 255; - -const int UINT_LEAST16_MAX = 65535; - -const int UINT_LEAST32_MAX = 4294967295; - -const int UINT_LEAST64_MAX = -1; - -const int INT_FAST8_MIN = -128; - -const int INT_FAST16_MIN = -32768; - -const int INT_FAST32_MIN = -2147483648; - -const int INT_FAST64_MIN = -9223372036854775808; - -const int INT_FAST8_MAX = 127; - -const int INT_FAST16_MAX = 32767; - -const int INT_FAST32_MAX = 2147483647; - -const int INT_FAST64_MAX = 9223372036854775807; - -const int UINT_FAST8_MAX = 255; - -const int UINT_FAST16_MAX = 65535; - -const int UINT_FAST32_MAX = 4294967295; - -const int UINT_FAST64_MAX = -1; - -const int INTPTR_MAX = 9223372036854775807; - -const int INTPTR_MIN = -9223372036854775808; - -const int UINTPTR_MAX = -1; - -const int INTMAX_MAX = 9223372036854775807; - -const int UINTMAX_MAX = -1; - -const int INTMAX_MIN = -9223372036854775808; - -const int PTRDIFF_MIN = -9223372036854775808; - -const int PTRDIFF_MAX = 9223372036854775807; - -const int SIZE_MAX = -1; - -const int RSIZE_MAX = 9223372036854775807; - -const int WCHAR_MAX = 2147483647; - -const int WCHAR_MIN = -2147483648; - -const int WINT_MIN = -2147483648; - -const int WINT_MAX = 2147483647; - -const int SIG_ATOMIC_MIN = -2147483648; - -const int SIG_ATOMIC_MAX = 2147483647; - -const int PRIO_PROCESS = 0; - -const int PRIO_PGRP = 1; - -const int PRIO_USER = 2; - -const int PRIO_DARWIN_THREAD = 3; - -const int PRIO_DARWIN_PROCESS = 4; - -const int PRIO_MIN = -20; - -const int PRIO_MAX = 20; - -const int PRIO_DARWIN_BG = 4096; - -const int PRIO_DARWIN_NONUI = 4097; - -const int RUSAGE_SELF = 0; - -const int RUSAGE_CHILDREN = -1; - -const int RUSAGE_INFO_V0 = 0; - -const int RUSAGE_INFO_V1 = 1; - -const int RUSAGE_INFO_V2 = 2; - -const int RUSAGE_INFO_V3 = 3; - -const int RUSAGE_INFO_V4 = 4; - -const int RUSAGE_INFO_V5 = 5; - -const int RUSAGE_INFO_V6 = 6; - -const int RUSAGE_INFO_CURRENT = 6; - -const int RU_PROC_RUNS_RESLIDE = 1; - -const int RLIM_INFINITY = 9223372036854775807; - -const int RLIM_SAVED_MAX = 9223372036854775807; - -const int RLIM_SAVED_CUR = 9223372036854775807; - -const int RLIMIT_CPU = 0; - -const int RLIMIT_FSIZE = 1; - -const int RLIMIT_DATA = 2; - -const int RLIMIT_STACK = 3; - -const int RLIMIT_CORE = 4; - -const int RLIMIT_AS = 5; - -const int RLIMIT_RSS = 5; - -const int RLIMIT_MEMLOCK = 6; - -const int RLIMIT_NPROC = 7; - -const int RLIMIT_NOFILE = 8; - -const int RLIM_NLIMITS = 9; - -const int _RLIMIT_POSIX_FLAG = 4096; - -const int RLIMIT_WAKEUPS_MONITOR = 1; - -const int RLIMIT_CPU_USAGE_MONITOR = 2; - -const int RLIMIT_THREAD_CPULIMITS = 3; - -const int RLIMIT_FOOTPRINT_INTERVAL = 4; - -const int WAKEMON_ENABLE = 1; - -const int WAKEMON_DISABLE = 2; - -const int WAKEMON_GET_PARAMS = 4; - -const int WAKEMON_SET_DEFAULTS = 8; - -const int WAKEMON_MAKE_FATAL = 16; - -const int CPUMON_MAKE_FATAL = 4096; - -const int FOOTPRINT_INTERVAL_RESET = 1; - -const int IOPOL_TYPE_DISK = 0; - -const int IOPOL_TYPE_VFS_ATIME_UPDATES = 2; - -const int IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES = 3; - -const int IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME = 4; - -const int IOPOL_TYPE_VFS_TRIGGER_RESOLVE = 5; - -const int IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION = 6; - -const int IOPOL_TYPE_VFS_IGNORE_PERMISSIONS = 7; - -const int IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE = 8; - -const int IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES = 9; - -const int IOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY = 10; - -const int IOPOL_TYPE_VFS_ENTITLED_RESERVE_ACCESS = 14; - -const int IOPOL_SCOPE_PROCESS = 0; - -const int IOPOL_SCOPE_THREAD = 1; - -const int IOPOL_SCOPE_DARWIN_BG = 2; - -const int IOPOL_DEFAULT = 0; - -const int IOPOL_IMPORTANT = 1; - -const int IOPOL_PASSIVE = 2; - -const int IOPOL_THROTTLE = 3; - -const int IOPOL_UTILITY = 4; - -const int IOPOL_STANDARD = 5; - -const int IOPOL_APPLICATION = 5; - -const int IOPOL_NORMAL = 1; - -const int IOPOL_ATIME_UPDATES_DEFAULT = 0; - -const int IOPOL_ATIME_UPDATES_OFF = 1; - -const int IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT = 0; - -const int IOPOL_MATERIALIZE_DATALESS_FILES_OFF = 1; - -const int IOPOL_MATERIALIZE_DATALESS_FILES_ON = 2; - -const int IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT = 0; - -const int IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME = 1; - -const int IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT = 0; - -const int IOPOL_VFS_TRIGGER_RESOLVE_OFF = 1; - -const int IOPOL_VFS_CONTENT_PROTECTION_DEFAULT = 0; - -const int IOPOL_VFS_CONTENT_PROTECTION_IGNORE = 1; - -const int IOPOL_VFS_IGNORE_PERMISSIONS_OFF = 0; - -const int IOPOL_VFS_IGNORE_PERMISSIONS_ON = 1; - -const int IOPOL_VFS_SKIP_MTIME_UPDATE_OFF = 0; - -const int IOPOL_VFS_SKIP_MTIME_UPDATE_ON = 1; - -const int IOPOL_VFS_SKIP_MTIME_UPDATE_IGNORE = 2; - -const int IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF = 0; - -const int IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON = 1; - -const int IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT = 0; - -const int IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON = 1; - -const int IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT = 0; - -const int IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON = 1; - -const int IOPOL_VFS_ENTITLED_RESERVE_ACCESS_OFF = 0; - -const int IOPOL_VFS_ENTITLED_RESERVE_ACCESS_ON = 1; - -const int WNOHANG = 1; - -const int WUNTRACED = 2; - -const int WCOREFLAG = 128; - -const int _WSTOPPED = 127; - -const int WEXITED = 4; - -const int WSTOPPED = 8; - -const int WCONTINUED = 16; - -const int WNOWAIT = 32; - -const int WAIT_ANY = -1; - -const int WAIT_MYPGRP = 0; - -const int _QUAD_HIGHWORD = 1; - -const int _QUAD_LOWWORD = 0; - -const int __DARWIN_LITTLE_ENDIAN = 1234; - -const int __DARWIN_BIG_ENDIAN = 4321; - -const int __DARWIN_PDP_ENDIAN = 3412; - -const int LITTLE_ENDIAN = 1234; - -const int BIG_ENDIAN = 4321; - -const int PDP_ENDIAN = 3412; - -const int __DARWIN_BYTE_ORDER = 1234; - -const int BYTE_ORDER = 1234; - -const int NULL = 0; - -const int EXIT_FAILURE = 1; - -const int EXIT_SUCCESS = 0; - -const int RAND_MAX = 2147483647; - -const int _MALLOC_TYPE_MALLOC_BACKDEPLOY_PUBLIC = 1; - -const int TARGET_OS_RTKIT = 0; - -const int TARGET_RT_LITTLE_ENDIAN = 1; - -const int TARGET_RT_BIG_ENDIAN = 0; - -const int TARGET_RT_64_BIT = 1; - -const int TARGET_RT_MAC_CFM = 0; - -const int TARGET_RT_MAC_MACHO = 1; - -const int TARGET_CPU_ARM64 = 1; - -const int TARGET_CPU_PPC = 0; - -const int TARGET_CPU_PPC64 = 0; - -const int TARGET_CPU_68K = 0; - -const int TARGET_CPU_X86 = 0; - -const int TARGET_CPU_X86_64 = 0; - -const int TARGET_CPU_ARM = 0; - -const int TARGET_CPU_MIPS = 0; - -const int TARGET_CPU_SPARC = 0; - -const int TARGET_CPU_ALPHA = 0; - -const int TARGET_ABI_USES_IOS_VALUES = 1; - -const int __DARWIN_FD_SETSIZE = 1024; - -const int __DARWIN_NBBY = 8; - -const int __DARWIN_NFDBITS = 32; - -const int NBBY = 8; - -const int NFDBITS = 32; - -const int FD_SETSIZE = 1024; - -const int __bool_true_false_are_defined = 1; - -const int true$ = 1; - -const int false$ = 0; - -const int __DARWIN_CLK_TCK = 100; - -const int MB_LEN_MAX = 6; - -const int CLK_TCK = 100; - -const int CHAR_BIT = 8; - -const int SCHAR_MAX = 127; - -const int SCHAR_MIN = -128; - -const int UCHAR_MAX = 255; - -const int CHAR_MAX = 127; - -const int CHAR_MIN = -128; - -const int USHRT_MAX = 65535; - -const int SHRT_MAX = 32767; - -const int SHRT_MIN = -32768; - -const int UINT_MAX = 4294967295; - -const int INT_MAX = 2147483647; - -const int INT_MIN = -2147483648; - -const int ULONG_MAX = -1; - -const int LONG_MAX = 9223372036854775807; - -const int LONG_MIN = -9223372036854775808; - -const int ULLONG_MAX = -1; - -const int LLONG_MAX = 9223372036854775807; - -const int LLONG_MIN = -9223372036854775808; - -const int LONG_BIT = 64; - -const int SSIZE_MAX = 9223372036854775807; - -const int WORD_BIT = 32; - -const int SIZE_T_MAX = -1; - -const int UQUAD_MAX = -1; - -const int QUAD_MAX = 9223372036854775807; - -const int QUAD_MIN = -9223372036854775808; - -const int _POSIX_THREAD_KEYS_MAX = 128; - -const int API_TO_BE_DEPRECATED = 100000; - -const int API_TO_BE_DEPRECATED_MACOS = 100000; - -const int API_TO_BE_DEPRECATED_IOS = 100000; - -const int API_TO_BE_DEPRECATED_TVOS = 100000; - -const int API_TO_BE_DEPRECATED_WATCHOS = 100000; - -const int API_TO_BE_DEPRECATED_DRIVERKIT = 100000; - -const int API_TO_BE_DEPRECATED_VISIONOS = 100000; - -const int TRUE = 1; - -const int FALSE = 0; - -const int OS_OBJECT_HAVE_OBJC_SUPPORT = 0; - -const int OS_OBJECT_USE_OBJC = 0; - -const int OS_OBJECT_SWIFT3 = 0; - -const int OS_OBJECT_USE_OBJC_RETAIN_RELEASE = 0; - -const int SEEK_SET = 0; - -const int SEEK_CUR = 1; - -const int SEEK_END = 2; - -const int SEEK_HOLE = 3; - -const int SEEK_DATA = 4; - -const int MACH_PORT_NULL = 0; - -const int MACH_PORT_DEAD = 4294967295; - -const int MACH_PORT_RIGHT_SEND = 0; - -const int MACH_PORT_RIGHT_RECEIVE = 1; - -const int MACH_PORT_RIGHT_SEND_ONCE = 2; - -const int MACH_PORT_RIGHT_PORT_SET = 3; - -const int MACH_PORT_RIGHT_DEAD_NAME = 4; - -const int MACH_PORT_RIGHT_LABELH = 5; - -const int MACH_PORT_RIGHT_NUMBER = 6; - -const int MACH_PORT_TYPE_NONE = 0; - -const int MACH_PORT_TYPE_SEND = 65536; - -const int MACH_PORT_TYPE_RECEIVE = 131072; - -const int MACH_PORT_TYPE_SEND_ONCE = 262144; - -const int MACH_PORT_TYPE_PORT_SET = 524288; - -const int MACH_PORT_TYPE_DEAD_NAME = 1048576; - -const int MACH_PORT_TYPE_LABELH = 2097152; - -const int MACH_PORT_TYPE_DNREQUEST = 2147483648; - -const int MACH_PORT_TYPE_SPREQUEST = 1073741824; - -const int MACH_PORT_TYPE_SPREQUEST_DELAYED = 536870912; - -const int MACH_PORT_TYPE_SEND_RECEIVE = 196608; - -const int MACH_PORT_TYPE_SEND_RIGHTS = 327680; - -const int MACH_PORT_TYPE_PORT_RIGHTS = 458752; - -const int MACH_PORT_TYPE_PORT_OR_DEAD = 1507328; - -const int MACH_PORT_TYPE_ALL_RIGHTS = 2031616; - -const int MACH_PORT_SRIGHTS_NONE = 0; - -const int MACH_PORT_SRIGHTS_PRESENT = 1; - -const int MACH_PORT_QLIMIT_ZERO = 0; - -const int MACH_PORT_QLIMIT_BASIC = 5; - -const int MACH_PORT_QLIMIT_SMALL = 16; - -const int MACH_PORT_QLIMIT_LARGE = 1024; - -const int MACH_PORT_QLIMIT_KERNEL = 65534; - -const int MACH_PORT_QLIMIT_MIN = 0; - -const int MACH_PORT_QLIMIT_DEFAULT = 5; - -const int MACH_PORT_QLIMIT_MAX = 1024; - -const int MACH_PORT_STATUS_FLAG_TEMPOWNER = 1; - -const int MACH_PORT_STATUS_FLAG_GUARDED = 2; - -const int MACH_PORT_STATUS_FLAG_STRICT_GUARD = 4; - -const int MACH_PORT_STATUS_FLAG_IMP_DONATION = 8; - -const int MACH_PORT_STATUS_FLAG_REVIVE = 16; - -const int MACH_PORT_STATUS_FLAG_TASKPTR = 32; - -const int MACH_PORT_STATUS_FLAG_GUARD_IMMOVABLE_RECEIVE = 64; - -const int MACH_PORT_STATUS_FLAG_NO_GRANT = 128; - -const int MACH_PORT_LIMITS_INFO = 1; - -const int MACH_PORT_RECEIVE_STATUS = 2; - -const int MACH_PORT_DNREQUESTS_SIZE = 3; - -const int MACH_PORT_TEMPOWNER = 4; - -const int MACH_PORT_IMPORTANCE_RECEIVER = 5; - -const int MACH_PORT_DENAP_RECEIVER = 6; - -const int MACH_PORT_INFO_EXT = 7; - -const int MACH_PORT_GUARD_INFO = 8; - -const int MACH_PORT_SERVICE_THROTTLED = 9; - -const int MACH_PORT_LIMITS_INFO_COUNT = 1; - -const int MACH_PORT_RECEIVE_STATUS_COUNT = 10; - -const int MACH_PORT_DNREQUESTS_SIZE_COUNT = 1; - -const int MACH_PORT_INFO_EXT_COUNT = 17; - -const int MACH_PORT_GUARD_INFO_COUNT = 2; - -const int MACH_PORT_SERVICE_THROTTLED_COUNT = 1; - -const int MACH_SERVICE_PORT_INFO_STRING_NAME_MAX_BUF_LEN = 255; - -const int MACH_SERVICE_PORT_INFO_COUNT = 0; - -const String MACH_PORT_CONNECTION_PORT_WITH_PORT_ARRAY = - 'com.apple.developer.allow-connection-port-with-port-array'; - -const String MACH_PORT_PROVISIONAL_REPLY_ENTITLEMENT = - 'com.apple.private.allow-weak-reply-port'; - -const int MPO_CONTEXT_AS_GUARD = 1; - -const int MPO_QLIMIT = 2; - -const int MPO_TEMPOWNER = 4; - -const int MPO_IMPORTANCE_RECEIVER = 8; - -const int MPO_INSERT_SEND_RIGHT = 16; - -const int MPO_STRICT = 32; - -const int MPO_DENAP_RECEIVER = 64; - -const int MPO_IMMOVABLE_RECEIVE = 128; - -const int MPO_FILTER_MSG = 256; - -const int MPO_TG_BLOCK_TRACKING = 512; - -const int MPO_ENFORCE_REPLY_PORT_SEMANTICS = 8192; - -const int MPO_STRICT_SERVICE_PORT = 9216; - -const int MPO_OPTIONS_MASK = 9215; - -const int MPO_PORT_TYPE_MASK = 121856; - -const int MPO_PORT = 0; - -const int MPO_SERVICE_PORT = 1024; - -const int MPO_CONNECTION_PORT = 2048; - -const int MPO_REPLY_PORT = 4096; - -const int MPO_PROVISIONAL_REPLY_PORT = 16384; - -const int MPO_EXCEPTION_PORT = 32768; - -const int MPO_CONNECTION_PORT_WITH_PORT_ARRAY = 65536; - -const int MPO_UNUSED_BITS = -131072; - -const int MPO_ANONYMOUS_SERVICE = 4294967294; - -const int GUARD_TYPE_MACH_PORT = 1; - -const int MAX_FATAL_kGUARD_EXC_CODE = 128; - -const int MAX_OPTIONAL_kGUARD_EXC_CODE = 524288; - -const int MPG_FLAGS_NONE = 0; - -const int MPG_FLAGS_STRICT_REPLY_INVALID_VOUCHER = 4; - -const int MPG_FLAGS_STRICT_REPLY_MISMATCHED_PERSONA = 16; - -const int MPG_FLAGS_MOD_REFS_PINNED_DEALLOC = 1; - -const int MPG_FLAGS_MOD_REFS_PINNED_DESTROY = 2; - -const int MPG_FLAGS_MOD_REFS_PINNED_COPYIN = 3; - -const int MPG_FLAGS_INVALID_RIGHT_RECV = 1; - -const int MPG_FLAGS_INVALID_RIGHT_DELTA = 2; - -const int MPG_FLAGS_INVALID_RIGHT_DESTRUCT = 3; - -const int MPG_FLAGS_INVALID_RIGHT_COPYIN = 4; - -const int MPG_FLAGS_INVALID_RIGHT_DEALLOC = 5; - -const int MPG_FLAGS_INVALID_RIGHT_DEALLOC_KERNEL = 6; - -const int MPG_FLAGS_INVALID_RIGHT_TRANSLATE_PORT = 7; - -const int MPG_FLAGS_INVALID_RIGHT_TRANSLATE_PSET = 8; - -const int MPG_FLAGS_INVALID_VALUE_PEEK = 1; - -const int MPG_FLAGS_INVALID_VALUE_DELTA = 2; - -const int MPG_FLAGS_INVALID_VALUE_DESTRUCT = 3; - -const int MPG_FLAGS_KERN_FAILURE_TASK = 1; - -const int MPG_FLAGS_KERN_FAILURE_NOTIFY_TYPE = 2; - -const int MPG_FLAGS_KERN_FAILURE_NOTIFY_RECV = 3; - -const int MPG_FLAGS_KERN_FAILURE_MULTI_NOTI = 4; - -const int MPG_FLAGS_SEND_INVALID_RIGHT_PORT = 1; - -const int MPG_FLAGS_SEND_INVALID_RIGHT_OOL_PORT = 2; - -const int MPG_FLAGS_SEND_INVALID_RIGHT_GUARDED = 3; - -const int MPG_FLAGS_INVALID_OPTIONS_OOL_DISP = 1; - -const int MPG_FLAGS_INVALID_OPTIONS_OOL_ARRAYS = 2; - -const int MPG_FLAGS_INVALID_OPTIONS_OOL_RIGHT = 3; - -const int MPG_STRICT = 1; - -const int MPG_IMMOVABLE_RECEIVE = 2; - -const int _POSIX_VERSION = 200112; - -const int _POSIX2_VERSION = 200112; - -const int _POSIX_VDISABLE = 255; - -const int F_OK = 0; - -const int X_OK = 1; - -const int W_OK = 2; - -const int R_OK = 4; - -const int _READ_OK = 512; - -const int _WRITE_OK = 1024; - -const int _EXECUTE_OK = 2048; - -const int _DELETE_OK = 4096; - -const int _APPEND_OK = 8192; - -const int _RMFILE_OK = 16384; - -const int _RATTR_OK = 32768; - -const int _WATTR_OK = 65536; - -const int _REXT_OK = 131072; - -const int _WEXT_OK = 262144; - -const int _RPERM_OK = 524288; - -const int _WPERM_OK = 1048576; - -const int _CHOWN_OK = 2097152; - -const int _ACCESS_EXTENDED_MASK = 4193792; - -const int L_SET = 0; - -const int L_INCR = 1; - -const int L_XTND = 2; - -const int ACCESSX_MAX_DESCRIPTORS = 100; - -const int ACCESSX_MAX_TABLESIZE = 16384; - -const int _PC_LINK_MAX = 1; - -const int _PC_MAX_CANON = 2; - -const int _PC_MAX_INPUT = 3; - -const int _PC_NAME_MAX = 4; - -const int _PC_PATH_MAX = 5; - -const int _PC_PIPE_BUF = 6; - -const int _PC_CHOWN_RESTRICTED = 7; - -const int _PC_NO_TRUNC = 8; - -const int _PC_VDISABLE = 9; - -const int _PC_NAME_CHARS_MAX = 10; - -const int _PC_CASE_SENSITIVE = 11; - -const int _PC_CASE_PRESERVING = 12; - -const int _PC_EXTENDED_SECURITY_NP = 13; - -const int _PC_AUTH_OPAQUE_NP = 14; - -const int _PC_2_SYMLINKS = 15; - -const int _PC_ALLOC_SIZE_MIN = 16; - -const int _PC_ASYNC_IO = 17; - -const int _PC_FILESIZEBITS = 18; - -const int _PC_PRIO_IO = 19; - -const int _PC_REC_INCR_XFER_SIZE = 20; - -const int _PC_REC_MAX_XFER_SIZE = 21; - -const int _PC_REC_MIN_XFER_SIZE = 22; - -const int _PC_REC_XFER_ALIGN = 23; - -const int _PC_SYMLINK_MAX = 24; - -const int _PC_SYNC_IO = 25; - -const int _PC_XATTR_SIZE_BITS = 26; - -const int _PC_MIN_HOLE_SIZE = 27; - -const int _CS_PATH = 1; - -const int STDIN_FILENO = 0; - -const int STDOUT_FILENO = 1; - -const int STDERR_FILENO = 2; - -const int _XOPEN_VERSION = 600; - -const int _XOPEN_XCU_VERSION = 4; - -const int _POSIX_ADVISORY_INFO = -1; - -const int _POSIX_ASYNCHRONOUS_IO = -1; - -const int _POSIX_BARRIERS = -1; - -const int _POSIX_CHOWN_RESTRICTED = 200112; - -const int _POSIX_CLOCK_SELECTION = -1; - -const int _POSIX_CPUTIME = -1; - -const int _POSIX_FSYNC = 200112; - -const int _POSIX_IPV6 = 200112; - -const int _POSIX_JOB_CONTROL = 200112; - -const int _POSIX_MAPPED_FILES = 200112; - -const int _POSIX_MEMLOCK = -1; - -const int _POSIX_MEMLOCK_RANGE = -1; - -const int _POSIX_MEMORY_PROTECTION = 200112; - -const int _POSIX_MESSAGE_PASSING = -1; - -const int _POSIX_MONOTONIC_CLOCK = -1; - -const int _POSIX_NO_TRUNC = 200112; - -const int _POSIX_PRIORITIZED_IO = -1; - -const int _POSIX_PRIORITY_SCHEDULING = -1; - -const int _POSIX_RAW_SOCKETS = -1; - -const int _POSIX_READER_WRITER_LOCKS = 200112; - -const int _POSIX_REALTIME_SIGNALS = -1; - -const int _POSIX_REGEXP = 200112; - -const int _POSIX_SAVED_IDS = 200112; - -const int _POSIX_SEMAPHORES = -1; - -const int _POSIX_SHARED_MEMORY_OBJECTS = -1; - -const int _POSIX_SHELL = 200112; - -const int _POSIX_SPAWN = 200112; - -const int _POSIX_SPIN_LOCKS = -1; - -const int _POSIX_SPORADIC_SERVER = -1; - -const int _POSIX_SYNCHRONIZED_IO = -1; - -const int _POSIX_THREAD_ATTR_STACKADDR = 200112; - -const int _POSIX_THREAD_ATTR_STACKSIZE = 200112; - -const int _POSIX_THREAD_CPUTIME = -1; - -const int _POSIX_THREAD_PRIO_INHERIT = -1; - -const int _POSIX_THREAD_PRIO_PROTECT = -1; - -const int _POSIX_THREAD_PRIORITY_SCHEDULING = -1; - -const int _POSIX_THREAD_PROCESS_SHARED = 200112; - -const int _POSIX_THREAD_SAFE_FUNCTIONS = 200112; - -const int _POSIX_THREAD_SPORADIC_SERVER = -1; - -const int _POSIX_THREADS = 200112; - -const int _POSIX_TIMEOUTS = -1; - -const int _POSIX_TIMERS = -1; - -const int _POSIX_TRACE = -1; - -const int _POSIX_TRACE_EVENT_FILTER = -1; - -const int _POSIX_TRACE_INHERIT = -1; - -const int _POSIX_TRACE_LOG = -1; - -const int _POSIX_TYPED_MEMORY_OBJECTS = -1; - -const int _POSIX2_C_BIND = 200112; - -const int _POSIX2_C_DEV = 200112; - -const int _POSIX2_CHAR_TERM = 200112; - -const int _POSIX2_FORT_DEV = -1; - -const int _POSIX2_FORT_RUN = 200112; - -const int _POSIX2_LOCALEDEF = 200112; - -const int _POSIX2_PBS = -1; - -const int _POSIX2_PBS_ACCOUNTING = -1; - -const int _POSIX2_PBS_CHECKPOINT = -1; - -const int _POSIX2_PBS_LOCATE = -1; - -const int _POSIX2_PBS_MESSAGE = -1; - -const int _POSIX2_PBS_TRACK = -1; - -const int _POSIX2_SW_DEV = 200112; - -const int _POSIX2_UPE = 200112; - -const int __ILP32_OFF32 = -1; - -const int __ILP32_OFFBIG = -1; - -const int __LP64_OFF64 = 1; - -const int __LPBIG_OFFBIG = 1; - -const int _POSIX_V6_ILP32_OFF32 = -1; - -const int _POSIX_V6_ILP32_OFFBIG = -1; - -const int _POSIX_V6_LP64_OFF64 = 1; - -const int _POSIX_V6_LPBIG_OFFBIG = 1; - -const int _POSIX_V7_ILP32_OFF32 = -1; - -const int _POSIX_V7_ILP32_OFFBIG = -1; - -const int _POSIX_V7_LP64_OFF64 = 1; - -const int _POSIX_V7_LPBIG_OFFBIG = 1; - -const int _V6_ILP32_OFF32 = -1; - -const int _V6_ILP32_OFFBIG = -1; - -const int _V6_LP64_OFF64 = 1; - -const int _V6_LPBIG_OFFBIG = 1; - -const int _XBS5_ILP32_OFF32 = -1; - -const int _XBS5_ILP32_OFFBIG = -1; - -const int _XBS5_LP64_OFF64 = 1; - -const int _XBS5_LPBIG_OFFBIG = 1; - -const int _XOPEN_CRYPT = 1; - -const int _XOPEN_ENH_I18N = 1; - -const int _XOPEN_LEGACY = -1; - -const int _XOPEN_REALTIME = -1; - -const int _XOPEN_REALTIME_THREADS = -1; - -const int _XOPEN_SHM = 1; - -const int _XOPEN_STREAMS = -1; - -const int _XOPEN_UNIX = 1; - -const int _SC_ARG_MAX = 1; - -const int _SC_CHILD_MAX = 2; - -const int _SC_CLK_TCK = 3; - -const int _SC_NGROUPS_MAX = 4; - -const int _SC_OPEN_MAX = 5; - -const int _SC_JOB_CONTROL = 6; - -const int _SC_SAVED_IDS = 7; - -const int _SC_VERSION = 8; - -const int _SC_BC_BASE_MAX = 9; - -const int _SC_BC_DIM_MAX = 10; - -const int _SC_BC_SCALE_MAX = 11; - -const int _SC_BC_STRING_MAX = 12; - -const int _SC_COLL_WEIGHTS_MAX = 13; - -const int _SC_EXPR_NEST_MAX = 14; - -const int _SC_LINE_MAX = 15; - -const int _SC_RE_DUP_MAX = 16; - -const int _SC_2_VERSION = 17; - -const int _SC_2_C_BIND = 18; - -const int _SC_2_C_DEV = 19; - -const int _SC_2_CHAR_TERM = 20; - -const int _SC_2_FORT_DEV = 21; - -const int _SC_2_FORT_RUN = 22; - -const int _SC_2_LOCALEDEF = 23; - -const int _SC_2_SW_DEV = 24; - -const int _SC_2_UPE = 25; - -const int _SC_STREAM_MAX = 26; - -const int _SC_TZNAME_MAX = 27; - -const int _SC_ASYNCHRONOUS_IO = 28; - -const int _SC_PAGESIZE = 29; - -const int _SC_MEMLOCK = 30; - -const int _SC_MEMLOCK_RANGE = 31; - -const int _SC_MEMORY_PROTECTION = 32; - -const int _SC_MESSAGE_PASSING = 33; - -const int _SC_PRIORITIZED_IO = 34; - -const int _SC_PRIORITY_SCHEDULING = 35; - -const int _SC_REALTIME_SIGNALS = 36; - -const int _SC_SEMAPHORES = 37; - -const int _SC_FSYNC = 38; - -const int _SC_SHARED_MEMORY_OBJECTS = 39; - -const int _SC_SYNCHRONIZED_IO = 40; - -const int _SC_TIMERS = 41; - -const int _SC_AIO_LISTIO_MAX = 42; - -const int _SC_AIO_MAX = 43; - -const int _SC_AIO_PRIO_DELTA_MAX = 44; - -const int _SC_DELAYTIMER_MAX = 45; - -const int _SC_MQ_OPEN_MAX = 46; - -const int _SC_MAPPED_FILES = 47; - -const int _SC_RTSIG_MAX = 48; - -const int _SC_SEM_NSEMS_MAX = 49; - -const int _SC_SEM_VALUE_MAX = 50; - -const int _SC_SIGQUEUE_MAX = 51; - -const int _SC_TIMER_MAX = 52; - -const int _SC_NPROCESSORS_CONF = 57; - -const int _SC_NPROCESSORS_ONLN = 58; - -const int _SC_2_PBS = 59; - -const int _SC_2_PBS_ACCOUNTING = 60; - -const int _SC_2_PBS_CHECKPOINT = 61; - -const int _SC_2_PBS_LOCATE = 62; - -const int _SC_2_PBS_MESSAGE = 63; - -const int _SC_2_PBS_TRACK = 64; - -const int _SC_ADVISORY_INFO = 65; - -const int _SC_BARRIERS = 66; - -const int _SC_CLOCK_SELECTION = 67; - -const int _SC_CPUTIME = 68; - -const int _SC_FILE_LOCKING = 69; - -const int _SC_GETGR_R_SIZE_MAX = 70; - -const int _SC_GETPW_R_SIZE_MAX = 71; - -const int _SC_HOST_NAME_MAX = 72; - -const int _SC_LOGIN_NAME_MAX = 73; - -const int _SC_MONOTONIC_CLOCK = 74; - -const int _SC_MQ_PRIO_MAX = 75; - -const int _SC_READER_WRITER_LOCKS = 76; - -const int _SC_REGEXP = 77; - -const int _SC_SHELL = 78; - -const int _SC_SPAWN = 79; - -const int _SC_SPIN_LOCKS = 80; - -const int _SC_SPORADIC_SERVER = 81; - -const int _SC_THREAD_ATTR_STACKADDR = 82; - -const int _SC_THREAD_ATTR_STACKSIZE = 83; - -const int _SC_THREAD_CPUTIME = 84; - -const int _SC_THREAD_DESTRUCTOR_ITERATIONS = 85; - -const int _SC_THREAD_KEYS_MAX = 86; - -const int _SC_THREAD_PRIO_INHERIT = 87; - -const int _SC_THREAD_PRIO_PROTECT = 88; - -const int _SC_THREAD_PRIORITY_SCHEDULING = 89; - -const int _SC_THREAD_PROCESS_SHARED = 90; - -const int _SC_THREAD_SAFE_FUNCTIONS = 91; - -const int _SC_THREAD_SPORADIC_SERVER = 92; - -const int _SC_THREAD_STACK_MIN = 93; - -const int _SC_THREAD_THREADS_MAX = 94; - -const int _SC_TIMEOUTS = 95; - -const int _SC_THREADS = 96; - -const int _SC_TRACE = 97; - -const int _SC_TRACE_EVENT_FILTER = 98; - -const int _SC_TRACE_INHERIT = 99; - -const int _SC_TRACE_LOG = 100; - -const int _SC_TTY_NAME_MAX = 101; - -const int _SC_TYPED_MEMORY_OBJECTS = 102; - -const int _SC_V6_ILP32_OFF32 = 103; - -const int _SC_V6_ILP32_OFFBIG = 104; - -const int _SC_V6_LP64_OFF64 = 105; - -const int _SC_V6_LPBIG_OFFBIG = 106; - -const int _SC_IPV6 = 118; - -const int _SC_RAW_SOCKETS = 119; - -const int _SC_SYMLOOP_MAX = 120; - -const int _SC_ATEXIT_MAX = 107; - -const int _SC_IOV_MAX = 56; - -const int _SC_PAGE_SIZE = 29; - -const int _SC_XOPEN_CRYPT = 108; - -const int _SC_XOPEN_ENH_I18N = 109; - -const int _SC_XOPEN_LEGACY = 110; - -const int _SC_XOPEN_REALTIME = 111; - -const int _SC_XOPEN_REALTIME_THREADS = 112; - -const int _SC_XOPEN_SHM = 113; - -const int _SC_XOPEN_STREAMS = 114; - -const int _SC_XOPEN_UNIX = 115; - -const int _SC_XOPEN_VERSION = 116; - -const int _SC_XOPEN_XCU_VERSION = 121; - -const int _SC_XBS5_ILP32_OFF32 = 122; - -const int _SC_XBS5_ILP32_OFFBIG = 123; - -const int _SC_XBS5_LP64_OFF64 = 124; - -const int _SC_XBS5_LPBIG_OFFBIG = 125; - -const int _SC_SS_REPL_MAX = 126; - -const int _SC_TRACE_EVENT_NAME_MAX = 127; - -const int _SC_TRACE_NAME_MAX = 128; - -const int _SC_TRACE_SYS_MAX = 129; - -const int _SC_TRACE_USER_EVENT_MAX = 130; - -const int _SC_PASS_MAX = 131; - -const int _SC_PHYS_PAGES = 200; - -const int _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 2; - -const int _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 3; - -const int _CS_POSIX_V6_ILP32_OFF32_LIBS = 4; - -const int _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 5; - -const int _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 6; - -const int _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 7; - -const int _CS_POSIX_V6_LP64_OFF64_CFLAGS = 8; - -const int _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 9; - -const int _CS_POSIX_V6_LP64_OFF64_LIBS = 10; - -const int _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 11; - -const int _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 12; - -const int _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 13; - -const int _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 14; - -const int _CS_XBS5_ILP32_OFF32_CFLAGS = 20; - -const int _CS_XBS5_ILP32_OFF32_LDFLAGS = 21; - -const int _CS_XBS5_ILP32_OFF32_LIBS = 22; - -const int _CS_XBS5_ILP32_OFF32_LINTFLAGS = 23; - -const int _CS_XBS5_ILP32_OFFBIG_CFLAGS = 24; - -const int _CS_XBS5_ILP32_OFFBIG_LDFLAGS = 25; - -const int _CS_XBS5_ILP32_OFFBIG_LIBS = 26; - -const int _CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 27; - -const int _CS_XBS5_LP64_OFF64_CFLAGS = 28; - -const int _CS_XBS5_LP64_OFF64_LDFLAGS = 29; - -const int _CS_XBS5_LP64_OFF64_LIBS = 30; - -const int _CS_XBS5_LP64_OFF64_LINTFLAGS = 31; - -const int _CS_XBS5_LPBIG_OFFBIG_CFLAGS = 32; - -const int _CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 33; - -const int _CS_XBS5_LPBIG_OFFBIG_LIBS = 34; - -const int _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 35; - -const int _CS_DARWIN_USER_DIR = 65536; - -const int _CS_DARWIN_USER_TEMP_DIR = 65537; - -const int _CS_DARWIN_USER_CACHE_DIR = 65538; - -const int F_ULOCK = 0; - -const int F_LOCK = 1; - -const int F_TLOCK = 2; - -const int F_TEST = 3; - -const int SYNC_VOLUME_FULLSYNC = 1; - -const int SYNC_VOLUME_WAIT = 2; - -const int O_RDONLY = 0; - -const int O_WRONLY = 1; - -const int O_RDWR = 2; - -const int O_ACCMODE = 3; - -const int FREAD = 1; - -const int FWRITE = 2; - -const int O_NONBLOCK = 4; - -const int O_APPEND = 8; - -const int O_SYNC = 128; - -const int O_SHLOCK = 16; - -const int O_EXLOCK = 32; - -const int O_ASYNC = 64; - -const int O_FSYNC = 128; - -const int O_NOFOLLOW = 256; - -const int O_CREAT = 512; - -const int O_TRUNC = 1024; - -const int O_EXCL = 2048; - -const int O_RESOLVE_BENEATH = 4096; - -const int O_UNIQUE = 8192; - -const int O_EVTONLY = 32768; - -const int O_NOCTTY = 131072; - -const int O_DIRECTORY = 1048576; - -const int O_SYMLINK = 2097152; - -const int O_DSYNC = 4194304; - -const int O_CLOEXEC = 16777216; - -const int O_NOFOLLOW_ANY = 536870912; - -const int O_EXEC = 1073741824; - -const int O_SEARCH = 1074790400; - -const int AT_FDCWD = -2; - -const int AT_EACCESS = 16; - -const int AT_SYMLINK_NOFOLLOW = 32; - -const int AT_SYMLINK_FOLLOW = 64; - -const int AT_REMOVEDIR = 128; - -const int AT_REALDEV = 512; - -const int AT_FDONLY = 1024; - -const int AT_SYMLINK_NOFOLLOW_ANY = 2048; - -const int AT_RESOLVE_BENEATH = 8192; - -const int AT_NODELETEBUSY = 16384; - -const int O_DP_GETRAWENCRYPTED = 1; - -const int O_DP_GETRAWUNENCRYPTED = 2; - -const int O_DP_AUTHENTICATE = 4; - -const int AUTH_OPEN_NOAUTHFD = -1; - -const int FAPPEND = 8; - -const int FASYNC = 64; - -const int FFSYNC = 128; - -const int FFDSYNC = 4194304; - -const int FNONBLOCK = 4; - -const int FNDELAY = 4; - -const int O_NDELAY = 4; - -const int CPF_OVERWRITE = 1; - -const int CPF_IGNORE_MODE = 2; - -const int CPF_MASK = 3; - -const int F_DUPFD = 0; - -const int F_GETFD = 1; - -const int F_SETFD = 2; - -const int F_GETFL = 3; - -const int F_SETFL = 4; - -const int F_GETOWN = 5; - -const int F_SETOWN = 6; - -const int F_GETLK = 7; - -const int F_SETLK = 8; - -const int F_SETLKW = 9; - -const int F_SETLKWTIMEOUT = 10; - -const int F_FLUSH_DATA = 40; - -const int F_CHKCLEAN = 41; - -const int F_PREALLOCATE = 42; - -const int F_SETSIZE = 43; - -const int F_RDADVISE = 44; - -const int F_RDAHEAD = 45; - -const int F_NOCACHE = 48; - -const int F_LOG2PHYS = 49; - -const int F_GETPATH = 50; - -const int F_FULLFSYNC = 51; - -const int F_PATHPKG_CHECK = 52; - -const int F_FREEZE_FS = 53; - -const int F_THAW_FS = 54; - -const int F_GLOBAL_NOCACHE = 55; - -const int F_ADDSIGS = 59; - -const int F_ADDFILESIGS = 61; - -const int F_NODIRECT = 62; - -const int F_GETPROTECTIONCLASS = 63; - -const int F_SETPROTECTIONCLASS = 64; - -const int F_LOG2PHYS_EXT = 65; - -const int F_GETLKPID = 66; - -const int F_SETBACKINGSTORE = 70; - -const int F_GETPATH_MTMINFO = 71; - -const int F_GETCODEDIR = 72; - -const int F_SETNOSIGPIPE = 73; - -const int F_GETNOSIGPIPE = 74; - -const int F_TRANSCODEKEY = 75; - -const int F_SINGLE_WRITER = 76; - -const int F_GETPROTECTIONLEVEL = 77; - -const int F_FINDSIGS = 78; - -const int F_ADDFILESIGS_FOR_DYLD_SIM = 83; - -const int F_BARRIERFSYNC = 85; - -const int F_OFD_SETLK = 90; - -const int F_OFD_SETLKW = 91; - -const int F_OFD_GETLK = 92; - -const int F_OFD_SETLKWTIMEOUT = 93; - -const int F_ADDFILESIGS_RETURN = 97; - -const int F_CHECK_LV = 98; - -const int F_PUNCHHOLE = 99; - -const int F_TRIM_ACTIVE_FILE = 100; - -const int F_SPECULATIVE_READ = 101; - -const int F_GETPATH_NOFIRMLINK = 102; - -const int F_ADDFILESIGS_INFO = 103; - -const int F_ADDFILESUPPL = 104; - -const int F_GETSIGSINFO = 105; - -const int F_SETLEASE = 106; - -const int F_GETLEASE = 107; - -const int F_TRANSFEREXTENTS = 110; - -const int F_ATTRIBUTION_TAG = 111; - -const int F_NOCACHE_EXT = 112; - -const int F_ADDSIGS_MAIN_BINARY = 113; - -const int FCNTL_FS_SPECIFIC_BASE = 65536; - -const int F_DUPFD_CLOEXEC = 67; - -const int FD_CLOEXEC = 1; - -const int F_RDLCK = 1; - -const int F_UNLCK = 2; - -const int F_WRLCK = 3; - -const int S_IFMT = 61440; - -const int S_IFIFO = 4096; - -const int S_IFCHR = 8192; - -const int S_IFDIR = 16384; - -const int S_IFBLK = 24576; - -const int S_IFREG = 32768; - -const int S_IFLNK = 40960; - -const int S_IFSOCK = 49152; - -const int S_IFWHT = 57344; - -const int S_IRWXU = 448; - -const int S_IRUSR = 256; - -const int S_IWUSR = 128; - -const int S_IXUSR = 64; - -const int S_IRWXG = 56; - -const int S_IRGRP = 32; - -const int S_IWGRP = 16; - -const int S_IXGRP = 8; - -const int S_IRWXO = 7; - -const int S_IROTH = 4; - -const int S_IWOTH = 2; - -const int S_IXOTH = 1; - -const int S_ISUID = 2048; - -const int S_ISGID = 1024; - -const int S_ISVTX = 512; - -const int S_ISTXT = 512; - -const int S_IREAD = 256; - -const int S_IWRITE = 128; - -const int S_IEXEC = 64; - -const int F_ALLOCATECONTIG = 2; - -const int F_ALLOCATEALL = 4; - -const int F_ALLOCATEPERSIST = 8; - -const int F_PEOFPOSMODE = 3; - -const int F_VOLPOSMODE = 4; - -const int USER_FSIGNATURES_CDHASH_LEN = 20; - -const int GETSIGSINFO_PLATFORM_BINARY = 1; - -const int LOCK_SH = 1; - -const int LOCK_EX = 2; - -const int LOCK_NB = 4; - -const int LOCK_UN = 8; - -const int ATTRIBUTION_NAME_MAX = 255; - -const int F_CREATE_TAG = 1; - -const int F_DELETE_TAG = 2; - -const int F_QUERY_TAG = 4; - -const int O_POPUP = 2147483648; - -const int O_ALERT = 536870912; - -const int FILESEC_GUID = 3; - -const int DISPATCH_API_VERSION = 20181008; - -const int __OS_WORKGROUP_ATTR_SIZE__ = 60; - -const int __OS_WORKGROUP_INTERVAL_DATA_SIZE__ = 56; - -const int __OS_WORKGROUP_JOIN_TOKEN_SIZE__ = 36; - -const int _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT = 799564724; - -const int _OS_WORKGROUP_ATTR_SIG_EMPTY_INIT = 799564740; - -const int _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT = 1386695757; - -const int DISPATCH_SWIFT3_OVERLAY = 0; - -const int TIME_MICROS_MAX = 1000000; - -const int SYSTEM_CLOCK = 0; - -const int CALENDAR_CLOCK = 1; - -const int REALTIME_CLOCK = 0; - -const int CLOCK_GET_TIME_RES = 1; - -const int CLOCK_ALARM_CURRES = 3; - -const int CLOCK_ALARM_MINRES = 4; - -const int CLOCK_ALARM_MAXRES = 5; - -const int NSEC_PER_USEC = 1000; - -const int USEC_PER_SEC = 1000000; - -const int NSEC_PER_SEC = 1000000000; - -const int NSEC_PER_MSEC = 1000000; - -const int ALRMTYPE = 255; - -const int TIME_ABSOLUTE = 0; - -const int TIME_RELATIVE = 1; - -const int MSEC_PER_SEC = 1000; - -const int DISPATCH_TIME_NOW = 0; - -const int DISPATCH_TIME_FOREVER = -1; - -const int QOS_MIN_RELATIVE_PRIORITY = -15; - -const int DISPATCH_APPLY_AUTO_AVAILABLE = 1; - -const int DISPATCH_QUEUE_PRIORITY_HIGH = 2; - -const int DISPATCH_QUEUE_PRIORITY_DEFAULT = 0; - -const int DISPATCH_QUEUE_PRIORITY_LOW = -2; - -const int DISPATCH_QUEUE_PRIORITY_BACKGROUND = -32768; - -const int DISPATCH_QUEUE_SERIAL = 0; - -const int DISPATCH_TARGET_QUEUE_DEFAULT = 0; - -const int DISPATCH_CURRENT_QUEUE_LABEL = 0; - -const int KERN_SUCCESS = 0; - -const int KERN_INVALID_ADDRESS = 1; - -const int KERN_PROTECTION_FAILURE = 2; - -const int KERN_NO_SPACE = 3; - -const int KERN_INVALID_ARGUMENT = 4; - -const int KERN_FAILURE = 5; - -const int KERN_RESOURCE_SHORTAGE = 6; - -const int KERN_NOT_RECEIVER = 7; - -const int KERN_NO_ACCESS = 8; - -const int KERN_MEMORY_FAILURE = 9; - -const int KERN_MEMORY_ERROR = 10; - -const int KERN_ALREADY_IN_SET = 11; - -const int KERN_NOT_IN_SET = 12; - -const int KERN_NAME_EXISTS = 13; - -const int KERN_ABORTED = 14; - -const int KERN_INVALID_NAME = 15; - -const int KERN_INVALID_TASK = 16; - -const int KERN_INVALID_RIGHT = 17; - -const int KERN_INVALID_VALUE = 18; - -const int KERN_UREFS_OVERFLOW = 19; - -const int KERN_INVALID_CAPABILITY = 20; - -const int KERN_RIGHT_EXISTS = 21; - -const int KERN_INVALID_HOST = 22; - -const int KERN_MEMORY_PRESENT = 23; - -const int KERN_MEMORY_DATA_MOVED = 24; - -const int KERN_MEMORY_RESTART_COPY = 25; - -const int KERN_INVALID_PROCESSOR_SET = 26; - -const int KERN_POLICY_LIMIT = 27; - -const int KERN_INVALID_POLICY = 28; - -const int KERN_INVALID_OBJECT = 29; - -const int KERN_ALREADY_WAITING = 30; - -const int KERN_DEFAULT_SET = 31; - -const int KERN_EXCEPTION_PROTECTED = 32; - -const int KERN_INVALID_LEDGER = 33; - -const int KERN_INVALID_MEMORY_CONTROL = 34; - -const int KERN_INVALID_SECURITY = 35; - -const int KERN_NOT_DEPRESSED = 36; - -const int KERN_TERMINATED = 37; - -const int KERN_LOCK_SET_DESTROYED = 38; - -const int KERN_LOCK_UNSTABLE = 39; - -const int KERN_LOCK_OWNED = 40; - -const int KERN_LOCK_OWNED_SELF = 41; - -const int KERN_SEMAPHORE_DESTROYED = 42; - -const int KERN_RPC_SERVER_TERMINATED = 43; - -const int KERN_RPC_TERMINATE_ORPHAN = 44; - -const int KERN_RPC_CONTINUE_ORPHAN = 45; - -const int KERN_NOT_SUPPORTED = 46; - -const int KERN_NODE_DOWN = 47; - -const int KERN_NOT_WAITING = 48; - -const int KERN_OPERATION_TIMED_OUT = 49; - -const int KERN_CODESIGN_ERROR = 50; - -const int KERN_POLICY_STATIC = 51; - -const int KERN_INSUFFICIENT_BUFFER_SIZE = 52; - -const int KERN_DENIED = 53; - -const int KERN_MISSING_KC = 54; - -const int KERN_INVALID_KC = 55; - -const int KERN_NOT_FOUND = 56; - -const int KERN_RETURN_MAX = 256; - -const int MACH_MSG_TIMEOUT_NONE = 0; - -const int MACH_MSGH_BITS_ZERO = 0; - -const int MACH_MSGH_BITS_REMOTE_MASK = 31; - -const int MACH_MSGH_BITS_LOCAL_MASK = 7936; - -const int MACH_MSGH_BITS_VOUCHER_MASK = 2031616; - -const int MACH_MSGH_BITS_PORTS_MASK = 2039583; - -const int MACH_MSGH_BITS_COMPLEX = 2147483648; - -const int MACH_MSGH_BITS_USER = 2149523231; - -const int MACH_MSGH_BITS_RAISEIMP = 536870912; - -const int MACH_MSGH_BITS_DENAP = 536870912; - -const int MACH_MSGH_BITS_IMPHOLDASRT = 268435456; - -const int MACH_MSGH_BITS_DENAPHOLDASRT = 268435456; - -const int MACH_MSGH_BITS_CIRCULAR = 268435456; - -const int MACH_MSGH_BITS_USED = 2954829599; - -const int MACH_MSG_PRIORITY_UNSPECIFIED = 0; - -const int MACH_MSG_TYPE_MOVE_RECEIVE = 16; - -const int MACH_MSG_TYPE_MOVE_SEND = 17; - -const int MACH_MSG_TYPE_MOVE_SEND_ONCE = 18; - -const int MACH_MSG_TYPE_COPY_SEND = 19; - -const int MACH_MSG_TYPE_MAKE_SEND = 20; - -const int MACH_MSG_TYPE_MAKE_SEND_ONCE = 21; - -const int MACH_MSG_TYPE_COPY_RECEIVE = 22; - -const int MACH_MSG_TYPE_DISPOSE_RECEIVE = 24; - -const int MACH_MSG_TYPE_DISPOSE_SEND = 25; - -const int MACH_MSG_TYPE_DISPOSE_SEND_ONCE = 26; - -const int MACH_MSG_PHYSICAL_COPY = 0; - -const int MACH_MSG_VIRTUAL_COPY = 1; - -const int MACH_MSG_ALLOCATE = 2; - -const int MACH_MSG_OVERWRITE = 3; - -const int MACH_MSG_GUARD_FLAGS_NONE = 0; - -const int MACH_MSG_GUARD_FLAGS_IMMOVABLE_RECEIVE = 1; - -const int MACH_MSG_GUARD_FLAGS_UNGUARDED_ON_SEND = 2; - -const int MACH_MSG_GUARD_FLAGS_MASK = 3; - -const int MACH_MSG_PORT_DESCRIPTOR = 0; - -const int MACH_MSG_OOL_DESCRIPTOR = 1; - -const int MACH_MSG_OOL_PORTS_DESCRIPTOR = 2; - -const int MACH_MSG_OOL_VOLATILE_DESCRIPTOR = 3; - -const int MACH_MSG_GUARDED_PORT_DESCRIPTOR = 4; - -const int MACH_MSG_DESCRIPTOR_MAX = 4; - -const int MACH_MSG_TRAILER_FORMAT_0 = 0; - -const int MACH_MSG_FILTER_POLICY_ALLOW = 0; - -const int MACH_MSG_TRAILER_MINIMUM_SIZE = 8; - -const int MAX_TRAILER_SIZE = 68; - -const int MACH_MSG_TRAILER_FORMAT_0_SIZE = 20; - -const int MACH_MSG_SIZE_MAX = 4294967295; - -const int MACH_MSG_SIZE_RELIABLE = 262144; - -const int MACH_MSGH_KIND_NORMAL = 0; - -const int MACH_MSGH_KIND_NOTIFICATION = 1; - -const int MACH_MSG_TYPE_PORT_NONE = 0; - -const int MACH_MSG_TYPE_PORT_NAME = 15; - -const int MACH_MSG_TYPE_PORT_RECEIVE = 16; - -const int MACH_MSG_TYPE_PORT_SEND = 17; - -const int MACH_MSG_TYPE_PORT_SEND_ONCE = 18; - -const int MACH_MSG_TYPE_LAST = 22; - -const int MACH_MSG_TYPE_POLYMORPHIC = 4294967295; - -const int MACH_MSG_OPTION_NONE = 0; - -const int MACH_SEND_MSG = 1; - -const int MACH_RCV_MSG = 2; - -const int MACH_RCV_LARGE = 4; - -const int MACH_RCV_LARGE_IDENTITY = 8; - -const int MACH_SEND_TIMEOUT = 16; - -const int MACH_SEND_OVERRIDE = 32; - -const int MACH_SEND_INTERRUPT = 64; - -const int MACH_SEND_NOTIFY = 128; - -const int MACH_SEND_ALWAYS = 65536; - -const int MACH_SEND_FILTER_NONFATAL = 65536; - -const int MACH_SEND_TRAILER = 131072; - -const int MACH_SEND_NOIMPORTANCE = 262144; - -const int MACH_SEND_NODENAP = 262144; - -const int MACH_SEND_IMPORTANCE = 524288; - -const int MACH_SEND_SYNC_OVERRIDE = 1048576; - -const int MACH_SEND_PROPAGATE_QOS = 2097152; - -const int MACH_SEND_SYNC_USE_THRPRI = 2097152; - -const int MACH_SEND_KERNEL = 4194304; - -const int MACH_SEND_SYNC_BOOTSTRAP_CHECKIN = 8388608; - -const int MACH_RCV_TIMEOUT = 256; - -const int MACH_RCV_NOTIFY = 0; - -const int MACH_RCV_INTERRUPT = 1024; - -const int MACH_RCV_VOUCHER = 2048; - -const int MACH_RCV_OVERWRITE = 0; - -const int MACH_RCV_GUARDED_DESC = 4096; - -const int MACH_RCV_SYNC_WAIT = 16384; - -const int MACH_RCV_SYNC_PEEK = 32768; - -const int MACH_MSG_STRICT_REPLY = 512; - -const int MACH_RCV_TRAILER_NULL = 0; - -const int MACH_RCV_TRAILER_SEQNO = 1; - -const int MACH_RCV_TRAILER_SENDER = 2; - -const int MACH_RCV_TRAILER_AUDIT = 3; - -const int MACH_RCV_TRAILER_CTX = 4; - -const int MACH_RCV_TRAILER_AV = 7; - -const int MACH_RCV_TRAILER_LABELS = 8; - -const int MACH_RCV_TRAILER_MASK = 251658240; - -const int MACH_MSG_SUCCESS = 0; - -const int MACH_MSG_MASK = 15872; - -const int MACH_MSG_IPC_SPACE = 8192; - -const int MACH_MSG_VM_SPACE = 4096; - -const int MACH_MSG_IPC_KERNEL = 2048; - -const int MACH_MSG_VM_KERNEL = 1024; - -const int MACH_SEND_IN_PROGRESS = 268435457; - -const int MACH_SEND_INVALID_DATA = 268435458; - -const int MACH_SEND_INVALID_DEST = 268435459; - -const int MACH_SEND_TIMED_OUT = 268435460; - -const int MACH_SEND_INVALID_VOUCHER = 268435461; - -const int MACH_SEND_INTERRUPTED = 268435463; - -const int MACH_SEND_MSG_TOO_SMALL = 268435464; - -const int MACH_SEND_INVALID_REPLY = 268435465; - -const int MACH_SEND_INVALID_RIGHT = 268435466; - -const int MACH_SEND_INVALID_NOTIFY = 268435467; - -const int MACH_SEND_INVALID_MEMORY = 268435468; - -const int MACH_SEND_NO_BUFFER = 268435469; - -const int MACH_SEND_TOO_LARGE = 268435470; - -const int MACH_SEND_INVALID_TYPE = 268435471; - -const int MACH_SEND_INVALID_HEADER = 268435472; - -const int MACH_SEND_INVALID_TRAILER = 268435473; - -const int MACH_SEND_INVALID_CONTEXT = 268435474; + /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking + /// listeners will be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsBlocking( + objc.ObjCProtocolBuilder builder, { + void Function(NSURLSession, objc.NSError?)? + URLSession_didBecomeInvalidWithError_, + void Function(NSURLSession, NSURLSessionTask)? URLSession_didCreateTask_, + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? + URLSession_task_didCompleteWithError_, + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? + URLSession_task_didFinishCollectingMetrics_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + )? + URLSession_task_didReceiveChallenge_completionHandler_, + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? + URLSession_task_didReceiveInformationalResponse_, + void Function(NSURLSession, NSURLSessionTask, int, int, int)? + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession, NSURLSessionWebSocketTask, int, objc.NSData?)? + URLSession_webSocketTask_didCloseWithCode_reason_, + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)? + URLSession_webSocketTask_didOpenWithProtocol_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + bool $keepIsolateAlive = true, + }) { + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsBlocking( + builder, + URLSession_task_didCompleteWithError_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( + builder, + URLSession_task_didFinishCollectingMetrics_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( + builder, + URLSession_task_didReceiveInformationalResponse_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStream_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( + builder, + URLSession_taskIsWaitingForConnectivity_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didCloseWithCode_reason_.implementAsBlocking( + builder, + URLSession_webSocketTask_didCloseWithCode_reason_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSession_webSocketTask_didOpenWithProtocol_.implementAsBlocking( + builder, + URLSession_webSocketTask_didOpenWithProtocol_, + ); + NSURLSessionWebSocketDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + } -const int MACH_SEND_INVALID_OPTIONS = 268435475; + /// The last message a session receives. A session will only become + /// invalid because of a systemic error or when it has been + /// explicitly invalidated, in which case the error parameter will be nil. + static final URLSession_didBecomeInvalidWithError_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, objc.NSError?) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_didBecomeInvalidWithError_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_didBecomeInvalidWithError_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSError.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + objc.NSError? arg2, + ) => func(arg1, arg2), + ), + ); -const int MACH_SEND_INVALID_RT_OOL_SIZE = 268435477; + /// Notification that a task has been created. This method is the first message + /// a task sends, providing a place to configure the task before it is resumed. + /// + /// This delegate callback is *NOT* dispatched to the delegate queue. It is + /// invoked synchronously before the task creation method returns. + static final URLSession_didCreateTask_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_didCreateTask_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_didCreateTask_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + ); -const int MACH_SEND_NO_GRANT_DEST = 268435478; + /// If implemented, when a connection level authentication challenge + /// has occurred, this delegate will be given the opportunity to + /// provide authentication credentials to the underlying + /// connection. Some types of authentication will apply to more than + /// one request on a given connection to a server (SSL Server Trust + /// challenges). If this delegate message is not implemented, the + /// behavior will be to use the default handling, which may involve user + /// interaction. + static final URLSession_didReceiveChallenge_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), + ); -const int MACH_SEND_MSG_FILTERED = 268435479; + /// Sent as the last message related to a specific task. Error may be + /// nil, which implies that no error occurred and this task is complete. + static final URLSession_task_didCompleteWithError_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, objc.NSError?) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didCompleteWithError_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didCompleteWithError_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), + (void Function(NSURLSession, NSURLSessionTask, objc.NSError?) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSError.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) => func(arg1, arg2, arg3), + ), + ); -const int MACH_SEND_AUX_TOO_SMALL = 268435480; + /// Sent when complete statistics information has been collected for the task. + static final URLSession_task_didFinishCollectingMetrics_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didFinishCollectingMetrics_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didFinishCollectingMetrics_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLSessionTaskMetrics.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLSessionTaskMetrics arg3, + ) => func(arg1, arg2, arg3), + ), + ); -const int MACH_SEND_AUX_TOO_LARGE = 268435481; + /// The task has received a request specific authentication challenge. + /// If this delegate is not implemented, the session specific authentication challenge + /// will *NOT* be called and the behavior will be the same as using the default handling + /// disposition. + static final URLSession_task_didReceiveChallenge_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock + arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ); -const int MACH_RCV_IN_PROGRESS = 268451841; + /// Sent for each informational response received except 101 switching protocols. + static final URLSession_task_didReceiveInformationalResponse_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didReceiveInformationalResponse_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didReceiveInformationalResponse_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) => func(arg1, arg2, arg3), + ), + ); -const int MACH_RCV_INVALID_NAME = 268451842; + /// Sent periodically to notify the delegate of upload progress. This + /// information is also available as properties of the task. + static final URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, int, int, int) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_h68abb) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + (void Function(NSURLSession, NSURLSessionTask, int, int, int) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_Int64_Int64.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + int arg4, + int arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ); -const int MACH_RCV_TIMED_OUT = 268451843; + /// Sent if a task requires a new, unopened body stream. This may be + /// necessary when authentication has failed for any request that + /// involves a body stream. + static final URLSession_task_needNewBodyStream_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_needNewBodyStream_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_needNewBodyStream_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), + ); -const int MACH_RCV_TOO_LARGE = 268451844; + /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be + /// necessary when resuming a failed upload task. + /// + /// - Parameter session: The session containing the task that needs a new body stream from the given offset. + /// - Parameter task: The task that needs a new body stream. + /// - Parameter offset: The starting offset required for the body stream. + /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. + static final URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_jyim80) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_Int64_ffiVoidNSInputStream.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + int arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ); -const int MACH_RCV_INTERRUPTED = 268451845; + /// Sent when the system is ready to begin work for a task with a delayed start + /// time set (using the earliestBeginDate property). The completionHandler must + /// be invoked in order for loading to proceed. The disposition provided to the + /// completion handler continues the load with the original request provided to + /// the task, replaces the request with the specified task, or cancels the task. + /// If this delegate is not implemented, loading will proceed with the original + /// request. + /// + /// Recommendation: only implement this delegate if tasks that have the + /// earliestBeginDate property set may become stale and require alteration prior + /// to starting the network load. + /// + /// If a new request is specified, the allowsExpensiveNetworkAccess, + /// allowsConstrainedNetworkAccess, and allowsCellularAccess properties + /// from the new request will not be used; the properties from the + /// original request will continue to be used. + /// + /// Canceling the task is equivalent to calling the task's cancel method; the + /// URLSession:task:didCompleteWithError: task delegate will be called with error + /// NSURLErrorCancelled. + static final URLSession_task_willBeginDelayedRequest_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSURLRequest_ffiVoidNSURLSessionDelayedRequestDispositionNSURLRequest.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLRequest arg3, + objc.ObjCBlock arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ); -const int MACH_RCV_PORT_CHANGED = 268451846; + /// An HTTP request is attempting to perform a redirection to a different + /// URL. You must invoke the completion routine to allow the + /// redirection, allow the redirection with a modified request, or + /// pass nil to the completionHandler to cause the body of the redirection + /// response to be delivered as the payload of this request. The default + /// is to follow redirections. + /// + /// For tasks in background sessions, redirections will always be followed and this method will not be called. + static final URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_l2g8ke) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_NSHTTPURLResponse_NSURLRequest_ffiVoidNSURLRequest.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) => func(arg1, arg2, arg3, arg4, arg5), + ), + ); -const int MACH_RCV_INVALID_NOTIFY = 268451847; + /// Sent when a task cannot start the network loading process because the current + /// network connectivity is not available or sufficient for the task's request. + /// + /// This delegate will be called at most one time per task, and is only called if + /// the waitsForConnectivity property in the NSURLSessionConfiguration has been + /// set to YES. + /// + /// This delegate callback will never be called for background sessions, because + /// the waitForConnectivity property is ignored by those sessions. + static final URLSession_taskIsWaitingForConnectivity_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_taskIsWaitingForConnectivity_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_taskIsWaitingForConnectivity_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + (void Function(NSURLSession, NSURLSessionTask) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + ) => func(arg1, arg2), + ), + ); -const int MACH_RCV_INVALID_DATA = 268451848; + /// Indicates that the WebSocket has received a close frame from the server endpoint. + /// The close code and the close reason may be provided by the delegate if the server elects to send + /// this information in the close frame + static final URLSession_webSocketTask_didCloseWithCode_reason_ = + objc.ObjCProtocolListenableMethod< + void Function( + NSURLSession, + NSURLSessionWebSocketTask, + int, + objc.NSData?, + ) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_webSocketTask_didCloseWithCode_reason_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1lx650f) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_webSocketTask_didCloseWithCode_reason_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionWebSocketTask, + int, + objc.NSData?, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionWebSocketTask arg2, + int arg3, + objc.NSData? arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionWebSocketTask, + int, + objc.NSData?, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionWebSocketTask arg2, + int arg3, + objc.NSData? arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ( + void Function( + NSURLSession, + NSURLSessionWebSocketTask, + int, + objc.NSData?, + ) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionWebSocketTask arg2, + int arg3, + objc.NSData? arg4, + ) => func(arg1, arg2, arg3, arg4), + ), + ); -const int MACH_RCV_PORT_DIED = 268451849; + /// Indicates that the WebSocket handshake was successful and the connection has been upgraded to webSockets. + /// It will also provide the protocol that is picked in the handshake. If the handshake fails, this delegate will not be invoked. + static final URLSession_webSocketTask_didOpenWithProtocol_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?) + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_webSocketTask_didOpenWithProtocol_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_webSocketTask_didOpenWithProtocol_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString.fromFunction( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionWebSocketTask arg2, + objc.NSString? arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionWebSocketTask arg2, + objc.NSString? arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function(NSURLSession, NSURLSessionWebSocketTask, objc.NSString?) + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionWebSocketTask arg2, + objc.NSString? arg3, + ) => func(arg1, arg2, arg3), + ), + ); -const int MACH_RCV_IN_SET = 268451850; + /// If an application has received an + /// -application:handleEventsForBackgroundURLSession:completionHandler: + /// message, the session delegate will receive this message to indicate + /// that all messages previously enqueued for this session have been + /// delivered. At this time it is safe to invoke the previously stored + /// completion handler, or to begin any internal updates that will + /// result in invoking the completion handler. + static final URLSessionDidFinishEventsForBackgroundURLSession_ = + objc.ObjCProtocolListenableMethod( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_NativeCupertinoHttp_protocolTrampoline_18v1jvf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.fromFunction( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.listener( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), + (void Function(NSURLSession) func) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession.blocking( + (ffi.Pointer _, NSURLSession arg1) => func(arg1), + ), + ); +} -const int MACH_RCV_HEADER_ERROR = 268451851; +/// WARNING: NSLocking is a stub. To generate bindings for this class, include +/// NSLocking in your config's objc-protocols list. +/// +/// NSLocking +extension type NSLocking._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol { + /// Constructs a [NSLocking] that points to the same underlying object as [other]. + NSLocking.as(objc.ObjCObject other) : object$ = other; -const int MACH_RCV_BODY_ERROR = 268451852; + /// Constructs a [NSLocking] that wraps the given raw object pointer. + NSLocking.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); +} -const int MACH_RCV_INVALID_TYPE = 268451853; +late final _class_NSCondition = objc.getClass("NSCondition"); +late final _sel_wait = objc.registerName("wait"); +late final _sel_waitUntilDate_ = objc.registerName("waitUntilDate:"); +late final _sel_signal = objc.registerName("signal"); +late final _sel_broadcast = objc.registerName("broadcast"); +late final _sel_lock = objc.registerName("lock"); -const int MACH_RCV_SCATTER_SMALL = 268451854; +/// Construction methods for `objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock)> fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock)>( + pointer, + retain: retain, + release: release, + ); -const int MACH_RCV_INVALID_TRAILER = 268451855; + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock)> + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction arg0)> + > + ptr, + ) => objc.ObjCBlock)>( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); -const int MACH_RCV_IN_PROGRESS_TIMED = 268451857; + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock)> fromFunction( + void Function(ffi.Pointer) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock)>( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn(arg0), + keepIsolateAlive, + ), + retain: false, + release: true, + ); -const int MACH_RCV_INVALID_REPLY = 268451858; + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock)> listener( + void Function(ffi.Pointer) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn(arg0), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapListenerBlock_ovsamd(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock)>( + wrapper, + retain: false, + release: true, + ); + } -const int MACH_RCV_INVALID_ARGUMENTS = 268451859; + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock)> blocking( + void Function(ffi.Pointer) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn(arg0), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn(arg0), + keepIsolateAlive, + ); + final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_ovsamd( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock)>( + wrapper, + retain: false, + release: true, + ); + } -const int DISPATCH_MACH_SEND_DEAD = 1; + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) { + (objc.getBlockClosure(block) as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); + } -const int DISPATCH_MEMORYPRESSURE_NORMAL = 1; + static ffi.NativeCallable< + ffi.Void Function(ffi.Pointer, ffi.Pointer) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer))( + arg0, + ); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } + } -const int DISPATCH_MEMORYPRESSURE_WARN = 2; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast arg0)>>() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => (objc.getBlockClosure(block) as void Function(ffi.Pointer))( + arg0, + ); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} -const int DISPATCH_MEMORYPRESSURE_CRITICAL = 4; +/// Call operator for `objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid$CallExtension + on objc.ObjCBlock)> { + void call(ffi.Pointer arg0) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< + void Function(ffi.Pointer, ffi.Pointer) + >()(ref.pointer, arg0); +} -const int DISPATCH_PROC_EXIT = 2147483648; +late final _sel_unlock = objc.registerName("unlock"); -const int DISPATCH_PROC_FORK = 1073741824; +/// NSCondition +extension type NSCondition._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject, NSLocking { + /// Constructs a [NSCondition] that points to the same underlying object as [other]. + NSCondition.as(objc.ObjCObject other) : object$ = other { + objc.checkOsVersionInternal( + 'NSCondition', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + assert(isA(object$)); + } -const int DISPATCH_PROC_EXEC = 536870912; + /// Constructs a [NSCondition] that wraps the given raw object pointer. + NSCondition.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSCondition', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + assert(isA(object$)); + } -const int DISPATCH_PROC_SIGNAL = 134217728; + /// Returns whether [obj] is an instance of [NSCondition]. + static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSCondition, + ); -const int DISPATCH_VNODE_DELETE = 1; + /// alloc + static NSCondition alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSCondition, _sel_alloc); + return NSCondition.fromPointer($ret, retain: false, release: true); + } -const int DISPATCH_VNODE_WRITE = 2; + /// allocWithZone: + static NSCondition allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSCondition, + _sel_allocWithZone_, + zone, + ); + return NSCondition.fromPointer($ret, retain: false, release: true); + } -const int DISPATCH_VNODE_EXTEND = 4; + /// new + static NSCondition new$() { + final $ret = _objc_msgSend_151sglz(_class_NSCondition, _sel_new); + return NSCondition.fromPointer($ret, retain: false, release: true); + } -const int DISPATCH_VNODE_ATTRIB = 8; + /// Returns a new instance of NSCondition constructed with the default `new` method. + NSCondition() : this.as(new$().object$); +} -const int DISPATCH_VNODE_LINK = 16; +extension NSCondition$Methods on NSCondition { + /// broadcast + void broadcast() { + objc.checkOsVersionInternal( + 'NSCondition.broadcast', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_broadcast); + } -const int DISPATCH_VNODE_RENAME = 32; + /// init + NSCondition init() { + objc.checkOsVersionInternal( + 'NSCondition.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return NSCondition.fromPointer($ret, retain: false, release: true); + } -const int DISPATCH_VNODE_REVOKE = 64; + /// lock + void lock() { + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_lock); + } -const int DISPATCH_VNODE_FUNLOCK = 256; + /// name + objc.NSString? get name { + objc.checkOsVersionInternal( + 'NSCondition.name', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_name); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); + } -const int DISPATCH_TIMER_STRICT = 1; + /// setName: + set name(objc.NSString? value) { + objc.checkOsVersionInternal( + 'NSCondition.setName:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_setName_, + value?.ref.pointer ?? ffi.nullptr, + ); + } -const int DISPATCH_ONCE_INLINE_FASTPATH = 1; + /// signal + void signal() { + objc.checkOsVersionInternal( + 'NSCondition.signal', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_signal); + } -const int DISPATCH_DATA_DESTRUCTOR_DEFAULT = 0; + /// unlock + void unlock() { + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_unlock); + } -const int DISPATCH_IO_STREAM = 0; + /// wait + void wait() { + objc.checkOsVersionInternal( + 'NSCondition.wait', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_wait); + } -const int DISPATCH_IO_RANDOM = 1; + /// waitUntilDate: + bool waitUntilDate(objc.NSDate limit) { + objc.checkOsVersionInternal( + 'NSCondition.waitUntilDate:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + return _objc_msgSend_19nvye5( + object$.ref.pointer, + _sel_waitUntilDate_, + limit.ref.pointer, + ); + } +} -const int DISPATCH_IO_STOP = 1; +enum NSOperationQueuePriority { + NSOperationQueuePriorityVeryLow(-8), + NSOperationQueuePriorityLow(-4), + NSOperationQueuePriorityNormal(0), + NSOperationQueuePriorityHigh(4), + NSOperationQueuePriorityVeryHigh(8); -const int DISPATCH_IO_STRICT_INTERVAL = 1; + final int value; + const NSOperationQueuePriority(this.value); -const int NSURLResponseUnknownLength = -1; + static NSOperationQueuePriority fromValue(int value) => switch (value) { + -8 => NSOperationQueuePriorityVeryLow, + -4 => NSOperationQueuePriorityLow, + 0 => NSOperationQueuePriorityNormal, + 4 => NSOperationQueuePriorityHigh, + 8 => NSOperationQueuePriorityVeryHigh, + _ => throw ArgumentError( + 'Unknown value for NSOperationQueuePriority: $value', + ), + }; +}