Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cupertino_http: upgrade ffigen version #1159

Merged
merged 5 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/cupertino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,7 @@ jobs:
name: Install dependencies
run: flutter pub get
- name: Check formatting
# Don't lint the generated file native_cupertino_bindings.dart
# This approach is simpler than using `find` and excluding that file
# because `dart format` also excludes other file e.g. ones in
# directories start with '.'.
run: |
mv lib/src/native_cupertino_bindings.dart lib/src/native_cupertino_bindings.tmp
dart format --output=none --set-exit-if-changed .
mv lib/src/native_cupertino_bindings.tmp lib/src/native_cupertino_bindings.dart
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: flutter analyze --fatal-infos
Expand Down
4 changes: 4 additions & 0 deletions pkgs/cupertino_http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.4.1-wip

* Upgrade to `package:ffigen` 11.0.0.

## 1.4.0

* **Experimental** support for the `package:web_socket` `WebSocket` interface.
Expand Down
40 changes: 19 additions & 21 deletions pkgs/cupertino_http/lib/src/cupertino_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ class Error extends _ObjectHolder<ncb.NSError> implements Exception {
linkedLibs, linkedLibs.NSLocalizedDescriptionKey),
);
}
final e = ncb.NSError.alloc(linkedLibs).initWithDomain_code_userInfo_(
domain.toNSString(linkedLibs).pointer, code, d);
final e = ncb.NSError.alloc(linkedLibs)
.initWithDomain_code_userInfo_(domain.toNSString(linkedLibs), code, d);
return Error._(e);
}

Expand All @@ -201,8 +201,7 @@ class Error extends _ObjectHolder<ncb.NSError> implements Exception {
/// The error domain, for example `"NSPOSIXErrorDomain"`.
///
/// See [NSError.domain](https://developer.apple.com/documentation/foundation/nserror/1413924-domain)
String get domain =>
ncb.NSString.castFromPointer(linkedLibs, _nsObject.domain).toString();
String get domain => _nsObject.domain.toString();

/// A description of the error in the current locale e.g.
/// 'A server with the specified hostname could not be found.'
Expand Down Expand Up @@ -244,7 +243,7 @@ class URLCache extends _ObjectHolder<ncb.NSURLCache> {
/// See [NSURLCache.sharedURLCache](https://developer.apple.com/documentation/foundation/nsurlcache/1413377-sharedurlcache)
static URLCache? get sharedURLCache {
final sharedCache = ncb.NSURLCache.getSharedURLCache(linkedLibs);
return sharedCache == null ? null : URLCache._(sharedCache);
return URLCache._(sharedCache);
}

/// Create a new [URLCache] with the given memory and disk cache sizes.
Expand Down Expand Up @@ -292,7 +291,7 @@ class URLSessionConfiguration
URLSessionConfiguration._(
ncb.NSURLSessionConfiguration.castFrom(
ncb.NSURLSessionConfiguration.getDefaultSessionConfiguration(
linkedLibs)!),
linkedLibs)),
isBackground: false);

/// A session configuration that uses no persistent storage for caches,
Expand All @@ -303,7 +302,7 @@ class URLSessionConfiguration
URLSessionConfiguration._(
ncb.NSURLSessionConfiguration.castFrom(
ncb.NSURLSessionConfiguration.getEphemeralSessionConfiguration(
linkedLibs)!),
linkedLibs)),
isBackground: false);

/// Whether connections over a cellular network are allowed.
Expand Down Expand Up @@ -552,7 +551,7 @@ class MutableData extends Data {

/// A new empty [MutableData].
factory MutableData.empty() =>
MutableData._(ncb.NSMutableData.dataWithCapacity_(linkedLibs, 0));
MutableData._(ncb.NSMutableData.dataWithCapacity_(linkedLibs, 0)!);

/// Appends the given data.
///
Expand Down Expand Up @@ -626,8 +625,7 @@ class HTTPURLResponse extends URLResponse {
///
/// See [HTTPURLResponse.allHeaderFields](https://developer.apple.com/documentation/foundation/nshttpurlresponse/1417930-allheaderfields)
Map<String, String> get allHeaderFields {
final headers =
ncb.NSDictionary.castFrom(_httpUrlResponse.allHeaderFields!);
final headers = ncb.NSDictionary.castFrom(_httpUrlResponse.allHeaderFields);
return stringNSDictionaryToMap(headers);
}

Expand Down Expand Up @@ -918,8 +916,8 @@ class URLSessionWebSocketTask extends URLSessionTask {
completionPort.close();
});

helperLibs.CUPHTTPSendMessage(_urlSessionWebSocketTask.pointer,
message._nsObject.pointer, completionPort.sendPort.nativePort);
helperLibs.CUPHTTPSendMessage(_urlSessionWebSocketTask, message._nsObject,
completionPort.sendPort.nativePort);
await completer.future;
}

