From 8922f8760af8042174b423be8ea9d9ecf19bf6ef Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Thu, 12 Sep 2024 17:54:17 -0700 Subject: [PATCH 01/38] Add a converter from Dart `Stream` to `NSInputStream` --- pkgs/ffigen/CHANGELOG.md | 3 +- .../objc_built_in_functions.dart | 2 + pkgs/ffigen/pubspec.yaml | 4 +- pkgs/objective_c/CHANGELOG.md | 4 + pkgs/objective_c/ffigen_objc.yaml | 7 + pkgs/objective_c/lib/objective_c.dart | 3 + pkgs/objective_c/lib/src/ns_input_stream.dart | 44 + .../src/objective_c_bindings_generated.dart | 1962 +++++++++++++---- pkgs/objective_c/macos/Classes/objective_c.m | 1 + pkgs/objective_c/pubspec.yaml | 2 +- pkgs/objective_c/src/foundation.h | 1 + pkgs/objective_c/src/input_stream_adapter.h | 27 + pkgs/objective_c/src/input_stream_adapter.m | 164 ++ .../test/ns_input_stream_test.dart | 236 ++ pkgs/objective_c/test/setup.dart | 2 +- 15 files changed, 1990 insertions(+), 472 deletions(-) create mode 100644 pkgs/objective_c/lib/src/ns_input_stream.dart create mode 100644 pkgs/objective_c/src/input_stream_adapter.h create mode 100644 pkgs/objective_c/src/input_stream_adapter.m create mode 100644 pkgs/objective_c/test/ns_input_stream_test.dart diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md index 9a09a879f..6cc74b9eb 100644 --- a/pkgs/ffigen/CHANGELOG.md +++ b/pkgs/ffigen/CHANGELOG.md @@ -1,6 +1,7 @@ -## 14.1.0-wip +## 15.0.0-wip - Dedupe `ObjCBlock` trampolines to reduce generated ObjC code. +- Update to latest `package:objective_c`. ## 14.0.1 diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index 307e11212..36f52ed77 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -51,6 +51,7 @@ class ObjCBuiltInFunctions { 'NSEnumerator', 'NSError', 'NSIndexSet', + 'NSInputStream', 'NSInvocation', 'NSItemProvider', 'NSLocale', @@ -68,6 +69,7 @@ class ObjCBuiltInFunctions { 'NSOrderedSet', 'NSProxy', 'NSSet', + 'NSStream', 'NSString', 'NSURL', 'NSURLHandle', diff --git a/pkgs/ffigen/pubspec.yaml b/pkgs/ffigen/pubspec.yaml index 5a027c231..fc79ac873 100644 --- a/pkgs/ffigen/pubspec.yaml +++ b/pkgs/ffigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: ffigen -version: 14.1.0-wip +version: 15.0.0 description: > Generator for FFI bindings, using LibClang to parse C, Objective-C, and Swift files. @@ -37,7 +37,7 @@ dev_dependencies: dart_flutter_team_lints: ^2.0.0 json_schema: ^5.1.1 meta: ^1.11.0 - objective_c: ^2.0.0 + objective_c: ^3.0.0 test: ^1.16.2 dependency_overrides: diff --git a/pkgs/objective_c/CHANGELOG.md b/pkgs/objective_c/CHANGELOG.md index 0e73ed549..9d7d9429d 100644 --- a/pkgs/objective_c/CHANGELOG.md +++ b/pkgs/objective_c/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.0-wip + +- Add `NSInputStream` and `NSStream` to the core package. + ## 2.0.0 - Drop API methods that are deprecated in the oldest versions of iOS and macOS diff --git a/pkgs/objective_c/ffigen_objc.yaml b/pkgs/objective_c/ffigen_objc.yaml index b19f3b870..daec4c550 100644 --- a/pkgs/objective_c/ffigen_objc.yaml +++ b/pkgs/objective_c/ffigen_objc.yaml @@ -6,6 +6,7 @@ output: 'lib/src/objective_c_bindings_generated.dart' headers: entry-points: - 'src/foundation.h' + - 'src/input_stream_adapter.h' - 'src/proxy.h' ffi-native: exclude-all-by-default: true @@ -19,6 +20,7 @@ external-versions: objc-interfaces: # Keep in sync with ffigen's ObjCBuiltInFunctions.builtInInterfaces. include: + - DartInputStreamAdapter - DartProxy - DartProxyBuilder - NSArray @@ -30,6 +32,7 @@ objc-interfaces: - NSEnumerator - NSError - NSIndexSet + - NSInputStream - NSInvocation - NSItemProvider - NSLocale @@ -47,6 +50,7 @@ objc-interfaces: - NSOrderedSet - NSProxy - NSSet + - NSStream - NSString - NSURL - NSURLHandle @@ -82,6 +86,9 @@ enums: - NSURLBookmarkCreationOptions - NSURLBookmarkResolutionOptions - NSURLHandleStatus +globals: + include: + - NSLocalizedDescriptionKey preamble: | // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a diff --git a/pkgs/objective_c/lib/objective_c.dart b/pkgs/objective_c/lib/objective_c.dart index 1d23ace55..d6fa26fe5 100644 --- a/pkgs/objective_c/lib/objective_c.dart +++ b/pkgs/objective_c/lib/objective_c.dart @@ -19,6 +19,7 @@ export 'src/internal.dart' isValidClass, isValidObject; export 'src/ns_data.dart'; +export 'src/ns_input_stream.dart'; export 'src/ns_mutable_data.dart'; export 'src/ns_string.dart'; // Keep in sync with pkgs/objective_c/ffigen_objc.yaml. @@ -45,6 +46,7 @@ export 'src/objective_c_bindings_generated.dart' NSError, NSFastEnumerationState, NSIndexSet, + NSInputStream, NSInvocation, NSItemProvider, NSItemProviderFileOptions, @@ -70,6 +72,7 @@ export 'src/objective_c_bindings_generated.dart' NSRange, NSSet, NSSortOptions, + NSStream, NSString, NSStringCompareOptions, NSStringEncodingConversionOptions, diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart new file mode 100644 index 000000000..d84bafa91 --- /dev/null +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -0,0 +1,44 @@ +import 'dart:async'; +import 'dart:ffi'; +import 'dart:isolate'; + +import 'ns_data.dart'; +import 'ns_string.dart'; +import 'objective_c_bindings_generated.dart'; + +extension NSInputStreamStreamExtension on Stream> { + /// Return a [NSInputStream] that, when read, will contain the contents of + /// the [Stream]. + NSInputStream toNSInputStream() { + // Eagerly add data until `maxReadAheadSize` is buffered. + const maxReadAheadSize = 4096; + + final port = ReceivePort(); + final inputStream = + DartInputStreamAdapter.inputStreamWithPort_(port.sendPort.nativePort); + late final StreamSubscription dataSubscription; + + dataSubscription = listen((data) { + if (inputStream.addData_(data.toNSData()) > maxReadAheadSize) { + dataSubscription.pause(); + } + }, onError: (Object e) { + final d = NSMutableDictionary.new1(); + d.setObject_forKey_(e.toString().toNSString(), NSLocalizedDescriptionKey); + inputStream.setError_(NSError.errorWithDomain_code_userInfo_( + 'DartError'.toNSString(), 0, d)); + }, onDone: inputStream.setDone, cancelOnError: true); + + dataSubscription.pause(); + port.listen((count) { + if (count == -1) { + dataSubscription.cancel(); + port.close(); + } else { + dataSubscription.resume(); + } + }, onDone: dataSubscription.cancel); + + return inputStream; + } +} diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index 92e725f94..1e8f548f5 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -19,6 +19,21 @@ import 'package:ffi/ffi.dart' as pkg_ffi; import 'dart:ffi' as ffi; import '../objective_c.dart' as objc; +@ffi.Native>(symbol: "NSLocalizedDescriptionKey") +external ffi.Pointer _NSLocalizedDescriptionKey; + +NSString get NSLocalizedDescriptionKey => + NSString.castFromPointer(_NSLocalizedDescriptionKey, + retain: true, release: true); + +set NSLocalizedDescriptionKey(NSString value) { + NSString.castFromPointer(_NSLocalizedDescriptionKey, + retain: false, release: true) + .ref + .release(); + _NSLocalizedDescriptionKey = value.ref.retainAndReturnPointer(); +} + /// NSObject class NSObject extends objc.ObjCObjectBase { NSObject._(ffi.Pointer pointer, @@ -154,7 +169,7 @@ class NSObject extends objc.ObjCObjectBase { /// methodSignatureForSelector: NSMethodSignature methodSignatureForSelector_( ffi.Pointer aSelector) { - final _ret = _objc_msgSend_240( + final _ret = _objc_msgSend_244( this.ref.pointer, _sel_methodSignatureForSelector_, aSelector); return NSMethodSignature.castFromPointer(_ret, retain: true, release: true); } @@ -162,7 +177,7 @@ class NSObject extends objc.ObjCObjectBase { /// instanceMethodSignatureForSelector: static NSMethodSignature instanceMethodSignatureForSelector_( ffi.Pointer aSelector) { - final _ret = _objc_msgSend_240( + final _ret = _objc_msgSend_244( _class_NSObject, _sel_instanceMethodSignatureForSelector_, aSelector); return NSMethodSignature.castFromPointer(_ret, retain: true, release: true); } @@ -219,7 +234,7 @@ class NSObject extends objc.ObjCObjectBase { /// setVersion: static void setVersion_(int aVersion) { - _objc_msgSend_241(_class_NSObject, _sel_setVersion_, aVersion); + _objc_msgSend_245(_class_NSObject, _sel_setVersion_, aVersion); } /// classForCoder @@ -261,7 +276,7 @@ class NSObject extends objc.ObjCObjectBase { objc.ObjCObjectBase? delegate, ffi.Pointer didRecoverSelector, ffi.Pointer contextInfo) { - _objc_msgSend_242( + _objc_msgSend_246( this.ref.pointer, _sel_attemptRecoveryFromError_optionIndex_delegate_didRecoverSelector_contextInfo_, error.ref.pointer, @@ -274,7 +289,7 @@ class NSObject extends objc.ObjCObjectBase { /// attemptRecoveryFromError:optionIndex: bool attemptRecoveryFromError_optionIndex_( NSError error, int recoveryOptionIndex) { - return _objc_msgSend_243( + return _objc_msgSend_247( this.ref.pointer, _sel_attemptRecoveryFromError_optionIndex_, error.ref.pointer, @@ -287,7 +302,7 @@ class NSObject extends objc.ObjCObjectBase { objc.ObjCObjectBase? object, NSDictionary? change, ffi.Pointer context) { - _objc_msgSend_244( + _objc_msgSend_248( this.ref.pointer, _sel_observeValueForKeyPath_ofObject_change_context_, keyPath?.ref.pointer ?? ffi.nullptr, @@ -326,34 +341,34 @@ class NSObject extends objc.ObjCObjectBase { /// willChangeValueForKey: void willChangeValueForKey_(NSString key) { - _objc_msgSend_148( + _objc_msgSend_147( this.ref.pointer, _sel_willChangeValueForKey_, key.ref.pointer); } /// didChangeValueForKey: void didChangeValueForKey_(NSString key) { - _objc_msgSend_148( + _objc_msgSend_147( this.ref.pointer, _sel_didChangeValueForKey_, key.ref.pointer); } /// willChange:valuesAtIndexes:forKey: void willChange_valuesAtIndexes_forKey_( NSKeyValueChange changeKind, NSIndexSet indexes, NSString key) { - _objc_msgSend_245(this.ref.pointer, _sel_willChange_valuesAtIndexes_forKey_, + _objc_msgSend_249(this.ref.pointer, _sel_willChange_valuesAtIndexes_forKey_, changeKind.value, indexes.ref.pointer, key.ref.pointer); } /// didChange:valuesAtIndexes:forKey: void didChange_valuesAtIndexes_forKey_( NSKeyValueChange changeKind, NSIndexSet indexes, NSString key) { - _objc_msgSend_245(this.ref.pointer, _sel_didChange_valuesAtIndexes_forKey_, + _objc_msgSend_249(this.ref.pointer, _sel_didChange_valuesAtIndexes_forKey_, changeKind.value, indexes.ref.pointer, key.ref.pointer); } /// willChangeValueForKey:withSetMutation:usingObjects: void willChangeValueForKey_withSetMutation_usingObjects_( NSString key, NSKeyValueSetMutationKind mutationKind, NSSet objects) { - _objc_msgSend_246( + _objc_msgSend_250( this.ref.pointer, _sel_willChangeValueForKey_withSetMutation_usingObjects_, key.ref.pointer, @@ -364,7 +379,7 @@ class NSObject extends objc.ObjCObjectBase { /// didChangeValueForKey:withSetMutation:usingObjects: void didChangeValueForKey_withSetMutation_usingObjects_( NSString key, NSKeyValueSetMutationKind mutationKind, NSSet objects) { - _objc_msgSend_246( + _objc_msgSend_250( this.ref.pointer, _sel_didChangeValueForKey_withSetMutation_usingObjects_, key.ref.pointer, @@ -392,7 +407,7 @@ class NSObject extends objc.ObjCObjectBase { /// setObservationInfo: set observationInfo(ffi.Pointer value) { - return _objc_msgSend_247(this.ref.pointer, _sel_setObservationInfo_, value); + return _objc_msgSend_251(this.ref.pointer, _sel_setObservationInfo_, value); } } @@ -474,17 +489,6 @@ class Protocol extends objc.ObjCObjectBase { } late final _class_Protocol = objc.getClass("Protocol"); -final _objc_msgSend_0 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer clazz)>>() - .asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); -late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); late final _sel_conformsToProtocol_ = objc.registerName("conformsToProtocol:"); final _objc_msgSend_5 = objc.msgSendPointer .cast< @@ -825,19 +829,19 @@ class NSSet extends NSObject { /// intersectsSet: bool intersectsSet_(NSSet otherSet) { - return _objc_msgSend_234( + return _objc_msgSend_238( this.ref.pointer, _sel_intersectsSet_, otherSet.ref.pointer); } /// isEqualToSet: bool isEqualToSet_(NSSet otherSet) { - return _objc_msgSend_234( + return _objc_msgSend_238( this.ref.pointer, _sel_isEqualToSet_, otherSet.ref.pointer); } /// isSubsetOfSet: bool isSubsetOfSet_(NSSet otherSet) { - return _objc_msgSend_234( + return _objc_msgSend_238( this.ref.pointer, _sel_isSubsetOfSet_, otherSet.ref.pointer); } @@ -859,21 +863,21 @@ class NSSet extends NSObject { /// setByAddingObject: NSSet setByAddingObject_(objc.ObjCObjectBase anObject) { - final _ret = _objc_msgSend_235( + final _ret = _objc_msgSend_239( this.ref.pointer, _sel_setByAddingObject_, anObject.ref.pointer); return NSSet.castFromPointer(_ret, retain: true, release: true); } /// setByAddingObjectsFromSet: NSSet setByAddingObjectsFromSet_(NSSet other) { - final _ret = _objc_msgSend_236( + final _ret = _objc_msgSend_240( this.ref.pointer, _sel_setByAddingObjectsFromSet_, other.ref.pointer); return NSSet.castFromPointer(_ret, retain: true, release: true); } /// setByAddingObjectsFromArray: NSSet setByAddingObjectsFromArray_(NSArray other) { - final _ret = _objc_msgSend_237( + final _ret = _objc_msgSend_241( this.ref.pointer, _sel_setByAddingObjectsFromArray_, other.ref.pointer); return NSSet.castFromPointer(_ret, retain: true, release: true); } @@ -909,7 +913,7 @@ class NSSet extends NSObject { /// setWithSet: static NSSet setWithSet_(NSSet set) { final _ret = - _objc_msgSend_238(_class_NSSet, _sel_setWithSet_, set.ref.pointer); + _objc_msgSend_242(_class_NSSet, _sel_setWithSet_, set.ref.pointer); return NSSet.castFromPointer(_ret, retain: true, release: true); } @@ -929,14 +933,14 @@ class NSSet extends NSObject { /// initWithSet: NSSet initWithSet_(NSSet set) { - final _ret = _objc_msgSend_238( + final _ret = _objc_msgSend_242( this.ref.retainAndReturnPointer(), _sel_initWithSet_, set.ref.pointer); return NSSet.castFromPointer(_ret, retain: false, release: true); } /// initWithSet:copyItems: NSSet initWithSet_copyItems_(NSSet set, bool flag) { - final _ret = _objc_msgSend_239(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_243(this.ref.retainAndReturnPointer(), _sel_initWithSet_copyItems_, set.ref.pointer, flag); return NSSet.castFromPointer(_ret, retain: false, release: true); } @@ -1911,10 +1915,18 @@ class NSString extends NSObject { return NSString.castFromPointer(_ret, retain: false, release: true); } + /// initWithFormat:arguments: + NSString initWithFormat_arguments_( + NSString format, ffi.Pointer argList) { + final _ret = _objc_msgSend_219(this.ref.retainAndReturnPointer(), + _sel_initWithFormat_arguments_, format.ref.pointer, argList); + return NSString.castFromPointer(_ret, retain: false, release: true); + } + /// initWithFormat:locale: NSString initWithFormat_locale_( NSString format, objc.ObjCObjectBase? locale) { - final _ret = _objc_msgSend_219( + final _ret = _objc_msgSend_220( this.ref.retainAndReturnPointer(), _sel_initWithFormat_locale_, format.ref.pointer, @@ -1922,12 +1934,24 @@ class NSString extends NSObject { return NSString.castFromPointer(_ret, retain: false, release: true); } + /// initWithFormat:locale:arguments: + NSString initWithFormat_locale_arguments_(NSString format, + objc.ObjCObjectBase? locale, ffi.Pointer argList) { + final _ret = _objc_msgSend_221( + this.ref.retainAndReturnPointer(), + _sel_initWithFormat_locale_arguments_, + format.ref.pointer, + locale?.ref.pointer ?? ffi.nullptr, + argList); + return NSString.castFromPointer(_ret, retain: false, release: true); + } + /// initWithValidatedFormat:validFormatSpecifiers:error: NSString? initWithValidatedFormat_validFormatSpecifiers_error_( NSString format, NSString validFormatSpecifiers, ffi.Pointer> error) { - final _ret = _objc_msgSend_220( + final _ret = _objc_msgSend_222( this.ref.retainAndReturnPointer(), _sel_initWithValidatedFormat_validFormatSpecifiers_error_, format.ref.pointer, @@ -1944,7 +1968,7 @@ class NSString extends NSObject { NSString validFormatSpecifiers, objc.ObjCObjectBase? locale, ffi.Pointer> error) { - final _ret = _objc_msgSend_221( + final _ret = _objc_msgSend_223( this.ref.retainAndReturnPointer(), _sel_initWithValidatedFormat_validFormatSpecifiers_locale_error_, format.ref.pointer, @@ -1956,9 +1980,48 @@ class NSString extends NSObject { : NSString.castFromPointer(_ret, retain: false, release: true); } + /// initWithValidatedFormat:validFormatSpecifiers:arguments:error: + NSString? initWithValidatedFormat_validFormatSpecifiers_arguments_error_( + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer argList, + ffi.Pointer> error) { + final _ret = _objc_msgSend_224( + this.ref.retainAndReturnPointer(), + _sel_initWithValidatedFormat_validFormatSpecifiers_arguments_error_, + format.ref.pointer, + validFormatSpecifiers.ref.pointer, + argList, + error); + return _ret.address == 0 + ? null + : NSString.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithValidatedFormat:validFormatSpecifiers:locale:arguments:error: + NSString? + initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_( + NSString format, + NSString validFormatSpecifiers, + objc.ObjCObjectBase? locale, + ffi.Pointer argList, + ffi.Pointer> error) { + final _ret = _objc_msgSend_225( + this.ref.retainAndReturnPointer(), + _sel_initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_, + format.ref.pointer, + validFormatSpecifiers.ref.pointer, + locale?.ref.pointer ?? ffi.nullptr, + argList, + error); + return _ret.address == 0 + ? null + : NSString.castFromPointer(_ret, retain: false, release: true); + } + /// initWithData:encoding: NSString? initWithData_encoding_(NSData data, int encoding) { - final _ret = _objc_msgSend_222(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_226(this.ref.retainAndReturnPointer(), _sel_initWithData_encoding_, data.ref.pointer, encoding); return _ret.address == 0 ? null @@ -1968,7 +2031,7 @@ class NSString extends NSObject { /// initWithBytes:length:encoding: NSString? initWithBytes_length_encoding_( ffi.Pointer bytes, int len, int encoding) { - final _ret = _objc_msgSend_223(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_227(this.ref.retainAndReturnPointer(), _sel_initWithBytes_length_encoding_, bytes, len, encoding); return _ret.address == 0 ? null @@ -1978,7 +2041,7 @@ class NSString extends NSObject { /// initWithBytesNoCopy:length:encoding:freeWhenDone: NSString? initWithBytesNoCopy_length_encoding_freeWhenDone_( ffi.Pointer bytes, int len, int encoding, bool freeBuffer) { - final _ret = _objc_msgSend_224( + final _ret = _objc_msgSend_228( this.ref.retainAndReturnPointer(), _sel_initWithBytesNoCopy_length_encoding_freeWhenDone_, bytes, @@ -2040,7 +2103,7 @@ class NSString extends NSObject { NSString format, NSString validFormatSpecifiers, ffi.Pointer> error) { - final _ret = _objc_msgSend_220( + final _ret = _objc_msgSend_222( _class_NSString, _sel_stringWithValidatedFormat_validFormatSpecifiers_error_, format.ref.pointer, @@ -2057,7 +2120,7 @@ class NSString extends NSObject { NSString format, NSString validFormatSpecifiers, ffi.Pointer> error) { - final _ret = _objc_msgSend_220( + final _ret = _objc_msgSend_222( _class_NSString, _sel_localizedStringWithValidatedFormat_validFormatSpecifiers_error_, format.ref.pointer, @@ -2071,7 +2134,7 @@ class NSString extends NSObject { /// initWithCString:encoding: NSString? initWithCString_encoding_( ffi.Pointer nullTerminatedCString, int encoding) { - final _ret = _objc_msgSend_225(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_229(this.ref.retainAndReturnPointer(), _sel_initWithCString_encoding_, nullTerminatedCString, encoding); return _ret.address == 0 ? null @@ -2081,7 +2144,7 @@ class NSString extends NSObject { /// stringWithCString:encoding: static NSString? stringWithCString_encoding_( ffi.Pointer cString, int enc) { - final _ret = _objc_msgSend_225( + final _ret = _objc_msgSend_229( _class_NSString, _sel_stringWithCString_encoding_, cString, enc); return _ret.address == 0 ? null @@ -2091,7 +2154,7 @@ class NSString extends NSObject { /// initWithContentsOfURL:encoding:error: NSString? initWithContentsOfURL_encoding_error_( NSURL url, int enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_226( + final _ret = _objc_msgSend_230( this.ref.retainAndReturnPointer(), _sel_initWithContentsOfURL_encoding_error_, url.ref.pointer, @@ -2105,7 +2168,7 @@ class NSString extends NSObject { /// initWithContentsOfFile:encoding:error: NSString? initWithContentsOfFile_encoding_error_( NSString path, int enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_227( + final _ret = _objc_msgSend_231( this.ref.retainAndReturnPointer(), _sel_initWithContentsOfFile_encoding_error_, path.ref.pointer, @@ -2119,7 +2182,7 @@ class NSString extends NSObject { /// stringWithContentsOfURL:encoding:error: static NSString? stringWithContentsOfURL_encoding_error_( NSURL url, int enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_226( + final _ret = _objc_msgSend_230( _class_NSString, _sel_stringWithContentsOfURL_encoding_error_, url.ref.pointer, @@ -2133,7 +2196,7 @@ class NSString extends NSObject { /// stringWithContentsOfFile:encoding:error: static NSString? stringWithContentsOfFile_encoding_error_( NSString path, int enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_227( + final _ret = _objc_msgSend_231( _class_NSString, _sel_stringWithContentsOfFile_encoding_error_, path.ref.pointer, @@ -2149,7 +2212,7 @@ class NSString extends NSObject { NSURL url, ffi.Pointer enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_228( + final _ret = _objc_msgSend_232( this.ref.retainAndReturnPointer(), _sel_initWithContentsOfURL_usedEncoding_error_, url.ref.pointer, @@ -2165,7 +2228,7 @@ class NSString extends NSObject { NSString path, ffi.Pointer enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_229( + final _ret = _objc_msgSend_233( this.ref.retainAndReturnPointer(), _sel_initWithContentsOfFile_usedEncoding_error_, path.ref.pointer, @@ -2181,7 +2244,7 @@ class NSString extends NSObject { NSURL url, ffi.Pointer enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_228( + final _ret = _objc_msgSend_232( _class_NSString, _sel_stringWithContentsOfURL_usedEncoding_error_, url.ref.pointer, @@ -2197,7 +2260,7 @@ class NSString extends NSObject { NSString path, ffi.Pointer enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_229( + final _ret = _objc_msgSend_233( _class_NSString, _sel_stringWithContentsOfFile_usedEncoding_error_, path.ref.pointer, @@ -2215,7 +2278,7 @@ class NSString extends NSObject { NSDictionary? opts, ffi.Pointer> string, ffi.Pointer usedLossyConversion) { - return _objc_msgSend_230( + return _objc_msgSend_234( _class_NSString, _sel_stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_, data.ref.pointer, @@ -2232,7 +2295,7 @@ class NSString extends NSObject { /// propertyListFromStringsFileFormat NSDictionary? propertyListFromStringsFileFormat() { - final _ret = _objc_msgSend_231( + final _ret = _objc_msgSend_235( this.ref.pointer, _sel_propertyListFromStringsFileFormat); return _ret.address == 0 ? null @@ -2241,13 +2304,13 @@ class NSString extends NSObject { /// getCharacters: void getCharacters_(ffi.Pointer buffer) { - _objc_msgSend_232(this.ref.pointer, _sel_getCharacters_, buffer); + _objc_msgSend_236(this.ref.pointer, _sel_getCharacters_, buffer); } /// stringByAddingPercentEncodingWithAllowedCharacters: NSString? stringByAddingPercentEncodingWithAllowedCharacters_( NSCharacterSet allowedCharacters) { - final _ret = _objc_msgSend_233( + final _ret = _objc_msgSend_237( this.ref.pointer, _sel_stringByAddingPercentEncodingWithAllowedCharacters_, allowedCharacters.ref.pointer); @@ -3869,13 +3932,6 @@ class NSURL extends NSObject { : NSURL.castFromPointer(_ret, retain: true, release: true); } - /// checkResourceIsReachableAndReturnError: - bool checkResourceIsReachableAndReturnError_( - ffi.Pointer> error) { - return _objc_msgSend_143( - this.ref.pointer, _sel_checkResourceIsReachableAndReturnError_, error); - } - /// isFileReferenceURL bool isFileReferenceURL() { return _objc_msgSend_13(this.ref.pointer, _sel_isFileReferenceURL); @@ -3902,14 +3958,14 @@ class NSURL extends NSObject { ffi.Pointer> value, NSString key, ffi.Pointer> error) { - return _objc_msgSend_144(this.ref.pointer, + return _objc_msgSend_143(this.ref.pointer, _sel_getResourceValue_forKey_error_, value, key.ref.pointer, error); } /// resourceValuesForKeys:error: objc.ObjCObjectBase? resourceValuesForKeys_error_( NSArray keys, ffi.Pointer> error) { - final _ret = _objc_msgSend_145(this.ref.pointer, + final _ret = _objc_msgSend_144(this.ref.pointer, _sel_resourceValuesForKeys_error_, keys.ref.pointer, error); return _ret.address == 0 ? null @@ -3919,7 +3975,7 @@ class NSURL extends NSObject { /// setResourceValue:forKey:error: bool setResourceValue_forKey_error_(objc.ObjCObjectBase? value, NSString key, ffi.Pointer> error) { - return _objc_msgSend_146( + return _objc_msgSend_145( this.ref.pointer, _sel_setResourceValue_forKey_error_, value?.ref.pointer ?? ffi.nullptr, @@ -3930,13 +3986,13 @@ class NSURL extends NSObject { /// setResourceValues:error: bool setResourceValues_error_(objc.ObjCObjectBase keyedValues, ffi.Pointer> error) { - return _objc_msgSend_147(this.ref.pointer, _sel_setResourceValues_error_, + return _objc_msgSend_146(this.ref.pointer, _sel_setResourceValues_error_, keyedValues.ref.pointer, error); } /// removeCachedResourceValueForKey: void removeCachedResourceValueForKey_(NSString key) { - _objc_msgSend_148(this.ref.pointer, _sel_removeCachedResourceValueForKey_, + _objc_msgSend_147(this.ref.pointer, _sel_removeCachedResourceValueForKey_, key.ref.pointer); } @@ -3948,7 +4004,7 @@ class NSURL extends NSObject { /// setTemporaryResourceValue:forKey: void setTemporaryResourceValue_forKey_( objc.ObjCObjectBase? value, NSString key) { - _objc_msgSend_149(this.ref.pointer, _sel_setTemporaryResourceValue_forKey_, + _objc_msgSend_148(this.ref.pointer, _sel_setTemporaryResourceValue_forKey_, value?.ref.pointer ?? ffi.nullptr, key.ref.pointer); } @@ -3959,7 +4015,7 @@ class NSURL extends NSObject { NSArray? keys, NSURL? relativeURL, ffi.Pointer> error) { - final _ret = _objc_msgSend_150( + final _ret = _objc_msgSend_149( this.ref.pointer, _sel_bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_, options.value, @@ -3979,7 +4035,7 @@ class NSURL extends NSObject { NSURL? relativeURL, ffi.Pointer isStale, ffi.Pointer> error) { - final _ret = _objc_msgSend_151( + final _ret = _objc_msgSend_150( this.ref.retainAndReturnPointer(), _sel_initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_, bookmarkData.ref.pointer, @@ -4000,7 +4056,7 @@ class NSURL extends NSObject { NSURL? relativeURL, ffi.Pointer isStale, ffi.Pointer> error) { - final _ret = _objc_msgSend_151( + final _ret = _objc_msgSend_150( _class_NSURL, _sel_URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_, bookmarkData.ref.pointer, @@ -4016,7 +4072,7 @@ class NSURL extends NSObject { /// resourceValuesForKeys:fromBookmarkData: static objc.ObjCObjectBase? resourceValuesForKeys_fromBookmarkData_( NSArray keys, NSData bookmarkData) { - final _ret = _objc_msgSend_152( + final _ret = _objc_msgSend_151( _class_NSURL, _sel_resourceValuesForKeys_fromBookmarkData_, keys.ref.pointer, @@ -4032,7 +4088,7 @@ class NSURL extends NSObject { NSURL bookmarkFileURL, int options, ffi.Pointer> error) { - return _objc_msgSend_153( + return _objc_msgSend_152( _class_NSURL, _sel_writeBookmarkData_toURL_options_error_, bookmarkData.ref.pointer, @@ -4044,7 +4100,7 @@ class NSURL extends NSObject { /// bookmarkDataWithContentsOfURL:error: static NSData? bookmarkDataWithContentsOfURL_error_( NSURL bookmarkFileURL, ffi.Pointer> error) { - final _ret = _objc_msgSend_154( + final _ret = _objc_msgSend_153( _class_NSURL, _sel_bookmarkDataWithContentsOfURL_error_, bookmarkFileURL.ref.pointer, @@ -4059,7 +4115,7 @@ class NSURL extends NSObject { NSURL url, NSURLBookmarkResolutionOptions options, ffi.Pointer> error) { - final _ret = _objc_msgSend_155( + final _ret = _objc_msgSend_154( _class_NSURL, _sel_URLByResolvingAliasFileAtURL_options_error_, url.ref.pointer, @@ -4086,7 +4142,7 @@ class NSURL extends NSObject { ffi.Pointer> value, NSString key, ffi.Pointer> error) { - return _objc_msgSend_144( + return _objc_msgSend_143( this.ref.pointer, _sel_getPromisedItemResourceValue_forKey_error_, value, @@ -4097,7 +4153,7 @@ class NSURL extends NSObject { /// promisedItemResourceValuesForKeys:error: NSDictionary? promisedItemResourceValuesForKeys_error_( NSArray keys, ffi.Pointer> error) { - final _ret = _objc_msgSend_168(this.ref.pointer, + final _ret = _objc_msgSend_167(this.ref.pointer, _sel_promisedItemResourceValuesForKeys_error_, keys.ref.pointer, error); return _ret.address == 0 ? null @@ -4107,7 +4163,7 @@ class NSURL extends NSObject { /// checkPromisedItemIsReachableAndReturnError: bool checkPromisedItemIsReachableAndReturnError_( ffi.Pointer> error) { - return _objc_msgSend_143(this.ref.pointer, + return _objc_msgSend_168(this.ref.pointer, _sel_checkPromisedItemIsReachableAndReturnError_, error); } @@ -4193,6 +4249,13 @@ class NSURL extends NSObject { : NSURL.castFromPointer(_ret, retain: true, release: true); } + /// checkResourceIsReachableAndReturnError: + bool checkResourceIsReachableAndReturnError_( + ffi.Pointer> error) { + return _objc_msgSend_168( + this.ref.pointer, _sel_checkResourceIsReachableAndReturnError_, error); + } + /// URLByStandardizingPath NSURL? get URLByStandardizingPath { final _ret = @@ -5566,6 +5629,9 @@ late final _sel_fileSystemRepresentation = objc.registerName("fileSystemRepresentation"); late final _sel_isFileURL = objc.registerName("isFileURL"); late final _sel_standardizedURL = objc.registerName("standardizedURL"); +late final _sel_isFileReferenceURL = objc.registerName("isFileReferenceURL"); +late final _sel_fileReferenceURL = objc.registerName("fileReferenceURL"); +late final _sel_filePathURL = objc.registerName("filePathURL"); /// NSError class NSError extends NSObject { @@ -6339,6 +6405,16 @@ final _objc_msgSend_103 = objc.msgSendPointer ffi.Pointer Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); late final _sel_containsObject_ = objc.registerName("containsObject:"); +final _objc_msgSend_0 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer clazz)>>() + .asFunction< + bool Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); late final _sel_descriptionWithLocale_indent_ = objc.registerName("descriptionWithLocale:indent:"); final _objc_msgSend_104 = objc.msgSendPointer @@ -7156,26 +7232,9 @@ final _objc_msgSend_142 = objc.msgSendPointer .asFunction< ffi.Pointer Function( ffi.Pointer, ffi.Pointer)>(); -late final _sel_checkResourceIsReachableAndReturnError_ = - objc.registerName("checkResourceIsReachableAndReturnError:"); -final _objc_msgSend_143 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer> error)>>() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>)>(); -late final _sel_isFileReferenceURL = objc.registerName("isFileReferenceURL"); -late final _sel_fileReferenceURL = objc.registerName("fileReferenceURL"); -late final _sel_filePathURL = objc.registerName("filePathURL"); late final _sel_getResourceValue_forKey_error_ = objc.registerName("getResourceValue:forKey:error:"); -final _objc_msgSend_144 = objc.msgSendPointer +final _objc_msgSend_143 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -7193,7 +7252,7 @@ final _objc_msgSend_144 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_resourceValuesForKeys_error_ = objc.registerName("resourceValuesForKeys:error:"); -final _objc_msgSend_145 = objc.msgSendPointer +final _objc_msgSend_144 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -7209,7 +7268,7 @@ final _objc_msgSend_145 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_setResourceValue_forKey_error_ = objc.registerName("setResourceValue:forKey:error:"); -final _objc_msgSend_146 = objc.msgSendPointer +final _objc_msgSend_145 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -7227,7 +7286,7 @@ final _objc_msgSend_146 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_setResourceValues_error_ = objc.registerName("setResourceValues:error:"); -final _objc_msgSend_147 = objc.msgSendPointer +final _objc_msgSend_146 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -7243,7 +7302,7 @@ final _objc_msgSend_147 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_removeCachedResourceValueForKey_ = objc.registerName("removeCachedResourceValueForKey:"); -final _objc_msgSend_148 = objc.msgSendPointer +final _objc_msgSend_147 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -7257,7 +7316,7 @@ late final _sel_removeAllCachedResourceValues = objc.registerName("removeAllCachedResourceValues"); late final _sel_setTemporaryResourceValue_forKey_ = objc.registerName("setTemporaryResourceValue:forKey:"); -final _objc_msgSend_149 = objc.msgSendPointer +final _objc_msgSend_148 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -7298,7 +7357,7 @@ enum NSURLBookmarkCreationOptions { late final _sel_bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_ = objc.registerName( "bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error:"); -final _objc_msgSend_150 = objc.msgSendPointer +final _objc_msgSend_149 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -7339,7 +7398,7 @@ enum NSURLBookmarkResolutionOptions { late final _sel_initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_ = objc.registerName( "initByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:"); -final _objc_msgSend_151 = objc.msgSendPointer +final _objc_msgSend_150 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -7364,7 +7423,7 @@ late final _sel_URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsS "URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:"); late final _sel_resourceValuesForKeys_fromBookmarkData_ = objc.registerName("resourceValuesForKeys:fromBookmarkData:"); -final _objc_msgSend_152 = objc.msgSendPointer +final _objc_msgSend_151 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -7380,7 +7439,7 @@ final _objc_msgSend_152 = objc.msgSendPointer ffi.Pointer)>(); late final _sel_writeBookmarkData_toURL_options_error_ = objc.registerName("writeBookmarkData:toURL:options:error:"); -final _objc_msgSend_153 = objc.msgSendPointer +final _objc_msgSend_152 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -7400,7 +7459,7 @@ final _objc_msgSend_153 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_bookmarkDataWithContentsOfURL_error_ = objc.registerName("bookmarkDataWithContentsOfURL:error:"); -final _objc_msgSend_154 = objc.msgSendPointer +final _objc_msgSend_153 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -7416,7 +7475,7 @@ final _objc_msgSend_154 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_URLByResolvingAliasFileAtURL_options_error_ = objc.registerName("URLByResolvingAliasFileAtURL:options:error:"); -final _objc_msgSend_155 = objc.msgSendPointer +final _objc_msgSend_154 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -7491,7 +7550,7 @@ class NSDictionary extends NSObject { ffi.Pointer> objects, ffi.Pointer> keys, int cnt) { - final _ret = _objc_msgSend_156(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_155(this.ref.retainAndReturnPointer(), _sel_initWithObjects_forKeys_count_, objects, keys, cnt); return NSDictionary.castFromPointer(_ret, retain: false, release: true); } @@ -7557,7 +7616,7 @@ class NSDictionary extends NSObject { /// isEqualToDictionary: bool isEqualToDictionary_(NSDictionary otherDictionary) { - return _objc_msgSend_157(this.ref.pointer, _sel_isEqualToDictionary_, + return _objc_msgSend_156(this.ref.pointer, _sel_isEqualToDictionary_, otherDictionary.ref.pointer); } @@ -7570,7 +7629,7 @@ class NSDictionary extends NSObject { /// objectsForKeys:notFoundMarker: NSArray objectsForKeys_notFoundMarker_( NSArray keys, objc.ObjCObjectBase marker) { - final _ret = _objc_msgSend_158( + final _ret = _objc_msgSend_157( this.ref.pointer, _sel_objectsForKeys_notFoundMarker_, keys.ref.pointer, @@ -7598,7 +7657,7 @@ class NSDictionary extends NSObject { ffi.Pointer> objects, ffi.Pointer> keys, int count) { - _objc_msgSend_159( + _objc_msgSend_158( this.ref.pointer, _sel_getObjects_andKeys_count_, objects, keys, count); } @@ -7613,7 +7672,7 @@ class NSDictionary extends NSObject { /// dictionaryWithContentsOfFile: static NSDictionary? dictionaryWithContentsOfFile_(NSString path) { - final _ret = _objc_msgSend_160(_class_NSDictionary, + final _ret = _objc_msgSend_159(_class_NSDictionary, _sel_dictionaryWithContentsOfFile_, path.ref.pointer); return _ret.address == 0 ? null @@ -7622,7 +7681,7 @@ class NSDictionary extends NSObject { /// dictionaryWithContentsOfURL: static NSDictionary? dictionaryWithContentsOfURL_(NSURL url) { - final _ret = _objc_msgSend_161(_class_NSDictionary, + final _ret = _objc_msgSend_160(_class_NSDictionary, _sel_dictionaryWithContentsOfURL_, url.ref.pointer); return _ret.address == 0 ? null @@ -7631,7 +7690,7 @@ class NSDictionary extends NSObject { /// initWithContentsOfFile: NSDictionary? initWithContentsOfFile_(NSString path) { - final _ret = _objc_msgSend_160(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_159(this.ref.retainAndReturnPointer(), _sel_initWithContentsOfFile_, path.ref.pointer); return _ret.address == 0 ? null @@ -7640,7 +7699,7 @@ class NSDictionary extends NSObject { /// initWithContentsOfURL: NSDictionary? initWithContentsOfURL_(NSURL url) { - final _ret = _objc_msgSend_161(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_160(this.ref.retainAndReturnPointer(), _sel_initWithContentsOfURL_, url.ref.pointer); return _ret.address == 0 ? null @@ -7668,7 +7727,7 @@ class NSDictionary extends NSObject { /// dictionaryWithObject:forKey: static NSDictionary dictionaryWithObject_forKey_( objc.ObjCObjectBase object, objc.ObjCObjectBase key) { - final _ret = _objc_msgSend_162(_class_NSDictionary, + final _ret = _objc_msgSend_161(_class_NSDictionary, _sel_dictionaryWithObject_forKey_, object.ref.pointer, key.ref.pointer); return NSDictionary.castFromPointer(_ret, retain: true, release: true); } @@ -7678,7 +7737,7 @@ class NSDictionary extends NSObject { ffi.Pointer> objects, ffi.Pointer> keys, int cnt) { - final _ret = _objc_msgSend_156(_class_NSDictionary, + final _ret = _objc_msgSend_155(_class_NSDictionary, _sel_dictionaryWithObjects_forKeys_count_, objects, keys, cnt); return NSDictionary.castFromPointer(_ret, retain: true, release: true); } @@ -7693,7 +7752,7 @@ class NSDictionary extends NSObject { /// dictionaryWithDictionary: static NSDictionary dictionaryWithDictionary_(NSDictionary dict) { - final _ret = _objc_msgSend_163( + final _ret = _objc_msgSend_162( _class_NSDictionary, _sel_dictionaryWithDictionary_, dict.ref.pointer); return NSDictionary.castFromPointer(_ret, retain: true, release: true); } @@ -7701,7 +7760,7 @@ class NSDictionary extends NSObject { /// dictionaryWithObjects:forKeys: static NSDictionary dictionaryWithObjects_forKeys_( NSArray objects, NSArray keys) { - final _ret = _objc_msgSend_164( + final _ret = _objc_msgSend_163( _class_NSDictionary, _sel_dictionaryWithObjects_forKeys_, objects.ref.pointer, @@ -7718,7 +7777,7 @@ class NSDictionary extends NSObject { /// initWithDictionary: NSDictionary initWithDictionary_(NSDictionary otherDictionary) { - final _ret = _objc_msgSend_163(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_162(this.ref.retainAndReturnPointer(), _sel_initWithDictionary_, otherDictionary.ref.pointer); return NSDictionary.castFromPointer(_ret, retain: false, release: true); } @@ -7726,14 +7785,14 @@ class NSDictionary extends NSObject { /// initWithDictionary:copyItems: NSDictionary initWithDictionary_copyItems_( NSDictionary otherDictionary, bool flag) { - final _ret = _objc_msgSend_165(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_164(this.ref.retainAndReturnPointer(), _sel_initWithDictionary_copyItems_, otherDictionary.ref.pointer, flag); return NSDictionary.castFromPointer(_ret, retain: false, release: true); } /// initWithObjects:forKeys: NSDictionary initWithObjects_forKeys_(NSArray objects, NSArray keys) { - final _ret = _objc_msgSend_164(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_163(this.ref.retainAndReturnPointer(), _sel_initWithObjects_forKeys_, objects.ref.pointer, keys.ref.pointer); return NSDictionary.castFromPointer(_ret, retain: false, release: true); } @@ -7741,7 +7800,7 @@ class NSDictionary extends NSObject { /// initWithContentsOfURL:error: NSDictionary? initWithContentsOfURL_error_( NSURL url, ffi.Pointer> error) { - final _ret = _objc_msgSend_166(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_165(this.ref.retainAndReturnPointer(), _sel_initWithContentsOfURL_error_, url.ref.pointer, error); return _ret.address == 0 ? null @@ -7751,7 +7810,7 @@ class NSDictionary extends NSObject { /// dictionaryWithContentsOfURL:error: static NSDictionary? dictionaryWithContentsOfURL_error_( NSURL url, ffi.Pointer> error) { - final _ret = _objc_msgSend_166(_class_NSDictionary, + final _ret = _objc_msgSend_165(_class_NSDictionary, _sel_dictionaryWithContentsOfURL_error_, url.ref.pointer, error); return _ret.address == 0 ? null @@ -7770,7 +7829,7 @@ class NSDictionary extends NSObject { ffi.Pointer state, ffi.Pointer> buffer, int len) { - return _objc_msgSend_167(this.ref.pointer, + return _objc_msgSend_166(this.ref.pointer, _sel_countByEnumeratingWithState_objects_count_, state, buffer, len); } @@ -7812,7 +7871,7 @@ late final _sel_objectForKey_ = objc.registerName("objectForKey:"); late final _sel_keyEnumerator = objc.registerName("keyEnumerator"); late final _sel_initWithObjects_forKeys_count_ = objc.registerName("initWithObjects:forKeys:count:"); -final _objc_msgSend_156 = objc.msgSendPointer +final _objc_msgSend_155 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -7835,7 +7894,7 @@ late final _sel_descriptionInStringsFileFormat = objc.registerName("descriptionInStringsFileFormat"); late final _sel_isEqualToDictionary_ = objc.registerName("isEqualToDictionary:"); -final _objc_msgSend_157 = objc.msgSendPointer +final _objc_msgSend_156 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -7847,7 +7906,7 @@ final _objc_msgSend_157 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_objectsForKeys_notFoundMarker_ = objc.registerName("objectsForKeys:notFoundMarker:"); -final _objc_msgSend_158 = objc.msgSendPointer +final _objc_msgSend_157 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -7865,7 +7924,7 @@ late final _sel_keysSortedByValueUsingSelector_ = objc.registerName("keysSortedByValueUsingSelector:"); late final _sel_getObjects_andKeys_count_ = objc.registerName("getObjects:andKeys:count:"); -final _objc_msgSend_159 = objc.msgSendPointer +final _objc_msgSend_158 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -7885,7 +7944,7 @@ late final _sel_objectForKeyedSubscript_ = objc.registerName("objectForKeyedSubscript:"); late final _sel_dictionaryWithContentsOfFile_ = objc.registerName("dictionaryWithContentsOfFile:"); -final _objc_msgSend_160 = objc.msgSendPointer +final _objc_msgSend_159 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -7897,7 +7956,7 @@ final _objc_msgSend_160 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_dictionaryWithContentsOfURL_ = objc.registerName("dictionaryWithContentsOfURL:"); -final _objc_msgSend_161 = objc.msgSendPointer +final _objc_msgSend_160 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -7910,7 +7969,7 @@ final _objc_msgSend_161 = objc.msgSendPointer late final _sel_dictionary = objc.registerName("dictionary"); late final _sel_dictionaryWithObject_forKey_ = objc.registerName("dictionaryWithObject:forKey:"); -final _objc_msgSend_162 = objc.msgSendPointer +final _objc_msgSend_161 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -7930,7 +7989,7 @@ late final _sel_dictionaryWithObjectsAndKeys_ = objc.registerName("dictionaryWithObjectsAndKeys:"); late final _sel_dictionaryWithDictionary_ = objc.registerName("dictionaryWithDictionary:"); -final _objc_msgSend_163 = objc.msgSendPointer +final _objc_msgSend_162 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -7942,7 +8001,7 @@ final _objc_msgSend_163 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_dictionaryWithObjects_forKeys_ = objc.registerName("dictionaryWithObjects:forKeys:"); -final _objc_msgSend_164 = objc.msgSendPointer +final _objc_msgSend_163 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -7961,7 +8020,7 @@ late final _sel_initWithObjectsAndKeys_ = late final _sel_initWithDictionary_ = objc.registerName("initWithDictionary:"); late final _sel_initWithDictionary_copyItems_ = objc.registerName("initWithDictionary:copyItems:"); -final _objc_msgSend_165 = objc.msgSendPointer +final _objc_msgSend_164 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -7977,7 +8036,7 @@ final _objc_msgSend_165 = objc.msgSendPointer bool)>(); late final _sel_initWithObjects_forKeys_ = objc.registerName("initWithObjects:forKeys:"); -final _objc_msgSend_166 = objc.msgSendPointer +final _objc_msgSend_165 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -8010,7 +8069,7 @@ final class NSFastEnumerationState extends ffi.Struct { late final _sel_countByEnumeratingWithState_objects_count_ = objc.registerName("countByEnumeratingWithState:objects:count:"); -final _objc_msgSend_167 = objc.msgSendPointer +final _objc_msgSend_166 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.UnsignedLong Function( @@ -8028,7 +8087,7 @@ final _objc_msgSend_167 = objc.msgSendPointer int)>(); late final _sel_promisedItemResourceValuesForKeys_error_ = objc.registerName("promisedItemResourceValuesForKeys:error:"); -final _objc_msgSend_168 = objc.msgSendPointer +final _objc_msgSend_167 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -8044,6 +8103,18 @@ final _objc_msgSend_168 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_checkPromisedItemIsReachableAndReturnError_ = objc.registerName("checkPromisedItemIsReachableAndReturnError:"); +final _objc_msgSend_168 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer> error)>>() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); late final _sel_fileURLWithPathComponents_ = objc.registerName("fileURLWithPathComponents:"); final _objc_msgSend_169 = objc.msgSendPointer @@ -8093,6 +8164,8 @@ late final _sel_URLByAppendingPathExtension_ = objc.registerName("URLByAppendingPathExtension:"); late final _sel_URLByDeletingPathExtension = objc.registerName("URLByDeletingPathExtension"); +late final _sel_checkResourceIsReachableAndReturnError_ = + objc.registerName("checkResourceIsReachableAndReturnError:"); late final _sel_URLByStandardizingPath = objc.registerName("URLByStandardizingPath"); late final _sel_URLByResolvingSymlinksInPath = @@ -9100,9 +9173,25 @@ final _objc_msgSend_218 = objc.msgSendPointer instancetype Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); late final _sel_initWithFormat_ = objc.registerName("initWithFormat:"); +late final _sel_initWithFormat_arguments_ = + objc.registerName("initWithFormat:arguments:"); +final _objc_msgSend_219 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer format, + ffi.Pointer argList)>>() + .asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); late final _sel_initWithFormat_locale_ = objc.registerName("initWithFormat:locale:"); -final _objc_msgSend_219 = objc.msgSendPointer +final _objc_msgSend_220 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9116,9 +9205,27 @@ final _objc_msgSend_219 = objc.msgSendPointer ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); +late final _sel_initWithFormat_locale_arguments_ = + objc.registerName("initWithFormat:locale:arguments:"); +final _objc_msgSend_221 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer format, + ffi.Pointer locale, + ffi.Pointer argList)>>() + .asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); late final _sel_initWithValidatedFormat_validFormatSpecifiers_error_ = objc.registerName("initWithValidatedFormat:validFormatSpecifiers:error:"); -final _objc_msgSend_220 = objc.msgSendPointer +final _objc_msgSend_222 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9137,7 +9244,7 @@ final _objc_msgSend_220 = objc.msgSendPointer late final _sel_initWithValidatedFormat_validFormatSpecifiers_locale_error_ = objc.registerName( "initWithValidatedFormat:validFormatSpecifiers:locale:error:"); -final _objc_msgSend_221 = objc.msgSendPointer +final _objc_msgSend_223 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9155,9 +9262,53 @@ final _objc_msgSend_221 = objc.msgSendPointer ffi.Pointer, ffi.Pointer, ffi.Pointer>)>(); -late final _sel_initWithData_encoding_ = - objc.registerName("initWithData:encoding:"); -final _objc_msgSend_222 = objc.msgSendPointer +late final _sel_initWithValidatedFormat_validFormatSpecifiers_arguments_error_ = + objc.registerName( + "initWithValidatedFormat:validFormatSpecifiers:arguments:error:"); +final _objc_msgSend_224 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer format, + ffi.Pointer validFormatSpecifiers, + ffi.Pointer argList, + ffi.Pointer> error)>>() + .asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); +late final _sel_initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_ = + objc.registerName( + "initWithValidatedFormat:validFormatSpecifiers:locale:arguments:error:"); +final _objc_msgSend_225 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer format, + ffi.Pointer validFormatSpecifiers, + ffi.Pointer locale, + ffi.Pointer argList, + ffi.Pointer> error)>>() + .asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>(); +late final _sel_initWithData_encoding_ = + objc.registerName("initWithData:encoding:"); +final _objc_msgSend_226 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9173,7 +9324,7 @@ final _objc_msgSend_222 = objc.msgSendPointer int)>(); late final _sel_initWithBytes_length_encoding_ = objc.registerName("initWithBytes:length:encoding:"); -final _objc_msgSend_223 = objc.msgSendPointer +final _objc_msgSend_227 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9187,7 +9338,7 @@ final _objc_msgSend_223 = objc.msgSendPointer ffi.Pointer, ffi.Pointer, int, int)>(); late final _sel_initWithBytesNoCopy_length_encoding_freeWhenDone_ = objc.registerName("initWithBytesNoCopy:length:encoding:freeWhenDone:"); -final _objc_msgSend_224 = objc.msgSendPointer +final _objc_msgSend_228 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9221,7 +9372,7 @@ late final _sel_localizedStringWithValidatedFormat_validFormatSpecifiers_error_ "localizedStringWithValidatedFormat:validFormatSpecifiers:error:"); late final _sel_initWithCString_encoding_ = objc.registerName("initWithCString:encoding:"); -final _objc_msgSend_225 = objc.msgSendPointer +final _objc_msgSend_229 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9236,7 +9387,7 @@ late final _sel_stringWithCString_encoding_ = objc.registerName("stringWithCString:encoding:"); late final _sel_initWithContentsOfURL_encoding_error_ = objc.registerName("initWithContentsOfURL:encoding:error:"); -final _objc_msgSend_226 = objc.msgSendPointer +final _objc_msgSend_230 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9254,7 +9405,7 @@ final _objc_msgSend_226 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_initWithContentsOfFile_encoding_error_ = objc.registerName("initWithContentsOfFile:encoding:error:"); -final _objc_msgSend_227 = objc.msgSendPointer +final _objc_msgSend_231 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9276,7 +9427,7 @@ late final _sel_stringWithContentsOfFile_encoding_error_ = objc.registerName("stringWithContentsOfFile:encoding:error:"); late final _sel_initWithContentsOfURL_usedEncoding_error_ = objc.registerName("initWithContentsOfURL:usedEncoding:error:"); -final _objc_msgSend_228 = objc.msgSendPointer +final _objc_msgSend_232 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9294,7 +9445,7 @@ final _objc_msgSend_228 = objc.msgSendPointer ffi.Pointer>)>(); late final _sel_initWithContentsOfFile_usedEncoding_error_ = objc.registerName("initWithContentsOfFile:usedEncoding:error:"); -final _objc_msgSend_229 = objc.msgSendPointer +final _objc_msgSend_233 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9317,7 +9468,7 @@ late final _sel_stringWithContentsOfFile_usedEncoding_error_ = late final _sel_stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_ = objc.registerName( "stringEncodingForData:encodingOptions:convertedString:usedLossyConversion:"); -final _objc_msgSend_230 = objc.msgSendPointer +final _objc_msgSend_234 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.UnsignedLong Function( @@ -9338,7 +9489,7 @@ final _objc_msgSend_230 = objc.msgSendPointer late final _sel_propertyList = objc.registerName("propertyList"); late final _sel_propertyListFromStringsFileFormat = objc.registerName("propertyListFromStringsFileFormat"); -final _objc_msgSend_231 = objc.msgSendPointer +final _objc_msgSend_235 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function(ffi.Pointer, @@ -9347,7 +9498,7 @@ final _objc_msgSend_231 = objc.msgSendPointer ffi.Pointer Function( ffi.Pointer, ffi.Pointer)>(); late final _sel_getCharacters_ = objc.registerName("getCharacters:"); -final _objc_msgSend_232 = objc.msgSendPointer +final _objc_msgSend_236 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -9359,7 +9510,7 @@ final _objc_msgSend_232 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_stringByAddingPercentEncodingWithAllowedCharacters_ = objc.registerName("stringByAddingPercentEncodingWithAllowedCharacters:"); -final _objc_msgSend_233 = objc.msgSendPointer +final _objc_msgSend_237 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -9373,7 +9524,7 @@ late final _sel_stringByRemovingPercentEncoding = objc.registerName("stringByRemovingPercentEncoding"); late final _sel_anyObject = objc.registerName("anyObject"); late final _sel_intersectsSet_ = objc.registerName("intersectsSet:"); -final _objc_msgSend_234 = objc.msgSendPointer +final _objc_msgSend_238 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -9386,7 +9537,7 @@ final _objc_msgSend_234 = objc.msgSendPointer late final _sel_isEqualToSet_ = objc.registerName("isEqualToSet:"); late final _sel_isSubsetOfSet_ = objc.registerName("isSubsetOfSet:"); late final _sel_setByAddingObject_ = objc.registerName("setByAddingObject:"); -final _objc_msgSend_235 = objc.msgSendPointer +final _objc_msgSend_239 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -9398,7 +9549,7 @@ final _objc_msgSend_235 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_setByAddingObjectsFromSet_ = objc.registerName("setByAddingObjectsFromSet:"); -final _objc_msgSend_236 = objc.msgSendPointer +final _objc_msgSend_240 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -9410,7 +9561,7 @@ final _objc_msgSend_236 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_setByAddingObjectsFromArray_ = objc.registerName("setByAddingObjectsFromArray:"); -final _objc_msgSend_237 = objc.msgSendPointer +final _objc_msgSend_241 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -9426,7 +9577,7 @@ late final _sel_setWithObjects_count_ = objc.registerName("setWithObjects:count:"); late final _sel_setWithObjects_ = objc.registerName("setWithObjects:"); late final _sel_setWithSet_ = objc.registerName("setWithSet:"); -final _objc_msgSend_238 = objc.msgSendPointer +final _objc_msgSend_242 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9440,7 +9591,7 @@ late final _sel_setWithArray_ = objc.registerName("setWithArray:"); late final _sel_initWithSet_ = objc.registerName("initWithSet:"); late final _sel_initWithSet_copyItems_ = objc.registerName("initWithSet:copyItems:"); -final _objc_msgSend_239 = objc.msgSendPointer +final _objc_msgSend_243 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -9456,7 +9607,7 @@ final _objc_msgSend_239 = objc.msgSendPointer bool)>(); late final _sel_methodSignatureForSelector_ = objc.registerName("methodSignatureForSelector:"); -final _objc_msgSend_240 = objc.msgSendPointer +final _objc_msgSend_244 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -9477,7 +9628,7 @@ late final _sel_class = objc.registerName("class"); late final _sel_debugDescription = objc.registerName("debugDescription"); late final _sel_version = objc.registerName("version"); late final _sel_setVersion_ = objc.registerName("setVersion:"); -final _objc_msgSend_241 = objc.msgSendPointer +final _objc_msgSend_245 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, @@ -9495,7 +9646,7 @@ late final _sel_autoContentAccessingProxy = late final _sel_attemptRecoveryFromError_optionIndex_delegate_didRecoverSelector_contextInfo_ = objc.registerName( "attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:"); -final _objc_msgSend_242 = objc.msgSendPointer +final _objc_msgSend_246 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -9517,7 +9668,7 @@ final _objc_msgSend_242 = objc.msgSendPointer ffi.Pointer)>(); late final _sel_attemptRecoveryFromError_optionIndex_ = objc.registerName("attemptRecoveryFromError:optionIndex:"); -final _objc_msgSend_243 = objc.msgSendPointer +final _objc_msgSend_247 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -9533,7 +9684,7 @@ final _objc_msgSend_243 = objc.msgSendPointer int)>(); late final _sel_observeValueForKeyPath_ofObject_change_context_ = objc.registerName("observeValueForKeyPath:ofObject:change:context:"); -final _objc_msgSend_244 = objc.msgSendPointer +final _objc_msgSend_248 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -9576,7 +9727,7 @@ enum NSKeyValueChange { late final _sel_willChange_valuesAtIndexes_forKey_ = objc.registerName("willChange:valuesAtIndexes:forKey:"); -final _objc_msgSend_245 = objc.msgSendPointer +final _objc_msgSend_249 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -9616,7 +9767,7 @@ enum NSKeyValueSetMutationKind { late final _sel_willChangeValueForKey_withSetMutation_usingObjects_ = objc.registerName("willChangeValueForKey:withSetMutation:usingObjects:"); -final _objc_msgSend_246 = objc.msgSendPointer +final _objc_msgSend_250 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -9636,7 +9787,7 @@ late final _sel_didChangeValueForKey_withSetMutation_usingObjects_ = objc.registerName("didChangeValueForKey:withSetMutation:usingObjects:"); late final _sel_observationInfo = objc.registerName("observationInfo"); late final _sel_setObservationInfo_ = objc.registerName("setObservationInfo:"); -final _objc_msgSend_247 = objc.msgSendPointer +final _objc_msgSend_251 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, @@ -9697,12 +9848,12 @@ class NSMutableIndexSet extends NSIndexSet { /// addIndexes: void addIndexes_(NSIndexSet indexSet) { - _objc_msgSend_248(this.ref.pointer, _sel_addIndexes_, indexSet.ref.pointer); + _objc_msgSend_252(this.ref.pointer, _sel_addIndexes_, indexSet.ref.pointer); } /// removeIndexes: void removeIndexes_(NSIndexSet indexSet) { - _objc_msgSend_248( + _objc_msgSend_252( this.ref.pointer, _sel_removeIndexes_, indexSet.ref.pointer); } @@ -9713,27 +9864,27 @@ class NSMutableIndexSet extends NSIndexSet { /// addIndex: void addIndex_(int value) { - _objc_msgSend_249(this.ref.pointer, _sel_addIndex_, value); + _objc_msgSend_253(this.ref.pointer, _sel_addIndex_, value); } /// removeIndex: void removeIndex_(int value) { - _objc_msgSend_249(this.ref.pointer, _sel_removeIndex_, value); + _objc_msgSend_253(this.ref.pointer, _sel_removeIndex_, value); } /// addIndexesInRange: void addIndexesInRange_(NSRange range) { - _objc_msgSend_250(this.ref.pointer, _sel_addIndexesInRange_, range); + _objc_msgSend_254(this.ref.pointer, _sel_addIndexesInRange_, range); } /// removeIndexesInRange: void removeIndexesInRange_(NSRange range) { - _objc_msgSend_250(this.ref.pointer, _sel_removeIndexesInRange_, range); + _objc_msgSend_254(this.ref.pointer, _sel_removeIndexesInRange_, range); } /// shiftIndexesStartingAtIndex:by: void shiftIndexesStartingAtIndex_by_(int index, int delta) { - _objc_msgSend_251( + _objc_msgSend_255( this.ref.pointer, _sel_shiftIndexesStartingAtIndex_by_, index, delta); } @@ -9826,7 +9977,7 @@ class NSMutableIndexSet extends NSIndexSet { late final _class_NSMutableIndexSet = objc.getClass("NSMutableIndexSet"); late final _sel_addIndexes_ = objc.registerName("addIndexes:"); -final _objc_msgSend_248 = objc.msgSendPointer +final _objc_msgSend_252 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -9839,7 +9990,7 @@ final _objc_msgSend_248 = objc.msgSendPointer late final _sel_removeIndexes_ = objc.registerName("removeIndexes:"); late final _sel_removeAllIndexes = objc.registerName("removeAllIndexes"); late final _sel_addIndex_ = objc.registerName("addIndex:"); -final _objc_msgSend_249 = objc.msgSendPointer +final _objc_msgSend_253 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, @@ -9849,7 +10000,7 @@ final _objc_msgSend_249 = objc.msgSendPointer ffi.Pointer, int)>(); late final _sel_removeIndex_ = objc.registerName("removeIndex:"); late final _sel_addIndexesInRange_ = objc.registerName("addIndexesInRange:"); -final _objc_msgSend_250 = objc.msgSendPointer +final _objc_msgSend_254 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, @@ -9861,7 +10012,7 @@ late final _sel_removeIndexesInRange_ = objc.registerName("removeIndexesInRange:"); late final _sel_shiftIndexesStartingAtIndex_by_ = objc.registerName("shiftIndexesStartingAtIndex:by:"); -final _objc_msgSend_251 = objc.msgSendPointer +final _objc_msgSend_255 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -9913,12 +10064,12 @@ class NSMutableArray extends NSArray { /// addObject: void addObject_(objc.ObjCObjectBase anObject) { - _objc_msgSend_252(this.ref.pointer, _sel_addObject_, anObject.ref.pointer); + _objc_msgSend_256(this.ref.pointer, _sel_addObject_, anObject.ref.pointer); } /// insertObject:atIndex: void insertObject_atIndex_(objc.ObjCObjectBase anObject, int index) { - _objc_msgSend_253(this.ref.pointer, _sel_insertObject_atIndex_, + _objc_msgSend_257(this.ref.pointer, _sel_insertObject_atIndex_, anObject.ref.pointer, index); } @@ -9929,13 +10080,13 @@ class NSMutableArray extends NSArray { /// removeObjectAtIndex: void removeObjectAtIndex_(int index) { - _objc_msgSend_249(this.ref.pointer, _sel_removeObjectAtIndex_, index); + _objc_msgSend_253(this.ref.pointer, _sel_removeObjectAtIndex_, index); } /// replaceObjectAtIndex:withObject: void replaceObjectAtIndex_withObject_( int index, objc.ObjCObjectBase anObject) { - _objc_msgSend_254(this.ref.pointer, _sel_replaceObjectAtIndex_withObject_, + _objc_msgSend_258(this.ref.pointer, _sel_replaceObjectAtIndex_withObject_, index, anObject.ref.pointer); } @@ -9963,13 +10114,13 @@ class NSMutableArray extends NSArray { /// addObjectsFromArray: void addObjectsFromArray_(NSArray otherArray) { - _objc_msgSend_255( + _objc_msgSend_259( this.ref.pointer, _sel_addObjectsFromArray_, otherArray.ref.pointer); } /// exchangeObjectAtIndex:withObjectAtIndex: void exchangeObjectAtIndex_withObjectAtIndex_(int idx1, int idx2) { - _objc_msgSend_256(this.ref.pointer, + _objc_msgSend_260(this.ref.pointer, _sel_exchangeObjectAtIndex_withObjectAtIndex_, idx1, idx2); } @@ -9980,44 +10131,44 @@ class NSMutableArray extends NSArray { /// removeObject:inRange: void removeObject_inRange_(objc.ObjCObjectBase anObject, NSRange range) { - _objc_msgSend_257(this.ref.pointer, _sel_removeObject_inRange_, + _objc_msgSend_261(this.ref.pointer, _sel_removeObject_inRange_, anObject.ref.pointer, range); } /// removeObject: void removeObject_(objc.ObjCObjectBase anObject) { - _objc_msgSend_252( + _objc_msgSend_256( this.ref.pointer, _sel_removeObject_, anObject.ref.pointer); } /// removeObjectIdenticalTo:inRange: void removeObjectIdenticalTo_inRange_( objc.ObjCObjectBase anObject, NSRange range) { - _objc_msgSend_257(this.ref.pointer, _sel_removeObjectIdenticalTo_inRange_, + _objc_msgSend_261(this.ref.pointer, _sel_removeObjectIdenticalTo_inRange_, anObject.ref.pointer, range); } /// removeObjectIdenticalTo: void removeObjectIdenticalTo_(objc.ObjCObjectBase anObject) { - _objc_msgSend_252( + _objc_msgSend_256( this.ref.pointer, _sel_removeObjectIdenticalTo_, anObject.ref.pointer); } /// removeObjectsInArray: void removeObjectsInArray_(NSArray otherArray) { - _objc_msgSend_255( + _objc_msgSend_259( this.ref.pointer, _sel_removeObjectsInArray_, otherArray.ref.pointer); } /// removeObjectsInRange: void removeObjectsInRange_(NSRange range) { - _objc_msgSend_250(this.ref.pointer, _sel_removeObjectsInRange_, range); + _objc_msgSend_254(this.ref.pointer, _sel_removeObjectsInRange_, range); } /// replaceObjectsInRange:withObjectsFromArray:range: void replaceObjectsInRange_withObjectsFromArray_range_( NSRange range, NSArray otherArray, NSRange otherRange) { - _objc_msgSend_258( + _objc_msgSend_262( this.ref.pointer, _sel_replaceObjectsInRange_withObjectsFromArray_range_, range, @@ -10028,7 +10179,7 @@ class NSMutableArray extends NSArray { /// replaceObjectsInRange:withObjectsFromArray: void replaceObjectsInRange_withObjectsFromArray_( NSRange range, NSArray otherArray) { - _objc_msgSend_259( + _objc_msgSend_263( this.ref.pointer, _sel_replaceObjectsInRange_withObjectsFromArray_, range, @@ -10037,7 +10188,7 @@ class NSMutableArray extends NSArray { /// setArray: void setArray_(NSArray otherArray) { - _objc_msgSend_255(this.ref.pointer, _sel_setArray_, otherArray.ref.pointer); + _objc_msgSend_259(this.ref.pointer, _sel_setArray_, otherArray.ref.pointer); } /// sortUsingFunction:context: @@ -10048,7 +10199,7 @@ class NSMutableArray extends NSArray { ffi.Pointer, ffi.Pointer)>> compare, ffi.Pointer context) { - _objc_msgSend_260( + _objc_msgSend_264( this.ref.pointer, _sel_sortUsingFunction_context_, compare, context); } @@ -10059,20 +10210,20 @@ class NSMutableArray extends NSArray { /// insertObjects:atIndexes: void insertObjects_atIndexes_(NSArray objects, NSIndexSet indexes) { - _objc_msgSend_261(this.ref.pointer, _sel_insertObjects_atIndexes_, + _objc_msgSend_265(this.ref.pointer, _sel_insertObjects_atIndexes_, objects.ref.pointer, indexes.ref.pointer); } /// removeObjectsAtIndexes: void removeObjectsAtIndexes_(NSIndexSet indexes) { - _objc_msgSend_248( + _objc_msgSend_252( this.ref.pointer, _sel_removeObjectsAtIndexes_, indexes.ref.pointer); } /// replaceObjectsAtIndexes:withObjects: void replaceObjectsAtIndexes_withObjects_( NSIndexSet indexes, NSArray objects) { - _objc_msgSend_262( + _objc_msgSend_266( this.ref.pointer, _sel_replaceObjectsAtIndexes_withObjects_, indexes.ref.pointer, @@ -10081,7 +10232,7 @@ class NSMutableArray extends NSArray { /// setObject:atIndexedSubscript: void setObject_atIndexedSubscript_(objc.ObjCObjectBase obj, int idx) { - _objc_msgSend_253(this.ref.pointer, _sel_setObject_atIndexedSubscript_, + _objc_msgSend_257(this.ref.pointer, _sel_setObject_atIndexedSubscript_, obj.ref.pointer, idx); } @@ -10112,7 +10263,7 @@ class NSMutableArray extends NSArray { /// initWithContentsOfFile: NSMutableArray? initWithContentsOfFile_(NSString path) { - final _ret = _objc_msgSend_263(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_267(this.ref.retainAndReturnPointer(), _sel_initWithContentsOfFile_, path.ref.pointer); return _ret.address == 0 ? null @@ -10121,7 +10272,7 @@ class NSMutableArray extends NSArray { /// initWithContentsOfURL: NSMutableArray? initWithContentsOfURL_(NSURL url) { - final _ret = _objc_msgSend_264(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_268(this.ref.retainAndReturnPointer(), _sel_initWithContentsOfURL_, url.ref.pointer); return _ret.address == 0 ? null @@ -10130,7 +10281,7 @@ class NSMutableArray extends NSArray { /// applyDifference: void applyDifference_(objc.ObjCObjectBase difference) { - _objc_msgSend_252( + _objc_msgSend_256( this.ref.pointer, _sel_applyDifference_, difference.ref.pointer); } @@ -10243,7 +10394,7 @@ class NSMutableArray extends NSArray { late final _class_NSMutableArray = objc.getClass("NSMutableArray"); late final _sel_addObject_ = objc.registerName("addObject:"); -final _objc_msgSend_252 = objc.msgSendPointer +final _objc_msgSend_256 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10255,7 +10406,7 @@ final _objc_msgSend_252 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_insertObject_atIndex_ = objc.registerName("insertObject:atIndex:"); -final _objc_msgSend_253 = objc.msgSendPointer +final _objc_msgSend_257 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10274,7 +10425,7 @@ late final _sel_removeObjectAtIndex_ = objc.registerName("removeObjectAtIndex:"); late final _sel_replaceObjectAtIndex_withObject_ = objc.registerName("replaceObjectAtIndex:withObject:"); -final _objc_msgSend_254 = objc.msgSendPointer +final _objc_msgSend_258 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10291,7 +10442,7 @@ final _objc_msgSend_254 = objc.msgSendPointer late final _sel_initWithCapacity_ = objc.registerName("initWithCapacity:"); late final _sel_addObjectsFromArray_ = objc.registerName("addObjectsFromArray:"); -final _objc_msgSend_255 = objc.msgSendPointer +final _objc_msgSend_259 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10303,7 +10454,7 @@ final _objc_msgSend_255 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_exchangeObjectAtIndex_withObjectAtIndex_ = objc.registerName("exchangeObjectAtIndex:withObjectAtIndex:"); -final _objc_msgSend_256 = objc.msgSendPointer +final _objc_msgSend_260 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10317,7 +10468,7 @@ final _objc_msgSend_256 = objc.msgSendPointer late final _sel_removeAllObjects = objc.registerName("removeAllObjects"); late final _sel_removeObject_inRange_ = objc.registerName("removeObject:inRange:"); -final _objc_msgSend_257 = objc.msgSendPointer +final _objc_msgSend_261 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10342,7 +10493,7 @@ late final _sel_removeObjectsInRange_ = objc.registerName("removeObjectsInRange:"); late final _sel_replaceObjectsInRange_withObjectsFromArray_range_ = objc.registerName("replaceObjectsInRange:withObjectsFromArray:range:"); -final _objc_msgSend_258 = objc.msgSendPointer +final _objc_msgSend_262 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10360,7 +10511,7 @@ final _objc_msgSend_258 = objc.msgSendPointer NSRange)>(); late final _sel_replaceObjectsInRange_withObjectsFromArray_ = objc.registerName("replaceObjectsInRange:withObjectsFromArray:"); -final _objc_msgSend_259 = objc.msgSendPointer +final _objc_msgSend_263 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10377,7 +10528,7 @@ final _objc_msgSend_259 = objc.msgSendPointer late final _sel_setArray_ = objc.registerName("setArray:"); late final _sel_sortUsingFunction_context_ = objc.registerName("sortUsingFunction:context:"); -final _objc_msgSend_260 = objc.msgSendPointer +final _objc_msgSend_264 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10403,7 +10554,7 @@ final _objc_msgSend_260 = objc.msgSendPointer late final _sel_sortUsingSelector_ = objc.registerName("sortUsingSelector:"); late final _sel_insertObjects_atIndexes_ = objc.registerName("insertObjects:atIndexes:"); -final _objc_msgSend_261 = objc.msgSendPointer +final _objc_msgSend_265 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10421,7 +10572,7 @@ late final _sel_removeObjectsAtIndexes_ = objc.registerName("removeObjectsAtIndexes:"); late final _sel_replaceObjectsAtIndexes_withObjects_ = objc.registerName("replaceObjectsAtIndexes:withObjects:"); -final _objc_msgSend_262 = objc.msgSendPointer +final _objc_msgSend_266 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10438,7 +10589,7 @@ final _objc_msgSend_262 = objc.msgSendPointer late final _sel_setObject_atIndexedSubscript_ = objc.registerName("setObject:atIndexedSubscript:"); late final _sel_arrayWithCapacity_ = objc.registerName("arrayWithCapacity:"); -final _objc_msgSend_263 = objc.msgSendPointer +final _objc_msgSend_267 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -10448,7 +10599,7 @@ final _objc_msgSend_263 = objc.msgSendPointer .asFunction< ffi.Pointer Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); -final _objc_msgSend_264 = objc.msgSendPointer +final _objc_msgSend_268 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -10493,7 +10644,7 @@ class NSMutableData extends NSData { /// setLength: set length(int value) { - return _objc_msgSend_265(this.ref.pointer, _sel_setLength_, value); + return _objc_msgSend_269(this.ref.pointer, _sel_setLength_, value); } /// appendBytes:length: @@ -10503,35 +10654,35 @@ class NSMutableData extends NSData { /// appendData: void appendData_(NSData other) { - _objc_msgSend_266(this.ref.pointer, _sel_appendData_, other.ref.pointer); + _objc_msgSend_270(this.ref.pointer, _sel_appendData_, other.ref.pointer); } /// increaseLengthBy: void increaseLengthBy_(int extraLength) { - _objc_msgSend_249(this.ref.pointer, _sel_increaseLengthBy_, extraLength); + _objc_msgSend_253(this.ref.pointer, _sel_increaseLengthBy_, extraLength); } /// replaceBytesInRange:withBytes: void replaceBytesInRange_withBytes_( NSRange range, ffi.Pointer bytes) { - _objc_msgSend_267( + _objc_msgSend_271( this.ref.pointer, _sel_replaceBytesInRange_withBytes_, range, bytes); } /// resetBytesInRange: void resetBytesInRange_(NSRange range) { - _objc_msgSend_250(this.ref.pointer, _sel_resetBytesInRange_, range); + _objc_msgSend_254(this.ref.pointer, _sel_resetBytesInRange_, range); } /// setData: void setData_(NSData data) { - _objc_msgSend_266(this.ref.pointer, _sel_setData_, data.ref.pointer); + _objc_msgSend_270(this.ref.pointer, _sel_setData_, data.ref.pointer); } /// replaceBytesInRange:withBytes:length: void replaceBytesInRange_withBytes_length_(NSRange range, ffi.Pointer replacementBytes, int replacementLength) { - _objc_msgSend_268( + _objc_msgSend_272( this.ref.pointer, _sel_replaceBytesInRange_withBytes_length_, range, @@ -10541,7 +10692,7 @@ class NSMutableData extends NSData { /// dataWithCapacity: static NSMutableData? dataWithCapacity_(int aNumItems) { - final _ret = _objc_msgSend_269( + final _ret = _objc_msgSend_273( _class_NSMutableData, _sel_dataWithCapacity_, aNumItems); return _ret.address == 0 ? null @@ -10551,7 +10702,7 @@ class NSMutableData extends NSData { /// dataWithLength: static NSMutableData? dataWithLength_(int length) { final _ret = - _objc_msgSend_269(_class_NSMutableData, _sel_dataWithLength_, length); + _objc_msgSend_273(_class_NSMutableData, _sel_dataWithLength_, length); return _ret.address == 0 ? null : NSMutableData.castFromPointer(_ret, retain: true, release: true); @@ -10559,7 +10710,7 @@ class NSMutableData extends NSData { /// initWithCapacity: NSMutableData? initWithCapacity_(int capacity) { - final _ret = _objc_msgSend_269( + final _ret = _objc_msgSend_273( this.ref.retainAndReturnPointer(), _sel_initWithCapacity_, capacity); return _ret.address == 0 ? null @@ -10568,7 +10719,7 @@ class NSMutableData extends NSData { /// initWithLength: NSMutableData? initWithLength_(int length) { - final _ret = _objc_msgSend_269( + final _ret = _objc_msgSend_273( this.ref.retainAndReturnPointer(), _sel_initWithLength_, length); return _ret.address == 0 ? null @@ -10578,14 +10729,14 @@ class NSMutableData extends NSData { /// decompressUsingAlgorithm:error: bool decompressUsingAlgorithm_error_(NSDataCompressionAlgorithm algorithm, ffi.Pointer> error) { - return _objc_msgSend_270(this.ref.pointer, + return _objc_msgSend_274(this.ref.pointer, _sel_decompressUsingAlgorithm_error_, algorithm.value, error); } /// compressUsingAlgorithm:error: bool compressUsingAlgorithm_error_(NSDataCompressionAlgorithm algorithm, ffi.Pointer> error) { - return _objc_msgSend_270(this.ref.pointer, + return _objc_msgSend_274(this.ref.pointer, _sel_compressUsingAlgorithm_error_, algorithm.value, error); } @@ -10846,7 +10997,7 @@ class NSMutableData extends NSData { late final _class_NSMutableData = objc.getClass("NSMutableData"); late final _sel_mutableBytes = objc.registerName("mutableBytes"); late final _sel_setLength_ = objc.registerName("setLength:"); -final _objc_msgSend_265 = objc.msgSendPointer +final _objc_msgSend_269 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function(ffi.Pointer, @@ -10856,7 +11007,7 @@ final _objc_msgSend_265 = objc.msgSendPointer ffi.Pointer, int)>(); late final _sel_appendBytes_length_ = objc.registerName("appendBytes:length:"); late final _sel_appendData_ = objc.registerName("appendData:"); -final _objc_msgSend_266 = objc.msgSendPointer +final _objc_msgSend_270 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10869,7 +11020,7 @@ final _objc_msgSend_266 = objc.msgSendPointer late final _sel_increaseLengthBy_ = objc.registerName("increaseLengthBy:"); late final _sel_replaceBytesInRange_withBytes_ = objc.registerName("replaceBytesInRange:withBytes:"); -final _objc_msgSend_267 = objc.msgSendPointer +final _objc_msgSend_271 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10884,7 +11035,7 @@ late final _sel_resetBytesInRange_ = objc.registerName("resetBytesInRange:"); late final _sel_setData_ = objc.registerName("setData:"); late final _sel_replaceBytesInRange_withBytes_length_ = objc.registerName("replaceBytesInRange:withBytes:length:"); -final _objc_msgSend_268 = objc.msgSendPointer +final _objc_msgSend_272 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -10901,7 +11052,7 @@ final _objc_msgSend_268 = objc.msgSendPointer ffi.Pointer, int)>(); late final _sel_dataWithCapacity_ = objc.registerName("dataWithCapacity:"); -final _objc_msgSend_269 = objc.msgSendPointer +final _objc_msgSend_273 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function(ffi.Pointer, @@ -10913,7 +11064,7 @@ late final _sel_dataWithLength_ = objc.registerName("dataWithLength:"); late final _sel_initWithLength_ = objc.registerName("initWithLength:"); late final _sel_decompressUsingAlgorithm_error_ = objc.registerName("decompressUsingAlgorithm:error:"); -final _objc_msgSend_270 = objc.msgSendPointer +final _objc_msgSend_274 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -10967,7 +11118,7 @@ class NSNotification extends NSObject { /// userInfo NSDictionary? get userInfo { - final _ret = _objc_msgSend_231(this.ref.pointer, _sel_userInfo); + final _ret = _objc_msgSend_235(this.ref.pointer, _sel_userInfo); return _ret.address == 0 ? null : NSDictionary.castFromPointer(_ret, retain: true, release: true); @@ -10976,7 +11127,7 @@ class NSNotification extends NSObject { /// initWithName:object:userInfo: NSNotification initWithName_object_userInfo_( NSString name, objc.ObjCObjectBase? object, NSDictionary? userInfo) { - final _ret = _objc_msgSend_271( + final _ret = _objc_msgSend_275( this.ref.retainAndReturnPointer(), _sel_initWithName_object_userInfo_, name.ref.pointer, @@ -10997,7 +11148,7 @@ class NSNotification extends NSObject { /// notificationWithName:object: static NSNotification notificationWithName_object_( NSString aName, objc.ObjCObjectBase? anObject) { - final _ret = _objc_msgSend_219( + final _ret = _objc_msgSend_220( _class_NSNotification, _sel_notificationWithName_object_, aName.ref.pointer, @@ -11008,7 +11159,7 @@ class NSNotification extends NSObject { /// notificationWithName:object:userInfo: static NSNotification notificationWithName_object_userInfo_( NSString aName, objc.ObjCObjectBase? anObject, NSDictionary? aUserInfo) { - final _ret = _objc_msgSend_271( + final _ret = _objc_msgSend_275( _class_NSNotification, _sel_notificationWithName_object_userInfo_, aName.ref.pointer, @@ -11061,7 +11212,7 @@ late final _sel_name = objc.registerName("name"); late final _sel_object = objc.registerName("object"); late final _sel_initWithName_object_userInfo_ = objc.registerName("initWithName:object:userInfo:"); -final _objc_msgSend_271 = objc.msgSendPointer +final _objc_msgSend_275 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -11118,7 +11269,7 @@ class NSDate extends NSObject { /// initWithTimeIntervalSinceReferenceDate: NSDate initWithTimeIntervalSinceReferenceDate_(double ti) { - final _ret = _objc_msgSend_272(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_276(this.ref.retainAndReturnPointer(), _sel_initWithTimeIntervalSinceReferenceDate_, ti); return NSDate.castFromPointer(_ret, retain: false, release: true); } @@ -11135,9 +11286,9 @@ class NSDate extends NSObject { /// timeIntervalSinceDate: double timeIntervalSinceDate_(NSDate anotherDate) { return objc.useMsgSendVariants - ? _objc_msgSend_273Fpret(this.ref.pointer, _sel_timeIntervalSinceDate_, + ? _objc_msgSend_277Fpret(this.ref.pointer, _sel_timeIntervalSinceDate_, anotherDate.ref.pointer) - : _objc_msgSend_273(this.ref.pointer, _sel_timeIntervalSinceDate_, + : _objc_msgSend_277(this.ref.pointer, _sel_timeIntervalSinceDate_, anotherDate.ref.pointer); } @@ -11158,20 +11309,20 @@ class NSDate extends NSObject { /// dateByAddingTimeInterval: NSDate dateByAddingTimeInterval_(double ti) { final _ret = - _objc_msgSend_272(this.ref.pointer, _sel_dateByAddingTimeInterval_, ti); + _objc_msgSend_276(this.ref.pointer, _sel_dateByAddingTimeInterval_, ti); return NSDate.castFromPointer(_ret, retain: true, release: true); } /// earlierDate: NSDate earlierDate_(NSDate anotherDate) { - final _ret = _objc_msgSend_274( + final _ret = _objc_msgSend_278( this.ref.pointer, _sel_earlierDate_, anotherDate.ref.pointer); return NSDate.castFromPointer(_ret, retain: true, release: true); } /// laterDate: NSDate laterDate_(NSDate anotherDate) { - final _ret = _objc_msgSend_274( + final _ret = _objc_msgSend_278( this.ref.pointer, _sel_laterDate_, anotherDate.ref.pointer); return NSDate.castFromPointer(_ret, retain: true, release: true); } @@ -11179,13 +11330,13 @@ class NSDate extends NSObject { /// compare: NSComparisonResult compare_(NSDate other) { final _ret = - _objc_msgSend_275(this.ref.pointer, _sel_compare_, other.ref.pointer); + _objc_msgSend_279(this.ref.pointer, _sel_compare_, other.ref.pointer); return NSComparisonResult.fromValue(_ret); } /// isEqualToDate: bool isEqualToDate_(NSDate otherDate) { - return _objc_msgSend_276( + return _objc_msgSend_280( this.ref.pointer, _sel_isEqualToDate_, otherDate.ref.pointer); } @@ -11210,21 +11361,21 @@ class NSDate extends NSObject { /// dateWithTimeIntervalSinceNow: static NSDate dateWithTimeIntervalSinceNow_(double secs) { - final _ret = _objc_msgSend_272( + final _ret = _objc_msgSend_276( _class_NSDate, _sel_dateWithTimeIntervalSinceNow_, secs); return NSDate.castFromPointer(_ret, retain: true, release: true); } /// dateWithTimeIntervalSinceReferenceDate: static NSDate dateWithTimeIntervalSinceReferenceDate_(double ti) { - final _ret = _objc_msgSend_272( + final _ret = _objc_msgSend_276( _class_NSDate, _sel_dateWithTimeIntervalSinceReferenceDate_, ti); return NSDate.castFromPointer(_ret, retain: true, release: true); } /// dateWithTimeIntervalSince1970: static NSDate dateWithTimeIntervalSince1970_(double secs) { - final _ret = _objc_msgSend_272( + final _ret = _objc_msgSend_276( _class_NSDate, _sel_dateWithTimeIntervalSince1970_, secs); return NSDate.castFromPointer(_ret, retain: true, release: true); } @@ -11232,46 +11383,46 @@ class NSDate extends NSObject { /// dateWithTimeInterval:sinceDate: static NSDate dateWithTimeInterval_sinceDate_( double secsToBeAdded, NSDate date) { - final _ret = _objc_msgSend_277(_class_NSDate, + final _ret = _objc_msgSend_281(_class_NSDate, _sel_dateWithTimeInterval_sinceDate_, secsToBeAdded, date.ref.pointer); return NSDate.castFromPointer(_ret, retain: true, release: true); } /// distantFuture static NSDate getDistantFuture() { - final _ret = _objc_msgSend_278(_class_NSDate, _sel_distantFuture); + final _ret = _objc_msgSend_282(_class_NSDate, _sel_distantFuture); return NSDate.castFromPointer(_ret, retain: true, release: true); } /// distantPast static NSDate getDistantPast() { - final _ret = _objc_msgSend_278(_class_NSDate, _sel_distantPast); + final _ret = _objc_msgSend_282(_class_NSDate, _sel_distantPast); return NSDate.castFromPointer(_ret, retain: true, release: true); } /// now static NSDate getNow() { - final _ret = _objc_msgSend_278(_class_NSDate, _sel_now); + final _ret = _objc_msgSend_282(_class_NSDate, _sel_now); return NSDate.castFromPointer(_ret, retain: true, release: true); } /// initWithTimeIntervalSinceNow: NSDate initWithTimeIntervalSinceNow_(double secs) { - final _ret = _objc_msgSend_272(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_276(this.ref.retainAndReturnPointer(), _sel_initWithTimeIntervalSinceNow_, secs); return NSDate.castFromPointer(_ret, retain: false, release: true); } /// initWithTimeIntervalSince1970: NSDate initWithTimeIntervalSince1970_(double secs) { - final _ret = _objc_msgSend_272(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_276(this.ref.retainAndReturnPointer(), _sel_initWithTimeIntervalSince1970_, secs); return NSDate.castFromPointer(_ret, retain: false, release: true); } /// initWithTimeInterval:sinceDate: NSDate initWithTimeInterval_sinceDate_(double secsToBeAdded, NSDate date) { - final _ret = _objc_msgSend_277(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_281(this.ref.retainAndReturnPointer(), _sel_initWithTimeInterval_sinceDate_, secsToBeAdded, date.ref.pointer); return NSDate.castFromPointer(_ret, retain: false, release: true); } @@ -11313,7 +11464,7 @@ late final _sel_timeIntervalSinceReferenceDate = objc.registerName("timeIntervalSinceReferenceDate"); late final _sel_initWithTimeIntervalSinceReferenceDate_ = objc.registerName("initWithTimeIntervalSinceReferenceDate:"); -final _objc_msgSend_272 = objc.msgSendPointer +final _objc_msgSend_276 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function(ffi.Pointer, @@ -11323,7 +11474,7 @@ final _objc_msgSend_272 = objc.msgSendPointer ffi.Pointer, double)>(); late final _sel_timeIntervalSinceDate_ = objc.registerName("timeIntervalSinceDate:"); -final _objc_msgSend_273 = objc.msgSendPointer +final _objc_msgSend_277 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Double Function( @@ -11333,7 +11484,7 @@ final _objc_msgSend_273 = objc.msgSendPointer .asFunction< double Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); -final _objc_msgSend_273Fpret = objc.msgSendFpretPointer +final _objc_msgSend_277Fpret = objc.msgSendFpretPointer .cast< ffi.NativeFunction< ffi.Double Function( @@ -11350,7 +11501,7 @@ late final _sel_timeIntervalSince1970 = late final _sel_dateByAddingTimeInterval_ = objc.registerName("dateByAddingTimeInterval:"); late final _sel_earlierDate_ = objc.registerName("earlierDate:"); -final _objc_msgSend_274 = objc.msgSendPointer +final _objc_msgSend_278 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -11361,7 +11512,7 @@ final _objc_msgSend_274 = objc.msgSendPointer ffi.Pointer Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); late final _sel_laterDate_ = objc.registerName("laterDate:"); -final _objc_msgSend_275 = objc.msgSendPointer +final _objc_msgSend_279 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Long Function( @@ -11372,7 +11523,7 @@ final _objc_msgSend_275 = objc.msgSendPointer int Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); late final _sel_isEqualToDate_ = objc.registerName("isEqualToDate:"); -final _objc_msgSend_276 = objc.msgSendPointer +final _objc_msgSend_280 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -11391,7 +11542,7 @@ late final _sel_dateWithTimeIntervalSince1970_ = objc.registerName("dateWithTimeIntervalSince1970:"); late final _sel_dateWithTimeInterval_sinceDate_ = objc.registerName("dateWithTimeInterval:sinceDate:"); -final _objc_msgSend_277 = objc.msgSendPointer +final _objc_msgSend_281 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -11406,7 +11557,7 @@ final _objc_msgSend_277 = objc.msgSendPointer double, ffi.Pointer)>(); late final _sel_distantFuture = objc.registerName("distantFuture"); -final _objc_msgSend_278 = objc.msgSendPointer +final _objc_msgSend_282 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function(ffi.Pointer, @@ -11446,14 +11597,14 @@ class NSMutableDictionary extends NSDictionary { /// removeObjectForKey: void removeObjectForKey_(objc.ObjCObjectBase aKey) { - _objc_msgSend_252( + _objc_msgSend_256( this.ref.pointer, _sel_removeObjectForKey_, aKey.ref.pointer); } /// setObject:forKey: void setObject_forKey_( objc.ObjCObjectBase anObject, objc.ObjCObjectBase aKey) { - _objc_msgSend_279(this.ref.pointer, _sel_setObject_forKey_, + _objc_msgSend_283(this.ref.pointer, _sel_setObject_forKey_, anObject.ref.pointer, aKey.ref.pointer); } @@ -11484,7 +11635,7 @@ class NSMutableDictionary extends NSDictionary { /// addEntriesFromDictionary: void addEntriesFromDictionary_(NSDictionary otherDictionary) { - _objc_msgSend_280(this.ref.pointer, _sel_addEntriesFromDictionary_, + _objc_msgSend_284(this.ref.pointer, _sel_addEntriesFromDictionary_, otherDictionary.ref.pointer); } @@ -11495,20 +11646,20 @@ class NSMutableDictionary extends NSDictionary { /// removeObjectsForKeys: void removeObjectsForKeys_(NSArray keyArray) { - _objc_msgSend_255( + _objc_msgSend_259( this.ref.pointer, _sel_removeObjectsForKeys_, keyArray.ref.pointer); } /// setDictionary: void setDictionary_(NSDictionary otherDictionary) { - _objc_msgSend_280( + _objc_msgSend_284( this.ref.pointer, _sel_setDictionary_, otherDictionary.ref.pointer); } /// setObject:forKeyedSubscript: void setObject_forKeyedSubscript_( objc.ObjCObjectBase? obj, objc.ObjCObjectBase key) { - _objc_msgSend_281(this.ref.pointer, _sel_setObject_forKeyedSubscript_, + _objc_msgSend_285(this.ref.pointer, _sel_setObject_forKeyedSubscript_, obj?.ref.pointer ?? ffi.nullptr, key.ref.pointer); } @@ -11522,7 +11673,7 @@ class NSMutableDictionary extends NSDictionary { /// dictionaryWithContentsOfFile: static NSDictionary? dictionaryWithContentsOfFile_(NSString path) { - final _ret = _objc_msgSend_160(_class_NSMutableDictionary, + final _ret = _objc_msgSend_159(_class_NSMutableDictionary, _sel_dictionaryWithContentsOfFile_, path.ref.pointer); return _ret.address == 0 ? null @@ -11531,7 +11682,7 @@ class NSMutableDictionary extends NSDictionary { /// dictionaryWithContentsOfURL: static NSDictionary? dictionaryWithContentsOfURL_(NSURL url) { - final _ret = _objc_msgSend_161(_class_NSMutableDictionary, + final _ret = _objc_msgSend_160(_class_NSMutableDictionary, _sel_dictionaryWithContentsOfURL_, url.ref.pointer); return _ret.address == 0 ? null @@ -11540,7 +11691,7 @@ class NSMutableDictionary extends NSDictionary { /// initWithContentsOfFile: NSMutableDictionary? initWithContentsOfFile_(NSString path) { - final _ret = _objc_msgSend_282(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_286(this.ref.retainAndReturnPointer(), _sel_initWithContentsOfFile_, path.ref.pointer); return _ret.address == 0 ? null @@ -11550,7 +11701,7 @@ class NSMutableDictionary extends NSDictionary { /// initWithContentsOfURL: NSMutableDictionary? initWithContentsOfURL_(NSURL url) { - final _ret = _objc_msgSend_283(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_287(this.ref.retainAndReturnPointer(), _sel_initWithContentsOfURL_, url.ref.pointer); return _ret.address == 0 ? null @@ -11561,7 +11712,7 @@ class NSMutableDictionary extends NSDictionary { /// dictionaryWithSharedKeySet: static NSMutableDictionary dictionaryWithSharedKeySet_( objc.ObjCObjectBase keyset) { - final _ret = _objc_msgSend_284(_class_NSMutableDictionary, + final _ret = _objc_msgSend_288(_class_NSMutableDictionary, _sel_dictionaryWithSharedKeySet_, keyset.ref.pointer); return NSMutableDictionary.castFromPointer(_ret, retain: true, release: true); @@ -11572,7 +11723,7 @@ class NSMutableDictionary extends NSDictionary { ffi.Pointer> objects, ffi.Pointer> keys, int cnt) { - final _ret = _objc_msgSend_156(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_155(this.ref.retainAndReturnPointer(), _sel_initWithObjects_forKeys_count_, objects, keys, cnt); return NSMutableDictionary.castFromPointer(_ret, retain: false, release: true); @@ -11588,7 +11739,7 @@ class NSMutableDictionary extends NSDictionary { /// dictionaryWithObject:forKey: static NSMutableDictionary dictionaryWithObject_forKey_( objc.ObjCObjectBase object, objc.ObjCObjectBase key) { - final _ret = _objc_msgSend_162(_class_NSMutableDictionary, + final _ret = _objc_msgSend_161(_class_NSMutableDictionary, _sel_dictionaryWithObject_forKey_, object.ref.pointer, key.ref.pointer); return NSMutableDictionary.castFromPointer(_ret, retain: true, release: true); @@ -11599,7 +11750,7 @@ class NSMutableDictionary extends NSDictionary { ffi.Pointer> objects, ffi.Pointer> keys, int cnt) { - final _ret = _objc_msgSend_156(_class_NSMutableDictionary, + final _ret = _objc_msgSend_155(_class_NSMutableDictionary, _sel_dictionaryWithObjects_forKeys_count_, objects, keys, cnt); return NSMutableDictionary.castFromPointer(_ret, retain: true, release: true); @@ -11616,7 +11767,7 @@ class NSMutableDictionary extends NSDictionary { /// dictionaryWithDictionary: static NSMutableDictionary dictionaryWithDictionary_(NSDictionary dict) { - final _ret = _objc_msgSend_163(_class_NSMutableDictionary, + final _ret = _objc_msgSend_162(_class_NSMutableDictionary, _sel_dictionaryWithDictionary_, dict.ref.pointer); return NSMutableDictionary.castFromPointer(_ret, retain: true, release: true); @@ -11625,7 +11776,7 @@ class NSMutableDictionary extends NSDictionary { /// dictionaryWithObjects:forKeys: static NSMutableDictionary dictionaryWithObjects_forKeys_( NSArray objects, NSArray keys) { - final _ret = _objc_msgSend_164( + final _ret = _objc_msgSend_163( _class_NSMutableDictionary, _sel_dictionaryWithObjects_forKeys_, objects.ref.pointer, @@ -11644,7 +11795,7 @@ class NSMutableDictionary extends NSDictionary { /// initWithDictionary: NSMutableDictionary initWithDictionary_(NSDictionary otherDictionary) { - final _ret = _objc_msgSend_163(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_162(this.ref.retainAndReturnPointer(), _sel_initWithDictionary_, otherDictionary.ref.pointer); return NSMutableDictionary.castFromPointer(_ret, retain: false, release: true); @@ -11653,7 +11804,7 @@ class NSMutableDictionary extends NSDictionary { /// initWithDictionary:copyItems: NSMutableDictionary initWithDictionary_copyItems_( NSDictionary otherDictionary, bool flag) { - final _ret = _objc_msgSend_165(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_164(this.ref.retainAndReturnPointer(), _sel_initWithDictionary_copyItems_, otherDictionary.ref.pointer, flag); return NSMutableDictionary.castFromPointer(_ret, retain: false, release: true); @@ -11661,7 +11812,7 @@ class NSMutableDictionary extends NSDictionary { /// initWithObjects:forKeys: NSMutableDictionary initWithObjects_forKeys_(NSArray objects, NSArray keys) { - final _ret = _objc_msgSend_164(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_163(this.ref.retainAndReturnPointer(), _sel_initWithObjects_forKeys_, objects.ref.pointer, keys.ref.pointer); return NSMutableDictionary.castFromPointer(_ret, retain: false, release: true); @@ -11670,7 +11821,7 @@ class NSMutableDictionary extends NSDictionary { /// dictionaryWithContentsOfURL:error: static NSDictionary? dictionaryWithContentsOfURL_error_( NSURL url, ffi.Pointer> error) { - final _ret = _objc_msgSend_166(_class_NSMutableDictionary, + final _ret = _objc_msgSend_165(_class_NSMutableDictionary, _sel_dictionaryWithContentsOfURL_error_, url.ref.pointer, error); return _ret.address == 0 ? null @@ -11723,7 +11874,7 @@ class NSMutableDictionary extends NSDictionary { late final _class_NSMutableDictionary = objc.getClass("NSMutableDictionary"); late final _sel_removeObjectForKey_ = objc.registerName("removeObjectForKey:"); late final _sel_setObject_forKey_ = objc.registerName("setObject:forKey:"); -final _objc_msgSend_279 = objc.msgSendPointer +final _objc_msgSend_283 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -11739,7 +11890,7 @@ final _objc_msgSend_279 = objc.msgSendPointer ffi.Pointer)>(); late final _sel_addEntriesFromDictionary_ = objc.registerName("addEntriesFromDictionary:"); -final _objc_msgSend_280 = objc.msgSendPointer +final _objc_msgSend_284 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -11754,7 +11905,7 @@ late final _sel_removeObjectsForKeys_ = late final _sel_setDictionary_ = objc.registerName("setDictionary:"); late final _sel_setObject_forKeyedSubscript_ = objc.registerName("setObject:forKeyedSubscript:"); -final _objc_msgSend_281 = objc.msgSendPointer +final _objc_msgSend_285 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -11770,7 +11921,7 @@ final _objc_msgSend_281 = objc.msgSendPointer ffi.Pointer)>(); late final _sel_dictionaryWithCapacity_ = objc.registerName("dictionaryWithCapacity:"); -final _objc_msgSend_282 = objc.msgSendPointer +final _objc_msgSend_286 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -11780,7 +11931,7 @@ final _objc_msgSend_282 = objc.msgSendPointer .asFunction< ffi.Pointer Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); -final _objc_msgSend_283 = objc.msgSendPointer +final _objc_msgSend_287 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -11792,7 +11943,7 @@ final _objc_msgSend_283 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_dictionaryWithSharedKeySet_ = objc.registerName("dictionaryWithSharedKeySet:"); -final _objc_msgSend_284 = objc.msgSendPointer +final _objc_msgSend_288 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -11803,86 +11954,732 @@ final _objc_msgSend_284 = objc.msgSendPointer ffi.Pointer Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); -/// NSOrderedSet -class NSOrderedSet extends NSObject { - NSOrderedSet._(ffi.Pointer pointer, +/// NSStream +class NSStream extends NSObject { + NSStream._(ffi.Pointer pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); - /// Constructs a [NSOrderedSet] that points to the same underlying object as [other]. - NSOrderedSet.castFrom(objc.ObjCObjectBase other) + /// Constructs a [NSStream] that points to the same underlying object as [other]. + NSStream.castFrom(objc.ObjCObjectBase other) : this._(other.ref.pointer, retain: true, release: true); - /// Constructs a [NSOrderedSet] that wraps the given raw object pointer. - NSOrderedSet.castFromPointer(ffi.Pointer other, + /// Constructs a [NSStream] that wraps the given raw object pointer. + NSStream.castFromPointer(ffi.Pointer other, {bool retain = false, bool release = false}) : this._(other, retain: retain, release: release); - /// Returns whether [obj] is an instance of [NSOrderedSet]. + /// Returns whether [obj] is an instance of [NSStream]. static bool isInstance(objc.ObjCObjectBase obj) { return _objc_msgSend_0( - obj.ref.pointer, _sel_isKindOfClass_, _class_NSOrderedSet); - } - - /// count - int get count { - return _objc_msgSend_11(this.ref.pointer, _sel_count); + obj.ref.pointer, _sel_isKindOfClass_, _class_NSStream); } - /// objectAtIndex: - objc.ObjCObjectBase objectAtIndex_(int idx) { - final _ret = _objc_msgSend_99(this.ref.pointer, _sel_objectAtIndex_, idx); - return objc.ObjCObjectBase(_ret, retain: true, release: true); + /// open + void open() { + _objc_msgSend_1(this.ref.pointer, _sel_open); } - /// indexOfObject: - int indexOfObject_(objc.ObjCObjectBase object) { - return _objc_msgSend_107( - this.ref.pointer, _sel_indexOfObject_, object.ref.pointer); + /// close + void close() { + _objc_msgSend_1(this.ref.pointer, _sel_close); } - /// init - NSOrderedSet init() { - final _ret = _objc_msgSend_2(this.ref.retainAndReturnPointer(), _sel_init); - return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); + /// delegate + objc.ObjCObjectBase? get delegate { + final _ret = _objc_msgSend_16(this.ref.pointer, _sel_delegate); + return _ret.address == 0 + ? null + : objc.ObjCObjectBase(_ret, retain: true, release: true); } - /// initWithObjects:count: - NSOrderedSet initWithObjects_count_( - ffi.Pointer> objects, int cnt) { - final _ret = _objc_msgSend_100(this.ref.retainAndReturnPointer(), - _sel_initWithObjects_count_, objects, cnt); - return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); + /// setDelegate: + set delegate(objc.ObjCObjectBase? value) { + return _objc_msgSend_289( + this.ref.pointer, _sel_setDelegate_, value?.ref.pointer ?? ffi.nullptr); } - /// initWithCoder: - NSOrderedSet? initWithCoder_(NSCoder coder) { - final _ret = _objc_msgSend_18(this.ref.retainAndReturnPointer(), - _sel_initWithCoder_, coder.ref.pointer); + /// propertyForKey: + objc.ObjCObjectBase? propertyForKey_(NSString key) { + final _ret = _objc_msgSend_52( + this.ref.pointer, _sel_propertyForKey_, key.ref.pointer); return _ret.address == 0 ? null - : NSOrderedSet.castFromPointer(_ret, retain: false, release: true); + : objc.ObjCObjectBase(_ret, retain: true, release: true); } - /// getObjects:range: - void getObjects_range_( - ffi.Pointer> objects, NSRange range) { - _objc_msgSend_106(this.ref.pointer, _sel_getObjects_range_, objects, range); + /// setProperty:forKey: + bool setProperty_forKey_(objc.ObjCObjectBase? property, NSString key) { + return _objc_msgSend_290(this.ref.pointer, _sel_setProperty_forKey_, + property?.ref.pointer ?? ffi.nullptr, key.ref.pointer); } - /// objectsAtIndexes: - NSArray objectsAtIndexes_(NSIndexSet indexes) { - final _ret = _objc_msgSend_125( - this.ref.pointer, _sel_objectsAtIndexes_, indexes.ref.pointer); - return NSArray.castFromPointer(_ret, retain: true, release: true); + /// scheduleInRunLoop:forMode: + void scheduleInRunLoop_forMode_(NSRunLoop aRunLoop, NSString mode) { + _objc_msgSend_291(this.ref.pointer, _sel_scheduleInRunLoop_forMode_, + aRunLoop.ref.pointer, mode.ref.pointer); } - /// firstObject - objc.ObjCObjectBase? get firstObject { - final _ret = _objc_msgSend_16(this.ref.pointer, _sel_firstObject); + /// removeFromRunLoop:forMode: + void removeFromRunLoop_forMode_(NSRunLoop aRunLoop, NSString mode) { + _objc_msgSend_291(this.ref.pointer, _sel_removeFromRunLoop_forMode_, + aRunLoop.ref.pointer, mode.ref.pointer); + } + + /// streamStatus + NSStreamStatus get streamStatus { + final _ret = _objc_msgSend_292(this.ref.pointer, _sel_streamStatus); + return NSStreamStatus.fromValue(_ret); + } + + /// streamError + NSError? get streamError { + final _ret = _objc_msgSend_293(this.ref.pointer, _sel_streamError); return _ret.address == 0 ? null - : objc.ObjCObjectBase(_ret, retain: true, release: true); + : NSError.castFromPointer(_ret, retain: true, release: true); + } + + /// getStreamsToHostWithName:port:inputStream:outputStream: + static void getStreamsToHostWithName_port_inputStream_outputStream_( + NSString hostname, + int port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_299( + _class_NSStream, + _sel_getStreamsToHostWithName_port_inputStream_outputStream_, + hostname.ref.pointer, + port, + inputStream, + outputStream); + } + + /// getBoundStreamsWithBufferSize:inputStream:outputStream: + static void getBoundStreamsWithBufferSize_inputStream_outputStream_( + int bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_300( + _class_NSStream, + _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_, + bufferSize, + inputStream, + outputStream); + } + + /// init + NSStream init() { + final _ret = _objc_msgSend_2(this.ref.retainAndReturnPointer(), _sel_init); + return NSStream.castFromPointer(_ret, retain: false, release: true); + } + + /// new + static NSStream new1() { + final _ret = _objc_msgSend_2(_class_NSStream, _sel_new); + return NSStream.castFromPointer(_ret, retain: false, release: true); + } + + /// allocWithZone: + static NSStream allocWithZone_(ffi.Pointer<_NSZone> zone) { + final _ret = _objc_msgSend_3(_class_NSStream, _sel_allocWithZone_, zone); + return NSStream.castFromPointer(_ret, retain: false, release: true); + } + + /// alloc + static NSStream alloc() { + final _ret = _objc_msgSend_2(_class_NSStream, _sel_alloc); + return NSStream.castFromPointer(_ret, retain: false, release: true); + } + + /// keyPathsForValuesAffectingValueForKey: + static NSSet keyPathsForValuesAffectingValueForKey_(NSString key) { + final _ret = _objc_msgSend_95(_class_NSStream, + _sel_keyPathsForValuesAffectingValueForKey_, key.ref.pointer); + return NSSet.castFromPointer(_ret, retain: true, release: true); + } + + /// automaticallyNotifiesObserversForKey: + static bool automaticallyNotifiesObserversForKey_(NSString key) { + return _objc_msgSend_26(_class_NSStream, + _sel_automaticallyNotifiesObserversForKey_, key.ref.pointer); + } +} + +late final _class_NSStream = objc.getClass("NSStream"); +late final _sel_open = objc.registerName("open"); +late final _sel_close = objc.registerName("close"); +late final _sel_delegate = objc.registerName("delegate"); +late final _sel_setDelegate_ = objc.registerName("setDelegate:"); +final _objc_msgSend_289 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer value)>>() + .asFunction< + void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); +late final _sel_propertyForKey_ = objc.registerName("propertyForKey:"); +late final _sel_setProperty_forKey_ = objc.registerName("setProperty:forKey:"); +final _objc_msgSend_290 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer property, + ffi.Pointer key)>>() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + +/// NSRunLoop +class NSRunLoop extends objc.ObjCObjectBase { + NSRunLoop._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super(pointer, retain: retain, release: release); + + /// Constructs a [NSRunLoop] that points to the same underlying object as [other]. + NSRunLoop.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSRunLoop] that wraps the given raw object pointer. + NSRunLoop.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [NSRunLoop]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_0( + obj.ref.pointer, _sel_isKindOfClass_, _class_NSRunLoop); + } +} + +late final _class_NSRunLoop = objc.getClass("NSRunLoop"); +late final _sel_scheduleInRunLoop_forMode_ = + objc.registerName("scheduleInRunLoop:forMode:"); +final _objc_msgSend_291 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer aRunLoop, + ffi.Pointer mode)>>() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); +late final _sel_removeFromRunLoop_forMode_ = + objc.registerName("removeFromRunLoop:forMode:"); + +enum NSStreamStatus { + NSStreamStatusNotOpen(0), + NSStreamStatusOpening(1), + NSStreamStatusOpen(2), + NSStreamStatusReading(3), + NSStreamStatusWriting(4), + NSStreamStatusAtEnd(5), + NSStreamStatusClosed(6), + NSStreamStatusError(7); + + final int value; + const NSStreamStatus(this.value); + + static NSStreamStatus fromValue(int value) => switch (value) { + 0 => NSStreamStatusNotOpen, + 1 => NSStreamStatusOpening, + 2 => NSStreamStatusOpen, + 3 => NSStreamStatusReading, + 4 => NSStreamStatusWriting, + 5 => NSStreamStatusAtEnd, + 6 => NSStreamStatusClosed, + 7 => NSStreamStatusError, + _ => throw ArgumentError("Unknown value for NSStreamStatus: $value"), + }; +} + +late final _sel_streamStatus = objc.registerName("streamStatus"); +final _objc_msgSend_292 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function(ffi.Pointer, + ffi.Pointer)>>() + .asFunction< + int Function( + ffi.Pointer, ffi.Pointer)>(); +late final _sel_streamError = objc.registerName("streamError"); +final _objc_msgSend_293 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>>() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); + +/// NSInputStream +class NSInputStream extends NSStream { + NSInputStream._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [NSInputStream] that points to the same underlying object as [other]. + NSInputStream.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSInputStream] that wraps the given raw object pointer. + NSInputStream.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [NSInputStream]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_0( + obj.ref.pointer, _sel_isKindOfClass_, _class_NSInputStream); + } + + /// read:maxLength: + int read_maxLength_(ffi.Pointer buffer, int len) { + return _objc_msgSend_294( + this.ref.pointer, _sel_read_maxLength_, buffer, len); + } + + /// getBuffer:length: + bool getBuffer_length_(ffi.Pointer> buffer, + ffi.Pointer len) { + return _objc_msgSend_295( + this.ref.pointer, _sel_getBuffer_length_, buffer, len); + } + + /// hasBytesAvailable + bool get hasBytesAvailable { + return _objc_msgSend_13(this.ref.pointer, _sel_hasBytesAvailable); + } + + /// initWithData: + NSInputStream initWithData_(NSData data) { + final _ret = _objc_msgSend_180(this.ref.retainAndReturnPointer(), + _sel_initWithData_, data.ref.pointer); + return NSInputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithURL: + NSInputStream? initWithURL_(NSURL url) { + final _ret = _objc_msgSend_179( + this.ref.retainAndReturnPointer(), _sel_initWithURL_, url.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithFileAtPath: + NSInputStream? initWithFileAtPath_(NSString path) { + final _ret = _objc_msgSend_52(this.ref.retainAndReturnPointer(), + _sel_initWithFileAtPath_, path.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// inputStreamWithData: + static NSInputStream? inputStreamWithData_(NSData data) { + final _ret = _objc_msgSend_296( + _class_NSInputStream, _sel_inputStreamWithData_, data.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// inputStreamWithFileAtPath: + static NSInputStream? inputStreamWithFileAtPath_(NSString path) { + final _ret = _objc_msgSend_52(_class_NSInputStream, + _sel_inputStreamWithFileAtPath_, path.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// inputStreamWithURL: + static NSInputStream? inputStreamWithURL_(NSURL url) { + final _ret = _objc_msgSend_179( + _class_NSInputStream, _sel_inputStreamWithURL_, url.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// getStreamsToHostWithName:port:inputStream:outputStream: + static void getStreamsToHostWithName_port_inputStream_outputStream_( + NSString hostname, + int port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_299( + _class_NSInputStream, + _sel_getStreamsToHostWithName_port_inputStream_outputStream_, + hostname.ref.pointer, + port, + inputStream, + outputStream); + } + + /// getBoundStreamsWithBufferSize:inputStream:outputStream: + static void getBoundStreamsWithBufferSize_inputStream_outputStream_( + int bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_300( + _class_NSInputStream, + _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_, + bufferSize, + inputStream, + outputStream); + } +} + +late final _class_NSInputStream = objc.getClass("NSInputStream"); +late final _sel_read_maxLength_ = objc.registerName("read:maxLength:"); +final _objc_msgSend_294 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer buffer, + ffi.UnsignedLong len)>>() + .asFunction< + int Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); +late final _sel_getBuffer_length_ = objc.registerName("getBuffer:length:"); +final _objc_msgSend_295 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer> buffer, + ffi.Pointer len)>>() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>(); +late final _sel_hasBytesAvailable = objc.registerName("hasBytesAvailable"); +late final _sel_initWithURL_ = objc.registerName("initWithURL:"); +late final _sel_initWithFileAtPath_ = objc.registerName("initWithFileAtPath:"); +late final _sel_inputStreamWithData_ = + objc.registerName("inputStreamWithData:"); +final _objc_msgSend_296 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer data)>>() + .asFunction< + instancetype Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); +late final _sel_inputStreamWithFileAtPath_ = + objc.registerName("inputStreamWithFileAtPath:"); +late final _sel_inputStreamWithURL_ = objc.registerName("inputStreamWithURL:"); + +/// NSOutputStream +class NSOutputStream extends NSStream { + NSOutputStream._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [NSOutputStream] that points to the same underlying object as [other]. + NSOutputStream.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSOutputStream] that wraps the given raw object pointer. + NSOutputStream.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [NSOutputStream]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_0( + obj.ref.pointer, _sel_isKindOfClass_, _class_NSOutputStream); + } + + /// write:maxLength: + int write_maxLength_(ffi.Pointer buffer, int len) { + return _objc_msgSend_294( + this.ref.pointer, _sel_write_maxLength_, buffer, len); + } + + /// hasSpaceAvailable + bool get hasSpaceAvailable { + return _objc_msgSend_13(this.ref.pointer, _sel_hasSpaceAvailable); + } + + /// initToMemory + NSOutputStream initToMemory() { + final _ret = + _objc_msgSend_2(this.ref.retainAndReturnPointer(), _sel_initToMemory); + return NSOutputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initToBuffer:capacity: + NSOutputStream initToBuffer_capacity_( + ffi.Pointer buffer, int capacity) { + final _ret = _objc_msgSend_297(this.ref.retainAndReturnPointer(), + _sel_initToBuffer_capacity_, buffer, capacity); + return NSOutputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithURL:append: + NSOutputStream? initWithURL_append_(NSURL url, bool shouldAppend) { + final _ret = _objc_msgSend_298(this.ref.retainAndReturnPointer(), + _sel_initWithURL_append_, url.ref.pointer, shouldAppend); + return _ret.address == 0 + ? null + : NSOutputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initToFileAtPath:append: + NSOutputStream? initToFileAtPath_append_(NSString path, bool shouldAppend) { + final _ret = _objc_msgSend_54(this.ref.retainAndReturnPointer(), + _sel_initToFileAtPath_append_, path.ref.pointer, shouldAppend); + return _ret.address == 0 + ? null + : NSOutputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// outputStreamToMemory + static NSOutputStream outputStreamToMemory() { + final _ret = + _objc_msgSend_2(_class_NSOutputStream, _sel_outputStreamToMemory); + return NSOutputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// outputStreamToBuffer:capacity: + static NSOutputStream outputStreamToBuffer_capacity_( + ffi.Pointer buffer, int capacity) { + final _ret = _objc_msgSend_297(_class_NSOutputStream, + _sel_outputStreamToBuffer_capacity_, buffer, capacity); + return NSOutputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// outputStreamToFileAtPath:append: + static NSOutputStream outputStreamToFileAtPath_append_( + NSString path, bool shouldAppend) { + final _ret = _objc_msgSend_44(_class_NSOutputStream, + _sel_outputStreamToFileAtPath_append_, path.ref.pointer, shouldAppend); + return NSOutputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// outputStreamWithURL:append: + static NSOutputStream? outputStreamWithURL_append_( + NSURL url, bool shouldAppend) { + final _ret = _objc_msgSend_298(_class_NSOutputStream, + _sel_outputStreamWithURL_append_, url.ref.pointer, shouldAppend); + return _ret.address == 0 + ? null + : NSOutputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// getStreamsToHostWithName:port:inputStream:outputStream: + static void getStreamsToHostWithName_port_inputStream_outputStream_( + NSString hostname, + int port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_299( + _class_NSOutputStream, + _sel_getStreamsToHostWithName_port_inputStream_outputStream_, + hostname.ref.pointer, + port, + inputStream, + outputStream); + } + + /// getBoundStreamsWithBufferSize:inputStream:outputStream: + static void getBoundStreamsWithBufferSize_inputStream_outputStream_( + int bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_300( + _class_NSOutputStream, + _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_, + bufferSize, + inputStream, + outputStream); + } +} + +late final _class_NSOutputStream = objc.getClass("NSOutputStream"); +late final _sel_write_maxLength_ = objc.registerName("write:maxLength:"); +late final _sel_hasSpaceAvailable = objc.registerName("hasSpaceAvailable"); +late final _sel_initToMemory = objc.registerName("initToMemory"); +late final _sel_initToBuffer_capacity_ = + objc.registerName("initToBuffer:capacity:"); +final _objc_msgSend_297 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer buffer, + ffi.UnsignedLong capacity)>>() + .asFunction< + instancetype Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); +late final _sel_initWithURL_append_ = objc.registerName("initWithURL:append:"); +final _objc_msgSend_298 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer url, + ffi.Bool shouldAppend)>>() + .asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + bool)>(); +late final _sel_initToFileAtPath_append_ = + objc.registerName("initToFileAtPath:append:"); +late final _sel_outputStreamToMemory = + objc.registerName("outputStreamToMemory"); +late final _sel_outputStreamToBuffer_capacity_ = + objc.registerName("outputStreamToBuffer:capacity:"); +late final _sel_outputStreamToFileAtPath_append_ = + objc.registerName("outputStreamToFileAtPath:append:"); +late final _sel_outputStreamWithURL_append_ = + objc.registerName("outputStreamWithURL:append:"); +late final _sel_getStreamsToHostWithName_port_inputStream_outputStream_ = objc + .registerName("getStreamsToHostWithName:port:inputStream:outputStream:"); +final _objc_msgSend_299 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer hostname, + ffi.Long port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream)>>() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>)>(); +late final _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_ = objc + .registerName("getBoundStreamsWithBufferSize:inputStream:outputStream:"); +final _objc_msgSend_300 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream)>>() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>)>(); + +/// NSOrderedSet +class NSOrderedSet extends NSObject { + NSOrderedSet._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [NSOrderedSet] that points to the same underlying object as [other]. + NSOrderedSet.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSOrderedSet] that wraps the given raw object pointer. + NSOrderedSet.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [NSOrderedSet]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_0( + obj.ref.pointer, _sel_isKindOfClass_, _class_NSOrderedSet); + } + + /// count + int get count { + return _objc_msgSend_11(this.ref.pointer, _sel_count); + } + + /// objectAtIndex: + objc.ObjCObjectBase objectAtIndex_(int idx) { + final _ret = _objc_msgSend_99(this.ref.pointer, _sel_objectAtIndex_, idx); + return objc.ObjCObjectBase(_ret, retain: true, release: true); + } + + /// indexOfObject: + int indexOfObject_(objc.ObjCObjectBase object) { + return _objc_msgSend_107( + this.ref.pointer, _sel_indexOfObject_, object.ref.pointer); + } + + /// init + NSOrderedSet init() { + final _ret = _objc_msgSend_2(this.ref.retainAndReturnPointer(), _sel_init); + return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithObjects:count: + NSOrderedSet initWithObjects_count_( + ffi.Pointer> objects, int cnt) { + final _ret = _objc_msgSend_100(this.ref.retainAndReturnPointer(), + _sel_initWithObjects_count_, objects, cnt); + return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithCoder: + NSOrderedSet? initWithCoder_(NSCoder coder) { + final _ret = _objc_msgSend_18(this.ref.retainAndReturnPointer(), + _sel_initWithCoder_, coder.ref.pointer); + return _ret.address == 0 + ? null + : NSOrderedSet.castFromPointer(_ret, retain: false, release: true); + } + + /// getObjects:range: + void getObjects_range_( + ffi.Pointer> objects, NSRange range) { + _objc_msgSend_106(this.ref.pointer, _sel_getObjects_range_, objects, range); + } + + /// objectsAtIndexes: + NSArray objectsAtIndexes_(NSIndexSet indexes) { + final _ret = _objc_msgSend_125( + this.ref.pointer, _sel_objectsAtIndexes_, indexes.ref.pointer); + return NSArray.castFromPointer(_ret, retain: true, release: true); + } + + /// firstObject + objc.ObjCObjectBase? get firstObject { + final _ret = _objc_msgSend_16(this.ref.pointer, _sel_firstObject); + return _ret.address == 0 + ? null + : objc.ObjCObjectBase(_ret, retain: true, release: true); } /// lastObject @@ -11895,7 +12692,7 @@ class NSOrderedSet extends NSObject { /// isEqualToOrderedSet: bool isEqualToOrderedSet_(NSOrderedSet other) { - return _objc_msgSend_285( + return _objc_msgSend_301( this.ref.pointer, _sel_isEqualToOrderedSet_, other.ref.pointer); } @@ -11907,7 +12704,7 @@ class NSOrderedSet extends NSObject { /// intersectsOrderedSet: bool intersectsOrderedSet_(NSOrderedSet other) { - return _objc_msgSend_285( + return _objc_msgSend_301( this.ref.pointer, _sel_intersectsOrderedSet_, other.ref.pointer); } @@ -11919,7 +12716,7 @@ class NSOrderedSet extends NSObject { /// isSubsetOfOrderedSet: bool isSubsetOfOrderedSet_(NSOrderedSet other) { - return _objc_msgSend_285( + return _objc_msgSend_301( this.ref.pointer, _sel_isSubsetOfOrderedSet_, other.ref.pointer); } @@ -11951,7 +12748,7 @@ class NSOrderedSet extends NSObject { /// reversedOrderedSet NSOrderedSet get reversedOrderedSet { - final _ret = _objc_msgSend_286(this.ref.pointer, _sel_reversedOrderedSet); + final _ret = _objc_msgSend_302(this.ref.pointer, _sel_reversedOrderedSet); return NSOrderedSet.castFromPointer(_ret, retain: true, release: true); } @@ -12021,7 +12818,7 @@ class NSOrderedSet extends NSObject { /// orderedSetWithOrderedSet: static NSOrderedSet orderedSetWithOrderedSet_(NSOrderedSet set) { - final _ret = _objc_msgSend_287( + final _ret = _objc_msgSend_303( _class_NSOrderedSet, _sel_orderedSetWithOrderedSet_, set.ref.pointer); return NSOrderedSet.castFromPointer(_ret, retain: true, release: true); } @@ -12029,7 +12826,7 @@ class NSOrderedSet extends NSObject { /// orderedSetWithOrderedSet:range:copyItems: static NSOrderedSet orderedSetWithOrderedSet_range_copyItems_( NSOrderedSet set, NSRange range, bool flag) { - final _ret = _objc_msgSend_288( + final _ret = _objc_msgSend_304( _class_NSOrderedSet, _sel_orderedSetWithOrderedSet_range_copyItems_, set.ref.pointer, @@ -12048,7 +12845,7 @@ class NSOrderedSet extends NSObject { /// orderedSetWithArray:range:copyItems: static NSOrderedSet orderedSetWithArray_range_copyItems_( NSArray array, NSRange range, bool flag) { - final _ret = _objc_msgSend_289( + final _ret = _objc_msgSend_305( _class_NSOrderedSet, _sel_orderedSetWithArray_range_copyItems_, array.ref.pointer, @@ -12067,7 +12864,7 @@ class NSOrderedSet extends NSObject { /// orderedSetWithSet:copyItems: static NSOrderedSet orderedSetWithSet_copyItems_( objc.ObjCObjectBase set, bool flag) { - final _ret = _objc_msgSend_290(_class_NSOrderedSet, + final _ret = _objc_msgSend_306(_class_NSOrderedSet, _sel_orderedSetWithSet_copyItems_, set.ref.pointer, flag); return NSOrderedSet.castFromPointer(_ret, retain: true, release: true); } @@ -12088,14 +12885,14 @@ class NSOrderedSet extends NSObject { /// initWithOrderedSet: NSOrderedSet initWithOrderedSet_(NSOrderedSet set) { - final _ret = _objc_msgSend_287(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_303(this.ref.retainAndReturnPointer(), _sel_initWithOrderedSet_, set.ref.pointer); return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); } /// initWithOrderedSet:copyItems: NSOrderedSet initWithOrderedSet_copyItems_(NSOrderedSet set, bool flag) { - final _ret = _objc_msgSend_291(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_307(this.ref.retainAndReturnPointer(), _sel_initWithOrderedSet_copyItems_, set.ref.pointer, flag); return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); } @@ -12103,7 +12900,7 @@ class NSOrderedSet extends NSObject { /// initWithOrderedSet:range:copyItems: NSOrderedSet initWithOrderedSet_range_copyItems_( NSOrderedSet set, NSRange range, bool flag) { - final _ret = _objc_msgSend_288(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_304(this.ref.retainAndReturnPointer(), _sel_initWithOrderedSet_range_copyItems_, set.ref.pointer, range, flag); return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); } @@ -12125,7 +12922,7 @@ class NSOrderedSet extends NSObject { /// initWithArray:range:copyItems: NSOrderedSet initWithArray_range_copyItems_( NSArray set, NSRange range, bool flag) { - final _ret = _objc_msgSend_289(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_305(this.ref.retainAndReturnPointer(), _sel_initWithArray_range_copyItems_, set.ref.pointer, range, flag); return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); } @@ -12139,7 +12936,7 @@ class NSOrderedSet extends NSObject { /// initWithSet:copyItems: NSOrderedSet initWithSet_copyItems_(objc.ObjCObjectBase set, bool flag) { - final _ret = _objc_msgSend_290(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_306(this.ref.retainAndReturnPointer(), _sel_initWithSet_copyItems_, set.ref.pointer, flag); return NSOrderedSet.castFromPointer(_ret, retain: false, release: true); } @@ -12147,7 +12944,7 @@ class NSOrderedSet extends NSObject { /// differenceFromOrderedSet:withOptions: objc.ObjCObjectBase differenceFromOrderedSet_withOptions_(NSOrderedSet other, NSOrderedCollectionDifferenceCalculationOptions options) { - final _ret = _objc_msgSend_292( + final _ret = _objc_msgSend_308( this.ref.pointer, _sel_differenceFromOrderedSet_withOptions_, other.ref.pointer, @@ -12157,7 +12954,7 @@ class NSOrderedSet extends NSObject { /// differenceFromOrderedSet: objc.ObjCObjectBase differenceFromOrderedSet_(NSOrderedSet other) { - final _ret = _objc_msgSend_287( + final _ret = _objc_msgSend_303( this.ref.pointer, _sel_differenceFromOrderedSet_, other.ref.pointer); return objc.ObjCObjectBase(_ret, retain: true, release: true); } @@ -12165,7 +12962,7 @@ class NSOrderedSet extends NSObject { /// orderedSetByApplyingDifference: NSOrderedSet? orderedSetByApplyingDifference_( objc.ObjCObjectBase difference) { - final _ret = _objc_msgSend_293(this.ref.pointer, + final _ret = _objc_msgSend_309(this.ref.pointer, _sel_orderedSetByApplyingDifference_, difference.ref.pointer); return _ret.address == 0 ? null @@ -12236,7 +13033,7 @@ class NSOrderedSet extends NSObject { late final _class_NSOrderedSet = objc.getClass("NSOrderedSet"); late final _sel_isEqualToOrderedSet_ = objc.registerName("isEqualToOrderedSet:"); -final _objc_msgSend_285 = objc.msgSendPointer +final _objc_msgSend_301 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -12251,7 +13048,7 @@ late final _sel_intersectsOrderedSet_ = late final _sel_isSubsetOfOrderedSet_ = objc.registerName("isSubsetOfOrderedSet:"); late final _sel_reversedOrderedSet = objc.registerName("reversedOrderedSet"); -final _objc_msgSend_286 = objc.msgSendPointer +final _objc_msgSend_302 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function(ffi.Pointer, @@ -12268,7 +13065,7 @@ late final _sel_orderedSetWithObjects_ = objc.registerName("orderedSetWithObjects:"); late final _sel_orderedSetWithOrderedSet_ = objc.registerName("orderedSetWithOrderedSet:"); -final _objc_msgSend_287 = objc.msgSendPointer +final _objc_msgSend_303 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -12280,7 +13077,7 @@ final _objc_msgSend_287 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_orderedSetWithOrderedSet_range_copyItems_ = objc.registerName("orderedSetWithOrderedSet:range:copyItems:"); -final _objc_msgSend_288 = objc.msgSendPointer +final _objc_msgSend_304 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -12300,7 +13097,7 @@ late final _sel_orderedSetWithArray_ = objc.registerName("orderedSetWithArray:"); late final _sel_orderedSetWithArray_range_copyItems_ = objc.registerName("orderedSetWithArray:range:copyItems:"); -final _objc_msgSend_289 = objc.msgSendPointer +final _objc_msgSend_305 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -12319,7 +13116,7 @@ final _objc_msgSend_289 = objc.msgSendPointer late final _sel_orderedSetWithSet_ = objc.registerName("orderedSetWithSet:"); late final _sel_orderedSetWithSet_copyItems_ = objc.registerName("orderedSetWithSet:copyItems:"); -final _objc_msgSend_290 = objc.msgSendPointer +final _objc_msgSend_306 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -12337,7 +13134,7 @@ late final _sel_initWithObject_ = objc.registerName("initWithObject:"); late final _sel_initWithOrderedSet_ = objc.registerName("initWithOrderedSet:"); late final _sel_initWithOrderedSet_copyItems_ = objc.registerName("initWithOrderedSet:copyItems:"); -final _objc_msgSend_291 = objc.msgSendPointer +final _objc_msgSend_307 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -12357,7 +13154,7 @@ late final _sel_initWithArray_range_copyItems_ = objc.registerName("initWithArray:range:copyItems:"); late final _sel_differenceFromOrderedSet_withOptions_ = objc.registerName("differenceFromOrderedSet:withOptions:"); -final _objc_msgSend_292 = objc.msgSendPointer +final _objc_msgSend_308 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -12375,7 +13172,7 @@ late final _sel_differenceFromOrderedSet_ = objc.registerName("differenceFromOrderedSet:"); late final _sel_orderedSetByApplyingDifference_ = objc.registerName("orderedSetByApplyingDifference:"); -final _objc_msgSend_293 = objc.msgSendPointer +final _objc_msgSend_309 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -12409,18 +13206,18 @@ class NSMutableOrderedSet extends NSOrderedSet { /// insertObject:atIndex: void insertObject_atIndex_(objc.ObjCObjectBase object, int idx) { - _objc_msgSend_253( + _objc_msgSend_257( this.ref.pointer, _sel_insertObject_atIndex_, object.ref.pointer, idx); } /// removeObjectAtIndex: void removeObjectAtIndex_(int idx) { - _objc_msgSend_249(this.ref.pointer, _sel_removeObjectAtIndex_, idx); + _objc_msgSend_253(this.ref.pointer, _sel_removeObjectAtIndex_, idx); } /// replaceObjectAtIndex:withObject: void replaceObjectAtIndex_withObject_(int idx, objc.ObjCObjectBase object) { - _objc_msgSend_254(this.ref.pointer, _sel_replaceObjectAtIndex_withObject_, + _objc_msgSend_258(this.ref.pointer, _sel_replaceObjectAtIndex_withObject_, idx, object.ref.pointer); } @@ -12451,62 +13248,62 @@ class NSMutableOrderedSet extends NSOrderedSet { /// addObject: void addObject_(objc.ObjCObjectBase object) { - _objc_msgSend_252(this.ref.pointer, _sel_addObject_, object.ref.pointer); + _objc_msgSend_256(this.ref.pointer, _sel_addObject_, object.ref.pointer); } /// addObjects:count: void addObjects_count_( ffi.Pointer> objects, int count) { - _objc_msgSend_294(this.ref.pointer, _sel_addObjects_count_, objects, count); + _objc_msgSend_310(this.ref.pointer, _sel_addObjects_count_, objects, count); } /// addObjectsFromArray: void addObjectsFromArray_(NSArray array) { - _objc_msgSend_255( + _objc_msgSend_259( this.ref.pointer, _sel_addObjectsFromArray_, array.ref.pointer); } /// exchangeObjectAtIndex:withObjectAtIndex: void exchangeObjectAtIndex_withObjectAtIndex_(int idx1, int idx2) { - _objc_msgSend_256(this.ref.pointer, + _objc_msgSend_260(this.ref.pointer, _sel_exchangeObjectAtIndex_withObjectAtIndex_, idx1, idx2); } /// moveObjectsAtIndexes:toIndex: void moveObjectsAtIndexes_toIndex_(NSIndexSet indexes, int idx) { - _objc_msgSend_295(this.ref.pointer, _sel_moveObjectsAtIndexes_toIndex_, + _objc_msgSend_311(this.ref.pointer, _sel_moveObjectsAtIndexes_toIndex_, indexes.ref.pointer, idx); } /// insertObjects:atIndexes: void insertObjects_atIndexes_(NSArray objects, NSIndexSet indexes) { - _objc_msgSend_261(this.ref.pointer, _sel_insertObjects_atIndexes_, + _objc_msgSend_265(this.ref.pointer, _sel_insertObjects_atIndexes_, objects.ref.pointer, indexes.ref.pointer); } /// setObject:atIndex: void setObject_atIndex_(objc.ObjCObjectBase obj, int idx) { - _objc_msgSend_253( + _objc_msgSend_257( this.ref.pointer, _sel_setObject_atIndex_, obj.ref.pointer, idx); } /// setObject:atIndexedSubscript: void setObject_atIndexedSubscript_(objc.ObjCObjectBase obj, int idx) { - _objc_msgSend_253(this.ref.pointer, _sel_setObject_atIndexedSubscript_, + _objc_msgSend_257(this.ref.pointer, _sel_setObject_atIndexedSubscript_, obj.ref.pointer, idx); } /// replaceObjectsInRange:withObjects:count: void replaceObjectsInRange_withObjects_count_(NSRange range, ffi.Pointer> objects, int count) { - _objc_msgSend_296(this.ref.pointer, + _objc_msgSend_312(this.ref.pointer, _sel_replaceObjectsInRange_withObjects_count_, range, objects, count); } /// replaceObjectsAtIndexes:withObjects: void replaceObjectsAtIndexes_withObjects_( NSIndexSet indexes, NSArray objects) { - _objc_msgSend_262( + _objc_msgSend_266( this.ref.pointer, _sel_replaceObjectsAtIndexes_withObjects_, indexes.ref.pointer, @@ -12515,12 +13312,12 @@ class NSMutableOrderedSet extends NSOrderedSet { /// removeObjectsInRange: void removeObjectsInRange_(NSRange range) { - _objc_msgSend_250(this.ref.pointer, _sel_removeObjectsInRange_, range); + _objc_msgSend_254(this.ref.pointer, _sel_removeObjectsInRange_, range); } /// removeObjectsAtIndexes: void removeObjectsAtIndexes_(NSIndexSet indexes) { - _objc_msgSend_248( + _objc_msgSend_252( this.ref.pointer, _sel_removeObjectsAtIndexes_, indexes.ref.pointer); } @@ -12531,46 +13328,46 @@ class NSMutableOrderedSet extends NSOrderedSet { /// removeObject: void removeObject_(objc.ObjCObjectBase object) { - _objc_msgSend_252(this.ref.pointer, _sel_removeObject_, object.ref.pointer); + _objc_msgSend_256(this.ref.pointer, _sel_removeObject_, object.ref.pointer); } /// removeObjectsInArray: void removeObjectsInArray_(NSArray array) { - _objc_msgSend_255( + _objc_msgSend_259( this.ref.pointer, _sel_removeObjectsInArray_, array.ref.pointer); } /// intersectOrderedSet: void intersectOrderedSet_(NSOrderedSet other) { - _objc_msgSend_297( + _objc_msgSend_313( this.ref.pointer, _sel_intersectOrderedSet_, other.ref.pointer); } /// minusOrderedSet: void minusOrderedSet_(NSOrderedSet other) { - _objc_msgSend_297( + _objc_msgSend_313( this.ref.pointer, _sel_minusOrderedSet_, other.ref.pointer); } /// unionOrderedSet: void unionOrderedSet_(NSOrderedSet other) { - _objc_msgSend_297( + _objc_msgSend_313( this.ref.pointer, _sel_unionOrderedSet_, other.ref.pointer); } /// intersectSet: void intersectSet_(objc.ObjCObjectBase other) { - _objc_msgSend_252(this.ref.pointer, _sel_intersectSet_, other.ref.pointer); + _objc_msgSend_256(this.ref.pointer, _sel_intersectSet_, other.ref.pointer); } /// minusSet: void minusSet_(objc.ObjCObjectBase other) { - _objc_msgSend_252(this.ref.pointer, _sel_minusSet_, other.ref.pointer); + _objc_msgSend_256(this.ref.pointer, _sel_minusSet_, other.ref.pointer); } /// unionSet: void unionSet_(objc.ObjCObjectBase other) { - _objc_msgSend_252(this.ref.pointer, _sel_unionSet_, other.ref.pointer); + _objc_msgSend_256(this.ref.pointer, _sel_unionSet_, other.ref.pointer); } /// orderedSetWithCapacity: @@ -12583,7 +13380,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// applyDifference: void applyDifference_(objc.ObjCObjectBase difference) { - _objc_msgSend_252( + _objc_msgSend_256( this.ref.pointer, _sel_applyDifference_, difference.ref.pointer); } @@ -12631,7 +13428,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// orderedSetWithOrderedSet: static NSMutableOrderedSet orderedSetWithOrderedSet_(NSOrderedSet set) { - final _ret = _objc_msgSend_287(_class_NSMutableOrderedSet, + final _ret = _objc_msgSend_303(_class_NSMutableOrderedSet, _sel_orderedSetWithOrderedSet_, set.ref.pointer); return NSMutableOrderedSet.castFromPointer(_ret, retain: true, release: true); @@ -12640,7 +13437,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// orderedSetWithOrderedSet:range:copyItems: static NSMutableOrderedSet orderedSetWithOrderedSet_range_copyItems_( NSOrderedSet set, NSRange range, bool flag) { - final _ret = _objc_msgSend_288( + final _ret = _objc_msgSend_304( _class_NSMutableOrderedSet, _sel_orderedSetWithOrderedSet_range_copyItems_, set.ref.pointer, @@ -12661,7 +13458,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// orderedSetWithArray:range:copyItems: static NSMutableOrderedSet orderedSetWithArray_range_copyItems_( NSArray array, NSRange range, bool flag) { - final _ret = _objc_msgSend_289( + final _ret = _objc_msgSend_305( _class_NSMutableOrderedSet, _sel_orderedSetWithArray_range_copyItems_, array.ref.pointer, @@ -12682,7 +13479,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// orderedSetWithSet:copyItems: static NSMutableOrderedSet orderedSetWithSet_copyItems_( objc.ObjCObjectBase set, bool flag) { - final _ret = _objc_msgSend_290(_class_NSMutableOrderedSet, + final _ret = _objc_msgSend_306(_class_NSMutableOrderedSet, _sel_orderedSetWithSet_copyItems_, set.ref.pointer, flag); return NSMutableOrderedSet.castFromPointer(_ret, retain: true, release: true); @@ -12706,7 +13503,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// initWithOrderedSet: NSMutableOrderedSet initWithOrderedSet_(NSOrderedSet set) { - final _ret = _objc_msgSend_287(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_303(this.ref.retainAndReturnPointer(), _sel_initWithOrderedSet_, set.ref.pointer); return NSMutableOrderedSet.castFromPointer(_ret, retain: false, release: true); @@ -12715,7 +13512,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// initWithOrderedSet:copyItems: NSMutableOrderedSet initWithOrderedSet_copyItems_( NSOrderedSet set, bool flag) { - final _ret = _objc_msgSend_291(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_307(this.ref.retainAndReturnPointer(), _sel_initWithOrderedSet_copyItems_, set.ref.pointer, flag); return NSMutableOrderedSet.castFromPointer(_ret, retain: false, release: true); @@ -12724,7 +13521,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// initWithOrderedSet:range:copyItems: NSMutableOrderedSet initWithOrderedSet_range_copyItems_( NSOrderedSet set, NSRange range, bool flag) { - final _ret = _objc_msgSend_288(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_304(this.ref.retainAndReturnPointer(), _sel_initWithOrderedSet_range_copyItems_, set.ref.pointer, range, flag); return NSMutableOrderedSet.castFromPointer(_ret, retain: false, release: true); @@ -12749,7 +13546,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// initWithArray:range:copyItems: NSMutableOrderedSet initWithArray_range_copyItems_( NSArray set, NSRange range, bool flag) { - final _ret = _objc_msgSend_289(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_305(this.ref.retainAndReturnPointer(), _sel_initWithArray_range_copyItems_, set.ref.pointer, range, flag); return NSMutableOrderedSet.castFromPointer(_ret, retain: false, release: true); @@ -12766,7 +13563,7 @@ class NSMutableOrderedSet extends NSOrderedSet { /// initWithSet:copyItems: NSMutableOrderedSet initWithSet_copyItems_( objc.ObjCObjectBase set, bool flag) { - final _ret = _objc_msgSend_290(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_306(this.ref.retainAndReturnPointer(), _sel_initWithSet_copyItems_, set.ref.pointer, flag); return NSMutableOrderedSet.castFromPointer(_ret, retain: false, release: true); @@ -12810,7 +13607,7 @@ class NSMutableOrderedSet extends NSOrderedSet { late final _class_NSMutableOrderedSet = objc.getClass("NSMutableOrderedSet"); late final _sel_addObjects_count_ = objc.registerName("addObjects:count:"); -final _objc_msgSend_294 = objc.msgSendPointer +final _objc_msgSend_310 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -12826,7 +13623,7 @@ final _objc_msgSend_294 = objc.msgSendPointer int)>(); late final _sel_moveObjectsAtIndexes_toIndex_ = objc.registerName("moveObjectsAtIndexes:toIndex:"); -final _objc_msgSend_295 = objc.msgSendPointer +final _objc_msgSend_311 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -12843,7 +13640,7 @@ final _objc_msgSend_295 = objc.msgSendPointer late final _sel_setObject_atIndex_ = objc.registerName("setObject:atIndex:"); late final _sel_replaceObjectsInRange_withObjects_count_ = objc.registerName("replaceObjectsInRange:withObjects:count:"); -final _objc_msgSend_296 = objc.msgSendPointer +final _objc_msgSend_312 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -12861,7 +13658,7 @@ final _objc_msgSend_296 = objc.msgSendPointer int)>(); late final _sel_intersectOrderedSet_ = objc.registerName("intersectOrderedSet:"); -final _objc_msgSend_297 = objc.msgSendPointer +final _objc_msgSend_313 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -12902,12 +13699,12 @@ class NSMutableSet extends NSSet { /// addObject: void addObject_(objc.ObjCObjectBase object) { - _objc_msgSend_252(this.ref.pointer, _sel_addObject_, object.ref.pointer); + _objc_msgSend_256(this.ref.pointer, _sel_addObject_, object.ref.pointer); } /// removeObject: void removeObject_(objc.ObjCObjectBase object) { - _objc_msgSend_252(this.ref.pointer, _sel_removeObject_, object.ref.pointer); + _objc_msgSend_256(this.ref.pointer, _sel_removeObject_, object.ref.pointer); } /// initWithCoder: @@ -12934,19 +13731,19 @@ class NSMutableSet extends NSSet { /// addObjectsFromArray: void addObjectsFromArray_(NSArray array) { - _objc_msgSend_255( + _objc_msgSend_259( this.ref.pointer, _sel_addObjectsFromArray_, array.ref.pointer); } /// intersectSet: void intersectSet_(NSSet otherSet) { - _objc_msgSend_298( + _objc_msgSend_314( this.ref.pointer, _sel_intersectSet_, otherSet.ref.pointer); } /// minusSet: void minusSet_(NSSet otherSet) { - _objc_msgSend_298(this.ref.pointer, _sel_minusSet_, otherSet.ref.pointer); + _objc_msgSend_314(this.ref.pointer, _sel_minusSet_, otherSet.ref.pointer); } /// removeAllObjects @@ -12956,12 +13753,12 @@ class NSMutableSet extends NSSet { /// unionSet: void unionSet_(NSSet otherSet) { - _objc_msgSend_298(this.ref.pointer, _sel_unionSet_, otherSet.ref.pointer); + _objc_msgSend_314(this.ref.pointer, _sel_unionSet_, otherSet.ref.pointer); } /// setSet: void setSet_(NSSet otherSet) { - _objc_msgSend_298(this.ref.pointer, _sel_setSet_, otherSet.ref.pointer); + _objc_msgSend_314(this.ref.pointer, _sel_setSet_, otherSet.ref.pointer); } /// setWithCapacity: @@ -13009,7 +13806,7 @@ class NSMutableSet extends NSSet { /// setWithSet: static NSMutableSet setWithSet_(NSSet set) { - final _ret = _objc_msgSend_238( + final _ret = _objc_msgSend_242( _class_NSMutableSet, _sel_setWithSet_, set.ref.pointer); return NSMutableSet.castFromPointer(_ret, retain: true, release: true); } @@ -13030,14 +13827,14 @@ class NSMutableSet extends NSSet { /// initWithSet: NSMutableSet initWithSet_(NSSet set) { - final _ret = _objc_msgSend_238( + final _ret = _objc_msgSend_242( this.ref.retainAndReturnPointer(), _sel_initWithSet_, set.ref.pointer); return NSMutableSet.castFromPointer(_ret, retain: false, release: true); } /// initWithSet:copyItems: NSMutableSet initWithSet_copyItems_(NSSet set, bool flag) { - final _ret = _objc_msgSend_239(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_243(this.ref.retainAndReturnPointer(), _sel_initWithSet_copyItems_, set.ref.pointer, flag); return NSMutableSet.castFromPointer(_ret, retain: false, release: true); } @@ -13083,7 +13880,7 @@ class NSMutableSet extends NSSet { } late final _class_NSMutableSet = objc.getClass("NSMutableSet"); -final _objc_msgSend_298 = objc.msgSendPointer +final _objc_msgSend_314 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -13166,7 +13963,7 @@ class NSItemProvider extends NSObject { /// registeredTypeIdentifiersWithFileOptions: NSArray registeredTypeIdentifiersWithFileOptions_( NSItemProviderFileOptions fileOptions) { - final _ret = _objc_msgSend_299(this.ref.pointer, + final _ret = _objc_msgSend_315(this.ref.pointer, _sel_registeredTypeIdentifiersWithFileOptions_, fileOptions.value); return NSArray.castFromPointer(_ret, retain: true, release: true); } @@ -13180,7 +13977,7 @@ class NSItemProvider extends NSObject { /// hasRepresentationConformingToTypeIdentifier:fileOptions: bool hasRepresentationConformingToTypeIdentifier_fileOptions_( NSString typeIdentifier, NSItemProviderFileOptions fileOptions) { - return _objc_msgSend_300( + return _objc_msgSend_316( this.ref.pointer, _sel_hasRepresentationConformingToTypeIdentifier_fileOptions_, typeIdentifier.ref.pointer, @@ -13197,7 +13994,7 @@ class NSItemProvider extends NSObject { /// setSuggestedName: set suggestedName(NSString? value) { - return _objc_msgSend_301(this.ref.pointer, _sel_setSuggestedName_, + return _objc_msgSend_317(this.ref.pointer, _sel_setSuggestedName_, value?.ref.pointer ?? ffi.nullptr); } @@ -13211,7 +14008,7 @@ class NSItemProvider extends NSObject { /// registerObject:visibility: void registerObject_visibility_(objc.ObjCObjectBase object, NSItemProviderRepresentationVisibility visibility) { - _objc_msgSend_302(this.ref.pointer, _sel_registerObject_visibility_, + _objc_msgSend_318(this.ref.pointer, _sel_registerObject_visibility_, object.ref.pointer, visibility.value); } @@ -13224,7 +14021,7 @@ class NSItemProvider extends NSObject { /// initWithItem:typeIdentifier: NSItemProvider initWithItem_typeIdentifier_( objc.ObjCObjectBase? item, NSString? typeIdentifier) { - final _ret = _objc_msgSend_303( + final _ret = _objc_msgSend_319( this.ref.retainAndReturnPointer(), _sel_initWithItem_typeIdentifier_, item?.ref.pointer ?? ffi.nullptr, @@ -13279,7 +14076,7 @@ late final _sel_registeredTypeIdentifiers = objc.registerName("registeredTypeIdentifiers"); late final _sel_registeredTypeIdentifiersWithFileOptions_ = objc.registerName("registeredTypeIdentifiersWithFileOptions:"); -final _objc_msgSend_299 = objc.msgSendPointer +final _objc_msgSend_315 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -13293,7 +14090,7 @@ late final _sel_hasItemConformingToTypeIdentifier_ = objc.registerName("hasItemConformingToTypeIdentifier:"); late final _sel_hasRepresentationConformingToTypeIdentifier_fileOptions_ = objc .registerName("hasRepresentationConformingToTypeIdentifier:fileOptions:"); -final _objc_msgSend_300 = objc.msgSendPointer +final _objc_msgSend_316 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -13309,7 +14106,7 @@ final _objc_msgSend_300 = objc.msgSendPointer int)>(); late final _sel_suggestedName = objc.registerName("suggestedName"); late final _sel_setSuggestedName_ = objc.registerName("setSuggestedName:"); -final _objc_msgSend_301 = objc.msgSendPointer +final _objc_msgSend_317 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -13321,7 +14118,7 @@ final _objc_msgSend_301 = objc.msgSendPointer ffi.Pointer, ffi.Pointer)>(); late final _sel_registerObject_visibility_ = objc.registerName("registerObject:visibility:"); -final _objc_msgSend_302 = objc.msgSendPointer +final _objc_msgSend_318 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -13339,7 +14136,7 @@ late final _sel_canLoadObjectOfClass_ = objc.registerName("canLoadObjectOfClass:"); late final _sel_initWithItem_typeIdentifier_ = objc.registerName("initWithItem:typeIdentifier:"); -final _objc_msgSend_303 = objc.msgSendPointer +final _objc_msgSend_319 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -13408,35 +14205,35 @@ class NSMutableString extends NSString { /// replaceCharactersInRange:withString: void replaceCharactersInRange_withString_(NSRange range, NSString aString) { - _objc_msgSend_304(this.ref.pointer, + _objc_msgSend_320(this.ref.pointer, _sel_replaceCharactersInRange_withString_, range, aString.ref.pointer); } /// insertString:atIndex: void insertString_atIndex_(NSString aString, int loc) { - _objc_msgSend_305( + _objc_msgSend_321( this.ref.pointer, _sel_insertString_atIndex_, aString.ref.pointer, loc); } /// deleteCharactersInRange: void deleteCharactersInRange_(NSRange range) { - _objc_msgSend_250(this.ref.pointer, _sel_deleteCharactersInRange_, range); + _objc_msgSend_254(this.ref.pointer, _sel_deleteCharactersInRange_, range); } /// appendString: void appendString_(NSString aString) { - _objc_msgSend_148( + _objc_msgSend_147( this.ref.pointer, _sel_appendString_, aString.ref.pointer); } /// appendFormat: void appendFormat_(NSString format) { - _objc_msgSend_148(this.ref.pointer, _sel_appendFormat_, format.ref.pointer); + _objc_msgSend_147(this.ref.pointer, _sel_appendFormat_, format.ref.pointer); } /// setString: void setString_(NSString aString) { - _objc_msgSend_148(this.ref.pointer, _sel_setString_, aString.ref.pointer); + _objc_msgSend_147(this.ref.pointer, _sel_setString_, aString.ref.pointer); } /// replaceOccurrencesOfString:withString:options:range: @@ -13445,7 +14242,7 @@ class NSMutableString extends NSString { NSString replacement, NSStringCompareOptions options, NSRange searchRange) { - return _objc_msgSend_306( + return _objc_msgSend_322( this.ref.pointer, _sel_replaceOccurrencesOfString_withString_options_range_, target.ref.pointer, @@ -13457,7 +14254,7 @@ class NSMutableString extends NSString { /// applyTransform:reverse:range:updatedRange: bool applyTransform_reverse_range_updatedRange_(NSString transform, bool reverse, NSRange range, ffi.Pointer resultingRange) { - return _objc_msgSend_307( + return _objc_msgSend_323( this.ref.pointer, _sel_applyTransform_reverse_range_updatedRange_, transform.ref.pointer, @@ -13468,14 +14265,14 @@ class NSMutableString extends NSString { /// initWithCapacity: NSMutableString initWithCapacity_(int capacity) { - final _ret = _objc_msgSend_308( + final _ret = _objc_msgSend_324( this.ref.retainAndReturnPointer(), _sel_initWithCapacity_, capacity); return NSMutableString.castFromPointer(_ret, retain: false, release: true); } /// stringWithCapacity: static NSMutableString stringWithCapacity_(int capacity) { - final _ret = _objc_msgSend_308( + final _ret = _objc_msgSend_324( _class_NSMutableString, _sel_stringWithCapacity_, capacity); return NSMutableString.castFromPointer(_ret, retain: true, release: true); } @@ -13558,10 +14355,18 @@ class NSMutableString extends NSString { return NSMutableString.castFromPointer(_ret, retain: false, release: true); } + /// initWithFormat:arguments: + NSMutableString initWithFormat_arguments_( + NSString format, ffi.Pointer argList) { + final _ret = _objc_msgSend_219(this.ref.retainAndReturnPointer(), + _sel_initWithFormat_arguments_, format.ref.pointer, argList); + return NSMutableString.castFromPointer(_ret, retain: false, release: true); + } + /// initWithFormat:locale: NSMutableString initWithFormat_locale_( NSString format, objc.ObjCObjectBase? locale) { - final _ret = _objc_msgSend_219( + final _ret = _objc_msgSend_220( this.ref.retainAndReturnPointer(), _sel_initWithFormat_locale_, format.ref.pointer, @@ -13569,12 +14374,24 @@ class NSMutableString extends NSString { return NSMutableString.castFromPointer(_ret, retain: false, release: true); } + /// initWithFormat:locale:arguments: + NSMutableString initWithFormat_locale_arguments_(NSString format, + objc.ObjCObjectBase? locale, ffi.Pointer argList) { + final _ret = _objc_msgSend_221( + this.ref.retainAndReturnPointer(), + _sel_initWithFormat_locale_arguments_, + format.ref.pointer, + locale?.ref.pointer ?? ffi.nullptr, + argList); + return NSMutableString.castFromPointer(_ret, retain: false, release: true); + } + /// initWithValidatedFormat:validFormatSpecifiers:error: NSMutableString? initWithValidatedFormat_validFormatSpecifiers_error_( NSString format, NSString validFormatSpecifiers, ffi.Pointer> error) { - final _ret = _objc_msgSend_220( + final _ret = _objc_msgSend_222( this.ref.retainAndReturnPointer(), _sel_initWithValidatedFormat_validFormatSpecifiers_error_, format.ref.pointer, @@ -13591,7 +14408,7 @@ class NSMutableString extends NSString { NSString validFormatSpecifiers, objc.ObjCObjectBase? locale, ffi.Pointer> error) { - final _ret = _objc_msgSend_221( + final _ret = _objc_msgSend_223( this.ref.retainAndReturnPointer(), _sel_initWithValidatedFormat_validFormatSpecifiers_locale_error_, format.ref.pointer, @@ -13603,9 +14420,49 @@ class NSMutableString extends NSString { : NSMutableString.castFromPointer(_ret, retain: false, release: true); } + /// initWithValidatedFormat:validFormatSpecifiers:arguments:error: + NSMutableString? + initWithValidatedFormat_validFormatSpecifiers_arguments_error_( + NSString format, + NSString validFormatSpecifiers, + ffi.Pointer argList, + ffi.Pointer> error) { + final _ret = _objc_msgSend_224( + this.ref.retainAndReturnPointer(), + _sel_initWithValidatedFormat_validFormatSpecifiers_arguments_error_, + format.ref.pointer, + validFormatSpecifiers.ref.pointer, + argList, + error); + return _ret.address == 0 + ? null + : NSMutableString.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithValidatedFormat:validFormatSpecifiers:locale:arguments:error: + NSMutableString? + initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_( + NSString format, + NSString validFormatSpecifiers, + objc.ObjCObjectBase? locale, + ffi.Pointer argList, + ffi.Pointer> error) { + final _ret = _objc_msgSend_225( + this.ref.retainAndReturnPointer(), + _sel_initWithValidatedFormat_validFormatSpecifiers_locale_arguments_error_, + format.ref.pointer, + validFormatSpecifiers.ref.pointer, + locale?.ref.pointer ?? ffi.nullptr, + argList, + error); + return _ret.address == 0 + ? null + : NSMutableString.castFromPointer(_ret, retain: false, release: true); + } + /// initWithData:encoding: NSMutableString? initWithData_encoding_(NSData data, int encoding) { - final _ret = _objc_msgSend_222(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_226(this.ref.retainAndReturnPointer(), _sel_initWithData_encoding_, data.ref.pointer, encoding); return _ret.address == 0 ? null @@ -13615,7 +14472,7 @@ class NSMutableString extends NSString { /// initWithBytes:length:encoding: NSMutableString? initWithBytes_length_encoding_( ffi.Pointer bytes, int len, int encoding) { - final _ret = _objc_msgSend_223(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_227(this.ref.retainAndReturnPointer(), _sel_initWithBytes_length_encoding_, bytes, len, encoding); return _ret.address == 0 ? null @@ -13625,7 +14482,7 @@ class NSMutableString extends NSString { /// initWithBytesNoCopy:length:encoding:freeWhenDone: NSMutableString? initWithBytesNoCopy_length_encoding_freeWhenDone_( ffi.Pointer bytes, int len, int encoding, bool freeBuffer) { - final _ret = _objc_msgSend_224( + final _ret = _objc_msgSend_228( this.ref.retainAndReturnPointer(), _sel_initWithBytesNoCopy_length_encoding_freeWhenDone_, bytes, @@ -13688,7 +14545,7 @@ class NSMutableString extends NSString { NSString format, NSString validFormatSpecifiers, ffi.Pointer> error) { - final _ret = _objc_msgSend_220( + final _ret = _objc_msgSend_222( _class_NSMutableString, _sel_stringWithValidatedFormat_validFormatSpecifiers_error_, format.ref.pointer, @@ -13705,7 +14562,7 @@ class NSMutableString extends NSString { NSString format, NSString validFormatSpecifiers, ffi.Pointer> error) { - final _ret = _objc_msgSend_220( + final _ret = _objc_msgSend_222( _class_NSMutableString, _sel_localizedStringWithValidatedFormat_validFormatSpecifiers_error_, format.ref.pointer, @@ -13719,7 +14576,7 @@ class NSMutableString extends NSString { /// initWithCString:encoding: NSMutableString? initWithCString_encoding_( ffi.Pointer nullTerminatedCString, int encoding) { - final _ret = _objc_msgSend_225(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_229(this.ref.retainAndReturnPointer(), _sel_initWithCString_encoding_, nullTerminatedCString, encoding); return _ret.address == 0 ? null @@ -13729,7 +14586,7 @@ class NSMutableString extends NSString { /// stringWithCString:encoding: static NSMutableString? stringWithCString_encoding_( ffi.Pointer cString, int enc) { - final _ret = _objc_msgSend_225( + final _ret = _objc_msgSend_229( _class_NSMutableString, _sel_stringWithCString_encoding_, cString, enc); return _ret.address == 0 ? null @@ -13739,7 +14596,7 @@ class NSMutableString extends NSString { /// initWithContentsOfURL:encoding:error: NSMutableString? initWithContentsOfURL_encoding_error_( NSURL url, int enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_226( + final _ret = _objc_msgSend_230( this.ref.retainAndReturnPointer(), _sel_initWithContentsOfURL_encoding_error_, url.ref.pointer, @@ -13753,7 +14610,7 @@ class NSMutableString extends NSString { /// initWithContentsOfFile:encoding:error: NSMutableString? initWithContentsOfFile_encoding_error_( NSString path, int enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_227( + final _ret = _objc_msgSend_231( this.ref.retainAndReturnPointer(), _sel_initWithContentsOfFile_encoding_error_, path.ref.pointer, @@ -13767,7 +14624,7 @@ class NSMutableString extends NSString { /// stringWithContentsOfURL:encoding:error: static NSMutableString? stringWithContentsOfURL_encoding_error_( NSURL url, int enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_226( + final _ret = _objc_msgSend_230( _class_NSMutableString, _sel_stringWithContentsOfURL_encoding_error_, url.ref.pointer, @@ -13781,7 +14638,7 @@ class NSMutableString extends NSString { /// stringWithContentsOfFile:encoding:error: static NSMutableString? stringWithContentsOfFile_encoding_error_( NSString path, int enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_227( + final _ret = _objc_msgSend_231( _class_NSMutableString, _sel_stringWithContentsOfFile_encoding_error_, path.ref.pointer, @@ -13797,7 +14654,7 @@ class NSMutableString extends NSString { NSURL url, ffi.Pointer enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_228( + final _ret = _objc_msgSend_232( this.ref.retainAndReturnPointer(), _sel_initWithContentsOfURL_usedEncoding_error_, url.ref.pointer, @@ -13813,7 +14670,7 @@ class NSMutableString extends NSString { NSString path, ffi.Pointer enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_229( + final _ret = _objc_msgSend_233( this.ref.retainAndReturnPointer(), _sel_initWithContentsOfFile_usedEncoding_error_, path.ref.pointer, @@ -13829,7 +14686,7 @@ class NSMutableString extends NSString { NSURL url, ffi.Pointer enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_228( + final _ret = _objc_msgSend_232( _class_NSMutableString, _sel_stringWithContentsOfURL_usedEncoding_error_, url.ref.pointer, @@ -13845,7 +14702,7 @@ class NSMutableString extends NSString { NSString path, ffi.Pointer enc, ffi.Pointer> error) { - final _ret = _objc_msgSend_229( + final _ret = _objc_msgSend_233( _class_NSMutableString, _sel_stringWithContentsOfFile_usedEncoding_error_, path.ref.pointer, @@ -13863,7 +14720,7 @@ class NSMutableString extends NSString { NSDictionary? opts, ffi.Pointer> string, ffi.Pointer usedLossyConversion) { - return _objc_msgSend_230( + return _objc_msgSend_234( _class_NSMutableString, _sel_stringEncodingForData_encodingOptions_convertedString_usedLossyConversion_, data.ref.pointer, @@ -13908,7 +14765,7 @@ class NSMutableString extends NSString { late final _class_NSMutableString = objc.getClass("NSMutableString"); late final _sel_replaceCharactersInRange_withString_ = objc.registerName("replaceCharactersInRange:withString:"); -final _objc_msgSend_304 = objc.msgSendPointer +final _objc_msgSend_320 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -13924,7 +14781,7 @@ final _objc_msgSend_304 = objc.msgSendPointer ffi.Pointer)>(); late final _sel_insertString_atIndex_ = objc.registerName("insertString:atIndex:"); -final _objc_msgSend_305 = objc.msgSendPointer +final _objc_msgSend_321 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -13945,7 +14802,7 @@ late final _sel_appendFormat_ = objc.registerName("appendFormat:"); late final _sel_setString_ = objc.registerName("setString:"); late final _sel_replaceOccurrencesOfString_withString_options_range_ = objc.registerName("replaceOccurrencesOfString:withString:options:range:"); -final _objc_msgSend_306 = objc.msgSendPointer +final _objc_msgSend_322 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.UnsignedLong Function( @@ -13965,7 +14822,7 @@ final _objc_msgSend_306 = objc.msgSendPointer NSRange)>(); late final _sel_applyTransform_reverse_range_updatedRange_ = objc.registerName("applyTransform:reverse:range:updatedRange:"); -final _objc_msgSend_307 = objc.msgSendPointer +final _objc_msgSend_323 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Bool Function( @@ -13983,7 +14840,7 @@ final _objc_msgSend_307 = objc.msgSendPointer bool, NSRange, ffi.Pointer)>(); -final _objc_msgSend_308 = objc.msgSendPointer +final _objc_msgSend_324 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function(ffi.Pointer, @@ -14072,6 +14929,176 @@ class NSURLHandle extends NSObject { late final _class_NSURLHandle = objc.getClass("NSURLHandle"); +/// Helper class to adapt a Dart stream into a `NSInputStream` +class DartInputStreamAdapter extends NSInputStream { + DartInputStreamAdapter._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [DartInputStreamAdapter] that points to the same underlying object as [other]. + DartInputStreamAdapter.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [DartInputStreamAdapter] that wraps the given raw object pointer. + DartInputStreamAdapter.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [DartInputStreamAdapter]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_0( + obj.ref.pointer, _sel_isKindOfClass_, _class_DartInputStreamAdapter); + } + + /// Creates the adapter. + /// @param sendPort A port to that is will receive two types of messages: + /// -1 => The `NSInputStream` has been closed and the port can be closed. + /// _ => The number of types being required in a `read:maxLength` call. + static DartInputStreamAdapter inputStreamWithPort_(int sendPort) { + final _ret = _objc_msgSend_325( + _class_DartInputStreamAdapter, _sel_inputStreamWithPort_, sendPort); + return DartInputStreamAdapter.castFromPointer(_ret, + retain: true, release: true); + } + + /// addData: + int addData_(NSData data) { + return _objc_msgSend_326(this.ref.pointer, _sel_addData_, data.ref.pointer); + } + + /// setDone + void setDone() { + _objc_msgSend_1(this.ref.pointer, _sel_setDone); + } + + /// setError: + void setError_(NSError error) { + _objc_msgSend_327(this.ref.pointer, _sel_setError_, error.ref.pointer); + } + + /// initWithData: + DartInputStreamAdapter initWithData_(NSData data) { + final _ret = _objc_msgSend_180(this.ref.retainAndReturnPointer(), + _sel_initWithData_, data.ref.pointer); + return DartInputStreamAdapter.castFromPointer(_ret, + retain: false, release: true); + } + + /// initWithURL: + DartInputStreamAdapter? initWithURL_(NSURL url) { + final _ret = _objc_msgSend_179( + this.ref.retainAndReturnPointer(), _sel_initWithURL_, url.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: false, release: true); + } + + /// initWithFileAtPath: + DartInputStreamAdapter? initWithFileAtPath_(NSString path) { + final _ret = _objc_msgSend_52(this.ref.retainAndReturnPointer(), + _sel_initWithFileAtPath_, path.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: false, release: true); + } + + /// inputStreamWithData: + static DartInputStreamAdapter? inputStreamWithData_(NSData data) { + final _ret = _objc_msgSend_296(_class_DartInputStreamAdapter, + _sel_inputStreamWithData_, data.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: true, release: true); + } + + /// inputStreamWithFileAtPath: + static DartInputStreamAdapter? inputStreamWithFileAtPath_(NSString path) { + final _ret = _objc_msgSend_52(_class_DartInputStreamAdapter, + _sel_inputStreamWithFileAtPath_, path.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: true, release: true); + } + + /// inputStreamWithURL: + static DartInputStreamAdapter? inputStreamWithURL_(NSURL url) { + final _ret = _objc_msgSend_179(_class_DartInputStreamAdapter, + _sel_inputStreamWithURL_, url.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: true, release: true); + } + + /// getStreamsToHostWithName:port:inputStream:outputStream: + static void getStreamsToHostWithName_port_inputStream_outputStream_( + NSString hostname, + int port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_299( + _class_DartInputStreamAdapter, + _sel_getStreamsToHostWithName_port_inputStream_outputStream_, + hostname.ref.pointer, + port, + inputStream, + outputStream); + } + + /// getBoundStreamsWithBufferSize:inputStream:outputStream: + static void getBoundStreamsWithBufferSize_inputStream_outputStream_( + int bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_300( + _class_DartInputStreamAdapter, + _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_, + bufferSize, + inputStream, + outputStream); + } +} + +late final _class_DartInputStreamAdapter = + objc.getClass("DartInputStreamAdapter"); +late final _sel_inputStreamWithPort_ = + objc.registerName("inputStreamWithPort:"); +final _objc_msgSend_325 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, + ffi.Pointer, ffi.Int64 sendPort)>>() + .asFunction< + instancetype Function(ffi.Pointer, + ffi.Pointer, int)>(); +late final _sel_addData_ = objc.registerName("addData:"); +final _objc_msgSend_326 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer data)>>() + .asFunction< + int Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); +late final _sel_setDone = objc.registerName("setDone"); +late final _sel_setError_ = objc.registerName("setError:"); +final _objc_msgSend_327 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer error)>>() + .asFunction< + void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + /// NSProxy class NSProxy extends objc.ObjCObjectBase { NSProxy._(ffi.Pointer pointer, @@ -14120,7 +15147,7 @@ class NSProxy extends objc.ObjCObjectBase { /// methodSignatureForSelector: NSMethodSignature? methodSignatureForSelector_( ffi.Pointer sel) { - final _ret = _objc_msgSend_309( + final _ret = _objc_msgSend_328( this.ref.pointer, _sel_methodSignatureForSelector_, sel); return _ret.address == 0 ? null @@ -14156,7 +15183,7 @@ class NSProxy extends objc.ObjCObjectBase { } late final _class_NSProxy = objc.getClass("NSProxy"); -final _objc_msgSend_309 = objc.msgSendPointer +final _objc_msgSend_328 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -14207,7 +15234,7 @@ class DartProxyBuilder extends NSObject { ffi.Pointer sel, NSMethodSignature signature, ffi.Pointer block) { - _objc_msgSend_310( + _objc_msgSend_329( this.ref.pointer, _sel_implementMethod_withSignature_andBlock_, sel, @@ -14245,7 +15272,7 @@ class DartProxyBuilder extends NSObject { late final _class_DartProxyBuilder = objc.getClass("DartProxyBuilder"); late final _sel_implementMethod_withSignature_andBlock_ = objc.registerName("implementMethod:withSignature:andBlock:"); -final _objc_msgSend_310 = objc.msgSendPointer +final _objc_msgSend_329 = objc.msgSendPointer .cast< ffi.NativeFunction< ffi.Void Function( @@ -14285,14 +15312,14 @@ class DartProxy extends NSProxy { /// newFromBuilder: static DartProxy newFromBuilder_(DartProxyBuilder builder) { - final _ret = _objc_msgSend_311( + final _ret = _objc_msgSend_330( _class_DartProxy, _sel_newFromBuilder_, builder.ref.pointer); return DartProxy.castFromPointer(_ret, retain: false, release: true); } /// initFromBuilder: DartProxy initFromBuilder_(DartProxyBuilder builder) { - final _ret = _objc_msgSend_311(this.ref.retainAndReturnPointer(), + final _ret = _objc_msgSend_330(this.ref.retainAndReturnPointer(), _sel_initFromBuilder_, builder.ref.pointer); return DartProxy.castFromPointer(_ret, retain: false, release: true); } @@ -14306,7 +15333,7 @@ class DartProxy extends NSProxy { /// methodSignatureForSelector: NSMethodSignature methodSignatureForSelector_( ffi.Pointer sel) { - final _ret = _objc_msgSend_240( + final _ret = _objc_msgSend_244( this.ref.pointer, _sel_methodSignatureForSelector_, sel); return NSMethodSignature.castFromPointer(_ret, retain: true, release: true); } @@ -14326,7 +15353,7 @@ class DartProxy extends NSProxy { late final _class_DartProxy = objc.getClass("DartProxy"); late final _sel_newFromBuilder_ = objc.registerName("newFromBuilder:"); -final _objc_msgSend_311 = objc.msgSendPointer +final _objc_msgSend_330 = objc.msgSendPointer .cast< ffi.NativeFunction< instancetype Function( @@ -14337,3 +15364,4 @@ final _objc_msgSend_311 = objc.msgSendPointer instancetype Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); late final _sel_initFromBuilder_ = objc.registerName("initFromBuilder:"); +late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); diff --git a/pkgs/objective_c/macos/Classes/objective_c.m b/pkgs/objective_c/macos/Classes/objective_c.m index d7f0800b6..52472340a 100644 --- a/pkgs/objective_c/macos/Classes/objective_c.m +++ b/pkgs/objective_c/macos/Classes/objective_c.m @@ -4,4 +4,5 @@ // Relative import to be able to reuse the ObjC sources. // See the comment in ../objective_c.podspec for more information. +#include "../../src/input_stream_adapter.m" #include "../../src/proxy.m" diff --git a/pkgs/objective_c/pubspec.yaml b/pkgs/objective_c/pubspec.yaml index 8f1310dbf..9741bd5c0 100644 --- a/pkgs/objective_c/pubspec.yaml +++ b/pkgs/objective_c/pubspec.yaml @@ -4,7 +4,7 @@ name: objective_c description: 'A library to access Objective C from Flutter that acts as a support library for package:ffigen.' -version: 2.0.0 +version: 3.0.0-wip repository: https://github.com/dart-lang/native/tree/main/pkgs/objective_c topics: diff --git a/pkgs/objective_c/src/foundation.h b/pkgs/objective_c/src/foundation.h index 85e20dcc3..4dd4f0a16 100644 --- a/pkgs/objective_c/src/foundation.h +++ b/pkgs/objective_c/src/foundation.h @@ -10,6 +10,7 @@ #import #import #import +#import #import #import #import diff --git a/pkgs/objective_c/src/input_stream_adapter.h b/pkgs/objective_c/src/input_stream_adapter.h new file mode 100644 index 000000000..a3482ac76 --- /dev/null +++ b/pkgs/objective_c/src/input_stream_adapter.h @@ -0,0 +1,27 @@ +// Copyright (c) 2024, 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. + +#ifndef INPUT_STREAM_ADAPTER_H_ +#define INPUT_STREAM_ADAPTER_H_ + +#include "include/dart_api_dl.h" + +#import +#import + +/// Helper class to adapt a Dart stream into a `NSInputStream` +@interface DartInputStreamAdapter : NSInputStream + +/// Creates the adapter. +/// @param sendPort A port to that is will receive two types of messages: +/// -1 => The `NSInputStream` has been closed and the port can be closed. +/// _ => The number of types being required in a `read:maxLength` call. ++ (instancetype)inputStreamWithPort:(Dart_Port)sendPort; + +- (NSUInteger)addData:(NSData *)data; +- (void)setDone; +- (void)setError:(NSError *)error; +@end + +#endif // INPUT_STREAM_ADAPTER_H_ diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m new file mode 100644 index 000000000..f3586483f --- /dev/null +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -0,0 +1,164 @@ +// Copyright (c) 2024, 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 "input_stream_adapter.h" + +#import +#include + +@implementation DartInputStreamAdapter { + Dart_Port _sendPort; + NSCondition *_dataCondition; + NSMutableData *_data; + NSStreamStatus _status; + BOOL _done; + NSError *_error; + id _delegate; // This is a weak reference. +} + ++ (instancetype)inputStreamWithPort:(Dart_Port)sendPort { + DartInputStreamAdapter *stream = [[DartInputStreamAdapter alloc] init]; + if (stream != nil) { + stream->_sendPort = sendPort; + stream->_dataCondition = [[NSCondition alloc] init]; + stream->_data = [[NSMutableData alloc] init]; + stream->_done = NO; + stream->_status = NSStreamStatusNotOpen; + stream->_error = nil; + stream->_delegate = stream; + } + return stream; +} + +- (NSUInteger)addData:(NSData *)data { + [_dataCondition lock]; + [_data appendData:data]; + [_dataCondition broadcast]; + [_dataCondition unlock]; + return [_data length]; +} + +- (void)setDone { + [_dataCondition lock]; + _done = YES; + [_dataCondition broadcast]; + [_dataCondition unlock]; +} + +- (void)setError:(NSError *)error { + [_dataCondition lock]; + _error = error; + [_dataCondition broadcast]; + [_dataCondition unlock]; +} + +#pragma mark - NSStream + +- (void)scheduleInRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode { +} + +- (void)removeFromRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode { +} + +- (void)open { + [_dataCondition lock]; + _status = NSStreamStatusOpen; + [_dataCondition unlock]; +} + +- (void)close { + [_dataCondition lock]; + _status = NSStreamStatusClosed; + const bool success = Dart_PostInteger_DL(_sendPort, -1); + NSCAssert(success, @"Dart_PostCObject_DL failed."); + [_dataCondition unlock]; +} + +- (id)propertyForKey:(NSStreamPropertyKey)key { + return nil; +} + +- (BOOL)setProperty:(id)property forKey:(NSStreamPropertyKey)key { + return NO; +} + +- (id)delegate { + return _delegate; +} + +- (void)setDelegate:(id)delegate { + if (delegate == nil) { + _delegate = self; + } else { + _delegate = delegate; + } +} + +- (NSError *)streamError { + return _error; +} + +- (NSStreamStatus)streamStatus { + return _status; +} + +#pragma mark - NSInputStream + +- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len { + if (_status == NSStreamStatusNotOpen) { + return -1; + } + + [_dataCondition lock]; + + while ([_data length] == 0 && !_done && _error == nil) { + os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, + "DartInputStreamAdapter: waiting for data"); + + const bool success = Dart_PostInteger_DL(_sendPort, len); + NSCAssert(success, @"Dart_PostCObject_DL failed."); + + [_dataCondition wait]; + } + + NSInteger copySize; + if (_error == nil) { + copySize = MIN(len, [_data length]); + NSRange readRange = NSMakeRange(0, copySize); + [_data getBytes:(void *)buffer range:readRange]; + // Shift the remaining data over to the beginning of the buffer. + // NOTE: this makes small reads expensive! + [_data replaceBytesInRange:readRange withBytes:NULL length:0]; + + if (_done && [_data length] == 0) { + _status = NSStreamStatusAtEnd; + } + } else { + _status = NSStreamStatusError; + copySize = -1; + } + + [_dataCondition unlock]; + return copySize; +} + +- (BOOL)getBuffer:(uint8_t **)buffer length:(NSUInteger *)len { + return NO; +} + +- (BOOL)hasBytesAvailable { + return _status == NSStreamStatusOpen; +} + +#pragma mark - NSStreamDelegate + +- (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent { + id delegate = _delegate; + if (delegate != self) { + os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_ERROR, + "DartInputStreamAdapter: non-self delegate was invoked"); + } +} + +@end diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart new file mode 100644 index 000000000..09172ea18 --- /dev/null +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -0,0 +1,236 @@ +// Copyright (c) 2024, 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. + +// Objective C support is only available on mac. +@TestOn('mac-os') +library; + +import 'dart:ffi'; +import 'dart:io'; +import 'dart:isolate'; +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:ffi/ffi.dart'; +import 'package:objective_c/objective_c.dart'; +import 'package:objective_c/src/objective_c_bindings_generated.dart'; +import 'package:test/test.dart'; + +Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( + NSInputStream stream, int size) { + return Isolate.run(() => using((arena) { + final buffer = arena(size); + final readSize = stream.read_maxLength_(buffer, size); + final data = Uint8List.fromList( + buffer.asTypedList(readSize == -1 ? 0 : readSize)); + return ( + readSize, + data, + stream.hasBytesAvailable, + stream.streamStatus, + stream.streamError, + ); + })); +} + +void main() { + group('NSInputStream', () { + setUpAll(() { + // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. + DynamicLibrary.open('test/objective_c.dylib'); + }); + + group('toNSInputStream', () { + group('empty', () { + late NSInputStream inputStream; + + setUp(() { + inputStream = const Stream>.empty().toNSInputStream(); + }); + + test('initial state', () { + expect( + inputStream.streamStatus, NSStreamStatus.NSStreamStatusNotOpen); + expect(inputStream.streamError, null); + }); + + test('open', () { + inputStream.open(); + expect(inputStream.streamStatus, NSStreamStatus.NSStreamStatusOpen); + expect(inputStream.streamError, null); + }); + + test('read', () async { + inputStream.open(); + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, 10); + expect(count, 0); + expect(data, isEmpty); + expect(hasBytesAvailable, false); + expect(status, NSStreamStatus.NSStreamStatusAtEnd); + expect(error, isNull); + }); + + test('read without open', () async { + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, 10); + expect(count, -1); + expect(data, isEmpty); + expect(hasBytesAvailable, false); + expect(status, NSStreamStatus.NSStreamStatusNotOpen); + expect(error, isNull); + }); + + test('close', () { + inputStream.open(); + inputStream.close(); + expect(inputStream.streamStatus, NSStreamStatus.NSStreamStatusClosed); + expect(inputStream.streamError, null); + }); + }); + + group('small stream', () { + late NSInputStream inputStream; + + setUp(() { + inputStream = Stream.fromIterable([ + [1], + [2, 3], + [4, 5, 6] + ]).toNSInputStream(); + }); + + test('initial state', () { + expect( + inputStream.streamStatus, NSStreamStatus.NSStreamStatusNotOpen); + expect(inputStream.streamError, null); + }); + + test('open', () { + inputStream.open(); + expect(inputStream.streamStatus, NSStreamStatus.NSStreamStatusOpen); + expect(inputStream.streamError, null); + }); + + test('partial read', () async { + inputStream.open(); + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, 5); + expect(count, lessThanOrEqualTo(5)); + expect(count, greaterThanOrEqualTo(1)); + expect(data, [1, 2, 3, 4, 5].sublist(0, count)); + expect(hasBytesAvailable, true); + expect(status, NSStreamStatus.NSStreamStatusOpen); + expect(error, isNull); + }); + + test('full read', () async { + inputStream.open(); + final readData = []; + while (true) { + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, 6); + + readData.addAll(data); + + expect(error, isNull); + if (count == 0) { + expect(hasBytesAvailable, false); + expect(status, NSStreamStatus.NSStreamStatusAtEnd); + expect(readData, [1, 2, 3, 4, 5, 6]); + break; + } + } + }); + + test('read without open', () async { + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, 10); + expect(count, -1); + expect(data, isEmpty); + expect(hasBytesAvailable, false); + expect(status, NSStreamStatus.NSStreamStatusNotOpen); + expect(error, isNull); + }); + + test('close', () { + inputStream.open(); + inputStream.close(); + expect(inputStream.streamStatus, NSStreamStatus.NSStreamStatusClosed); + expect(inputStream.streamError, null); + }); + }); + }); + + group('large stream', () { + late NSInputStream inputStream; + final streamData = List.generate(100, (x) => List.filled(10000, x)); + final testData = streamData.expand((x) => x).toList(); + + setUp(() { + inputStream = Stream.fromIterable(streamData).toNSInputStream(); + }); + + test('partial read', () async { + inputStream.open(); + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, 100000); + expect(count, lessThanOrEqualTo(100000)); + expect(count, greaterThanOrEqualTo(1)); + expect(data, testData.sublist(0, count)); + expect(hasBytesAvailable, true); + expect(status, NSStreamStatus.NSStreamStatusOpen); + expect(error, isNull); + }); + + test('full read', () async { + inputStream.open(); + final readData = []; + while (true) { + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, Random.secure().nextInt(100000)); + + readData.addAll(data); + + expect(error, isNull); + if (count == 0) { + expect(hasBytesAvailable, false); + expect(status, NSStreamStatus.NSStreamStatusAtEnd); + expect(readData, testData); + break; + } + } + }); + }); + + test('error in stream', () async { + late NSInputStream inputStream; + + inputStream = () async* { + yield [1, 2]; + throw const FileSystemException('some exception message'); + }() + .toNSInputStream(); + + inputStream.open(); + final (count1, data1, hasBytesAvailable1, status1, error1) = + await read(inputStream, 10); + expect(count1, 2); + expect(data1, [1, 2]); + expect(hasBytesAvailable1, true); + expect(status1, NSStreamStatus.NSStreamStatusOpen); + expect(error1, isNull); + + final (count2, data2, hasBytesAvailable2, status2, error2) = + await read(inputStream, 10); + expect(count2, -1); + expect(hasBytesAvailable2, false); + expect(status2, NSStreamStatus.NSStreamStatusError); + expect( + error2, + isA().having((e) => e.localizedDescription.toString(), + 'localizedDescription', contains('some exception message'))); + }); + }); +} diff --git a/pkgs/objective_c/test/setup.dart b/pkgs/objective_c/test/setup.dart index c59f4619c..1d091a334 100644 --- a/pkgs/objective_c/test/setup.dart +++ b/pkgs/objective_c/test/setup.dart @@ -13,7 +13,7 @@ import 'dart:ffi'; import 'dart:io'; const cFiles = ['src/objective_c.c', 'src/include/dart_api_dl.c']; -const objCFiles = ['src/proxy.m']; +const objCFiles = ['src/input_stream_adapter.m', 'src/proxy.m']; const objCFlags = [ '-x', 'objective-c', From af7f981c7eec7e97847d0a670f321894f998be85 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 13 Sep 2024 15:27:57 -0700 Subject: [PATCH 02/38] Clarify the deadlock behavior of `toNSInputStream`. --- pkgs/objective_c/lib/src/ns_input_stream.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index d84bafa91..704b73073 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -9,6 +9,12 @@ import 'objective_c_bindings_generated.dart'; extension NSInputStreamStreamExtension on Stream> { /// Return a [NSInputStream] that, when read, will contain the contents of /// the [Stream]. + /// + /// > [!IMPORTANT] + /// > [NSInputStream.read_maxLength_] must called called from a different + /// > thread or [Isolate] than the one that calls [toNSInputStream]. + /// > Otherwise, [NSInputStream.read_maxLength_] will deadlock waiting for + /// > data to be added from the [Stream]. NSInputStream toNSInputStream() { // Eagerly add data until `maxReadAheadSize` is buffered. const maxReadAheadSize = 4096; From 903a7de59cc0d9c342fba92d1f2ac4e1ee8c0554 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 13 Sep 2024 15:29:58 -0700 Subject: [PATCH 03/38] Update ns_input_stream_test.dart --- pkgs/objective_c/test/ns_input_stream_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index 09172ea18..5e3c15b23 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -229,8 +229,10 @@ void main() { expect(status2, NSStreamStatus.NSStreamStatusError); expect( error2, - isA().having((e) => e.localizedDescription.toString(), - 'localizedDescription', contains('some exception message'))); + isA() + .having((e) => e.localizedDescription.toString(), + 'localizedDescription', contains('some exception message')) + .having((e) => e.domain.toString(), 'domain', 'DartError')); }); }); } From c8215be83be93ea45fb316cce5eb8bfb3673b0ac Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 13 Sep 2024 15:34:39 -0700 Subject: [PATCH 04/38] Update ns_input_stream_test.dart --- pkgs/objective_c/test/ns_input_stream_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index 5e3c15b23..ac7ac4348 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -222,7 +222,7 @@ void main() { expect(status1, NSStreamStatus.NSStreamStatusOpen); expect(error1, isNull); - final (count2, data2, hasBytesAvailable2, status2, error2) = + final (count2, _, hasBytesAvailable2, status2, error2) = await read(inputStream, 10); expect(count2, -1); expect(hasBytesAvailable2, false); From 55788d7ffc1d52214c1c0a06bb8ac639013841e3 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Thu, 26 Sep 2024 15:51:59 -0700 Subject: [PATCH 05/38] Update input_stream_adapter.m --- pkgs/objective_c/src/input_stream_adapter.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m index f3586483f..e2d47dc17 100644 --- a/pkgs/objective_c/src/input_stream_adapter.m +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -14,7 +14,7 @@ @implementation DartInputStreamAdapter { NSStreamStatus _status; BOOL _done; NSError *_error; - id _delegate; // This is a weak reference. + id __weak _delegate; // This is a weak reference. } + (instancetype)inputStreamWithPort:(Dart_Port)sendPort { From 893d1ffd0e9beb9fed04aa4304ee79ee63f1d2cc Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Thu, 26 Sep 2024 16:41:44 -0700 Subject: [PATCH 06/38] Update CHANGELOG.md --- pkgs/ffigen/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md index 436976506..754c0d812 100644 --- a/pkgs/ffigen/CHANGELOG.md +++ b/pkgs/ffigen/CHANGELOG.md @@ -1,5 +1,6 @@ ## 15.0.0-wip +- Dedupe `ObjCBlock` trampolines to reduce generated ObjC code. - Update to latest `package:objective_c`. - ObjC objects now include the methods from the protocols they implement. Both required and optional methods are included. Optional methods will throw an From 041c9696c99781f93fa693a3d1331ff7af625081 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 10:33:26 -0700 Subject: [PATCH 07/38] More work --- .../objc_built_in_functions.dart | 2 + pkgs/objective_c/ffigen_objc.yaml | 1 + pkgs/objective_c/lib/objective_c.dart | 1 + .../src/objective_c_bindings_generated.dart | 991 ++++++++++++++++++ .../src/objective_c_bindings_generated.m | 9 + 5 files changed, 1004 insertions(+) diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index 8dcdc1d09..1394c84da 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -44,6 +44,7 @@ class ObjCBuiltInFunctions { // Keep in sync with pkgs/objective_c/ffigen_objc.yaml. static const builtInInterfaces = { + 'DartInputStreamAdapter', 'DartProxy', 'DartProxyBuilder', 'NSArray', @@ -71,6 +72,7 @@ class ObjCBuiltInFunctions { 'NSNumber', 'NSObject', 'NSOrderedSet', + 'NSOutputStream', 'NSProxy', 'NSSet', 'NSStream', diff --git a/pkgs/objective_c/ffigen_objc.yaml b/pkgs/objective_c/ffigen_objc.yaml index 6ba0483e2..38526efc2 100644 --- a/pkgs/objective_c/ffigen_objc.yaml +++ b/pkgs/objective_c/ffigen_objc.yaml @@ -50,6 +50,7 @@ objc-interfaces: - NSNotification - NSNumber - NSObject + - NSOutputStream - NSOrderedSet - NSProxy - NSSet diff --git a/pkgs/objective_c/lib/objective_c.dart b/pkgs/objective_c/lib/objective_c.dart index d6fa26fe5..d7cfb5574 100644 --- a/pkgs/objective_c/lib/objective_c.dart +++ b/pkgs/objective_c/lib/objective_c.dart @@ -68,6 +68,7 @@ export 'src/objective_c_bindings_generated.dart' NSObject, NSOrderedCollectionDifferenceCalculationOptions, NSOrderedSet, + NSOutputStream, NSProxy, NSRange, NSSet, diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index 4d01ce9fb..c789479a7 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -22,6 +22,21 @@ import 'package:ffi/ffi.dart' as pkg_ffi; import 'dart:ffi' as ffi; import '../objective_c.dart' as objc; +@ffi.Native>(symbol: "NSLocalizedDescriptionKey") +external ffi.Pointer _NSLocalizedDescriptionKey; + +NSString get NSLocalizedDescriptionKey => + NSString.castFromPointer(_NSLocalizedDescriptionKey, + retain: true, release: true); + +set NSLocalizedDescriptionKey(NSString value) { + NSString.castFromPointer(_NSLocalizedDescriptionKey, + retain: false, release: true) + .ref + .release(); + _NSLocalizedDescriptionKey = value.ref.retainAndReturnPointer(); +} + @ffi.Native< ffi.Pointer Function( ffi.Pointer)>(isLeaf: true) @@ -29,6 +44,13 @@ external ffi.Pointer _wrapListenerBlock_hepzs( ffi.Pointer block, ); +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer _wrapListenerBlock_m1viep( + ffi.Pointer block, +); + @ffi.Native< ffi.Pointer Function( ffi.Pointer)>(isLeaf: true) @@ -36,6 +58,151 @@ external ffi.Pointer _wrapListenerBlock_sjfpmz( ffi.Pointer block, ); +/// Helper class to adapt a Dart stream into a `NSInputStream` +class DartInputStreamAdapter extends NSInputStream { + DartInputStreamAdapter._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [DartInputStreamAdapter] that points to the same underlying object as [other]. + DartInputStreamAdapter.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [DartInputStreamAdapter] that wraps the given raw object pointer. + DartInputStreamAdapter.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [DartInputStreamAdapter]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_l8lotg( + obj.ref.pointer, _sel_isKindOfClass_, _class_DartInputStreamAdapter); + } + + /// addData: + int addData_(NSData data) { + return _objc_msgSend_eymsul( + this.ref.pointer, _sel_addData_, data.ref.pointer); + } + + /// getBoundStreamsWithBufferSize:inputStream:outputStream: + static void getBoundStreamsWithBufferSize_inputStream_outputStream_( + int bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_5r8xlx( + _class_DartInputStreamAdapter, + _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_, + bufferSize, + inputStream, + outputStream); + } + + /// getStreamsToHostWithName:port:inputStream:outputStream: + static void getStreamsToHostWithName_port_inputStream_outputStream_( + NSString hostname, + int port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_imc4v7( + _class_DartInputStreamAdapter, + _sel_getStreamsToHostWithName_port_inputStream_outputStream_, + hostname.ref.pointer, + port, + inputStream, + outputStream); + } + + /// initWithData: + DartInputStreamAdapter initWithData_(NSData data) { + final _ret = _objc_msgSend_juohf7(this.ref.retainAndReturnPointer(), + _sel_initWithData_, data.ref.pointer); + return DartInputStreamAdapter.castFromPointer(_ret, + retain: false, release: true); + } + + /// initWithFileAtPath: + DartInputStreamAdapter? initWithFileAtPath_(NSString path) { + final _ret = _objc_msgSend_juohf7(this.ref.retainAndReturnPointer(), + _sel_initWithFileAtPath_, path.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: false, release: true); + } + + /// initWithURL: + DartInputStreamAdapter? initWithURL_(NSURL url) { + final _ret = _objc_msgSend_juohf7( + this.ref.retainAndReturnPointer(), _sel_initWithURL_, url.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: false, release: true); + } + + /// inputStreamWithData: + static DartInputStreamAdapter? inputStreamWithData_(NSData data) { + final _ret = _objc_msgSend_juohf7(_class_DartInputStreamAdapter, + _sel_inputStreamWithData_, data.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: true, release: true); + } + + /// inputStreamWithFileAtPath: + static DartInputStreamAdapter? inputStreamWithFileAtPath_(NSString path) { + final _ret = _objc_msgSend_juohf7(_class_DartInputStreamAdapter, + _sel_inputStreamWithFileAtPath_, path.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: true, release: true); + } + + /// Creates the adapter. + /// @param sendPort A port to that is will receive two types of messages: + /// -1 => The `NSInputStream` has been closed and the port can be closed. + /// _ => The number of types being required in a `read:maxLength` call. + static DartInputStreamAdapter inputStreamWithPort_(int sendPort) { + final _ret = _objc_msgSend_n9eq1n( + _class_DartInputStreamAdapter, _sel_inputStreamWithPort_, sendPort); + return DartInputStreamAdapter.castFromPointer(_ret, + retain: true, release: true); + } + + /// inputStreamWithURL: + static DartInputStreamAdapter? inputStreamWithURL_(NSURL url) { + final _ret = _objc_msgSend_juohf7(_class_DartInputStreamAdapter, + _sel_inputStreamWithURL_, url.ref.pointer); + return _ret.address == 0 + ? null + : DartInputStreamAdapter.castFromPointer(_ret, + retain: true, release: true); + } + + /// setDone + void setDone() { + _objc_msgSend_ksby9f(this.ref.pointer, _sel_setDone); + } + + /// setError: + void setError_(NSError error) { + _objc_msgSend_ukcdfq(this.ref.pointer, _sel_setError_, error.ref.pointer); + } + + /// stream:handleEvent: + void stream_handleEvent_(NSStream aStream, NSStreamEvent eventCode) { + if (!objc.respondsToSelector(ref.pointer, _sel_stream_handleEvent_)) { + throw objc.UnimplementedOptionalMethodException( + 'DartInputStreamAdapter', 'stream:handleEvent:'); + } + _objc_msgSend_7zmbk4(this.ref.pointer, _sel_stream_handleEvent_, + aStream.ref.pointer, eventCode.value); + } +} + /// DartProxy class DartProxy extends NSProxy { DartProxy._(ffi.Pointer pointer, @@ -2787,6 +2954,126 @@ class NSIndexSet extends NSObject { } } +/// NSInputStream +class NSInputStream extends NSStream { + NSInputStream._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [NSInputStream] that points to the same underlying object as [other]. + NSInputStream.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSInputStream] that wraps the given raw object pointer. + NSInputStream.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [NSInputStream]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_l8lotg( + obj.ref.pointer, _sel_isKindOfClass_, _class_NSInputStream); + } + + /// getBoundStreamsWithBufferSize:inputStream:outputStream: + static void getBoundStreamsWithBufferSize_inputStream_outputStream_( + int bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_5r8xlx( + _class_NSInputStream, + _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_, + bufferSize, + inputStream, + outputStream); + } + + /// getBuffer:length: + bool getBuffer_length_(ffi.Pointer> buffer, + ffi.Pointer len) { + return _objc_msgSend_1vnalux( + this.ref.pointer, _sel_getBuffer_length_, buffer, len); + } + + /// getStreamsToHostWithName:port:inputStream:outputStream: + static void getStreamsToHostWithName_port_inputStream_outputStream_( + NSString hostname, + int port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_imc4v7( + _class_NSInputStream, + _sel_getStreamsToHostWithName_port_inputStream_outputStream_, + hostname.ref.pointer, + port, + inputStream, + outputStream); + } + + /// hasBytesAvailable + bool get hasBytesAvailable { + return _objc_msgSend_olxnu1(this.ref.pointer, _sel_hasBytesAvailable); + } + + /// initWithData: + NSInputStream initWithData_(NSData data) { + final _ret = _objc_msgSend_juohf7(this.ref.retainAndReturnPointer(), + _sel_initWithData_, data.ref.pointer); + return NSInputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithFileAtPath: + NSInputStream? initWithFileAtPath_(NSString path) { + final _ret = _objc_msgSend_juohf7(this.ref.retainAndReturnPointer(), + _sel_initWithFileAtPath_, path.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithURL: + NSInputStream? initWithURL_(NSURL url) { + final _ret = _objc_msgSend_juohf7( + this.ref.retainAndReturnPointer(), _sel_initWithURL_, url.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// inputStreamWithData: + static NSInputStream? inputStreamWithData_(NSData data) { + final _ret = _objc_msgSend_juohf7( + _class_NSInputStream, _sel_inputStreamWithData_, data.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// inputStreamWithFileAtPath: + static NSInputStream? inputStreamWithFileAtPath_(NSString path) { + final _ret = _objc_msgSend_juohf7(_class_NSInputStream, + _sel_inputStreamWithFileAtPath_, path.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// inputStreamWithURL: + static NSInputStream? inputStreamWithURL_(NSURL url) { + final _ret = _objc_msgSend_juohf7( + _class_NSInputStream, _sel_inputStreamWithURL_, url.ref.pointer); + return _ret.address == 0 + ? null + : NSInputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// read:maxLength: + int read_maxLength_(ffi.Pointer buffer, int len) { + return _objc_msgSend_1wopcqf( + this.ref.pointer, _sel_read_maxLength_, buffer, len); + } +} + /// NSInvocation class NSInvocation extends objc.ObjCObjectBase { NSInvocation._(ffi.Pointer pointer, @@ -7202,6 +7489,133 @@ class NSOrderedSet extends NSObject { } } +/// NSOutputStream +class NSOutputStream extends NSStream { + NSOutputStream._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [NSOutputStream] that points to the same underlying object as [other]. + NSOutputStream.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSOutputStream] that wraps the given raw object pointer. + NSOutputStream.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [NSOutputStream]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_l8lotg( + obj.ref.pointer, _sel_isKindOfClass_, _class_NSOutputStream); + } + + /// getBoundStreamsWithBufferSize:inputStream:outputStream: + static void getBoundStreamsWithBufferSize_inputStream_outputStream_( + int bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_5r8xlx( + _class_NSOutputStream, + _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_, + bufferSize, + inputStream, + outputStream); + } + + /// getStreamsToHostWithName:port:inputStream:outputStream: + static void getStreamsToHostWithName_port_inputStream_outputStream_( + NSString hostname, + int port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_imc4v7( + _class_NSOutputStream, + _sel_getStreamsToHostWithName_port_inputStream_outputStream_, + hostname.ref.pointer, + port, + inputStream, + outputStream); + } + + /// hasSpaceAvailable + bool get hasSpaceAvailable { + return _objc_msgSend_olxnu1(this.ref.pointer, _sel_hasSpaceAvailable); + } + + /// initToBuffer:capacity: + NSOutputStream initToBuffer_capacity_( + ffi.Pointer buffer, int capacity) { + final _ret = _objc_msgSend_pblopu(this.ref.retainAndReturnPointer(), + _sel_initToBuffer_capacity_, buffer, capacity); + return NSOutputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initToFileAtPath:append: + NSOutputStream? initToFileAtPath_append_(NSString path, bool shouldAppend) { + final _ret = _objc_msgSend_qqbb5y(this.ref.retainAndReturnPointer(), + _sel_initToFileAtPath_append_, path.ref.pointer, shouldAppend); + return _ret.address == 0 + ? null + : NSOutputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initToMemory + NSOutputStream initToMemory() { + final _ret = _objc_msgSend_1unuoxw( + this.ref.retainAndReturnPointer(), _sel_initToMemory); + return NSOutputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithURL:append: + NSOutputStream? initWithURL_append_(NSURL url, bool shouldAppend) { + final _ret = _objc_msgSend_qqbb5y(this.ref.retainAndReturnPointer(), + _sel_initWithURL_append_, url.ref.pointer, shouldAppend); + return _ret.address == 0 + ? null + : NSOutputStream.castFromPointer(_ret, retain: false, release: true); + } + + /// outputStreamToBuffer:capacity: + static NSOutputStream outputStreamToBuffer_capacity_( + ffi.Pointer buffer, int capacity) { + final _ret = _objc_msgSend_pblopu(_class_NSOutputStream, + _sel_outputStreamToBuffer_capacity_, buffer, capacity); + return NSOutputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// outputStreamToFileAtPath:append: + static NSOutputStream outputStreamToFileAtPath_append_( + NSString path, bool shouldAppend) { + final _ret = _objc_msgSend_qqbb5y(_class_NSOutputStream, + _sel_outputStreamToFileAtPath_append_, path.ref.pointer, shouldAppend); + return NSOutputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// outputStreamToMemory + static NSOutputStream outputStreamToMemory() { + final _ret = + _objc_msgSend_1unuoxw(_class_NSOutputStream, _sel_outputStreamToMemory); + return NSOutputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// outputStreamWithURL:append: + static NSOutputStream? outputStreamWithURL_append_( + NSURL url, bool shouldAppend) { + final _ret = _objc_msgSend_qqbb5y(_class_NSOutputStream, + _sel_outputStreamWithURL_append_, url.ref.pointer, shouldAppend); + return _ret.address == 0 + ? null + : NSOutputStream.castFromPointer(_ret, retain: true, release: true); + } + + /// write:maxLength: + int write_maxLength_(ffi.Pointer buffer, int len) { + return _objc_msgSend_1wopcqf( + this.ref.pointer, _sel_write_maxLength_, buffer, len); + } +} + /// NSProxy class NSProxy extends objc.ObjCObjectBase { NSProxy._(ffi.Pointer pointer, @@ -7381,6 +7795,28 @@ final class NSRange extends ffi.Struct { external int length; } +/// NSRunLoop +class NSRunLoop extends objc.ObjCObjectBase { + NSRunLoop._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super(pointer, retain: retain, release: release); + + /// Constructs a [NSRunLoop] that points to the same underlying object as [other]. + NSRunLoop.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSRunLoop] that wraps the given raw object pointer. + NSRunLoop.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [NSRunLoop]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_l8lotg( + obj.ref.pointer, _sel_isKindOfClass_, _class_NSRunLoop); + } +} + /// NSSet class NSSet extends NSObject { NSSet._(ffi.Pointer pointer, @@ -7702,6 +8138,226 @@ enum NSSortOptions { }; } +/// NSStream +class NSStream extends NSObject { + NSStream._(ffi.Pointer pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [NSStream] that points to the same underlying object as [other]. + NSStream.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSStream] that wraps the given raw object pointer. + NSStream.castFromPointer(ffi.Pointer other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [NSStream]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_l8lotg( + obj.ref.pointer, _sel_isKindOfClass_, _class_NSStream); + } + + /// alloc + static NSStream alloc() { + final _ret = _objc_msgSend_1unuoxw(_class_NSStream, _sel_alloc); + return NSStream.castFromPointer(_ret, retain: false, release: true); + } + + /// allocWithZone: + static NSStream allocWithZone_(ffi.Pointer<_NSZone> zone) { + final _ret = + _objc_msgSend_1b3ihd0(_class_NSStream, _sel_allocWithZone_, zone); + return NSStream.castFromPointer(_ret, retain: false, release: true); + } + + /// automaticallyNotifiesObserversForKey: + static bool automaticallyNotifiesObserversForKey_(NSString key) { + return _objc_msgSend_l8lotg(_class_NSStream, + _sel_automaticallyNotifiesObserversForKey_, key.ref.pointer); + } + + /// autorelease + NSStream autorelease() { + final _ret = _objc_msgSend_1unuoxw(this.ref.pointer, _sel_autorelease); + return NSStream.castFromPointer(_ret, retain: true, release: true); + } + + /// close + void close() { + _objc_msgSend_ksby9f(this.ref.pointer, _sel_close); + } + + /// delegate + objc.ObjCObjectBase? get delegate { + final _ret = _objc_msgSend_1unuoxw(this.ref.pointer, _sel_delegate); + return _ret.address == 0 + ? null + : objc.ObjCObjectBase(_ret, retain: true, release: true); + } + + /// getBoundStreamsWithBufferSize:inputStream:outputStream: + static void getBoundStreamsWithBufferSize_inputStream_outputStream_( + int bufferSize, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_5r8xlx( + _class_NSStream, + _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_, + bufferSize, + inputStream, + outputStream); + } + + /// getStreamsToHostWithName:port:inputStream:outputStream: + static void getStreamsToHostWithName_port_inputStream_outputStream_( + NSString hostname, + int port, + ffi.Pointer> inputStream, + ffi.Pointer> outputStream) { + _objc_msgSend_imc4v7( + _class_NSStream, + _sel_getStreamsToHostWithName_port_inputStream_outputStream_, + hostname.ref.pointer, + port, + inputStream, + outputStream); + } + + /// init + NSStream init() { + final _ret = + _objc_msgSend_1unuoxw(this.ref.retainAndReturnPointer(), _sel_init); + return NSStream.castFromPointer(_ret, retain: false, release: true); + } + + /// keyPathsForValuesAffectingValueForKey: + static NSSet keyPathsForValuesAffectingValueForKey_(NSString key) { + final _ret = _objc_msgSend_juohf7(_class_NSStream, + _sel_keyPathsForValuesAffectingValueForKey_, key.ref.pointer); + return NSSet.castFromPointer(_ret, retain: true, release: true); + } + + /// new + static NSStream new1() { + final _ret = _objc_msgSend_1unuoxw(_class_NSStream, _sel_new); + return NSStream.castFromPointer(_ret, retain: false, release: true); + } + + /// open + void open() { + _objc_msgSend_ksby9f(this.ref.pointer, _sel_open); + } + + /// propertyForKey: + objc.ObjCObjectBase? propertyForKey_(NSString key) { + final _ret = _objc_msgSend_juohf7( + this.ref.pointer, _sel_propertyForKey_, key.ref.pointer); + return _ret.address == 0 + ? null + : objc.ObjCObjectBase(_ret, retain: true, release: true); + } + + /// removeFromRunLoop:forMode: + void removeFromRunLoop_forMode_(NSRunLoop aRunLoop, NSString mode) { + _objc_msgSend_1tjlcwl(this.ref.pointer, _sel_removeFromRunLoop_forMode_, + aRunLoop.ref.pointer, mode.ref.pointer); + } + + /// retain + NSStream retain() { + final _ret = _objc_msgSend_1unuoxw(this.ref.pointer, _sel_retain); + return NSStream.castFromPointer(_ret, retain: true, release: true); + } + + /// scheduleInRunLoop:forMode: + void scheduleInRunLoop_forMode_(NSRunLoop aRunLoop, NSString mode) { + _objc_msgSend_1tjlcwl(this.ref.pointer, _sel_scheduleInRunLoop_forMode_, + aRunLoop.ref.pointer, mode.ref.pointer); + } + + /// self + NSStream self() { + final _ret = _objc_msgSend_1unuoxw(this.ref.pointer, _sel_self); + return NSStream.castFromPointer(_ret, retain: true, release: true); + } + + /// setDelegate: + set delegate(objc.ObjCObjectBase? value) { + return _objc_msgSend_ukcdfq( + this.ref.pointer, _sel_setDelegate_, value?.ref.pointer ?? ffi.nullptr); + } + + /// setProperty:forKey: + bool setProperty_forKey_(objc.ObjCObjectBase? property, NSString key) { + return _objc_msgSend_1ywe6ev(this.ref.pointer, _sel_setProperty_forKey_, + property?.ref.pointer ?? ffi.nullptr, key.ref.pointer); + } + + /// streamError + NSError? get streamError { + final _ret = _objc_msgSend_1unuoxw(this.ref.pointer, _sel_streamError); + return _ret.address == 0 + ? null + : NSError.castFromPointer(_ret, retain: true, release: true); + } + + /// streamStatus + NSStreamStatus get streamStatus { + final _ret = _objc_msgSend_1pu7ifu(this.ref.pointer, _sel_streamStatus); + return NSStreamStatus.fromValue(_ret); + } +} + +enum NSStreamEvent { + NSStreamEventNone(0), + NSStreamEventOpenCompleted(1), + NSStreamEventHasBytesAvailable(2), + NSStreamEventHasSpaceAvailable(4), + NSStreamEventErrorOccurred(8), + NSStreamEventEndEncountered(16); + + final int value; + const NSStreamEvent(this.value); + + static NSStreamEvent fromValue(int value) => switch (value) { + 0 => NSStreamEventNone, + 1 => NSStreamEventOpenCompleted, + 2 => NSStreamEventHasBytesAvailable, + 4 => NSStreamEventHasSpaceAvailable, + 8 => NSStreamEventErrorOccurred, + 16 => NSStreamEventEndEncountered, + _ => throw ArgumentError("Unknown value for NSStreamEvent: $value"), + }; +} + +enum NSStreamStatus { + NSStreamStatusNotOpen(0), + NSStreamStatusOpening(1), + NSStreamStatusOpen(2), + NSStreamStatusReading(3), + NSStreamStatusWriting(4), + NSStreamStatusAtEnd(5), + NSStreamStatusClosed(6), + NSStreamStatusError(7); + + final int value; + const NSStreamStatus(this.value); + + static NSStreamStatus fromValue(int value) => switch (value) { + 0 => NSStreamStatusNotOpen, + 1 => NSStreamStatusOpening, + 2 => NSStreamStatusOpen, + 3 => NSStreamStatusReading, + 4 => NSStreamStatusWriting, + 5 => NSStreamStatusAtEnd, + 6 => NSStreamStatusClosed, + 7 => NSStreamStatusError, + _ => throw ArgumentError("Unknown value for NSStreamStatus: $value"), + }; +} + /// NSString class NSString extends NSObject { factory NSString(String str) { @@ -11377,6 +12033,173 @@ extension ObjCBlock_ffiVoid_ffiVoid_NSCoder_CallExtension ref.pointer, arg0, arg1.ref.pointer); } +void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.UnsignedLong arg2)>>() + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, + int)>()(arg0, arg1, arg2); +ffi.Pointer + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer, + ffi.Pointer, int))(arg0, arg1, arg2); +ffi.Pointer + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2) { + (objc.getBlockClosure(block) as void Function(ffi.Pointer, + ffi.Pointer, int))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)> + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>.listener( + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock, NSStream, ffi.UnsignedLong)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSStream, ffi.UnsignedLong)> + castFromPointer(ffi.Pointer pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSStream, + ffi.UnsignedLong)>(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc + .ObjCBlock, NSStream, ffi.UnsignedLong)> + fromFunctionPointer( + ffi.Pointer arg0, ffi.Pointer arg1, ffi.UnsignedLong arg2)>> + ptr) => + objc.ObjCBlock, NSStream, ffi.UnsignedLong)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_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. + static objc.ObjCBlock, NSStream, ffi.UnsignedLong)> fromFunction( + void Function(ffi.Pointer, NSStream, NSStreamEvent) fn) => + objc.ObjCBlock, NSStream, ffi.UnsignedLong)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureCallable, + (ffi.Pointer arg0, ffi.Pointer arg1, + int arg2) => + fn( + arg0, + NSStream.castFromPointer(arg1, retain: true, release: true), + NSStreamEvent.fromValue(arg2))), + 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. + /// + /// Note that unlike the default behavior of NativeCallable.listener, listener + /// blocks do not keep the isolate alive. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSStream, ffi.UnsignedLong)> + listener( + void Function(ffi.Pointer, NSStream, NSStreamEvent) fn) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerCallable + .nativeFunction + .cast(), + (ffi.Pointer arg0, ffi.Pointer arg1, + int arg2) => + fn( + arg0, + NSStream.castFromPointer(arg1, retain: false, release: true), + NSStreamEvent.fromValue(arg2))); + final wrapper = _wrapListenerBlock_m1viep(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSStream, + ffi.UnsignedLong)>(wrapper, retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock, NSStream, ffi.UnsignedLong)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_CallExtension + on objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSStream, ffi.UnsignedLong)> { + void call(ffi.Pointer arg0, NSStream arg1, NSStreamEvent arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.UnsignedLong arg2)>>() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int)>()(ref.pointer, arg0, arg1.ref.pointer, arg2.value); +} + instancetype _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrTrampoline( ffi.Pointer block, ffi.Pointer arg0, @@ -12252,6 +13075,8 @@ class Protocol extends objc.ObjCObjectBase { final class _NSZone extends ffi.Opaque {} +late final _class_DartInputStreamAdapter = + objc.getClass("DartInputStreamAdapter"); late final _class_DartProxy = objc.getClass("DartProxy"); late final _class_DartProxyBuilder = objc.getClass("DartProxyBuilder"); late final _class_NSArray = objc.getClass("NSArray"); @@ -12263,6 +13088,7 @@ late final _class_NSDictionary = objc.getClass("NSDictionary"); late final _class_NSEnumerator = objc.getClass("NSEnumerator"); late final _class_NSError = objc.getClass("NSError"); late final _class_NSIndexSet = objc.getClass("NSIndexSet"); +late final _class_NSInputStream = objc.getClass("NSInputStream"); late final _class_NSInvocation = objc.getClass("NSInvocation"); late final _class_NSItemProvider = objc.getClass("NSItemProvider"); late final _class_NSLocale = objc.getClass("NSLocale"); @@ -12278,8 +13104,11 @@ late final _class_NSNotification = objc.getClass("NSNotification"); late final _class_NSNumber = objc.getClass("NSNumber"); late final _class_NSObject = objc.getClass("NSObject"); late final _class_NSOrderedSet = objc.getClass("NSOrderedSet"); +late final _class_NSOutputStream = objc.getClass("NSOutputStream"); late final _class_NSProxy = objc.getClass("NSProxy"); +late final _class_NSRunLoop = objc.getClass("NSRunLoop"); late final _class_NSSet = objc.getClass("NSSet"); +late final _class_NSStream = objc.getClass("NSStream"); late final _class_NSString = objc.getClass("NSString"); late final _class_NSURL = objc.getClass("NSURL"); late final _class_NSURLHandle = objc.getClass("NSURLHandle"); @@ -13067,6 +13896,14 @@ final _objc_msgSend_1pmj399 = objc.msgSendPointer .asFunction< ffi.Pointer Function(ffi.Pointer, ffi.Pointer, double)>(); +final _objc_msgSend_1pu7ifu = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function(ffi.Pointer, + ffi.Pointer)>>() + .asFunction< + int Function( + ffi.Pointer, ffi.Pointer)>(); final _objc_msgSend_1qfg2kn = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -13224,6 +14061,20 @@ final _objc_msgSend_1upz917 = objc.msgSendPointer .asFunction< ffi.Pointer Function(ffi.Pointer, ffi.Pointer, bool)>(); +final _objc_msgSend_1vnalux = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>>() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>(); final _objc_msgSend_1wjxqnx = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -13258,6 +14109,17 @@ final _objc_msgSend_1wjxqnxStret = objc.msgSendStretPointer ffi.Pointer, int, NSRange)>(); +final _objc_msgSend_1wopcqf = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>() + .asFunction< + int Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); final _objc_msgSend_1x7hfdx = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -13352,6 +14214,20 @@ final _objc_msgSend_1ypnhm3 = objc.msgSendPointer .asFunction< ffi.Pointer Function( ffi.Pointer, ffi.Pointer)>(); +final _objc_msgSend_1ywe6ev = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); final _objc_msgSend_2n95es = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -13400,6 +14276,22 @@ final _objc_msgSend_5ns8s6 = objc.msgSendPointer .asFunction< void Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); +final _objc_msgSend_5r8xlx = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer>, + ffi.Pointer>)>>() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>)>(); final _objc_msgSend_6ka9sp = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -13450,6 +14342,20 @@ final _objc_msgSend_6toz8x = objc.msgSendPointer ffi.Pointer, ffi.Pointer, ffi.Pointer>)>(); +final _objc_msgSend_7zmbk4 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int)>(); final _objc_msgSend_85e5ih = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -13792,6 +14698,24 @@ final _objc_msgSend_hyhdx3 = objc.msgSendPointer ffi.Pointer, NSRange, bool)>(); +final _objc_msgSend_imc4v7 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ffi.Pointer>, + ffi.Pointer>)>>() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>)>(); final _objc_msgSend_iq11qg = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -14026,6 +14950,14 @@ final _objc_msgSend_n73nlr = objc.msgSendPointer ffi.Pointer, int, NSRange)>(); +final _objc_msgSend_n9eq1n = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function(ffi.Pointer, + ffi.Pointer, ffi.Int64)>>() + .asFunction< + instancetype Function(ffi.Pointer, + ffi.Pointer, int)>(); final _objc_msgSend_nbaahq = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -14122,6 +15054,17 @@ final _objc_msgSend_p02k6o = objc.msgSendPointer ffi.Pointer, ffi.Pointer, ffi.Pointer>)>(); +final _objc_msgSend_pblopu = objc.msgSendPointer + .cast< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>>() + .asFunction< + instancetype Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); final _objc_msgSend_pxgym4 = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -14540,6 +15483,7 @@ late final _sel_absoluteString = objc.registerName("absoluteString"); late final _sel_absoluteURL = objc.registerName("absoluteURL"); late final _sel_absoluteURLWithDataRepresentation_relativeToURL_ = objc.registerName("absoluteURLWithDataRepresentation:relativeToURL:"); +late final _sel_addData_ = objc.registerName("addData:"); late final _sel_addEntriesFromDictionary_ = objc.registerName("addEntriesFromDictionary:"); late final _sel_addIndex_ = objc.registerName("addIndex:"); @@ -14647,6 +15591,7 @@ late final _sel_checkResourceIsReachableAndReturnError_ = objc.registerName("checkResourceIsReachableAndReturnError:"); late final _sel_class = objc.registerName("class"); late final _sel_classForCoder = objc.registerName("classForCoder"); +late final _sel_close = objc.registerName("close"); late final _sel_code = objc.registerName("code"); late final _sel_commonPrefixWithString_options_ = objc.registerName("commonPrefixWithString:options:"); @@ -14730,6 +15675,7 @@ late final _sel_decompressedDataUsingAlgorithm_error_ = objc.registerName("decompressedDataUsingAlgorithm:error:"); late final _sel_defaultCStringEncoding = objc.registerName("defaultCStringEncoding"); +late final _sel_delegate = objc.registerName("delegate"); late final _sel_deleteCharactersInRange_ = objc.registerName("deleteCharactersInRange:"); late final _sel_description = objc.registerName("description"); @@ -14816,6 +15762,9 @@ late final _sel_fragment = objc.registerName("fragment"); late final _sel_frameLength = objc.registerName("frameLength"); late final _sel_getArgumentTypeAtIndex_ = objc.registerName("getArgumentTypeAtIndex:"); +late final _sel_getBoundStreamsWithBufferSize_inputStream_outputStream_ = objc + .registerName("getBoundStreamsWithBufferSize:inputStream:outputStream:"); +late final _sel_getBuffer_length_ = objc.registerName("getBuffer:length:"); late final _sel_getBytes_length_ = objc.registerName("getBytes:length:"); late final _sel_getBytes_maxLength_usedLength_encoding_options_range_remainingRange_ = objc.registerName( @@ -14841,8 +15790,11 @@ late final _sel_getPromisedItemResourceValue_forKey_error_ = objc.registerName("getPromisedItemResourceValue:forKey:error:"); late final _sel_getResourceValue_forKey_error_ = objc.registerName("getResourceValue:forKey:error:"); +late final _sel_getStreamsToHostWithName_port_inputStream_outputStream_ = objc + .registerName("getStreamsToHostWithName:port:inputStream:outputStream:"); late final _sel_getValue_ = objc.registerName("getValue:"); late final _sel_getValue_size_ = objc.registerName("getValue:size:"); +late final _sel_hasBytesAvailable = objc.registerName("hasBytesAvailable"); late final _sel_hasDirectoryPath = objc.registerName("hasDirectoryPath"); late final _sel_hasItemConformingToTypeIdentifier_ = objc.registerName("hasItemConformingToTypeIdentifier:"); @@ -14850,6 +15802,7 @@ late final _sel_hasMemberInPlane_ = objc.registerName("hasMemberInPlane:"); late final _sel_hasPrefix_ = objc.registerName("hasPrefix:"); late final _sel_hasRepresentationConformingToTypeIdentifier_fileOptions_ = objc .registerName("hasRepresentationConformingToTypeIdentifier:fileOptions:"); +late final _sel_hasSpaceAvailable = objc.registerName("hasSpaceAvailable"); late final _sel_hasSuffix_ = objc.registerName("hasSuffix:"); late final _sel_hash = objc.registerName("hash"); late final _sel_helpAnchor = objc.registerName("helpAnchor"); @@ -14894,6 +15847,11 @@ late final _sel_initFileURLWithPath_isDirectory_relativeToURL_ = late final _sel_initFileURLWithPath_relativeToURL_ = objc.registerName("initFileURLWithPath:relativeToURL:"); late final _sel_initFromBuilder_ = objc.registerName("initFromBuilder:"); +late final _sel_initToBuffer_capacity_ = + objc.registerName("initToBuffer:capacity:"); +late final _sel_initToFileAtPath_append_ = + objc.registerName("initToFileAtPath:append:"); +late final _sel_initToMemory = objc.registerName("initToMemory"); late final _sel_initWithArray_ = objc.registerName("initWithArray:"); late final _sel_initWithArray_copyItems_ = objc.registerName("initWithArray:copyItems:"); @@ -14954,6 +15912,7 @@ late final _sel_initWithDictionary_copyItems_ = late final _sel_initWithDomain_code_userInfo_ = objc.registerName("initWithDomain:code:userInfo:"); late final _sel_initWithDouble_ = objc.registerName("initWithDouble:"); +late final _sel_initWithFileAtPath_ = objc.registerName("initWithFileAtPath:"); late final _sel_initWithFloat_ = objc.registerName("initWithFloat:"); late final _sel_initWithFormat_ = objc.registerName("initWithFormat:"); late final _sel_initWithFormat_locale_ = @@ -15003,6 +15962,8 @@ late final _sel_initWithTimeIntervalSinceReferenceDate_ = objc.registerName("initWithTimeIntervalSinceReferenceDate:"); late final _sel_initWithTimeInterval_sinceDate_ = objc.registerName("initWithTimeInterval:sinceDate:"); +late final _sel_initWithURL_ = objc.registerName("initWithURL:"); +late final _sel_initWithURL_append_ = objc.registerName("initWithURL:append:"); late final _sel_initWithUTF8String_ = objc.registerName("initWithUTF8String:"); late final _sel_initWithUnsignedChar_ = objc.registerName("initWithUnsignedChar:"); @@ -15022,6 +15983,13 @@ late final _sel_initWithValidatedFormat_validFormatSpecifiers_locale_error_ = objc.registerName( "initWithValidatedFormat:validFormatSpecifiers:locale:error:"); late final _sel_initialize = objc.registerName("initialize"); +late final _sel_inputStreamWithData_ = + objc.registerName("inputStreamWithData:"); +late final _sel_inputStreamWithFileAtPath_ = + objc.registerName("inputStreamWithFileAtPath:"); +late final _sel_inputStreamWithPort_ = + objc.registerName("inputStreamWithPort:"); +late final _sel_inputStreamWithURL_ = objc.registerName("inputStreamWithURL:"); late final _sel_insertObject_atIndex_ = objc.registerName("insertObject:atIndex:"); late final _sel_insertObjects_atIndexes_ = @@ -15200,6 +16168,7 @@ late final _sel_objectsForKeys_notFoundMarker_ = late final _sel_observationInfo = objc.registerName("observationInfo"); late final _sel_observeValueForKeyPath_ofObject_change_context_ = objc.registerName("observeValueForKeyPath:ofObject:change:context:"); +late final _sel_open = objc.registerName("open"); late final _sel_orderedSet = objc.registerName("orderedSet"); late final _sel_orderedSetByApplyingDifference_ = objc.registerName("orderedSetByApplyingDifference:"); @@ -15222,6 +16191,14 @@ late final _sel_orderedSetWithOrderedSet_range_copyItems_ = late final _sel_orderedSetWithSet_ = objc.registerName("orderedSetWithSet:"); late final _sel_orderedSetWithSet_copyItems_ = objc.registerName("orderedSetWithSet:copyItems:"); +late final _sel_outputStreamToBuffer_capacity_ = + objc.registerName("outputStreamToBuffer:capacity:"); +late final _sel_outputStreamToFileAtPath_append_ = + objc.registerName("outputStreamToFileAtPath:append:"); +late final _sel_outputStreamToMemory = + objc.registerName("outputStreamToMemory"); +late final _sel_outputStreamWithURL_append_ = + objc.registerName("outputStreamWithURL:append:"); late final _sel_paragraphRangeForRange_ = objc.registerName("paragraphRangeForRange:"); late final _sel_parameterString = objc.registerName("parameterString"); @@ -15242,6 +16219,7 @@ late final _sel_precomposedStringWithCompatibilityMapping = objc.registerName("precomposedStringWithCompatibilityMapping"); late final _sel_promisedItemResourceValuesForKeys_error_ = objc.registerName("promisedItemResourceValuesForKeys:error:"); +late final _sel_propertyForKey_ = objc.registerName("propertyForKey:"); late final _sel_propertyList = objc.registerName("propertyList"); late final _sel_propertyListFromStringsFileFormat = objc.registerName("propertyListFromStringsFileFormat"); @@ -15268,6 +16246,7 @@ late final _sel_rangeOfString_options_range_ = late final _sel_rangeOfString_options_range_locale_ = objc.registerName("rangeOfString:options:range:locale:"); late final _sel_rangeValue = objc.registerName("rangeValue"); +late final _sel_read_maxLength_ = objc.registerName("read:maxLength:"); late final _sel_readableTypeIdentifiersForItemProvider = objc.registerName("readableTypeIdentifiersForItemProvider"); late final _sel_recoveryAttempter = objc.registerName("recoveryAttempter"); @@ -15286,6 +16265,8 @@ late final _sel_removeAllIndexes = objc.registerName("removeAllIndexes"); late final _sel_removeAllObjects = objc.registerName("removeAllObjects"); late final _sel_removeCachedResourceValueForKey_ = objc.registerName("removeCachedResourceValueForKey:"); +late final _sel_removeFromRunLoop_forMode_ = + objc.registerName("removeFromRunLoop:forMode:"); late final _sel_removeIndex_ = objc.registerName("removeIndex:"); late final _sel_removeIndexesInRange_ = objc.registerName("removeIndexesInRange:"); @@ -15352,6 +16333,8 @@ late final _sel_retainCount = objc.registerName("retainCount"); late final _sel_reverseObjectEnumerator = objc.registerName("reverseObjectEnumerator"); late final _sel_reversedOrderedSet = objc.registerName("reversedOrderedSet"); +late final _sel_scheduleInRunLoop_forMode_ = + objc.registerName("scheduleInRunLoop:forMode:"); late final _sel_scheme = objc.registerName("scheme"); late final _sel_self = objc.registerName("self"); late final _sel_set = objc.registerName("set"); @@ -15362,7 +16345,10 @@ late final _sel_setByAddingObjectsFromArray_ = late final _sel_setByAddingObjectsFromSet_ = objc.registerName("setByAddingObjectsFromSet:"); late final _sel_setData_ = objc.registerName("setData:"); +late final _sel_setDelegate_ = objc.registerName("setDelegate:"); late final _sel_setDictionary_ = objc.registerName("setDictionary:"); +late final _sel_setDone = objc.registerName("setDone"); +late final _sel_setError_ = objc.registerName("setError:"); late final _sel_setLength_ = objc.registerName("setLength:"); late final _sel_setObject_atIndex_ = objc.registerName("setObject:atIndex:"); late final _sel_setObject_atIndexedSubscript_ = @@ -15371,6 +16357,7 @@ late final _sel_setObject_forKey_ = objc.registerName("setObject:forKey:"); late final _sel_setObject_forKeyedSubscript_ = objc.registerName("setObject:forKeyedSubscript:"); late final _sel_setObservationInfo_ = objc.registerName("setObservationInfo:"); +late final _sel_setProperty_forKey_ = objc.registerName("setProperty:forKey:"); late final _sel_setResourceValue_forKey_error_ = objc.registerName("setResourceValue:forKey:error:"); late final _sel_setResourceValues_error_ = @@ -15411,6 +16398,9 @@ late final _sel_startAccessingSecurityScopedResource = objc.registerName("startAccessingSecurityScopedResource"); late final _sel_stopAccessingSecurityScopedResource = objc.registerName("stopAccessingSecurityScopedResource"); +late final _sel_streamError = objc.registerName("streamError"); +late final _sel_streamStatus = objc.registerName("streamStatus"); +late final _sel_stream_handleEvent_ = objc.registerName("stream:handleEvent:"); late final _sel_string = objc.registerName("string"); late final _sel_stringByAddingPercentEncodingWithAllowedCharacters_ = objc.registerName("stringByAddingPercentEncodingWithAllowedCharacters:"); @@ -15529,6 +16519,7 @@ late final _sel_writeToURL_atomically_encoding_error_ = late final _sel_writeToURL_error_ = objc.registerName("writeToURL:error:"); late final _sel_writeToURL_options_error_ = objc.registerName("writeToURL:options:error:"); +late final _sel_write_maxLength_ = objc.registerName("write:maxLength:"); late final _sel_zone = objc.registerName("zone"); typedef instancetype = ffi.Pointer; typedef Dartinstancetype = objc.ObjCObjectBase; diff --git a/pkgs/objective_c/src/objective_c_bindings_generated.m b/pkgs/objective_c/src/objective_c_bindings_generated.m index 01874b672..9237ca7be 100644 --- a/pkgs/objective_c/src/objective_c_bindings_generated.m +++ b/pkgs/objective_c/src/objective_c_bindings_generated.m @@ -1,5 +1,6 @@ #include #import "foundation.h" +#import "input_stream_adapter.h" #import "proxy.h" #if !__has_feature(objc_arc) @@ -24,3 +25,11 @@ _ListenerTrampoline1 _wrapListenerBlock_sjfpmz(_ListenerTrampoline1 block) NS_RE block(arg0, objc_retain(arg1)); }; } + +typedef void (^_ListenerTrampoline2)(void * arg0, id arg1, NSStreamEvent arg2); +_ListenerTrampoline2 _wrapListenerBlock_m1viep(_ListenerTrampoline2 block) NS_RETURNS_RETAINED { + return ^void(void * arg0, id arg1, NSStreamEvent arg2) { + objc_retainBlock(block); + block(arg0, objc_retain(arg1), arg2); + }; +} From 58937962f6f76f2bf3fe70410848db5458e247af Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 11:25:00 -0700 Subject: [PATCH 08/38] Fix --- pkgs/objective_c/test/interface_lists_test.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/objective_c/test/interface_lists_test.dart b/pkgs/objective_c/test/interface_lists_test.dart index 3d4c2d567..a0aade8d1 100644 --- a/pkgs/objective_c/test/interface_lists_test.dart +++ b/pkgs/objective_c/test/interface_lists_test.dart @@ -12,6 +12,8 @@ import 'package:ffigen/src/code_generator/objc_built_in_functions.dart'; import 'package:test/test.dart'; import 'package:yaml/yaml.dart'; +const privateObjectiveCClasses = ['DartInputStreamAdapter']; + void main() { group('Verify interface lists', () { late List yamlInterfaces; @@ -53,7 +55,9 @@ void main() { test('package:objective_c exports all the interfaces', () { final exportFile = File('lib/objective_c.dart').readAsStringSync(); for (final intf in yamlInterfaces) { - expect(exportFile, contains(intf)); + if (!privateObjectiveCClasses.contains(intf)) { + expect(exportFile, contains(intf)); + } } }); @@ -109,12 +113,11 @@ void main() { for (final line in File('lib/src/objective_c_bindings_generated.dart') .readAsLinesSync()) { final match = enumNameRegExp.firstMatch(line); - if (match != null) { + if (match != null && !privateObjectiveCClasses.contains(match[1])) { allEnumNames.add(match[1]!); } } - allEnumNames.sort(); - expect(allEnumNames, yamlEnums); + expect(allEnumNames, unorderedEquals(yamlEnums)); }); }); } From 78f8bba52333c811c5f53dc4f46d4d2b62842f54 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 13:29:14 -0700 Subject: [PATCH 09/38] Fixes --- pkgs/objective_c/ios/Classes/objective_c.m | 1 + pkgs/objective_c/lib/src/ns_input_stream.dart | 10 ++++++---- pkgs/objective_c/macos/Classes/objective_c.m | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/objective_c/ios/Classes/objective_c.m b/pkgs/objective_c/ios/Classes/objective_c.m index 545adba1f..9de5e7eea 100644 --- a/pkgs/objective_c/ios/Classes/objective_c.m +++ b/pkgs/objective_c/ios/Classes/objective_c.m @@ -4,5 +4,6 @@ // Relative import to be able to reuse the ObjC sources. // See the comment in ../objective_c.podspec for more information. +#include "../../src/input_stream_adapter.m" #include "../../src/objective_c_bindings_generated.m" #include "../../src/proxy.m" diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index 704b73073..b2dbaf6fe 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -11,10 +11,10 @@ extension NSInputStreamStreamExtension on Stream> { /// the [Stream]. /// /// > [!IMPORTANT] - /// > [NSInputStream.read_maxLength_] must called called from a different - /// > thread or [Isolate] than the one that calls [toNSInputStream]. - /// > Otherwise, [NSInputStream.read_maxLength_] will deadlock waiting for - /// > data to be added from the [Stream]. + /// > [NSInputStream.read_maxLength_] must be called from a different thread + /// > or [Isolate] than the one that calls [toNSInputStream]. Otherwise, + /// > [NSInputStream.read_maxLength_] will deadlock waiting for data to be + /// > added from the [Stream]. NSInputStream toNSInputStream() { // Eagerly add data until `maxReadAheadSize` is buffered. const maxReadAheadSize = 4096; @@ -37,6 +37,8 @@ extension NSInputStreamStreamExtension on Stream> { dataSubscription.pause(); port.listen((count) { + // -1 indicates that the `NSInputStream` is closed. All other values + // indicate that the `NSInputStream` needs more data. if (count == -1) { dataSubscription.cancel(); port.close(); diff --git a/pkgs/objective_c/macos/Classes/objective_c.m b/pkgs/objective_c/macos/Classes/objective_c.m index 545adba1f..9de5e7eea 100644 --- a/pkgs/objective_c/macos/Classes/objective_c.m +++ b/pkgs/objective_c/macos/Classes/objective_c.m @@ -4,5 +4,6 @@ // Relative import to be able to reuse the ObjC sources. // See the comment in ../objective_c.podspec for more information. +#include "../../src/input_stream_adapter.m" #include "../../src/objective_c_bindings_generated.m" #include "../../src/proxy.m" From d40f878b638269d28877bf57955b2fd2f7e32784 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 14:00:41 -0700 Subject: [PATCH 10/38] Update objective_c.yaml --- .github/workflows/objective_c.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/objective_c.yaml b/.github/workflows/objective_c.yaml index d6ca3f834..13120bd62 100644 --- a/.github/workflows/objective_c.yaml +++ b/.github/workflows/objective_c.yaml @@ -31,7 +31,6 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 with: - flutter-version: 3.19.0 channel: 'stable' - id: install name: Install dependencies @@ -53,7 +52,6 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 with: - flutter-version: 3.19.0 channel: 'stable' - name: Install dependencies run: flutter pub get @@ -90,7 +88,6 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 with: - flutter-version: 3.19.0 channel: 'stable' - name: Install dependencies run: flutter pub get From a0b57691f77319a6db097704c0af2187bf61f87e Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 14:47:55 -0700 Subject: [PATCH 11/38] Update ns_input_stream.dart --- pkgs/objective_c/lib/src/ns_input_stream.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index b2dbaf6fe..e268c0ec6 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -24,11 +24,14 @@ extension NSInputStreamStreamExtension on Stream> { DartInputStreamAdapter.inputStreamWithPort_(port.sendPort.nativePort); late final StreamSubscription dataSubscription; + print('Here1'); dataSubscription = listen((data) { if (inputStream.addData_(data.toNSData()) > maxReadAheadSize) { + print('pause'); dataSubscription.pause(); } }, onError: (Object e) { + print('error'); final d = NSMutableDictionary.new1(); d.setObject_forKey_(e.toString().toNSString(), NSLocalizedDescriptionKey); inputStream.setError_(NSError.errorWithDomain_code_userInfo_( @@ -37,6 +40,7 @@ extension NSInputStreamStreamExtension on Stream> { dataSubscription.pause(); port.listen((count) { + print('count: $count'); // -1 indicates that the `NSInputStream` is closed. All other values // indicate that the `NSInputStream` needs more data. if (count == -1) { From c7c5c3554501508e93b50eaf2af8df0c2ee34c80 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 15:17:03 -0700 Subject: [PATCH 12/38] Update ns_input_stream.dart --- pkgs/objective_c/lib/src/ns_input_stream.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index e268c0ec6..968f26019 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -26,6 +26,7 @@ extension NSInputStreamStreamExtension on Stream> { print('Here1'); dataSubscription = listen((data) { + print('data: $data'); if (inputStream.addData_(data.toNSData()) > maxReadAheadSize) { print('pause'); dataSubscription.pause(); @@ -47,6 +48,7 @@ extension NSInputStreamStreamExtension on Stream> { dataSubscription.cancel(); port.close(); } else { + print('Resuming'); dataSubscription.resume(); } }, onDone: dataSubscription.cancel); From a02e72910fa9dbb96d9d02766b63d973036920b3 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 15:31:54 -0700 Subject: [PATCH 13/38] Update ns_input_stream.dart --- pkgs/objective_c/lib/src/ns_input_stream.dart | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index 968f26019..792ae5b2a 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -40,18 +40,20 @@ extension NSInputStreamStreamExtension on Stream> { }, onDone: inputStream.setDone, cancelOnError: true); dataSubscription.pause(); - port.listen((count) { - print('count: $count'); - // -1 indicates that the `NSInputStream` is closed. All other values - // indicate that the `NSInputStream` needs more data. - if (count == -1) { - dataSubscription.cancel(); - port.close(); - } else { - print('Resuming'); - dataSubscription.resume(); - } - }, onDone: dataSubscription.cancel); + port.listen( + (count) { + print('count: $count'); + // -1 indicates that the `NSInputStream` is closed. All other values + // indicate that the `NSInputStream` needs more data. + if (count == -1) { + dataSubscription.cancel(); + port.close(); + } else { + print('Resuming'); + dataSubscription.resume(); + } + }, /*onDone: dataSubscription.cancel*/ + ); return inputStream; } From a34f3c8b3ada25835f1b3b6ab3449f4c6d898d51 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 15:38:28 -0700 Subject: [PATCH 14/38] Update ns_input_stream.dart --- pkgs/objective_c/lib/src/ns_input_stream.dart | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index 792ae5b2a..aada01740 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -37,23 +37,27 @@ extension NSInputStreamStreamExtension on Stream> { d.setObject_forKey_(e.toString().toNSString(), NSLocalizedDescriptionKey); inputStream.setError_(NSError.errorWithDomain_code_userInfo_( 'DartError'.toNSString(), 0, d)); - }, onDone: inputStream.setDone, cancelOnError: true); + }, onDone: () { + inputStream.setDone(); + print('Stream done'); + }, cancelOnError: true); dataSubscription.pause(); - port.listen( - (count) { - print('count: $count'); - // -1 indicates that the `NSInputStream` is closed. All other values - // indicate that the `NSInputStream` needs more data. - if (count == -1) { - dataSubscription.cancel(); - port.close(); - } else { - print('Resuming'); - dataSubscription.resume(); - } - }, /*onDone: dataSubscription.cancel*/ - ); + port.listen((count) { + print('count: $count'); + // -1 indicates that the `NSInputStream` is closed. All other values + // indicate that the `NSInputStream` needs more data. + if (count == -1) { + dataSubscription.cancel(); + port.close(); + } else { + print('Resuming'); + dataSubscription.resume(); + } + }, onDone: () { + dataSubscription.cancel(); + print('port done'); + }); return inputStream; } From f9abb113a3a5fd8bd26a9233692cd63a76e43462 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 16:11:22 -0700 Subject: [PATCH 15/38] Update ns_input_stream.dart --- pkgs/objective_c/lib/src/ns_input_stream.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index aada01740..14e63fda1 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -39,6 +39,7 @@ extension NSInputStreamStreamExtension on Stream> { 'DartError'.toNSString(), 0, d)); }, onDone: () { inputStream.setDone(); + port.close(); print('Stream done'); }, cancelOnError: true); From 3147c62756ebd3aad5ab6cd297f4d9f449457f2d Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 16:27:20 -0700 Subject: [PATCH 16/38] Update ns_input_stream_test.dart --- pkgs/objective_c/test/ns_input_stream_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index ac7ac4348..ef5fed8ea 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -21,7 +21,9 @@ Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( NSInputStream stream, int size) { return Isolate.run(() => using((arena) { final buffer = arena(size); + print('Starting read'); final readSize = stream.read_maxLength_(buffer, size); + print('Read complete'); final data = Uint8List.fromList( buffer.asTypedList(readSize == -1 ? 0 : readSize)); return ( From 51ad42bae9e882feff5504b435b6caf41e746faa Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 16:44:40 -0700 Subject: [PATCH 17/38] Update ns_input_stream_test.dart --- pkgs/objective_c/test/ns_input_stream_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index ef5fed8ea..a36b35315 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -21,7 +21,7 @@ Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( NSInputStream stream, int size) { return Isolate.run(() => using((arena) { final buffer = arena(size); - print('Starting read'); + print('Starting read: $size'); final readSize = stream.read_maxLength_(buffer, size); print('Read complete'); final data = Uint8List.fromList( From 2f145e893cb049a19bcacc3238d4a869e5b039b4 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 17:31:03 -0700 Subject: [PATCH 18/38] More tries --- pkgs/objective_c/lib/src/ns_input_stream.dart | 1 + pkgs/objective_c/src/input_stream_adapter.m | 8 +++++--- pkgs/objective_c/test/ns_input_stream_test.dart | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index 14e63fda1..ecabc185d 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -37,6 +37,7 @@ extension NSInputStreamStreamExtension on Stream> { d.setObject_forKey_(e.toString().toNSString(), NSLocalizedDescriptionKey); inputStream.setError_(NSError.errorWithDomain_code_userInfo_( 'DartError'.toNSString(), 0, d)); + port.close(); }, onDone: () { inputStream.setDone(); port.close(); diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m index e2d47dc17..b41ff86e4 100644 --- a/pkgs/objective_c/src/input_stream_adapter.m +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -70,8 +70,10 @@ - (void)open { - (void)close { [_dataCondition lock]; _status = NSStreamStatusClosed; - const bool success = Dart_PostInteger_DL(_sendPort, -1); - NSCAssert(success, @"Dart_PostCObject_DL failed."); + if (!_done && !_error == nil) { + const bool success = Dart_PostInteger_DL(_sendPort, -1); + NSCAssert(success, @"Dart_PostCObject_DL failed."); + } [_dataCondition unlock]; } @@ -112,7 +114,7 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len { [_dataCondition lock]; - while ([_data length] == 0 && !_done && _error == nil) { + while (([_data length] == 0) && !_done && _error == nil) { os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, "DartInputStreamAdapter: waiting for data"); diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index a36b35315..02aa75238 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -72,6 +72,7 @@ void main() { expect(hasBytesAvailable, false); expect(status, NSStreamStatus.NSStreamStatusAtEnd); expect(error, isNull); + inputStream.close(); }); test('read without open', () async { From b3965ffd982299a77da60e7eae7244058e23341f Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 17:32:42 -0700 Subject: [PATCH 19/38] Update ns_input_stream.dart --- pkgs/objective_c/lib/src/ns_input_stream.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index ecabc185d..908136a14 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -51,7 +51,6 @@ extension NSInputStreamStreamExtension on Stream> { // indicate that the `NSInputStream` needs more data. if (count == -1) { dataSubscription.cancel(); - port.close(); } else { print('Resuming'); dataSubscription.resume(); From 0f683a48ed629c2fe1402694934395c3cc2d9afa Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 17:44:46 -0700 Subject: [PATCH 20/38] Update ns_input_stream_test.dart --- pkgs/objective_c/test/ns_input_stream_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index 02aa75238..ca91f613e 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -134,7 +134,7 @@ void main() { while (true) { final (count, data, hasBytesAvailable, status, error) = await read(inputStream, 6); - + print('${(count, data, hasBytesAvailable, status, error)}'); readData.addAll(data); expect(error, isNull); From 7bc06241763adaefaab2e0c9e6e6a042da4a544e Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 17:57:03 -0700 Subject: [PATCH 21/38] Update ns_input_stream_test.dart --- pkgs/objective_c/test/ns_input_stream_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index ca91f613e..fcfce531a 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -129,9 +129,11 @@ void main() { }); test('full read', () async { + print('full read'); inputStream.open(); final readData = []; while (true) { + print('about to read'); final (count, data, hasBytesAvailable, status, error) = await read(inputStream, 6); print('${(count, data, hasBytesAvailable, status, error)}'); From 365f095c86d95ba0d74e98daf2463475acc9dd07 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 27 Sep 2024 18:08:10 -0700 Subject: [PATCH 22/38] Update ns_input_stream_test.dart --- pkgs/objective_c/test/ns_input_stream_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index fcfce531a..7e9358644 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -23,9 +23,9 @@ Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( final buffer = arena(size); print('Starting read: $size'); final readSize = stream.read_maxLength_(buffer, size); - print('Read complete'); final data = Uint8List.fromList( buffer.asTypedList(readSize == -1 ? 0 : readSize)); + print('Read complete: $readSize, $data, ${stream.hasBytesAvailable}'); return ( readSize, data, From 67d6f180f2a6bb286902a1a4ce93cc1168d8c872 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Sep 2024 10:11:22 -0700 Subject: [PATCH 23/38] Update ns_input_stream_test.dart --- .../test/ns_input_stream_test.dart | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index 7e9358644..26c9d1468 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -18,22 +18,30 @@ import 'package:objective_c/src/objective_c_bindings_generated.dart'; import 'package:test/test.dart'; Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( - NSInputStream stream, int size) { - return Isolate.run(() => using((arena) { - final buffer = arena(size); - print('Starting read: $size'); - final readSize = stream.read_maxLength_(buffer, size); - final data = Uint8List.fromList( - buffer.asTypedList(readSize == -1 ? 0 : readSize)); - print('Read complete: $readSize, $data, ${stream.hasBytesAvailable}'); - return ( - readSize, - data, - stream.hasBytesAvailable, - stream.streamStatus, - stream.streamError, - ); - })); + NSInputStream stream, int size) async { + // TODO(https://github.com/dart-lang/tools/issues/520): + // Use `Isolate.run`. + + final port = ReceivePort(); + await Isolate.spawn((sendPort) { + using((arena) { + final buffer = arena(size); + print('Starting read: $size'); + final readSize = stream.read_maxLength_(buffer, size); + final data = + Uint8List.fromList(buffer.asTypedList(readSize == -1 ? 0 : readSize)); + print('Read complete: $readSize, $data, ${stream.hasBytesAvailable}'); + sendPort.send(( + readSize, + data, + stream.hasBytesAvailable, + stream.streamStatus, + stream.streamError, + )); + Isolate.current.kill(); + }); + }, port.sendPort); + return await port.first as (int, Uint8List, bool, NSStreamStatus, NSError?); } void main() { From 508b84074da509fbc0f8773b9a1a93995e8472ef Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Sep 2024 10:24:50 -0700 Subject: [PATCH 24/38] Update objective_c_bindings_generated.dart --- .../src/objective_c_bindings_generated.dart | 174 ++++++++++++------ 1 file changed, 117 insertions(+), 57 deletions(-) diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index c789479a7..aefb6a816 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -21,6 +21,7 @@ import 'package:ffi/ffi.dart' as pkg_ffi; // ignore_for_file: type=lint import 'dart:ffi' as ffi; import '../objective_c.dart' as objc; +import 'package:ffi/ffi.dart' as pkg_ffi; @ffi.Native>(symbol: "NSLocalizedDescriptionKey") external ffi.Pointer _NSLocalizedDescriptionKey; @@ -1616,22 +1617,27 @@ class NSData extends NSObject { } /// rangeOfData:options:range: - void rangeOfData_options_range_(ffi.Pointer stret, NSData dataToFind, - NSDataSearchOptions mask, NSRange searchRange) { + NSRange rangeOfData_options_range_( + NSData dataToFind, NSDataSearchOptions mask, NSRange searchRange) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants ? _objc_msgSend_1wjxqnxStret( - stret, + _ptr, this.ref.pointer, _sel_rangeOfData_options_range_, dataToFind.ref.pointer, mask.value, searchRange) - : stret.ref = _objc_msgSend_1wjxqnx( + : _ptr.ref = _objc_msgSend_1wjxqnx( this.ref.pointer, _sel_rangeOfData_options_range_, dataToFind.ref.pointer, mask.value, searchRange); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// subdataWithRange: @@ -8951,12 +8957,17 @@ class NSString extends NSObject { } /// lineRangeForRange: - void lineRangeForRange_(ffi.Pointer stret, NSRange range) { + NSRange lineRangeForRange_(NSRange range) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants ? _objc_msgSend_hgyeceStret( - stret, this.ref.pointer, _sel_lineRangeForRange_, range) - : stret.ref = _objc_msgSend_hgyece( + _ptr, this.ref.pointer, _sel_lineRangeForRange_, range) + : _ptr.ref = _objc_msgSend_hgyece( this.ref.pointer, _sel_lineRangeForRange_, range); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// localizedCapitalizedString @@ -9014,13 +9025,17 @@ class NSString extends NSObject { } /// localizedStandardRangeOfString: - void localizedStandardRangeOfString_( - ffi.Pointer stret, NSString str) { + NSRange localizedStandardRangeOfString_(NSString str) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants - ? _objc_msgSend_1pl4rx6Stret(stret, this.ref.pointer, + ? _objc_msgSend_1pl4rx6Stret(_ptr, this.ref.pointer, _sel_localizedStandardRangeOfString_, str.ref.pointer) - : stret.ref = _objc_msgSend_1pl4rx6(this.ref.pointer, + : _ptr.ref = _objc_msgSend_1pl4rx6(this.ref.pointer, _sel_localizedStandardRangeOfString_, str.ref.pointer); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// localizedStringWithFormat: @@ -9101,12 +9116,17 @@ class NSString extends NSObject { } /// paragraphRangeForRange: - void paragraphRangeForRange_(ffi.Pointer stret, NSRange range) { + NSRange paragraphRangeForRange_(NSRange range) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants ? _objc_msgSend_hgyeceStret( - stret, this.ref.pointer, _sel_paragraphRangeForRange_, range) - : stret.ref = _objc_msgSend_hgyece( + _ptr, this.ref.pointer, _sel_paragraphRangeForRange_, range) + : _ptr.ref = _objc_msgSend_hgyece( this.ref.pointer, _sel_paragraphRangeForRange_, range); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// precomposedStringWithCanonicalMapping @@ -9139,138 +9159,173 @@ class NSString extends NSObject { } /// rangeOfCharacterFromSet: - void rangeOfCharacterFromSet_( - ffi.Pointer stret, NSCharacterSet searchSet) { + NSRange rangeOfCharacterFromSet_(NSCharacterSet searchSet) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants - ? _objc_msgSend_1pl4rx6Stret(stret, this.ref.pointer, + ? _objc_msgSend_1pl4rx6Stret(_ptr, this.ref.pointer, _sel_rangeOfCharacterFromSet_, searchSet.ref.pointer) - : stret.ref = _objc_msgSend_1pl4rx6(this.ref.pointer, + : _ptr.ref = _objc_msgSend_1pl4rx6(this.ref.pointer, _sel_rangeOfCharacterFromSet_, searchSet.ref.pointer); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// rangeOfCharacterFromSet:options: - void rangeOfCharacterFromSet_options_(ffi.Pointer stret, + NSRange rangeOfCharacterFromSet_options_( NSCharacterSet searchSet, NSStringCompareOptions mask) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants ? _objc_msgSend_1yjgs24Stret( - stret, + _ptr, this.ref.pointer, _sel_rangeOfCharacterFromSet_options_, searchSet.ref.pointer, mask.value) - : stret.ref = _objc_msgSend_1yjgs24( + : _ptr.ref = _objc_msgSend_1yjgs24( this.ref.pointer, _sel_rangeOfCharacterFromSet_options_, searchSet.ref.pointer, mask.value); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// rangeOfCharacterFromSet:options:range: - void rangeOfCharacterFromSet_options_range_( - ffi.Pointer stret, - NSCharacterSet searchSet, - NSStringCompareOptions mask, - NSRange rangeOfReceiverToSearch) { + NSRange rangeOfCharacterFromSet_options_range_(NSCharacterSet searchSet, + NSStringCompareOptions mask, NSRange rangeOfReceiverToSearch) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants ? _objc_msgSend_ws2nkjStret( - stret, + _ptr, this.ref.pointer, _sel_rangeOfCharacterFromSet_options_range_, searchSet.ref.pointer, mask.value, rangeOfReceiverToSearch) - : stret.ref = _objc_msgSend_ws2nkj( + : _ptr.ref = _objc_msgSend_ws2nkj( this.ref.pointer, _sel_rangeOfCharacterFromSet_options_range_, searchSet.ref.pointer, mask.value, rangeOfReceiverToSearch); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// rangeOfComposedCharacterSequenceAtIndex: - void rangeOfComposedCharacterSequenceAtIndex_( - ffi.Pointer stret, int index) { + NSRange rangeOfComposedCharacterSequenceAtIndex_(int index) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants - ? _objc_msgSend_rmij85Stret(stret, this.ref.pointer, + ? _objc_msgSend_rmij85Stret(_ptr, this.ref.pointer, _sel_rangeOfComposedCharacterSequenceAtIndex_, index) - : stret.ref = _objc_msgSend_rmij85(this.ref.pointer, + : _ptr.ref = _objc_msgSend_rmij85(this.ref.pointer, _sel_rangeOfComposedCharacterSequenceAtIndex_, index); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// rangeOfComposedCharacterSequencesForRange: - void rangeOfComposedCharacterSequencesForRange_( - ffi.Pointer stret, NSRange range) { + NSRange rangeOfComposedCharacterSequencesForRange_(NSRange range) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants - ? _objc_msgSend_hgyeceStret(stret, this.ref.pointer, + ? _objc_msgSend_hgyeceStret(_ptr, this.ref.pointer, _sel_rangeOfComposedCharacterSequencesForRange_, range) - : stret.ref = _objc_msgSend_hgyece(this.ref.pointer, + : _ptr.ref = _objc_msgSend_hgyece(this.ref.pointer, _sel_rangeOfComposedCharacterSequencesForRange_, range); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// rangeOfString: - void rangeOfString_(ffi.Pointer stret, NSString searchString) { + NSRange rangeOfString_(NSString searchString) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants - ? _objc_msgSend_1pl4rx6Stret(stret, this.ref.pointer, + ? _objc_msgSend_1pl4rx6Stret(_ptr, this.ref.pointer, _sel_rangeOfString_, searchString.ref.pointer) - : stret.ref = _objc_msgSend_1pl4rx6( + : _ptr.ref = _objc_msgSend_1pl4rx6( this.ref.pointer, _sel_rangeOfString_, searchString.ref.pointer); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// rangeOfString:options: - void rangeOfString_options_(ffi.Pointer stret, NSString searchString, - NSStringCompareOptions mask) { + NSRange rangeOfString_options_( + NSString searchString, NSStringCompareOptions mask) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants - ? _objc_msgSend_1yjgs24Stret(stret, this.ref.pointer, + ? _objc_msgSend_1yjgs24Stret(_ptr, this.ref.pointer, _sel_rangeOfString_options_, searchString.ref.pointer, mask.value) - : stret.ref = _objc_msgSend_1yjgs24(this.ref.pointer, + : _ptr.ref = _objc_msgSend_1yjgs24(this.ref.pointer, _sel_rangeOfString_options_, searchString.ref.pointer, mask.value); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// rangeOfString:options:range: - void rangeOfString_options_range_( - ffi.Pointer stret, - NSString searchString, - NSStringCompareOptions mask, - NSRange rangeOfReceiverToSearch) { + NSRange rangeOfString_options_range_(NSString searchString, + NSStringCompareOptions mask, NSRange rangeOfReceiverToSearch) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants ? _objc_msgSend_ws2nkjStret( - stret, + _ptr, this.ref.pointer, _sel_rangeOfString_options_range_, searchString.ref.pointer, mask.value, rangeOfReceiverToSearch) - : stret.ref = _objc_msgSend_ws2nkj( + : _ptr.ref = _objc_msgSend_ws2nkj( this.ref.pointer, _sel_rangeOfString_options_range_, searchString.ref.pointer, mask.value, rangeOfReceiverToSearch); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// rangeOfString:options:range:locale: - void rangeOfString_options_range_locale_( - ffi.Pointer stret, + NSRange rangeOfString_options_range_locale_( NSString searchString, NSStringCompareOptions mask, NSRange rangeOfReceiverToSearch, NSLocale? locale) { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants ? _objc_msgSend_17qtp0oStret( - stret, + _ptr, this.ref.pointer, _sel_rangeOfString_options_range_locale_, searchString.ref.pointer, mask.value, rangeOfReceiverToSearch, locale?.ref.pointer ?? ffi.nullptr) - : stret.ref = _objc_msgSend_17qtp0o( + : _ptr.ref = _objc_msgSend_17qtp0o( this.ref.pointer, _sel_rangeOfString_options_range_locale_, searchString.ref.pointer, mask.value, rangeOfReceiverToSearch, locale?.ref.pointer ?? ffi.nullptr); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// readableTypeIdentifiersForItemProvider @@ -10797,10 +10852,15 @@ class NSValue extends NSObject { } /// rangeValue - void getRangeValue(ffi.Pointer stret) { + NSRange get rangeValue { + final _ptr = pkg_ffi.calloc(); objc.useMsgSendVariants - ? _objc_msgSend_vi3lefStret(stret, this.ref.pointer, _sel_rangeValue) - : stret.ref = _objc_msgSend_vi3lef(this.ref.pointer, _sel_rangeValue); + ? _objc_msgSend_vi3lefStret(_ptr, this.ref.pointer, _sel_rangeValue) + : _ptr.ref = _objc_msgSend_vi3lef(this.ref.pointer, _sel_rangeValue); + final _finalizable = _ptr.cast().asTypedList( + ffi.sizeOf(), + finalizer: pkg_ffi.calloc.nativeFree); + return ffi.Struct.create(_finalizable); } /// supportsSecureCoding From f4a5b74a13edd4cee6a2e8919f09adbf8a0cd3e1 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Sep 2024 14:36:05 -0700 Subject: [PATCH 25/38] Fix --- pkgs/objective_c/lib/src/ns_input_stream.dart | 8 -------- .../lib/src/objective_c_bindings_generated.dart | 2 -- pkgs/objective_c/test/ns_input_stream_test.dart | 5 ----- 3 files changed, 15 deletions(-) diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index 908136a14..cc0e3ad5c 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -24,15 +24,11 @@ extension NSInputStreamStreamExtension on Stream> { DartInputStreamAdapter.inputStreamWithPort_(port.sendPort.nativePort); late final StreamSubscription dataSubscription; - print('Here1'); dataSubscription = listen((data) { - print('data: $data'); if (inputStream.addData_(data.toNSData()) > maxReadAheadSize) { - print('pause'); dataSubscription.pause(); } }, onError: (Object e) { - print('error'); final d = NSMutableDictionary.new1(); d.setObject_forKey_(e.toString().toNSString(), NSLocalizedDescriptionKey); inputStream.setError_(NSError.errorWithDomain_code_userInfo_( @@ -41,23 +37,19 @@ extension NSInputStreamStreamExtension on Stream> { }, onDone: () { inputStream.setDone(); port.close(); - print('Stream done'); }, cancelOnError: true); dataSubscription.pause(); port.listen((count) { - print('count: $count'); // -1 indicates that the `NSInputStream` is closed. All other values // indicate that the `NSInputStream` needs more data. if (count == -1) { dataSubscription.cancel(); } else { - print('Resuming'); dataSubscription.resume(); } }, onDone: () { dataSubscription.cancel(); - print('port done'); }); return inputStream; diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index aefb6a816..f3119c048 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -13,8 +13,6 @@ // ignore_for_file: unused_field // coverage:ignore-file -import 'package:ffi/ffi.dart' as pkg_ffi; - // AUTO GENERATED FILE, DO NOT EDIT. // // Generated by `package:ffigen`. diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index 26c9d1468..3c73101dd 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -26,11 +26,9 @@ Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( await Isolate.spawn((sendPort) { using((arena) { final buffer = arena(size); - print('Starting read: $size'); final readSize = stream.read_maxLength_(buffer, size); final data = Uint8List.fromList(buffer.asTypedList(readSize == -1 ? 0 : readSize)); - print('Read complete: $readSize, $data, ${stream.hasBytesAvailable}'); sendPort.send(( readSize, data, @@ -137,14 +135,11 @@ void main() { }); test('full read', () async { - print('full read'); inputStream.open(); final readData = []; while (true) { - print('about to read'); final (count, data, hasBytesAvailable, status, error) = await read(inputStream, 6); - print('${(count, data, hasBytesAvailable, status, error)}'); readData.addAll(data); expect(error, isNull); From fae63aecc34314b28e20fc49b1430a3e23953b2a Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Sep 2024 14:47:22 -0700 Subject: [PATCH 26/38] Update pubspec.yaml --- pkgs/ffigen/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/ffigen/pubspec.yaml b/pkgs/ffigen/pubspec.yaml index 93206e31c..cfe73df7a 100644 --- a/pkgs/ffigen/pubspec.yaml +++ b/pkgs/ffigen/pubspec.yaml @@ -38,7 +38,6 @@ dev_dependencies: dart_flutter_team_lints: ^2.0.0 json_schema: ^5.1.1 leak_tracker: ^10.0.7 - meta: ^1.11.0 objective_c: ^3.0.0 test: ^1.16.2 From 4a5cf957f822b390da7946b67439efd5f35744be Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Sep 2024 16:30:25 -0700 Subject: [PATCH 27/38] Fixes --- .../src/code_generator/objc_built_in_functions.dart | 3 +++ pkgs/objective_c/ffigen_objc.yaml | 3 +++ pkgs/objective_c/lib/objective_c.dart | 3 +++ pkgs/objective_c/src/input_stream_adapter.m | 11 ++++++++--- pkgs/objective_c/test/interface_lists_test.dart | 4 +++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index 339f84b05..e1286fcea 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -78,6 +78,7 @@ class ObjCBuiltInFunctions { 'NSOrderedSet', 'NSOutputStream', 'NSProxy', + 'NSRunLoop', 'NSSet', 'NSStream', 'NSString', @@ -109,6 +110,8 @@ class ObjCBuiltInFunctions { 'NSKeyValueSetMutationKind', 'NSOrderedCollectionDifferenceCalculationOptions', 'NSSortOptions', + 'NSStreamEvent', + 'NSStreamStatus', 'NSStringCompareOptions', 'NSStringEncodingConversionOptions', 'NSStringEnumerationOptions', diff --git a/pkgs/objective_c/ffigen_objc.yaml b/pkgs/objective_c/ffigen_objc.yaml index e8b15f695..269c26524 100644 --- a/pkgs/objective_c/ffigen_objc.yaml +++ b/pkgs/objective_c/ffigen_objc.yaml @@ -53,6 +53,7 @@ objc-interfaces: - NSOutputStream - NSOrderedSet - NSProxy + - NSRunLoop - NSSet - NSStream - NSString @@ -84,6 +85,8 @@ enums: - NSKeyValueSetMutationKind - NSOrderedCollectionDifferenceCalculationOptions - NSSortOptions + - NSStreamEvent + - NSStreamStatus - NSStringCompareOptions - NSStringEncodingConversionOptions - NSStringEnumerationOptions diff --git a/pkgs/objective_c/lib/objective_c.dart b/pkgs/objective_c/lib/objective_c.dart index d7cfb5574..f08f904f7 100644 --- a/pkgs/objective_c/lib/objective_c.dart +++ b/pkgs/objective_c/lib/objective_c.dart @@ -71,9 +71,12 @@ export 'src/objective_c_bindings_generated.dart' NSOutputStream, NSProxy, NSRange, + NSRunLoop, NSSet, NSSortOptions, NSStream, + NSStreamEvent, + NSStreamStatus, NSString, NSStringCompareOptions, NSStringEncodingConversionOptions, diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m index b41ff86e4..1d57c762c 100644 --- a/pkgs/objective_c/src/input_stream_adapter.m +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -70,9 +70,9 @@ - (void)open { - (void)close { [_dataCondition lock]; _status = NSStreamStatusClosed; - if (!_done && !_error == nil) { + if (!_done && _error == nil) { const bool success = Dart_PostInteger_DL(_sendPort, -1); - NSCAssert(success, @"Dart_PostCObject_DL failed."); + NSCAssert(success, @"DartInputStreamAdapter: Dart_PostCObject_DL failed."); } [_dataCondition unlock]; } @@ -108,7 +108,12 @@ - (NSStreamStatus)streamStatus { #pragma mark - NSInputStream - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len { + os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, + "DartInputStreamAdapter: read called!"); + if (_status == NSStreamStatusNotOpen) { + os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, + "DartInputStreamAdapter: read before open"); return -1; } @@ -119,7 +124,7 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len { "DartInputStreamAdapter: waiting for data"); const bool success = Dart_PostInteger_DL(_sendPort, len); - NSCAssert(success, @"Dart_PostCObject_DL failed."); + NSCAssert(success, @"DartInputStreamAdapter: Dart_PostCObject_DL failed."); [_dataCondition wait]; } diff --git a/pkgs/objective_c/test/interface_lists_test.dart b/pkgs/objective_c/test/interface_lists_test.dart index 161506feb..025a34d9f 100644 --- a/pkgs/objective_c/test/interface_lists_test.dart +++ b/pkgs/objective_c/test/interface_lists_test.dart @@ -113,10 +113,12 @@ void main() { for (final line in File('lib/src/objective_c_bindings_generated.dart') .readAsLinesSync()) { final match = enumNameRegExp.firstMatch(line); - if (match != null && !privateObjectiveCClasses.contains(match[1])) { + if (match != null) { allEnumNames.add(match[1]!); } } + print(Set.from(allEnumNames) + .difference(Set.from(yamlEnums))); expect(allEnumNames, unorderedEquals(yamlEnums)); }); }); From 16b38ad3ac6f935a90d2139d4c199d612e0ff175 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Sep 2024 16:35:43 -0700 Subject: [PATCH 28/38] Update ns_input_stream_test.dart --- pkgs/objective_c/test/ns_input_stream_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index 3c73101dd..da3b09364 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -14,7 +14,6 @@ import 'dart:typed_data'; import 'package:ffi/ffi.dart'; import 'package:objective_c/objective_c.dart'; -import 'package:objective_c/src/objective_c_bindings_generated.dart'; import 'package:test/test.dart'; Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( From 5b35857d2c9330d60c9f6b7a985b62e4623fd0ca Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Sep 2024 16:36:23 -0700 Subject: [PATCH 29/38] Update input_stream_adapter.h --- pkgs/objective_c/src/input_stream_adapter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/objective_c/src/input_stream_adapter.h b/pkgs/objective_c/src/input_stream_adapter.h index a3482ac76..77f9e42ce 100644 --- a/pkgs/objective_c/src/input_stream_adapter.h +++ b/pkgs/objective_c/src/input_stream_adapter.h @@ -10,7 +10,7 @@ #import #import -/// Helper class to adapt a Dart stream into a `NSInputStream` +/// Helper class to adapt a Dart stream into a `NSInputStream`. @interface DartInputStreamAdapter : NSInputStream /// Creates the adapter. From c9e17ad62f716913b5e51366cad3de513fcd0a82 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Sep 2024 16:51:41 -0700 Subject: [PATCH 30/38] Regenerate --- .../src/objective_c_bindings_generated.dart | 2 +- .../test/ns_input_stream_test.dart | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index f3119c048..2091709f1 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -57,7 +57,7 @@ external ffi.Pointer _wrapListenerBlock_sjfpmz( ffi.Pointer block, ); -/// Helper class to adapt a Dart stream into a `NSInputStream` +/// Helper class to adapt a Dart stream into a `NSInputStream`. class DartInputStreamAdapter extends NSInputStream { DartInputStreamAdapter._(ffi.Pointer pointer, {bool retain = false, bool release = false}) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index da3b09364..c4dfe858b 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -242,4 +242,32 @@ void main() { .having((e) => e.domain.toString(), 'domain', 'DartError')); }); }); + + group('assign delegate', () { + late NSInputStream inputStream; + + setUp(() { + inputStream = Stream.fromIterable([ + [1, 2, 3], + ]).toNSInputStream(); + }); + + test('self', () async { + inputStream.open(); + inputStream.delegate = inputStream; + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, 3); + expect(count, 3); + expect(error, null); + }); + + test('non-self', () async { + inputStream.open(); + inputStream.delegate = [1, 2, 3].toNSData(); + final (count, data, hasBytesAvailable, status, error) = + await read(inputStream, 3); + expect(count, 3); + expect(error, null); + }); + }); } From c67c4b87da99ba32896898998f952a4734fc078b Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 1 Oct 2024 10:16:48 -0700 Subject: [PATCH 31/38] Add comment --- pkgs/objective_c/src/input_stream_adapter.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m index 1d57c762c..ce2a5611e 100644 --- a/pkgs/objective_c/src/input_stream_adapter.m +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -26,6 +26,8 @@ + (instancetype)inputStreamWithPort:(Dart_Port)sendPort { stream->_done = NO; stream->_status = NSStreamStatusNotOpen; stream->_error = nil; + // From https://developer.apple.com/documentation/foundation/nsstream: + // "...by a default, a stream object must be its own delegate..." stream->_delegate = stream; } return stream; @@ -90,6 +92,9 @@ - (BOOL)setProperty:(id)property forKey:(NSStreamPropertyKey)key { } - (void)setDelegate:(id)delegate { + // From https://developer.apple.com/documentation/foundation/nsstream: + // "...so a delegate message with an argument of nil should restore this + // delegate..." if (delegate == nil) { _delegate = self; } else { From 1c1a3c8deb817d6b1c8c4a663b00b3fe4b33c363 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 1 Oct 2024 10:17:28 -0700 Subject: [PATCH 32/38] Update input_stream_adapter.m --- pkgs/objective_c/src/input_stream_adapter.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m index ce2a5611e..7628a596d 100644 --- a/pkgs/objective_c/src/input_stream_adapter.m +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -14,7 +14,7 @@ @implementation DartInputStreamAdapter { NSStreamStatus _status; BOOL _done; NSError *_error; - id __weak _delegate; // This is a weak reference. + id __weak _delegate; } + (instancetype)inputStreamWithPort:(Dart_Port)sendPort { From c4e42a16b0514af814bca9990d03ba667c3ace7a Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 1 Oct 2024 10:40:25 -0700 Subject: [PATCH 33/38] Update input_stream_adapter.m --- pkgs/objective_c/src/input_stream_adapter.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m index 7628a596d..326dc27e4 100644 --- a/pkgs/objective_c/src/input_stream_adapter.m +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -113,9 +113,6 @@ - (NSStreamStatus)streamStatus { #pragma mark - NSInputStream - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len { - os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, - "DartInputStreamAdapter: read called!"); - if (_status == NSStreamStatusNotOpen) { os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, "DartInputStreamAdapter: read before open"); From 442af6269e9bb68aef69008bf7b1b887a1a94ec1 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 1 Oct 2024 10:53:54 -0700 Subject: [PATCH 34/38] Update input_stream_adapter.m --- pkgs/objective_c/src/input_stream_adapter.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m index 326dc27e4..a67870615 100644 --- a/pkgs/objective_c/src/input_stream_adapter.m +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -122,9 +122,6 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len { [_dataCondition lock]; while (([_data length] == 0) && !_done && _error == nil) { - os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, - "DartInputStreamAdapter: waiting for data"); - const bool success = Dart_PostInteger_DL(_sendPort, len); NSCAssert(success, @"DartInputStreamAdapter: Dart_PostCObject_DL failed."); From d0f65b671f22e2bc02faf093413f411d17f5f90f Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 1 Oct 2024 10:58:50 -0700 Subject: [PATCH 35/38] Update interface_lists_test.dart --- pkgs/objective_c/test/interface_lists_test.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/objective_c/test/interface_lists_test.dart b/pkgs/objective_c/test/interface_lists_test.dart index 025a34d9f..ad3ad455e 100644 --- a/pkgs/objective_c/test/interface_lists_test.dart +++ b/pkgs/objective_c/test/interface_lists_test.dart @@ -117,8 +117,6 @@ void main() { allEnumNames.add(match[1]!); } } - print(Set.from(allEnumNames) - .difference(Set.from(yamlEnums))); expect(allEnumNames, unorderedEquals(yamlEnums)); }); }); From 254577d598f9a9f4df9f926b2daf90a39086f0d7 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Wed, 2 Oct 2024 11:12:54 -0700 Subject: [PATCH 36/38] Update ns_input_stream_test.dart --- .../test/ns_input_stream_test.dart | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index c4dfe858b..8a9cf297c 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -243,7 +243,7 @@ void main() { }); }); - group('assign delegate', () { + group('delegate', () { late NSInputStream inputStream; setUp(() { @@ -252,22 +252,22 @@ void main() { ]).toNSInputStream(); }); - test('self', () async { - inputStream.open(); - inputStream.delegate = inputStream; - final (count, data, hasBytesAvailable, status, error) = - await read(inputStream, 3); - expect(count, 3); - expect(error, null); + test('default delegate', () async { + expect(inputStream.delegate, inputStream); }); - test('non-self', () async { - inputStream.open(); + test('assign to non-self', () async { inputStream.delegate = [1, 2, 3].toNSData(); + inputStream.open(); final (count, data, hasBytesAvailable, status, error) = await read(inputStream, 3); expect(count, 3); expect(error, null); }); + + test('assign to null', () async { + inputStream.delegate = null; + expect(inputStream.delegate, inputStream); + }); }); } From 93d688acd640c162d884b6e52bf184c97fe15456 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Thu, 3 Oct 2024 18:37:51 -0700 Subject: [PATCH 37/38] Fixes --- .../objc_built_in_functions.dart | 7 ++- .../lib/src/code_generator/objc_protocol.dart | 3 +- pkgs/objective_c/ffigen_objc.yaml | 3 + pkgs/objective_c/lib/objective_c.dart | 1 + .../src/objective_c_bindings_generated.dart | 62 +++++++++++++++++++ pkgs/objective_c/src/input_stream_adapter.m | 3 +- .../test/interface_lists_test.dart | 31 ++++++++++ .../test/ns_input_stream_test.dart | 24 ++++--- 8 files changed, 121 insertions(+), 13 deletions(-) diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index e1286fcea..0ee4f0825 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -119,6 +119,10 @@ class ObjCBuiltInFunctions { 'NSURLBookmarkResolutionOptions', 'NSURLHandleStatus', }; + @visibleForTesting + static const builtInProtocols = { + 'NSStreamDelegate', + }; // TODO(https://github.com/dart-lang/native/issues/1173): Ideally this check // would be based on more than just the name. @@ -128,8 +132,9 @@ class ObjCBuiltInFunctions { generateForPackageObjectiveC ? null : builtInCompounds[name]; bool isBuiltInEnum(String name) => !generateForPackageObjectiveC && builtInEnums.contains(name); + bool isBuiltInProtocol(String name) => + !generateForPackageObjectiveC && builtInProtocols.contains(name); bool isNSObject(String name) => name == 'NSObject'; - // We need to load a separate instance of objc_msgSend for each signature. If // the return type is a struct, we need to use objc_msgSend_stret instead, and // for float return types we need objc_msgSend_fpret. diff --git a/pkgs/ffigen/lib/src/code_generator/objc_protocol.dart b/pkgs/ffigen/lib/src/code_generator/objc_protocol.dart index 0d88252bf..9d6f732e0 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_protocol.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_protocol.dart @@ -32,10 +32,11 @@ class ObjCProtocol extends NoLookUpBinding with ObjCMethods { @override void sort() => sortMethods(); + bool get _isBuiltIn => builtInFunctions.isBuiltInProtocol(originalName); @override BindingString toBindingString(Writer w) { - if (!generateBindings) { + if (!generateBindings || _isBuiltIn) { return const BindingString( type: BindingStringType.objcProtocol, string: ''); } diff --git a/pkgs/objective_c/ffigen_objc.yaml b/pkgs/objective_c/ffigen_objc.yaml index 269c26524..1b1f7ebe9 100644 --- a/pkgs/objective_c/ffigen_objc.yaml +++ b/pkgs/objective_c/ffigen_objc.yaml @@ -61,6 +61,9 @@ objc-interfaces: - NSURLHandle - NSValue - Protocol +objc-protocols: + include: + - NSStreamDelegate structs: include: - _NSRange diff --git a/pkgs/objective_c/lib/objective_c.dart b/pkgs/objective_c/lib/objective_c.dart index f08f904f7..b3c9c6e38 100644 --- a/pkgs/objective_c/lib/objective_c.dart +++ b/pkgs/objective_c/lib/objective_c.dart @@ -75,6 +75,7 @@ export 'src/objective_c_bindings_generated.dart' NSSet, NSSortOptions, NSStream, + NSStreamDelegate, NSStreamEvent, NSStreamStatus, NSString, diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index 2091709f1..593dbfaec 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -8314,6 +8314,67 @@ class NSStream extends NSObject { } } +/// NSStreamDelegate +abstract final class NSStreamDelegate { + /// Builds an object that implements the NSStreamDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. + static objc.ObjCObjectBase implement( + {void Function(NSStream, NSStreamEvent)? stream_handleEvent_}) { + final builder = objc.ObjCProtocolBuilder(); + NSStreamDelegate.stream_handleEvent_ + .implement(builder, stream_handleEvent_); + return builder.build(); + } + + /// Adds the implementation of the NSStreamDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. + static void addToBuilder(objc.ObjCProtocolBuilder builder, + {void Function(NSStream, NSStreamEvent)? stream_handleEvent_}) { + NSStreamDelegate.stream_handleEvent_ + .implement(builder, stream_handleEvent_); + } + + /// Builds an object that implements the NSStreamDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as listeners will be. + static objc.ObjCObjectBase implementAsListener( + {void Function(NSStream, NSStreamEvent)? stream_handleEvent_}) { + final builder = objc.ObjCProtocolBuilder(); + NSStreamDelegate.stream_handleEvent_ + .implementAsListener(builder, stream_handleEvent_); + return builder.build(); + } + + /// Adds the implementation of the NSStreamDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will + /// be. + static void addToBuilderAsListener(objc.ObjCProtocolBuilder builder, + {void Function(NSStream, NSStreamEvent)? stream_handleEvent_}) { + NSStreamDelegate.stream_handleEvent_ + .implementAsListener(builder, stream_handleEvent_); + } + + /// stream:handleEvent: + static final stream_handleEvent_ = + objc.ObjCProtocolListenableMethod( + _sel_stream_handleEvent_, + objc.getProtocolMethodSignature( + _protocol_NSStreamDelegate, + _sel_stream_handleEvent_, + isRequired: false, + isInstanceMethod: true, + ), + (void Function(NSStream, NSStreamEvent) func) => + ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent.fromFunction( + (ffi.Pointer _, NSStream arg1, NSStreamEvent arg2) => + func(arg1, arg2)), + (void Function(NSStream, NSStreamEvent) func) => + ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent.listener( + (ffi.Pointer _, NSStream arg1, NSStreamEvent arg2) => + func(arg1, arg2)), + ); +} + enum NSStreamEvent { NSStreamEventNone(0), NSStreamEventOpenCompleted(1), @@ -15498,6 +15559,7 @@ final _objc_msgSend_z1lin0 = objc.msgSendPointer .asFunction< bool Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, int)>(); +late final _protocol_NSStreamDelegate = objc.getProtocol("NSStreamDelegate"); late final _sel_URLByAppendingPathComponent_ = objc.registerName("URLByAppendingPathComponent:"); late final _sel_URLByAppendingPathComponent_isDirectory_ = diff --git a/pkgs/objective_c/src/input_stream_adapter.m b/pkgs/objective_c/src/input_stream_adapter.m index a67870615..5260ae1ba 100644 --- a/pkgs/objective_c/src/input_stream_adapter.m +++ b/pkgs/objective_c/src/input_stream_adapter.m @@ -162,8 +162,7 @@ - (BOOL)hasBytesAvailable { - (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent { id delegate = _delegate; if (delegate != self) { - os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_ERROR, - "DartInputStreamAdapter: non-self delegate was invoked"); + [delegate stream:self handleEvent:streamEvent]; } } diff --git a/pkgs/objective_c/test/interface_lists_test.dart b/pkgs/objective_c/test/interface_lists_test.dart index ad3ad455e..094eabb59 100644 --- a/pkgs/objective_c/test/interface_lists_test.dart +++ b/pkgs/objective_c/test/interface_lists_test.dart @@ -19,6 +19,7 @@ void main() { late List yamlInterfaces; late List yamlStructs; late List yamlEnums; + late List yamlProtocols; setUpAll(() { final yaml = @@ -38,6 +39,11 @@ void main() { .map((dynamic i) => i as String) .toList() ..sort(); + yamlProtocols = ((yaml['objc-protocols'] as YamlMap)['include'] + as YamlList) + .map((dynamic i) => i as String) + .toList() + ..sort(); }); test('ObjCBuiltInFunctions.builtInInterfaces', () { @@ -52,6 +58,10 @@ void main() { expect(ObjCBuiltInFunctions.builtInEnums, yamlEnums); }); + test('ObjCBuiltInFunctions.builtInProtocols', () { + expect(ObjCBuiltInFunctions.builtInProtocols, yamlProtocols); + }); + test('package:objective_c exports all the interfaces', () { final exportFile = File('lib/objective_c.dart').readAsStringSync(); for (final intf in yamlInterfaces) { @@ -75,6 +85,13 @@ void main() { } }); + test('package:objective_c exports all the protocols', () { + final exportFile = File('lib/objective_c.dart').readAsStringSync(); + for (final protocol in yamlProtocols) { + expect(exportFile, contains(protocol)); + } + }); + test('All code genned interfaces are included in the list', () { final classNameRegExp = RegExp(r'^class (\w+) '); final allClassNames = []; @@ -119,5 +136,19 @@ void main() { } expect(allEnumNames, unorderedEquals(yamlEnums)); }); + + test('All code genned protocols are included in the list', () { + final protocolNameRegExp = + RegExp(r'^abstract final class (?!ObjCBlock_)(\w+) {'); + final allProtocolNames = []; + for (final line in File('lib/src/objective_c_bindings_generated.dart') + .readAsLinesSync()) { + final match = protocolNameRegExp.firstMatch(line); + if (match != null) { + allProtocolNames.add(match[1]!); + } + } + expect(allProtocolNames, unorderedEquals(yamlProtocols)); + }); }); } diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index 8a9cf297c..c9baa02ac 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -14,6 +14,7 @@ import 'dart:typed_data'; import 'package:ffi/ffi.dart'; import 'package:objective_c/objective_c.dart'; +import 'package:objective_c/src/objective_c_bindings_generated.dart'; import 'package:test/test.dart'; Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( @@ -244,25 +245,30 @@ void main() { }); group('delegate', () { - late NSInputStream inputStream; + late DartInputStreamAdapter inputStream; setUp(() { inputStream = Stream.fromIterable([ [1, 2, 3], - ]).toNSInputStream(); + ]).toNSInputStream() as DartInputStreamAdapter; }); test('default delegate', () async { expect(inputStream.delegate, inputStream); + inputStream.stream_handleEvent_( + inputStream, NSStreamEvent.NSStreamEventOpenCompleted); }); - test('assign to non-self', () async { - inputStream.delegate = [1, 2, 3].toNSData(); - inputStream.open(); - final (count, data, hasBytesAvailable, status, error) = - await read(inputStream, 3); - expect(count, 3); - expect(error, null); + test('non-self delegate', () async { + final protoBuilder = ObjCProtocolBuilder(); + final events = []; + + NSStreamDelegate.addToBuilder(protoBuilder, + stream_handleEvent_: (stream, event) => events.add(event)); + inputStream.delegate = protoBuilder.build(); + inputStream.stream_handleEvent_( + inputStream, NSStreamEvent.NSStreamEventOpenCompleted); + expect(events, [NSStreamEvent.NSStreamEventOpenCompleted]); }); test('assign to null', () async { From 8069f027441f6f14f3b91d7246bd8f2e7ff24b5d Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 4 Oct 2024 11:26:47 -0700 Subject: [PATCH 38/38] Update CHANGELOG.md --- pkgs/objective_c/CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/objective_c/CHANGELOG.md b/pkgs/objective_c/CHANGELOG.md index 7f378e122..335b8d6e0 100644 --- a/pkgs/objective_c/CHANGELOG.md +++ b/pkgs/objective_c/CHANGELOG.md @@ -1,6 +1,13 @@ ## 3.0.0-wip -- Add `NSInputStream` and `NSStream` to the core package. +- Add the following stream-related types to the core package: + - `NSInputStream` + - `NSOutputStream` + - `NSRunLoop` + - `NSStream` + - `NSStreamDelegate` + - `NSStreamEvent` + - `NSStreamStatus` - Add `UnimplementedOptionalMethodException`, which is thrown by the ObjC bindings if an optional method is invoked, and the instance doesn't implement the method.