diff --git a/pkgs/cupertino_http/CHANGELOG.md b/pkgs/cupertino_http/CHANGELOG.md index ebfef8cf57..31602d03a6 100644 --- a/pkgs/cupertino_http/CHANGELOG.md +++ b/pkgs/cupertino_http/CHANGELOG.md @@ -1,3 +1,9 @@ +## 3.1.0-wip + +* Switch to `package:objective_c` `9.5.0` and `package:ffigen` `21.0.0`, fixing + a [bug](https://github.com/dart-lang/http/issues/1894) where a request that + was still in flight when its isolate shut down could crash the process. + ## 3.0.2 * Fix a [bug](https://github.com/dart-lang/http/issues/1929) where code diff --git a/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart b/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart index 149f58ef51..28c3f7ec3c 100644 --- a/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart +++ b/pkgs/cupertino_http/lib/src/native_cupertino_bindings.dart @@ -8,39 +8,59 @@ // AUTO GENERATED FILE, DO NOT EDIT. // // Generated by `package:ffigen`. -// ignore_for_file: type=lint, unused_import +// ignore_for_file: type=lint, unused_import, deprecated_member_use_from_same_package import 'dart:ffi' as ffi; import 'package:objective_c/objective_c.dart' as objc; import 'package:ffi/ffi.dart' as pkg_ffi; +const _$objcVersionCheck = objc.ObjCVersionCheck(9, 5); @ffi.Native< - ffi.Bool Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) >() -external bool _NativeCupertinoHttp_protocolTrampoline_e3qsqz( +external void _1tf3our_protocolTrampoline_18v1jvf( ffi.Pointer target, ffi.Pointer arg0, + ffi.Pointer arg1, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_18v1jvf( - ffi.Pointer block, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer, + ) +>() +external void _1tf3our_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, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, +>() +external void _1tf3our_protocolTrampoline_1tz5yf( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ); @ffi.Native< @@ -48,623 +68,659 @@ _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( ffi.Pointer, ffi.Pointer, ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) >() -external void _NativeCupertinoHttp_protocolTrampoline_18v1jvf( +external void _1tf3our_protocolTrampoline_bklti2( ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, ); @ffi.Native< - instancetype Function( + ffi.Void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer, + ffi.Pointer, ) >() -external instancetype _NativeCupertinoHttp_protocolTrampoline_xr62hr( +external void _1tf3our_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_xtuoz7( - ffi.Pointer block, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) +>() +external void _1tf3our_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.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, + ) +>() +external void _1tf3our_protocolTrampoline_jyim80( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer arg4, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ffi.Pointer, - ffi.Pointer, ) ->(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - ffi.Pointer block, - ffi.Pointer listnerBlock, - ffi.Pointer context, +>() +external void _1tf3our_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.Void Function( ffi.Pointer, ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Int64, ) >() -external ffi.Pointer -_NativeCupertinoHttp_protocolTrampoline_1mbt9g9( +external void _1tf3our_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_1pl9qdv( - ffi.Pointer block, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _1tf3our_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, - ffi.Pointer, + ffi.Int64, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1pl9qdv( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapBlockingBlock_16sve1d( + int port, ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, + ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_r8gdi7( - ffi.Pointer block, +external ffi.Pointer _1tf3our_wrapBlockingBlock_18v1jvf( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapBlockingBlock_1lx650f( + int port, ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, + ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_pfv6jd( - ffi.Pointer block, +external ffi.Pointer _1tf3our_wrapBlockingBlock_1otpo83( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapBlockingBlock_1pl9qdv( + int port, ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, + ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_16sve1d( - ffi.Pointer block, +external ffi.Pointer _1tf3our_wrapBlockingBlock_1tz5yf( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_16sve1d( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapBlockingBlock_bklti2( + int port, ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, + ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_xx612k( - ffi.Pointer block, +external ffi.Pointer _1tf3our_wrapBlockingBlock_fjrv01( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_xx612k( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapBlockingBlock_h68abb( + int port, ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, + ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1otpo83( - ffi.Pointer block, +external ffi.Pointer _1tf3our_wrapBlockingBlock_jyim80( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1otpo83( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapBlockingBlock_l2g8ke( + int port, ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_xx612k( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer arg4, +>(isLeaf: true) +external ffi.Pointer _1tf3our_wrapBlockingBlock_ly2579( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, + ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_1tz5yf( - ffi.Pointer block, +external ffi.Pointer _1tf3our_wrapBlockingBlock_n8yd09( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapBlockingBlock_pfv6jd( + int port, ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) ->() -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, +external ffi.Pointer _1tf3our_wrapBlockingBlock_r8gdi7( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_fjrv01( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapBlockingBlock_xtuoz7( + int port, ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer args) + > + >, ) ->() -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, +external ffi.Pointer _1tf3our_wrapBlockingBlock_xx612k( + int port, + ffi.Pointer context, + ffi.Pointer< + ffi.NativeFunction args)> + > + directInvoke, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_l2g8ke( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapListenerBlock_16sve1d( + int port, ffi.Pointer context, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer Function( + ffi.Int64, + 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, +external ffi.Pointer _1tf3our_wrapListenerBlock_18v1jvf( + int port, + ffi.Pointer context, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_n8yd09( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapListenerBlock_1lx650f( + int port, ffi.Pointer context, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_bklti2( - ffi.Pointer block, +external ffi.Pointer _1tf3our_wrapListenerBlock_1otpo83( + int port, + ffi.Pointer context, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_bklti2( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapListenerBlock_1pl9qdv( + int port, ffi.Pointer context, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer Function( + ffi.Int64, + 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, +external ffi.Pointer _1tf3our_wrapListenerBlock_1tz5yf( + int port, + ffi.Pointer context, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_jyim80( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapListenerBlock_bklti2( + int port, ffi.Pointer context, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer Function( ffi.Int64, - ffi.Pointer, + 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, +external ffi.Pointer _1tf3our_wrapListenerBlock_fjrv01( + int port, + ffi.Pointer context, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_h68abb( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapListenerBlock_h68abb( + int port, ffi.Pointer context, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Int64, + ffi.Pointer Function( ffi.Int64, + ffi.Pointer, ) ->() -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, +external ffi.Pointer _1tf3our_wrapListenerBlock_jyim80( + int port, + ffi.Pointer context, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_ly2579( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapListenerBlock_l2g8ke( + int port, ffi.Pointer context, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, + ffi.Pointer Function( ffi.Int64, + ffi.Pointer, ) ->() -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, +external ffi.Pointer _1tf3our_wrapListenerBlock_ly2579( + int port, + ffi.Pointer context, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_1lx650f( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapListenerBlock_n8yd09( + int port, ffi.Pointer context, ); @ffi.Native< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ffi.Pointer, + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, ) ->() -external void _NativeCupertinoHttp_protocolTrampoline_1lx650f( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, +>(isLeaf: true) +external ffi.Pointer _1tf3our_wrapListenerBlock_pfv6jd( + int port, + ffi.Pointer context, ); @ffi.Native< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapListenerBlock_ovsamd( - ffi.Pointer block, +external ffi.Pointer _1tf3our_wrapListenerBlock_r8gdi7( + int port, + ffi.Pointer context, ); @ffi.Native< ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, + ffi.Int64, ffi.Pointer, ) >(isLeaf: true) -external ffi.Pointer -_NativeCupertinoHttp_wrapBlockingBlock_ovsamd( - ffi.Pointer block, - ffi.Pointer listnerBlock, +external ffi.Pointer _1tf3our_wrapListenerBlock_xtuoz7( + int port, ffi.Pointer context, ); @ffi.Native< - ffi.Void Function(ffi.Pointer, ffi.Pointer) ->() -external void _NativeCupertinoHttp_protocolTrampoline_ovsamd( - ffi.Pointer target, - ffi.Pointer arg0, + ffi.Pointer Function( + ffi.Int64, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer _1tf3our_wrapListenerBlock_xx612k( + int port, + ffi.Pointer context, ); -/// ! -/// @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. /// @@ -703,1168 +759,612 @@ extension type NSCachedURLResponse._(objc.ObjCObject object$) } } -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, - ) - >(); +/// 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$)); + } -/// 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, { + /// Constructs a [NSCondition] that wraps the given raw object pointer. + NSCondition.fromPointer( + ffi.Pointer other, { 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, - ); + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSCondition', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + assert(isA(object$)); + } - /// 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, - ); + /// Returns whether [obj] is an instance of [NSCondition]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSCondition, + ); - 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(); -} + /// alloc + static NSCondition alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSCondition, _sel_alloc); + return NSCondition.fromPointer($ret, retain: false, release: true); + } -/// 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); -} + /// 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); + } -/// ! -/// @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); + /// new + static NSCondition new$() { + final $ret = _objc_msgSend_151sglz(_class_NSCondition, _sel_new); + return NSCondition.fromPointer($ret, retain: false, release: true); + } - static const NSURLRequestReloadIgnoringCacheData = - NSURLRequestReloadIgnoringLocalCacheData; + /// Returns a new instance of NSCondition constructed with the default `new` method. + NSCondition() : this.as(new$().object$); +} - final int value; - const NSURLRequestCachePolicy(this.value); +extension NSCondition$Methods on NSCondition { + /// broadcast + void broadcast() { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSCondition.broadcast', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_broadcast); + } - 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(); + /// init + NSCondition init() { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSCondition.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref.retainAndReturnPointer(), + _sel_init, + ); + return NSCondition.fromPointer($ret, retain: false, release: true); } -} -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"); + /// lock + void lock() { + final _$$ref = object$.ref; + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_lock); + } -/// ! -/// @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), + /// name + objc.NSString? get name { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSCondition.name', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_name); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); + } - /// Voice over IP control traffic - NSURLNetworkServiceTypeVoIP(1), + /// setName: + set name(objc.NSString? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSCondition.setName:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setName_, + _$$ref$1?.pointer ?? ffi.nullptr, + ); + } - /// Video traffic - NSURLNetworkServiceTypeVideo(2), + /// signal + void signal() { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSCondition.signal', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_signal); + } - /// Background traffic - NSURLNetworkServiceTypeBackground(3), + /// unlock + void unlock() { + final _$$ref = object$.ref; + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_unlock); + } - /// Voice data - NSURLNetworkServiceTypeVoice(4), + /// wait + void wait() { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSCondition.wait', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_wait); + } - /// Responsive data - NSURLNetworkServiceTypeResponsiveData(6), + /// waitUntilDate: + bool waitUntilDate(objc.NSDate limit) { + final _$$ref = object$.ref; + final _$$ref$1 = limit.ref; + objc.checkOsVersionInternal( + 'NSCondition.waitUntilDate:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + return _objc_msgSend_19nvye5( + _$$ref.pointer, + _sel_waitUntilDate_, + _$$ref$1.pointer, + ); + } +} - /// Multimedia Audio/Video Streaming - NSURLNetworkServiceTypeAVStreaming(8), +/// NSDeprecated +extension NSDeprecated on NSOperationQueue { + /// operationCount + @Deprecated('Deprecated') + int get operationCount { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.operationCount', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + return _objc_msgSend_xw2lbc(_$$ref.pointer, _sel_operationCount); + } - /// Responsive Multimedia Audio/Video - NSURLNetworkServiceTypeResponsiveAV(9), + /// These two functions are inherently a race condition and should be avoided if possible + @Deprecated( + 'access to operations is inherently a race condition, it should not be used. For barrier style behaviors please use addBarrierBlock: instead', + ) + objc.NSArray get operations { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.operations', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_operations); + return objc.NSArray.fromPointer($ret, retain: true, release: true); + } +} - /// Call Signaling - NSURLNetworkServiceTypeCallSignaling(11); +enum NSHTTPCookieAcceptPolicy { + NSHTTPCookieAcceptPolicyAlways(0), + NSHTTPCookieAcceptPolicyNever(1), + NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain(2); final int value; - const NSURLRequestNetworkServiceType(this.value); + const NSHTTPCookieAcceptPolicy(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, + static NSHTTPCookieAcceptPolicy fromValue(int value) => switch (value) { + 0 => NSHTTPCookieAcceptPolicyAlways, + 1 => NSHTTPCookieAcceptPolicyNever, + 2 => NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, _ => throw ArgumentError( - 'Unknown value for NSURLRequestNetworkServiceType: $value', + 'Unknown value for NSHTTPCookieAcceptPolicy: $value', ), }; } -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"); - -/// ! -/// @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. +/// WARNING: NSHTTPCookieStorage is a stub. To generate bindings for this class, include +/// NSHTTPCookieStorage in your config's objc-interfaces list. /// -/// @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< - ffi.UnsignedLong 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:"); +/// 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)), + ); + } -/// 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, { + /// Constructs a [NSHTTPCookieStorage] that wraps the given raw object pointer. + NSHTTPCookieStorage.fromPointer( + ffi.Pointer other, { 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, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSHTTPCookieStorage', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - 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, +/// ! +/// @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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPBody', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( - raw, - rawListener, - objc.objCContext, + final $ret = _objc_msgSend_151sglz(_$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPBodyStream', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, objc.NSCoder) - >(wrapper, retain: false, release: true); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_HTTPBodyStream); + return $ret.address == 0 + ? null + : objc.NSInputStream.fromPointer($ret, retain: true, 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()); + /// ! + /// @abstract Returns the HTTP request method of the receiver. + /// @result the HTTP request method of the receiver. + objc.NSString? get HTTPMethod { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPMethod', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_HTTPMethod); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - 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()); - } + /// ! + /// @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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPShouldHandleCookies', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_HTTPShouldHandleCookies); } - 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(); -} + /// ! + /// @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. + @Deprecated( + 'Only supported in the classic loader, please adopt HTTP/2 and HTTP/3 instead', + ) + bool get HTTPShouldUsePipelining { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLRequest.HTTPShouldUsePipelining', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_HTTPShouldUsePipelining); + } -/// 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); + /// ! + /// @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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLRequest.allHTTPHeaderFields', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$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) { + final _$$ref = object$.ref; + final _$$ref$1 = field.ref; + objc.checkOsVersionInternal( + 'NSURLRequest.valueForHTTPHeaderField:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_valueForHTTPHeaderField_, + _$$ref$1.pointer, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); + } } -late final _sel_initWithCoder_ = objc.registerName("initWithCoder:"); +/// 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$)); + } -/// 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, { + /// Constructs a [NSHTTPURLResponse] that wraps the given raw object pointer. + NSHTTPURLResponse.fromPointer( + ffi.Pointer other, { bool retain = false, bool release = false, - }) => - objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, - objc.NSCoder, - ) - >(pointer, retain: retain, release: release); + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); + } - /// 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, - ); + /// Returns whether [obj] is an instance of [NSHTTPURLResponse]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSHTTPURLResponse, + ); - /// 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, - ); + /// alloc + static NSHTTPURLResponse alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSHTTPURLResponse, _sel_alloc); + return NSHTTPURLResponse.fromPointer($ret, 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", -); + /// 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); + } -/// ! -/// @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 { + /// @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( - 'NSURLRequest.HTTPBody', + 'NSHTTPURLResponse.localizedStringForStatusCode:', 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); + 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 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 { + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.HTTPBodyStream', + 'NSHTTPURLResponse.allHeaderFields', 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); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_allHeaderFields); + return objc.NSDictionary.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 { + /// init + NSHTTPURLResponse init() { + final _$$ref$1 = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.HTTPMethod', + 'NSHTTPURLResponse.init', iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref$1.retainAndReturnPointer(), + _sel_init, + ); + return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); + } + + /// initWithCoder: + NSHTTPURLResponse? initWithCoder(objc.NSCoder coder) { + final _$$ref = object$.ref; + final _$$ref$1 = coder.ref; + final $ret = _objc_msgSend_1sotr3r( + _$$ref.retainAndReturnPointer(), + _sel_initWithCoder_, + _$$ref$1.pointer, ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPMethod); return $ret.address == 0 ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); + : NSHTTPURLResponse.fromPointer($ret, retain: false, 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 { + /// @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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = URL.ref; + final _$$ref$2 = MIMEType?.ref; + final _$$ref$3 = name?.ref; objc.checkOsVersionInternal( - 'NSURLRequest.HTTPShouldHandleCookies', + 'NSHTTPURLResponse.initWithURL:MIMEType:expectedContentLength:textEncodingName:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldHandleCookies, + final $ret = _objc_msgSend_l9ppnx( + _$$ref.retainAndReturnPointer(), + _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_, + _$$ref$1.pointer, + _$$ref$2?.pointer ?? ffi.nullptr, + length, + _$$ref$3?.pointer ?? ffi.nullptr, ); + return NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } /// ! - /// @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 { + /// @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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = url.ref; + final _$$ref$2 = HTTPVersion?.ref; + final _$$ref$3 = headerFields?.ref; objc.checkOsVersionInternal( - 'NSURLRequest.HTTPShouldUsePipelining', - iOS: (false, (4, 0, 0)), + 'NSHTTPURLResponse.initWithURL:statusCode:HTTPVersion:headerFields:', + iOS: (false, (5, 0, 0)), macOS: (false, (10, 7, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldUsePipelining, + final $ret = _objc_msgSend_xw7l5( + _$$ref.retainAndReturnPointer(), + _sel_initWithURL_statusCode_HTTPVersion_headerFields_, + _$$ref$1.pointer, + statusCode, + _$$ref$2?.pointer ?? ffi.nullptr, + _$$ref$3?.pointer ?? ffi.nullptr, ); + return $ret.address == 0 + ? null + : NSHTTPURLResponse.fromPointer($ret, retain: false, release: true); } /// ! - /// @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 { + /// @abstract Returns the HTTP status code of the receiver. + /// @result The HTTP status code of the receiver. + int get statusCode { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.allHTTPHeaderFields', + 'NSHTTPURLResponse.statusCode', 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); + return _objc_msgSend_1hz7y9r(_$$ref.pointer, _sel_statusCode); } /// ! @@ -1877,15 +1377,17 @@ extension NSHTTPURLRequest on NSURLRequest { /// @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) { + final _$$ref = object$.ref; + final _$$ref$1 = field.ref; objc.checkOsVersionInternal( - 'NSURLRequest.valueForHTTPHeaderField:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSHTTPURLResponse.valueForHTTPHeaderField:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, + _$$ref.pointer, _sel_valueForHTTPHeaderField_, - field.ref.pointer, + _$$ref$1.pointer, ); return $ret.address == 0 ? null @@ -1893,382 +1395,778 @@ extension NSHTTPURLRequest on NSURLRequest { } } -/// 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( +/// 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.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, - ); + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); +} - /// alloc - static NSURLRequest alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSURLRequest, _sel_alloc); - return NSURLRequest.fromPointer($ret, retain: false, release: true); +/// ! +/// @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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPBody', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_HTTPBody); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); } - /// allocWithZone: - static NSURLRequest allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLRequest, - _sel_allocWithZone_, - zone, + /// ! + /// @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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPBodyStream', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - return NSURLRequest.fromPointer($ret, retain: false, release: true); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_HTTPBodyStream); + return $ret.address == 0 + ? null + : objc.NSInputStream.fromPointer($ret, retain: true, release: true); } - /// new - static NSURLRequest new$() { - final $ret = _objc_msgSend_151sglz(_class_NSURLRequest, _sel_new); - return NSURLRequest.fromPointer($ret, retain: false, release: true); + /// ! + /// @abstract Sets the HTTP request method of the receiver. + objc.NSString get HTTPMethod { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPMethod', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_HTTPMethod); + return objc.NSString.fromPointer($ret, retain: true, 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) { + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.requestWithURL:', + 'NSMutableURLRequest.HTTPShouldHandleCookies', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - final $ret = _objc_msgSend_1sotr3r( - _class_NSURLRequest, - _sel_requestWithURL_, - URL.ref.pointer, + return _objc_msgSend_91o635(_$$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.). + @Deprecated( + 'Only supported in the classic loader, please adopt HTTP/2 and HTTP/3 instead', + ) + bool get HTTPShouldUsePipelining { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.HTTPShouldUsePipelining', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), ); - return NSURLRequest.fromPointer($ret, retain: true, release: true); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_HTTPShouldUsePipelining); } /// ! - /// @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, + /// @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, }) { + final _$$ref = object$.ref; + final _$$ref$1 = value.ref; + final _$$ref$2 = forHTTPHeaderField.ref; objc.checkOsVersionInternal( - 'NSURLRequest.requestWithURL:cachePolicy:timeoutInterval:', + 'NSMutableURLRequest.addValue:forHTTPHeaderField:', 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, + _objc_msgSend_pfv6jd( + _$$ref.pointer, + _sel_addValue_forHTTPHeaderField_, + _$$ref$1.pointer, + _$$ref$2.pointer, ); - 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 { + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.URL', + 'NSMutableURLRequest.allHTTPHeaderFields', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URL); + final $ret = _objc_msgSend_151sglz( + _$$ref.pointer, + _sel_allHTTPHeaderFields, + ); return $ret.address == 0 ? null - : objc.NSURL.fromPointer($ret, retain: true, release: true); + : objc.NSDictionary.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 { + /// @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) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSURLRequest.allowsCellularAccess', - iOS: (false, (6, 0, 0)), - macOS: (false, (10, 8, 0)), + 'NSMutableURLRequest.setAllHTTPHeaderFields:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setAllHTTPHeaderFields_, + _$$ref$1?.pointer ?? ffi.nullptr, ); - 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 { + /// @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) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSURLRequest.allowsConstrainedNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), + 'NSMutableURLRequest.setHTTPBody:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsConstrainedNetworkAccess, + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setHTTPBody_, + _$$ref$1?.pointer ?? ffi.nullptr, ); } /// ! - /// @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 { + /// @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) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSURLRequest.allowsExpensiveNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), + 'NSMutableURLRequest.setHTTPBodyStream:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsExpensiveNetworkAccess, + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setHTTPBodyStream_, + _$$ref$1?.pointer ?? ffi.nullptr, ); } /// ! - /// @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 { + /// @abstract Sets the HTTP request method of the receiver. + set HTTPMethod(objc.NSString value) { + final _$$ref = object$.ref; + final _$$ref$1 = value.ref; objc.checkOsVersionInternal( - 'NSURLRequest.allowsPersistentDNS', - iOS: (false, (18, 0, 0)), - macOS: (false, (15, 0, 0)), + 'NSMutableURLRequest.setHTTPMethod:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsPersistentDNS); + _objc_msgSend_xtuoz7(_$$ref.pointer, _sel_setHTTPMethod_, _$$ref$1.pointer); } /// ! - /// @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 { + /// @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) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.assumesHTTP3Capable', - iOS: (false, (14, 5, 0)), - macOS: (false, (11, 3, 0)), + 'NSMutableURLRequest.setHTTPShouldHandleCookies:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setHTTPShouldHandleCookies_, + value, ); - 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 { + /// @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.). + @Deprecated( + 'Only supported in the classic loader, please adopt HTTP/2 and HTTP/3 instead', + ) + set HTTPShouldUsePipelining(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.attribution', - iOS: (false, (15, 0, 0)), - macOS: (false, (12, 0, 0)), + 'NSMutableURLRequest.setHTTPShouldUsePipelining:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setHTTPShouldUsePipelining_, + value, ); - 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 { + /// @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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + final _$$ref$2 = forHTTPHeaderField.ref; objc.checkOsVersionInternal( - 'NSURLRequest.cachePolicy', + 'NSMutableURLRequest.setValue:forHTTPHeaderField:', 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, + _objc_msgSend_pfv6jd( + _$$ref.pointer, + _sel_setValue_forHTTPHeaderField_, + _$$ref$1?.pointer ?? ffi.nullptr, + _$$ref$2.pointer, ); - 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, +/// ! +/// @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$)); } - /// init - NSURLRequest init() { + /// 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( - 'NSURLRequest.init', + 'NSMutableURLRequest', iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + macOS: (false, (10, 2, 0)), ); - return NSURLRequest.fromPointer($ret, retain: false, release: true); + assert(isA(object$)); } - /// initWithCoder: - NSURLRequest? initWithCoder(objc.NSCoder coder) { - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithCoder_, - coder.ref.pointer, + /// Returns whether [obj] is an instance of [NSMutableURLRequest]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _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 $ret.address == 0 - ? null - : NSURLRequest.fromPointer($ret, retain: false, release: true); + 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 initWithURL: - /// @abstract Initializes an NSURLRequest with the given URL. + /// @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 An initialized NSURLRequest. - NSURLRequest initWithURL(objc.NSURL URL) { + /// @result A newly-created and autoreleased NSURLRequest instance. + static NSMutableURLRequest requestWithURL(objc.NSURL URL) { + final _$$ref = URL.ref; objc.checkOsVersionInternal( - 'NSURLRequest.initWithURL:', + 'NSMutableURLRequest.requestWithURL:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithURL_, - URL.ref.pointer, + _class_NSMutableURLRequest, + _sel_requestWithURL_, + _$$ref.pointer, ); - return NSURLRequest.fromPointer($ret, retain: false, release: true); + return NSMutableURLRequest.fromPointer($ret, retain: true, 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. + /// @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 An initialized NSURLRequest. - NSURLRequest initWithURL$1( + /// @result A newly-created and autoreleased NSURLRequest instance. + static NSMutableURLRequest requestWithURL$1( objc.NSURL URL, { required NSURLRequestCachePolicy cachePolicy, required double timeoutInterval, }) { + final _$$ref = URL.ref; objc.checkOsVersionInternal( - 'NSURLRequest.initWithURL:cachePolicy:timeoutInterval:', + 'NSMutableURLRequest.requestWithURL: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, + _class_NSMutableURLRequest, + _sel_requestWithURL_cachePolicy_timeoutInterval_, + _$$ref.pointer, cachePolicy.value, timeoutInterval, ); - return NSURLRequest.fromPointer($ret, retain: false, release: true); + 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 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 { + /// @abstract The URL of the receiver. + objc.NSURL? get URL { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.mainDocumentURL', + 'NSMutableURLRequest.URL', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_mainDocumentURL, - ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_URL); 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', + /// @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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsCellularAccess', + iOS: (false, (6, 0, 0)), + macOS: (false, (10, 8, 0)), + ); + return _objc_msgSend_91o635(_$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsConstrainedNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + _$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsExpensiveNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + _$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsPersistentDNS', + iOS: (false, (18, 0, 0)), + macOS: (false, (15, 0, 0)), + ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_allowsPersistentDNS); + } + + /// ! + /// @abstract sets whether a connection created with this request is allowed to use + /// network interfaces which have been marked as ultra constrained. + /// @discussion NO if the receiver should not be allowed to use an interface marked as ultra constrained to + /// satisfy the request, YES otherwise. + bool get allowsUltraConstrainedNetworkAccess { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.allowsUltraConstrainedNetworkAccess', + iOS: (false, (26, 1, 0)), + macOS: (false, (26, 1, 0)), + ); + return _objc_msgSend_91o635( + _$$ref.pointer, + _sel_allowsUltraConstrainedNetworkAccess, + ); + } + + /// ! + /// @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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.assumesHTTP3Capable', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), + ); + return _objc_msgSend_91o635(_$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.attribution', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), + ); + final $ret = _objc_msgSend_i3avs9(_$$ref.pointer, _sel_attribution); + return NSURLRequestAttribution.fromValue($ret); + } + + /// ! + /// @abstract The cache policy of the receiver. + NSURLRequestCachePolicy get cachePolicy { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.cachePolicy', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_8jm3uo(_$$ref.pointer, _sel_cachePolicy); + return NSURLRequestCachePolicy.fromValue($ret); + } + + /// Cookie partition identifier used for cookie storage and retrieval. + objc.NSString? get cookiePartitionIdentifier { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.cookiePartitionIdentifier', + iOS: (false, (18, 2, 0)), + macOS: (false, (15, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref.pointer, + _sel_cookiePartitionIdentifier, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); + } + + /// init + NSMutableURLRequest init() { + final _$$ref$2 = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref$2.retainAndReturnPointer(), + _sel_init, + ); + return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); + } + + /// initWithCoder: + NSMutableURLRequest? initWithCoder(objc.NSCoder coder) { + final _$$ref$2 = object$.ref; + final _$$ref$3 = coder.ref; + final $ret = _objc_msgSend_1sotr3r( + _$$ref$2.retainAndReturnPointer(), + _sel_initWithCoder_, + _$$ref$3.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) { + final _$$ref = object$.ref; + final _$$ref$1 = URL.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.initWithURL:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _$$ref.retainAndReturnPointer(), + _sel_initWithURL_, + _$$ref$1.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 double timeoutInterval, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = URL.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.initWithURL:cachePolicy:timeoutInterval:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_1ajs603( + _$$ref.retainAndReturnPointer(), + _sel_initWithURL_cachePolicy_timeoutInterval_, + _$$ref$1.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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.mainDocumentURL', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.networkServiceType', iOS: (false, (4, 0, 0)), macOS: (false, (10, 7, 0)), ); - final $ret = _objc_msgSend_t4uaw1( - object$.ref.pointer, - _sel_networkServiceType, - ); + final $ret = _objc_msgSend_t4uaw1(_$$ref.pointer, _sel_networkServiceType); return NSURLRequestNetworkServiceType.fromValue($ret); } @@ -2277,1410 +2175,1190 @@ extension NSURLRequest$Methods on NSURLRequest { /// @discussion YES, if the DNS lookup for this request should require DNSSEC validation, /// No otherwise. Defaults to NO. bool get requiresDNSSECValidation { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.requiresDNSSECValidation', + 'NSMutableURLRequest.requiresDNSSECValidation', iOS: (false, (16, 1, 0)), macOS: (false, (13, 0, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_requiresDNSSECValidation, - ); + return _objc_msgSend_91o635(_$$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. - double get timeoutInterval { + /// @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) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLRequest.timeoutInterval', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSMutableURLRequest.setAllowsCellularAccess:', + iOS: (false, (6, 0, 0)), + macOS: (false, (10, 8, 0)), ); - return objc.useMsgSendVariants - ? _objc_msgSend_1ukqyt8Fpret(object$.ref.pointer, _sel_timeoutInterval) - : _objc_msgSend_1ukqyt8(object$.ref.pointer, _sel_timeoutInterval); + _objc_msgSend_1s56lr9(_$$ref.pointer, _sel_setAllowsCellularAccess_, value); } -} -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, + /// ! + /// @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) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAllowsConstrainedNetworkAccess:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setAllowsConstrainedNetworkAccess_, + 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 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, + /// ! + /// @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) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAllowsExpensiveNetworkAccess:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setAllowsExpensiveNetworkAccess_, + value, ); } - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); + /// ! + /// @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) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSMutableURLRequest.setAllowsPersistentDNS:', + iOS: (false, (18, 0, 0)), + macOS: (false, (15, 0, 0)), + ); + _objc_msgSend_1s56lr9(_$$ref.pointer, _sel_setAllowsPersistentDNS_, value); } - 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, - }) { + /// ! + /// @abstract sets whether a connection created with this request is allowed to use + /// network interfaces which have been marked as ultra constrained. + /// @discussion NO if the receiver should not be allowed to use an interface marked as ultra constrained to + /// satisfy the request, YES otherwise. + set allowsUltraConstrainedNetworkAccess$1(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLCache.getCachedResponseForDataTask:completionHandler:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), + 'NSMutableURLRequest.setAllowsUltraConstrainedNetworkAccess:', + iOS: (false, (26, 1, 0)), + macOS: (false, (26, 1, 0)), ); - _objc_msgSend_o762yo( - object$.ref.pointer, - _sel_getCachedResponseForDataTask_completionHandler_, - dataTask.ref.pointer, - completionHandler.ref.pointer, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setAllowsUltraConstrainedNetworkAccess_, + value, ); } - /// removeCachedResponseForDataTask: - void removeCachedResponseForDataTask(NSURLSessionDataTask dataTask) { + /// ! + /// @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) { + final _$$ref = object$.ref; 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, + 'NSMutableURLRequest.setAssumesHTTP3Capable:', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), ); + _objc_msgSend_1s56lr9(_$$ref.pointer, _sel_setAssumesHTTP3Capable_, value); } - /// storeCachedResponse:forDataTask: - void storeCachedResponse$1( - NSCachedURLResponse cachedResponse, { - required NSURLSessionDataTask forDataTask, - }) { + /// ! + /// @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) { + final _$$ref = object$.ref; 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, + 'NSMutableURLRequest.setAttribution:', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), ); + _objc_msgSend_1nw1jep(_$$ref.pointer, _sel_setAttribution_, value.value); } -} -/// 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 { + /// ! + /// @abstract The cache policy of the receiver. + set cachePolicy$1(NSURLRequestCachePolicy value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLCache', + 'NSMutableURLRequest.setCachePolicy:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - assert(isA(object$)); + _objc_msgSend_1yjxuv2(_$$ref.pointer, _sel_setCachePolicy_, value.value); } - /// 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) { + /// Cookie partition identifier used for cookie storage and retrieval. + set cookiePartitionIdentifier$1(objc.NSString? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSURLCache', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSMutableURLRequest.setCookiePartitionIdentifier:', + iOS: (false, (18, 2, 0)), + macOS: (false, (15, 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, + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setCookiePartitionIdentifier_, + _$$ref$1?.pointer ?? ffi.nullptr, ); - 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) { + /// @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) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSURLCache.setSharedURLCache:', + 'NSMutableURLRequest.setMainDocumentURL:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); _objc_msgSend_xtuoz7( - _class_NSURLCache, - _sel_setSharedURLCache_, - value.ref.pointer, + _$$ref.pointer, + _sel_setMainDocumentURL_, + _$$ref$1?.pointer ?? ffi.nullptr, ); } /// ! - /// @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() { + /// @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) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLCache.sharedURLCache', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSMutableURLRequest.setNetworkServiceType:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 7, 0)), + ); + _objc_msgSend_1mse4s1( + _$$ref.pointer, + _sel_setNetworkServiceType_, + value.value, ); - 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) { + /// @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) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLCache.cachedResponseForRequest:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSMutableURLRequest.setRequiresDNSSECValidation:', + iOS: (false, (16, 1, 0)), + macOS: (false, (13, 0, 0)), ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_cachedResponseForRequest_, - request.ref.pointer, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setRequiresDNSSECValidation_, + value, ); - 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. - int get currentDiskUsage { + /// @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) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLCache.currentDiskUsage', + 'NSMutableURLRequest.setTimeoutInterval:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_currentDiskUsage); + _objc_msgSend_hwm8nu(_$$ref.pointer, _sel_setTimeoutInterval_, value); } /// ! - /// @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 { + /// @abstract The URL of the receiver. + set URL$1(objc.NSURL? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSURLCache.currentMemoryUsage', + 'NSMutableURLRequest.setURL:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_currentMemoryUsage); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setURL_, + _$$ref$1?.pointer ?? ffi.nullptr, + ); } /// ! - /// @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 { + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLCache.diskCapacity', + 'NSMutableURLRequest.timeoutInterval', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_diskCapacity); + return objc.useMsgSendVariants + ? _objc_msgSend_1ukqyt8Fpret(_$$ref.pointer, _sel_timeoutInterval) + : _objc_msgSend_1ukqyt8(_$$ref.pointer, _sel_timeoutInterval); } +} - /// init - NSURLCache init() { +/// 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) {} +} + +/// 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( - 'NSURLCache.init', + 'NSOperation', iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + macOS: (false, (10, 5, 0)), ); - 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( - int memoryCapacity, { - required int diskCapacity, - objc.NSURL? directoryURL, - }) { + /// 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( - '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, + 'NSOperation', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), ); - 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( - 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); +/// 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$)); } - /// ! - /// @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); + /// 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$)); } - /// ! - /// @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); + /// Returns whether [obj] is an instance of [NSOperationQueue]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _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); } - /// ! - /// @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) { + /// 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( - 'NSURLCache.removeCachedResponseForRequest:', + '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) { + final _$$ref = object$.ref; + final _$$ref$1 = barrier.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.addBarrierBlock:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_addBarrierBlock_, + _$$ref$1.pointer, + ); + } + + /// addOperation: + void addOperation(NSOperation op) { + final _$$ref = object$.ref; + final _$$ref$1 = op.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.addOperation:', iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + macOS: (false, (10, 5, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_removeCachedResponseForRequest_, - request.ref.pointer, + _objc_msgSend_xtuoz7(_$$ref.pointer, _sel_addOperation_, _$$ref$1.pointer); + } + + /// addOperationWithBlock: + void addOperationWithBlock(objc.ObjCBlock block) { + final _$$ref = object$.ref; + final _$$ref$1 = block.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.addOperationWithBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_addOperationWithBlock_, + _$$ref$1.pointer, ); } - /// ! - /// @method removeCachedResponsesSince: - /// @abstract Clears the given cache of any cached responses since the provided date. - void removeCachedResponsesSinceDate(objc.NSDate date) { + /// addOperations:waitUntilFinished: + void addOperations(objc.NSArray ops, {required bool waitUntilFinished}) { + final _$$ref = object$.ref; + final _$$ref$1 = ops.ref; objc.checkOsVersionInternal( - 'NSURLCache.removeCachedResponsesSinceDate:', + 'NSOperationQueue.addOperations:waitUntilFinished:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + _objc_msgSend_6p7ndb( + _$$ref.pointer, + _sel_addOperations_waitUntilFinished_, + _$$ref$1.pointer, + waitUntilFinished, + ); + } + + /// cancelAllOperations + void cancelAllOperations() { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.cancelAllOperations', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_cancelAllOperations); + } + + /// init + NSOperationQueue init() { + final _$$ref$3 = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref$3.retainAndReturnPointer(), + _sel_init, + ); + return NSOperationQueue.fromPointer($ret, retain: false, release: true); + } + + /// isSuspended + bool get isSuspended { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.isSuspended', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_isSuspended); + } + + /// maxConcurrentOperationCount + int get maxConcurrentOperationCount { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.maxConcurrentOperationCount', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + return _objc_msgSend_1hz7y9r( + _$$ref.pointer, + _sel_maxConcurrentOperationCount, + ); + } + + /// name + objc.NSString? get name { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.name', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_name); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); + } + + /// progress + objc.NSProgress get progress { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_progress); + return objc.NSProgress.fromPointer($ret, retain: true, release: true); + } + + /// qualityOfService + objc.NSQualityOfService get qualityOfService { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.qualityOfService', iOS: (false, (8, 0, 0)), macOS: (false, (10, 10, 0)), ); + final $ret = _objc_msgSend_oi8iq9(_$$ref.pointer, _sel_qualityOfService); + return objc.NSQualityOfService.fromValue($ret); + } + + /// setMaxConcurrentOperationCount: + set maxConcurrentOperationCount(int value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.setMaxConcurrentOperationCount:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 5, 0)), + ); + _objc_msgSend_4sp4xj( + _$$ref.pointer, + _sel_setMaxConcurrentOperationCount_, + value, + ); + } + + /// setName: + set name(objc.NSString? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSOperationQueue.setName:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0)), + ); _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_removeCachedResponsesSinceDate_, - date.ref.pointer, + _$$ref.pointer, + _sel_setName_, + _$$ref$1?.pointer ?? ffi.nullptr, ); } - /// ! - /// @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) { + /// setQualityOfService: + set qualityOfService(objc.NSQualityOfService value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLCache.setDiskCapacity:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSOperationQueue.setQualityOfService:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_n2da1l( + _$$ref.pointer, + _sel_setQualityOfService_, + value.value, ); - _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(int value) { + /// setSuspended: + set isSuspended(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLCache.setMemoryCapacity:', + 'NSOperationQueue.setSuspended:', iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + macOS: (false, (10, 5, 0)), ); - _objc_msgSend_1i9r4xy(object$.ref.pointer, _sel_setMemoryCapacity_, value); + _objc_msgSend_1s56lr9(_$$ref.pointer, _sel_setSuspended_, 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, - }) { + /// actually retain + set underlyingQueue(objc.NSObject? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSURLCache.storeCachedResponse:forRequest:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSOperationQueue.setUnderlyingQueue:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), ); - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_storeCachedResponse_forRequest_, - cachedResponse.ref.pointer, - forRequest.ref.pointer, + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setUnderlyingQueue_, + _$$ref$1?.pointer ?? ffi.nullptr, ); } -} -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, - ) - > - >() - .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, - ffi.UnsignedLong, - ) - > - >() - .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:", -); - -/// ! -/// @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 { + /// actually retain + objc.NSObject? get underlyingQueue { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.HTTPBody', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSOperationQueue.underlyingQueue', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_HTTPBody); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_underlyingQueue); return $ret.address == 0 ? null - : objc.NSData.fromPointer($ret, retain: true, release: true); + : objc.NSObject.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 { + /// waitUntilAllOperationsAreFinished + void waitUntilAllOperationsAreFinished() { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.HTTPBodyStream', + 'NSOperationQueue.waitUntilAllOperationsAreFinished', iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + macOS: (false, (10, 5, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_HTTPBodyStream, + _objc_msgSend_1pl9qdv( + _$$ref.pointer, + _sel_waitUntilAllOperationsAreFinished, ); - 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 { +/// 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); +} + +/// 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) {} +} + +/// 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( - 'NSMutableURLRequest.HTTPMethod', + 'NSURLCache', 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); + assert(isA(object$)); } - /// ! - /// @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 { + /// 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( - 'NSMutableURLRequest.HTTPShouldHandleCookies', + 'NSURLCache', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldHandleCookies, + assert(isA(object$)); + } + + /// Returns whether [obj] is an instance of [NSURLCache]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _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); } /// ! - /// @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 { + /// @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) { + final _$$ref = value.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.HTTPShouldUsePipelining', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 7, 0)), + 'NSURLCache.setSharedURLCache:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldUsePipelining, + _objc_msgSend_xtuoz7( + _class_NSURLCache, + _sel_setSharedURLCache_, + _$$ref.pointer, ); } /// ! - /// @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, - }) { + /// @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( - 'NSMutableURLRequest.addValue:forHTTPHeaderField:', + 'NSURLCache.sharedURLCache', 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, - ); + 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 { /// ! - /// @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 { + /// @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) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.allHTTPHeaderFields', + 'NSURLCache.cachedResponseForRequest:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_allHTTPHeaderFields, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_cachedResponseForRequest_, + _$$ref$1.pointer, ); return $ret.address == 0 ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); + : NSCachedURLResponse.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) { + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.setAllHTTPHeaderFields:', + 'NSURLCache.currentDiskUsage', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setAllHTTPHeaderFields_, - value?.ref.pointer ?? ffi.nullptr, - ); + return _objc_msgSend_xw2lbc(_$$ref.pointer, _sel_currentDiskUsage); } /// ! - /// @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) { + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPBody:', + 'NSURLCache.currentMemoryUsage', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPBody_, - value?.ref.pointer ?? ffi.nullptr, - ); + return _objc_msgSend_xw2lbc(_$$ref.pointer, _sel_currentMemoryUsage); } /// ! - /// @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) { + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPBodyStream:', + 'NSURLCache.diskCapacity', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPBodyStream_, - value?.ref.pointer ?? ffi.nullptr, + return _objc_msgSend_xw2lbc(_$$ref.pointer, _sel_diskCapacity); + } + + /// init + NSURLCache init() { + final _$$ref$4 = object$.ref; + objc.checkOsVersionInternal( + 'NSURLCache.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref$4.retainAndReturnPointer(), + _sel_init, ); + return NSURLCache.fromPointer($ret, retain: false, release: true); } /// ! - /// @abstract Sets the HTTP request method of the receiver. - set HTTPMethod(objc.NSString value) { + /// @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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = directoryURL?.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPMethod:', + 'NSURLCache.initWithMemoryCapacity:diskCapacity:directoryURL:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1dqnse5( + _$$ref.retainAndReturnPointer(), + _sel_initWithMemoryCapacity_diskCapacity_directoryURL_, + memoryCapacity, + diskCapacity, + _$$ref$1?.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. + @Deprecated('Deprecated') + NSURLCache initWithMemoryCapacity$1( + int memoryCapacity, { + required int diskCapacity, + objc.NSString? diskPath, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = diskPath?.ref; + objc.checkOsVersionInternal( + 'NSURLCache.initWithMemoryCapacity:diskCapacity:diskPath:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPMethod_, - value.ref.pointer, + final $ret = _objc_msgSend_1dqnse5( + _$$ref.retainAndReturnPointer(), + _sel_initWithMemoryCapacity_diskCapacity_diskPath_, + memoryCapacity, + diskCapacity, + _$$ref$1?.pointer ?? ffi.nullptr, ); + return NSURLCache.fromPointer($ret, retain: false, 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 - set HTTPShouldHandleCookies(bool 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. + int get memoryCapacity { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPShouldHandleCookies:', + 'NSURLCache.memoryCapacity', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setHTTPShouldHandleCookies_, - value, - ); + return _objc_msgSend_xw2lbc(_$$ref.pointer, _sel_memoryCapacity); } /// ! - /// @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) { + /// @method removeAllCachedResponses + /// @abstract Clears the given cache, removing all NSCachedURLResponse + /// objects that it stores. + void removeAllCachedResponses() { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.setHTTPShouldUsePipelining:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 7, 0)), + 'NSURLCache.removeAllCachedResponses', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setHTTPShouldUsePipelining_, - value, + _objc_msgSend_1pl9qdv(_$$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) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; + objc.checkOsVersionInternal( + 'NSURLCache.removeCachedResponseForRequest:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_removeCachedResponseForRequest_, + _$$ref$1.pointer, ); } /// ! - /// @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, + /// @method removeCachedResponsesSince: + /// @abstract Clears the given cache of any cached responses since the provided date. + void removeCachedResponsesSinceDate(objc.NSDate date) { + final _$$ref = object$.ref; + final _$$ref$1 = date.ref; + objc.checkOsVersionInternal( + 'NSURLCache.removeCachedResponsesSinceDate:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_removeCachedResponsesSinceDate_, + _$$ref$1.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(int value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLCache.setDiskCapacity:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_1i9r4xy(_$$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(int value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLCache.setMemoryCapacity:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), + ); + _objc_msgSend_1i9r4xy(_$$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, }) { + final _$$ref = object$.ref; + final _$$ref$1 = cachedResponse.ref; + final _$$ref$2 = forRequest.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.setValue:forHTTPHeaderField:', + 'NSURLCache.storeCachedResponse:forRequest:', 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, + _$$ref.pointer, + _sel_storeCachedResponse_forRequest_, + _$$ref$1.pointer, + _$$ref$2.pointer, ); } } -/// ! -/// @class NSMutableURLRequest +/// WARNING: NSURLCredential is a stub. To generate bindings for this class, include +/// NSURLCredential in your config's objc-interfaces list. /// -/// @abstract An NSMutableURLRequest object represents a mutable URL load -/// request in a manner independent of protocol and URL scheme. +/// 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) {} +} + +/// WARNING: NSURLCredentialStorage is a stub. To generate bindings for this class, include +/// NSURLCredentialStorage in your config's objc-interfaces list. /// -/// @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)), - ); +/// 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) {} +} + +/// 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 [NSMutableURLRequest] that wraps the given raw object pointer. - NSMutableURLRequest.fromPointer( + /// 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) { - 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, - ); + /// Returns whether [obj] is an instance of [NSURLRequest]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLRequest, + ); /// alloc - static NSMutableURLRequest alloc() { - final $ret = _objc_msgSend_151sglz(_class_NSMutableURLRequest, _sel_alloc); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); + static NSURLRequest alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSURLRequest, _sel_alloc); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } /// allocWithZone: - static NSMutableURLRequest allocWithZone(ffi.Pointer zone) { + static NSURLRequest allocWithZone(ffi.Pointer zone) { final $ret = _objc_msgSend_1cwp428( - _class_NSMutableURLRequest, + _class_NSURLRequest, _sel_allocWithZone_, zone, ); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); + return NSURLRequest.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); + static NSURLRequest new$() { + final $ret = _objc_msgSend_151sglz(_class_NSURLRequest, _sel_new); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } /// ! @@ -3692,18 +3370,19 @@ extension type NSMutableURLRequest._(objc.ObjCObject object$) /// seconds). /// @param URL The URL for the request. /// @result A newly-created and autoreleased NSURLRequest instance. - static NSMutableURLRequest requestWithURL(objc.NSURL URL) { + static NSURLRequest requestWithURL(objc.NSURL URL) { + final _$$ref$1 = URL.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.requestWithURL:', + 'NSURLRequest.requestWithURL:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); final $ret = _objc_msgSend_1sotr3r( - _class_NSMutableURLRequest, + _class_NSURLRequest, _sel_requestWithURL_, - URL.ref.pointer, + _$$ref$1.pointer, ); - return NSMutableURLRequest.fromPointer($ret, retain: true, release: true); + return NSURLRequest.fromPointer($ret, retain: true, release: true); } /// ! @@ -3716,97 +3395,100 @@ extension type NSMutableURLRequest._(objc.ObjCObject object$) /// commentary for the timeoutInterval for more information on /// timeout intervals. /// @result A newly-created and autoreleased NSURLRequest instance. - static NSMutableURLRequest requestWithURL$1( + static NSURLRequest requestWithURL$1( objc.NSURL URL, { required NSURLRequestCachePolicy cachePolicy, required double timeoutInterval, }) { + final _$$ref$1 = URL.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.requestWithURL:cachePolicy:timeoutInterval:', + 'NSURLRequest.requestWithURL:cachePolicy:timeoutInterval:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); final $ret = _objc_msgSend_1ajs603( - _class_NSMutableURLRequest, + _class_NSURLRequest, _sel_requestWithURL_cachePolicy_timeoutInterval_, - URL.ref.pointer, + _$$ref$1.pointer, cachePolicy.value, timeoutInterval, ); - return NSMutableURLRequest.fromPointer($ret, retain: true, release: true); + return NSURLRequest.fromPointer($ret, retain: true, release: true); } /// supportsSecureCoding static bool getSupportsSecureCoding() { - return _objc_msgSend_91o635( - _class_NSMutableURLRequest, - _sel_supportsSecureCoding, - ); + return _objc_msgSend_91o635(_class_NSURLRequest, _sel_supportsSecureCoding); } - /// Returns a new instance of NSMutableURLRequest constructed with the default `new` method. - NSMutableURLRequest() : this.as(new$().object$); + /// Returns a new instance of NSURLRequest constructed with the default `new` method. + NSURLRequest() : this.as(new$().object$); } -extension NSMutableURLRequest$Methods on NSMutableURLRequest { +extension NSURLRequest$Methods on NSURLRequest { /// ! - /// @abstract The URL of the receiver. + /// @abstract Returns the URL of the receiver. + /// @result The URL of the receiver. objc.NSURL? get URL { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.URL', + 'NSURLRequest.URL', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URL); + final $ret = _objc_msgSend_151sglz(_$$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 + /// @abstract returns 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. + /// @result YES if the receiver is allowed to use the built in cellular radios to + /// satisfy the request, NO otherwise. bool get allowsCellularAccess { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.allowsCellularAccess', + 'NSURLRequest.allowsCellularAccess', iOS: (false, (6, 0, 0)), macOS: (false, (10, 8, 0)), ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsCellularAccess); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_allowsCellularAccess); } /// ! - /// @abstract sets whether a connection created with this request is allowed to use + /// @abstract returns 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. + /// @result YES if the receiver is allowed to use an interface marked as constrained to + /// satisfy the request, NO otherwise. bool get allowsConstrainedNetworkAccess { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.allowsConstrainedNetworkAccess', + 'NSURLRequest.allowsConstrainedNetworkAccess', iOS: (false, (13, 0, 0)), macOS: (false, (10, 15, 0)), ); return _objc_msgSend_91o635( - object$.ref.pointer, + _$$ref.pointer, _sel_allowsConstrainedNetworkAccess, ); } /// ! - /// @abstract sets whether a connection created with this request is allowed to use + /// @abstract returns 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. + /// @result YES if the receiver is allowed to use an interface marked as expensive to + /// satisfy the request, NO otherwise. bool get allowsExpensiveNetworkAccess { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.allowsExpensiveNetworkAccess', + 'NSURLRequest.allowsExpensiveNetworkAccess', iOS: (false, (13, 0, 0)), macOS: (false, (10, 15, 0)), ); return _objc_msgSend_91o635( - object$.ref.pointer, + _$$ref.pointer, _sel_allowsExpensiveNetworkAccess, ); } @@ -3818,12 +3500,31 @@ extension NSMutableURLRequest$Methods on NSMutableURLRequest { /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.allowsPersistentDNS', + 'NSURLRequest.allowsPersistentDNS', iOS: (false, (18, 0, 0)), macOS: (false, (15, 0, 0)), ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_allowsPersistentDNS); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_allowsPersistentDNS); + } + + /// ! + /// @abstract returns whether a connection created with this request is allowed to use + /// network interfaces which have been marked as ultra constrained. + /// @result YES if the receiver is allowed to use an interface marked as ultra constrained to + /// satisfy the request, NO otherwise. + bool get allowsUltraConstrainedNetworkAccess { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLRequest.allowsUltraConstrainedNetworkAccess', + iOS: (false, (26, 1, 0)), + macOS: (false, (26, 1, 0)), + ); + return _objc_msgSend_91o635( + _$$ref.pointer, + _sel_allowsUltraConstrainedNetworkAccess, + ); } /// ! @@ -3832,49 +3533,55 @@ extension NSMutableURLRequest$Methods on NSMutableURLRequest { /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.assumesHTTP3Capable', + 'NSURLRequest.assumesHTTP3Capable', iOS: (false, (14, 5, 0)), macOS: (false, (11, 3, 0)), ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_assumesHTTP3Capable); + return _objc_msgSend_91o635(_$$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. + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.attribution', + 'NSURLRequest.attribution', iOS: (false, (15, 0, 0)), macOS: (false, (12, 0, 0)), ); - final $ret = _objc_msgSend_i3avs9(object$.ref.pointer, _sel_attribution); + final $ret = _objc_msgSend_i3avs9(_$$ref.pointer, _sel_attribution); return NSURLRequestAttribution.fromValue($ret); } /// ! - /// @abstract The cache policy of the receiver. + /// @abstract Returns the cache policy of the receiver. + /// @result The cache policy of the receiver. NSURLRequestCachePolicy get cachePolicy { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.cachePolicy', + 'NSURLRequest.cachePolicy', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - final $ret = _objc_msgSend_8jm3uo(object$.ref.pointer, _sel_cachePolicy); + final $ret = _objc_msgSend_8jm3uo(_$$ref.pointer, _sel_cachePolicy); return NSURLRequestCachePolicy.fromValue($ret); } /// Cookie partition identifier used for cookie storage and retrieval. objc.NSString? get cookiePartitionIdentifier { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.cookiePartitionIdentifier', + 'NSURLRequest.cookiePartitionIdentifier', iOS: (false, (18, 2, 0)), macOS: (false, (15, 2, 0)), ); final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, + _$$ref.pointer, _sel_cookiePartitionIdentifier, ); return $ret.address == 0 @@ -3882,30 +3589,44 @@ extension NSMutableURLRequest$Methods on NSMutableURLRequest { : objc.NSString.fromPointer($ret, retain: true, release: true); } + /// encodeWithCoder: + void encodeWithCoder(objc.NSCoder coder) { + final _$$ref = object$.ref; + final _$$ref$1 = coder.ref; + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_encodeWithCoder_, + _$$ref$1.pointer, + ); + } + /// init - NSMutableURLRequest init() { + NSURLRequest init() { + final _$$ref$5 = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.init', + 'NSURLRequest.init', iOS: (false, (2, 0, 0)), macOS: (false, (10, 0, 0)), ); final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), + _$$ref$5.retainAndReturnPointer(), _sel_init, ); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } /// initWithCoder: - NSMutableURLRequest? initWithCoder(objc.NSCoder coder) { + NSURLRequest? initWithCoder(objc.NSCoder coder) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = coder.ref; final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), + _$$ref$4.retainAndReturnPointer(), _sel_initWithCoder_, - coder.ref.pointer, + _$$ref$5.pointer, ); return $ret.address == 0 ? null - : NSMutableURLRequest.fromPointer($ret, retain: false, release: true); + : NSURLRequest.fromPointer($ret, retain: false, release: true); } /// ! @@ -3916,18 +3637,20 @@ extension NSMutableURLRequest$Methods on NSMutableURLRequest { /// seconds). /// @param URL The URL for the request. /// @result An initialized NSURLRequest. - NSMutableURLRequest initWithURL(objc.NSURL URL) { + NSURLRequest initWithURL(objc.NSURL URL) { + final _$$ref$2 = object$.ref; + final _$$ref$3 = URL.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.initWithURL:', + 'NSURLRequest.initWithURL:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), + _$$ref$2.retainAndReturnPointer(), _sel_initWithURL_, - URL.ref.pointer, + _$$ref$3.pointer, ); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); + return NSURLRequest.fromPointer($ret, retain: false, release: true); } /// ! @@ -3942,64 +3665,61 @@ extension NSMutableURLRequest$Methods on NSMutableURLRequest { /// commentary for the timeoutInterval for more information on /// timeout intervals. /// @result An initialized NSURLRequest. - NSMutableURLRequest initWithURL$1( + NSURLRequest initWithURL$1( objc.NSURL URL, { required NSURLRequestCachePolicy cachePolicy, required double timeoutInterval, }) { + final _$$ref$2 = object$.ref; + final _$$ref$3 = URL.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.initWithURL:cachePolicy:timeoutInterval:', + 'NSURLRequest.initWithURL:cachePolicy:timeoutInterval:', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); final $ret = _objc_msgSend_1ajs603( - object$.ref.retainAndReturnPointer(), + _$$ref$2.retainAndReturnPointer(), _sel_initWithURL_cachePolicy_timeoutInterval_, - URL.ref.pointer, + _$$ref$3.pointer, cachePolicy.value, timeoutInterval, ); - return NSMutableURLRequest.fromPointer($ret, retain: false, release: true); + return NSURLRequest.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. + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.mainDocumentURL', + 'NSURLRequest.mainDocumentURL', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_mainDocumentURL, - ); + final $ret = _objc_msgSend_151sglz(_$$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. + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.networkServiceType', + 'NSURLRequest.networkServiceType', iOS: (false, (4, 0, 0)), macOS: (false, (10, 7, 0)), ); - final $ret = _objc_msgSend_t4uaw1( - object$.ref.pointer, - _sel_networkServiceType, - ); + final $ret = _objc_msgSend_t4uaw1(_$$ref.pointer, _sel_networkServiceType); return NSURLRequestNetworkServiceType.fromValue($ret); } @@ -4008,21453 +3728,14796 @@ extension NSMutableURLRequest$Methods on NSMutableURLRequest { /// @discussion YES, if the DNS lookup for this request should require DNSSEC validation, /// No otherwise. Defaults to NO. bool get requiresDNSSECValidation { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.requiresDNSSECValidation', + 'NSURLRequest.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, - ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_requiresDNSSECValidation); } /// ! - /// @abstract The cache policy of the receiver. - set cachePolicy$1(NSURLRequestCachePolicy value) { + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSMutableURLRequest.setCachePolicy:', + 'NSURLRequest.timeoutInterval', iOS: (false, (2, 0, 0)), macOS: (false, (10, 2, 0)), ); - _objc_msgSend_1yjxuv2( - object$.ref.pointer, - _sel_setCachePolicy_, - value.value, - ); + return objc.useMsgSendVariants + ? _objc_msgSend_1ukqyt8Fpret(_$$ref.pointer, _sel_timeoutInterval) + : _objc_msgSend_1ukqyt8(_$$ref.pointer, _sel_timeoutInterval); } +} - /// 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(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); - } - - /// ! - /// @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. - 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); - } -} - -enum NSHTTPCookieAcceptPolicy { - NSHTTPCookieAcceptPolicyAlways(0), - NSHTTPCookieAcceptPolicyNever(1), - NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain(2); +/// ! +/// @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 NSHTTPCookieAcceptPolicy(this.value); + const NSURLRequestAttribution(this.value); - static NSHTTPCookieAcceptPolicy fromValue(int value) => switch (value) { - 0 => NSHTTPCookieAcceptPolicyAlways, - 1 => NSHTTPCookieAcceptPolicyNever, - 2 => NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, + static NSURLRequestAttribution fromValue(int value) => switch (value) { + 0 => NSURLRequestAttributionDeveloper, + 1 => NSURLRequestAttributionUser, _ => throw ArgumentError( - 'Unknown value for NSHTTPCookieAcceptPolicy: $value', + 'Unknown value for NSURLRequestAttribution: $value', ), }; } -/// WARNING: NSHTTPCookieStorage is a stub. To generate bindings for this class, include -/// NSHTTPCookieStorage in your config's objc-interfaces list. +/// ! +/// @enum NSURLRequestCachePolicy /// -/// 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)), - ); - } -} - -/// WARNING: NSProgressReporting is a stub. To generate bindings for this class, include -/// NSProgressReporting in your config's objc-protocols list. +/// @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. /// -/// 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); -} +/// @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); -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); + static const NSURLRequestReloadIgnoringCacheData = + NSURLRequestReloadIgnoringLocalCacheData; final int value; - const tls_protocol_version_t(this.value); + const NSURLRequestCachePolicy(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, + static NSURLRequestCachePolicy fromValue(int value) => switch (value) { + 0 => NSURLRequestUseProtocolCachePolicy, + 1 => NSURLRequestReloadIgnoringLocalCacheData, + 4 => NSURLRequestReloadIgnoringLocalAndRemoteCacheData, + 2 => NSURLRequestReturnCacheDataElseLoad, + 3 => NSURLRequestReturnCacheDataDontLoad, + 5 => NSURLRequestReloadRevalidatingCacheData, _ => throw ArgumentError( - 'Unknown value for tls_protocol_version_t: $value', + 'Unknown value for NSURLRequestCachePolicy: $value', ), }; + + @override + String toString() { + if (this == NSURLRequestReloadIgnoringLocalCacheData) + return "NSURLRequestCachePolicy.NSURLRequestReloadIgnoringLocalCacheData, NSURLRequestCachePolicy.NSURLRequestReloadIgnoringCacheData"; + return super.toString(); + } } -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); +/// ! +/// @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 SSLProtocol(this.value); + const NSURLRequestNetworkServiceType(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'), + 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 _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:", -); - -/// 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 {} +/// 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 [NSURLCredentialStorage] that wraps the given raw object pointer. - NSURLCredentialStorage.fromPointer( + /// 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) {} -} - -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), + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); + } - /// Aggregate - multiple subflows used for greater bandwidth. - NSURLSessionMultipathServiceTypeAggregate(3); + /// Returns whether [obj] is an instance of [NSURLResponse]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLResponse, + ); - final int value; - const NSURLSessionMultipathServiceType(this.value); + /// alloc + static NSURLResponse alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSURLResponse, _sel_alloc); + return NSURLResponse.fromPointer($ret, retain: false, release: true); + } - static NSURLSessionMultipathServiceType fromValue(int value) => - switch (value) { - 0 => NSURLSessionMultipathServiceTypeNone, - 1 => NSURLSessionMultipathServiceTypeHandover, - 2 => NSURLSessionMultipathServiceTypeInteractive, - 3 => NSURLSessionMultipathServiceTypeAggregate, - _ => throw ArgumentError( - 'Unknown value for NSURLSessionMultipathServiceType: $value', - ), - }; -} + /// 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 _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:", -); + /// new + static NSURLResponse new$() { + final $ret = _objc_msgSend_151sglz(_class_NSURLResponse, _sel_new); + return NSURLResponse.fromPointer($ret, retain: false, release: true); + } -/// 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, + /// 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$); } -/// 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 { +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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + 'NSURLResponse.MIMEType', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - assert(isA(object$)); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_MIMEType); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - /// 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) { + /// ! + /// @abstract Returns the URL of the receiver. + /// @result The URL of the receiver. + objc.NSURL? get URL { + final _$$ref = object$.ref; 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, + 'NSURLResponse.URL', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_URL); + return $ret.address == 0 + ? null + : objc.NSURL.fromPointer($ret, retain: true, 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, + /// encodeWithCoder: + void encodeWithCoder(objc.NSCoder coder) { + final _$$ref$2 = object$.ref; + final _$$ref$3 = coder.ref; + _objc_msgSend_xtuoz7( + _$$ref$2.pointer, + _sel_encodeWithCoder_, + _$$ref$3.pointer, ); } - /// backgroundSessionConfigurationWithIdentifier: - static NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier( - objc.NSString identifier, - ) { + /// ! + /// @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 { + final _$$ref = object$.ref; 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, + 'NSURLResponse.expectedContentLength', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); + return _objc_msgSend_1k101e3(_$$ref.pointer, _sel_expectedContentLength); } - /// defaultSessionConfiguration - static NSURLSessionConfiguration getDefaultSessionConfiguration() { + /// init + NSURLResponse init() { + final _$$ref$6 = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.defaultSessionConfiguration', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + 'NSURLResponse.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), ); final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionConfiguration, - _sel_defaultSessionConfiguration, - ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: true, - release: true, + _$$ref$6.retainAndReturnPointer(), + _sel_init, ); + return NSURLResponse.fromPointer($ret, retain: false, 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, + /// initWithCoder: + NSURLResponse? initWithCoder(objc.NSCoder coder) { + final _$$ref$6 = object$.ref; + final _$$ref$7 = coder.ref; + final $ret = _objc_msgSend_1sotr3r( + _$$ref$6.retainAndReturnPointer(), + _sel_initWithCoder_, + _$$ref$7.pointer, ); + return $ret.address == 0 + ? null + : NSURLResponse.fromPointer($ret, retain: false, release: true); } - /// new - static NSURLSessionConfiguration new$() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionConfiguration, - _sel_new, + /// ! + /// @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, + }) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = URL.ref; + final _$$ref$6 = MIMEType?.ref; + final _$$ref$7 = name?.ref; + objc.checkOsVersionInternal( + 'NSURLResponse.initWithURL:MIMEType:expectedContentLength:textEncodingName:', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: false, - release: true, + final $ret = _objc_msgSend_l9ppnx( + _$$ref$4.retainAndReturnPointer(), + _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_, + _$$ref$5.pointer, + _$$ref$6?.pointer ?? ffi.nullptr, + length, + _$$ref$7?.pointer ?? ffi.nullptr, ); + return NSURLResponse.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 { + /// ! + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPAdditionalHeaders', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_HTTPAdditionalHeaders, + 'NSURLResponse.suggestedFilename', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_suggestedFilename); return $ret.address == 0 ? null - : objc.NSDictionary.fromPointer($ret, retain: true, release: true); + : objc.NSString.fromPointer($ret, retain: true, release: true); } - /// Policy for accepting cookies. This overrides the policy otherwise specified by the cookie storage. - NSHTTPCookieAcceptPolicy get HTTPCookieAcceptPolicy { + /// ! + /// @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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPCookieAcceptPolicy', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), - ); - final $ret = _objc_msgSend_104dkoq( - object$.ref.pointer, - _sel_HTTPCookieAcceptPolicy, + 'NSURLResponse.textEncodingName', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 2, 0)), ); - return NSHTTPCookieAcceptPolicy.fromValue($ret); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_textEncodingName); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } +} - /// 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, +/// 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)), ); - return $ret.address == 0 - ? null - : NSHTTPCookieStorage.fromPointer($ret, retain: true, release: true); + assert(isA(object$)); } - /// The maximum number of simultaneous persistent connections per host - int get HTTPMaximumConnectionsPerHost { + /// 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( - 'NSURLSessionConfiguration.HTTPMaximumConnectionsPerHost', + 'NSURLSession', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - return _objc_msgSend_1hz7y9r( - object$.ref.pointer, - _sel_HTTPMaximumConnectionsPerHost, + assert(isA(object$)); + } + + /// Returns whether [obj] is an instance of [NSURLSession]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _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); } - /// Allow the session to set cookies on requests - bool get HTTPShouldSetCookies { + /// 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, + ) { + final _$$ref = configuration.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPShouldSetCookies', + 'NSURLSession.sessionWithConfiguration:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_HTTPShouldSetCookies); + final $ret = _objc_msgSend_1sotr3r( + _class_NSURLSession, + _sel_sessionWithConfiguration_, + _$$ref.pointer, + ); + return NSURLSession.fromPointer($ret, retain: true, release: true); } - /// Allow the use of HTTP pipelining - bool get HTTPShouldUsePipelining { + /// sessionWithConfiguration:delegate:delegateQueue: + static NSURLSession sessionWithConfiguration$1( + NSURLSessionConfiguration configuration, { + NSURLSessionDelegate? delegate, + NSOperationQueue? delegateQueue, + }) { + final _$$ref = configuration.ref; + final _$$ref$1 = delegate?.ref; + final _$$ref$2 = delegateQueue?.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.HTTPShouldUsePipelining', + 'NSURLSession.sessionWithConfiguration:delegate:delegateQueue:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_HTTPShouldUsePipelining, + final $ret = _objc_msgSend_11spmsz( + _class_NSURLSession, + _sel_sessionWithConfiguration_delegate_delegateQueue_, + _$$ref.pointer, + _$$ref$1?.pointer ?? ffi.nullptr, + _$$ref$2?.pointer ?? ffi.nullptr, ); + return NSURLSession.fromPointer($ret, retain: true, release: true); } - /// The maximum allowable versions of the TLS protocol, from - SSLProtocol get TLSMaximumSupportedProtocol { + /// The shared session uses the currently set global NSURLCache, + /// NSHTTPCookieStorage and NSURLCredentialStorage objects. + static NSURLSession getSharedSession() { objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.TLSMaximumSupportedProtocol', + 'NSURLSession.sharedSession', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_cbopi9( - object$.ref.pointer, - _sel_TLSMaximumSupportedProtocol, - ); - return SSLProtocol.fromValue($ret); + final $ret = _objc_msgSend_151sglz(_class_NSURLSession, _sel_sharedSession); + return NSURLSession.fromPointer($ret, retain: true, release: true); } - /// The maximum allowable versions of the TLS protocol, from - tls_protocol_version_t get TLSMaximumSupportedProtocolVersion { + /// 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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.TLSMaximumSupportedProtocolVersion', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), + 'NSURLSession.configuration', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_9jpwfb( - object$.ref.pointer, - _sel_TLSMaximumSupportedProtocolVersion, + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_configuration); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, + release: true, ); - return tls_protocol_version_t.fromValue($ret); } - /// The minimum allowable versions of the TLS protocol, from - SSLProtocol get TLSMinimumSupportedProtocol { + /// Creates a data task with the given request. The request may have a body stream. + NSURLSessionDataTask dataTaskWithRequest(NSURLRequest request) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.TLSMinimumSupportedProtocol', + 'NSURLSession.dataTaskWithRequest:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_cbopi9( - object$.ref.pointer, - _sel_TLSMinimumSupportedProtocol, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_dataTaskWithRequest_, + _$$ref$1.pointer, ); - return SSLProtocol.fromValue($ret); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); } - /// The minimum allowable versions of the TLS protocol, from - tls_protocol_version_t get TLSMinimumSupportedProtocolVersion { + /// Creates a data task to retrieve the contents of the given URL. + NSURLSessionDataTask dataTaskWithURL(objc.NSURL url) { + final _$$ref = object$.ref; + final _$$ref$1 = url.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.TLSMinimumSupportedProtocolVersion', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), + 'NSURLSession.dataTaskWithURL:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_9jpwfb( - object$.ref.pointer, - _sel_TLSMinimumSupportedProtocolVersion, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_dataTaskWithURL_, + _$$ref$1.pointer, ); - return tls_protocol_version_t.fromValue($ret); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); } - /// The URL resource cache, or nil to indicate that no caching is to be performed - NSURLCache? get URLCache { + /// delegate + NSURLSessionDelegate? get delegate { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.URLCache', + 'NSURLSession.delegate', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_URLCache); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_delegate); return $ret.address == 0 ? null - : NSURLCache.fromPointer($ret, retain: true, release: true); + : NSURLSessionDelegate.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 { + /// delegateQueue + NSOperationQueue get delegateQueue { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.URLCredentialStorage', + 'NSURLSession.delegateQueue', 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); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_delegateQueue); + return NSOperationQueue.fromPointer($ret, retain: true, release: true); } - /// allow request to route over cellular. - bool get allowsCellularAccess { + /// Creates a download task with the given request. + NSURLSessionDownloadTask downloadTaskWithRequest(NSURLRequest request) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.allowsCellularAccess', + 'NSURLSession.downloadTaskWithRequest:', 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)), + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_downloadTaskWithRequest_, + _$$ref$1.pointer, ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsConstrainedNetworkAccess, + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// allow request to route over expensive networks. Defaults to YES. - bool get allowsExpensiveNetworkAccess { + /// 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) { + final _$$ref = object$.ref; + final _$$ref$1 = resumeData.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.allowsExpensiveNetworkAccess', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), - ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_allowsExpensiveNetworkAccess, + 'NSURLSession.downloadTaskWithResumeData:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_downloadTaskWithResumeData_, + _$$ref$1.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// The proxy dictionary, as described by - objc.NSDictionary? get connectionProxyDictionary { + /// Creates a download task to download the contents of the given URL. + NSURLSessionDownloadTask downloadTaskWithURL(objc.NSURL url) { + final _$$ref = object$.ref; + final _$$ref$1 = url.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.connectionProxyDictionary', + 'NSURLSession.downloadTaskWithURL:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_connectionProxyDictionary, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_downloadTaskWithURL_, + _$$ref$1.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, ); - 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. + /// -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. /// - /// NOTE: Not supported in the classic loading mode. + /// -finishTasksAndInvalidate and -invalidateAndCancel do not + /// have any effect on the shared session instance. /// - /// Defaults to NO. - bool get enablesEarlyData { + /// 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() { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.enablesEarlyData', - iOS: (false, (26, 0, 0)), - macOS: (false, (26, 0, 0)), + 'NSURLSession.finishTasksAndInvalidate', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_enablesEarlyData); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_finishTasksAndInvalidate); } - /// identifier for the background session configuration - objc.NSString? get identifier { + /// flush storage to disk and clear transient network caches. Invokes completionHandler() on the delegate queue. + void flushWithCompletionHandler( + objc.ObjCBlock completionHandler, + ) { + final _$$ref = object$.ref; + final _$$ref$1 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.identifier', + 'NSURLSession.flushWithCompletionHandler:', 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); + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_flushWithCompletionHandler_, + _$$ref$1.pointer, + ); } - /// init - NSURLSessionConfiguration init() { + /// invokes completionHandler with all outstanding tasks. + void getAllTasksWithCompletionHandler( + objc.ObjCBlock completionHandler, + ) { + final _$$ref = object$.ref; + final _$$ref$1 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + 'NSURLSession.getAllTasksWithCompletionHandler:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), ); - return NSURLSessionConfiguration.fromPointer( - $ret, - retain: false, - release: true, + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_getAllTasksWithCompletionHandler_, + _$$ref$1.pointer, ); } - /// allows background tasks to be scheduled at the discretion of the system for optimal performance. - bool get isDiscretionary { + /// invokes completionHandler with outstanding data, upload and download tasks. + void getTasksWithCompletionHandler( + objc.ObjCBlock + completionHandler, + ) { + final _$$ref = object$.ref; + final _$$ref$1 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.isDiscretionary', + 'NSURLSession.getTasksWithCompletionHandler:', iOS: (false, (7, 0, 0)), - macOS: (false, (10, 10, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_getTasksWithCompletionHandler_, + _$$ref$1.pointer, ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_isDiscretionary); } - /// multipath service type to use for connections. The default is NSURLSessionMultipathServiceTypeNone - NSURLSessionMultipathServiceType get multipathServiceType { + /// init + NSURLSession init() { + final _$$ref$7 = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.multipathServiceType', - iOS: (false, (11, 0, 0)), - macOS: (true, null), + 'NSURLSession.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), ); - final $ret = _objc_msgSend_1wxwnc0( - object$.ref.pointer, - _sel_multipathServiceType, + final $ret = _objc_msgSend_151sglz( + _$$ref$7.retainAndReturnPointer(), + _sel_init, ); - return NSURLSessionMultipathServiceType.fromValue($ret); + return NSURLSession.fromPointer($ret, retain: false, release: true); } - /// type of service for requests. - NSURLRequestNetworkServiceType get networkServiceType { + /// -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() { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.networkServiceType', + 'NSURLSession.invalidateAndCancel', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_t4uaw1( - object$.ref.pointer, - _sel_networkServiceType, - ); - return NSURLRequestNetworkServiceType.fromValue($ret); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_invalidateAndCancel); } - /// 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 { + /// empty all cookies, cache and credential stores, removes disk files, issues -flushWithCompletionHandler:. Invokes completionHandler() on the delegate queue. + void resetWithCompletionHandler( + objc.ObjCBlock completionHandler, + ) { + final _$$ref = object$.ref; + final _$$ref$1 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.protocolClasses', + 'NSURLSession.resetWithCompletionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_protocolClasses, + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_resetWithCompletionHandler_, + _$$ref$1.pointer, + ); + } + + /// The sessionDescription property is available for the developer to + /// provide a descriptive label for the session. + objc.NSString? get sessionDescription { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSession.sessionDescription', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_sessionDescription); return $ret.address == 0 ? null - : objc.NSArray.fromPointer($ret, retain: true, release: true); + : objc.NSString.fromPointer($ret, retain: true, release: true); } - /// default cache policy for requests - NSURLRequestCachePolicy get requestCachePolicy { + /// The sessionDescription property is available for the developer to + /// provide a descriptive label for the session. + set sessionDescription(objc.NSString? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.requestCachePolicy', + 'NSURLSession.setSessionDescription:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_8jm3uo( - object$.ref.pointer, - _sel_requestCachePolicy, + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setSessionDescription_, + _$$ref$1?.pointer ?? ffi.nullptr, ); - return NSURLRequestCachePolicy.fromValue($ret); } - /// requires requests from the session to be made with DNSSEC validation enabled. Defaults to NO. - bool get requiresDNSSECValidation { + /// Creates a bidirectional stream task to a given host and port. + NSURLSessionStreamTask streamTaskWithHostName( + objc.NSString hostname, { + required int port, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = hostname.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.requiresDNSSECValidation', - iOS: (false, (16, 0, 0)), - macOS: (false, (13, 0, 0)), + 'NSURLSession.streamTaskWithHostName:port:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_requiresDNSSECValidation, + final $ret = _objc_msgSend_9slupp( + _$$ref.pointer, + _sel_streamTaskWithHostName_port_, + _$$ref$1.pointer, + port, + ); + return NSURLSessionStreamTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// 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 { + /// Creates a bidirectional stream task with an NSNetService to identify the endpoint. + /// The NSNetService will be resolved before any IO completes. + @Deprecated('Use nw_connection_t in Network framework instead') + NSURLSessionStreamTask streamTaskWithNetService(NSNetService service) { + final _$$ref = object$.ref; + final _$$ref$1 = service.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.sessionSendsLaunchEvents', - iOS: (false, (7, 0, 0)), - macOS: (false, (11, 0, 0)), + 'NSURLSession.streamTaskWithNetService:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_sessionSendsLaunchEvents, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_streamTaskWithNetService_, + _$$ref$1.pointer, + ); + return NSURLSessionStreamTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// allow request to route over cellular. - set allowsCellularAccess(bool 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; + final _$$ref$2 = fromData.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setAllowsCellularAccess:', + 'NSURLSession.uploadTaskWithRequest:fromData:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsCellularAccess_, - value, + final $ret = _objc_msgSend_15qeuct( + _$$ref.pointer, + _sel_uploadTaskWithRequest_fromData_, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// 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)), + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; + final _$$ref$2 = fromFile.ref; + objc.checkOsVersionInternal( + 'NSURLSession.uploadTaskWithRequest:fromFile:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsConstrainedNetworkAccess_, - value, + final $ret = _objc_msgSend_15qeuct( + _$$ref.pointer, + _sel_uploadTaskWithRequest_fromFile_, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// allow request to route over expensive networks. Defaults to YES. - set allowsExpensiveNetworkAccess(bool value) { + /// 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) { + final _$$ref = object$.ref; + final _$$ref$1 = resumeData.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setAllowsExpensiveNetworkAccess:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), + 'NSURLSession.uploadTaskWithResumeData:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setAllowsExpensiveNetworkAccess_, - value, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_uploadTaskWithResumeData_, + _$$ref$1.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// The proxy dictionary, as described by - set connectionProxyDictionary(objc.NSDictionary? value) { + /// 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) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setConnectionProxyDictionary:', + 'NSURLSession.uploadTaskWithStreamedRequest:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setConnectionProxyDictionary_, - value?.ref.pointer ?? ffi.nullptr, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_uploadTaskWithStreamedRequest_, + _$$ref$1.pointer, ); - } - - /// 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)), + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, ); - _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) { + /// 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) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setEnablesEarlyData:', - iOS: (false, (26, 0, 0)), - macOS: (false, (26, 0, 0)), + 'NSURLSession.webSocketTaskWithRequest:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setEnablesEarlyData_, - value, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_webSocketTaskWithRequest_, + _$$ref$1.pointer, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// 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) { + /// Creates a WebSocket task given the url. The given url must have a ws or wss scheme. + NSURLSessionWebSocketTask webSocketTaskWithURL(objc.NSURL url) { + final _$$ref = object$.ref; + final _$$ref$1 = url.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPAdditionalHeaders:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + 'NSURLSession.webSocketTaskWithURL:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPAdditionalHeaders_, - value?.ref.pointer ?? ffi.nullptr, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.pointer, + _sel_webSocketTaskWithURL_, + _$$ref$1.pointer, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// Policy for accepting cookies. This overrides the policy otherwise specified by the cookie storage. - set HTTPCookieAcceptPolicy(NSHTTPCookieAcceptPolicy value) { + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = url.ref; + final _$$ref$2 = protocols.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPCookieAcceptPolicy:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + 'NSURLSession.webSocketTaskWithURL:protocols:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - _objc_msgSend_3q55ys( - object$.ref.pointer, - _sel_setHTTPCookieAcceptPolicy_, - value.value, + final $ret = _objc_msgSend_15qeuct( + _$$ref.pointer, + _sel_webSocketTaskWithURL_protocols_, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: true, + release: true, ); } +} - /// The cookie storage object to use, or nil to indicate that no cookies should be handled - set HTTPCookieStorage(NSHTTPCookieStorage? value) { +/// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; + final _$$ref$2 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPCookieStorage:', + 'NSURLSession.dataTaskWithRequest:completionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setHTTPCookieStorage_, - value?.ref.pointer ?? ffi.nullptr, + final $ret = _objc_msgSend_r0bo0s( + _$$ref.pointer, + _sel_dataTaskWithRequest_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, ); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); } - /// The maximum number of simultaneous persistent connections per host - set HTTPMaximumConnectionsPerHost(int value) { + /// dataTaskWithURL:completionHandler: + NSURLSessionDataTask dataTaskWithURL$1( + objc.NSURL url, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = url.ref; + final _$$ref$2 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPMaximumConnectionsPerHost:', + 'NSURLSession.dataTaskWithURL:completionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_4sp4xj( - object$.ref.pointer, - _sel_setHTTPMaximumConnectionsPerHost_, - value, + final $ret = _objc_msgSend_r0bo0s( + _$$ref.pointer, + _sel_dataTaskWithURL_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, ); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); } - /// Allow the session to set cookies on requests - set HTTPShouldSetCookies(bool 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; + final _$$ref$2 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPShouldSetCookies:', + 'NSURLSession.downloadTaskWithRequest:completionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setHTTPShouldSetCookies_, - value, + final $ret = _objc_msgSend_r0bo0s( + _$$ref.pointer, + _sel_downloadTaskWithRequest_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// Allow the use of HTTP pipelining - set HTTPShouldUsePipelining(bool value) { + /// downloadTaskWithResumeData:completionHandler: + NSURLSessionDownloadTask downloadTaskWithResumeData$1( + objc.NSData resumeData, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = resumeData.ref; + final _$$ref$2 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setHTTPShouldUsePipelining:', + 'NSURLSession.downloadTaskWithResumeData:completionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setHTTPShouldUsePipelining_, - value, + final $ret = _objc_msgSend_r0bo0s( + _$$ref.pointer, + _sel_downloadTaskWithResumeData_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, ); - } - - /// 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, + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// type of service for requests. - set networkServiceType(NSURLRequestNetworkServiceType value) { + /// downloadTaskWithURL:completionHandler: + NSURLSessionDownloadTask downloadTaskWithURL$1( + objc.NSURL url, { + required objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = url.ref; + final _$$ref$2 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setNetworkServiceType:', + 'NSURLSession.downloadTaskWithURL:completionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_1mse4s1( - object$.ref.pointer, - _sel_setNetworkServiceType_, - value.value, + final $ret = _objc_msgSend_r0bo0s( + _$$ref.pointer, + _sel_downloadTaskWithURL_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// 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) { + /// uploadTaskWithRequest:fromData:completionHandler: + NSURLSessionUploadTask uploadTaskWithRequest$2( + NSURLRequest request, { + objc.NSData? fromData, + required objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + > + completionHandler, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; + final _$$ref$2 = fromData?.ref; + final _$$ref$3 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setProtocolClasses:', + 'NSURLSession.uploadTaskWithRequest:fromData:completionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setProtocolClasses_, - value?.ref.pointer ?? ffi.nullptr, + final $ret = _objc_msgSend_2wiv66( + _$$ref.pointer, + _sel_uploadTaskWithRequest_fromData_completionHandler_, + _$$ref$1.pointer, + _$$ref$2?.pointer ?? ffi.nullptr, + _$$ref$3.pointer, + ); + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// default cache policy for requests - set requestCachePolicy(NSURLRequestCachePolicy 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = request.ref; + final _$$ref$2 = fromFile.ref; + final _$$ref$3 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setRequestCachePolicy:', + 'NSURLSession.uploadTaskWithRequest:fromFile:completionHandler:', 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)), + final $ret = _objc_msgSend_2wiv66( + _$$ref.pointer, + _sel_uploadTaskWithRequest_fromFile_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setRequiresDNSSECValidation_, - value, + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, ); } - /// 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. + /// Creates a URLSessionUploadTask from a resume data blob. If resuming from an upload + /// file, the file must still exist and be unmodified. /// - /// NOTE: macOS apps based on AppKit do not support background launch. - set sessionSendsLaunchEvents(bool value) { + /// - 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = resumeData.ref; + final _$$ref$2 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setSessionSendsLaunchEvents:', - iOS: (false, (7, 0, 0)), - macOS: (false, (11, 0, 0)), - ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setSessionSendsLaunchEvents_, - value, + 'NSURLSession.uploadTaskWithResumeData:completionHandler:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), ); - } - - /// 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)), + final $ret = _objc_msgSend_r0bo0s( + _$$ref.pointer, + _sel_uploadTaskWithResumeData_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setSharedContainerIdentifier_, - value?.ref.pointer ?? ffi.nullptr, + return NSURLSessionUploadTask.fromPointer( + $ret, + retain: true, + release: true, ); } +} - /// 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, - ); - } +enum NSURLSessionAuthChallengeDisposition { + /// Use the specified credential, which may be nil + NSURLSessionAuthChallengeUseCredential(0), - /// The maximum allowable versions of the TLS protocol, from - set TLSMaximumSupportedProtocol(SSLProtocol value) { + /// 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', + ), + }; +} + +/// 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.setTLSMaximumSupportedProtocol:', + 'NSURLSessionConfiguration', 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, - ); + assert(isA(object$)); } - /// The minimum allowable versions of the TLS protocol, from - set TLSMinimumSupportedProtocol(SSLProtocol value) { + /// 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.setTLSMinimumSupportedProtocol:', + 'NSURLSessionConfiguration', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_268k8x( - object$.ref.pointer, - _sel_setTLSMinimumSupportedProtocol_, - value.value, - ); + assert(isA(object$)); } - /// 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)), + /// Returns whether [obj] is an instance of [NSURLSessionConfiguration]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionConfiguration, + ); + + /// alloc + static NSURLSessionConfiguration alloc() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionConfiguration, + _sel_alloc, ); - _objc_msgSend_1mvuct7( - object$.ref.pointer, - _sel_setTLSMinimumSupportedProtocolVersion_, - value.value, + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: false, + release: true, ); } - /// 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)), + /// allocWithZone: + static NSURLSessionConfiguration allocWithZone( + ffi.Pointer zone, + ) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSessionConfiguration, + _sel_allocWithZone_, + zone, ); - _objc_msgSend_hwm8nu( - object$.ref.pointer, - _sel_setTimeoutIntervalForRequest_, - value, + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: false, + release: true, ); } - /// 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) { + /// backgroundSessionConfigurationWithIdentifier: + static NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier( + objc.NSString identifier, + ) { + final _$$ref = identifier.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setTimeoutIntervalForResource:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + 'NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), ); - _objc_msgSend_hwm8nu( - object$.ref.pointer, - _sel_setTimeoutIntervalForResource_, - value, + final $ret = _objc_msgSend_1sotr3r( + _class_NSURLSessionConfiguration, + _sel_backgroundSessionConfigurationWithIdentifier_, + _$$ref.pointer, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, + release: true, ); } - /// The URL resource cache, or nil to indicate that no caching is to be performed - set URLCache(NSURLCache? value) { + /// defaultSessionConfiguration + static NSURLSessionConfiguration getDefaultSessionConfiguration() { objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setURLCache:', + 'NSURLSessionConfiguration.defaultSessionConfiguration', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setURLCache_, - value?.ref.pointer ?? ffi.nullptr, + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionConfiguration, + _sel_defaultSessionConfiguration, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, + release: true, ); } - /// The credential storage object, or nil to indicate that no credential storage is to be used - set URLCredentialStorage(NSURLCredentialStorage? value) { + /// ephemeralSessionConfiguration + static NSURLSessionConfiguration getEphemeralSessionConfiguration() { objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setURLCredentialStorage:', + 'NSURLSessionConfiguration.ephemeralSessionConfiguration', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setURLCredentialStorage_, - value?.ref.pointer ?? ffi.nullptr, + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionConfiguration, + _sel_ephemeralSessionConfiguration, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, + release: true, ); } - /// 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)), + /// new + static NSURLSessionConfiguration new$() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionConfiguration, + _sel_new, ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setUsesClassicLoadingMode_, - value, + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: false, + release: true, ); } - /// 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) { + /// 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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.setWaitsForConnectivity:', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), + 'NSURLSessionConfiguration.HTTPAdditionalHeaders', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - _objc_msgSend_1s56lr9( - object$.ref.pointer, - _sel_setWaitsForConnectivity_, - value, + final $ret = _objc_msgSend_151sglz( + _$$ref.pointer, + _sel_HTTPAdditionalHeaders, ); + return $ret.address == 0 + ? null + : objc.NSDictionary.fromPointer($ret, retain: true, release: true); } - /// 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 { + /// Policy for accepting cookies. This overrides the policy otherwise specified by the cookie storage. + NSHTTPCookieAcceptPolicy get HTTPCookieAcceptPolicy { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.sharedContainerIdentifier', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), + 'NSURLSessionConfiguration.HTTPCookieAcceptPolicy', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_sharedContainerIdentifier, + final $ret = _objc_msgSend_104dkoq( + _$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.HTTPCookieStorage', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_HTTPCookieStorage); return $ret.address == 0 ? null - : objc.NSString.fromPointer($ret, retain: true, release: true); + : NSHTTPCookieStorage.fromPointer($ret, retain: true, release: true); } - /// shouldUseExtendedBackgroundIdleMode - bool get shouldUseExtendedBackgroundIdleMode { + /// The maximum number of simultaneous persistent connections per host + int get HTTPMaximumConnectionsPerHost { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.shouldUseExtendedBackgroundIdleMode', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), + 'NSURLSessionConfiguration.HTTPMaximumConnectionsPerHost', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_shouldUseExtendedBackgroundIdleMode, + return _objc_msgSend_1hz7y9r( + _$$ref.pointer, + _sel_HTTPMaximumConnectionsPerHost, ); } - /// 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 { + /// Allow the session to set cookies on requests + bool get HTTPShouldSetCookies { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.timeoutIntervalForRequest', + 'NSURLSessionConfiguration.HTTPShouldSetCookies', 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, - ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_HTTPShouldSetCookies); } - /// 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 { + /// Allow the use of HTTP pipelining + @Deprecated( + 'Only supported in the classic loader, please adopt HTTP/2 and HTTP/3 instead', + ) + bool get HTTPShouldUsePipelining { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.timeoutIntervalForResource', + 'NSURLSessionConfiguration.HTTPShouldUsePipelining', 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, - ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_HTTPShouldUsePipelining); } - /// 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 { + /// The maximum allowable versions of the TLS protocol, from + @Deprecated('Deprecated') + SSLProtocol get TLSMaximumSupportedProtocol { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.usesClassicLoadingMode', - iOS: (false, (18, 4, 0)), - macOS: (false, (15, 4, 0)), + 'NSURLSessionConfiguration.TLSMaximumSupportedProtocol', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_usesClassicLoadingMode, + final $ret = _objc_msgSend_cbopi9( + _$$ref.pointer, + _sel_TLSMaximumSupportedProtocol, ); + return SSLProtocol.fromValue($ret); } - /// 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 { + /// The maximum allowable versions of the TLS protocol, from + tls_protocol_version_t get TLSMaximumSupportedProtocolVersion { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSURLSessionConfiguration.waitsForConnectivity', - iOS: (false, (11, 0, 0)), - macOS: (false, (10, 13, 0)), + 'NSURLSessionConfiguration.TLSMaximumSupportedProtocolVersion', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_waitsForConnectivity); + final $ret = _objc_msgSend_9jpwfb( + _$$ref.pointer, + _sel_TLSMaximumSupportedProtocolVersion, + ); + return tls_protocol_version_t.fromValue($ret); } -} - -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"); -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, - ); + /// The minimum allowable versions of the TLS protocol, from + @Deprecated('Deprecated') + SSLProtocol get TLSMinimumSupportedProtocol { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.TLSMinimumSupportedProtocol', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_cbopi9( + _$$ref.pointer, + _sel_TLSMinimumSupportedProtocol, + ); + return SSLProtocol.fromValue($ret); + } - /// 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, - ); + /// The minimum allowable versions of the TLS protocol, from + tls_protocol_version_t get TLSMinimumSupportedProtocolVersion { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.TLSMinimumSupportedProtocolVersion', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_9jpwfb( + _$$ref.pointer, + _sel_TLSMinimumSupportedProtocolVersion, + ); + return tls_protocol_version_t.fromValue($ret); + } - 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(); -} + /// The URL resource cache, or nil to indicate that no caching is to be performed + NSURLCache? get URLCache { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.URLCache', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_URLCache); + return $ret.address == 0 + ? null + : NSURLCache.fromPointer($ret, retain: true, release: true); + } -/// 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, - ); -} + /// The credential storage object, or nil to indicate that no credential storage is to be used + NSURLCredentialStorage? get URLCredentialStorage { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.URLCredentialStorage', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref.pointer, + _sel_URLCredentialStorage, + ); + return $ret.address == 0 + ? null + : NSURLCredentialStorage.fromPointer($ret, retain: true, release: true); + } -/// 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 { + /// allow request to route over cellular. + bool get allowsCellularAccess { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperation', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.allowsCellularAccess', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_allowsCellularAccess); } - /// 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) { + /// allow request to route over networks in constrained mode. Defaults to YES. + bool get allowsConstrainedNetworkAccess { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperation', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.allowsConstrainedNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + _$$ref.pointer, + _sel_allowsConstrainedNetworkAccess, ); } -} -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, - ) - >(); + /// allow request to route over expensive networks. Defaults to YES. + bool get allowsExpensiveNetworkAccess { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.allowsExpensiveNetworkAccess', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + return _objc_msgSend_91o635( + _$$ref.pointer, + _sel_allowsExpensiveNetworkAccess, + ); + } -/// 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, - ); + /// allow request to route over ultra constrained networks. + bool get allowsUltraConstrainedNetworkAccess { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.allowsUltraConstrainedNetworkAccess', + iOS: (false, (26, 1, 0)), + macOS: (false, (26, 1, 0)), + ); + return _objc_msgSend_91o635( + _$$ref.pointer, + _sel_allowsUltraConstrainedNetworkAccess, + ); + } - /// 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, - ); + /// The proxy dictionary, as described by + objc.NSDictionary? get connectionProxyDictionary { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.connectionProxyDictionary', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref.pointer, + _sel_connectionProxyDictionary, + ); + return $ret.address == 0 + ? null + : objc.NSDictionary.fromPointer($ret, retain: true, release: true); + } - /// Creates a block from a Dart function. + /// Enables HTTP/3 0-RTT early data transmission of safe requests (GET or HEAD + /// requests). /// - /// 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. + /// WARNING: Inclusion in TLS early data changes the security guarantees offered + /// by TLS. /// - /// 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. + /// 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. /// - /// 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. + /// See Section 8 of RFC8446 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, + /// 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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.enablesEarlyData', + iOS: (false, (26, 0, 0)), + macOS: (false, (26, 0, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1pl9qdv(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + return _objc_msgSend_91o635(_$$ref.pointer, _sel_enablesEarlyData); + } + + /// identifier for the background session configuration + objc.NSString? get identifier { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.identifier', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_identifier); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, 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, + /// init + NSURLSessionConfiguration init() { + final _$$ref$8 = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref$8.retainAndReturnPointer(), + _sel_init, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, retain: false, release: true, ); } - static void _listenerTrampoline(ffi.Pointer block) { - (objc.getBlockClosure(block) as void Function())(); - objc.objectRelease(block.cast()); + /// allows background tasks to be scheduled at the discretion of the system for optimal performance. + bool get isDiscretionary { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.isDiscretionary', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_isDiscretionary); } - 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()); - } + /// multipath service type to use for connections. The default is NSURLSessionMultipathServiceTypeNone + NSURLSessionMultipathServiceType get multipathServiceType { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.multipathServiceType', + iOS: (false, (11, 0, 0)), + macOS: (true, null), + ); + final $ret = _objc_msgSend_1wxwnc0( + _$$ref.pointer, + _sel_multipathServiceType, + ); + return NSURLSessionMultipathServiceType.fromValue($ret); } - 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, - ); -} - -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"); - -/// NSDeprecated -extension NSDeprecated on NSOperationQueue { - /// operationCount - int get operationCount { + /// type of service for requests. + NSURLRequestNetworkServiceType get networkServiceType { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.operationCount', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), + 'NSURLSessionConfiguration.networkServiceType', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_operationCount); + final $ret = _objc_msgSend_t4uaw1(_$$ref.pointer, _sel_networkServiceType); + return NSURLRequestNetworkServiceType.fromValue($ret); } - /// These two functions are inherently a race condition and should be avoided if possible - objc.NSArray get operations { + /// 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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.operations', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.protocolClasses', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_operations); - return objc.NSArray.fromPointer($ret, retain: true, release: true); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_protocolClasses); + return $ret.address == 0 + ? null + : 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, + /// default cache policy for requests + NSURLRequestCachePolicy get requestCachePolicy { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.requestCachePolicy', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return NSOperationQueue.fromPointer($ret, retain: false, release: true); + final $ret = _objc_msgSend_8jm3uo(_$$ref.pointer, _sel_requestCachePolicy); + return NSURLRequestCachePolicy.fromValue($ret); } - /// currentQueue - static NSOperationQueue? getCurrentQueue() { + /// requires requests from the session to be made with DNSSEC validation enabled. Defaults to NO. + bool get requiresDNSSECValidation { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.currentQueue', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), - ); - final $ret = _objc_msgSend_151sglz( - _class_NSOperationQueue, - _sel_currentQueue, + 'NSURLSessionConfiguration.requiresDNSSECValidation', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), ); - return $ret.address == 0 - ? null - : NSOperationQueue.fromPointer($ret, retain: true, release: true); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_requiresDNSSECValidation); } - /// mainQueue - static NSOperationQueue getMainQueue() { + /// 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 { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.mainQueue', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), + 'NSURLSessionConfiguration.sessionSendsLaunchEvents', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), ); - final $ret = _objc_msgSend_151sglz(_class_NSOperationQueue, _sel_mainQueue); - return NSOperationQueue.fromPointer($ret, retain: true, release: true); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_sessionSendsLaunchEvents); } - /// new - static NSOperationQueue new$() { - final $ret = _objc_msgSend_151sglz(_class_NSOperationQueue, _sel_new); - return NSOperationQueue.fromPointer($ret, retain: false, release: true); + /// allow request to route over cellular. + set allowsCellularAccess(bool value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setAllowsCellularAccess:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1s56lr9(_$$ref.pointer, _sel_setAllowsCellularAccess_, value); } - /// 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) { + /// allow request to route over networks in constrained mode. Defaults to YES. + set allowsConstrainedNetworkAccess(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.addBarrierBlock:', + 'NSURLSessionConfiguration.setAllowsConstrainedNetworkAccess:', iOS: (false, (13, 0, 0)), macOS: (false, (10, 15, 0)), ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_addBarrierBlock_, - barrier.ref.pointer, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setAllowsConstrainedNetworkAccess_, + value, ); } - /// addOperation: - void addOperation(NSOperation op) { + /// allow request to route over expensive networks. Defaults to YES. + set allowsExpensiveNetworkAccess(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.addOperation:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.setAllowsExpensiveNetworkAccess:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_addOperation_, - op.ref.pointer, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setAllowsExpensiveNetworkAccess_, + value, ); } - /// addOperationWithBlock: - void addOperationWithBlock(objc.ObjCBlock block) { + /// allow request to route over ultra constrained networks. + set allowsUltraConstrainedNetworkAccess(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.addOperationWithBlock:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), + 'NSURLSessionConfiguration.setAllowsUltraConstrainedNetworkAccess:', + iOS: (false, (26, 1, 0)), + macOS: (false, (26, 1, 0)), ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_addOperationWithBlock_, - block.ref.pointer, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setAllowsUltraConstrainedNetworkAccess_, + value, ); } - /// addOperations:waitUntilFinished: - void addOperations(objc.NSArray ops, {required bool waitUntilFinished}) { + /// The proxy dictionary, as described by + set connectionProxyDictionary(objc.NSDictionary? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.addOperations:waitUntilFinished:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), + 'NSURLSessionConfiguration.setConnectionProxyDictionary:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - _objc_msgSend_6p7ndb( - object$.ref.pointer, - _sel_addOperations_waitUntilFinished_, - ops.ref.pointer, - waitUntilFinished, + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setConnectionProxyDictionary_, + _$$ref$1?.pointer ?? ffi.nullptr, ); } - /// cancelAllOperations - void cancelAllOperations() { + /// allows background tasks to be scheduled at the discretion of the system for optimal performance. + set isDiscretionary(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.cancelAllOperations', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.setDiscretionary:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 10, 0)), ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_cancelAllOperations); + _objc_msgSend_1s56lr9(_$$ref.pointer, _sel_setDiscretionary_, value); } - /// init - NSOperationQueue init() { + /// 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) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + 'NSURLSessionConfiguration.setEnablesEarlyData:', + iOS: (false, (26, 0, 0)), + macOS: (false, (26, 0, 0)), ); - return NSOperationQueue.fromPointer($ret, retain: false, release: true); + _objc_msgSend_1s56lr9(_$$ref.pointer, _sel_setEnablesEarlyData_, value); } - /// isSuspended - bool get isSuspended { + /// 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) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.isSuspended', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.setHTTPAdditionalHeaders:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setHTTPAdditionalHeaders_, + _$$ref$1?.pointer ?? ffi.nullptr, ); - return _objc_msgSend_91o635(object$.ref.pointer, _sel_isSuspended); } - /// maxConcurrentOperationCount - int get maxConcurrentOperationCount { + /// Policy for accepting cookies. This overrides the policy otherwise specified by the cookie storage. + set HTTPCookieAcceptPolicy(NSHTTPCookieAcceptPolicy value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.maxConcurrentOperationCount', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.setHTTPCookieAcceptPolicy:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return _objc_msgSend_1hz7y9r( - object$.ref.pointer, - _sel_maxConcurrentOperationCount, + _objc_msgSend_3q55ys( + _$$ref.pointer, + _sel_setHTTPCookieAcceptPolicy_, + value.value, ); } - /// name - objc.NSString? get name { + /// The cookie storage object to use, or nil to indicate that no cookies should be handled + set HTTPCookieStorage(NSHTTPCookieStorage? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.name', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), + 'NSURLSessionConfiguration.setHTTPCookieStorage:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setHTTPCookieStorage_, + _$$ref$1?.pointer ?? ffi.nullptr, ); - 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 { + /// The maximum number of simultaneous persistent connections per host + set HTTPMaximumConnectionsPerHost(int value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.qualityOfService', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), + 'NSURLSessionConfiguration.setHTTPMaximumConnectionsPerHost:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_oi8iq9( - object$.ref.pointer, - _sel_qualityOfService, + _objc_msgSend_4sp4xj( + _$$ref.pointer, + _sel_setHTTPMaximumConnectionsPerHost_, + value, ); - return objc.NSQualityOfService.fromValue($ret); } - /// setMaxConcurrentOperationCount: - set maxConcurrentOperationCount(int value) { + /// Allow the session to set cookies on requests + set HTTPShouldSetCookies(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.setMaxConcurrentOperationCount:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.setHTTPShouldSetCookies:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - _objc_msgSend_4sp4xj( - object$.ref.pointer, - _sel_setMaxConcurrentOperationCount_, + _objc_msgSend_1s56lr9(_$$ref.pointer, _sel_setHTTPShouldSetCookies_, value); + } + + /// Allow the use of HTTP pipelining + @Deprecated( + 'Only supported in the classic loader, please adopt HTTP/2 and HTTP/3 instead', + ) + set HTTPShouldUsePipelining(bool value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setHTTPShouldUsePipelining:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setHTTPShouldUsePipelining_, value, ); } - /// setName: - set name(objc.NSString? value) { + /// multipath service type to use for connections. The default is NSURLSessionMultipathServiceTypeNone + set multipathServiceType(NSURLSessionMultipathServiceType value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.setName:', - iOS: (false, (4, 0, 0)), - macOS: (false, (10, 6, 0)), + 'NSURLSessionConfiguration.setMultipathServiceType:', + iOS: (false, (11, 0, 0)), + macOS: (true, null), + ); + _objc_msgSend_1hx005a( + _$$ref.pointer, + _sel_setMultipathServiceType_, + value.value, + ); + } + + /// type of service for requests. + set networkServiceType(NSURLRequestNetworkServiceType value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setNetworkServiceType:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1mse4s1( + _$$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) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setProtocolClasses:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setName_, - value?.ref.pointer ?? ffi.nullptr, + _$$ref.pointer, + _sel_setProtocolClasses_, + _$$ref$1?.pointer ?? ffi.nullptr, ); } - /// setQualityOfService: - set qualityOfService(objc.NSQualityOfService value) { + /// default cache policy for requests + set requestCachePolicy(NSURLRequestCachePolicy value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.setQualityOfService:', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), + 'NSURLSessionConfiguration.setRequestCachePolicy:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - _objc_msgSend_n2da1l( - object$.ref.pointer, - _sel_setQualityOfService_, + _objc_msgSend_1yjxuv2( + _$$ref.pointer, + _sel_setRequestCachePolicy_, value.value, ); } - /// setSuspended: - set isSuspended(bool value) { + /// requires requests from the session to be made with DNSSEC validation enabled. Defaults to NO. + set requiresDNSSECValidation(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.setSuspended:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.setRequiresDNSSECValidation:', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), + ); + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setRequiresDNSSECValidation_, + value, ); - _objc_msgSend_1s56lr9(object$.ref.pointer, _sel_setSuspended_, value); } - /// actually retain - set underlyingQueue(objc.NSObject? 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) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.setUnderlyingQueue:', + 'NSURLSessionConfiguration.setSessionSendsLaunchEvents:', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), + ); + _objc_msgSend_1s56lr9( + _$$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) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setSharedContainerIdentifier:', iOS: (false, (8, 0, 0)), macOS: (false, (10, 10, 0)), ); _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setUnderlyingQueue_, - value?.ref.pointer ?? ffi.nullptr, + _$$ref.pointer, + _sel_setSharedContainerIdentifier_, + _$$ref$1?.pointer ?? ffi.nullptr, ); } - /// actually retain - objc.NSObject? get underlyingQueue { + /// setShouldUseExtendedBackgroundIdleMode: + @Deprecated('Not supported') + set shouldUseExtendedBackgroundIdleMode(bool value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.underlyingQueue', - iOS: (false, (8, 0, 0)), - macOS: (false, (10, 10, 0)), + 'NSURLSessionConfiguration.setShouldUseExtendedBackgroundIdleMode:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_underlyingQueue, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setShouldUseExtendedBackgroundIdleMode_, + value, ); - return $ret.address == 0 - ? null - : objc.NSObject.fromPointer($ret, retain: true, release: true); } - /// waitUntilAllOperationsAreFinished - void waitUntilAllOperationsAreFinished() { + /// The maximum allowable versions of the TLS protocol, from + @Deprecated('Deprecated') + set TLSMaximumSupportedProtocol(SSLProtocol value) { + final _$$ref = object$.ref; objc.checkOsVersionInternal( - 'NSOperationQueue.waitUntilAllOperationsAreFinished', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 5, 0)), + 'NSURLSessionConfiguration.setTLSMaximumSupportedProtocol:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - _objc_msgSend_1pl9qdv( - object$.ref.pointer, - _sel_waitUntilAllOperationsAreFinished, + _objc_msgSend_268k8x( + _$$ref.pointer, + _sel_setTLSMaximumSupportedProtocol_, + value.value, ); } -} -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:", -); + /// The maximum allowable versions of the TLS protocol, from + set TLSMaximumSupportedProtocolVersion(tls_protocol_version_t value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTLSMaximumSupportedProtocolVersion:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_1mvuct7( + _$$ref.pointer, + _sel_setTLSMaximumSupportedProtocolVersion_, + value.value, + ); + } -/// 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); + /// The minimum allowable versions of the TLS protocol, from + @Deprecated('Deprecated') + set TLSMinimumSupportedProtocol(SSLProtocol value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTLSMinimumSupportedProtocol:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_268k8x( + _$$ref.pointer, + _sel_setTLSMinimumSupportedProtocol_, + value.value, + ); + } - /// 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, - ); + /// The minimum allowable versions of the TLS protocol, from + set TLSMinimumSupportedProtocolVersion(tls_protocol_version_t value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTLSMinimumSupportedProtocolVersion:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + _objc_msgSend_1mvuct7( + _$$ref.pointer, + _sel_setTLSMinimumSupportedProtocolVersion_, + value.value, + ); + } - /// 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, - ); + /// 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) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTimeoutIntervalForRequest:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_hwm8nu( + _$$ref.pointer, + _sel_setTimeoutIntervalForRequest_, + value, + ); + } - /// Creates a listener block from a Dart function. + /// 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) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setTimeoutIntervalForResource:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_hwm8nu( + _$$ref.pointer, + _sel_setTimeoutIntervalForResource_, + value, + ); + } + + /// The URL resource cache, or nil to indicate that no caching is to be performed + set URLCache(NSURLCache? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setURLCache:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setURLCache_, + _$$ref$1?.pointer ?? ffi.nullptr, + ); + } + + /// The credential storage object, or nil to indicate that no credential storage is to be used + set URLCredentialStorage(NSURLCredentialStorage? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setURLCredentialStorage:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setURLCredentialStorage_, + _$$ref$1?.pointer ?? ffi.nullptr, + ); + } + + /// Uses the classic network loader. /// - /// 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. + /// NOTE: FTP and HTTP/1 pipelining are only supported in the classic loading mode. /// - /// 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, + /// Defaults to YES. The default may be NO in a future OS update. + set usesClassicLoadingMode(bool value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setUsesClassicLoadingMode:', + iOS: (false, (18, 4, 0)), + macOS: (false, (15, 4, 0)), + ); + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setUsesClassicLoadingMode_, + value, ); - 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. + /// 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. /// - /// 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. + /// 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). /// - /// 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, + /// Default value is NO. Ignored by background sessions, as background sessions + /// always wait for connectivity. + set waitsForConnectivity(bool value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.setWaitsForConnectivity:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( - raw, - rawListener, - objc.objCContext, + _objc_msgSend_1s56lr9(_$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.sharedContainerIdentifier', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), ); - 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); + final $ret = _objc_msgSend_151sglz( + _$$ref.pointer, + _sel_sharedContainerIdentifier, + ); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, 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()); + /// shouldUseExtendedBackgroundIdleMode + @Deprecated('Not supported') + bool get shouldUseExtendedBackgroundIdleMode { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.shouldUseExtendedBackgroundIdleMode', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); + return _objc_msgSend_91o635( + _$$ref.pointer, + _sel_shouldUseExtendedBackgroundIdleMode, + ); } - 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, + /// 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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.timeoutIntervalForRequest', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return objc.useMsgSendVariants + ? _objc_msgSend_1ukqyt8Fpret( + _$$ref.pointer, + _sel_timeoutIntervalForRequest, ) - >.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()); - } + : _objc_msgSend_1ukqyt8(_$$ref.pointer, _sel_timeoutIntervalForRequest); } - 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, + /// 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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.timeoutIntervalForResource', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return objc.useMsgSendVariants + ? _objc_msgSend_1ukqyt8Fpret( + _$$ref.pointer, + _sel_timeoutIntervalForResource, ) - >.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(); -} + : _objc_msgSend_1ukqyt8( + _$$ref.pointer, + _sel_timeoutIntervalForResource, + ); + } -/// 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); + /// 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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.usesClassicLoadingMode', + iOS: (false, (18, 4, 0)), + macOS: (false, (15, 4, 0)), + ); + return _objc_msgSend_91o635(_$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionConfiguration.waitsForConnectivity', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + return _objc_msgSend_91o635(_$$ref.pointer, _sel_waitsForConnectivity); + } } -late final _sel_getTasksWithCompletionHandler_ = objc.registerName( - "getTasksWithCompletionHandler:", -); +/// 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; -/// 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, { + /// Constructs a [NSURLSessionDataDelegate] that wraps the given raw object pointer. + NSURLSessionDataDelegate.fromPointer( + ffi.Pointer other, { 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, - ); + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); - /// 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, - ); + /// 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, + ); + } +} - /// 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, +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, }) { - 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, + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = dataTask.ref; + final _$$ref$3 = didBecomeDownloadTask.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:dataTask:didBecomeDownloadTask:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_dataTask_didBecomeDownloadTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:didBecomeDownloadTask:', + ); + } + _objc_msgSend_r8gdi7( + _$$ref.pointer, + _sel_URLSession_dataTask_didBecomeDownloadTask_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, ); } - /// Creates a blocking block from a Dart function. + /// 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. /// - /// 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. + /// 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. /// - /// 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, + /// 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, }) { - 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, + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = dataTask.ref; + final _$$ref$3 = didBecomeStreamTask.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:dataTask:didBecomeStreamTask:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_dataTask_didBecomeStreamTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:didBecomeStreamTask:', + ); + } + _objc_msgSend_r8gdi7( + _$$ref.pointer, + _sel_URLSession_dataTask_didBecomeStreamTask_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, ); } - 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()); + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = dataTask.ref; + final _$$ref$3 = didReceiveData.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:dataTask:didReceiveData:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_dataTask_didReceiveData_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:didReceiveData:', + ); } + _objc_msgSend_r8gdi7( + _$$ref.pointer, + _sel_URLSession_dataTask_didReceiveData_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.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, - ) - >.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 { + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = dataTask.ref; + final _$$ref$3 = didReceiveResponse.ref; + final _$$ref$4 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionUploadTask', + 'NSURLSessionDataDelegate.URLSession:dataTask:didReceiveResponse:completionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:didReceiveResponse:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + _$$ref.pointer, + _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, + _$$ref$4.pointer, + ); } - /// 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) { + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = dataTask.ref; + final _$$ref$3 = willCacheResponse.ref; + final _$$ref$4 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionUploadTask', + 'NSURLSessionDataDelegate.URLSession:dataTask:willCacheResponse:completionHandler:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_dataTask_willCacheResponse_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:dataTask:willCacheResponse:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + _$$ref.pointer, + _sel_URLSession_dataTask_willCacheResponse_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, + _$$ref$4.pointer, + ); } -} - -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", -); -/// 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, - ); + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = didBecomeInvalidWithError?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:didBecomeInvalidWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:didBecomeInvalidWithError:', + ); + } + _objc_msgSend_pfv6jd( + _$$ref.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + _$$ref$1.pointer, + _$$ref$2?.pointer ?? ffi.nullptr, + ); + } - /// Creates a block from a C function pointer. + /// 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 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, - ); + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = didCreateTask.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:didCreateTask:', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_didCreateTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:didCreateTask:', + ); + } + _objc_msgSend_pfv6jd( + _$$ref.pointer, + _sel_URLSession_didCreateTask_, + _$$ref$1.pointer, + _$$ref$2.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(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, - ); + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = didReceiveChallenge.ref; + final _$$ref$3 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:didReceiveChallenge:completionHandler:', + ); + } + _objc_msgSend_18qun1e( + _$$ref.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.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(objc.NSData?) fn, { - bool keepIsolateAlive = 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, }) { - 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 _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + final _$$ref$3 = didCompleteWithError?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didCompleteWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_didCompleteWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didCompleteWithError:', + ); + } + _objc_msgSend_r8gdi7( + _$$ref.pointer, + _sel_URLSession_task_didCompleteWithError_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3?.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 blocking( - void Function(objc.NSData?) fn, { - bool keepIsolateAlive = true, + /// Sent when complete statistics information has been collected for the task. + void URLSession$9( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLSessionTaskMetrics didFinishCollectingMetrics, }) { - 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 _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + final _$$ref$3 = didFinishCollectingMetrics.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didFinishCollectingMetrics:', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0)), ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSData.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didFinishCollectingMetrics:', + ); + } + _objc_msgSend_r8gdi7( + _$$ref.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, + } + + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + final _$$ref$3 = didReceiveChallenge.ref; + final _$$ref$4 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didReceiveChallenge:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + _$$ref.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, + _$$ref$4.pointer, ); } - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); + /// Sent for each informational response received except 101 switching protocols. + void URLSession$11( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse didReceiveInformationalResponse, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + final _$$ref$3 = didReceiveInformationalResponse.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didReceiveInformationalResponse:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didReceiveInformationalResponse:', + ); + } + _objc_msgSend_r8gdi7( + _$$ref.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, + ); } - 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()); + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', + ); } + _objc_msgSend_1modw1b( + _$$ref.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + _$$ref$1.pointer, + _$$ref$2.pointer, + didSendBodyData, + totalBytesSent, + totalBytesExpectedToSend, + ); } - 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:", -); -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, + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + final _$$ref$3 = needNewBodyStream.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDataDelegate.URLSession:task:needNewBodyStream:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - 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, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_needNewBodyStream_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:needNewBodyStream:', + ); + } + _objc_msgSend_18qun1e( + _$$ref.pointer, + _sel_URLSession_task_needNewBodyStream_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, ); } - /// 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 { + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + final _$$ref$3 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLResponse.MIMEType', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSURLSessionDataDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 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)), + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + ); + } + _objc_msgSend_9cddqw( + _$$ref.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + needNewBodyStreamFromOffset, + _$$ref$3.pointer, ); - 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() { + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + final _$$ref$3 = willBeginDelayedRequest.ref; + final _$$ref$4 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLResponse.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + 'NSURLSessionDataDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), ); - 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, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:willBeginDelayedRequest:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + _$$ref.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, + _$$ref$4.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 int length, - objc.NSString? name, + /// 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, }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = task.ref; + final _$$ref$3 = willPerformHTTPRedirection.ref; + final _$$ref$4 = newRequest.ref; + final _$$ref$5 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLResponse.initWithURL:MIMEType:expectedContentLength:textEncodingName:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSURLSessionDataDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 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, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + ); + } + _objc_msgSend_e1wgee( + _$$ref.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, + _$$ref$4.pointer, + _$$ref$5.pointer, ); - 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 { + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = taskIsWaitingForConnectivity.ref; objc.checkOsVersionInternal( - 'NSURLResponse.suggestedFilename', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSURLSessionDataDelegate.URLSession:taskIsWaitingForConnectivity:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_suggestedFilename, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSession:taskIsWaitingForConnectivity:', + ); + } + _objc_msgSend_pfv6jd( + _$$ref.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + _$$ref$1.pointer, + _$$ref$2.pointer, ); - 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 { + /// 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) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; objc.checkOsVersionInternal( - 'NSURLResponse.textEncodingName', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + 'NSURLSessionDataDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_textEncodingName, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDataDelegate', + 'URLSessionDidFinishEventsForBackgroundURLSession:', + ); + } + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + _$$ref$1.pointer, ); - 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); -} +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 _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"); - -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< - 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:", -); - -/// 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)), + /// 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', ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implement( + builder, + URLSession_dataTask_didBecomeDownloadTask_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implement( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - _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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implement( + builder, + URLSession_dataTask_didReceiveData_, ); - return _objc_msgSend_pysgoz( - object$.ref.pointer, - _sel_countOfBytesClientExpectsToReceive, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implement( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implement( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - return _objc_msgSend_pysgoz( - object$.ref.pointer, - _sel_countOfBytesClientExpectsToSend, + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, ); - return _objc_msgSend_pysgoz( - object$.ref.pointer, - _sel_countOfBytesExpectedToReceive, + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implement( + builder, + URLSession_task_didCompleteWithError_, ); - return _objc_msgSend_pysgoz( - object$.ref.pointer, - _sel_countOfBytesExpectedToSend, + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implement( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - } - - /// number of body bytes already received - int get countOfBytesReceived { - objc.checkOsVersionInternal( - 'NSURLSessionTask.countOfBytesReceived', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implement( + builder, + URLSession_task_didReceiveInformationalResponse_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_currentRequest, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implement( + builder, + URLSession_task_needNewBodyStream_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_earliestBeginDate, + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implement( + builder, + URLSession_taskIsWaitingForConnectivity_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implement( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + builder.addProtocol($protocol); + return NSURLSessionDataDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), ); - 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. + /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. /// - /// 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)), + /// 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_, ); - return _objc_msgSend_91o635( - object$.ref.pointer, - _sel_prefersIncrementalDelivery, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implement( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implement( + builder, + URLSession_dataTask_didReceiveData_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implement( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implement( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - _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)), + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, ); - _objc_msgSend_17gvxvj( - object$.ref.pointer, - _sel_setCountOfBytesClientExpectsToReceive_, - value, + NSURLSessionDataDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - _objc_msgSend_17gvxvj( - object$.ref.pointer, - _sel_setCountOfBytesClientExpectsToSend_, - value, + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implement( + builder, + URLSession_task_didCompleteWithError_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implement( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setDelegate_, - value?.ref.pointer ?? ffi.nullptr, + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implement( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implement( + builder, + URLSession_task_didReceiveInformationalResponse_, ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setEarliestBeginDate_, - value?.ref.pointer ?? ffi.nullptr, + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implement( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, ); - } - - /// 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, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implement( + builder, + URLSession_task_needNewBodyStream_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implement( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, ); - _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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implement( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setTaskDescription_, - value?.ref.pointer ?? ffi.nullptr, + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implement( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implement( + builder, + URLSession_taskIsWaitingForConnectivity_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implement( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, ); - _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_suspend); + builder.addProtocol($protocol); } - /// 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)), + /// 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', ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_taskDescription, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implementAsListener( + builder, + URLSession_dataTask_didBecomeDownloadTask_, ); - 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 - int get taskIdentifier { - objc.checkOsVersionInternal( - 'NSURLSessionTask.taskIdentifier', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implementAsListener( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - return _objc_msgSend_xw2lbc(object$.ref.pointer, _sel_taskIdentifier); - } -} - -/// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implementAsListener( + builder, + URLSession_dataTask_didReceiveData_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsListener( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - 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, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsListener( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, ); - } - - /// allocWithZone: - static NSURLSessionDownloadTask allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSessionDownloadTask, - _sel_allocWithZone_, - zone, + NSURLSessionDataDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - } - - /// new - static NSURLSessionDownloadTask new$() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionDownloadTask, - _sel_new, + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_cancelByProducingResumeData_, - completionHandler.ref.pointer, + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, ); - } - - /// init - NSURLSessionDownloadTask init() { - objc.checkOsVersionInternal( - 'NSURLSessionDownloadTask.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, ); - return NSURLSessionDownloadTask.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, ); - } -} - -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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, ); - } - - /// 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)), + 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 _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< - 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"); - -/// 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)), + /// 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_, ); - 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, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implementAsListener( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implementAsListener( + builder, + URLSession_dataTask_didReceiveData_, ); - } - - /// allocWithZone: - static NSURLSessionWebSocketMessage allocWithZone( - ffi.Pointer zone, - ) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSessionWebSocketMessage, - _sel_allocWithZone_, - zone, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsListener( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsListener( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - } - - /// new - static NSURLSessionWebSocketMessage new$() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionWebSocketMessage, - _sel_new, + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithData_, - data.ref.pointer, + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.retainAndReturnPointer(), - _sel_initWithString_, - string.ref.pointer, + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, ); - return NSURLSessionWebSocketMessage.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, ); - } - - /// string - objc.NSString? get string { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketMessage.string', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsListener( + builder, + URLSession_taskIsWaitingForConnectivity_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, ); - final $ret = _objc_msgSend_1qouven(object$.ref.pointer, _sel_type); - return NSURLSessionWebSocketMessageType.fromValue($ret); + builder.addProtocol($protocol); } -} - -/// 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. + /// 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 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, + /// 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 raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSError.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, + final builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionDataDelegate', ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeDownloadTask_.implementAsBlocking( + builder, + URLSession_dataTask_didBecomeDownloadTask_, ); - } - - /// 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, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implementAsBlocking( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSError.fromPointer(arg0, retain: false, release: true), - ), - keepIsolateAlive, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implementAsBlocking( + builder, + URLSession_dataTask_didReceiveData_, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsBlocking( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsBlocking( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - } - - 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, + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, ); - 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, + NSURLSessionDataDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_pfv6jd( - raw, - rawListener, - objc.objCContext, + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - 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, - 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"); - -/// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsBlocking( + builder, + URLSession_task_didCompleteWithError_, ); - 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, + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, ); - } - - /// allocWithZone: - static NSURLSessionWebSocketTask allocWithZone( - ffi.Pointer zone, - ) { - final $ret = _objc_msgSend_1cwp428( - _class_NSURLSessionWebSocketTask, - _sel_allocWithZone_, - zone, + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsBlocking( + builder, + URLSession_task_didReceiveInformationalResponse_, ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsBlocking( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, ); - } - - /// new - static NSURLSessionWebSocketTask new$() { - final $ret = _objc_msgSend_151sglz( - _class_NSURLSessionWebSocketTask, - _sel_new, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStream_, ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsBlocking( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, ); - } - - /// 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(int closeCode, {objc.NSData? reason}) { - objc.checkOsVersionInternal( - 'NSURLSessionWebSocketTask.cancelWithCloseCode:reason:', - iOS: (false, (13, 0, 0)), - macOS: (false, (10, 15, 0)), + NSURLSessionDataDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, ); - _objc_msgSend_tqzk0b( - object$.ref.pointer, - _sel_cancelWithCloseCode_reason_, - closeCode, - reason?.ref.pointer ?? ffi.nullptr, + NSURLSessionDataDelegate$Builder + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_.implementAsBlocking( + builder, + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_taskIsWaitingForConnectivity_.implementAsBlocking( + builder, + URLSession_taskIsWaitingForConnectivity_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( + builder, + URLSessionDidFinishEventsForBackgroundURLSession_, + ); + builder.addProtocol($protocol); + return NSURLSessionDataDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), ); - 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)), + /// 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_, ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didBecomeStreamTask_.implementAsBlocking( + builder, + URLSession_dataTask_didBecomeStreamTask_, ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: false, - release: true, + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveData_.implementAsBlocking( + builder, + URLSession_dataTask_didReceiveData_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_didReceiveResponse_completionHandler_.implementAsBlocking( + builder, + URLSession_dataTask_didReceiveResponse_completionHandler_, ); - 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)), + NSURLSessionDataDelegate$Builder + .URLSession_dataTask_willCacheResponse_completionHandler_.implementAsBlocking( + builder, + URLSession_dataTask_willCacheResponse_completionHandler_, ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_receiveMessageWithCompletionHandler_, - completionHandler.ref.pointer, + NSURLSessionDataDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, ); - _objc_msgSend_o762yo( - object$.ref.pointer, - _sel_sendMessage_completionHandler_, - message.ref.pointer, - completionHandler.ref.pointer, + NSURLSessionDataDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsBlocking( + builder, + URLSession_task_didCompleteWithError_, ); - _objc_msgSend_f167m6( - object$.ref.pointer, - _sel_sendPingWithPongReceiveHandler_, - pongReceiveHandler.ref.pointer, + NSURLSessionDataDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsBlocking( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - } - - /// 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)), + NSURLSessionDataDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsBlocking( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, ); - _objc_msgSend_4sp4xj( - object$.ref.pointer, - _sel_setMaximumMessageSize_, - value, + 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 _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, + /// 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, ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didBecomeDownloadTask_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_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), + ), ); - /// Creates a block from a Dart function. + /// 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. /// - /// 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. + /// 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. /// - /// 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?) + /// 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, + ) >( - 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, + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didBecomeStreamTask_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didBecomeStreamTask_, + isRequired: false, + isInstanceMethod: true, ), - 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, + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, ) - >.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, + 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, ) - >.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, + 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, ) - > - >() - .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, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionStreamTask.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionStreamTask arg3, + ) => func(arg1, arg2, arg3), + ), ); -} -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?) + /// 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) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didReceiveData_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_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), + ), ); - /// 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. + /// 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. /// - /// 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?) + /// 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, + ) >( - 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, + _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, + ) + > + >(_1tf3our_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_didReceiveResponse_completionHandler_, + isRequired: false, + isInstanceMethod: true, ), - retain: false, - release: 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), + ), ); - /// 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, + /// 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, + ) + > + >(_1tf3our_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDataDelegate, + _sel_URLSession_dataTask_willCacheResponse_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, ) - >.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, + 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, ) - >.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, + 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, ) - > - >() - .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, + 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 _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); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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, - ); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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, - ); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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, - ); - } -} + /// 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, + ) + > + >(_1tf3our_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), + ), + ); -/// 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); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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, - ); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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, - ); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// -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. + /// 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. /// - /// -finishTasksAndInvalidate and -invalidateAndCancel do not - /// have any effect on the shared session instance. + /// 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. /// - /// 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, - ); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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, - ); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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, - ); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); +} - /// -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); - } +/// 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 {} - /// 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, - ); - } + /// 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) {} +} - /// The sessionDescription property is available for the developer to - /// provide a descriptive label for the session. - objc.NSString? get sessionDescription { +/// 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', + ), + }; +} + +/// 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); +} + +/// NSURLSessionDeprecated +extension NSURLSessionDeprecated on NSURLSessionConfiguration { + /// backgroundSessionConfiguration: + @Deprecated('Deprecated') + static NSURLSessionConfiguration backgroundSessionConfiguration( + objc.NSString identifier, + ) { + final _$$ref = identifier.ref; objc.checkOsVersionInternal( - 'NSURLSession.sessionDescription', + 'NSURLSessionConfiguration.backgroundSessionConfiguration:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_sessionDescription, + final $ret = _objc_msgSend_1sotr3r( + _class_NSURLSessionConfiguration, + _sel_backgroundSessionConfiguration_, + _$$ref.pointer, + ); + return NSURLSessionConfiguration.fromPointer( + $ret, + retain: true, + release: true, ); - 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) { +/// 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, + }) { + final _$$ref$3 = object$.ref; + final _$$ref$4 = session.ref; + final _$$ref$5 = didBecomeInvalidWithError?.ref; objc.checkOsVersionInternal( - 'NSURLSession.setSessionDescription:', + 'NSURLSessionDownloadDelegate.URLSession:didBecomeInvalidWithError:', iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0)), ); - _objc_msgSend_xtuoz7( - object$.ref.pointer, - _sel_setSessionDescription_, - value?.ref.pointer ?? ffi.nullptr, + if (!objc.respondsToSelector( + _$$ref$3.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:didBecomeInvalidWithError:', + ); + } + _objc_msgSend_pfv6jd( + _$$ref$3.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + _$$ref$4.pointer, + _$$ref$5?.pointer ?? ffi.nullptr, ); } - /// Creates a bidirectional stream task to a given host and port. - NSURLSessionStreamTask streamTaskWithHostName( - objc.NSString hostname, { - required int port, + /// 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, }) { + final _$$ref$3 = object$.ref; + final _$$ref$4 = session.ref; + final _$$ref$5 = didCreateTask.ref; 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, + 'NSURLSessionDownloadDelegate.URLSession:didCreateTask:', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), ); - return NSURLSessionStreamTask.fromPointer( - $ret, - retain: true, - release: true, + if (!objc.respondsToSelector( + _$$ref$3.pointer, + _sel_URLSession_didCreateTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:didCreateTask:', + ); + } + _objc_msgSend_pfv6jd( + _$$ref$3.pointer, + _sel_URLSession_didCreateTask_, + _$$ref$4.pointer, + _$$ref$5.pointer, ); } - /// 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) { + /// 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, + }) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = session.ref; + final _$$ref$6 = didReceiveChallenge.ref; + final _$$ref$7 = completionHandler.ref; 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, + 'NSURLSessionDownloadDelegate.URLSession:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return NSURLSessionStreamTask.fromPointer( - $ret, - retain: true, - release: true, + if (!objc.respondsToSelector( + _$$ref$4.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:didReceiveChallenge:completionHandler:', + ); + } + _objc_msgSend_18qun1e( + _$$ref$4.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + _$$ref$5.pointer, + _$$ref$6.pointer, + _$$ref$7.pointer, ); } - /// 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, + /// 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, }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = downloadTask.ref; + final _$$ref$3 = didFinishDownloadingToURL.ref; objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithRequest:fromData:', + 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didFinishDownloadingToURL:', 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, + _objc_msgSend_r8gdi7( + _$$ref.pointer, + _sel_URLSession_downloadTask_didFinishDownloadingToURL_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, ); } - /// 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, + /// 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, }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = downloadTask.ref; objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithRequest:fromFile:', + 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:', 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, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:', + ); + } + _objc_msgSend_fm5719( + _$$ref.pointer, + _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + _$$ref$1.pointer, + _$$ref$2.pointer, + didResumeAtOffset, + expectedTotalBytes, ); } - /// 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) { + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = downloadTask.ref; 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, + 'NSURLSessionDownloadDelegate.URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return NSURLSessionUploadTask.fromPointer( - $ret, - retain: true, - release: true, + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:', + ); + } + _objc_msgSend_1modw1b( + _$$ref.pointer, + _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + _$$ref$1.pointer, + _$$ref$2.pointer, + didWriteData, + totalBytesWritten, + totalBytesExpectedToWrite, ); } - /// 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) { + /// 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, + }) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = session.ref; + final _$$ref$6 = task.ref; + final _$$ref$7 = didCompleteWithError?.ref; objc.checkOsVersionInternal( - 'NSURLSession.uploadTaskWithStreamedRequest:', + 'NSURLSessionDownloadDelegate.URLSession:task:didCompleteWithError:', 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, + if (!objc.respondsToSelector( + _$$ref$4.pointer, + _sel_URLSession_task_didCompleteWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didCompleteWithError:', + ); + } + _objc_msgSend_r8gdi7( + _$$ref$4.pointer, + _sel_URLSession_task_didCompleteWithError_, + _$$ref$5.pointer, + _$$ref$6.pointer, + _$$ref$7?.pointer ?? ffi.nullptr, ); } - /// 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) { + /// Sent when complete statistics information has been collected for the task. + void URLSession$9( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLSessionTaskMetrics didFinishCollectingMetrics, + }) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = session.ref; + final _$$ref$6 = task.ref; + final _$$ref$7 = didFinishCollectingMetrics.ref; 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, + 'NSURLSessionDownloadDelegate.URLSession:task:didFinishCollectingMetrics:', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0)), ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: true, - release: true, + if (!objc.respondsToSelector( + _$$ref$4.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didFinishCollectingMetrics:', + ); + } + _objc_msgSend_r8gdi7( + _$$ref$4.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + _$$ref$5.pointer, + _$$ref$6.pointer, + _$$ref$7.pointer, ); } - /// Creates a WebSocket task given the url. The given url must have a ws or wss scheme. - NSURLSessionWebSocketTask webSocketTaskWithURL(objc.NSURL url) { + /// 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, + }) { + final _$$ref$5 = object$.ref; + final _$$ref$6 = session.ref; + final _$$ref$7 = task.ref; + final _$$ref$8 = didReceiveChallenge.ref; + final _$$ref$9 = completionHandler.ref; 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, + 'NSURLSessionDownloadDelegate.URLSession:task:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: true, - release: true, + if (!objc.respondsToSelector( + _$$ref$5.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didReceiveChallenge:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + _$$ref$5.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + _$$ref$6.pointer, + _$$ref$7.pointer, + _$$ref$8.pointer, + _$$ref$9.pointer, ); } - /// 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, + /// Sent for each informational response received except 101 switching protocols. + void URLSession$11( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse didReceiveInformationalResponse, }) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = session.ref; + final _$$ref$6 = task.ref; + final _$$ref$7 = didReceiveInformationalResponse.ref; 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, + 'NSURLSessionDownloadDelegate.URLSession:task:didReceiveInformationalResponse:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), ); - return NSURLSessionWebSocketTask.fromPointer( - $ret, - retain: true, - release: true, + if (!objc.respondsToSelector( + _$$ref$4.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didReceiveInformationalResponse:', + ); + } + _objc_msgSend_r8gdi7( + _$$ref$4.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + _$$ref$5.pointer, + _$$ref$6.pointer, + _$$ref$7.pointer, ); } -} - -/// 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); + /// 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, + }) { + final _$$ref$3 = object$.ref; + final _$$ref$4 = session.ref; + final _$$ref$5 = task.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$3.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', + ); + } + _objc_msgSend_1modw1b( + _$$ref$3.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + _$$ref$4.pointer, + _$$ref$5.pointer, + didSendBodyData, + totalBytesSent, + totalBytesExpectedToSend, + ); + } - static NSURLSessionDelayedRequestDisposition fromValue(int value) => - switch (value) { - 0 => NSURLSessionDelayedRequestContinueLoading, - 1 => NSURLSessionDelayedRequestUseNewRequest, - 2 => NSURLSessionDelayedRequestCancel, - _ => throw ArgumentError( - 'Unknown value for NSURLSessionDelayedRequestDisposition: $value', - ), - }; -} + /// 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, + }) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = session.ref; + final _$$ref$6 = task.ref; + final _$$ref$7 = needNewBodyStream.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:needNewBodyStream:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$4.pointer, + _sel_URLSession_task_needNewBodyStream_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:needNewBodyStream:', + ); + } + _objc_msgSend_18qun1e( + _$$ref$4.pointer, + _sel_URLSession_task_needNewBodyStream_, + _$$ref$5.pointer, + _$$ref$6.pointer, + _$$ref$7.pointer, + ); + } -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. + /// 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. /// - /// 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, - ); + /// - 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, + }) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = session.ref; + final _$$ref$6 = task.ref; + final _$$ref$7 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$4.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + ); + } + _objc_msgSend_9cddqw( + _$$ref$4.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + _$$ref$5.pointer, + _$$ref$6.pointer, + needNewBodyStreamFromOffset, + _$$ref$7.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. + /// 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. /// - /// 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. + /// 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. /// - /// 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 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. /// - /// 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, + /// 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, }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - (int arg0) => fn(NSURLSessionResponseDisposition.fromValue(arg0)), - keepIsolateAlive, + final _$$ref$5 = object$.ref; + final _$$ref$6 = session.ref; + final _$$ref$7 = task.ref; + final _$$ref$8 = willBeginDelayedRequest.ref; + final _$$ref$9 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_16sve1d(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + if (!objc.respondsToSelector( + _$$ref$5.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:willBeginDelayedRequest:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + _$$ref$5.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + _$$ref$6.pointer, + _$$ref$7.pointer, + _$$ref$8.pointer, + _$$ref$9.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. + /// 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. /// - /// 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, + /// 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, }) { - 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, + final _$$ref$6 = object$.ref; + final _$$ref$7 = session.ref; + final _$$ref$8 = task.ref; + final _$$ref$9 = willPerformHTTPRedirection.ref; + final _$$ref$10 = newRequest.ref; + final _$$ref$11 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - } - - 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.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, - ) { - try { - (objc.getBlockClosure(block) as void Function(int))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); + if (!objc.respondsToSelector( + _$$ref$6.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + ); } + _objc_msgSend_e1wgee( + _$$ref$6.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + _$$ref$7.pointer, + _$$ref$8.pointer, + _$$ref$9.pointer, + _$$ref$10.pointer, + _$$ref$11.pointer, + ); } - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - >.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(); -} - -/// 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 _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(ffi.Long 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. + /// 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 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. + /// 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. /// - /// 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, + /// 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, }) { - 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 _$$ref$3 = object$.ref; + final _$$ref$4 = session.ref; + final _$$ref$5 = taskIsWaitingForConnectivity.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSession:taskIsWaitingForConnectivity:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_1otpo83(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + if (!objc.respondsToSelector( + _$$ref$3.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSession:taskIsWaitingForConnectivity:', + ); + } + _objc_msgSend_pfv6jd( + _$$ref$3.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + _$$ref$4.pointer, + _$$ref$5.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 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, + /// 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) { + final _$$ref$2 = object$.ref; + final _$$ref$3 = session.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + if (!objc.respondsToSelector( + _$$ref$2.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionDownloadDelegate', + 'URLSessionDidFinishEventsForBackgroundURLSession:', + ); + } + _objc_msgSend_xtuoz7( + _$$ref$2.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + _$$ref$3.pointer, ); } +} - 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, - ffi.Long, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Long, - 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()); - } - } +interface class NSURLSessionDownloadDelegate$Builder { + /// Returns the [objc.Protocol] object for this protocol. + static objc.Protocol get $protocol => + objc.Protocol.fromPointer(_protocol_NSURLSessionDownloadDelegate.cast()); - 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, - ) - >.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, - ) - >.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, - ); - 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(); -} - -/// 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); -} - -/// 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. + /// Builds an object that implements the NSURLSessionDownloadDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. /// - /// 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, + /// 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, - 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, + 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, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > - fromFunction( + 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( - 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, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > - listener( + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, 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); + 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), + ); } - /// 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. + /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. /// - /// 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, + /// 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, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - > - blocking( + 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( - ffi.Pointer, NSURLSession, - NSURLSessionDataTask, - NSURLResponse, - objc.ObjCBlock, - ) - fn, { - bool keepIsolateAlive = true, + 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 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, + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( - raw, - rawListener, - objc.objCContext, + NSURLSessionDownloadDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, ); - 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()); - } + 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); } - 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, + /// 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', ); - 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(int statusCode) { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.localizedStringForStatusCode:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, ); - final $ret = _objc_msgSend_qugqlf( - _class_NSHTTPURLResponse, - _sel_localizedStringForStatusCode_, - statusCode, + NSURLSessionDownloadDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, ); - 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, + NSURLSessionDownloadDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - } - - /// 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)), + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didFinishDownloadingToURL_.implementAsListener( + builder, + URLSession_downloadTask_didFinishDownloadingToURL_, ); - final $ret = _objc_msgSend_151sglz( - object$.ref.pointer, - _sel_allHeaderFields, + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_.implementAsListener( + builder, + URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, ); - 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)), + NSURLSessionDownloadDelegate$Builder + .URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_.implementAsListener( + builder, + URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didCompleteWithError_.implementAsListener( + builder, + URLSession_task_didCompleteWithError_, ); - 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, + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didFinishCollectingMetrics_.implementAsListener( + builder, + URLSession_task_didFinishCollectingMetrics_, ); - 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 int length, - objc.NSString? name, - }) { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.initWithURL:MIMEType:expectedContentLength:textEncodingName:', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_task_didReceiveChallenge_completionHandler_, ); - 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, + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didReceiveInformationalResponse_.implementAsListener( + builder, + URLSession_task_didReceiveInformationalResponse_, ); - 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 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)), + NSURLSessionDownloadDelegate$Builder + .URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_.implementAsListener( + builder, + URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, ); - 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, + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStream_.implementAsListener( + builder, + URLSession_task_needNewBodyStream_, ); - 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. - int get statusCode { - objc.checkOsVersionInternal( - 'NSHTTPURLResponse.statusCode', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 2, 0)), + NSURLSessionDownloadDelegate$Builder + .URLSession_task_needNewBodyStreamFromOffset_completionHandler_.implementAsListener( + builder, + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, ); - 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)), + NSURLSessionDownloadDelegate$Builder + .URLSession_task_willBeginDelayedRequest_completionHandler_.implementAsListener( + builder, + URLSession_task_willBeginDelayedRequest_completionHandler_, ); - final $ret = _objc_msgSend_1sotr3r( - object$.ref.pointer, - _sel_valueForHTTPHeaderField_, - field.ref.pointer, + 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), ); - 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. + /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will + /// be. /// - /// 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, + /// 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, - 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, + 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, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > - fromFunction( + 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( - 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, + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, + void Function( NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > - listener( + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, void Function( - ffi.Pointer, NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - fn, { - bool keepIsolateAlive = true, + 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 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, + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, ); - 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); + 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); } - /// 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. + /// 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 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, + /// 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, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - > - blocking( + 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( - ffi.Pointer, NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, - ) - fn, { - bool keepIsolateAlive = true, + 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 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 builder = objc.ObjCProtocolBuilder( + debugName: 'NSURLSessionDownloadDelegate', ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, + 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), ); - 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. + /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking + /// listeners will be. /// - /// 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, + /// 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, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > - fromFunction( + 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( - 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, + 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, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > - listener( + NSURLSessionTask, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, 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, + NSURLSessionTask, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - > - blocking( + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, void Function( - ffi.Pointer, NSURLSession, - NSURLSessionDataTask, - NSURLSessionStreamTask, - ) - fn, { - bool keepIsolateAlive = true, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + void Function(NSURLSession, NSURLSessionTask)? + URLSession_taskIsWaitingForConnectivity_, + void Function(NSURLSession)? + URLSessionDidFinishEventsForBackgroundURLSession_, + 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, + NSURLSessionDownloadDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, + NSURLSessionDownloadDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, ); - 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()); - } + 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); } - 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(); -} + /// 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, + ) + > + >(_1tf3our_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), + ), + ); -/// 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. + /// 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 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, - ) + /// 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) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didCreateTask_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_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), + ), ); - /// 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, + /// 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, - NSURLSessionDataTask, - objc.NSData, + 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), - NSURLSessionDataTask.fromPointer(arg2, retain: true, release: true), - objc.NSData.fromPointer(arg3, retain: true, release: true), - ), - keepIsolateAlive, + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, ), - 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, + ( + void Function( + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - >.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, + 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, ) - > - >() - .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, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), + ( + void Function( NSURLSession, - NSURLSessionDataTask, - objc.NSData, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - > { - 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, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLAuthenticationChallenge arg2, + objc.ObjCBlock + arg3, + ) => func(arg1, arg2, arg3), + ), ); -} -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, - ) + /// 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) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didFinishDownloadingToURL_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_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), + ), ); - /// 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, - ) + /// 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) >( - 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, + _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, + ) + > + >(_1tf3our_protocolTrampoline_ly2579) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_, + isRequired: false, + isInstanceMethod: true, ), - retain: false, - release: 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), + ), ); - /// 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, + /// 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, + ) + > + >(_1tf3our_protocolTrampoline_h68abb) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_, + isRequired: false, + isInstanceMethod: 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, + ( + 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, + ) + > + >(_1tf3our_protocolTrampoline_1tz5yf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didCompleteWithError_, + isRequired: false, + isInstanceMethod: 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); - } + (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), + ), + ); - 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()); - } + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - 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< + /// 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( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - >()(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, + >( + _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, + ) + > + >(_1tf3our_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, + NSURLSessionTask, + NSURLAuthenticationChallenge, + 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, + 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 _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); + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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) + /// 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) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _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, + ) + > + >(_1tf3our_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), + ), ); - /// 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) + /// 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, + ) >( - 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, + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_needNewBodyStream_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_needNewBodyStream_, + isRequired: false, + isInstanceMethod: true, ), - retain: false, - release: 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), + ), ); - /// 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. + /// 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. /// - /// 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< + /// - 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( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + NSURLSession, + NSURLSessionTask, + int, + objc.ObjCBlock, ) - >()(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, + >( + _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, + ) + > + >(_1tf3our_protocolTrampoline_jyim80) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( NSURLSession, NSURLSessionTask, + int, + objc.ObjCBlock, ) - > { - 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, + 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, ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.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, + ) + 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 _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. + /// 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. /// - /// 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, + /// 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, ) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _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, + ) + > + >(_1tf3our_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), + ), ); - /// 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. + /// 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. /// - /// 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, + /// 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, + 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, + _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, + ) + > + >(_1tf3our_protocolTrampoline_l2g8ke) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + isRequired: false, + isInstanceMethod: true, ), - 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); - } + ( + 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), + ), + ); - /// Creates a blocking block from a Dart function. + /// 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 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. + /// 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. /// - /// 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, + /// 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, + ) + > + >(_1tf3our_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSession_taskIsWaitingForConnectivity_, + isRequired: false, + isInstanceMethod: 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, + (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, + ) + > + >(_1tf3our_protocolTrampoline_18v1jvf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionDownloadDelegate, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + isRequired: false, + isInstanceMethod: true, ), - ), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( - raw, - rawListener, - objc.objCContext, + (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), + ), + ); +} + +/// 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)), ); - 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); + assert(isA(object$)); } - 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()); + /// 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$)); } - 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, - ); + /// Returns whether [obj] is an instance of [NSURLSessionDownloadTask]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionDownloadTask, + ); - /// 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, - ); + /// alloc + static NSURLSessionDownloadTask alloc() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionDownloadTask, + _sel_alloc, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + 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, + /// allocWithZone: + static NSURLSessionDownloadTask allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSessionDownloadTask, + _sel_allocWithZone_, + zone, ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, + return NSURLSessionDownloadTask.fromPointer( + $ret, 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, + /// new + static NSURLSessionDownloadTask new$() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionDownloadTask, + _sel_new, ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, + return NSURLSessionDownloadTask.fromPointer( + $ret, 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()); - } + /// Returns a new instance of NSURLSessionDownloadTask constructed with the default `new` method. + NSURLSessionDownloadTask() : this.as(new$().object$); +} - 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, +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, ) { - try { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } + final _$$ref = object$.ref; + final _$$ref$1 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadTask.cancelByProducingResumeData:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_cancelByProducingResumeData_, + _$$ref$1.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, - ) - >.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(); + /// init + NSURLSessionDownloadTask init() { + final _$$ref$9 = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionDownloadTask.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref$9.retainAndReturnPointer(), + _sel_init, + ); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: false, + release: true, + ); + } } -/// 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); +/// ! +/// @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_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, - ) - >(); +enum NSURLSessionResponseDisposition { + /// Cancel the load, this is the same as -[task cancel] + NSURLSessionResponseCancel(0), -/// 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); + /// Allow the load to continue + NSURLSessionResponseAllow(1), - /// 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, - ); + /// Turn this request into a download + NSURLSessionResponseBecomeDownload(2), - /// 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, - ); + /// Turn this task into a stream task + NSURLSessionResponseBecomeStream(3); - /// 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, + 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', ), - ), - keepIsolateAlive, + }; +} + +/// 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)), ); - 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, + /// 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)), ); - 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()); +/// 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$)); } - 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()); - } + /// 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$)); } - 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(); -} + /// Returns whether [obj] is an instance of [NSURLSessionTask]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionTask, + ); -/// 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, - ); -} + /// alloc + static NSURLSessionTask alloc() { + final $ret = _objc_msgSend_151sglz(_class_NSURLSessionTask, _sel_alloc); + return NSURLSessionTask.fromPointer($ret, retain: false, release: true); + } -/// 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 {} + /// 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); + } - /// 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) {} + /// 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$); } -/// 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 {} +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() { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.cancel', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_cancel); + } - /// 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) {} -} + /// countOfBytesClientExpectsToReceive + int get countOfBytesClientExpectsToReceive { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesClientExpectsToReceive', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + return _objc_msgSend_pysgoz( + _$$ref.pointer, + _sel_countOfBytesClientExpectsToReceive, + ); + } -/// 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, - ); + /// 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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesClientExpectsToSend', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + return _objc_msgSend_pysgoz( + _$$ref.pointer, + _sel_countOfBytesClientExpectsToSend, + ); + } - /// 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, - ); + /// number of byte bytes we expect to receive, usually derived from the Content-Length header of an HTTP response. + int get countOfBytesExpectedToReceive { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesExpectedToReceive', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_pysgoz( + _$$ref.pointer, + _sel_countOfBytesExpectedToReceive, + ); + } - /// 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, - ); + /// number of body bytes we expect to send, derived from the Content-Length of the HTTP request + int get countOfBytesExpectedToSend { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesExpectedToSend', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_pysgoz( + _$$ref.pointer, + _sel_countOfBytesExpectedToSend, + ); + } - /// 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, + /// number of body bytes already received + int get countOfBytesReceived { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesReceived', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_n8yd09(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_countOfBytesReceived); + } + + /// number of body bytes already sent + int get countOfBytesSent { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.countOfBytesSent', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_countOfBytesSent); } - /// Creates a blocking block from a Dart function. + /// may differ from originalRequest due to http server redirection + NSURLRequest? get currentRequest { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.currentRequest', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$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. /// - /// 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. + /// Cannot be modified after task resumes. Not supported on background session. /// - /// 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, + /// Delegate is strongly referenced until the task completes, after which it is + /// reset to `nil`. + NSURLSessionTaskDelegate? get delegate { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.delegate', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), ); - 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 $ret = _objc_msgSend_151sglz(_$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.earliestBeginDate', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_n8yd09( - raw, - rawListener, - objc.objCContext, + final $ret = _objc_msgSend_151sglz(_$$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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.error', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_error); + return $ret.address == 0 + ? null + : objc.NSError.fromPointer($ret, retain: true, release: true); + } + + /// init + NSURLSessionTask init() { + final _$$ref$10 = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + _$$ref$10.retainAndReturnPointer(), + _sel_init, ); + return NSURLSessionTask.fromPointer($ret, 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()); + /// may be nil if this is a stream task + NSURLRequest? get originalRequest { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.originalRequest', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_originalRequest); + return $ret.address == 0 + ? null + : NSURLRequest.fromPointer($ret, retain: true, release: true); } - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Long, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Long, - 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()); - } + /// 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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.prefersIncrementalDelivery', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), + ); + return _objc_msgSend_91o635( + _$$ref.pointer, + _sel_prefersIncrementalDelivery, + ); } - 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, - ) - >.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, - ) - >.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, - ); - 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(); -} + /// 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 { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.priority', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + return objc.useMsgSendVariants + ? _objc_msgSend_2cgrxlFpret(_$$ref.pointer, _sel_priority) + : _objc_msgSend_2cgrxl(_$$ref.pointer, _sel_priority); + } -/// 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); -} + /// progress + objc.NSProgress get progress { + final _$$ref$1 = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref$1.pointer, _sel_progress); + return objc.NSProgress.fromPointer($ret, retain: true, release: true); + } -late final _sel_URLSession_task_didReceiveChallenge_completionHandler_ = objc - .registerName("URLSession:task:didReceiveChallenge:completionHandler:"); + /// may be nil if no response has been received + NSURLResponse? get response { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.response', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_response); + return $ret.address == 0 + ? null + : NSURLResponse.fromPointer($ret, retain: true, release: true); + } -/// 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); + /// resume + void resume() { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.resume', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_resume); + } - /// 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, - ); + /// setCountOfBytesClientExpectsToReceive: + set countOfBytesClientExpectsToReceive(int value) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.setCountOfBytesClientExpectsToReceive:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + _objc_msgSend_17gvxvj( + _$$ref.pointer, + _sel_setCountOfBytesClientExpectsToReceive_, + value, + ); + } - /// Creates a block from a Dart function. + /// 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) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.setCountOfBytesClientExpectsToSend:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + _objc_msgSend_17gvxvj( + _$$ref.pointer, + _sel_setCountOfBytesClientExpectsToSend_, + value, + ); + } + + /// Sets a task-specific delegate. Methods not implemented on this delegate will + /// still be forwarded to the session delegate. /// - /// 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. + /// Cannot be modified after task resumes. Not supported on background session. /// - /// 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, - ); + /// Delegate is strongly referenced until the task completes, after which it is + /// reset to `nil`. + set delegate(NSURLSessionTaskDelegate? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.setDelegate:', + iOS: (false, (15, 0, 0)), + macOS: (false, (12, 0, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setDelegate_, + _$$ref$1?.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. + /// Start the network load for this task no earlier than the specified date. If + /// not specified, no start delay is used. /// - /// 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, + /// Only applies to tasks created from background NSURLSession instances; has no + /// effect for tasks created from other session types. + set earliestBeginDate(objc.NSDate? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.setEarliestBeginDate:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setEarliestBeginDate_, + _$$ref$1?.pointer ?? ffi.nullptr, ); - 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. + /// 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. /// - /// 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, + /// 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) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.setPrefersIncrementalDelivery:', + iOS: (false, (14, 5, 0)), + macOS: (false, (11, 3, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xx612k( - raw, - rawListener, - objc.objCContext, + _objc_msgSend_1s56lr9( + _$$ref.pointer, + _sel_setPrefersIncrementalDelivery_, + value, ); - 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()); + /// 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) { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.setPriority:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), + ); + _objc_msgSend_v5hmet(_$$ref.pointer, _sel_setPriority_, value); } - 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()); - } + /// The taskDescription property is available for the developer to + /// provide a descriptive label for the task. + set taskDescription(objc.NSString? value) { + final _$$ref = object$.ref; + final _$$ref$1 = value?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.setTaskDescription:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_setTaskDescription_, + _$$ref$1?.pointer ?? ffi.nullptr, + ); } - 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, - ); -} + /// The current state of the task within the session. + NSURLSessionTaskState get state { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.state', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_1vze0g9(_$$ref.pointer, _sel_state); + return NSURLSessionTaskState.fromValue($ret); + } -/// 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, - ); + /// 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() { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.suspend', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + _objc_msgSend_1pl9qdv(_$$ref.pointer, _sel_suspend); + } - /// 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, - ); + /// The taskDescription property is available for the developer to + /// provide a descriptive label for the task. + objc.NSString? get taskDescription { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.taskDescription', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_taskDescription); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, 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, - ); + /// an identifier for this task, assigned by and unique to the owning session + int get taskIdentifier { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionTask.taskIdentifier', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + return _objc_msgSend_xw2lbc(_$$ref.pointer, _sel_taskIdentifier); + } +} - /// 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, +/// NSURLSessionTaskAdditions +extension NSURLSessionTaskAdditions on NSURLCache { + /// getCachedResponseForDataTask:completionHandler: + void getCachedResponseForDataTask( + NSURLSessionDataTask dataTask, { + required objc.ObjCBlock + completionHandler, }) { - 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 _$$ref = object$.ref; + final _$$ref$1 = dataTask.ref; + final _$$ref$2 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLCache.getCachedResponseForDataTask:completionHandler:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_xtuoz7(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + _objc_msgSend_o762yo( + _$$ref.pointer, + _sel_getCachedResponseForDataTask_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.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 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, + /// removeCachedResponseForDataTask: + void removeCachedResponseForDataTask(NSURLSessionDataTask dataTask) { + final _$$ref = object$.ref; + final _$$ref$1 = dataTask.ref; + objc.checkOsVersionInternal( + 'NSURLCache.removeCachedResponseForDataTask:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn( - arg0.address == 0 - ? null - : objc.NSInputStream.fromPointer( - arg0, - retain: false, - release: true, - ), - ), - keepIsolateAlive, + _objc_msgSend_xtuoz7( + _$$ref.pointer, + _sel_removeCachedResponseForDataTask_, + _$$ref$1.pointer, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_xtuoz7( - raw, - rawListener, - objc.objCContext, + } + + /// storeCachedResponse:forDataTask: + void storeCachedResponse$1( + NSCachedURLResponse cachedResponse, { + required NSURLSessionDataTask forDataTask, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = cachedResponse.ref; + final _$$ref$2 = forDataTask.ref; + objc.checkOsVersionInternal( + 'NSURLCache.storeCachedResponse:forDataTask:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0)), ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock( - wrapper, - retain: false, - release: true, + _objc_msgSend_pfv6jd( + _$$ref.pointer, + _sel_storeCachedResponse_forDataTask_, + _$$ref$1.pointer, + _$$ref$2.pointer, ); } +} - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - ) { - (objc.getBlockClosure(block) - as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); - } +/// 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; - 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()); - } + /// 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); +} + +/// 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)), + ); } - 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(); + /// 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)), + ); + } } -/// 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); +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_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, - ) - >(); +/// 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)), + ); + } -/// 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, { + /// Constructs a [NSURLSessionUploadTask] that wraps the given raw object pointer. + NSURLSessionUploadTask.fromPointer( + ffi.Pointer other, { bool retain = false, bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, - ) - >(pointer, retain: retain, release: release); + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionUploadTask', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + } +} - /// 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, - ); +/// 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; +} - /// 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, - ); +/// 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; - /// 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, + /// 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, }) { - 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 _$$ref$6 = object$.ref; + final _$$ref$7 = session.ref; + final _$$ref$8 = didBecomeInvalidWithError?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:didBecomeInvalidWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$6.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:didBecomeInvalidWithError:', + ); + } + _objc_msgSend_pfv6jd( + _$$ref$6.pointer, + _sel_URLSession_didBecomeInvalidWithError_, + _$$ref$7.pointer, + _$$ref$8?.pointer ?? ffi.nullptr, ); - 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. + /// 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. /// - /// 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, + /// 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, }) { - 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 _$$ref$6 = object$.ref; + final _$$ref$7 = session.ref; + final _$$ref$8 = didCreateTask.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:didCreateTask:', + iOS: (false, (16, 0, 0)), + macOS: (false, (13, 0, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_bklti2( - raw, - rawListener, - objc.objCContext, + if (!objc.respondsToSelector( + _$$ref$6.pointer, + _sel_URLSession_didCreateTask_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:didCreateTask:', + ); + } + _objc_msgSend_pfv6jd( + _$$ref$6.pointer, + _sel_URLSession_didCreateTask_, + _$$ref$7.pointer, + _$$ref$8.pointer, ); - 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()); + /// 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, + }) { + final _$$ref$8 = object$.ref; + final _$$ref$9 = session.ref; + final _$$ref$10 = didReceiveChallenge.ref; + final _$$ref$11 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$8.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:didReceiveChallenge:completionHandler:', + ); + } + _objc_msgSend_18qun1e( + _$$ref$8.pointer, + _sel_URLSession_didReceiveChallenge_completionHandler_, + _$$ref$9.pointer, + _$$ref$10.pointer, + _$$ref$11.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, - ) - >.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()); + /// 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, + }) { + final _$$ref$8 = object$.ref; + final _$$ref$9 = session.ref; + final _$$ref$10 = task.ref; + final _$$ref$11 = didCompleteWithError?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didCompleteWithError:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$8.pointer, + _sel_URLSession_task_didCompleteWithError_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didCompleteWithError:', + ); } + _objc_msgSend_r8gdi7( + _$$ref$8.pointer, + _sel_URLSession_task_didCompleteWithError_, + _$$ref$9.pointer, + _$$ref$10.pointer, + _$$ref$11?.pointer ?? ffi.nullptr, + ); } - 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, + /// Sent when complete statistics information has been collected for the task. + void URLSession$9( + NSURLSession session, { + required NSURLSessionTask task, + required NSURLSessionTaskMetrics didFinishCollectingMetrics, + }) { + final _$$ref$8 = object$.ref; + final _$$ref$9 = session.ref; + final _$$ref$10 = task.ref; + final _$$ref$11 = didFinishCollectingMetrics.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didFinishCollectingMetrics:', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$8.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didFinishCollectingMetrics:', ); -} - -late final _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = - objc.registerName( - "URLSession:task:needNewBodyStreamFromOffset:completionHandler:", + } + _objc_msgSend_r8gdi7( + _$$ref$8.pointer, + _sel_URLSession_task_didFinishCollectingMetrics_, + _$$ref$9.pointer, + _$$ref$10.pointer, + _$$ref$11.pointer, ); -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); + /// 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, + }) { + final _$$ref$10 = object$.ref; + final _$$ref$11 = session.ref; + final _$$ref$12 = task.ref; + final _$$ref$13 = didReceiveChallenge.ref; + final _$$ref$14 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didReceiveChallenge:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$10.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didReceiveChallenge:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + _$$ref$10.pointer, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + _$$ref$11.pointer, + _$$ref$12.pointer, + _$$ref$13.pointer, + _$$ref$14.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, - 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, + /// Sent for each informational response received except 101 switching protocols. + void URLSession$11( + NSURLSession session, { + required NSURLSessionTask task, + required NSHTTPURLResponse didReceiveInformationalResponse, + }) { + final _$$ref$8 = object$.ref; + final _$$ref$9 = session.ref; + final _$$ref$10 = task.ref; + final _$$ref$11 = didReceiveInformationalResponse.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didReceiveInformationalResponse:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$8.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didReceiveInformationalResponse:', ); + } + _objc_msgSend_r8gdi7( + _$$ref$8.pointer, + _sel_URLSession_task_didReceiveInformationalResponse_, + _$$ref$9.pointer, + _$$ref$10.pointer, + _$$ref$11.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( - 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, + /// 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, + }) { + final _$$ref$6 = object$.ref; + final _$$ref$7 = session.ref; + final _$$ref$8 = task.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$6.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:', ); + } + _objc_msgSend_1modw1b( + _$$ref$6.pointer, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + _$$ref$7.pointer, + _$$ref$8.pointer, + didSendBodyData, + totalBytesSent, + totalBytesExpectedToSend, + ); + } - /// 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, + /// 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, }) { - 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 _$$ref$8 = object$.ref; + final _$$ref$9 = session.ref; + final _$$ref$10 = task.ref; + final _$$ref$11 = needNewBodyStream.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:needNewBodyStream:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$8.pointer, + _sel_URLSession_task_needNewBodyStream_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:needNewBodyStream:', + ); + } + _objc_msgSend_18qun1e( + _$$ref$8.pointer, + _sel_URLSession_task_needNewBodyStream_, + _$$ref$9.pointer, + _$$ref$10.pointer, + _$$ref$11.pointer, ); - 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. + /// 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. /// - /// 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. + /// - 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, + }) { + final _$$ref$8 = object$.ref; + final _$$ref$9 = session.ref; + final _$$ref$10 = task.ref; + final _$$ref$11 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + iOS: (false, (17, 0, 0)), + macOS: (false, (14, 0, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$8.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:needNewBodyStreamFromOffset:completionHandler:', + ); + } + _objc_msgSend_9cddqw( + _$$ref$8.pointer, + _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + _$$ref$9.pointer, + _$$ref$10.pointer, + needNewBodyStreamFromOffset, + _$$ref$11.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. /// - /// 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, + /// 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, }) { - 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 _$$ref$10 = object$.ref; + final _$$ref$11 = session.ref; + final _$$ref$12 = task.ref; + final _$$ref$13 = willBeginDelayedRequest.ref; + final _$$ref$14 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:willBeginDelayedRequest:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_jyim80( - raw, - rawListener, - objc.objCContext, + if (!objc.respondsToSelector( + _$$ref$10.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:willBeginDelayedRequest:completionHandler:', + ); + } + _objc_msgSend_m7tls4( + _$$ref$10.pointer, + _sel_URLSession_task_willBeginDelayedRequest_completionHandler_, + _$$ref$11.pointer, + _$$ref$12.pointer, + _$$ref$13.pointer, + _$$ref$14.pointer, ); - 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()); + /// 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, + }) { + final _$$ref$12 = object$.ref; + final _$$ref$13 = session.ref; + final _$$ref$14 = task.ref; + final _$$ref$15 = willPerformHTTPRedirection.ref; + final _$$ref$16 = newRequest.ref; + final _$$ref$17 = completionHandler.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$12.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:', + ); + } + _objc_msgSend_e1wgee( + _$$ref$12.pointer, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + _$$ref$13.pointer, + _$$ref$14.pointer, + _$$ref$15.pointer, + _$$ref$16.pointer, + _$$ref$17.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.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()); + /// 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, + }) { + final _$$ref$6 = object$.ref; + final _$$ref$7 = session.ref; + final _$$ref$8 = taskIsWaitingForConnectivity.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:taskIsWaitingForConnectivity:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0)), + ); + if (!objc.respondsToSelector( + _$$ref$6.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:taskIsWaitingForConnectivity:', + ); } + _objc_msgSend_pfv6jd( + _$$ref$6.pointer, + _sel_URLSession_taskIsWaitingForConnectivity_, + _$$ref$7.pointer, + _$$ref$8.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.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(); -} + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = webSocketTask.ref; + final _$$ref$3 = reason?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:webSocketTask:didCloseWithCode:reason:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_webSocketTask_didCloseWithCode_reason_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:webSocketTask:didCloseWithCode:reason:', + ); + } + _objc_msgSend_d9bpjb( + _$$ref.pointer, + _sel_URLSession_webSocketTask_didCloseWithCode_reason_, + _$$ref$1.pointer, + _$$ref$2.pointer, + didCloseWithCode, + _$$ref$3?.pointer ?? ffi.nullptr, + ); + } -/// 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, + /// 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, + }) { + final _$$ref = object$.ref; + final _$$ref$1 = session.ref; + final _$$ref$2 = webSocketTask.ref; + final _$$ref$3 = didOpenWithProtocol?.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSession:webSocketTask:didOpenWithProtocol:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + if (!objc.respondsToSelector( + _$$ref.pointer, + _sel_URLSession_webSocketTask_didOpenWithProtocol_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSession:webSocketTask:didOpenWithProtocol:', ); -} + } + _objc_msgSend_r8gdi7( + _$$ref.pointer, + _sel_URLSession_webSocketTask_didOpenWithProtocol_, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3?.pointer ?? ffi.nullptr, + ); + } -late final _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = - objc.registerName( - "URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:", + /// 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) { + final _$$ref$4 = object$.ref; + final _$$ref$5 = session.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketDelegate.URLSessionDidFinishEventsForBackgroundURLSession:', + iOS: (false, (7, 0, 0)), + macOS: (false, (11, 0, 0)), ); -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, - ) - >(); + if (!objc.respondsToSelector( + _$$ref$4.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + )) { + throw objc.UnimplementedOptionalMethodException( + 'NSURLSessionWebSocketDelegate', + 'URLSessionDidFinishEventsForBackgroundURLSession:', + ); + } + _objc_msgSend_xtuoz7( + _$$ref$4.pointer, + _sel_URLSessionDidFinishEventsForBackgroundURLSession_, + _$$ref$5.pointer, + ); + } +} -/// 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); +interface class NSURLSessionWebSocketDelegate$Builder { + /// Returns the [objc.Protocol] object for this protocol. + static objc.Protocol get $protocol => + objc.Protocol.fromPointer(_protocol_NSURLSessionWebSocketDelegate.cast()); - /// Creates a block from a C function pointer. + /// Builds an object that implements the NSURLSessionWebSocketDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. /// - /// 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, + /// 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, - 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, + 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, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - fromFunction( + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, 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, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( NSURLSession, NSURLSessionTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) - > - listener( + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, void Function( - ffi.Pointer, NSURLSession, NSURLSessionTask, - int, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, + 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 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 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), ); - 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. + /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. /// - /// 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( + /// 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( - ffi.Pointer, NSURLSession, - NSURLSessionTask, - int, - int, - int, - ) - fn, { - bool keepIsolateAlive = true, + 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 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, + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implement( + builder, + URLSession_didBecomeInvalidWithError_, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_h68abb( - raw, - rawListener, - objc.objCContext, + NSURLSessionWebSocketDelegate$Builder.URLSession_didCreateTask_.implement( + builder, + URLSession_didCreateTask_, ); - 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()); - } + 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); } - 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. + /// 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. /// - /// 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, + /// 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, - 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, + 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, - NSHTTPURLResponse, - ) - > - fromFunction( + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, 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, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( NSURLSession, NSURLSessionTask, - NSHTTPURLResponse, - ) - > - listener( + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, void Function( - ffi.Pointer, NSURLSession, NSURLSessionTask, NSHTTPURLResponse, - ) - fn, { - bool keepIsolateAlive = true, + 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 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 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), ); - 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. + /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will + /// be. /// - /// 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, + /// 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, - NSHTTPURLResponse, - ) - > - blocking( + 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( - ffi.Pointer, NSURLSession, NSURLSessionTask, NSHTTPURLResponse, - ) - fn, { - bool keepIsolateAlive = true, + 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 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, + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsListener( + builder, + URLSession_didBecomeInvalidWithError_, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, + NSURLSessionWebSocketDelegate$Builder + .URLSession_didCreateTask_.implementAsListener( + builder, + URLSession_didCreateTask_, ); - 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)), + NSURLSessionWebSocketDelegate$Builder + .URLSession_didReceiveChallenge_completionHandler_.implementAsListener( + builder, + URLSession_didReceiveChallenge_completionHandler_, ); - } - - /// 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)), + 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); } -} - -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, + /// 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, - 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, + 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, - NSURLSessionTaskMetrics, - ) - > - fromFunction( + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStream_, 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, + int, + objc.ObjCBlock, + )? + URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + void Function( NSURLSession, NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - > - listener( + NSURLRequest, + objc.ObjCBlock, + )? + URLSession_task_willBeginDelayedRequest_completionHandler_, void Function( - ffi.Pointer, NSURLSession, NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - fn, { - bool keepIsolateAlive = true, + 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 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 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), ); - 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. + /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking + /// listeners will be. /// - /// 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( + /// 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( - ffi.Pointer, NSURLSession, NSURLSessionTask, - NSURLSessionTaskMetrics, - ) - fn, { - bool keepIsolateAlive = true, + 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 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, + NSURLSessionWebSocketDelegate$Builder + .URLSession_didBecomeInvalidWithError_.implementAsBlocking( + builder, + URLSession_didBecomeInvalidWithError_, ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_1tz5yf( - raw, - rawListener, - objc.objCContext, + NSURLSessionWebSocketDelegate$Builder + .URLSession_didCreateTask_.implementAsBlocking( + builder, + URLSession_didCreateTask_, ); - 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()); + 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); } - 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 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, + ) + > + >(_1tf3our_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), + ), + ); - 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< + /// 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, + ) + > + >(_1tf3our_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( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - >()(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, + >( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( NSURLSession, - NSURLSessionTask, - NSURLSessionTaskMetrics, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - > { - 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, + 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 _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); + /// 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, + ) + > + >(_1tf3our_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), + ), + ); - /// 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?, - ) + /// Sent when complete statistics information has been collected for the task. + static final URLSession_task_didFinishCollectingMetrics_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didFinishCollectingMetrics_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_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), + ), ); - /// 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, + /// 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, - objc.NSError?, + 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), - NSURLSessionTask.fromPointer(arg2, retain: true, release: true), - arg3.address == 0 - ? null - : objc.NSError.fromPointer(arg3, retain: true, release: true), - ), - keepIsolateAlive, + _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, + ) + > + >(_1tf3our_protocolTrampoline_xx612k) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didReceiveChallenge_completionHandler_, + isRequired: false, + isInstanceMethod: true, ), - 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, + ( + void Function( + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - >.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, + 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, ) - > - >() - .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, + 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, - objc.NSError?, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - > { - 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); + 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), + ), + ); - /// 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?) + /// Sent for each informational response received except 101 switching protocols. + static final URLSession_task_didReceiveInformationalResponse_ = + objc.ObjCProtocolListenableMethod< + void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didReceiveInformationalResponse_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1tf3our_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), + ), ); - /// 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?) + /// 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) >( - 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, + _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, + ) + > + >(_1tf3our_protocolTrampoline_h68abb) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + isRequired: false, + isInstanceMethod: true, ), - retain: false, - release: 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), + ), ); - /// 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, + /// 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, + ) + > + >(_1tf3our_protocolTrampoline_bklti2) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_needNewBodyStream_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, ) - >.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, + 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, ) - >.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, + 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, ) - > - >() - .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, + func, + ) => + ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask_ffiVoidNSInputStream.blocking( + ( + ffi.Pointer _, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.ObjCBlock arg3, + ) => func(arg1, arg2, arg3), + ), ); -} -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, + /// 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, - 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, + NSURLSessionTask, + int, + objc.ObjCBlock, ) >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, + _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, + ) + > + >(_1tf3our_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), + ), ); - /// Creates a block from a Dart function. + /// 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. /// - /// 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. + /// 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 `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, + /// 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, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + NSURLSessionTask, + NSURLRequest, + 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, + _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, + ) + > + >(_1tf3our_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), ), - ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( - arg3, - retain: true, - release: true, + ( + 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), ), - ), - 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. + /// 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. /// - /// 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, + /// 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, + ) + > + >(_1tf3our_protocolTrampoline_l2g8ke) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, + isRequired: false, + isInstanceMethod: 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); - } + ( + 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), + ), + ); - /// Creates a blocking block from a Dart function. + /// 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 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. + /// 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. /// - /// 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, + /// 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, + ) + > + >(_1tf3our_protocolTrampoline_fjrv01) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_taskIsWaitingForConnectivity_, + isRequired: false, + isInstanceMethod: 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()); - } - } + (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), + ), + ); - 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< + /// 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( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + int, + objc.NSData?, ) - >()(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, + >( + _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, + ) + > + >(_1tf3our_protocolTrampoline_1lx650f) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSURLSessionWebSocketDelegate, + _sel_URLSession_webSocketTask_didCloseWithCode_reason_, + isRequired: false, + isInstanceMethod: true, + ), + ( + void Function( NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + NSURLSessionWebSocketTask, + int, + objc.NSData?, ) - > { - 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, + 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), + ), ); -} -late final _sel_URLSessionDidFinishEventsForBackgroundURLSession_ = objc - .registerName("URLSessionDidFinishEventsForBackgroundURLSession:"); + /// 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, + ) + > + >(_1tf3our_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), + ), + ); -/// 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, { + /// 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, + ) + > + >(_1tf3our_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), + ), + ); +} + +/// 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, - }) => objc.ObjCBlock, NSURLSession)>( - pointer, - retain: retain, - release: release, - ); + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + assert(isA(object$)); + } - /// 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, - ); + /// Returns whether [obj] is an instance of [NSURLSessionWebSocketMessage]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLSessionWebSocketMessage, + ); - /// 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, - ); + /// alloc + static NSURLSessionWebSocketMessage alloc() { + final $ret = _objc_msgSend_151sglz( + _class_NSURLSessionWebSocketMessage, + _sel_alloc, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + 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, + /// 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, ); - 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, +extension NSURLSessionWebSocketMessage$Methods on NSURLSessionWebSocketMessage { + /// data + objc.NSData? get data { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.data', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - ), - keepIsolateAlive, + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_data); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); + } + + /// Create a message with data type + NSURLSessionWebSocketMessage initWithData(objc.NSData data) { + final _$$ref = object$.ref; + final _$$ref$1 = data.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.initWithData:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); - final wrapper = _NativeCupertinoHttp_wrapBlockingBlock_18v1jvf( - raw, - rawListener, - objc.objCContext, + final $ret = _objc_msgSend_1sotr3r( + _$$ref.retainAndReturnPointer(), + _sel_initWithData_, + _$$ref$1.pointer, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: false, + release: true, ); - 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()); + /// Create a message with string type + NSURLSessionWebSocketMessage initWithString(objc.NSString string) { + final _$$ref = object$.ref; + final _$$ref$1 = string.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.initWithString:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1sotr3r( + _$$ref.retainAndReturnPointer(), + _sel_initWithString_, + _$$ref$1.pointer, + ); + return NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: false, + release: true, + ); } - 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()); - } + /// string + objc.NSString? get string { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.string', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_string); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); } - 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(); + /// type + NSURLSessionWebSocketMessageType get type { + final _$$ref = object$.ref; + objc.checkOsVersionInternal( + 'NSURLSessionWebSocketMessage.type', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), + ); + final $ret = _objc_msgSend_1qouven(_$$ref.pointer, _sel_type); + return NSURLSessionWebSocketMessageType.fromValue($ret); + } } -/// 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); +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', + ), + }; } -/// 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; +/// 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 [NSURLSessionDataDelegate] that wraps the given raw object pointer. - NSURLSessionDataDelegate.fromPointer( + /// Constructs a [NSURLSessionWebSocketTask] that wraps the given raw object pointer. + NSURLSessionWebSocketTask.fromPointer( ffi.Pointer other, { bool retain = false, bool release = false, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); + }) : 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 [NSURLSessionDataDelegate]. - static bool conformsTo(objc.ObjCObject obj) { - return _objc_msgSend_e3qsqz( - obj.ref.pointer, - _sel_conformsToProtocol_, - _protocol_NSURLSessionDataDelegate, + /// Returns whether [obj] is an instance of [NSURLSessionWebSocketTask]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _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, ); } -} -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)), + /// allocWithZone: + static NSURLSessionWebSocketTask allocWithZone( + ffi.Pointer zone, + ) { + final $ret = _objc_msgSend_1cwp428( + _class_NSURLSessionWebSocketTask, + _sel_allocWithZone_, + zone, ); - 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, + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: false, + release: true, ); } +} - /// 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, - }) { +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}) { + final _$$ref = object$.ref; + final _$$ref$1 = reason?.ref; objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:dataTask:didBecomeStreamTask:', - iOS: (false, (9, 0, 0)), - macOS: (false, (10, 11, 0)), + 'NSURLSessionWebSocketTask.cancelWithCloseCode:reason:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 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, + _objc_msgSend_tqzk0b( + _$$ref.pointer, + _sel_cancelWithCloseCode_reason_, + closeCode, + _$$ref$1?.pointer ?? ffi.nullptr, ); } - /// 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, - }) { + /// 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 { + final _$$ref = object$.ref; 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, + 'NSURLSessionWebSocketTask.closeCode', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); + return _objc_msgSend_1rhk8uh(_$$ref.pointer, _sel_closeCode); } - /// 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, - }) { + /// 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 { + final _$$ref = object$.ref; 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, + 'NSURLSessionWebSocketTask.closeReason', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_closeReason); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); } - /// 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, - }) { + /// 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 { + final _$$ref = object$.ref; 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, + 'NSURLSessionWebSocketTask.maximumMessageSize', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); + return _objc_msgSend_1hz7y9r(_$$ref.pointer, _sel_maximumMessageSize); } - /// 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, - }) { + /// 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, + ) { + final _$$ref = object$.ref; + final _$$ref$1 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:didBecomeInvalidWithError:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + 'NSURLSessionWebSocketTask.receiveMessageWithCompletionHandler:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 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, + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_receiveMessageWithCompletionHandler_, + _$$ref$1.pointer, ); } - /// 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, + /// 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, }) { + final _$$ref = object$.ref; + final _$$ref$1 = message.ref; + final _$$ref$2 = completionHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:didCreateTask:', - iOS: (false, (16, 0, 0)), - macOS: (false, (13, 0, 0)), + 'NSURLSessionWebSocketTask.sendMessage:completionHandler:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 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, + _objc_msgSend_o762yo( + _$$ref.pointer, + _sel_sendMessage_completionHandler_, + _$$ref$1.pointer, + _$$ref$2.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, - }) { + /// 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, + ) { + final _$$ref = object$.ref; + final _$$ref$1 = pongReceiveHandler.ref; objc.checkOsVersionInternal( - 'NSURLSessionDataDelegate.URLSession:didReceiveChallenge:completionHandler:', - iOS: (false, (7, 0, 0)), - macOS: (false, (10, 9, 0)), + 'NSURLSessionWebSocketTask.sendPingWithPongReceiveHandler:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 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, + _objc_msgSend_f167m6( + _$$ref.pointer, + _sel_sendPingWithPongReceiveHandler_, + _$$ref$1.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, - }) { + /// 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) { + final _$$ref = object$.ref; 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, + 'NSURLSessionWebSocketTask.setMaximumMessageSize:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0)), ); + _objc_msgSend_4sp4xj(_$$ref.pointer, _sel_setMaximumMessageSize_, value); } +} - /// 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, - ); - } +/// 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, + ); - /// 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, - ); - } + /// 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, + ); - /// Sent for each informational response received except 101 switching protocols. - void URLSession$11( - NSURLSession session, { - required NSURLSessionTask task, - required NSHTTPURLResponse didReceiveInformationalResponse, + /// 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, () { + return fn(); + }, keepIsolateAlive), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, }) { - 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, + return objc.ObjCBlock( + objc.newBlockPort( + _1tf3our_wrapListenerBlock_1pl9qdv, + (ffi.Pointer rawArgs) => fn(), + keepIsolateAlive, + ), + retain: false, + 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, + /// 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 (ie returning Future) 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, }) { - 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, + return objc.ObjCBlock( + objc.newBlockingBlockPort( + _1tf3our_wrapBlockingBlock_1pl9qdv, + (ffi.Pointer rawArgs) => fn(), + keepIsolateAlive, + ), + retain: false, + 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( - '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, + 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() { + return ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer block) + > + >() + .asFunction)>()( + 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. +/// 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. /// - /// - 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, - ); - } + /// 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, + ); - /// 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. + /// Creates a block from a Dart function. /// - /// 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. + /// 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 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. + /// 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, + ) { + return fn(objc.NSArray.fromPointer(arg0, retain: true, release: true)); + }, keepIsolateAlive), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. /// - /// 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// - /// 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, + /// 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, }) { - 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, + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1ucj4uc.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + 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. + /// Creates a blocking block from a Dart function. /// - /// 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 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 (ie returning Future) are not supported. /// - /// 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, + /// 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, }) { - 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, + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1ucj4uc.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + 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( - '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, - ); + 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) { + final _$$ref = arg0.ref; + return 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, _$$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()); +/// 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); - /// Builds an object that implements the NSURLSessionDataDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. + /// Creates a block from a C function pointer. /// - /// 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, + /// 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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 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), + return objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_r8gdi7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_ih4kg4.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + release: true, ); } - /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. + /// Creates a blocking block from a Dart function. /// - /// 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, + /// 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 (ie returning Future) 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, }) { - 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_, + return objc.ObjCBlock< + ffi.Void Function(objc.NSArray, objc.NSArray, objc.NSArray) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_r8gdi7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_ih4kg4.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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. + 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) { + final _$$ref = arg0.ref; + final _$$ref$1 = arg1.ref; + final _$$ref$2 = arg2.ref; + return 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, _$$ref.pointer, _$$ref$1.pointer, _$$ref$2.pointer); + } +} + +/// 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. /// - /// 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, + /// 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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 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), + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_wtbfzi.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, ); } - /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will - /// be. + /// Creates a blocking block from a Dart function. /// - /// 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, + /// 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 (ie returning Future) 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, }) { - 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_, + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_wtbfzi.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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. + 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) { + final _$$ref = arg0?.ref; + return 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, _$$ref?.pointer ?? ffi.nullptr); + } +} + +/// 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. /// - /// 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, + /// 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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 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), + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_lsc494.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, ); } - /// Adds the implementation of the NSURLSessionDataDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking - /// listeners will be. + /// Creates a blocking block from a Dart function. /// - /// 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, + /// 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 (ie returning Future) 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, }) { - 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_, + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_lsc494.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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), - ), - ( + 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) { + final _$$ref = arg0?.ref; + return ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< void Function( - NSURLSession, - NSURLSessionDataTask, - NSURLSessionDownloadTask, + ffi.Pointer, + ffi.Pointer, ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDataTask_NSURLSessionDownloadTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionDataTask arg2, - NSURLSessionDownloadTask arg3, - ) => func(arg1, arg2, arg3), - ), - ); + >()(ref.pointer, _$$ref?.pointer ?? ffi.nullptr); + } +} - /// 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. +/// 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. /// - /// 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, + /// 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?) >( - _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), - ), + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, ); - /// 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) + /// 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?) >( - _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), - ), + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) { + return 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, ); - /// 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. + /// Creates a listener block from a Dart function. /// - /// 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), - ), - ); + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_r8gdi7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1mv87bk.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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< + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function(objc.NSData?, NSURLResponse?, objc.NSError?) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_r8gdi7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1mv87bk.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >( - _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), - ), - ( + >()(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) { + final _$$ref = arg0?.ref; + final _$$ref$1 = arg1?.ref; + final _$$ref$2 = arg2?.ref; + return 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( - NSURLSession, - NSURLSessionDataTask, - NSCachedURLResponse, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - 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), - ), - ); + >()( + ref.pointer, + _$$ref?.pointer ?? ffi.nullptr, + _$$ref$1?.pointer ?? ffi.nullptr, + _$$ref$2?.pointer ?? ffi.nullptr, + ); + } +} - /// 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), - ), - ); +/// 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, + ); - /// 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. + /// Creates a block from a C function pointer. /// - /// 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), - ), + /// 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, + ) { + return fn( + arg0.address == 0 + ? null + : objc.NSError.fromPointer(arg0, retain: true, release: true), ); + }, keepIsolateAlive), + retain: false, + 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_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), - ), - ( + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_117e0ww.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_117e0ww.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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) { + final _$$ref = arg0?.ref; + return ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< void Function( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, ) - 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), - ), - ); + >()(ref.pointer, _$$ref?.pointer ?? ffi.nullptr); + } +} - /// 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), - ), - ); +/// 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, + ); - /// 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), - ), + /// 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, + ) { + return fn( + arg0.address == 0 + ? null + : objc.NSInputStream.fromPointer(arg0, retain: true, release: true), ); + }, keepIsolateAlive), + retain: false, + 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_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), - ), - ); + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1ura76.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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), - ), - ); + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + 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_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), - ), - ); + /// 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1ura76.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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, - ), - ( + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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) { + final _$$ref = arg0?.ref; + return ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< void Function( - NSURLSession, - NSURLSessionTask, - objc.ObjCBlock, + ffi.Pointer, + 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, - ) - 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), - ), - ); + >()(ref.pointer, _$$ref?.pointer ?? ffi.nullptr); + } +} - /// 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. +/// 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. /// - /// - 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), - ), + /// 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, + ) { + return fn( + arg0.address == 0 + ? null + : NSURLRequest.fromPointer(arg0, retain: true, release: true), ); + }, keepIsolateAlive), + retain: false, + 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. + /// Creates a listener block from a Dart function. /// - /// 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// - /// 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. + /// 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, + }) { + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1n6ph2.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + /// Creates a blocking block from a Dart function. /// - /// 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), - ), - ( + /// 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xtuoz7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1n6ph2.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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) { + final _$$ref = arg0?.ref; + return ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< void Function( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, ) - 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), - ), - ); + >()(ref.pointer, _$$ref?.pointer ?? ffi.nullptr); + } +} - /// 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. +/// 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. /// - /// 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), - ), - ); + /// 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, + ); - /// 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. + /// Creates a block from a Dart function. /// - /// 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 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. /// - /// 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 `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, + ) { + return fn( + NSURLSessionAuthChallengeDisposition.fromValue(arg0), + arg1.address == 0 + ? null + : NSURLCredential.fromPointer(arg1, retain: true, release: true), ); + }, keepIsolateAlive), + retain: false, + 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_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), - ), + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_n8yd09, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_u65oe8.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_n8yd09, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_u65oe8.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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, ); + 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 _protocol_NSURLSessionDownloadDelegate = objc.getProtocol( - "NSURLSessionDownloadDelegate", -); -late final _sel_URLSession_downloadTask_didFinishDownloadingToURL_ = objc - .registerName("URLSession:downloadTask:didFinishDownloadingToURL:"); +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential$CallExtension + on objc.ObjCBlock { + void call(NSURLSessionAuthChallengeDisposition arg0, NSURLCredential? arg1) { + final _$$ref = arg1?.ref; + return 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, _$$ref?.pointer ?? ffi.nullptr); + } +} -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, objc.NSURL)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_NSURL { +/// 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< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - > - fromPointer( + static objc.ObjCBlock 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); + }) => 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, - NSURLSessionDownloadTask, - objc.NSURL, - ) - > + static objc.ObjCBlock fromFunctionPointer( ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) + ffi.Void Function(ffi.Long arg0, ffi.Pointer arg1) > > ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); /// Creates a block from a Dart function. /// @@ -25464,426 +18527,308 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownload /// /// 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, - ) - > + static objc.ObjCBlock fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - objc.NSURL, - ) - fn, { + void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) 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, + }) => objc.ObjCBlock( + objc.newClosureBlock(_closureCallable, ( + int arg0, + ffi.Pointer arg1, + ) { + return 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// /// 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, { + static objc.ObjCBlock listener( + void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) 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, + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1otpo83, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_171cldw.fromPointer( + rawArgs, retain: false, - release: true, - ), - objc.NSURL.fromPointer(arg3, retain: false, release: true), - ), - keepIsolateAlive, + release: false, + ); + + fn(args.arg0, args.arg1); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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. + /// the block. Async functions (ie returning Future) 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, { + static objc.ObjCBlock blocking( + void Function(NSURLSessionDelayedRequestDisposition, NSURLRequest?) 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, + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1otpo83, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_171cldw.fromPointer( + rawArgs, 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()); - } + release: false, + ); - 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()); - } + fn(args.arg0, args.arg1); + }, keepIsolateAlive), + retain: false, + release: true, + ); } - 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, + int 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); + ) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Long arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction)>()( + arg0, + arg1, + ); 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, + int 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); + as void Function(int, ffi.Pointer))(arg0, arg1); static ffi.Pointer _closureCallable = ffi.Pointer.fromFunction< ffi.Void Function( ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Long, 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, +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest$CallExtension + on objc.ObjCBlock { + void call(NSURLSessionDelayedRequestDisposition arg0, NSURLRequest? arg1) { + final _$$ref = arg1?.ref; + return 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, ) - > { - 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, - ); + >()(ref.pointer, arg0.value, _$$ref?.pointer ?? ffi.nullptr); + } } -late final _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_ = - objc.registerName( - "URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:", +/// 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) { + return fn(NSURLSessionResponseDisposition.fromValue(arg0)); + }, keepIsolateAlive), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock( + objc.newBlockPort(_1tf3our_wrapListenerBlock_16sve1d, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1y7f3jy.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, ); + } -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64, ffi.Int64)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64_Int64 { + /// 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_16sve1d, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1y7f3jy.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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(); +} + +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLSessionResponseDisposition$CallExtension + on objc.ObjCBlock { + void call(NSURLSessionResponseDisposition arg0) { + return ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Long arg0, + ) + > + >() + .asFunction, int)>()( + ref.pointer, + arg0.value, + ); + } +} + +/// 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( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) > fromPointer( ffi.Pointer pointer, { @@ -25891,14 +18836,7 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownload bool release = false, }) => objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) >(pointer, retain: retain, release: release); /// Creates a block from a C function pointer. @@ -25907,39 +18845,21 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownload /// 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, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) > fromFunctionPointer( ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer arg0, + 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, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) >( objc.newPointerBlock(_fnPtrCallable, ptr.cast()), retain: false, @@ -25955,525 +18875,193 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownload /// 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, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) > fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - int, - ) - fn, { + void Function(NSURLSessionWebSocketMessage?, objc.NSError?) fn, { bool keepIsolateAlive = true, }) => objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) >( - 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, - ), + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) { + return 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// /// 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, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) > listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - int, - ) - fn, { + void Function(NSURLSessionWebSocketMessage?, objc.NSError?) 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); + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_pfv6jd, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_130i0xx.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1); + }, keepIsolateAlive), + 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. + /// the block. Async functions (ie returning Future) 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, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) > blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - int, - ) - fn, { + void Function(NSURLSessionWebSocketMessage?, objc.NSError?) 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()); - } + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_pfv6jd, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_130i0xx.fromPointer( + rawArgs, + retain: false, + release: false, + ); - 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()); - } + fn(args.arg0, args.arg1); + }, keepIsolateAlive), + retain: false, + release: true, + ); } - 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 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 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); + >()(arg0, arg1); 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 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); + ))(arg0, arg1); 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 +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURLSessionWebSocketMessage_NSError$CallExtension on objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ffi.Int64, - ) + ffi.Void Function(NSURLSessionWebSocketMessage?, objc.NSError?) > { - 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, + void call(NSURLSessionWebSocketMessage? arg0, objc.NSError? arg1) { + final _$$ref = arg0?.ref; + final _$$ref$1 = arg1?.ref; + return ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, ) - >()( - 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:", + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + _$$ref?.pointer ?? ffi.nullptr, + _$$ref$1?.pointer ?? ffi.nullptr, ); -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 { +/// 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( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) > fromPointer( ffi.Pointer pointer, { @@ -26481,13 +19069,7 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownload bool release = false, }) => objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) >(pointer, retain: retain, release: release); /// Creates a block from a C function pointer. @@ -26496,36 +19078,22 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownload /// 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.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) > fromFunctionPointer( ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer arg0, + 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, - ) + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) >( objc.newPointerBlock(_fnPtrCallable, ptr.cast()), retain: false, @@ -26541,3297 +19109,3133 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownload /// 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.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) > fromFunction( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - ) - fn, { + void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) fn, { bool keepIsolateAlive = true, }) => objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) >( - 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, - ), + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) { + return 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// /// 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.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) > listener( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - ) - fn, { + 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, - int arg3, - int arg4, - ) => fn( - arg0, - NSURLSession.fromPointer(arg1, retain: false, release: true), - NSURLSessionDownloadTask.fromPointer( - arg2, + return objc.ObjCBlock< + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_r8gdi7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_3gru2r.fromPointer( + rawArgs, retain: false, - release: true, - ), - arg3, - arg4, - ), - keepIsolateAlive, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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. + /// the block. Async functions (ie returning Future) 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.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) > blocking( - void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - int, - int, - ) - fn, { + 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, - 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()); - } + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_r8gdi7, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_3gru2r.fromPointer( + rawArgs, + retain: false, + release: false, + ); - 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()); - } + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + release: true, + ); } - 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 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 arg0, ffi.Pointer arg1, ffi.Pointer arg2, - ffi.Int64 arg3, - ffi.Int64 arg4, ) > >() .asFunction< void Function( - ffi.Pointer, ffi.Pointer, ffi.Pointer, - int, - int, + ffi.Pointer, ) - >()(arg0, arg1, arg2, arg3, arg4); + >()(arg0, arg1, arg2); static ffi.Pointer _fnPtrCallable = ffi.Pointer.fromFunction< ffi.Void Function( ffi.Pointer, - ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Int64, - ffi.Int64, + ffi.Pointer, ) >(_fnPtrTrampoline) .cast(); static void _closureTrampoline( ffi.Pointer block, - ffi.Pointer arg0, + 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); + ffi.Pointer, + ))(arg0, arg1, arg2); static ffi.Pointer _closureCallable = ffi.Pointer.fromFunction< ffi.Void Function( ffi.Pointer, - ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Int64, - ffi.Int64, + ffi.Pointer, ) >(_closureTrampoline) .cast(); } -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionDownloadTask, ffi.Int64, ffi.Int64)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionDownloadTask_Int64_Int64$CallExtension +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSURL_NSURLResponse_NSError$CallExtension on objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - NSURLSession, - NSURLSessionDownloadTask, - ffi.Int64, - ffi.Int64, - ) + ffi.Void Function(objc.NSURL?, NSURLResponse?, objc.NSError?) > { - 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, + void call(objc.NSURL? arg0, NSURLResponse? arg1, objc.NSError? arg2) { + final _$$ref = arg0?.ref; + final _$$ref$1 = arg1?.ref; + final _$$ref$2 = arg2?.ref; + return 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, ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ) - >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer, arg3, arg4); + >()( + ref.pointer, + _$$ref?.pointer ?? ffi.nullptr, + _$$ref$1?.pointer ?? ffi.nullptr, + _$$ref$2?.pointer ?? ffi.nullptr, + ); + } } -/// 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, { +/// 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, - }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); + }) => objc.ObjCBlock, NSURLSession)>( + pointer, + 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, - ); - } -} + /// 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, + ); -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:', + /// 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, + ) { + return fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), ); - } - _objc_msgSend_pfv6jd( - object$.ref.pointer, - _sel_URLSession_didBecomeInvalidWithError_, - session.ref.pointer, - didBecomeInvalidWithError?.ref.pointer ?? ffi.nullptr, - ); - } + }, keepIsolateAlive), + retain: false, + 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. + /// Creates a listener block from a Dart function. /// - /// 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, + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, }) { - 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, - ); - } + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_18v1jvf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_7xicdf.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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, + fn(args.arg0, args.arg1); + }, keepIsolateAlive), + retain: false, + release: true, ); } - /// 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, + /// 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 (ie returning Future) 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, }) { - 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, + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_18v1jvf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_7xicdf.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1); + }, keepIsolateAlive), + retain: false, + 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. - 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, - ); + 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) { + final _$$ref = arg1.ref; + return 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); } +} - /// 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:', +/// 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, ); - } - _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:', + /// 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, + ) { + return 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, ); - } - _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, + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, }) { - 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, + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_fjrv01, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1f64crj.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + 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( - '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, + /// 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 (ie returning Future) 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, }) { - 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, - ); - } + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, objc.NSError?) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_fjrv01, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1f64crj.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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, + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + 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( - '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, - ); - } + 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(); +} - /// 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, +/// 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) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2?.ref; + return 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, + _$$ref$1?.pointer ?? ffi.nullptr, ); } +} - /// 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. +/// 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. /// - /// 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:', + /// 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, ); - } - _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. + /// Creates a block from a Dart function. /// - /// 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:', + /// 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, + ) { + return 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, ); - } - _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. + /// Creates a listener block from a Dart function. /// - /// 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// - /// 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, + /// 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, }) { - 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, - ); - } + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_bklti2, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_de64m.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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, + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + 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()); - /// Builds an object that implements the NSURLSessionDownloadDelegate protocol. To implement - /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. + /// Creates a blocking block from a Dart function. /// - /// 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_, + /// 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 (ie returning Future) 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, - )? - 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, + ) + fn, { + 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_, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_bklti2, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_de64m.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, ); - builder.addProtocol($protocol); - return NSURLSessionDownloadDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, ); } +} - /// 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( +/// 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, - 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( + 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, - 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( + 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, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + > + fromFunction( void Function( + ffi.Pointer, NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xx612k, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_15cdu5z.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + 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 (ie returning Future) 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, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, }) { - NSURLSessionDownloadDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implement( - builder, - URLSession_didBecomeInvalidWithError_, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSCachedURLResponse, + objc.ObjCBlock, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xx612k, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_15cdu5z.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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_, + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + final _$$ref$3 = arg4.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, ); - 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( +/// 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, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( + 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, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + 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, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, + 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, + NSURLSessionDataTask, + objc.NSData, + ) + fn, { + 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), + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_16ix251.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, ); } - /// Adds the implementation of the NSURLSessionDownloadDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will - /// be. + /// Creates a blocking block from a Dart function. /// - /// 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_, + /// 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 (ie returning Future) 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, - 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, + NSURLSessionDataTask, + objc.NSData, + ) + fn, { + 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_, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + objc.NSData, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_16ix251.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, ); - NSURLSessionDownloadDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsListener( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, ); - 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( +/// 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, - 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( + 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, - 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( + 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, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + > + fromFunction( void Function( + ffi.Pointer, NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( + 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + > + listener( void Function( + ffi.Pointer, NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, }) { - final builder = objc.ObjCProtocolBuilder( - debugName: 'NSURLSessionDownloadDelegate', - ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didBecomeInvalidWithError_.implementAsBlocking( - builder, - URLSession_didBecomeInvalidWithError_, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xx612k, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1xfn2k3.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, ); - NSURLSessionDownloadDelegate$Builder - .URLSession_didCreateTask_.implementAsBlocking( - builder, - URLSession_didCreateTask_, + } + + /// 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLResponse, + objc.ObjCBlock, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xx612k, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1xfn2k3.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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), + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + final _$$ref$3 = arg4.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, ); } +} - /// 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( +/// 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, - NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( + 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, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, + 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, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, + 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_, - void Function(NSURLSession, NSURLSessionTask)? - URLSession_taskIsWaitingForConnectivity_, - void Function(NSURLSession)? - URLSessionDidFinishEventsForBackgroundURLSession_, - bool $keepIsolateAlive = true, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + fn, { + 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_, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_140cpyj.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, ); - NSURLSessionDownloadDelegate$Builder - .URLSessionDidFinishEventsForBackgroundURLSession_.implementAsBlocking( - builder, - URLSessionDidFinishEventsForBackgroundURLSession_, + } + + /// 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionDownloadTask, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_140cpyj.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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< + 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( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >( - _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( + >()(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, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + NSURLSessionDataTask, + NSURLSessionDownloadTask, ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ( + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionDownloadTask arg3, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + return 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( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ); + >()( + ref.pointer, + arg0, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.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. - static final URLSession_downloadTask_didFinishDownloadingToURL_ = - objc.ObjCProtocolListenableMethod< - void Function(NSURLSession, NSURLSessionDownloadTask, objc.NSURL) +/// 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, + ) >( - _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.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + 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) + /// 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, + ) >( - _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), + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) { + return 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, ); - /// 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), - ), - ); + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_43hp0b.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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), - ), - ); + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + 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), - ), - ); + /// 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDataTask, + NSURLSessionStreamTask, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_43hp0b.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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, + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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, ) - 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( + > + >() + .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, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + NSURLSessionDataTask, + NSURLSessionStreamTask, ) - 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 call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDataTask arg2, + NSURLSessionStreamTask arg3, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + return 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( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - 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), - ), - ); + >()( + ref.pointer, + arg0, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + } +} - /// 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), - ), - ); +/// 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); - /// 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( + /// 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, - NSURLSessionTask, - objc.ObjCBlock, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, ) >( - _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), - ), + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + 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. + /// Creates a block from a Dart function. /// - /// - 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( + /// 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, - NSURLSessionTask, - int, - objc.ObjCBlock, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, ) >( - _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), + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + ) { + return fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionDownloadTask.fromPointer( + arg2, + retain: true, + release: true, ), + arg3, + arg4, + ); + }, keepIsolateAlive), + retain: false, + 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. + /// Creates a listener block from a Dart function. /// - /// 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// - /// 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. + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_ly2579, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1l7b9ji.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + /// Creates a blocking block from a Dart function. /// - /// 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< + /// 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_ly2579, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1l7b9ji.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, ) - >( - _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( + >()(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, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, ) - 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 call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + return 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( - NSURLSession, - NSURLSessionTask, - NSURLRequest, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, ) - 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), - ), - ); + >()(ref.pointer, arg0, _$$ref.pointer, _$$ref$1.pointer, 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. +/// 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. /// - /// 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( + /// 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, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) >( - _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), - ), + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + 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. + /// Creates a block from a Dart function. /// - /// 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. + /// 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. @@ -29839,16 +22243,20 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) > fromFunction( void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, + NSURLSessionDownloadTask, + int, + int, + int, ) fn, { bool keepIsolateAlive = true, @@ -29857,41 +22265,42 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ) => fn( + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + int arg3, + int arg4, + int arg5, + ) { + return fn( arg0, NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionWebSocketTask.fromPointer( + NSURLSessionDownloadTask.fromPointer( arg2, retain: true, release: true, ), - arg3.address == 0 - ? null - : objc.NSString.fromPointer(arg3, retain: true, release: true), - ), - keepIsolateAlive, - ), + 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// /// If `keepIsolateAlive` is true, this block will keep this isolate alive /// until it is garbage collected by both Dart and ObjC. @@ -29899,58 +22308,55 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) > listener( void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, + NSURLSessionDownloadTask, + int, + int, + int, ) 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?, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - >(wrapper, retain: false, release: true); + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_h68abb, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1pfucun.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4, args.arg5); + }, keepIsolateAlive), + 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. + /// the block. Async functions (ie returning Future) 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 @@ -29960,189 +22366,58 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) > blocking( void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - objc.NSString?, + NSURLSessionDownloadTask, + int, + int, + int, ) 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?, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) - >(wrapper, retain: false, release: true); + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_h68abb, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1pfucun.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4, args.arg5); + }, keepIsolateAlive), + retain: false, + release: true, + ); } - static void _listenerTrampoline( + static void _fnPtrTrampoline( 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, + int arg3, + int arg4, + int arg5, ) => block.ref.target .cast< ffi.NativeFunction< @@ -30150,7 +22425,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, - ffi.Pointer arg3, + ffi.Int64 arg3, + ffi.Int64 arg4, + ffi.Int64 arg5, ) > >() @@ -30159,9 +22436,11 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer, + int, + int, + int, ) - >()(arg0, arg1, arg2, arg3); + >()(arg0, arg1, arg2, arg3, arg4, arg5); static ffi.Pointer _fnPtrCallable = ffi.Pointer.fromFunction< ffi.Void Function( @@ -30169,7 +22448,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) >(_fnPtrTrampoline) .cast(); @@ -30178,15 +22459,19 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, - ffi.Pointer arg3, + int arg3, + int arg4, + int arg5, ) => (objc.getBlockClosure(block) as void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1, arg2, arg3); + int, + int, + int, + ))(arg0, arg1, arg2, arg3, arg4, arg5); static ffi.Pointer _closureCallable = ffi.Pointer.fromFunction< ffi.Void Function( @@ -30194,94 +22479,82 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) >(_closureTrampoline) .cast(); } -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, objc.NSString?)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSString$CallExtension +/// 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, - NSURLSessionWebSocketTask, - objc.NSString?, + NSURLSessionDownloadTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, ) > { 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, + NSURLSessionDownloadTask arg2, + int arg3, + int arg4, + int arg5, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + return 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, ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3?.ref.pointer ?? ffi.nullptr, - ); + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ) + >()( + ref.pointer, + arg0, + _$$ref.pointer, + _$$ref$1.pointer, + arg3, + arg4, + arg5, + ); + } } -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, - ) - >(); - -/// Construction methods for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, ffi.Long, objc.NSData?)>`. -abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData { +/// 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, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) > fromPointer( @@ -30293,9 +22566,8 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) >(pointer, retain: retain, release: release); @@ -30308,9 +22580,8 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) > fromFunctionPointer( @@ -30320,8 +22591,7 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, - ffi.Long arg3, - ffi.Pointer arg4, + ffi.Pointer arg3, ) > > @@ -30331,9 +22601,8 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) >( objc.newPointerBlock(_fnPtrCallable, ptr.cast()), @@ -30353,18 +22622,16 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) > fromFunction( void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - int, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) fn, { bool keepIsolateAlive = true, @@ -30373,44 +22640,36 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, - ) => fn( + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) { + return fn( arg0, NSURLSession.fromPointer(arg1, retain: true, release: true), - NSURLSessionWebSocketTask.fromPointer( + NSURLSessionDownloadTask.fromPointer( arg2, retain: true, release: true, ), - arg3, - arg4.address == 0 - ? null - : objc.NSData.fromPointer(arg4, retain: true, release: true), - ), - keepIsolateAlive, - ), + 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// /// If `keepIsolateAlive` is true, this block will keep this isolate alive /// until it is garbage collected by both Dart and ObjC. @@ -30418,63 +22677,49 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) > listener( void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - int, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) 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?, + NSURLSessionDownloadTask, + objc.NSURL, ) - >(wrapper, retain: false, release: true); + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_pm23bg.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + 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. + /// the block. Async functions (ie returning Future) 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 @@ -30484,207 +22729,50 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) > blocking( void Function( ffi.Pointer, NSURLSession, - NSURLSessionWebSocketTask, - int, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) 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?, + NSURLSessionDownloadTask, + objc.NSURL, ) - >(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()); - } + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_pm23bg.fromPointer( + rawArgs, + retain: false, + release: false, + ); - 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()); - } + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, + ); } - 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, + ffi.Pointer arg3, ) => block.ref.target .cast< ffi.NativeFunction< @@ -30692,8 +22780,7 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, - ffi.Long arg3, - ffi.Pointer arg4, + ffi.Pointer arg3, ) > >() @@ -30702,10 +22789,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer, ffi.Pointer, ffi.Pointer, - int, ffi.Pointer, ) - >()(arg0, arg1, arg2, arg3, arg4); + >()(arg0, arg1, arg2, arg3); static ffi.Pointer _fnPtrCallable = ffi.Pointer.fromFunction< ffi.Void Function( @@ -30713,7 +22799,6 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Long, ffi.Pointer, ) >(_fnPtrTrampoline) @@ -30723,17 +22808,15 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, - int arg3, - ffi.Pointer arg4, + ffi.Pointer arg3, ) => (objc.getBlockClosure(block) as void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer, - int, ffi.Pointer, - ))(arg0, arg1, arg2, arg3, arg4); + ))(arg0, arg1, arg2, arg3); static ffi.Pointer _closureCallable = ffi.Pointer.fromFunction< ffi.Void Function( @@ -30741,3158 +22824,8427 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocke ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Long, ffi.Pointer, ) >(_closureTrampoline) .cast(); } -/// Call operator for `objc.ObjCBlock, NSURLSession, NSURLSessionWebSocketTask, ffi.Long, objc.NSData?)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionWebSocketTask_NSURLSessionWebSocketCloseCode_NSData$CallExtension +/// 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, - NSURLSessionWebSocketTask, - ffi.Long, - objc.NSData?, + NSURLSessionDownloadTask, + objc.NSURL, ) > { 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, + NSURLSessionDownloadTask arg2, + objc.NSURL arg3, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + return 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, ) - >()( - ref.pointer, - arg0, - arg1.ref.pointer, - arg2.ref.pointer, - arg3, - arg4?.ref.pointer ?? ffi.nullptr, - ); + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + } } -/// 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, { +/// 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, - }) : 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, - ); - } -} + }) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + >(pointer, retain: retain, release: release); -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:', + /// 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, ); - } - _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. + /// Creates a block from a Dart function. /// - /// 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:', + /// 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, + ) { + return fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + ); + }, keepIsolateAlive), + retain: false, + release: true, ); - } - _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, + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, }) { - 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, - ); - } + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_fjrv01, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_k1nazc.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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, + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + 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, + /// 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 (ie returning Future) 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, }) { - 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, - ); - } + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSURLSession, NSURLSessionTask) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_fjrv01, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_k1nazc.fromPointer( + rawArgs, + retain: false, + release: false, + ); - /// 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, + fn(args.arg0, args.arg1, args.arg2); + }, keepIsolateAlive), + retain: false, + 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:', - ); - } - _objc_msgSend_9cddqw( - object$.ref.pointer, - _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - session.ref.pointer, - task.ref.pointer, - needNewBodyStreamFromOffset, - completionHandler.ref.pointer, - ); - } + 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(); +} - /// 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, - ); +/// 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + return 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, _$$ref$1.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. +/// 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. /// - /// 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:', + /// 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, ); - } - _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. + /// Creates a block from a Dart function. /// - /// 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 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. /// - /// 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 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:', - ); - } - _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( + /// 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, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + fromFunction( void Function( + ffi.Pointer, 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( + 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, - )? - URLSession_task_needNewBodyStream_, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + listener( void Function( + ffi.Pointer, NSURLSession, NSURLSessionTask, int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( + int, + int, + ) + fn, { + bool keepIsolateAlive = true, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_h68abb, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_xh08sz.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4, args.arg5); + }, keepIsolateAlive), + 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 (ie returning Future) 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, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + > + blocking( void Function( + ffi.Pointer, 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, + int, + int, + int, + ) + fn, { + 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_, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + ffi.Int64, + ffi.Int64, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_h68abb, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_xh08sz.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4, args.arg5); + }, keepIsolateAlive), + retain: false, + release: true, ); - builder.addProtocol($protocol); - return NSURLSessionWebSocketDelegate.as( - builder.build(keepIsolateAlive: $keepIsolateAlive), + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + arg3, + arg4, + arg5, ); } +} - /// 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( +/// 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, - )? - URLSession_task_needNewBodyStream_, - void Function( + ) + > + 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, - int, + ffi.Int64, objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( + ) + > + 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, - NSURLRequest, - objc.ObjCBlock, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, + ffi.Int64, + objc.ObjCBlock, + ) + > + fromFunction( void Function( + ffi.Pointer, 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); - } + 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, + ) { + return 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, + ); - /// 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. + /// Creates a listener block from a Dart function. /// - /// 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( + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, - )? - URLSession_task_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, NSHTTPURLResponse)? - URLSession_task_didReceiveInformationalResponse_, - void Function(NSURLSession, NSURLSessionTask, int, int, int)? - URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_, + ffi.Int64, + objc.ObjCBlock, + ) + > + listener( void Function( + ffi.Pointer, NSURLSession, NSURLSessionTask, + int, 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, + ) + fn, { + 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), + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_jyim80, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_99x6vt.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, ); } - /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will - /// be. + /// Creates a blocking block from a Dart function. /// - /// 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( + /// 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 (ie returning Future) 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, - )? - URLSession_task_needNewBodyStream_, + ) + > + blocking( void Function( + ffi.Pointer, 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, + ) + fn, { + 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_, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + ffi.Int64, + objc.ObjCBlock, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_jyim80, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_99x6vt.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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_, + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg4.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + arg3, + _$$ref$2.pointer, ); - 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. +/// 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. /// - /// 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( + /// 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, - )? - URLSession_didReceiveChallenge_completionHandler_, - void Function(NSURLSession, NSURLSessionTask, objc.NSError?)? - URLSession_task_didCompleteWithError_, - void Function(NSURLSession, NSURLSessionTask, NSURLSessionTaskMetrics)? - URLSession_task_didFinishCollectingMetrics_, - void Function( + 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, - 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_, + objc.NSError?, + ) + > + fromFunction( void Function( + ffi.Pointer, NSURLSession, NSURLSessionTask, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStream_, - void Function( - NSURLSession, - NSURLSessionTask, - int, - objc.ObjCBlock, - )? - URLSession_task_needNewBodyStreamFromOffset_completionHandler_, - void Function( + 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, + objc.NSError?, + ) + > + listener( void Function( + ffi.Pointer, 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, + objc.NSError?, + ) + fn, { + 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), + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_qjjttc.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, ); } - /// Adds the implementation of the NSURLSessionWebSocketDelegate protocol to an existing - /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking - /// listeners will be. + /// Creates a blocking block from a Dart function. /// - /// 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( + /// 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 (ie returning Future) 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, - )? - URLSession_task_willBeginDelayedRequest_completionHandler_, + objc.NSError?, + ) + > + blocking( void Function( + ffi.Pointer, 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, + objc.NSError?, + ) + fn, { + 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_, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.NSError?, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_qjjttc.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, ); - 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< + 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( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >( - _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( + >()(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, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + NSURLSessionTask, + objc.NSError?, ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.listener( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ( + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + objc.NSError? arg3, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3?.ref; + return 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( - NSURLSession, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - func, - ) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLAuthenticationChallenge_ffiVoidNSURLSessionAuthChallengeDispositionNSURLCredential.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLAuthenticationChallenge arg2, - objc.ObjCBlock - arg3, - ) => func(arg1, arg2, arg3), - ), - ); + >()( + ref.pointer, + arg0, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2?.pointer ?? ffi.nullptr, + ); + } +} - /// 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?) +/// 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, + ) >( - _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), - ), + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + 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) + /// 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, + ) >( - _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), - ), + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ) { + return 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, ); - /// 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< + /// Creates a listener block from a Dart function. + /// + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1n5meg5.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1n5meg5.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >( - _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( + >()(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, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + NSHTTPURLResponse, ) - 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 call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + return 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( - NSURLSession, - NSURLSessionTask, - NSURLAuthenticationChallenge, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - 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), - ), - ); + >()( + ref.pointer, + arg0, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + } +} - /// 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), - ), - ); +/// 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); - /// 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( + /// 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, - objc.ObjCBlock, + NSHTTPURLResponse, + NSURLRequest, + 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), - ), + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + 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. + /// Creates a block from a Dart function. /// - /// - 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( + /// 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, - int, - objc.ObjCBlock, + NSHTTPURLResponse, + NSURLRequest, + 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), + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ffi.Pointer arg5, + ) { + return 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, ); - /// 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. + /// Creates a listener block from a Dart function. /// - /// 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// - /// 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. + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_l2g8ke, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1ayzt6i.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4, args.arg5); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + /// Creates a blocking block from a Dart function. /// - /// 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. + /// 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 (ie returning Future) are not supported. /// - /// 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< + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSHTTPURLResponse, + NSURLRequest, + objc.ObjCBlock, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_l2g8ke, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_1ayzt6i.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4, args.arg5); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - >( - _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( + >()(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, ) - 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 call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + NSHTTPURLResponse arg3, + NSURLRequest arg4, + objc.ObjCBlock arg5, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + final _$$ref$3 = arg4.ref; + final _$$ref$4 = arg5.ref; + return 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( - NSURLSession, - NSURLSessionTask, - NSHTTPURLResponse, - NSURLRequest, - objc.ObjCBlock, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) - 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), - ), + >()( + ref.pointer, + arg0, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, + _$$ref$4.pointer, + ); + } +} + +/// 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, ); - /// 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. + /// Creates a block from a Dart function. /// - /// 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 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. /// - /// 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) + /// 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, + ) >( - _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), + objc.newClosureBlock(_closureCallable, ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, + ) { + return fn( + arg0, + NSURLSession.fromPointer(arg1, retain: true, release: true), + NSURLSessionTask.fromPointer(arg2, retain: true, release: true), + NSURLAuthenticationChallenge.fromPointer( + arg3, + retain: true, + release: true, ), - (void Function(NSURLSession, NSURLSessionTask) func) => - ObjCBlock_ffiVoid_ffiVoid_NSURLSession_NSURLSessionTask.blocking( - ( - ffi.Pointer _, - NSURLSession arg1, - NSURLSessionTask arg2, - ) => func(arg1, arg2), + ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + arg4, + retain: true, + release: true, ), + ); + }, keepIsolateAlive), + retain: false, + 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 - 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), - ), - ); - - /// 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), - ), - ); -} - -/// 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. + /// This block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. /// /// 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, { + 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) => fn(arg0), - keepIsolateAlive, - ); - final wrapper = _NativeCupertinoHttp_wrapListenerBlock_ovsamd(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock)>( - wrapper, - retain: false, - release: true, - ); - } + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xx612k, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_31cygh.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + 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. + /// the block. Async functions (ie returning Future) 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, { + 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) => 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, + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xx612k, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_31cygh.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), 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, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer arg4, ) => block.ref.target - .cast arg0)>>() - .asFunction)>()(arg0); + .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, - ) => (objc.getBlockClosure(block) as void Function(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)>`. -extension ObjCBlock_ffiVoid_ffiVoid$CallExtension - on objc.ObjCBlock)> { - void call(ffi.Pointer arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< +/// 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 block, - ffi.Pointer arg0, + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLAuthenticationChallenge, + objc.ObjCBlock, ) - > - >() - .asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >()(ref.pointer, arg0); + > { + void call( + ffi.Pointer arg0, + NSURLSession arg1, + NSURLSessionTask arg2, + NSURLAuthenticationChallenge arg3, + objc.ObjCBlock arg4, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + final _$$ref$3 = arg4.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.pointer, + ); + } } +/// 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_xx612k, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_jqba1.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLRequest, + objc.ObjCBlock, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_xx612k, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_jqba1.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + final _$$ref$3 = arg4.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + _$$ref$3.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); + + /// 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_i7wriu.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + NSURLSessionTaskMetrics, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_i7wriu.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_bklti2, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_112ozxo.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionTask, + objc.ObjCBlock, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_bklti2, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_112ozxo.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2.pointer, + ); + } +} + +/// 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_xcrg5s.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + objc.NSString?, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1tz5yf, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_xcrg5s.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg3?.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + _$$ref$2?.pointer ?? ffi.nullptr, + ); + } +} + +/// 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); + + /// 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, + ); + + /// 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, + ) { + return 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 block can be invoked from any thread, but only supports void + /// functions, and is not run synchronously. Async functions (ie returning + /// Future) are not supported. + /// + /// 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + >( + objc.newBlockPort(_1tf3our_wrapListenerBlock_1lx650f, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_17jmtfx.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + 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 (ie returning Future) 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, + }) { + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + NSURLSession, + NSURLSessionWebSocketTask, + ffi.Long, + objc.NSData?, + ) + >( + objc.newBlockingBlockPort(_1tf3our_wrapBlockingBlock_1lx650f, ( + ffi.Pointer rawArgs, + ) { + final args = _BlockArgs_17jmtfx.fromPointer( + rawArgs, + retain: false, + release: false, + ); + + fn(args.arg0, args.arg1, args.arg2, args.arg3, args.arg4); + }, keepIsolateAlive), + retain: false, + release: true, + ); + } + + 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(); +} + +/// 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, + ) { + final _$$ref = arg1.ref; + final _$$ref$1 = arg2.ref; + final _$$ref$2 = arg4?.ref; + return 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, + _$$ref.pointer, + _$$ref$1.pointer, + arg3, + _$$ref$2?.pointer ?? ffi.nullptr, + ); + } +} + +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'), + }; +} + +extension type _BlockArgs_112ozxo._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_112ozxo] that points to the same underlying object as [other]. + _BlockArgs_112ozxo.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_112ozxo] that wraps the given raw object pointer. + _BlockArgs_112ozxo.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 [_BlockArgs_112ozxo]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_112ozxo, + ); +} + +extension _BlockArgs_112ozxo$Methods on _BlockArgs_112ozxo { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + objc.ObjCBlock get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_uwvaik(_$$ref.pointer, _sel_arg3); + return ObjCBlock_ffiVoid_NSInputStream.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_117e0ww._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_117e0ww] that points to the same underlying object as [other]. + _BlockArgs_117e0ww.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_117e0ww] that wraps the given raw object pointer. + _BlockArgs_117e0ww.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 [_BlockArgs_117e0ww]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_117e0ww, + ); +} + +extension _BlockArgs_117e0ww$Methods on _BlockArgs_117e0ww { + objc.NSError? get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return $ret.address == 0 + ? null + : objc.NSError.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_130i0xx._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_130i0xx] that points to the same underlying object as [other]. + _BlockArgs_130i0xx.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_130i0xx] that wraps the given raw object pointer. + _BlockArgs_130i0xx.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 [_BlockArgs_130i0xx]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_130i0xx, + ); +} + +extension _BlockArgs_130i0xx$Methods on _BlockArgs_130i0xx { + NSURLSessionWebSocketMessage? get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return $ret.address == 0 + ? null + : NSURLSessionWebSocketMessage.fromPointer( + $ret, + retain: true, + release: true, + ); + } + + objc.NSError? get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return $ret.address == 0 + ? null + : objc.NSError.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_140cpyj._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_140cpyj] that points to the same underlying object as [other]. + _BlockArgs_140cpyj.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_140cpyj] that wraps the given raw object pointer. + _BlockArgs_140cpyj.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 [_BlockArgs_140cpyj]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_140cpyj, + ); +} + +extension _BlockArgs_140cpyj$Methods on _BlockArgs_140cpyj { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDataTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDownloadTask get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_15cdu5z._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_15cdu5z] that points to the same underlying object as [other]. + _BlockArgs_15cdu5z.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_15cdu5z] that wraps the given raw object pointer. + _BlockArgs_15cdu5z.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 [_BlockArgs_15cdu5z]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_15cdu5z, + ); +} + +extension _BlockArgs_15cdu5z$Methods on _BlockArgs_15cdu5z { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDataTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); + } + + NSCachedURLResponse get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSCachedURLResponse.fromPointer($ret, retain: true, release: true); + } + + objc.ObjCBlock get arg4 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_uwvaik(_$$ref.pointer, _sel_arg4); + return ObjCBlock_ffiVoid_NSCachedURLResponse.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_16ix251._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_16ix251] that points to the same underlying object as [other]. + _BlockArgs_16ix251.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_16ix251] that wraps the given raw object pointer. + _BlockArgs_16ix251.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 [_BlockArgs_16ix251]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_16ix251, + ); +} + +extension _BlockArgs_16ix251$Methods on _BlockArgs_16ix251 { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDataTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); + } + + objc.NSData get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return objc.NSData.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_171cldw._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_171cldw] that points to the same underlying object as [other]. + _BlockArgs_171cldw.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_171cldw] that wraps the given raw object pointer. + _BlockArgs_171cldw.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 [_BlockArgs_171cldw]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_171cldw, + ); +} + +extension _BlockArgs_171cldw$Methods on _BlockArgs_171cldw { + NSURLSessionDelayedRequestDisposition get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_tyifel(_$$ref.pointer, _sel_arg0); + return NSURLSessionDelayedRequestDisposition.fromValue($ret); + } + + NSURLRequest? get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return $ret.address == 0 + ? null + : NSURLRequest.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_17jmtfx._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_17jmtfx] that points to the same underlying object as [other]. + _BlockArgs_17jmtfx.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_17jmtfx] that wraps the given raw object pointer. + _BlockArgs_17jmtfx.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 [_BlockArgs_17jmtfx]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_17jmtfx, + ); +} + +extension _BlockArgs_17jmtfx$Methods on _BlockArgs_17jmtfx { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionWebSocketTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: true, + release: true, + ); + } + + int get arg3 { + final _$$ref = object$.ref; + return _objc_msgSend_1rhk8uh(_$$ref.pointer, _sel_arg3); + } + + objc.NSData? get arg4 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg4); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_1ayzt6i._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1ayzt6i] that points to the same underlying object as [other]. + _BlockArgs_1ayzt6i.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1ayzt6i] that wraps the given raw object pointer. + _BlockArgs_1ayzt6i.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 [_BlockArgs_1ayzt6i]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1ayzt6i, + ); +} + +extension _BlockArgs_1ayzt6i$Methods on _BlockArgs_1ayzt6i { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + NSHTTPURLResponse get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSHTTPURLResponse.fromPointer($ret, retain: true, release: true); + } + + NSURLRequest get arg4 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg4); + return NSURLRequest.fromPointer($ret, retain: true, release: true); + } + + objc.ObjCBlock get arg5 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_uwvaik(_$$ref.pointer, _sel_arg5); + return ObjCBlock_ffiVoid_NSURLRequest.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_1f64crj._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1f64crj] that points to the same underlying object as [other]. + _BlockArgs_1f64crj.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1f64crj] that wraps the given raw object pointer. + _BlockArgs_1f64crj.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 [_BlockArgs_1f64crj]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1f64crj, + ); +} + +extension _BlockArgs_1f64crj$Methods on _BlockArgs_1f64crj { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + objc.NSError? get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return $ret.address == 0 + ? null + : objc.NSError.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_1l7b9ji._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1l7b9ji] that points to the same underlying object as [other]. + _BlockArgs_1l7b9ji.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1l7b9ji] that wraps the given raw object pointer. + _BlockArgs_1l7b9ji.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 [_BlockArgs_1l7b9ji]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1l7b9ji, + ); +} + +extension _BlockArgs_1l7b9ji$Methods on _BlockArgs_1l7b9ji { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDownloadTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); + } + + int get arg3 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg3); + } + + int get arg4 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg4); + } +} + +extension type _BlockArgs_1mv87bk._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1mv87bk] that points to the same underlying object as [other]. + _BlockArgs_1mv87bk.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1mv87bk] that wraps the given raw object pointer. + _BlockArgs_1mv87bk.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 [_BlockArgs_1mv87bk]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1mv87bk, + ); +} + +extension _BlockArgs_1mv87bk$Methods on _BlockArgs_1mv87bk { + objc.NSData? get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); + } + + NSURLResponse? get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return $ret.address == 0 + ? null + : NSURLResponse.fromPointer($ret, retain: true, release: true); + } + + objc.NSError? get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return $ret.address == 0 + ? null + : objc.NSError.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_1n5meg5._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1n5meg5] that points to the same underlying object as [other]. + _BlockArgs_1n5meg5.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1n5meg5] that wraps the given raw object pointer. + _BlockArgs_1n5meg5.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 [_BlockArgs_1n5meg5]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1n5meg5, + ); +} + +extension _BlockArgs_1n5meg5$Methods on _BlockArgs_1n5meg5 { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + NSHTTPURLResponse get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSHTTPURLResponse.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_1n6ph2._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1n6ph2] that points to the same underlying object as [other]. + _BlockArgs_1n6ph2.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1n6ph2] that wraps the given raw object pointer. + _BlockArgs_1n6ph2.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 [_BlockArgs_1n6ph2]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1n6ph2, + ); +} + +extension _BlockArgs_1n6ph2$Methods on _BlockArgs_1n6ph2 { + NSURLRequest? get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return $ret.address == 0 + ? null + : NSURLRequest.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_1pfucun._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1pfucun] that points to the same underlying object as [other]. + _BlockArgs_1pfucun.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1pfucun] that wraps the given raw object pointer. + _BlockArgs_1pfucun.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 [_BlockArgs_1pfucun]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1pfucun, + ); +} + +extension _BlockArgs_1pfucun$Methods on _BlockArgs_1pfucun { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDownloadTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); + } + + int get arg3 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg3); + } + + int get arg4 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg4); + } + + int get arg5 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg5); + } +} + +extension type _BlockArgs_1ucj4uc._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1ucj4uc] that points to the same underlying object as [other]. + _BlockArgs_1ucj4uc.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1ucj4uc] that wraps the given raw object pointer. + _BlockArgs_1ucj4uc.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 [_BlockArgs_1ucj4uc]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1ucj4uc, + ); +} + +extension _BlockArgs_1ucj4uc$Methods on _BlockArgs_1ucj4uc { + objc.NSArray get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return objc.NSArray.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_1ura76._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1ura76] that points to the same underlying object as [other]. + _BlockArgs_1ura76.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1ura76] that wraps the given raw object pointer. + _BlockArgs_1ura76.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 [_BlockArgs_1ura76]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1ura76, + ); +} + +extension _BlockArgs_1ura76$Methods on _BlockArgs_1ura76 { + objc.NSInputStream? get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return $ret.address == 0 + ? null + : objc.NSInputStream.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_1xfn2k3._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1xfn2k3] that points to the same underlying object as [other]. + _BlockArgs_1xfn2k3.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1xfn2k3] that wraps the given raw object pointer. + _BlockArgs_1xfn2k3.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 [_BlockArgs_1xfn2k3]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1xfn2k3, + ); +} + +extension _BlockArgs_1xfn2k3$Methods on _BlockArgs_1xfn2k3 { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDataTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); + } + + NSURLResponse get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSURLResponse.fromPointer($ret, retain: true, release: true); + } + + objc.ObjCBlock get arg4 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_uwvaik(_$$ref.pointer, _sel_arg4); + return ObjCBlock_ffiVoid_NSURLSessionResponseDisposition.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_1y7f3jy._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_1y7f3jy] that points to the same underlying object as [other]. + _BlockArgs_1y7f3jy.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_1y7f3jy] that wraps the given raw object pointer. + _BlockArgs_1y7f3jy.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 [_BlockArgs_1y7f3jy]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_1y7f3jy, + ); +} + +extension _BlockArgs_1y7f3jy$Methods on _BlockArgs_1y7f3jy { + NSURLSessionResponseDisposition get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_129c579(_$$ref.pointer, _sel_arg0); + return NSURLSessionResponseDisposition.fromValue($ret); + } +} + +extension type _BlockArgs_31cygh._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_31cygh] that points to the same underlying object as [other]. + _BlockArgs_31cygh.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_31cygh] that wraps the given raw object pointer. + _BlockArgs_31cygh.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 [_BlockArgs_31cygh]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_31cygh, + ); +} + +extension _BlockArgs_31cygh$Methods on _BlockArgs_31cygh { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + NSURLAuthenticationChallenge get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSURLAuthenticationChallenge.fromPointer( + $ret, + retain: true, + release: true, + ); + } + + objc.ObjCBlock get arg4 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_uwvaik(_$$ref.pointer, _sel_arg4); + return ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_3gru2r._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_3gru2r] that points to the same underlying object as [other]. + _BlockArgs_3gru2r.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_3gru2r] that wraps the given raw object pointer. + _BlockArgs_3gru2r.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 [_BlockArgs_3gru2r]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_3gru2r, + ); +} + +extension _BlockArgs_3gru2r$Methods on _BlockArgs_3gru2r { + objc.NSURL? get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return $ret.address == 0 + ? null + : objc.NSURL.fromPointer($ret, retain: true, release: true); + } + + NSURLResponse? get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return $ret.address == 0 + ? null + : NSURLResponse.fromPointer($ret, retain: true, release: true); + } + + objc.NSError? get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return $ret.address == 0 + ? null + : objc.NSError.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_43hp0b._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_43hp0b] that points to the same underlying object as [other]. + _BlockArgs_43hp0b.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_43hp0b] that wraps the given raw object pointer. + _BlockArgs_43hp0b.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 [_BlockArgs_43hp0b]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_43hp0b, + ); +} + +extension _BlockArgs_43hp0b$Methods on _BlockArgs_43hp0b { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDataTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionDataTask.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionStreamTask get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSURLSessionStreamTask.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_7xicdf._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_7xicdf] that points to the same underlying object as [other]. + _BlockArgs_7xicdf.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_7xicdf] that wraps the given raw object pointer. + _BlockArgs_7xicdf.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 [_BlockArgs_7xicdf]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_7xicdf, + ); +} + +extension _BlockArgs_7xicdf$Methods on _BlockArgs_7xicdf { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_99x6vt._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_99x6vt] that points to the same underlying object as [other]. + _BlockArgs_99x6vt.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_99x6vt] that wraps the given raw object pointer. + _BlockArgs_99x6vt.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 [_BlockArgs_99x6vt]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_99x6vt, + ); +} + +extension _BlockArgs_99x6vt$Methods on _BlockArgs_99x6vt { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + int get arg3 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg3); + } + + objc.ObjCBlock get arg4 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_uwvaik(_$$ref.pointer, _sel_arg4); + return ObjCBlock_ffiVoid_NSInputStream.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_de64m._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_de64m] that points to the same underlying object as [other]. + _BlockArgs_de64m.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_de64m] that wraps the given raw object pointer. + _BlockArgs_de64m.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 [_BlockArgs_de64m]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_de64m, + ); +} + +extension _BlockArgs_de64m$Methods on _BlockArgs_de64m { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLAuthenticationChallenge get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLAuthenticationChallenge.fromPointer( + $ret, + retain: true, + release: true, + ); + } + + objc.ObjCBlock get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_uwvaik(_$$ref.pointer, _sel_arg3); + return ObjCBlock_ffiVoid_NSURLSessionAuthChallengeDisposition_NSURLCredential.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_i7wriu._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_i7wriu] that points to the same underlying object as [other]. + _BlockArgs_i7wriu.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_i7wriu] that wraps the given raw object pointer. + _BlockArgs_i7wriu.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 [_BlockArgs_i7wriu]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_i7wriu, + ); +} + +extension _BlockArgs_i7wriu$Methods on _BlockArgs_i7wriu { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTaskMetrics get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSURLSessionTaskMetrics.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_ih4kg4._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_ih4kg4] that points to the same underlying object as [other]. + _BlockArgs_ih4kg4.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_ih4kg4] that wraps the given raw object pointer. + _BlockArgs_ih4kg4.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 [_BlockArgs_ih4kg4]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_ih4kg4, + ); +} + +extension _BlockArgs_ih4kg4$Methods on _BlockArgs_ih4kg4 { + objc.NSArray get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return objc.NSArray.fromPointer($ret, retain: true, release: true); + } + + objc.NSArray get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return objc.NSArray.fromPointer($ret, retain: true, release: true); + } + + objc.NSArray get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return objc.NSArray.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_ii17hk._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_ii17hk] that points to the same underlying object as [other]. + _BlockArgs_ii17hk.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_ii17hk] that wraps the given raw object pointer. + _BlockArgs_ii17hk.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 [_BlockArgs_ii17hk]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_ii17hk, + ); +} + +extension _BlockArgs_ii17hk$Methods on _BlockArgs_ii17hk {} + +extension type _BlockArgs_jqba1._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_jqba1] that points to the same underlying object as [other]. + _BlockArgs_jqba1.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_jqba1] that wraps the given raw object pointer. + _BlockArgs_jqba1.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 [_BlockArgs_jqba1]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_jqba1, + ); +} + +extension _BlockArgs_jqba1$Methods on _BlockArgs_jqba1 { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + NSURLRequest get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return NSURLRequest.fromPointer($ret, retain: true, release: true); + } + + objc.ObjCBlock get arg4 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_uwvaik(_$$ref.pointer, _sel_arg4); + return ObjCBlock_ffiVoid_NSURLSessionDelayedRequestDisposition_NSURLRequest.fromPointer( + $ret, + retain: true, + release: true, + ); + } +} + +extension type _BlockArgs_k1nazc._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_k1nazc] that points to the same underlying object as [other]. + _BlockArgs_k1nazc.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_k1nazc] that wraps the given raw object pointer. + _BlockArgs_k1nazc.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 [_BlockArgs_k1nazc]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_k1nazc, + ); +} + +extension _BlockArgs_k1nazc$Methods on _BlockArgs_k1nazc { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_lsc494._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_lsc494] that points to the same underlying object as [other]. + _BlockArgs_lsc494.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_lsc494] that wraps the given raw object pointer. + _BlockArgs_lsc494.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 [_BlockArgs_lsc494]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_lsc494, + ); +} + +extension _BlockArgs_lsc494$Methods on _BlockArgs_lsc494 { + objc.NSData? get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return $ret.address == 0 + ? null + : objc.NSData.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_pm23bg._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_pm23bg] that points to the same underlying object as [other]. + _BlockArgs_pm23bg.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_pm23bg] that wraps the given raw object pointer. + _BlockArgs_pm23bg.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 [_BlockArgs_pm23bg]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_pm23bg, + ); +} + +extension _BlockArgs_pm23bg$Methods on _BlockArgs_pm23bg { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionDownloadTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionDownloadTask.fromPointer( + $ret, + retain: true, + release: true, + ); + } + + objc.NSURL get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return objc.NSURL.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_qjjttc._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_qjjttc] that points to the same underlying object as [other]. + _BlockArgs_qjjttc.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_qjjttc] that wraps the given raw object pointer. + _BlockArgs_qjjttc.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 [_BlockArgs_qjjttc]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_qjjttc, + ); +} + +extension _BlockArgs_qjjttc$Methods on _BlockArgs_qjjttc { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + objc.NSError? get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return $ret.address == 0 + ? null + : objc.NSError.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_u65oe8._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_u65oe8] that points to the same underlying object as [other]. + _BlockArgs_u65oe8.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_u65oe8] that wraps the given raw object pointer. + _BlockArgs_u65oe8.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 [_BlockArgs_u65oe8]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_u65oe8, + ); +} + +extension _BlockArgs_u65oe8$Methods on _BlockArgs_u65oe8 { + NSURLSessionAuthChallengeDisposition get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_1vfc2dz(_$$ref.pointer, _sel_arg0); + return NSURLSessionAuthChallengeDisposition.fromValue($ret); + } + + NSURLCredential? get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return $ret.address == 0 + ? null + : NSURLCredential.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_wtbfzi._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_wtbfzi] that points to the same underlying object as [other]. + _BlockArgs_wtbfzi.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_wtbfzi] that wraps the given raw object pointer. + _BlockArgs_wtbfzi.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 [_BlockArgs_wtbfzi]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_wtbfzi, + ); +} + +extension _BlockArgs_wtbfzi$Methods on _BlockArgs_wtbfzi { + NSCachedURLResponse? get arg0 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg0); + return $ret.address == 0 + ? null + : NSCachedURLResponse.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_xcrg5s._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_xcrg5s] that points to the same underlying object as [other]. + _BlockArgs_xcrg5s.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_xcrg5s] that wraps the given raw object pointer. + _BlockArgs_xcrg5s.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 [_BlockArgs_xcrg5s]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_xcrg5s, + ); +} + +extension _BlockArgs_xcrg5s$Methods on _BlockArgs_xcrg5s { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionWebSocketTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionWebSocketTask.fromPointer( + $ret, + retain: true, + release: true, + ); + } + + objc.NSString? get arg3 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg3); + return $ret.address == 0 + ? null + : objc.NSString.fromPointer($ret, retain: true, release: true); + } +} + +extension type _BlockArgs_xh08sz._(objc.ObjCObject object$) + implements objc.ObjCObject { + /// Constructs a [_BlockArgs_xh08sz] that points to the same underlying object as [other]. + _BlockArgs_xh08sz.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [_BlockArgs_xh08sz] that wraps the given raw object pointer. + _BlockArgs_xh08sz.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 [_BlockArgs_xh08sz]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class__BlockArgs_xh08sz, + ); +} + +extension _BlockArgs_xh08sz$Methods on _BlockArgs_xh08sz { + ffi.Pointer get arg0 { + final _$$ref = object$.ref; + return _objc_msgSend_6ex6p5(_$$ref.pointer, _sel_arg0); + } + + NSURLSession get arg1 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg1); + return NSURLSession.fromPointer($ret, retain: true, release: true); + } + + NSURLSessionTask get arg2 { + final _$$ref = object$.ref; + final $ret = _objc_msgSend_151sglz(_$$ref.pointer, _sel_arg2); + return NSURLSessionTask.fromPointer($ret, retain: true, release: true); + } + + int get arg3 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg3); + } + + int get arg4 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg4); + } + + int get arg5 { + final _$$ref = object$.ref; + return _objc_msgSend_pysgoz(_$$ref.pointer, _sel_arg5); + } +} + +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSCondition', +) +external ffi.Pointer _class_NSCondition_raw; +final _class_NSCondition = objc.getClass( + "NSCondition", + () => ffi.Native.addressOf>( + _class_NSCondition_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSHTTPURLResponse', +) +external ffi.Pointer _class_NSHTTPURLResponse_raw; +final _class_NSHTTPURLResponse = objc.getClass( + "NSHTTPURLResponse", + () => ffi.Native.addressOf>( + _class_NSHTTPURLResponse_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSMutableURLRequest', +) +external ffi.Pointer _class_NSMutableURLRequest_raw; +final _class_NSMutableURLRequest = objc.getClass( + "NSMutableURLRequest", + () => ffi.Native.addressOf>( + _class_NSMutableURLRequest_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSOperationQueue', +) +external ffi.Pointer _class_NSOperationQueue_raw; +final _class_NSOperationQueue = objc.getClass( + "NSOperationQueue", + () => ffi.Native.addressOf>( + _class_NSOperationQueue_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLCache', +) +external ffi.Pointer _class_NSURLCache_raw; +final _class_NSURLCache = objc.getClass( + "NSURLCache", + () => ffi.Native.addressOf>( + _class_NSURLCache_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLRequest', +) +external ffi.Pointer _class_NSURLRequest_raw; +final _class_NSURLRequest = objc.getClass( + "NSURLRequest", + () => ffi.Native.addressOf>( + _class_NSURLRequest_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLResponse', +) +external ffi.Pointer _class_NSURLResponse_raw; +final _class_NSURLResponse = objc.getClass( + "NSURLResponse", + () => ffi.Native.addressOf>( + _class_NSURLResponse_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLSession', +) +external ffi.Pointer _class_NSURLSession_raw; +final _class_NSURLSession = objc.getClass( + "NSURLSession", + () => ffi.Native.addressOf>( + _class_NSURLSession_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLSessionConfiguration', +) +external ffi.Pointer _class_NSURLSessionConfiguration_raw; +final _class_NSURLSessionConfiguration = objc.getClass( + "NSURLSessionConfiguration", + () => ffi.Native.addressOf>( + _class_NSURLSessionConfiguration_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLSessionDownloadTask', +) +external ffi.Pointer _class_NSURLSessionDownloadTask_raw; +final _class_NSURLSessionDownloadTask = objc.getClass( + "NSURLSessionDownloadTask", + () => ffi.Native.addressOf>( + _class_NSURLSessionDownloadTask_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLSessionTask', +) +external ffi.Pointer _class_NSURLSessionTask_raw; +final _class_NSURLSessionTask = objc.getClass( + "NSURLSessionTask", + () => ffi.Native.addressOf>( + _class_NSURLSessionTask_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLSessionWebSocketMessage', +) +external ffi.Pointer +_class_NSURLSessionWebSocketMessage_raw; +final _class_NSURLSessionWebSocketMessage = objc.getClass( + "NSURLSessionWebSocketMessage", + () => ffi.Native.addressOf>( + _class_NSURLSessionWebSocketMessage_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$_NSURLSessionWebSocketTask', +) +external ffi.Pointer _class_NSURLSessionWebSocketTask_raw; +final _class_NSURLSessionWebSocketTask = objc.getClass( + "NSURLSessionWebSocketTask", + () => ffi.Native.addressOf>( + _class_NSURLSessionWebSocketTask_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_bklti2', +) +external ffi.Pointer _class__BlockArgs_112ozxo_raw; +final _class__BlockArgs_112ozxo = objc.getClass( + "_1tf3our_BlockArgs_bklti2", + () => ffi.Native.addressOf>( + _class__BlockArgs_112ozxo_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xtuoz7', +) +external ffi.Pointer _class__BlockArgs_117e0ww_raw; +final _class__BlockArgs_117e0ww = objc.getClass( + "_1tf3our_BlockArgs_xtuoz7", + () => ffi.Native.addressOf>( + _class__BlockArgs_117e0ww_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_pfv6jd', +) +external ffi.Pointer _class__BlockArgs_130i0xx_raw; +final _class__BlockArgs_130i0xx = objc.getClass( + "_1tf3our_BlockArgs_pfv6jd", + () => ffi.Native.addressOf>( + _class__BlockArgs_130i0xx_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1tz5yf', +) +external ffi.Pointer _class__BlockArgs_140cpyj_raw; +final _class__BlockArgs_140cpyj = objc.getClass( + "_1tf3our_BlockArgs_1tz5yf", + () => ffi.Native.addressOf>( + _class__BlockArgs_140cpyj_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xx612k', +) +external ffi.Pointer _class__BlockArgs_15cdu5z_raw; +final _class__BlockArgs_15cdu5z = objc.getClass( + "_1tf3our_BlockArgs_xx612k", + () => ffi.Native.addressOf>( + _class__BlockArgs_15cdu5z_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1tz5yf', +) +external ffi.Pointer _class__BlockArgs_16ix251_raw; +final _class__BlockArgs_16ix251 = objc.getClass( + "_1tf3our_BlockArgs_1tz5yf", + () => ffi.Native.addressOf>( + _class__BlockArgs_16ix251_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1otpo83', +) +external ffi.Pointer _class__BlockArgs_171cldw_raw; +final _class__BlockArgs_171cldw = objc.getClass( + "_1tf3our_BlockArgs_1otpo83", + () => ffi.Native.addressOf>( + _class__BlockArgs_171cldw_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1lx650f', +) +external ffi.Pointer _class__BlockArgs_17jmtfx_raw; +final _class__BlockArgs_17jmtfx = objc.getClass( + "_1tf3our_BlockArgs_1lx650f", + () => ffi.Native.addressOf>( + _class__BlockArgs_17jmtfx_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_l2g8ke', +) +external ffi.Pointer _class__BlockArgs_1ayzt6i_raw; +final _class__BlockArgs_1ayzt6i = objc.getClass( + "_1tf3our_BlockArgs_l2g8ke", + () => ffi.Native.addressOf>( + _class__BlockArgs_1ayzt6i_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_fjrv01', +) +external ffi.Pointer _class__BlockArgs_1f64crj_raw; +final _class__BlockArgs_1f64crj = objc.getClass( + "_1tf3our_BlockArgs_fjrv01", + () => ffi.Native.addressOf>( + _class__BlockArgs_1f64crj_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_ly2579', +) +external ffi.Pointer _class__BlockArgs_1l7b9ji_raw; +final _class__BlockArgs_1l7b9ji = objc.getClass( + "_1tf3our_BlockArgs_ly2579", + () => ffi.Native.addressOf>( + _class__BlockArgs_1l7b9ji_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_r8gdi7', +) +external ffi.Pointer _class__BlockArgs_1mv87bk_raw; +final _class__BlockArgs_1mv87bk = objc.getClass( + "_1tf3our_BlockArgs_r8gdi7", + () => ffi.Native.addressOf>( + _class__BlockArgs_1mv87bk_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1tz5yf', +) +external ffi.Pointer _class__BlockArgs_1n5meg5_raw; +final _class__BlockArgs_1n5meg5 = objc.getClass( + "_1tf3our_BlockArgs_1tz5yf", + () => ffi.Native.addressOf>( + _class__BlockArgs_1n5meg5_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xtuoz7', +) +external ffi.Pointer _class__BlockArgs_1n6ph2_raw; +final _class__BlockArgs_1n6ph2 = objc.getClass( + "_1tf3our_BlockArgs_xtuoz7", + () => ffi.Native.addressOf>( + _class__BlockArgs_1n6ph2_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_h68abb', +) +external ffi.Pointer _class__BlockArgs_1pfucun_raw; +final _class__BlockArgs_1pfucun = objc.getClass( + "_1tf3our_BlockArgs_h68abb", + () => ffi.Native.addressOf>( + _class__BlockArgs_1pfucun_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xtuoz7', +) +external ffi.Pointer _class__BlockArgs_1ucj4uc_raw; +final _class__BlockArgs_1ucj4uc = objc.getClass( + "_1tf3our_BlockArgs_xtuoz7", + () => ffi.Native.addressOf>( + _class__BlockArgs_1ucj4uc_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xtuoz7', +) +external ffi.Pointer _class__BlockArgs_1ura76_raw; +final _class__BlockArgs_1ura76 = objc.getClass( + "_1tf3our_BlockArgs_xtuoz7", + () => ffi.Native.addressOf>( + _class__BlockArgs_1ura76_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xx612k', +) +external ffi.Pointer _class__BlockArgs_1xfn2k3_raw; +final _class__BlockArgs_1xfn2k3 = objc.getClass( + "_1tf3our_BlockArgs_xx612k", + () => ffi.Native.addressOf>( + _class__BlockArgs_1xfn2k3_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_16sve1d', +) +external ffi.Pointer _class__BlockArgs_1y7f3jy_raw; +final _class__BlockArgs_1y7f3jy = objc.getClass( + "_1tf3our_BlockArgs_16sve1d", + () => ffi.Native.addressOf>( + _class__BlockArgs_1y7f3jy_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xx612k', +) +external ffi.Pointer _class__BlockArgs_31cygh_raw; +final _class__BlockArgs_31cygh = objc.getClass( + "_1tf3our_BlockArgs_xx612k", + () => ffi.Native.addressOf>( + _class__BlockArgs_31cygh_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_r8gdi7', +) +external ffi.Pointer _class__BlockArgs_3gru2r_raw; +final _class__BlockArgs_3gru2r = objc.getClass( + "_1tf3our_BlockArgs_r8gdi7", + () => ffi.Native.addressOf>( + _class__BlockArgs_3gru2r_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1tz5yf', +) +external ffi.Pointer _class__BlockArgs_43hp0b_raw; +final _class__BlockArgs_43hp0b = objc.getClass( + "_1tf3our_BlockArgs_1tz5yf", + () => ffi.Native.addressOf>( + _class__BlockArgs_43hp0b_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_18v1jvf', +) +external ffi.Pointer _class__BlockArgs_7xicdf_raw; +final _class__BlockArgs_7xicdf = objc.getClass( + "_1tf3our_BlockArgs_18v1jvf", + () => ffi.Native.addressOf>( + _class__BlockArgs_7xicdf_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_jyim80', +) +external ffi.Pointer _class__BlockArgs_99x6vt_raw; +final _class__BlockArgs_99x6vt = objc.getClass( + "_1tf3our_BlockArgs_jyim80", + () => ffi.Native.addressOf>( + _class__BlockArgs_99x6vt_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_bklti2', +) +external ffi.Pointer _class__BlockArgs_de64m_raw; +final _class__BlockArgs_de64m = objc.getClass( + "_1tf3our_BlockArgs_bklti2", + () => ffi.Native.addressOf>( + _class__BlockArgs_de64m_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1tz5yf', +) +external ffi.Pointer _class__BlockArgs_i7wriu_raw; +final _class__BlockArgs_i7wriu = objc.getClass( + "_1tf3our_BlockArgs_1tz5yf", + () => ffi.Native.addressOf>( + _class__BlockArgs_i7wriu_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_r8gdi7', +) +external ffi.Pointer _class__BlockArgs_ih4kg4_raw; +final _class__BlockArgs_ih4kg4 = objc.getClass( + "_1tf3our_BlockArgs_r8gdi7", + () => ffi.Native.addressOf>( + _class__BlockArgs_ih4kg4_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1pl9qdv', +) +external ffi.Pointer _class__BlockArgs_ii17hk_raw; +final _class__BlockArgs_ii17hk = objc.getClass( + "_1tf3our_BlockArgs_1pl9qdv", + () => ffi.Native.addressOf>( + _class__BlockArgs_ii17hk_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xx612k', +) +external ffi.Pointer _class__BlockArgs_jqba1_raw; +final _class__BlockArgs_jqba1 = objc.getClass( + "_1tf3our_BlockArgs_xx612k", + () => ffi.Native.addressOf>( + _class__BlockArgs_jqba1_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_fjrv01', +) +external ffi.Pointer _class__BlockArgs_k1nazc_raw; +final _class__BlockArgs_k1nazc = objc.getClass( + "_1tf3our_BlockArgs_fjrv01", + () => ffi.Native.addressOf>( + _class__BlockArgs_k1nazc_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xtuoz7', +) +external ffi.Pointer _class__BlockArgs_lsc494_raw; +final _class__BlockArgs_lsc494 = objc.getClass( + "_1tf3our_BlockArgs_xtuoz7", + () => ffi.Native.addressOf>( + _class__BlockArgs_lsc494_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1tz5yf', +) +external ffi.Pointer _class__BlockArgs_pm23bg_raw; +final _class__BlockArgs_pm23bg = objc.getClass( + "_1tf3our_BlockArgs_1tz5yf", + () => ffi.Native.addressOf>( + _class__BlockArgs_pm23bg_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1tz5yf', +) +external ffi.Pointer _class__BlockArgs_qjjttc_raw; +final _class__BlockArgs_qjjttc = objc.getClass( + "_1tf3our_BlockArgs_1tz5yf", + () => ffi.Native.addressOf>( + _class__BlockArgs_qjjttc_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_n8yd09', +) +external ffi.Pointer _class__BlockArgs_u65oe8_raw; +final _class__BlockArgs_u65oe8 = objc.getClass( + "_1tf3our_BlockArgs_n8yd09", + () => ffi.Native.addressOf>( + _class__BlockArgs_u65oe8_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_xtuoz7', +) +external ffi.Pointer _class__BlockArgs_wtbfzi_raw; +final _class__BlockArgs_wtbfzi = objc.getClass( + "_1tf3our_BlockArgs_xtuoz7", + () => ffi.Native.addressOf>( + _class__BlockArgs_wtbfzi_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_1tz5yf', +) +external ffi.Pointer _class__BlockArgs_xcrg5s_raw; +final _class__BlockArgs_xcrg5s = objc.getClass( + "_1tf3our_BlockArgs_1tz5yf", + () => ffi.Native.addressOf>( + _class__BlockArgs_xcrg5s_raw, + ).cast(), +); +@ffi.Native>( + symbol: 'OBJC_CLASS_\$__1tf3our_BlockArgs_h68abb', +) +external ffi.Pointer _class__BlockArgs_xh08sz_raw; +final _class__BlockArgs_xh08sz = objc.getClass( + "_1tf3our_BlockArgs_h68abb", + () => ffi.Native.addressOf>( + _class__BlockArgs_xh08sz_raw, + ).cast(), +); +final _objc_msgSend_104dkoq = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +final _objc_msgSend_129c579 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_151sglz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +final _objc_msgSend_1hz7y9r = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +final _objc_msgSend_1k101e3 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.LongLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +final _objc_msgSend_1mse4s1 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +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, + ) + >(); +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, + ) + >(); +final _objc_msgSend_1pl9qdv = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1qouven = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1rhk8uh = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +final _objc_msgSend_1vfc2dz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1vze0g9 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1wxwnc0 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1yjxuv2 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +final _objc_msgSend_6ex6p5 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +final _objc_msgSend_8jm3uo = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_91o635 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +final _objc_msgSend_9jpwfb = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Uint16 Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +final _objc_msgSend_cbopi9 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedInt Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +final _objc_msgSend_i3avs9 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +final _objc_msgSend_oi8iq9 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +final _objc_msgSend_pysgoz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +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, + ) + >(); +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, + ) + >(); +final _objc_msgSend_t4uaw1 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +final _objc_msgSend_tyifel = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_uwvaik = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +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, + ) + >(); +final _objc_msgSend_xw2lbc = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +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, + ) + >(); +@ffi.Native Function()>( + symbol: '_1tf3our_NSURLSessionDataDelegate', +) +external ffi.Pointer +_protocol_NSURLSessionDataDelegate_raw(); +final _protocol_NSURLSessionDataDelegate = objc.getProtocol( + "NSURLSessionDataDelegate", + _protocol_NSURLSessionDataDelegate_raw, +); +@ffi.Native Function()>( + symbol: '_1tf3our_NSURLSessionDownloadDelegate', +) +external ffi.Pointer +_protocol_NSURLSessionDownloadDelegate_raw(); +final _protocol_NSURLSessionDownloadDelegate = objc.getProtocol( + "NSURLSessionDownloadDelegate", + _protocol_NSURLSessionDownloadDelegate_raw, +); +@ffi.Native Function()>( + symbol: '_1tf3our_NSURLSessionWebSocketDelegate', +) +external ffi.Pointer +_protocol_NSURLSessionWebSocketDelegate_raw(); +final _protocol_NSURLSessionWebSocketDelegate = objc.getProtocol( + "NSURLSessionWebSocketDelegate", + _protocol_NSURLSessionWebSocketDelegate_raw, +); +late final _sel_HTTPAdditionalHeaders = objc.registerName( + "HTTPAdditionalHeaders", +); +late final _sel_HTTPBody = objc.registerName("HTTPBody"); +late final _sel_HTTPBodyStream = objc.registerName("HTTPBodyStream"); +late final _sel_HTTPCookieAcceptPolicy = objc.registerName( + "HTTPCookieAcceptPolicy", +); +late final _sel_HTTPCookieStorage = objc.registerName("HTTPCookieStorage"); +late final _sel_HTTPMaximumConnectionsPerHost = objc.registerName( + "HTTPMaximumConnectionsPerHost", +); +late final _sel_HTTPMethod = objc.registerName("HTTPMethod"); +late final _sel_HTTPShouldHandleCookies = objc.registerName( + "HTTPShouldHandleCookies", +); +late final _sel_HTTPShouldSetCookies = objc.registerName( + "HTTPShouldSetCookies", +); +late final _sel_HTTPShouldUsePipelining = objc.registerName( + "HTTPShouldUsePipelining", +); +late final _sel_MIMEType = objc.registerName("MIMEType"); +late final _sel_TLSMaximumSupportedProtocol = objc.registerName( + "TLSMaximumSupportedProtocol", +); +late final _sel_TLSMaximumSupportedProtocolVersion = objc.registerName( + "TLSMaximumSupportedProtocolVersion", +); +late final _sel_TLSMinimumSupportedProtocol = objc.registerName( + "TLSMinimumSupportedProtocol", +); +late final _sel_TLSMinimumSupportedProtocolVersion = objc.registerName( + "TLSMinimumSupportedProtocolVersion", +); +late final _sel_URL = objc.registerName("URL"); +late final _sel_URLCache = objc.registerName("URLCache"); +late final _sel_URLCredentialStorage = objc.registerName( + "URLCredentialStorage", +); +late final _sel_URLSessionDidFinishEventsForBackgroundURLSession_ = objc + .registerName("URLSessionDidFinishEventsForBackgroundURLSession:"); +late final _sel_URLSession_dataTask_didBecomeDownloadTask_ = objc.registerName( + "URLSession:dataTask:didBecomeDownloadTask:", +); +late final _sel_URLSession_dataTask_didBecomeStreamTask_ = objc.registerName( + "URLSession:dataTask:didBecomeStreamTask:", +); +late final _sel_URLSession_dataTask_didReceiveData_ = objc.registerName( + "URLSession:dataTask:didReceiveData:", +); +late final _sel_URLSession_dataTask_didReceiveResponse_completionHandler_ = objc + .registerName("URLSession:dataTask:didReceiveResponse:completionHandler:"); +late final _sel_URLSession_dataTask_willCacheResponse_completionHandler_ = objc + .registerName("URLSession:dataTask:willCacheResponse:completionHandler:"); +late final _sel_URLSession_didBecomeInvalidWithError_ = objc.registerName( + "URLSession:didBecomeInvalidWithError:", +); +late final _sel_URLSession_didCreateTask_ = objc.registerName( + "URLSession:didCreateTask:", +); +late final _sel_URLSession_didReceiveChallenge_completionHandler_ = objc + .registerName("URLSession:didReceiveChallenge:completionHandler:"); +late final _sel_URLSession_downloadTask_didFinishDownloadingToURL_ = objc + .registerName("URLSession:downloadTask:didFinishDownloadingToURL:"); +late final _sel_URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes_ = + objc.registerName( + "URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:", + ); +late final _sel_URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite_ = + objc.registerName( + "URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:", + ); +late final _sel_URLSession_taskIsWaitingForConnectivity_ = objc.registerName( + "URLSession:taskIsWaitingForConnectivity:", +); +late final _sel_URLSession_task_didCompleteWithError_ = objc.registerName( + "URLSession:task:didCompleteWithError:", +); +late final _sel_URLSession_task_didFinishCollectingMetrics_ = objc.registerName( + "URLSession:task:didFinishCollectingMetrics:", +); +late final _sel_URLSession_task_didReceiveChallenge_completionHandler_ = objc + .registerName("URLSession:task:didReceiveChallenge:completionHandler:"); +late final _sel_URLSession_task_didReceiveInformationalResponse_ = objc + .registerName("URLSession:task:didReceiveInformationalResponse:"); +late final _sel_URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend_ = + objc.registerName( + "URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:", + ); +late final _sel_URLSession_task_needNewBodyStreamFromOffset_completionHandler_ = + objc.registerName( + "URLSession:task:needNewBodyStreamFromOffset:completionHandler:", + ); +late final _sel_URLSession_task_needNewBodyStream_ = objc.registerName( + "URLSession:task:needNewBodyStream:", +); +late final _sel_URLSession_task_willBeginDelayedRequest_completionHandler_ = + objc.registerName( + "URLSession:task:willBeginDelayedRequest:completionHandler:", + ); +late final _sel_URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ = + objc.registerName( + "URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:", + ); +late final _sel_URLSession_webSocketTask_didCloseWithCode_reason_ = objc + .registerName("URLSession:webSocketTask:didCloseWithCode:reason:"); +late final _sel_URLSession_webSocketTask_didOpenWithProtocol_ = objc + .registerName("URLSession:webSocketTask:didOpenWithProtocol:"); +late final _sel_addBarrierBlock_ = objc.registerName("addBarrierBlock:"); +late final _sel_addOperationWithBlock_ = objc.registerName( + "addOperationWithBlock:", +); +late final _sel_addOperation_ = objc.registerName("addOperation:"); +late final _sel_addOperations_waitUntilFinished_ = objc.registerName( + "addOperations:waitUntilFinished:", +); +late final _sel_addValue_forHTTPHeaderField_ = objc.registerName( + "addValue:forHTTPHeaderField:", +); +late final _sel_allHTTPHeaderFields = objc.registerName("allHTTPHeaderFields"); +late final _sel_allHeaderFields = objc.registerName("allHeaderFields"); +late final _sel_alloc = objc.registerName("alloc"); +late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); +late final _sel_allowsCellularAccess = objc.registerName( + "allowsCellularAccess", +); +late final _sel_allowsConstrainedNetworkAccess = objc.registerName( + "allowsConstrainedNetworkAccess", +); +late final _sel_allowsExpensiveNetworkAccess = objc.registerName( + "allowsExpensiveNetworkAccess", +); +late final _sel_allowsPersistentDNS = objc.registerName("allowsPersistentDNS"); +late final _sel_allowsUltraConstrainedNetworkAccess = objc.registerName( + "allowsUltraConstrainedNetworkAccess", +); +late final _sel_arg0 = objc.registerName("arg0"); +late final _sel_arg1 = objc.registerName("arg1"); +late final _sel_arg2 = objc.registerName("arg2"); +late final _sel_arg3 = objc.registerName("arg3"); +late final _sel_arg4 = objc.registerName("arg4"); +late final _sel_arg5 = objc.registerName("arg5"); +late final _sel_assumesHTTP3Capable = objc.registerName("assumesHTTP3Capable"); +late final _sel_attribution = objc.registerName("attribution"); +late final _sel_backgroundSessionConfigurationWithIdentifier_ = objc + .registerName("backgroundSessionConfigurationWithIdentifier:"); +late final _sel_backgroundSessionConfiguration_ = objc.registerName( + "backgroundSessionConfiguration:", +); +late final _sel_broadcast = objc.registerName("broadcast"); +late final _sel_cachePolicy = objc.registerName("cachePolicy"); +late final _sel_cachedResponseForRequest_ = objc.registerName( + "cachedResponseForRequest:", +); +late final _sel_cancel = objc.registerName("cancel"); +late final _sel_cancelAllOperations = objc.registerName("cancelAllOperations"); +late final _sel_cancelByProducingResumeData_ = objc.registerName( + "cancelByProducingResumeData:", +); +late final _sel_cancelWithCloseCode_reason_ = objc.registerName( + "cancelWithCloseCode:reason:", +); +late final _sel_closeCode = objc.registerName("closeCode"); +late final _sel_closeReason = objc.registerName("closeReason"); +late final _sel_configuration = objc.registerName("configuration"); +late final _sel_conformsToProtocol_ = objc.registerName("conformsToProtocol:"); +late final _sel_connectionProxyDictionary = objc.registerName( + "connectionProxyDictionary", +); +late final _sel_cookiePartitionIdentifier = objc.registerName( + "cookiePartitionIdentifier", +); +late final _sel_countOfBytesClientExpectsToReceive = objc.registerName( + "countOfBytesClientExpectsToReceive", +); +late final _sel_countOfBytesClientExpectsToSend = objc.registerName( + "countOfBytesClientExpectsToSend", +); +late final _sel_countOfBytesExpectedToReceive = objc.registerName( + "countOfBytesExpectedToReceive", +); +late final _sel_countOfBytesExpectedToSend = objc.registerName( + "countOfBytesExpectedToSend", +); +late final _sel_countOfBytesReceived = objc.registerName( + "countOfBytesReceived", +); +late final _sel_countOfBytesSent = objc.registerName("countOfBytesSent"); +late final _sel_currentDiskUsage = objc.registerName("currentDiskUsage"); +late final _sel_currentMemoryUsage = objc.registerName("currentMemoryUsage"); +late final _sel_currentQueue = objc.registerName("currentQueue"); +late final _sel_currentRequest = objc.registerName("currentRequest"); +late final _sel_data = objc.registerName("data"); +late final _sel_dataTaskWithRequest_ = objc.registerName( + "dataTaskWithRequest:", +); +late final _sel_dataTaskWithRequest_completionHandler_ = objc.registerName( + "dataTaskWithRequest:completionHandler:", +); +late final _sel_dataTaskWithURL_ = objc.registerName("dataTaskWithURL:"); +late final _sel_dataTaskWithURL_completionHandler_ = objc.registerName( + "dataTaskWithURL:completionHandler:", +); +late final _sel_defaultSessionConfiguration = objc.registerName( + "defaultSessionConfiguration", +); +late final _sel_delegate = objc.registerName("delegate"); +late final _sel_delegateQueue = objc.registerName("delegateQueue"); +late final _sel_diskCapacity = objc.registerName("diskCapacity"); +late final _sel_downloadTaskWithRequest_ = objc.registerName( + "downloadTaskWithRequest:", +); +late final _sel_downloadTaskWithRequest_completionHandler_ = objc.registerName( + "downloadTaskWithRequest:completionHandler:", +); +late final _sel_downloadTaskWithResumeData_ = objc.registerName( + "downloadTaskWithResumeData:", +); +late final _sel_downloadTaskWithResumeData_completionHandler_ = objc + .registerName("downloadTaskWithResumeData:completionHandler:"); +late final _sel_downloadTaskWithURL_ = objc.registerName( + "downloadTaskWithURL:", +); +late final _sel_downloadTaskWithURL_completionHandler_ = objc.registerName( + "downloadTaskWithURL:completionHandler:", +); +late final _sel_earliestBeginDate = objc.registerName("earliestBeginDate"); +late final _sel_enablesEarlyData = objc.registerName("enablesEarlyData"); +late final _sel_encodeWithCoder_ = objc.registerName("encodeWithCoder:"); +late final _sel_ephemeralSessionConfiguration = objc.registerName( + "ephemeralSessionConfiguration", +); +late final _sel_error = objc.registerName("error"); +late final _sel_expectedContentLength = objc.registerName( + "expectedContentLength", +); +late final _sel_finishTasksAndInvalidate = objc.registerName( + "finishTasksAndInvalidate", +); +late final _sel_flushWithCompletionHandler_ = objc.registerName( + "flushWithCompletionHandler:", +); +late final _sel_getAllTasksWithCompletionHandler_ = objc.registerName( + "getAllTasksWithCompletionHandler:", +); +late final _sel_getCachedResponseForDataTask_completionHandler_ = objc + .registerName("getCachedResponseForDataTask:completionHandler:"); +late final _sel_getTasksWithCompletionHandler_ = objc.registerName( + "getTasksWithCompletionHandler:", +); +late final _sel_identifier = objc.registerName("identifier"); +late final _sel_init = objc.registerName("init"); +late final _sel_initWithCoder_ = objc.registerName("initWithCoder:"); +late final _sel_initWithData_ = objc.registerName("initWithData:"); +late final _sel_initWithMemoryCapacity_diskCapacity_directoryURL_ = objc + .registerName("initWithMemoryCapacity:diskCapacity:directoryURL:"); +late final _sel_initWithMemoryCapacity_diskCapacity_diskPath_ = objc + .registerName("initWithMemoryCapacity:diskCapacity:diskPath:"); +late final _sel_initWithString_ = objc.registerName("initWithString:"); +late final _sel_initWithURL_ = objc.registerName("initWithURL:"); +late final _sel_initWithURL_MIMEType_expectedContentLength_textEncodingName_ = + objc.registerName( + "initWithURL:MIMEType:expectedContentLength:textEncodingName:", + ); +late final _sel_initWithURL_cachePolicy_timeoutInterval_ = objc.registerName( + "initWithURL:cachePolicy:timeoutInterval:", +); +late final _sel_initWithURL_statusCode_HTTPVersion_headerFields_ = objc + .registerName("initWithURL:statusCode:HTTPVersion:headerFields:"); +late final _sel_invalidateAndCancel = objc.registerName("invalidateAndCancel"); +late final _sel_isDiscretionary = objc.registerName("isDiscretionary"); +late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); +late final _sel_isSuspended = objc.registerName("isSuspended"); +late final _sel_localizedStringForStatusCode_ = objc.registerName( + "localizedStringForStatusCode:", +); +late final _sel_lock = objc.registerName("lock"); +late final _sel_mainDocumentURL = objc.registerName("mainDocumentURL"); +late final _sel_mainQueue = objc.registerName("mainQueue"); +late final _sel_maxConcurrentOperationCount = objc.registerName( + "maxConcurrentOperationCount", +); +late final _sel_maximumMessageSize = objc.registerName("maximumMessageSize"); +late final _sel_memoryCapacity = objc.registerName("memoryCapacity"); +late final _sel_multipathServiceType = objc.registerName( + "multipathServiceType", +); +late final _sel_name = objc.registerName("name"); +late final _sel_networkServiceType = objc.registerName("networkServiceType"); +late final _sel_new = objc.registerName("new"); +late final _sel_operationCount = objc.registerName("operationCount"); +late final _sel_operations = objc.registerName("operations"); +late final _sel_originalRequest = objc.registerName("originalRequest"); +late final _sel_prefersIncrementalDelivery = objc.registerName( + "prefersIncrementalDelivery", +); +late final _sel_priority = objc.registerName("priority"); +late final _sel_progress = objc.registerName("progress"); +late final _sel_protocolClasses = objc.registerName("protocolClasses"); +late final _sel_qualityOfService = objc.registerName("qualityOfService"); +late final _sel_receiveMessageWithCompletionHandler_ = objc.registerName( + "receiveMessageWithCompletionHandler:", +); +late final _sel_removeAllCachedResponses = objc.registerName( + "removeAllCachedResponses", +); +late final _sel_removeCachedResponseForDataTask_ = objc.registerName( + "removeCachedResponseForDataTask:", +); +late final _sel_removeCachedResponseForRequest_ = objc.registerName( + "removeCachedResponseForRequest:", +); +late final _sel_removeCachedResponsesSinceDate_ = objc.registerName( + "removeCachedResponsesSinceDate:", +); +late final _sel_requestCachePolicy = objc.registerName("requestCachePolicy"); +late final _sel_requestWithURL_ = objc.registerName("requestWithURL:"); +late final _sel_requestWithURL_cachePolicy_timeoutInterval_ = objc.registerName( + "requestWithURL:cachePolicy:timeoutInterval:", +); +late final _sel_requiresDNSSECValidation = objc.registerName( + "requiresDNSSECValidation", +); +late final _sel_resetWithCompletionHandler_ = objc.registerName( + "resetWithCompletionHandler:", +); +late final _sel_response = objc.registerName("response"); +late final _sel_resume = objc.registerName("resume"); +late final _sel_sendMessage_completionHandler_ = objc.registerName( + "sendMessage:completionHandler:", +); +late final _sel_sendPingWithPongReceiveHandler_ = objc.registerName( + "sendPingWithPongReceiveHandler:", +); +late final _sel_sessionDescription = objc.registerName("sessionDescription"); +late final _sel_sessionSendsLaunchEvents = objc.registerName( + "sessionSendsLaunchEvents", +); +late final _sel_sessionWithConfiguration_ = objc.registerName( + "sessionWithConfiguration:", +); +late final _sel_sessionWithConfiguration_delegate_delegateQueue_ = objc + .registerName("sessionWithConfiguration:delegate:delegateQueue:"); +late final _sel_setAllHTTPHeaderFields_ = objc.registerName( + "setAllHTTPHeaderFields:", +); +late final _sel_setAllowsCellularAccess_ = objc.registerName( + "setAllowsCellularAccess:", +); +late final _sel_setAllowsConstrainedNetworkAccess_ = objc.registerName( + "setAllowsConstrainedNetworkAccess:", +); +late final _sel_setAllowsExpensiveNetworkAccess_ = objc.registerName( + "setAllowsExpensiveNetworkAccess:", +); +late final _sel_setAllowsPersistentDNS_ = objc.registerName( + "setAllowsPersistentDNS:", +); +late final _sel_setAllowsUltraConstrainedNetworkAccess_ = objc.registerName( + "setAllowsUltraConstrainedNetworkAccess:", +); +late final _sel_setAssumesHTTP3Capable_ = objc.registerName( + "setAssumesHTTP3Capable:", +); +late final _sel_setAttribution_ = objc.registerName("setAttribution:"); +late final _sel_setCachePolicy_ = objc.registerName("setCachePolicy:"); +late final _sel_setConnectionProxyDictionary_ = objc.registerName( + "setConnectionProxyDictionary:", +); +late final _sel_setCookiePartitionIdentifier_ = objc.registerName( + "setCookiePartitionIdentifier:", +); +late final _sel_setCountOfBytesClientExpectsToReceive_ = objc.registerName( + "setCountOfBytesClientExpectsToReceive:", +); +late final _sel_setCountOfBytesClientExpectsToSend_ = objc.registerName( + "setCountOfBytesClientExpectsToSend:", +); +late final _sel_setDelegate_ = objc.registerName("setDelegate:"); +late final _sel_setDiscretionary_ = objc.registerName("setDiscretionary:"); +late final _sel_setDiskCapacity_ = objc.registerName("setDiskCapacity:"); +late final _sel_setEarliestBeginDate_ = objc.registerName( + "setEarliestBeginDate:", +); +late final _sel_setEnablesEarlyData_ = objc.registerName( + "setEnablesEarlyData:", +); +late final _sel_setHTTPAdditionalHeaders_ = objc.registerName( + "setHTTPAdditionalHeaders:", +); +late final _sel_setHTTPBodyStream_ = objc.registerName("setHTTPBodyStream:"); +late final _sel_setHTTPBody_ = objc.registerName("setHTTPBody:"); +late final _sel_setHTTPCookieAcceptPolicy_ = objc.registerName( + "setHTTPCookieAcceptPolicy:", +); +late final _sel_setHTTPCookieStorage_ = objc.registerName( + "setHTTPCookieStorage:", +); +late final _sel_setHTTPMaximumConnectionsPerHost_ = objc.registerName( + "setHTTPMaximumConnectionsPerHost:", +); +late final _sel_setHTTPMethod_ = objc.registerName("setHTTPMethod:"); +late final _sel_setHTTPShouldHandleCookies_ = objc.registerName( + "setHTTPShouldHandleCookies:", +); +late final _sel_setHTTPShouldSetCookies_ = objc.registerName( + "setHTTPShouldSetCookies:", +); +late final _sel_setHTTPShouldUsePipelining_ = objc.registerName( + "setHTTPShouldUsePipelining:", +); +late final _sel_setMainDocumentURL_ = objc.registerName("setMainDocumentURL:"); +late final _sel_setMaxConcurrentOperationCount_ = objc.registerName( + "setMaxConcurrentOperationCount:", +); +late final _sel_setMaximumMessageSize_ = objc.registerName( + "setMaximumMessageSize:", +); +late final _sel_setMemoryCapacity_ = objc.registerName("setMemoryCapacity:"); +late final _sel_setMultipathServiceType_ = objc.registerName( + "setMultipathServiceType:", +); +late final _sel_setName_ = objc.registerName("setName:"); +late final _sel_setNetworkServiceType_ = objc.registerName( + "setNetworkServiceType:", +); +late final _sel_setPrefersIncrementalDelivery_ = objc.registerName( + "setPrefersIncrementalDelivery:", +); +late final _sel_setPriority_ = objc.registerName("setPriority:"); +late final _sel_setProtocolClasses_ = objc.registerName("setProtocolClasses:"); +late final _sel_setQualityOfService_ = objc.registerName( + "setQualityOfService:", +); +late final _sel_setRequestCachePolicy_ = objc.registerName( + "setRequestCachePolicy:", +); +late final _sel_setRequiresDNSSECValidation_ = objc.registerName( + "setRequiresDNSSECValidation:", +); +late final _sel_setSessionDescription_ = objc.registerName( + "setSessionDescription:", +); +late final _sel_setSessionSendsLaunchEvents_ = objc.registerName( + "setSessionSendsLaunchEvents:", +); +late final _sel_setSharedContainerIdentifier_ = objc.registerName( + "setSharedContainerIdentifier:", +); +late final _sel_setSharedURLCache_ = objc.registerName("setSharedURLCache:"); +late final _sel_setShouldUseExtendedBackgroundIdleMode_ = objc.registerName( + "setShouldUseExtendedBackgroundIdleMode:", +); +late final _sel_setSuspended_ = objc.registerName("setSuspended:"); +late final _sel_setTLSMaximumSupportedProtocolVersion_ = objc.registerName( + "setTLSMaximumSupportedProtocolVersion:", +); +late final _sel_setTLSMaximumSupportedProtocol_ = objc.registerName( + "setTLSMaximumSupportedProtocol:", +); +late final _sel_setTLSMinimumSupportedProtocolVersion_ = objc.registerName( + "setTLSMinimumSupportedProtocolVersion:", +); +late final _sel_setTLSMinimumSupportedProtocol_ = objc.registerName( + "setTLSMinimumSupportedProtocol:", +); +late final _sel_setTaskDescription_ = objc.registerName("setTaskDescription:"); +late final _sel_setTimeoutIntervalForRequest_ = objc.registerName( + "setTimeoutIntervalForRequest:", +); +late final _sel_setTimeoutIntervalForResource_ = objc.registerName( + "setTimeoutIntervalForResource:", +); +late final _sel_setTimeoutInterval_ = objc.registerName("setTimeoutInterval:"); +late final _sel_setURLCache_ = objc.registerName("setURLCache:"); +late final _sel_setURLCredentialStorage_ = objc.registerName( + "setURLCredentialStorage:", +); +late final _sel_setURL_ = objc.registerName("setURL:"); +late final _sel_setUnderlyingQueue_ = objc.registerName("setUnderlyingQueue:"); +late final _sel_setUsesClassicLoadingMode_ = objc.registerName( + "setUsesClassicLoadingMode:", +); +late final _sel_setValue_forHTTPHeaderField_ = objc.registerName( + "setValue:forHTTPHeaderField:", +); +late final _sel_setWaitsForConnectivity_ = objc.registerName( + "setWaitsForConnectivity:", +); +late final _sel_sharedContainerIdentifier = objc.registerName( + "sharedContainerIdentifier", +); +late final _sel_sharedSession = objc.registerName("sharedSession"); +late final _sel_sharedURLCache = objc.registerName("sharedURLCache"); +late final _sel_shouldUseExtendedBackgroundIdleMode = objc.registerName( + "shouldUseExtendedBackgroundIdleMode", +); +late final _sel_signal = objc.registerName("signal"); +late final _sel_state = objc.registerName("state"); +late final _sel_statusCode = objc.registerName("statusCode"); +late final _sel_storeCachedResponse_forDataTask_ = objc.registerName( + "storeCachedResponse:forDataTask:", +); +late final _sel_storeCachedResponse_forRequest_ = objc.registerName( + "storeCachedResponse:forRequest:", +); +late final _sel_streamTaskWithHostName_port_ = objc.registerName( + "streamTaskWithHostName:port:", +); +late final _sel_streamTaskWithNetService_ = objc.registerName( + "streamTaskWithNetService:", +); +late final _sel_string = objc.registerName("string"); +late final _sel_suggestedFilename = objc.registerName("suggestedFilename"); +late final _sel_supportsSecureCoding = objc.registerName( + "supportsSecureCoding", +); +late final _sel_suspend = objc.registerName("suspend"); +late final _sel_taskDescription = objc.registerName("taskDescription"); +late final _sel_taskIdentifier = objc.registerName("taskIdentifier"); +late final _sel_textEncodingName = objc.registerName("textEncodingName"); +late final _sel_timeoutInterval = objc.registerName("timeoutInterval"); +late final _sel_timeoutIntervalForRequest = objc.registerName( + "timeoutIntervalForRequest", +); +late final _sel_timeoutIntervalForResource = objc.registerName( + "timeoutIntervalForResource", +); +late final _sel_type = objc.registerName("type"); +late final _sel_underlyingQueue = objc.registerName("underlyingQueue"); late final _sel_unlock = objc.registerName("unlock"); +late final _sel_uploadTaskWithRequest_fromData_ = objc.registerName( + "uploadTaskWithRequest:fromData:", +); +late final _sel_uploadTaskWithRequest_fromData_completionHandler_ = objc + .registerName("uploadTaskWithRequest:fromData:completionHandler:"); +late final _sel_uploadTaskWithRequest_fromFile_ = objc.registerName( + "uploadTaskWithRequest:fromFile:", +); +late final _sel_uploadTaskWithRequest_fromFile_completionHandler_ = objc + .registerName("uploadTaskWithRequest:fromFile:completionHandler:"); +late final _sel_uploadTaskWithResumeData_ = objc.registerName( + "uploadTaskWithResumeData:", +); +late final _sel_uploadTaskWithResumeData_completionHandler_ = objc.registerName( + "uploadTaskWithResumeData:completionHandler:", +); +late final _sel_uploadTaskWithStreamedRequest_ = objc.registerName( + "uploadTaskWithStreamedRequest:", +); +late final _sel_usesClassicLoadingMode = objc.registerName( + "usesClassicLoadingMode", +); +late final _sel_valueForHTTPHeaderField_ = objc.registerName( + "valueForHTTPHeaderField:", +); +late final _sel_wait = objc.registerName("wait"); +late final _sel_waitUntilAllOperationsAreFinished = objc.registerName( + "waitUntilAllOperationsAreFinished", +); +late final _sel_waitUntilDate_ = objc.registerName("waitUntilDate:"); +late final _sel_waitsForConnectivity = objc.registerName( + "waitsForConnectivity", +); +late final _sel_webSocketTaskWithRequest_ = objc.registerName( + "webSocketTaskWithRequest:", +); +late final _sel_webSocketTaskWithURL_ = objc.registerName( + "webSocketTaskWithURL:", +); +late final _sel_webSocketTaskWithURL_protocols_ = objc.registerName( + "webSocketTaskWithURL:protocols:", +); +typedef instancetype = ffi.Pointer; +typedef Dartinstancetype = objc.ObjCObject; -/// 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() { - 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() { - 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, - ); - } -} - -enum NSOperationQueuePriority { - NSOperationQueuePriorityVeryLow(-8), - NSOperationQueuePriorityLow(-4), - NSOperationQueuePriorityNormal(0), - NSOperationQueuePriorityHigh(4), - NSOperationQueuePriorityVeryHigh(8); +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 NSOperationQueuePriority(this.value); - - static NSOperationQueuePriority fromValue(int value) => switch (value) { - -8 => NSOperationQueuePriorityVeryLow, - -4 => NSOperationQueuePriorityLow, - 0 => NSOperationQueuePriorityNormal, - 4 => NSOperationQueuePriorityHigh, - 8 => NSOperationQueuePriorityVeryHigh, + 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 NSOperationQueuePriority: $value', + 'Unknown value for tls_protocol_version_t: $value', ), }; } diff --git a/pkgs/cupertino_http/pubspec.yaml b/pkgs/cupertino_http/pubspec.yaml index a51fc83164..5c7e9ca360 100644 --- a/pkgs/cupertino_http/pubspec.yaml +++ b/pkgs/cupertino_http/pubspec.yaml @@ -1,5 +1,5 @@ name: cupertino_http -version: 3.0.2 +version: 3.1.0-wip description: >- A macOS/iOS Flutter plugin that provides access to the Foundation URL Loading System. @@ -17,14 +17,14 @@ dependencies: http_profile: ^0.1.0 logging: ^1.3.0 native_toolchain_c: ^0.19.1 - objective_c: ^9.1.0 + objective_c: ^9.5.0 web_socket: '>=0.1.5 <2.0.0' dev_dependencies: convert: ^3.1.1 crypto: ^3.0.3 dart_flutter_team_lints: ^3.0.0 - ffigen: ^20.1.0 + ffigen: ^21.0.0 http_client_conformance_tests: path: ../http_client_conformance_tests/ test: ^1.21.1 diff --git a/pkgs/cupertino_http/src/native_cupertino_bindings.m b/pkgs/cupertino_http/src/native_cupertino_bindings.m index aae636a34a..4e50f0f275 100644 --- a/pkgs/cupertino_http/src/native_cupertino_bindings.m +++ b/pkgs/cupertino_http/src/native_cupertino_bindings.m @@ -29,15 +29,18 @@ void (*exitIsolate)(void); int64_t (*getMainPortId)(void); bool (*getCurrentThreadOwnsIsolate)(int64_t); + void (*invokeListenerPortBlock)(int64_t port, void*); + void (*invokeBlockingPortBlock)(int64_t port, void*, void*); } DOBJC_Context; id objc_retainBlock(id); -#define BLOCKING_BLOCK_IMPL(ctx, BLOCK_SIG, INVOKE_DIRECT, INVOKE_LISTENER) \ +#define BLOCKING_BLOCK_IMPL(ctx, TYPE, SIG, INVOKE_DIRECT, INVOKE_LISTENER) \ assert(ctx->version >= 1); \ void* targetIsolate = ctx->currentIsolate(); \ int64_t targetPort = ctx->getMainPortId == NULL ? 0 : ctx->getMainPortId(); \ - return BLOCK_SIG { \ + __block __weak TYPE weakSelfBlock = nil; \ + TYPE strongSelfBlock = [SIG { \ void* currentIsolate = ctx->currentIsolate(); \ bool mayEnterIsolate = \ currentIsolate == NULL && \ @@ -53,514 +56,1025 @@ } \ } else { \ void* waiter = ctx->newWaiter(); \ + TYPE selfRetain = [weakSelfBlock copy]; \ INVOKE_LISTENER; \ ctx->awaitWaiter(waiter); \ + (void)selfRetain; \ } \ - }; + } copy]; \ + weakSelfBlock = strongSelfBlock; \ + return strongSelfBlock; -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); -} +Protocol* _1tf3our_NSURLSessionDataDelegate(void) { return @protocol(NSURLSessionDataDelegate); } -typedef void (^_ListenerTrampoline)(void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; -} +Protocol* _1tf3our_NSURLSessionDownloadDelegate(void) { return @protocol(NSURLSessionDownloadDelegate); } -typedef void (^_BlockingTrampoline)(void * waiter, void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1)); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1)); - }); -} +Protocol* _1tf3our_NSURLSessionWebSocketDelegate(void) { return @protocol(NSURLSessionWebSocketDelegate); } -typedef void (^_ProtocolTrampoline_1)(void * sel, id arg1); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_1pl9qdv : NSObject +@property (copy) id block; + +@end +@implementation _1tf3our_BlockArgs_1pl9qdv +@end + +typedef void (^_ListenerTrampoline)(void); __attribute__((visibility("default"))) __attribute__((used)) -void _NativeCupertinoHttp_protocolTrampoline_18v1jvf(id target, void * sel, id arg1) { - return ((_ProtocolTrampoline_1)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); +_ListenerTrampoline _1tf3our_wrapListenerBlock_1pl9qdv( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline weakSelfBlock = nil; + _ListenerTrampoline strongSelfBlock = [^void() { + @autoreleasepool { + _1tf3our_BlockArgs_1pl9qdv* args = [[_1tf3our_BlockArgs_1pl9qdv alloc] init]; + args.block = weakSelfBlock; + + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef id (^_ProtocolTrampoline_2)(void * sel, id arg1); +typedef void (^_BlockingTrampoline)(void * waiter); __attribute__((visibility("default"))) __attribute__((used)) -id _NativeCupertinoHttp_protocolTrampoline_xr62hr(id target, void * sel, id arg1) { - return ((_ProtocolTrampoline_2)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); +_ListenerTrampoline _1tf3our_wrapBlockingBlock_1pl9qdv(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline, ^void(), { + @autoreleasepool { + _1tf3our_BlockArgs_1pl9qdv* args = [[_1tf3our_BlockArgs_1pl9qdv alloc] init]; + args.block = weakSelfBlock; + + directInvoke((__bridge_retained void*)args); + } + }, { + @autoreleasepool { + _1tf3our_BlockArgs_1pl9qdv* args = [[_1tf3our_BlockArgs_1pl9qdv alloc] init]; + args.block = weakSelfBlock; + + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } + }); } +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_xtuoz7 : NSObject +@property (copy) id block; +@property (strong) id arg0; +@end +@implementation _1tf3our_BlockArgs_xtuoz7 +@end + typedef void (^_ListenerTrampoline_1)(id arg0); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_1 _1tf3our_wrapListenerBlock_xtuoz7( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_1 weakSelfBlock = nil; + _ListenerTrampoline_1 strongSelfBlock = [^void(id arg0) { + @autoreleasepool { + _1tf3our_BlockArgs_xtuoz7* args = [[_1tf3our_BlockArgs_xtuoz7 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } typedef void (^_BlockingTrampoline_1)(void * waiter, id arg0); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, (__bridge id)(__bridge_retained void*)(arg0)); +_ListenerTrampoline_1 _1tf3our_wrapBlockingBlock_xtuoz7(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_1, ^void(id arg0), { + @autoreleasepool { + _1tf3our_BlockArgs_xtuoz7* args = [[_1tf3our_BlockArgs_xtuoz7 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0)); + @autoreleasepool { + _1tf3our_BlockArgs_xtuoz7* args = [[_1tf3our_BlockArgs_xtuoz7 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef id (^_ProtocolTrampoline_3)(void * sel); -__attribute__((visibility("default"))) __attribute__((used)) -id _NativeCupertinoHttp_protocolTrampoline_1mbt9g9(id target, void * sel) { - return ((_ProtocolTrampoline_3)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); -} +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_r8gdi7 : NSObject +@property (copy) id block; +@property (strong) id arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@end +@implementation _1tf3our_BlockArgs_r8gdi7 +@end -typedef void (^_ListenerTrampoline_2)(void); +typedef void (^_ListenerTrampoline_2)(id arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_2 _NativeCupertinoHttp_wrapListenerBlock_1pl9qdv(_ListenerTrampoline_2 block) NS_RETURNS_RETAINED { - return ^void() { - objc_retainBlock(block); - block(); - }; +_ListenerTrampoline_2 _1tf3our_wrapListenerBlock_r8gdi7( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_2 weakSelfBlock = nil; + _ListenerTrampoline_2 strongSelfBlock = [^void(id arg0, id arg1, id arg2) { + @autoreleasepool { + _1tf3our_BlockArgs_r8gdi7* args = [[_1tf3our_BlockArgs_r8gdi7 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_2)(void * waiter); +typedef void (^_BlockingTrampoline_2)(void * waiter, id arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_2 _NativeCupertinoHttp_wrapBlockingBlock_1pl9qdv( - _BlockingTrampoline_2 block, _BlockingTrampoline_2 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(), { - objc_retainBlock(block); - block(nil); +_ListenerTrampoline_2 _1tf3our_wrapBlockingBlock_r8gdi7(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_2, ^void(id arg0, id arg1, id arg2), { + @autoreleasepool { + _1tf3our_BlockArgs_r8gdi7* args = [[_1tf3our_BlockArgs_r8gdi7 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter); + @autoreleasepool { + _1tf3our_BlockArgs_r8gdi7* args = [[_1tf3our_BlockArgs_r8gdi7 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ListenerTrampoline_3)(id arg0, id arg1, id arg2); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_n8yd09 : NSObject +@property (copy) id block; +@property NSURLSessionAuthChallengeDisposition arg0; +@property (strong) id arg1; +@end +@implementation _1tf3our_BlockArgs_n8yd09 +@end + +typedef void (^_ListenerTrampoline_3)(NSURLSessionAuthChallengeDisposition arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_3 _NativeCupertinoHttp_wrapListenerBlock_r8gdi7(_ListenerTrampoline_3 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)); - }; +_ListenerTrampoline_3 _1tf3our_wrapListenerBlock_n8yd09( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_3 weakSelfBlock = nil; + _ListenerTrampoline_3 strongSelfBlock = [^void(NSURLSessionAuthChallengeDisposition arg0, id arg1) { + @autoreleasepool { + _1tf3our_BlockArgs_n8yd09* args = [[_1tf3our_BlockArgs_n8yd09 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_3)(void * waiter, id arg0, id arg1, id arg2); +typedef void (^_BlockingTrampoline_3)(void * waiter, NSURLSessionAuthChallengeDisposition arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_3 _NativeCupertinoHttp_wrapBlockingBlock_r8gdi7( - _BlockingTrampoline_3 block, _BlockingTrampoline_3 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)); +_ListenerTrampoline_3 _1tf3our_wrapBlockingBlock_n8yd09(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_3, ^void(NSURLSessionAuthChallengeDisposition arg0, id arg1), { + @autoreleasepool { + _1tf3our_BlockArgs_n8yd09* args = [[_1tf3our_BlockArgs_n8yd09 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + @autoreleasepool { + _1tf3our_BlockArgs_n8yd09* args = [[_1tf3our_BlockArgs_n8yd09 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ListenerTrampoline_4)(id arg0, id arg1); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_1otpo83 : NSObject +@property (copy) id block; +@property NSURLSessionDelayedRequestDisposition arg0; +@property (strong) id arg1; +@end +@implementation _1tf3our_BlockArgs_1otpo83 +@end + +typedef void (^_ListenerTrampoline_4)(NSURLSessionDelayedRequestDisposition arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_4 _1tf3our_wrapListenerBlock_1otpo83( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_4 weakSelfBlock = nil; + _ListenerTrampoline_4 strongSelfBlock = [^void(NSURLSessionDelayedRequestDisposition arg0, id arg1) { + @autoreleasepool { + _1tf3our_BlockArgs_1otpo83* args = [[_1tf3our_BlockArgs_1otpo83 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_4)(void * waiter, id arg0, id arg1); +typedef void (^_BlockingTrampoline_4)(void * waiter, NSURLSessionDelayedRequestDisposition arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1)); +_ListenerTrampoline_4 _1tf3our_wrapBlockingBlock_1otpo83(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_4, ^void(NSURLSessionDelayedRequestDisposition arg0, id arg1), { + @autoreleasepool { + _1tf3our_BlockArgs_1otpo83* args = [[_1tf3our_BlockArgs_1otpo83 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1)); + @autoreleasepool { + _1tf3our_BlockArgs_1otpo83* args = [[_1tf3our_BlockArgs_1otpo83 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_16sve1d : NSObject +@property (copy) id block; +@property NSURLSessionResponseDisposition arg0; +@end +@implementation _1tf3our_BlockArgs_16sve1d +@end + typedef void (^_ListenerTrampoline_5)(NSURLSessionResponseDisposition arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_5 _NativeCupertinoHttp_wrapListenerBlock_16sve1d(_ListenerTrampoline_5 block) NS_RETURNS_RETAINED { - return ^void(NSURLSessionResponseDisposition arg0) { - objc_retainBlock(block); - block(arg0); - }; +_ListenerTrampoline_5 _1tf3our_wrapListenerBlock_16sve1d( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_5 weakSelfBlock = nil; + _ListenerTrampoline_5 strongSelfBlock = [^void(NSURLSessionResponseDisposition arg0) { + @autoreleasepool { + _1tf3our_BlockArgs_16sve1d* args = [[_1tf3our_BlockArgs_16sve1d alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } typedef void (^_BlockingTrampoline_5)(void * waiter, NSURLSessionResponseDisposition arg0); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0); +_ListenerTrampoline_5 _1tf3our_wrapBlockingBlock_16sve1d(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_5, ^void(NSURLSessionResponseDisposition arg0), { + @autoreleasepool { + _1tf3our_BlockArgs_16sve1d* args = [[_1tf3our_BlockArgs_16sve1d alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0); + @autoreleasepool { + _1tf3our_BlockArgs_16sve1d* args = [[_1tf3our_BlockArgs_16sve1d alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ListenerTrampoline_6)(NSURLSessionDelayedRequestDisposition arg0, id arg1); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_pfv6jd : NSObject +@property (copy) id block; +@property (strong) id arg0; +@property (strong) id arg1; +@end +@implementation _1tf3our_BlockArgs_pfv6jd +@end + +typedef void (^_ListenerTrampoline_6)(id arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_6 _1tf3our_wrapListenerBlock_pfv6jd( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_6 weakSelfBlock = nil; + _ListenerTrampoline_6 strongSelfBlock = [^void(id arg0, id arg1) { + @autoreleasepool { + _1tf3our_BlockArgs_pfv6jd* args = [[_1tf3our_BlockArgs_pfv6jd alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_6)(void * waiter, NSURLSessionDelayedRequestDisposition arg0, id arg1); +typedef void (^_BlockingTrampoline_6)(void * waiter, id arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1)); +_ListenerTrampoline_6 _1tf3our_wrapBlockingBlock_pfv6jd(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_6, ^void(id arg0, id arg1), { + @autoreleasepool { + _1tf3our_BlockArgs_pfv6jd* args = [[_1tf3our_BlockArgs_pfv6jd alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1)); + @autoreleasepool { + _1tf3our_BlockArgs_pfv6jd* args = [[_1tf3our_BlockArgs_pfv6jd alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ListenerTrampoline_7)(void * arg0, id arg1, id arg2, id arg3, id arg4); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_18v1jvf : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@end +@implementation _1tf3our_BlockArgs_18v1jvf +@end + +typedef void (^_ListenerTrampoline_7)(void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_7 _1tf3our_wrapListenerBlock_18v1jvf( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_7 weakSelfBlock = nil; + _ListenerTrampoline_7 strongSelfBlock = [^void(void * arg0, id arg1) { + @autoreleasepool { + _1tf3our_BlockArgs_18v1jvf* args = [[_1tf3our_BlockArgs_18v1jvf alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_7)(void * waiter, void * arg0, id arg1, id arg2, id arg3, id arg4); +typedef void (^_BlockingTrampoline_7)(void * waiter, void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), (__bridge id)(__bridge_retained void*)(arg3), objc_retainBlock(arg4)); +_ListenerTrampoline_7 _1tf3our_wrapBlockingBlock_18v1jvf(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_7, ^void(void * arg0, id arg1), { + @autoreleasepool { + _1tf3our_BlockArgs_18v1jvf* args = [[_1tf3our_BlockArgs_18v1jvf alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), (__bridge id)(__bridge_retained void*)(arg3), objc_retainBlock(arg4)); + @autoreleasepool { + _1tf3our_BlockArgs_18v1jvf* args = [[_1tf3our_BlockArgs_18v1jvf alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_4)(void * sel, id arg1, id arg2, id arg3, id arg4); +typedef void (^_ProtocolTrampoline)(void * sel, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -void _NativeCupertinoHttp_protocolTrampoline_xx612k(id target, void * sel, id arg1, id arg2, id arg3, id arg4) { - return ((_ProtocolTrampoline_4)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); +void _1tf3our_protocolTrampoline_18v1jvf(id target, void * sel, id arg1) { + return ((_ProtocolTrampoline)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); } -typedef void (^_ListenerTrampoline_8)(void * arg0, id arg1, id arg2, id arg3); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_fjrv01 : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@end +@implementation _1tf3our_BlockArgs_fjrv01 +@end + +typedef void (^_ListenerTrampoline_8)(void * arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_8 _1tf3our_wrapListenerBlock_fjrv01( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_8 weakSelfBlock = nil; + _ListenerTrampoline_8 strongSelfBlock = [^void(void * arg0, id arg1, id arg2) { + @autoreleasepool { + _1tf3our_BlockArgs_fjrv01* args = [[_1tf3our_BlockArgs_fjrv01 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_8)(void * waiter, void * arg0, id arg1, id arg2, id arg3); +typedef void (^_BlockingTrampoline_8)(void * waiter, void * arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), (__bridge id)(__bridge_retained void*)(arg3)); +_ListenerTrampoline_8 _1tf3our_wrapBlockingBlock_fjrv01(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_8, ^void(void * arg0, id arg1, id arg2), { + @autoreleasepool { + _1tf3our_BlockArgs_fjrv01* args = [[_1tf3our_BlockArgs_fjrv01 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), (__bridge id)(__bridge_retained void*)(arg3)); + @autoreleasepool { + _1tf3our_BlockArgs_fjrv01* args = [[_1tf3our_BlockArgs_fjrv01 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_5)(void * sel, id arg1, id arg2, id arg3); +typedef void (^_ProtocolTrampoline_1)(void * sel, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -void _NativeCupertinoHttp_protocolTrampoline_1tz5yf(id target, void * sel, id arg1, id arg2, id arg3) { - return ((_ProtocolTrampoline_5)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); +void _1tf3our_protocolTrampoline_fjrv01(id target, void * sel, id arg1, id arg2) { + return ((_ProtocolTrampoline_1)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); } -typedef void (^_ListenerTrampoline_9)(void * arg0, id arg1, id arg2); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_bklti2 : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@property (copy) id arg3; +@end +@implementation _1tf3our_BlockArgs_bklti2 +@end + +typedef void (^_ListenerTrampoline_9)(void * arg0, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_9 _1tf3our_wrapListenerBlock_bklti2( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_9 weakSelfBlock = nil; + _ListenerTrampoline_9 strongSelfBlock = [^void(void * arg0, id arg1, id arg2, id arg3) { + @autoreleasepool { + _1tf3our_BlockArgs_bklti2* args = [[_1tf3our_BlockArgs_bklti2 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_9)(void * waiter, void * arg0, id arg1, id arg2); +typedef void (^_BlockingTrampoline_9)(void * waiter, void * arg0, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); +_ListenerTrampoline_9 _1tf3our_wrapBlockingBlock_bklti2(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_9, ^void(void * arg0, id arg1, id arg2, id arg3), { + @autoreleasepool { + _1tf3our_BlockArgs_bklti2* args = [[_1tf3our_BlockArgs_bklti2 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + @autoreleasepool { + _1tf3our_BlockArgs_bklti2* args = [[_1tf3our_BlockArgs_bklti2 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_6)(void * sel, id arg1, id arg2); +typedef void (^_ProtocolTrampoline_2)(void * sel, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -void _NativeCupertinoHttp_protocolTrampoline_fjrv01(id target, void * sel, id arg1, id arg2) { - return ((_ProtocolTrampoline_6)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); +void _1tf3our_protocolTrampoline_bklti2(id target, void * sel, id arg1, id arg2, id arg3) { + return ((_ProtocolTrampoline_2)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); } -typedef void (^_ListenerTrampoline_10)(void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_xx612k : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@property (strong) id arg3; +@property (copy) id arg4; +@end +@implementation _1tf3our_BlockArgs_xx612k +@end + +typedef void (^_ListenerTrampoline_10)(void * arg0, id arg1, id arg2, id arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_10 _1tf3our_wrapListenerBlock_xx612k( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_10 weakSelfBlock = nil; + _ListenerTrampoline_10 strongSelfBlock = [^void(void * arg0, id arg1, id arg2, id arg3, id arg4) { + @autoreleasepool { + _1tf3our_BlockArgs_xx612k* args = [[_1tf3our_BlockArgs_xx612k alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_10)(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); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, 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)); +_ListenerTrampoline_10 _1tf3our_wrapBlockingBlock_xx612k(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_10, ^void(void * arg0, id arg1, id arg2, id arg3, id arg4), { + @autoreleasepool { + _1tf3our_BlockArgs_xx612k* args = [[_1tf3our_BlockArgs_xx612k alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, 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)); + @autoreleasepool { + _1tf3our_BlockArgs_xx612k* args = [[_1tf3our_BlockArgs_xx612k alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -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_7)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4, arg5); -} - -typedef void (^_ListenerTrampoline_11)(NSURLSessionAuthChallengeDisposition arg0, id arg1); +typedef void (^_ProtocolTrampoline_3)(void * sel, id arg1, id arg2, id arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +void _1tf3our_protocolTrampoline_xx612k(id target, void * sel, id arg1, id arg2, id arg3, id arg4) { + return ((_ProtocolTrampoline_3)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } -typedef void (^_BlockingTrampoline_11)(void * waiter, NSURLSessionAuthChallengeDisposition arg0, id arg1); -__attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1)); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1)); - }); -} +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_1tz5yf : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@property (strong) id arg3; +@end +@implementation _1tf3our_BlockArgs_1tz5yf +@end -typedef void (^_ListenerTrampoline_12)(void * arg0, id arg1, id arg2, id arg3); +typedef void (^_ListenerTrampoline_11)(void * arg0, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_11 _1tf3our_wrapListenerBlock_1tz5yf( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_11 weakSelfBlock = nil; + _ListenerTrampoline_11 strongSelfBlock = [^void(void * arg0, id arg1, id arg2, id arg3) { + @autoreleasepool { + _1tf3our_BlockArgs_1tz5yf* args = [[_1tf3our_BlockArgs_1tz5yf alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_12)(void * waiter, void * arg0, id arg1, id arg2, id arg3); +typedef void (^_BlockingTrampoline_11)(void * waiter, void * arg0, id arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), objc_retainBlock(arg3)); +_ListenerTrampoline_11 _1tf3our_wrapBlockingBlock_1tz5yf(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_11, ^void(void * arg0, id arg1, id arg2, id arg3), { + @autoreleasepool { + _1tf3our_BlockArgs_1tz5yf* args = [[_1tf3our_BlockArgs_1tz5yf alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), objc_retainBlock(arg3)); + @autoreleasepool { + _1tf3our_BlockArgs_1tz5yf* args = [[_1tf3our_BlockArgs_1tz5yf alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_8)(void * sel, id arg1, id arg2, id arg3); +typedef void (^_ProtocolTrampoline_4)(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_8)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); +void _1tf3our_protocolTrampoline_1tz5yf(id target, void * sel, id arg1, id arg2, id arg3) { + return ((_ProtocolTrampoline_4)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); } -typedef void (^_ListenerTrampoline_13)(void * arg0, id arg1, id arg2, int64_t arg3, id arg4); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_ly2579 : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@property int64_t arg3; +@property int64_t arg4; +@end +@implementation _1tf3our_BlockArgs_ly2579 +@end + +typedef void (^_ListenerTrampoline_12)(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_12 _1tf3our_wrapListenerBlock_ly2579( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_12 weakSelfBlock = nil; + _ListenerTrampoline_12 strongSelfBlock = [^void(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4) { + @autoreleasepool { + _1tf3our_BlockArgs_ly2579* args = [[_1tf3our_BlockArgs_ly2579 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_13)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, id arg4); +typedef void (^_BlockingTrampoline_12)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, objc_retainBlock(arg4)); +_ListenerTrampoline_12 _1tf3our_wrapBlockingBlock_ly2579(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_12, ^void(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4), { + @autoreleasepool { + _1tf3our_BlockArgs_ly2579* args = [[_1tf3our_BlockArgs_ly2579 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, objc_retainBlock(arg4)); + @autoreleasepool { + _1tf3our_BlockArgs_ly2579* args = [[_1tf3our_BlockArgs_ly2579 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_9)(void * sel, id arg1, id arg2, int64_t arg3, id arg4); +typedef void (^_ProtocolTrampoline_5)(void * sel, id arg1, id arg2, int64_t arg3, int64_t 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_9)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); +void _1tf3our_protocolTrampoline_ly2579(id target, void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4) { + return ((_ProtocolTrampoline_5)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } -typedef void (^_ListenerTrampoline_14)(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_h68abb : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@property int64_t arg3; +@property int64_t arg4; +@property int64_t arg5; +@end +@implementation _1tf3our_BlockArgs_h68abb +@end + +typedef void (^_ListenerTrampoline_13)(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); __attribute__((visibility("default"))) __attribute__((used)) -_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); - }; +_ListenerTrampoline_13 _1tf3our_wrapListenerBlock_h68abb( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_13 weakSelfBlock = nil; + _ListenerTrampoline_13 strongSelfBlock = [^void(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5) { + @autoreleasepool { + _1tf3our_BlockArgs_h68abb* args = [[_1tf3our_BlockArgs_h68abb alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + args.arg5 = arg5; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_14)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); +typedef void (^_BlockingTrampoline_13)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, arg4, arg5); +_ListenerTrampoline_13 _1tf3our_wrapBlockingBlock_h68abb(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_13, ^void(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5), { + @autoreleasepool { + _1tf3our_BlockArgs_h68abb* args = [[_1tf3our_BlockArgs_h68abb alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + args.arg5 = arg5; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, arg4, arg5); + @autoreleasepool { + _1tf3our_BlockArgs_h68abb* args = [[_1tf3our_BlockArgs_h68abb alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + args.arg5 = arg5; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_10)(void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5); +typedef void (^_ProtocolTrampoline_6)(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_10)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4, arg5); +void _1tf3our_protocolTrampoline_h68abb(id target, void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4, int64_t arg5) { + return ((_ProtocolTrampoline_6)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4, arg5); } -Protocol* _NativeCupertinoHttp_NSURLSessionDataDelegate(void) { return @protocol(NSURLSessionDataDelegate); } +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_jyim80 : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@property int64_t arg3; +@property (copy) id arg4; +@end +@implementation _1tf3our_BlockArgs_jyim80 +@end -typedef void (^_ListenerTrampoline_15)(void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4); +typedef void (^_ListenerTrampoline_14)(void * arg0, id arg1, id arg2, int64_t arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_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); - }; +_ListenerTrampoline_14 _1tf3our_wrapListenerBlock_jyim80( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_14 weakSelfBlock = nil; + _ListenerTrampoline_14 strongSelfBlock = [^void(void * arg0, id arg1, id arg2, int64_t arg3, id arg4) { + @autoreleasepool { + _1tf3our_BlockArgs_jyim80* args = [[_1tf3our_BlockArgs_jyim80 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_15)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, int64_t arg4); +typedef void (^_BlockingTrampoline_14)(void * waiter, void * arg0, id arg1, id arg2, int64_t arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, arg4); +_ListenerTrampoline_14 _1tf3our_wrapBlockingBlock_jyim80(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_14, ^void(void * arg0, id arg1, id arg2, int64_t arg3, id arg4), { + @autoreleasepool { + _1tf3our_BlockArgs_jyim80* args = [[_1tf3our_BlockArgs_jyim80 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, arg4); + @autoreleasepool { + _1tf3our_BlockArgs_jyim80* args = [[_1tf3our_BlockArgs_jyim80 alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_11)(void * sel, id arg1, id arg2, int64_t arg3, int64_t arg4); +typedef void (^_ProtocolTrampoline_7)(void * sel, id arg1, id arg2, int64_t arg3, id 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_11)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); +void _1tf3our_protocolTrampoline_jyim80(id target, void * sel, id arg1, id arg2, int64_t arg3, id arg4) { + return ((_ProtocolTrampoline_7)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } -Protocol* _NativeCupertinoHttp_NSURLSessionDownloadDelegate(void) { return @protocol(NSURLSessionDownloadDelegate); } +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_l2g8ke : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@property (strong) id arg3; +@property (strong) id arg4; +@property (copy) id arg5; +@end +@implementation _1tf3our_BlockArgs_l2g8ke +@end -typedef void (^_ListenerTrampoline_16)(void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); +typedef void (^_ListenerTrampoline_15)(void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5); __attribute__((visibility("default"))) __attribute__((used)) -_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)); - }; +_ListenerTrampoline_15 _1tf3our_wrapListenerBlock_l2g8ke( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_15 weakSelfBlock = nil; + _ListenerTrampoline_15 strongSelfBlock = [^void(void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5) { + @autoreleasepool { + _1tf3our_BlockArgs_l2g8ke* args = [[_1tf3our_BlockArgs_l2g8ke alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + args.arg5 = arg5; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_16)(void * waiter, void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); +typedef void (^_BlockingTrampoline_15)(void * waiter, void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, (__bridge id)(__bridge_retained void*)(arg4)); +_ListenerTrampoline_15 _1tf3our_wrapBlockingBlock_l2g8ke(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_15, ^void(void * arg0, id arg1, id arg2, id arg3, id arg4, id arg5), { + @autoreleasepool { + _1tf3our_BlockArgs_l2g8ke* args = [[_1tf3our_BlockArgs_l2g8ke alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + args.arg5 = arg5; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), arg3, (__bridge id)(__bridge_retained void*)(arg4)); + @autoreleasepool { + _1tf3our_BlockArgs_l2g8ke* args = [[_1tf3our_BlockArgs_l2g8ke alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + args.arg5 = arg5; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_12)(void * sel, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); +typedef void (^_ProtocolTrampoline_8)(void * sel, id arg1, id arg2, id arg3, id arg4, id arg5); __attribute__((visibility("default"))) __attribute__((used)) -void _NativeCupertinoHttp_protocolTrampoline_1lx650f(id target, void * sel, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4) { - return ((_ProtocolTrampoline_12)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); +void _1tf3our_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); } -Protocol* _NativeCupertinoHttp_NSURLSessionWebSocketDelegate(void) { return @protocol(NSURLSessionWebSocketDelegate); } +__attribute__((visibility("default"))) +@interface _1tf3our_BlockArgs_1lx650f : NSObject +@property (copy) id block; +@property void * arg0; +@property (strong) id arg1; +@property (strong) id arg2; +@property NSURLSessionWebSocketCloseCode arg3; +@property (strong) id arg4; +@end +@implementation _1tf3our_BlockArgs_1lx650f +@end -typedef void (^_ListenerTrampoline_17)(void * arg0); +typedef void (^_ListenerTrampoline_16)(void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_17 _NativeCupertinoHttp_wrapListenerBlock_ovsamd(_ListenerTrampoline_17 block) NS_RETURNS_RETAINED { - return ^void(void * arg0) { - objc_retainBlock(block); - block(arg0); - }; +_ListenerTrampoline_16 _1tf3our_wrapListenerBlock_1lx650f( + int64_t port, DOBJC_Context* ctx) NS_RETURNS_RETAINED { + __block __weak _ListenerTrampoline_16 weakSelfBlock = nil; + _ListenerTrampoline_16 strongSelfBlock = [^void(void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4) { + @autoreleasepool { + _1tf3our_BlockArgs_1lx650f* args = [[_1tf3our_BlockArgs_1lx650f alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + ctx->invokeListenerPortBlock(port, (__bridge_retained void*)args); + } + } copy]; + weakSelfBlock = strongSelfBlock; + return strongSelfBlock; } -typedef void (^_BlockingTrampoline_17)(void * waiter, void * arg0); +typedef void (^_BlockingTrampoline_16)(void * waiter, void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -_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); - block(nil, arg0); +_ListenerTrampoline_16 _1tf3our_wrapBlockingBlock_1lx650f(int64_t port, DOBJC_Context* ctx, + void (*directInvoke)(void*)) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, _ListenerTrampoline_16, ^void(void * arg0, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4), { + @autoreleasepool { + _1tf3our_BlockArgs_1lx650f* args = [[_1tf3our_BlockArgs_1lx650f alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + directInvoke((__bridge_retained void*)args); + } }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0); + @autoreleasepool { + _1tf3our_BlockArgs_1lx650f* args = [[_1tf3our_BlockArgs_1lx650f alloc] init]; + args.block = weakSelfBlock; + args.arg0 = arg0; + args.arg1 = arg1; + args.arg2 = arg2; + args.arg3 = arg3; + args.arg4 = arg4; + ctx->invokeBlockingPortBlock(port, (__bridge_retained void*)args, waiter); + } }); } -typedef void (^_ProtocolTrampoline_13)(void * sel); +typedef void (^_ProtocolTrampoline_9)(void * sel, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4); __attribute__((visibility("default"))) __attribute__((used)) -void _NativeCupertinoHttp_protocolTrampoline_ovsamd(id target, void * sel) { - return ((_ProtocolTrampoline_13)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); +void _1tf3our_protocolTrampoline_1lx650f(id target, void * sel, id arg1, id arg2, NSURLSessionWebSocketCloseCode arg3, id arg4) { + return ((_ProtocolTrampoline_9)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } #undef BLOCKING_BLOCK_IMPL diff --git a/pkgs/cupertino_http/test/isolate_shutdown_test.dart b/pkgs/cupertino_http/test/isolate_shutdown_test.dart new file mode 100644 index 0000000000..3164ea1493 --- /dev/null +++ b/pkgs/cupertino_http/test/isolate_shutdown_test.dart @@ -0,0 +1,63 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:async'; +import 'dart:io'; +import 'dart:isolate'; + +import 'package:cupertino_http/cupertino_http.dart'; +import 'package:test/test.dart'; + +/// The failure is a race between the callback and the isolate teardown, so it +/// takes a few attempts to hit reliably. +const _isolateCount = 20; + +const _responseDelay = Duration(milliseconds: 500); +const _callbackGracePeriod = Duration(seconds: 1); + +/// Selects the child process; `package:test` rejects a `main` with arguments. +const _childMarker = 'CUPERTINO_HTTP_ISOLATE_SHUTDOWN_CHILD'; + +/// A delegate callback that arrives after its isolate is gone aborts the VM, +/// which would take the test runner down with it, hence the child process. +Future _shutDownIsolatesWithRequestsInFlight() async { + final server = await HttpServer.bind('localhost', 0); + server.listen((request) async { + await Future.delayed(_responseDelay); + await request.response.close(); + }); + final uri = Uri.parse('http://localhost:${server.port}'); + + for (var i = 0; i < _isolateCount; ++i) { + await Isolate.run(() { + CupertinoClient.defaultSessionConfiguration().get(uri).ignore(); + }); + } + + await Future.delayed(_callbackGracePeriod); + await server.close(); +} + +void main() { + if (Platform.environment.containsKey(_childMarker)) { + unawaited(_shutDownIsolatesWithRequestsInFlight()); + return; + } + + // The generous timeout is for the native assets, which the child builds + // itself when the cache is cold. + test( + 'isolate shut down with a request in flight', + () async { + final result = await Process.run( + Platform.resolvedExecutable, + ['run', 'test/isolate_shutdown_test.dart'], + environment: {_childMarker: '1'}, + ); + printOnFailure(result.stderr as String); + expect(result.exitCode, 0); + }, + timeout: const Timeout(Duration(minutes: 2)), + ); +}