Expand Down Expand Up @@ -956,7 +954,7 @@ class URLSessionWebSocketTask extends URLSessionTask {
});

helperLibs.CUPHTTPReceiveMessage(
_urlSessionWebSocketTask.pointer, completionPort.sendPort.nativePort);
_urlSessionWebSocketTask, completionPort.sendPort.nativePort);
return completer.future;
}

Expand Down Expand Up @@ -1066,7 +1064,7 @@ class MutableURLRequest extends URLRequest {
/// See [NSMutableURLRequest.requestWithURL:](https://developer.apple.com/documentation/foundation/nsmutableurlrequest/1414617-allhttpheaderfields)
factory MutableURLRequest.fromUrl(Uri uri) {
final url = ncb.NSURL
.URLWithString_(linkedLibs, uri.toString().toNSString(linkedLibs));
.URLWithString_(linkedLibs, uri.toString().toNSString(linkedLibs))!;
return MutableURLRequest._(
ncb.NSMutableURLRequest.requestWithURL_(linkedLibs, url));
}
Expand Down Expand Up @@ -1160,15 +1158,15 @@ void _setupDelegation(

try {
final request = URLRequest._(
ncb.NSURLRequest.castFrom(forwardedRedirect.request!));
ncb.NSURLRequest.castFrom(forwardedRedirect.request));

if (onRedirect == null) {
redirectRequest = request;
break;
}
try {
final response = HTTPURLResponse._(
ncb.NSHTTPURLResponse.castFrom(forwardedRedirect.response!));
ncb.NSHTTPURLResponse.castFrom(forwardedRedirect.response));
redirectRequest = onRedirect(session, task, response, request);
} catch (e) {
// TODO(https://github.com/dart-lang/ffigen/issues/386): Package
Expand All @@ -1191,7 +1189,7 @@ void _setupDelegation(
break;
}
final response =
URLResponse._exactURLResponseType(forwardedResponse.response!);
URLResponse._exactURLResponseType(forwardedResponse.response);

try {
disposition = onResponse(session, task, response);
Expand All @@ -1213,8 +1211,8 @@ void _setupDelegation(
break;
}
try {
onData(session, task,
Data._(ncb.NSData.castFrom(forwardedData.data!)));
onData(
session, task, Data._(ncb.NSData.castFrom(forwardedData.data)));
} catch (e) {
// TODO(https://github.com/dart-lang/ffigen/issues/386): Package
// this exception as an `Error` and call the completion function
Expand All @@ -1236,7 +1234,7 @@ void _setupDelegation(
session,
task as URLSessionDownloadTask,
Uri.parse(
finishedDownloading.location!.absoluteString!.toString()));
finishedDownloading.location.absoluteString!.toString()));
} catch (e) {
// TODO(https://github.com/dart-lang/ffigen/issues/386): Package
// this exception as an `Error` and call the completion function
Expand Down Expand Up @@ -1474,7 +1472,7 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
///
/// See [NSURLSession.configuration](https://developer.apple.com/documentation/foundation/nsurlsession/1411477-configuration)
URLSessionConfiguration get configuration => URLSessionConfiguration._(
ncb.NSURLSessionConfiguration.castFrom(_nsObject.configuration!),
ncb.NSURLSessionConfiguration.castFrom(_nsObject.configuration),
isBackground: _isBackground);

/// A description of the session that may be useful for debugging.
Expand Down
Loading
Loading