blob: 1905261653ba60105693a11be63ddfad78950e45 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import "messages.g.h"
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif
#if !__has_feature(objc_arc)
#error File requires ARC to be enabled.
#endif
static NSArray *wrapResult(id result, FlutterError *error) {
if (error) {
return @[
error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null]
];
}
return @[ result ?: [NSNull null] ];
}
static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
id result = array[key];
return (result == [NSNull null]) ? nil : result;
}
@interface FFSFileSelectorConfig ()
+ (FFSFileSelectorConfig *)fromList:(NSArray *)list;
+ (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list;
- (NSArray *)toList;
@end
@implementation FFSFileSelectorConfig
+ (instancetype)makeWithUtis:(NSArray<NSString *> *)utis
allowMultiSelection:(BOOL)allowMultiSelection {
FFSFileSelectorConfig *pigeonResult = [[FFSFileSelectorConfig alloc] init];
pigeonResult.utis = utis;
pigeonResult.allowMultiSelection = allowMultiSelection;
return pigeonResult;
}
+ (FFSFileSelectorConfig *)fromList:(NSArray *)list {
FFSFileSelectorConfig *pigeonResult = [[FFSFileSelectorConfig alloc] init];
pigeonResult.utis = GetNullableObjectAtIndex(list, 0);
pigeonResult.allowMultiSelection = [GetNullableObjectAtIndex(list, 1) boolValue];
return pigeonResult;
}
+ (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list {
return (list) ? [FFSFileSelectorConfig fromList:list] : nil;
}
- (NSArray *)toList {
return @[
self.utis ?: [NSNull null],
@(self.allowMultiSelection),
];
}
@end
@interface FFSFileSelectorApiCodecReader : FlutterStandardReader
@end
@implementation FFSFileSelectorApiCodecReader
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
return [FFSFileSelectorConfig fromList:[self readValue]];
default:
return [super readValueOfType:type];
}
}
@end
@interface FFSFileSelectorApiCodecWriter : FlutterStandardWriter
@end
@implementation FFSFileSelectorApiCodecWriter
- (void)writeValue:(id)value {
if ([value isKindOfClass:[FFSFileSelectorConfig class]]) {
[self writeByte:128];
[self writeValue:[value toList]];
} else {
[super writeValue:value];
}
}
@end
@interface FFSFileSelectorApiCodecReaderWriter : FlutterStandardReaderWriter
@end
@implementation FFSFileSelectorApiCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
return [[FFSFileSelectorApiCodecWriter alloc] initWithData:data];
}
- (FlutterStandardReader *)readerWithData:(NSData *)data {
return [[FFSFileSelectorApiCodecReader alloc] initWithData:data];
}
@end
NSObject<FlutterMessageCodec> *FFSFileSelectorApiGetCodec(void) {
static FlutterStandardMessageCodec *sSharedObject = nil;
static dispatch_once_t sPred = 0;
dispatch_once(&sPred, ^{
FFSFileSelectorApiCodecReaderWriter *readerWriter =
[[FFSFileSelectorApiCodecReaderWriter alloc] init];
sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
});
return sSharedObject;
}
void SetUpFFSFileSelectorApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FFSFileSelectorApi> *api) {
{
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile"
binaryMessenger:binaryMessenger
codec:FFSFileSelectorApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(openFileSelectorWithConfig:completion:)],
@"FFSFileSelectorApi api (%@) doesn't respond to "
@"@selector(openFileSelectorWithConfig:completion:)",
api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
FFSFileSelectorConfig *arg_config = GetNullableObjectAtIndex(args, 0);
[api openFileSelectorWithConfig:arg_config
completion:^(NSArray<NSString *> *_Nullable output,
FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
}];
} else {
[channel setMessageHandler:nil];
}
}
}