From 7e098fb7ea5602c5bc98eb86fcf731e3dbc384f0 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Thu, 2 Apr 2026 14:51:28 +0200 Subject: [PATCH 01/11] ESA-42 spm: fix pdfx alternative --- packages/pdfx/CHANGELOG.md | 4 + packages/pdfx/ios/pdfx/Package.swift | 26 + .../pdfx/Sources/PdfxCodec/include/messages.h | 186 ++++ .../ios/pdfx/Sources/PdfxCodec/messages.m | 828 ++++++++++++++++++ .../pdfx/ios/pdfx/Sources/pdfx/Document.swift | 209 +++++ .../pdfx/ios/pdfx/Sources/pdfx/Hooks.swift | 60 ++ .../ios/pdfx/Sources/pdfx/PdfxPlugin.swift | 8 + .../ios/pdfx/Sources/pdfx/Resources.swift | 44 + .../pdfx/Sources/pdfx/SwiftPdfxPlugin.swift | 397 +++++++++ packages/pdfx/pubspec.yaml | 2 +- 10 files changed, 1763 insertions(+), 1 deletion(-) create mode 100644 packages/pdfx/ios/pdfx/Package.swift create mode 100644 packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h create mode 100644 packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m create mode 100644 packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift create mode 100644 packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift create mode 100644 packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift create mode 100644 packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift create mode 100644 packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift diff --git a/packages/pdfx/CHANGELOG.md b/packages/pdfx/CHANGELOG.md index 08fae596..de3511bb 100644 --- a/packages/pdfx/CHANGELOG.md +++ b/packages/pdfx/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.9.3 + +* Added Swift Package Manager support for iOS. + ## 2.9.2 * Fixed PdfViewPinch when compiling to WASM [pull#586](https://github.com/ScerIO/packages.flutter/pull/586) diff --git a/packages/pdfx/ios/pdfx/Package.swift b/packages/pdfx/ios/pdfx/Package.swift new file mode 100644 index 00000000..d6b77963 --- /dev/null +++ b/packages/pdfx/ios/pdfx/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "pdfx", + platforms: [ + .iOS(.v13), + ], + products: [ + .library(name: "pdfx", targets: ["pdfx", "PdfxCodec"]), + ], + dependencies: [], + targets: [ + .target( + name: "PdfxCodec", + dependencies: [], + path: "Sources/PdfxCodec", + publicHeadersPath: "include" + ), + .target( + name: "pdfx", + dependencies: ["PdfxCodec"], + path: "Sources/pdfx" + ), + ] +) diff --git a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h new file mode 100644 index 00000000..5b0aef71 --- /dev/null +++ b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h @@ -0,0 +1,186 @@ +// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// See also: https://pub.dev/packages/pigeon +#import +@protocol FlutterBinaryMessenger; +@protocol FlutterMessageCodec; +@class FlutterError; +@class FlutterStandardTypedData; + +NS_ASSUME_NONNULL_BEGIN + +@class OpenDataMessage; +@class OpenPathMessage; +@class OpenReply; +@class IdMessage; +@class GetPageMessage; +@class GetPageReply; +@class RenderPageMessage; +@class RenderPageReply; +@class RegisterTextureReply; +@class UpdateTextureMessage; +@class ResizeTextureMessage; +@class UnregisterTextureMessage; + +@interface OpenDataMessage : NSObject ++ (instancetype)makeWithData:(nullable FlutterStandardTypedData *)data + password:(nullable NSString *)password; +@property(nonatomic, strong, nullable) FlutterStandardTypedData * data; +@property(nonatomic, copy, nullable) NSString * password; +@end + +@interface OpenPathMessage : NSObject ++ (instancetype)makeWithPath:(nullable NSString *)path + password:(nullable NSString *)password; +@property(nonatomic, copy, nullable) NSString * path; +@property(nonatomic, copy, nullable) NSString * password; +@end + +@interface OpenReply : NSObject ++ (instancetype)makeWithId:(nullable NSString *)id + pagesCount:(nullable NSNumber *)pagesCount; +@property(nonatomic, copy, nullable) NSString * id; +@property(nonatomic, strong, nullable) NSNumber * pagesCount; +@end + +@interface IdMessage : NSObject ++ (instancetype)makeWithId:(nullable NSString *)id; +@property(nonatomic, copy, nullable) NSString * id; +@end + +@interface GetPageMessage : NSObject ++ (instancetype)makeWithDocumentId:(nullable NSString *)documentId + pageNumber:(nullable NSNumber *)pageNumber + autoCloseAndroid:(nullable NSNumber *)autoCloseAndroid; +@property(nonatomic, copy, nullable) NSString * documentId; +@property(nonatomic, strong, nullable) NSNumber * pageNumber; +@property(nonatomic, strong, nullable) NSNumber * autoCloseAndroid; +@end + +@interface GetPageReply : NSObject ++ (instancetype)makeWithId:(nullable NSString *)id + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height; +@property(nonatomic, copy, nullable) NSString * id; +@property(nonatomic, strong, nullable) NSNumber * width; +@property(nonatomic, strong, nullable) NSNumber * height; +@end + +@interface RenderPageMessage : NSObject ++ (instancetype)makeWithPageId:(nullable NSString *)pageId + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height + format:(nullable NSNumber *)format + backgroundColor:(nullable NSString *)backgroundColor + crop:(nullable NSNumber *)crop + cropX:(nullable NSNumber *)cropX + cropY:(nullable NSNumber *)cropY + cropHeight:(nullable NSNumber *)cropHeight + cropWidth:(nullable NSNumber *)cropWidth + quality:(nullable NSNumber *)quality + forPrint:(nullable NSNumber *)forPrint; +@property(nonatomic, copy, nullable) NSString * pageId; +@property(nonatomic, strong, nullable) NSNumber * width; +@property(nonatomic, strong, nullable) NSNumber * height; +@property(nonatomic, strong, nullable) NSNumber * format; +@property(nonatomic, copy, nullable) NSString * backgroundColor; +@property(nonatomic, strong, nullable) NSNumber * crop; +@property(nonatomic, strong, nullable) NSNumber * cropX; +@property(nonatomic, strong, nullable) NSNumber * cropY; +@property(nonatomic, strong, nullable) NSNumber * cropHeight; +@property(nonatomic, strong, nullable) NSNumber * cropWidth; +@property(nonatomic, strong, nullable) NSNumber * quality; +@property(nonatomic, strong, nullable) NSNumber * forPrint; +@end + +@interface RenderPageReply : NSObject ++ (instancetype)makeWithWidth:(nullable NSNumber *)width + height:(nullable NSNumber *)height + path:(nullable NSString *)path + data:(nullable FlutterStandardTypedData *)data; +@property(nonatomic, strong, nullable) NSNumber * width; +@property(nonatomic, strong, nullable) NSNumber * height; +@property(nonatomic, copy, nullable) NSString * path; +@property(nonatomic, strong, nullable) FlutterStandardTypedData * data; +@end + +@interface RegisterTextureReply : NSObject ++ (instancetype)makeWithId:(nullable NSNumber *)id; +@property(nonatomic, strong, nullable) NSNumber * id; +@end + +@interface UpdateTextureMessage : NSObject ++ (instancetype)makeWithDocumentId:(nullable NSString *)documentId + pageNumber:(nullable NSNumber *)pageNumber + pageId:(nullable NSString *)pageId + textureId:(nullable NSNumber *)textureId + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height + backgroundColor:(nullable NSString *)backgroundColor + sourceX:(nullable NSNumber *)sourceX + sourceY:(nullable NSNumber *)sourceY + destinationX:(nullable NSNumber *)destinationX + destinationY:(nullable NSNumber *)destinationY + fullWidth:(nullable NSNumber *)fullWidth + fullHeight:(nullable NSNumber *)fullHeight + textureWidth:(nullable NSNumber *)textureWidth + textureHeight:(nullable NSNumber *)textureHeight + allowAntiAliasing:(nullable NSNumber *)allowAntiAliasing; +@property(nonatomic, copy, nullable) NSString * documentId; +@property(nonatomic, strong, nullable) NSNumber * pageNumber; +@property(nonatomic, copy, nullable) NSString * pageId; +@property(nonatomic, strong, nullable) NSNumber * textureId; +@property(nonatomic, strong, nullable) NSNumber * width; +@property(nonatomic, strong, nullable) NSNumber * height; +@property(nonatomic, copy, nullable) NSString * backgroundColor; +@property(nonatomic, strong, nullable) NSNumber * sourceX; +@property(nonatomic, strong, nullable) NSNumber * sourceY; +@property(nonatomic, strong, nullable) NSNumber * destinationX; +@property(nonatomic, strong, nullable) NSNumber * destinationY; +@property(nonatomic, strong, nullable) NSNumber * fullWidth; +@property(nonatomic, strong, nullable) NSNumber * fullHeight; +@property(nonatomic, strong, nullable) NSNumber * textureWidth; +@property(nonatomic, strong, nullable) NSNumber * textureHeight; +@property(nonatomic, strong, nullable) NSNumber * allowAntiAliasing; +@end + +@interface ResizeTextureMessage : NSObject ++ (instancetype)makeWithTextureId:(nullable NSNumber *)textureId + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height; +@property(nonatomic, strong, nullable) NSNumber * textureId; +@property(nonatomic, strong, nullable) NSNumber * width; +@property(nonatomic, strong, nullable) NSNumber * height; +@end + +@interface UnregisterTextureMessage : NSObject ++ (instancetype)makeWithId:(nullable NSNumber *)id; +@property(nonatomic, strong, nullable) NSNumber * id; +@end + +///The codec used by PdfxApi. +NSObject *PdfxApiGetCodec(void); + +/// Rebuild: `flutter pub run pigeon --input pigeons/message.dart` +/// After build edit ios/Classes/pigeon/messages.m +/// replace `#import ` to +/// ```` +/// ```` +/// +@protocol PdfxApi +- (void)openDocumentDataMessage:(OpenDataMessage *)message completion:(void(^)(OpenReply *_Nullable, FlutterError *_Nullable))completion; +- (void)openDocumentFileMessage:(OpenPathMessage *)message completion:(void(^)(OpenReply *_Nullable, FlutterError *_Nullable))completion; +- (void)openDocumentAssetMessage:(OpenPathMessage *)message completion:(void(^)(OpenReply *_Nullable, FlutterError *_Nullable))completion; +- (void)closeDocumentMessage:(IdMessage *)message error:(FlutterError *_Nullable *_Nonnull)error; +- (void)getPageMessage:(GetPageMessage *)message completion:(void(^)(GetPageReply *_Nullable, FlutterError *_Nullable))completion; +- (void)renderPageMessage:(RenderPageMessage *)message completion:(void(^)(RenderPageReply *_Nullable, FlutterError *_Nullable))completion; +- (void)closePageMessage:(IdMessage *)message error:(FlutterError *_Nullable *_Nonnull)error; +/// @return `nil` only when `error != nil`. +- (nullable RegisterTextureReply *)registerTextureWithError:(FlutterError *_Nullable *_Nonnull)error; +- (void)updateTextureMessage:(UpdateTextureMessage *)message completion:(void(^)(FlutterError *_Nullable))completion; +- (void)resizeTextureMessage:(ResizeTextureMessage *)message completion:(void(^)(FlutterError *_Nullable))completion; +- (void)unregisterTextureMessage:(UnregisterTextureMessage *)message error:(FlutterError *_Nullable *_Nonnull)error; +@end + +extern void PdfxApiSetup(id binaryMessenger, NSObject *_Nullable api); + +NS_ASSUME_NONNULL_END diff --git a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m new file mode 100644 index 00000000..6070a468 --- /dev/null +++ b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m @@ -0,0 +1,828 @@ +// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// See also: https://pub.dev/packages/pigeon +#import "messages.h" +#if TARGET_OS_IOS +#import +#else +#import +#endif + +#if !__has_feature(objc_arc) +#error File requires ARC to be enabled. +#endif + +static NSDictionary *wrapResult(id result, FlutterError *error) { + NSDictionary *errorDict = (NSDictionary *)[NSNull null]; + if (error) { + errorDict = @{ + @"code": (error.code ?: [NSNull null]), + @"message": (error.message ?: [NSNull null]), + @"details": (error.details ?: [NSNull null]), + }; + } + return @{ + @"result": (result ?: [NSNull null]), + @"error": errorDict, + }; +} +static id GetNullableObject(NSDictionary* dict, id key) { + id result = dict[key]; + return (result == [NSNull null]) ? nil : result; +} +static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { + id result = array[key]; + return (result == [NSNull null]) ? nil : result; +} + + +@interface OpenDataMessage () ++ (OpenDataMessage *)fromMap:(NSDictionary *)dict; ++ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface OpenPathMessage () ++ (OpenPathMessage *)fromMap:(NSDictionary *)dict; ++ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface OpenReply () ++ (OpenReply *)fromMap:(NSDictionary *)dict; ++ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface IdMessage () ++ (IdMessage *)fromMap:(NSDictionary *)dict; ++ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface GetPageMessage () ++ (GetPageMessage *)fromMap:(NSDictionary *)dict; ++ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface GetPageReply () ++ (GetPageReply *)fromMap:(NSDictionary *)dict; ++ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface RenderPageMessage () ++ (RenderPageMessage *)fromMap:(NSDictionary *)dict; ++ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface RenderPageReply () ++ (RenderPageReply *)fromMap:(NSDictionary *)dict; ++ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface RegisterTextureReply () ++ (RegisterTextureReply *)fromMap:(NSDictionary *)dict; ++ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface UpdateTextureMessage () ++ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict; ++ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface ResizeTextureMessage () ++ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict; ++ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end +@interface UnregisterTextureMessage () ++ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict; ++ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; +@end + +@implementation OpenDataMessage ++ (instancetype)makeWithData:(nullable FlutterStandardTypedData *)data + password:(nullable NSString *)password { + OpenDataMessage* pigeonResult = [[OpenDataMessage alloc] init]; + pigeonResult.data = data; + pigeonResult.password = password; + return pigeonResult; +} ++ (OpenDataMessage *)fromMap:(NSDictionary *)dict { + OpenDataMessage *pigeonResult = [[OpenDataMessage alloc] init]; + pigeonResult.data = GetNullableObject(dict, @"data"); + pigeonResult.password = GetNullableObject(dict, @"password"); + return pigeonResult; +} ++ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenDataMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"data" : (self.data ?: [NSNull null]), + @"password" : (self.password ?: [NSNull null]), + }; +} +@end + +@implementation OpenPathMessage ++ (instancetype)makeWithPath:(nullable NSString *)path + password:(nullable NSString *)password { + OpenPathMessage* pigeonResult = [[OpenPathMessage alloc] init]; + pigeonResult.path = path; + pigeonResult.password = password; + return pigeonResult; +} ++ (OpenPathMessage *)fromMap:(NSDictionary *)dict { + OpenPathMessage *pigeonResult = [[OpenPathMessage alloc] init]; + pigeonResult.path = GetNullableObject(dict, @"path"); + pigeonResult.password = GetNullableObject(dict, @"password"); + return pigeonResult; +} ++ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenPathMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"path" : (self.path ?: [NSNull null]), + @"password" : (self.password ?: [NSNull null]), + }; +} +@end + +@implementation OpenReply ++ (instancetype)makeWithId:(nullable NSString *)id + pagesCount:(nullable NSNumber *)pagesCount { + OpenReply* pigeonResult = [[OpenReply alloc] init]; + pigeonResult.id = id; + pigeonResult.pagesCount = pagesCount; + return pigeonResult; +} ++ (OpenReply *)fromMap:(NSDictionary *)dict { + OpenReply *pigeonResult = [[OpenReply alloc] init]; + pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.pagesCount = GetNullableObject(dict, @"pagesCount"); + return pigeonResult; +} ++ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenReply fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + @"pagesCount" : (self.pagesCount ?: [NSNull null]), + }; +} +@end + +@implementation IdMessage ++ (instancetype)makeWithId:(nullable NSString *)id { + IdMessage* pigeonResult = [[IdMessage alloc] init]; + pigeonResult.id = id; + return pigeonResult; +} ++ (IdMessage *)fromMap:(NSDictionary *)dict { + IdMessage *pigeonResult = [[IdMessage alloc] init]; + pigeonResult.id = GetNullableObject(dict, @"id"); + return pigeonResult; +} ++ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [IdMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + }; +} +@end + +@implementation GetPageMessage ++ (instancetype)makeWithDocumentId:(nullable NSString *)documentId + pageNumber:(nullable NSNumber *)pageNumber + autoCloseAndroid:(nullable NSNumber *)autoCloseAndroid { + GetPageMessage* pigeonResult = [[GetPageMessage alloc] init]; + pigeonResult.documentId = documentId; + pigeonResult.pageNumber = pageNumber; + pigeonResult.autoCloseAndroid = autoCloseAndroid; + return pigeonResult; +} ++ (GetPageMessage *)fromMap:(NSDictionary *)dict { + GetPageMessage *pigeonResult = [[GetPageMessage alloc] init]; + pigeonResult.documentId = GetNullableObject(dict, @"documentId"); + pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); + pigeonResult.autoCloseAndroid = GetNullableObject(dict, @"autoCloseAndroid"); + return pigeonResult; +} ++ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"documentId" : (self.documentId ?: [NSNull null]), + @"pageNumber" : (self.pageNumber ?: [NSNull null]), + @"autoCloseAndroid" : (self.autoCloseAndroid ?: [NSNull null]), + }; +} +@end + +@implementation GetPageReply ++ (instancetype)makeWithId:(nullable NSString *)id + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height { + GetPageReply* pigeonResult = [[GetPageReply alloc] init]; + pigeonResult.id = id; + pigeonResult.width = width; + pigeonResult.height = height; + return pigeonResult; +} ++ (GetPageReply *)fromMap:(NSDictionary *)dict { + GetPageReply *pigeonResult = [[GetPageReply alloc] init]; + pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); + return pigeonResult; +} ++ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageReply fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + }; +} +@end + +@implementation RenderPageMessage ++ (instancetype)makeWithPageId:(nullable NSString *)pageId + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height + format:(nullable NSNumber *)format + backgroundColor:(nullable NSString *)backgroundColor + crop:(nullable NSNumber *)crop + cropX:(nullable NSNumber *)cropX + cropY:(nullable NSNumber *)cropY + cropHeight:(nullable NSNumber *)cropHeight + cropWidth:(nullable NSNumber *)cropWidth + quality:(nullable NSNumber *)quality + forPrint:(nullable NSNumber *)forPrint { + RenderPageMessage* pigeonResult = [[RenderPageMessage alloc] init]; + pigeonResult.pageId = pageId; + pigeonResult.width = width; + pigeonResult.height = height; + pigeonResult.format = format; + pigeonResult.backgroundColor = backgroundColor; + pigeonResult.crop = crop; + pigeonResult.cropX = cropX; + pigeonResult.cropY = cropY; + pigeonResult.cropHeight = cropHeight; + pigeonResult.cropWidth = cropWidth; + pigeonResult.quality = quality; + pigeonResult.forPrint = forPrint; + return pigeonResult; +} ++ (RenderPageMessage *)fromMap:(NSDictionary *)dict { + RenderPageMessage *pigeonResult = [[RenderPageMessage alloc] init]; + pigeonResult.pageId = GetNullableObject(dict, @"pageId"); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.format = GetNullableObject(dict, @"format"); + pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); + pigeonResult.crop = GetNullableObject(dict, @"crop"); + pigeonResult.cropX = GetNullableObject(dict, @"cropX"); + pigeonResult.cropY = GetNullableObject(dict, @"cropY"); + pigeonResult.cropHeight = GetNullableObject(dict, @"cropHeight"); + pigeonResult.cropWidth = GetNullableObject(dict, @"cropWidth"); + pigeonResult.quality = GetNullableObject(dict, @"quality"); + pigeonResult.forPrint = GetNullableObject(dict, @"forPrint"); + return pigeonResult; +} ++ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"pageId" : (self.pageId ?: [NSNull null]), + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + @"format" : (self.format ?: [NSNull null]), + @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), + @"crop" : (self.crop ?: [NSNull null]), + @"cropX" : (self.cropX ?: [NSNull null]), + @"cropY" : (self.cropY ?: [NSNull null]), + @"cropHeight" : (self.cropHeight ?: [NSNull null]), + @"cropWidth" : (self.cropWidth ?: [NSNull null]), + @"quality" : (self.quality ?: [NSNull null]), + @"forPrint" : (self.forPrint ?: [NSNull null]), + }; +} +@end + +@implementation RenderPageReply ++ (instancetype)makeWithWidth:(nullable NSNumber *)width + height:(nullable NSNumber *)height + path:(nullable NSString *)path + data:(nullable FlutterStandardTypedData *)data { + RenderPageReply* pigeonResult = [[RenderPageReply alloc] init]; + pigeonResult.width = width; + pigeonResult.height = height; + pigeonResult.path = path; + pigeonResult.data = data; + return pigeonResult; +} ++ (RenderPageReply *)fromMap:(NSDictionary *)dict { + RenderPageReply *pigeonResult = [[RenderPageReply alloc] init]; + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.path = GetNullableObject(dict, @"path"); + pigeonResult.data = GetNullableObject(dict, @"data"); + return pigeonResult; +} ++ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageReply fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + @"path" : (self.path ?: [NSNull null]), + @"data" : (self.data ?: [NSNull null]), + }; +} +@end + +@implementation RegisterTextureReply ++ (instancetype)makeWithId:(nullable NSNumber *)id { + RegisterTextureReply* pigeonResult = [[RegisterTextureReply alloc] init]; + pigeonResult.id = id; + return pigeonResult; +} ++ (RegisterTextureReply *)fromMap:(NSDictionary *)dict { + RegisterTextureReply *pigeonResult = [[RegisterTextureReply alloc] init]; + pigeonResult.id = GetNullableObject(dict, @"id"); + return pigeonResult; +} ++ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RegisterTextureReply fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + }; +} +@end + +@implementation UpdateTextureMessage ++ (instancetype)makeWithDocumentId:(nullable NSString *)documentId + pageNumber:(nullable NSNumber *)pageNumber + pageId:(nullable NSString *)pageId + textureId:(nullable NSNumber *)textureId + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height + backgroundColor:(nullable NSString *)backgroundColor + sourceX:(nullable NSNumber *)sourceX + sourceY:(nullable NSNumber *)sourceY + destinationX:(nullable NSNumber *)destinationX + destinationY:(nullable NSNumber *)destinationY + fullWidth:(nullable NSNumber *)fullWidth + fullHeight:(nullable NSNumber *)fullHeight + textureWidth:(nullable NSNumber *)textureWidth + textureHeight:(nullable NSNumber *)textureHeight + allowAntiAliasing:(nullable NSNumber *)allowAntiAliasing { + UpdateTextureMessage* pigeonResult = [[UpdateTextureMessage alloc] init]; + pigeonResult.documentId = documentId; + pigeonResult.pageNumber = pageNumber; + pigeonResult.pageId = pageId; + pigeonResult.textureId = textureId; + pigeonResult.width = width; + pigeonResult.height = height; + pigeonResult.backgroundColor = backgroundColor; + pigeonResult.sourceX = sourceX; + pigeonResult.sourceY = sourceY; + pigeonResult.destinationX = destinationX; + pigeonResult.destinationY = destinationY; + pigeonResult.fullWidth = fullWidth; + pigeonResult.fullHeight = fullHeight; + pigeonResult.textureWidth = textureWidth; + pigeonResult.textureHeight = textureHeight; + pigeonResult.allowAntiAliasing = allowAntiAliasing; + return pigeonResult; +} ++ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict { + UpdateTextureMessage *pigeonResult = [[UpdateTextureMessage alloc] init]; + pigeonResult.documentId = GetNullableObject(dict, @"documentId"); + pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); + pigeonResult.pageId = GetNullableObject(dict, @"pageId"); + pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); + pigeonResult.sourceX = GetNullableObject(dict, @"sourceX"); + pigeonResult.sourceY = GetNullableObject(dict, @"sourceY"); + pigeonResult.destinationX = GetNullableObject(dict, @"destinationX"); + pigeonResult.destinationY = GetNullableObject(dict, @"destinationY"); + pigeonResult.fullWidth = GetNullableObject(dict, @"fullWidth"); + pigeonResult.fullHeight = GetNullableObject(dict, @"fullHeight"); + pigeonResult.textureWidth = GetNullableObject(dict, @"textureWidth"); + pigeonResult.textureHeight = GetNullableObject(dict, @"textureHeight"); + pigeonResult.allowAntiAliasing = GetNullableObject(dict, @"allowAntiAliasing"); + return pigeonResult; +} ++ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UpdateTextureMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"documentId" : (self.documentId ?: [NSNull null]), + @"pageNumber" : (self.pageNumber ?: [NSNull null]), + @"pageId" : (self.pageId ?: [NSNull null]), + @"textureId" : (self.textureId ?: [NSNull null]), + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), + @"sourceX" : (self.sourceX ?: [NSNull null]), + @"sourceY" : (self.sourceY ?: [NSNull null]), + @"destinationX" : (self.destinationX ?: [NSNull null]), + @"destinationY" : (self.destinationY ?: [NSNull null]), + @"fullWidth" : (self.fullWidth ?: [NSNull null]), + @"fullHeight" : (self.fullHeight ?: [NSNull null]), + @"textureWidth" : (self.textureWidth ?: [NSNull null]), + @"textureHeight" : (self.textureHeight ?: [NSNull null]), + @"allowAntiAliasing" : (self.allowAntiAliasing ?: [NSNull null]), + }; +} +@end + +@implementation ResizeTextureMessage ++ (instancetype)makeWithTextureId:(nullable NSNumber *)textureId + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height { + ResizeTextureMessage* pigeonResult = [[ResizeTextureMessage alloc] init]; + pigeonResult.textureId = textureId; + pigeonResult.width = width; + pigeonResult.height = height; + return pigeonResult; +} ++ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict { + ResizeTextureMessage *pigeonResult = [[ResizeTextureMessage alloc] init]; + pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); + return pigeonResult; +} ++ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [ResizeTextureMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"textureId" : (self.textureId ?: [NSNull null]), + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + }; +} +@end + +@implementation UnregisterTextureMessage ++ (instancetype)makeWithId:(nullable NSNumber *)id { + UnregisterTextureMessage* pigeonResult = [[UnregisterTextureMessage alloc] init]; + pigeonResult.id = id; + return pigeonResult; +} ++ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict { + UnregisterTextureMessage *pigeonResult = [[UnregisterTextureMessage alloc] init]; + pigeonResult.id = GetNullableObject(dict, @"id"); + return pigeonResult; +} ++ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UnregisterTextureMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + }; +} +@end + +@interface PdfxApiCodecReader : FlutterStandardReader +@end +@implementation PdfxApiCodecReader +- (nullable id)readValueOfType:(UInt8)type +{ + switch (type) { + case 128: + return [GetPageMessage fromMap:[self readValue]]; + + case 129: + return [GetPageReply fromMap:[self readValue]]; + + case 130: + return [IdMessage fromMap:[self readValue]]; + + case 131: + return [OpenDataMessage fromMap:[self readValue]]; + + case 132: + return [OpenPathMessage fromMap:[self readValue]]; + + case 133: + return [OpenReply fromMap:[self readValue]]; + + case 134: + return [RegisterTextureReply fromMap:[self readValue]]; + + case 135: + return [RenderPageMessage fromMap:[self readValue]]; + + case 136: + return [RenderPageReply fromMap:[self readValue]]; + + case 137: + return [ResizeTextureMessage fromMap:[self readValue]]; + + case 138: + return [UnregisterTextureMessage fromMap:[self readValue]]; + + case 139: + return [UpdateTextureMessage fromMap:[self readValue]]; + + default: + return [super readValueOfType:type]; + + } +} +@end + +@interface PdfxApiCodecWriter : FlutterStandardWriter +@end +@implementation PdfxApiCodecWriter +- (void)writeValue:(id)value +{ + if ([value isKindOfClass:[GetPageMessage class]]) { + [self writeByte:128]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[GetPageReply class]]) { + [self writeByte:129]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[IdMessage class]]) { + [self writeByte:130]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[OpenDataMessage class]]) { + [self writeByte:131]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[OpenPathMessage class]]) { + [self writeByte:132]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[OpenReply class]]) { + [self writeByte:133]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[RegisterTextureReply class]]) { + [self writeByte:134]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[RenderPageMessage class]]) { + [self writeByte:135]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[RenderPageReply class]]) { + [self writeByte:136]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[ResizeTextureMessage class]]) { + [self writeByte:137]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[UnregisterTextureMessage class]]) { + [self writeByte:138]; + [self writeValue:[value toMap]]; + } else + if ([value isKindOfClass:[UpdateTextureMessage class]]) { + [self writeByte:139]; + [self writeValue:[value toMap]]; + } else +{ + [super writeValue:value]; + } +} +@end + +@interface PdfxApiCodecReaderWriter : FlutterStandardReaderWriter +@end +@implementation PdfxApiCodecReaderWriter +- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { + return [[PdfxApiCodecWriter alloc] initWithData:data]; +} +- (FlutterStandardReader *)readerWithData:(NSData *)data { + return [[PdfxApiCodecReader alloc] initWithData:data]; +} +@end + +NSObject *PdfxApiGetCodec(void) { + static dispatch_once_t sPred = 0; + static FlutterStandardMessageCodec *sSharedObject = nil; + dispatch_once(&sPred, ^{ + PdfxApiCodecReaderWriter *readerWriter = [[PdfxApiCodecReaderWriter alloc] init]; + sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; + }); + return sSharedObject; +} + + +void PdfxApiSetup(id binaryMessenger, NSObject *api) { + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentData" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(openDocumentDataMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentDataMessage:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + OpenDataMessage *arg_message = GetNullableObjectAtIndex(args, 0); + [api openDocumentDataMessage:arg_message completion:^(OpenReply *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentFile" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(openDocumentFileMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentFileMessage:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + OpenPathMessage *arg_message = GetNullableObjectAtIndex(args, 0); + [api openDocumentFileMessage:arg_message completion:^(OpenReply *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentAsset" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(openDocumentAssetMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentAssetMessage:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + OpenPathMessage *arg_message = GetNullableObjectAtIndex(args, 0); + [api openDocumentAssetMessage:arg_message completion:^(OpenReply *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.closeDocument" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(closeDocumentMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closeDocumentMessage:error:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + IdMessage *arg_message = GetNullableObjectAtIndex(args, 0); + FlutterError *error; + [api closeDocumentMessage:arg_message error:&error]; + callback(wrapResult(nil, error)); + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.getPage" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(getPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(getPageMessage:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + GetPageMessage *arg_message = GetNullableObjectAtIndex(args, 0); + [api getPageMessage:arg_message completion:^(GetPageReply *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.renderPage" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(renderPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(renderPageMessage:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + RenderPageMessage *arg_message = GetNullableObjectAtIndex(args, 0); + [api renderPageMessage:arg_message completion:^(RenderPageReply *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.closePage" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(closePageMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closePageMessage:error:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + IdMessage *arg_message = GetNullableObjectAtIndex(args, 0); + FlutterError *error; + [api closePageMessage:arg_message error:&error]; + callback(wrapResult(nil, error)); + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.registerTexture" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(registerTextureWithError:)], @"PdfxApi api (%@) doesn't respond to @selector(registerTextureWithError:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + FlutterError *error; + RegisterTextureReply *output = [api registerTextureWithError:&error]; + callback(wrapResult(output, error)); + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.updateTexture" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(updateTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(updateTextureMessage:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + UpdateTextureMessage *arg_message = GetNullableObjectAtIndex(args, 0); + [api updateTextureMessage:arg_message completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.resizeTexture" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(resizeTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(resizeTextureMessage:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + ResizeTextureMessage *arg_message = GetNullableObjectAtIndex(args, 0); + [api resizeTextureMessage:arg_message completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; + }]; + } + else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.PdfxApi.unregisterTexture" + binaryMessenger:binaryMessenger + codec:PdfxApiGetCodec() ]; + if (api) { + NSCAssert([api respondsToSelector:@selector(unregisterTextureMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(unregisterTextureMessage:error:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + UnregisterTextureMessage *arg_message = GetNullableObjectAtIndex(args, 0); + FlutterError *error; + [api unregisterTextureMessage:arg_message error:&error]; + callback(wrapResult(nil, error)); + }]; + } + else { + [channel setMessageHandler:nil]; + } + } +} diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift new file mode 100644 index 00000000..404fbc3f --- /dev/null +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift @@ -0,0 +1,209 @@ +class Document { + let id: String + let renderer: CGPDFDocument + var pages: [CGPDFPage?] + + init(id: String, renderer: CGPDFDocument) { + self.id = id + self.renderer = renderer + self.pages = Array(repeating: nil, count: renderer.numberOfPages) + } + + var pagesCount: Int { + get { + return renderer.numberOfPages + } + } + + /** + * Open page by page number (not index!) + */ + public func openPage(pageNumber: Int) -> CGPDFPage? { + return renderer.page(at: pageNumber) + } +} + +class Page { + let id: String + let documentId: String + let renderer: CGPDFPage + let boxRect: CGRect + + init(id: String, documentId: String, renderer: CGPDFPage) { + self.id = id + self.documentId = documentId + self.renderer = renderer + self.boxRect = renderer.getBoxRect(.mediaBox) + } + + var number: Int { + get { + return renderer.pageNumber + } + } + + var width: Double { + get { + return Double(boxRect.width) + } + } + + var height: Double { + get { + return Double(boxRect.height) + } + } + + var rotationAngle: Int32 { + get { + return renderer.rotationAngle + } + } + + var isLandscape: Bool { + get { + return Bool(rotationAngle == 90 || rotationAngle == 270) + } + } + + func render(width: Int, height: Int, crop: CGRect?, compressFormat: CompressFormat, backgroundColor: String = "#ffffff", quality: Int) -> Page.DataResult? { + let box = renderer.getBoxRect(.mediaBox) + let bitmapSize = isLandscape ? CGSize(width: height, height: width) : CGSize(width: width, height: height) + let stride = Int(bitmapSize.width * 4) + var tempData = Data(repeating: 0, count: stride * Int(bitmapSize.height)) + var data: Data? + var fileURL: URL? + var success = false + var transform = renderer.getDrawingTransform(.mediaBox, rect: CGRect(origin: CGPoint.zero, size: bitmapSize), rotate: 0, preserveAspectRatio: true) + let compressionQuality = CGFloat(quality) / 100 + tempData.withUnsafeMutableBytes { (ptr) in + let rawPtr = ptr.baseAddress + let rgb = CGColorSpaceCreateDeviceRGB() + let context = CGContext(data: rawPtr, width: Int(bitmapSize.width), height: Int(bitmapSize.height), bitsPerComponent: 8, bytesPerRow: stride, space: rgb, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) + if context != nil { + // Credit: https://stackoverflow.com/a/35985236 + // We change the context scale to fill completely the destination size (scale-down is handled by getDrawingTransform) + if box.width < bitmapSize.width { + let sx = CGFloat(width) / box.width + let sy = CGFloat(height) / box.height + transform = transform.scaledBy(x: sx, y: sy) + + transform.tx = -(box.origin.x * transform.a + box.origin.y * transform.b) + transform.ty = -(box.origin.x * transform.c + box.origin.y * transform.d) + + // Rotation handling + if rotationAngle == 180 || rotationAngle == 270 { + transform.tx += bitmapSize.width + } + if rotationAngle == 90 || rotationAngle == 180 { + transform.ty += bitmapSize.height + } + } + context!.concatenate(transform) + #if os(iOS) + context!.setFillColor(UIColor(hexString: backgroundColor).cgColor) + #elseif os(macOS) + context!.setFillColor(NSColor(hexString: backgroundColor).cgColor) + #endif + context!.fill(box) + context!.drawPDFPage(renderer) + #if os(iOS) + var image = UIImage(cgImage: context!.makeImage()!) + #elseif os(macOS) + var image = NSBitmapImageRep(cgImage: context!.makeImage()!) + #endif + + if (crop != nil) { + // Perform cropping in Core Graphics + let cutImageRef: CGImage = (image.cgImage?.cropping(to:crop!))! + #if os(iOS) + image = UIImage(cgImage: cutImageRef) + #elseif os(macOS) + image = NSBitmapImageRep(cgImage: cutImageRef) + #endif + } + + switch(compressFormat) { + case CompressFormat.JPEG: + #if os(iOS) + data = image.jpegData(compressionQuality: compressionQuality) as Data? + #elseif os(macOS) + data = image.representation(using: NSBitmapImageRep.FileType.jpeg, properties: [:]) as Data? + #endif + break; + case CompressFormat.PNG: + #if os(iOS) + data = image.pngData() as Data? + #elseif os(macOS) + data = image.representation(using: NSBitmapImageRep.FileType.png, properties: [:]) as Data? + #endif + break; + } + + if data != nil { + fileURL = writeToTempFile(data: data!, compressFormat: compressFormat) + } + + success = true + } + } + return success ? Page.DataResult( + width: (crop != nil) ? Int(crop!.width) : width, + height: (crop != nil) ? Int(crop!.height) : height, + path: (fileURL != nil) ? fileURL!.path : "" + ) : nil + } + + func writeToTempFile(data: Data, compressFormat: CompressFormat) -> URL? { + // Create missing directories + let docURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] + let cacheURL = docURL.appendingPathComponent("pdf_renderer_cache") + if !FileManager.default.fileExists(atPath: cacheURL.path) { + do { + try FileManager.default.createDirectory(at: cacheURL, withIntermediateDirectories: true, attributes: nil) + } catch { + print(error.localizedDescription) + return nil + } + } + // Create temporary filename + let randomFileName = NSUUID().uuidString.replacingOccurrences(of: "-", with: "") + var tempOutFileExtension: String? + var tempOutFileName: String? + switch(compressFormat) { + case CompressFormat.JPEG: + tempOutFileExtension = "jpg" + break; + case CompressFormat.PNG: + tempOutFileExtension = "png" + break; + } + tempOutFileName = "\(randomFileName).\(tempOutFileExtension!)" + let fileURL = cacheURL.appendingPathComponent(tempOutFileName!) + // Write the data to the temporary file + do { + try data.write(to: fileURL, options: .atomic) + } catch { + print(error.localizedDescription) + return nil + } + return fileURL + } + + class DataResult { + let width: Int + let height: Int + let path: String + + init(width: Int, height: Int, path: String) { + self.width = width + self.height = height + self.path = path + } + } +} + +enum CompressFormat: Int { + case JPEG = 0 + case PNG = 1 +} diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift new file mode 100644 index 00000000..2dadd875 --- /dev/null +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift @@ -0,0 +1,60 @@ +#if os(iOS) + +extension UIColor { + convenience init(hexString: String) { + let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) + var int: UInt64 = UInt64() + Scanner(string: hex).scanHexInt64(&int) + let a, r, g, b: UInt64 + switch hex.count { + case 3: // RGB (12-bit) + (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) + case 6: // RGB (24-bit) + (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) + case 8: // ARGB (32-bit) + (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) + default: + (a, r, g, b) = (255, 0, 0, 0) + } + self.init(red: CGFloat(r) / 255, green: CGFloat(g) / 255, blue: CGFloat(b) / 255, alpha: CGFloat(a) / 255) + } +} + +#elseif os(macOS) + +extension NSColor { + convenience init(hexString: String) { + let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) + var int = UInt64() + Scanner(string: hex).scanHexInt64(&int) + let a, r, g, b: UInt64 + switch hex.count { + case 3: // RGB (12-bit) + (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) + case 6: // RGB (24-bit) + (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) + case 8: // ARGB (32-bit) + (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) + default: + (a, r, g, b) = (255, 0, 0, 0) + } + self.init(red: CGFloat(r) / 255, green: CGFloat(g) / 255, blue: CGFloat(b) / 255, alpha: CGFloat(a) / 255) + } +} + +#endif + +extension CGPDFPage { + func getRotatedSize() -> CGSize { + let bbox = getBoxRect(.mediaBox) + let rot = rotationAngle + if rot == 90 || rot == 270 { + return CGSize(width: bbox.height, height: bbox.width) + } + return bbox.size + } + func getRotationTransform() -> CGAffineTransform { + let rect = CGRect(origin: CGPoint.zero, size: getRotatedSize()) + return getDrawingTransform(.mediaBox, rect: rect, rotate: 0, preserveAspectRatio: true) + } +} diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift new file mode 100644 index 00000000..bb2a3b0a --- /dev/null +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift @@ -0,0 +1,8 @@ +import Flutter +import PdfxCodec + +public class PdfxPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + SwiftPdfxPlugin.register(with: registrar) + } +} diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift new file mode 100644 index 00000000..e8ab0c49 --- /dev/null +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift @@ -0,0 +1,44 @@ +enum RepositoryError: Error { + case ItemNotFound +} + +class Repository { + var items: [String: T] = [:] + + public func get(id: String) throws -> T { + if !exist(id: id) { + throw RepositoryError.ItemNotFound + } + return items[id]! + } + + public func set(id: String, item: T) { + items[id] = item + } + + private func exist(id: String) -> Bool { + return items.keys.contains(id) + } + + open func close(id: String) { + items.removeValue(forKey: id) + } +} + +class DocumentRepository : Repository { + func register(renderer: CGPDFDocument) -> Document { + let id = NSUUID().uuidString + let page = Document(id: id, renderer: renderer) + set(id: id, item: page) + return page + } +} + +class PageRepository : Repository { + func register(documentId: String, renderer: CGPDFPage) -> Page { + let id = NSUUID().uuidString + let page = Page(id: id, documentId: documentId, renderer: renderer) + set(id: id, item: page) + return page + } +} diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift new file mode 100644 index 00000000..a8fdd2e4 --- /dev/null +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift @@ -0,0 +1,397 @@ +#if os(iOS) +import Flutter +import UIKit +import PdfxCodec +#elseif os(macOS) +import Cocoa +import FlutterMacOS +#endif +import CoreGraphics + +public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { + let registrar: FlutterPluginRegistrar + static let invalid = NSNumber(value: -1) + let dispQueue = DispatchQueue(label: "io.scer.pdf_renderer") + + let documents = DocumentRepository() + let pages = PageRepository() + var textures: [Int64: PdfPageTexture] = [:] + + init(registrar: FlutterPluginRegistrar) { + self.registrar = registrar + } + + public static func register(with registrar: FlutterPluginRegistrar) { + #if os(iOS) + let messenger: FlutterBinaryMessenger = registrar.messenger() + #elseif os(macOS) + let messenger: FlutterBinaryMessenger = registrar.messenger + #endif + let api: PdfxApi & NSObjectProtocol = SwiftPdfxPlugin.init(registrar: registrar) + PdfxApiSetup(messenger, api); + } + + public func openDocumentDataMessage(_ message: OpenDataMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let data = message.data else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Arguments not sended", + details: nil)) + } + guard let renderer = openDataDocument(data: data.data) else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Invalid PDF format", + details: nil)) + } + + let document = documents.register(renderer: renderer); + let result = OpenReply.init() + result.id = document.id + result.pagesCount = NSNumber.init(value: document.pagesCount) + + completion(result, nil); + } + + public func openDocumentFileMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let pdfFilePath = message.path else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Arguments not sended", + details: nil)) + } + guard let renderer = openFileDocument(pdfFilePath: pdfFilePath) else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Invalid PDF format", + details: nil)) + } + + let document = documents.register(renderer: renderer); + let result = OpenReply.init() + result.id = document.id + result.pagesCount = NSNumber.init(value: document.pagesCount) + + completion(result, nil); + } + + public func openDocumentAssetMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let name = message.path else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Arguments not sended", + details: nil)) + } + guard let renderer = openAssetDocument(name: name) else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Invalid PDF format", + details: nil)) + } + + let document = documents.register(renderer: renderer); + let result = OpenReply.init() + result.id = document.id + result.pagesCount = NSNumber.init(value: document.pagesCount) + + completion(result, nil); + } + + public func closeDocumentMessage(_ message: IdMessage, error: AutoreleasingUnsafeMutablePointer) { + if let id = message.id { + documents.close(id: id) + } + } + + public func getPageMessage(_ message: GetPageMessage, completion: @escaping (GetPageReply?, FlutterError?) -> Void) { + do { + let documentId = message.documentId + let pageNumber = message.pageNumber + + let result = GetPageReply.init(); + + let renderer = try documents.get(id: documentId!).openPage(pageNumber: pageNumber as! Int) + if (renderer == nil) { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Unexpected error: renderer is nil.", + details: nil)) + } + + let page = pages.register(documentId: documentId!, renderer: renderer!) + result.id = page.id + result.width = NSNumber.init(value: page.width) + result.height = NSNumber.init(value: page.height) + completion(result, nil) + } catch let err { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Unexpected error: \(err).", + details: nil)) + } + } + + public func renderPageMessage(_ message: RenderPageMessage, completion: @escaping (RenderPageReply?, FlutterError?) -> Void) { + // Set crop if required + var cropZone: CGRect? = nil + if (message.crop!.boolValue){ + let cWidth = message.cropWidth!.intValue + let cHeight = message.cropHeight!.intValue + if (cWidth != message.width!.intValue || cHeight != message.height!.intValue){ + cropZone = CGRect(x: message.cropX as! Int, + y: message.cropY as! Int, + width: cWidth, + height: cHeight) + } + } + + dispQueue.async { + let result = RenderPageReply.init() + do { + let page = try self.pages.get(id: message.pageId!) + if let data = page.render( + width: message.width!.intValue, + height: message.height!.intValue, + crop: cropZone, + compressFormat: CompressFormat(rawValue: message.format!.intValue)!, + backgroundColor: message.backgroundColor!, + quality: message.quality!.intValue + ) { + result.width = NSNumber.init(value: data.width) + result.height = NSNumber.init(value: data.height) + result.path = data.path + } + } catch { + completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Unexpected error: \(error).", + details: nil)) + } + DispatchQueue.main.async { + completion(result.path != nil ? result : nil, nil) + } + } + } + + public func closePageMessage(_ message: IdMessage, error: AutoreleasingUnsafeMutablePointer) { + if let id = message.id { + pages.close(id: id) + } + } + + public func registerTextureWithError(_ error: AutoreleasingUnsafeMutablePointer) -> RegisterTextureReply? { + let result = RegisterTextureReply.init() + let pageTex = PdfPageTexture(registrar: registrar) + #if os(iOS) + let texId = registrar.textures().register(pageTex) + #elseif os(macOS) + let texId = registrar.textures.register(pageTex) + #endif + textures[texId] = pageTex + pageTex.texId = texId + result.id = NSNumber.init(value: texId) + return result + } + + public func unregisterTextureMessage(_ message: UnregisterTextureMessage, error: AutoreleasingUnsafeMutablePointer) { + let texId = message.id?.int64Value + #if os(iOS) + registrar.textures().unregisterTexture(texId!) + #elseif os(macOS) + registrar.textures.unregisterTexture(texId!) + #endif + textures[texId!] = nil + } + + public func resizeTextureMessage(_ message: ResizeTextureMessage, completion: @escaping (FlutterError?) -> Void) { + let texId = message.textureId?.int64Value + guard let pageTex = textures[texId!] else { + return completion(FlutterError(code: "RENDER_ERROR", + message: "No texture of texId=\(String(describing: texId!))", + details: nil)) + } + let width = message.width?.intValue, + height = message.height?.intValue + pageTex.resize(width: width!, height: height!) + return completion(nil) + } + + public func updateTextureMessage(_ message: UpdateTextureMessage, completion: @escaping (FlutterError?) -> Void) { + let texId = message.textureId?.int64Value + let pageId = message.pageId! + let destX = message.destinationX?.intValue + let destY = message.destinationY?.intValue + let width = message.width?.intValue + let height = message.height?.intValue + let srcX = message.sourceX?.intValue + let srcY = message.sourceY?.intValue + let fw = message.fullWidth?.doubleValue + let fh = message.fullHeight?.doubleValue + let backgroundColor = message.backgroundColor + let allowAntialiasing = message.allowAntiAliasing?.boolValue + + let tw = message.textureWidth?.intValue + let th = message.textureHeight?.intValue + + let pageTex = textures[texId!]! + + if tw != nil && th != nil { + pageTex.resize(width: tw!, height: th!) + } + + if width == nil || height == nil { + return completion(FlutterError(code: "RENDER_ERROR", + message: "width/height nil", + details: nil)) + } + do { + let page = try self.pages.get(id: pageId) + + try pageTex.updateTex( + page: page.renderer, + destX: destX!, + destY: destY!, + width: width!, + height: height!, + srcX: srcX!, + srcY: srcY!, + fullWidth: fw, + fullHeight: fh, + backgroundColor: backgroundColor, + allowAntialiasing: allowAntialiasing! + ) + return completion(nil) + } catch { + return completion(FlutterError(code: "RENDER_ERROR", + message: "Cannot render texture", + details: nil)) + } + + } + + func openDataDocument(data: Data) -> CGPDFDocument? { + guard let datProv = CGDataProvider(data: data as CFData) else { return nil } + let docment = CGPDFDocument(datProv) + if docment?.isUnlocked == false { + return nil + } + return docment + } + + func openFileDocument(pdfFilePath: String) -> CGPDFDocument? { + let docment = CGPDFDocument(URL(fileURLWithPath: pdfFilePath) as CFURL) + if docment?.isEncrypted == true { + return nil + } + return docment + } + + func openAssetDocument(name: String) -> CGPDFDocument? { + #if os(iOS) + guard let path = Bundle.main.path(forResource: "Frameworks/App.framework/flutter_assets/" + name, ofType: "") else { + return nil + } + #elseif os(macOS) + let path = Bundle.main.bundlePath + "/Contents/Frameworks/App.framework/Resources/flutter_assets/" + name; + #endif + + return openFileDocument(pdfFilePath: path) + } +} + +enum PdfRenderError : Error { + case operationFailed(String) + case invalidArgument(String) + case notSupported(String) +} + +class PdfPageTexture : NSObject { + var pixBuf : CVPixelBuffer? + weak var registrar: FlutterPluginRegistrar? + var texId: Int64 = 0 + var texWidth: Int = 0 + var texHeight: Int = 0 + + init(registrar: FlutterPluginRegistrar?) { + self.registrar = registrar + } + + func resize(width: Int, height: Int) { + if self.texWidth == width && self.texHeight == height { + return + } + self.texWidth = width + self.texHeight = height + } + + func updateTex( + page: CGPDFPage, + destX: Int, + destY: Int, + width: Int, + height: Int, + srcX: Int, + srcY: Int, + fullWidth: Double?, + fullHeight: Double?, + backgroundColor: String?, + allowAntialiasing: Bool = true + ) throws { + + let rotatedSize = page.getRotatedSize() + let fw = fullWidth ?? Double(rotatedSize.width) + let fh = fullHeight ?? Double(rotatedSize.height) + let sx = CGFloat(fw) / rotatedSize.width + let sy = CGFloat(fh) / rotatedSize.height + + var pixBuf: CVPixelBuffer? + let options = [ + kCVPixelBufferCGImageCompatibilityKey as String: true, + kCVPixelBufferCGBitmapContextCompatibilityKey as String: true, + kCVPixelBufferIOSurfacePropertiesKey as String: [:] + ] as [String : Any] + let cvRet = CVPixelBufferCreate(kCFAllocatorDefault, texWidth, texHeight, kCVPixelFormatType_32BGRA, options as CFDictionary?, &pixBuf) + if pixBuf == nil { + throw PdfRenderError.operationFailed("CVPixelBufferCreate failed: result code=\(cvRet)") + } + + let lockFlags = CVPixelBufferLockFlags(rawValue: 0) + let _ = CVPixelBufferLockBaseAddress(pixBuf!, lockFlags) + defer { + CVPixelBufferUnlockBaseAddress(pixBuf!, lockFlags) + } + + let bufferAddress = CVPixelBufferGetBaseAddress(pixBuf!) + let bytesPerRow = CVPixelBufferGetBytesPerRow(pixBuf!) + let rgbColorSpace = CGColorSpaceCreateDeviceRGB() + let context = CGContext(data: bufferAddress?.advanced(by: destX * 4 + destY * bytesPerRow), + width: width, + height: height, + bitsPerComponent: 8, + bytesPerRow: bytesPerRow, + space: rgbColorSpace, + bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue | CGBitmapInfo.byteOrder32Little.rawValue) + + + if backgroundColor != nil { + #if os(iOS) + context?.setFillColor(UIColor(hexString: backgroundColor!).cgColor) + #elseif os(macOS) + context?.setFillColor(NSColor(hexString: backgroundColor!).cgColor) + #endif + context?.fill(CGRect(x: 0, y: 0, width: width, height: height)) + } + + context?.setAllowsAntialiasing(allowAntialiasing) + + context?.translateBy(x: CGFloat(-srcX), y: CGFloat(Double(srcY + height) - fh)) + context?.scaleBy(x: sx, y: sy) + context?.concatenate(page.getRotationTransform()) + context?.drawPDFPage(page) + context?.flush() + + self.pixBuf = pixBuf + #if os(iOS) + registrar?.textures().textureFrameAvailable(texId) + #elseif os(macOS) + registrar?.textures.textureFrameAvailable(texId) + #endif + } +} + +extension PdfPageTexture : FlutterTexture { + func copyPixelBuffer() -> Unmanaged? { + return pixBuf != nil ? Unmanaged.passRetained(pixBuf!) : nil + } +} diff --git a/packages/pdfx/pubspec.yaml b/packages/pdfx/pubspec.yaml index d0d0831e..7b4ae35f 100644 --- a/packages/pdfx/pubspec.yaml +++ b/packages/pdfx/pubspec.yaml @@ -2,7 +2,7 @@ name: pdfx description: Flutter plugin to render & show PDF pages as images on Web, MacOS, Windows, Android and iOS. repository: https://github.com/ScerIO/packages.flutter/tree/main/packages/pdfx issue_tracker: https://github.com/ScerIO/packages.flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+pdfx%22 -version: 2.9.2 +version: 2.9.3 environment: sdk: '>=3.3.0 <4.0.0' From d3f0cdcda6b4c1802c767f89eaf8a7272bc9f12e Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Thu, 2 Apr 2026 15:00:08 +0200 Subject: [PATCH 02/11] ESA-42 spm: fix pdfx alternative --- packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift | 6 ++++++ packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift | 1 + packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift | 2 ++ 3 files changed, 9 insertions(+) diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift index 404fbc3f..c6362f75 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Document.swift @@ -1,3 +1,9 @@ +#if os(iOS) +import UIKit +#elseif os(macOS) +import Cocoa +#endif + class Document { let id: String let renderer: CGPDFDocument diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift index 2dadd875..a8bb5fa8 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Hooks.swift @@ -1,4 +1,5 @@ #if os(iOS) +import UIKit extension UIColor { convenience init(hexString: String) { diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift index e8ab0c49..10c0b824 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift @@ -1,3 +1,5 @@ +import CoreGraphics + enum RepositoryError: Error { case ItemNotFound } From 09dfaa021e4f2e649c55c8cf570dc14b8cbfc689 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Thu, 2 Apr 2026 15:02:31 +0200 Subject: [PATCH 03/11] ESA-42 spm: fix pdfx alternative --- packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift index 10c0b824..e05ba895 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Resources.swift @@ -1,3 +1,4 @@ +import Foundation import CoreGraphics enum RepositoryError: Error { From b878597481971e1a2cc59760b71dee6442144874 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Thu, 2 Apr 2026 15:26:28 +0200 Subject: [PATCH 04/11] ESA-42 spm: fix pdfx alternative --- .../main/java/dev/flutter/pigeon/Pigeon.java | 491 +++++++------- packages/pdfx/ios/Classes/messages.h | 4 +- packages/pdfx/ios/Classes/messages.m | 488 +++++++------- .../pdfx/Sources/PdfxCodec/include/messages.h | 4 +- .../ios/pdfx/Sources/PdfxCodec/messages.m | 488 +++++++------- .../ios/pdfx/Sources/pdfx/PdfxPlugin.swift | 393 ++++++++++- .../pdfx/Sources/pdfx/SwiftPdfxPlugin.swift | 397 ------------ packages/pdfx/lib/src/renderer/io/pigeon.dart | 610 +++++++++--------- packages/pdfx/pigeons/messages.dart | 1 + 9 files changed, 1443 insertions(+), 1433 deletions(-) delete mode 100644 packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift diff --git a/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java b/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java index 53ad753f..e7e26b74 100644 --- a/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java +++ b/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon package dev.flutter.pigeon; @@ -14,11 +14,12 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.HashMap; -/**Generated class from Pigeon. */ +/** Generated class from Pigeon. */ @SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) public class Pigeon { @@ -54,17 +55,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("data", data); - toMapResult.put("password", password); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(2); + toListResult.add(data); + toListResult.add(password); + return toListResult; } - static @NonNull OpenDataMessage fromMap(@NonNull Map map) { + static @NonNull OpenDataMessage fromList(@NonNull ArrayList list) { OpenDataMessage pigeonResult = new OpenDataMessage(); - Object data = map.get("data"); + Object data = list.get(0); pigeonResult.setData((byte[])data); - Object password = map.get("password"); + Object password = list.get(1); pigeonResult.setPassword((String)password); return pigeonResult; } @@ -102,17 +103,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("path", path); - toMapResult.put("password", password); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(2); + toListResult.add(path); + toListResult.add(password); + return toListResult; } - static @NonNull OpenPathMessage fromMap(@NonNull Map map) { + static @NonNull OpenPathMessage fromList(@NonNull ArrayList list) { OpenPathMessage pigeonResult = new OpenPathMessage(); - Object path = map.get("path"); + Object path = list.get(0); pigeonResult.setPath((String)path); - Object password = map.get("password"); + Object password = list.get(1); pigeonResult.setPassword((String)password); return pigeonResult; } @@ -150,17 +151,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - toMapResult.put("pagesCount", pagesCount); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(2); + toListResult.add(id); + toListResult.add(pagesCount); + return toListResult; } - static @NonNull OpenReply fromMap(@NonNull Map map) { + static @NonNull OpenReply fromList(@NonNull ArrayList list) { OpenReply pigeonResult = new OpenReply(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((String)id); - Object pagesCount = map.get("pagesCount"); + Object pagesCount = list.get(1); pigeonResult.setPagesCount((pagesCount == null) ? null : ((pagesCount instanceof Integer) ? (Integer)pagesCount : (Long)pagesCount)); return pigeonResult; } @@ -186,14 +187,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(1); + toListResult.add(id); + return toListResult; } - static @NonNull IdMessage fromMap(@NonNull Map map) { + static @NonNull IdMessage fromList(@NonNull ArrayList list) { IdMessage pigeonResult = new IdMessage(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((String)id); return pigeonResult; } @@ -243,20 +244,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("documentId", documentId); - toMapResult.put("pageNumber", pageNumber); - toMapResult.put("autoCloseAndroid", autoCloseAndroid); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(3); + toListResult.add(documentId); + toListResult.add(pageNumber); + toListResult.add(autoCloseAndroid); + return toListResult; } - static @NonNull GetPageMessage fromMap(@NonNull Map map) { + static @NonNull GetPageMessage fromList(@NonNull ArrayList list) { GetPageMessage pigeonResult = new GetPageMessage(); - Object documentId = map.get("documentId"); + Object documentId = list.get(0); pigeonResult.setDocumentId((String)documentId); - Object pageNumber = map.get("pageNumber"); + Object pageNumber = list.get(1); pigeonResult.setPageNumber((pageNumber == null) ? null : ((pageNumber instanceof Integer) ? (Integer)pageNumber : (Long)pageNumber)); - Object autoCloseAndroid = map.get("autoCloseAndroid"); + Object autoCloseAndroid = list.get(2); pigeonResult.setAutoCloseAndroid((Boolean)autoCloseAndroid); return pigeonResult; } @@ -306,20 +307,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - toMapResult.put("width", width); - toMapResult.put("height", height); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(3); + toListResult.add(id); + toListResult.add(width); + toListResult.add(height); + return toListResult; } - static @NonNull GetPageReply fromMap(@NonNull Map map) { + static @NonNull GetPageReply fromList(@NonNull ArrayList list) { GetPageReply pigeonResult = new GetPageReply(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((String)id); - Object width = map.get("width"); + Object width = list.get(1); pigeonResult.setWidth((Double)width); - Object height = map.get("height"); + Object height = list.get(2); pigeonResult.setHeight((Double)height); return pigeonResult; } @@ -477,47 +478,47 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("pageId", pageId); - toMapResult.put("width", width); - toMapResult.put("height", height); - toMapResult.put("format", format); - toMapResult.put("backgroundColor", backgroundColor); - toMapResult.put("crop", crop); - toMapResult.put("cropX", cropX); - toMapResult.put("cropY", cropY); - toMapResult.put("cropHeight", cropHeight); - toMapResult.put("cropWidth", cropWidth); - toMapResult.put("quality", quality); - toMapResult.put("forPrint", forPrint); - return toMapResult; - } - static @NonNull RenderPageMessage fromMap(@NonNull Map map) { + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(12); + toListResult.add(pageId); + toListResult.add(width); + toListResult.add(height); + toListResult.add(format); + toListResult.add(backgroundColor); + toListResult.add(crop); + toListResult.add(cropX); + toListResult.add(cropY); + toListResult.add(cropHeight); + toListResult.add(cropWidth); + toListResult.add(quality); + toListResult.add(forPrint); + return toListResult; + } + static @NonNull RenderPageMessage fromList(@NonNull ArrayList list) { RenderPageMessage pigeonResult = new RenderPageMessage(); - Object pageId = map.get("pageId"); + Object pageId = list.get(0); pigeonResult.setPageId((String)pageId); - Object width = map.get("width"); + Object width = list.get(1); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = map.get("height"); + Object height = list.get(2); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object format = map.get("format"); + Object format = list.get(3); pigeonResult.setFormat((format == null) ? null : ((format instanceof Integer) ? (Integer)format : (Long)format)); - Object backgroundColor = map.get("backgroundColor"); + Object backgroundColor = list.get(4); pigeonResult.setBackgroundColor((String)backgroundColor); - Object crop = map.get("crop"); + Object crop = list.get(5); pigeonResult.setCrop((Boolean)crop); - Object cropX = map.get("cropX"); + Object cropX = list.get(6); pigeonResult.setCropX((cropX == null) ? null : ((cropX instanceof Integer) ? (Integer)cropX : (Long)cropX)); - Object cropY = map.get("cropY"); + Object cropY = list.get(7); pigeonResult.setCropY((cropY == null) ? null : ((cropY instanceof Integer) ? (Integer)cropY : (Long)cropY)); - Object cropHeight = map.get("cropHeight"); + Object cropHeight = list.get(8); pigeonResult.setCropHeight((cropHeight == null) ? null : ((cropHeight instanceof Integer) ? (Integer)cropHeight : (Long)cropHeight)); - Object cropWidth = map.get("cropWidth"); + Object cropWidth = list.get(9); pigeonResult.setCropWidth((cropWidth == null) ? null : ((cropWidth instanceof Integer) ? (Integer)cropWidth : (Long)cropWidth)); - Object quality = map.get("quality"); + Object quality = list.get(10); pigeonResult.setQuality((quality == null) ? null : ((quality instanceof Integer) ? (Integer)quality : (Long)quality)); - Object forPrint = map.get("forPrint"); + Object forPrint = list.get(11); pigeonResult.setForPrint((Boolean)forPrint); return pigeonResult; } @@ -579,23 +580,23 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("width", width); - toMapResult.put("height", height); - toMapResult.put("path", path); - toMapResult.put("data", data); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(4); + toListResult.add(width); + toListResult.add(height); + toListResult.add(path); + toListResult.add(data); + return toListResult; } - static @NonNull RenderPageReply fromMap(@NonNull Map map) { + static @NonNull RenderPageReply fromList(@NonNull ArrayList list) { RenderPageReply pigeonResult = new RenderPageReply(); - Object width = map.get("width"); + Object width = list.get(0); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = map.get("height"); + Object height = list.get(1); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object path = map.get("path"); + Object path = list.get(2); pigeonResult.setPath((String)path); - Object data = map.get("data"); + Object data = list.get(3); pigeonResult.setData((byte[])data); return pigeonResult; } @@ -621,14 +622,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(1); + toListResult.add(id); + return toListResult; } - static @NonNull RegisterTextureReply fromMap(@NonNull Map map) { + static @NonNull RegisterTextureReply fromList(@NonNull ArrayList list) { RegisterTextureReply pigeonResult = new RegisterTextureReply(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((id == null) ? null : ((id instanceof Integer) ? (Integer)id : (Long)id)); return pigeonResult; } @@ -834,59 +835,59 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("documentId", documentId); - toMapResult.put("pageNumber", pageNumber); - toMapResult.put("pageId", pageId); - toMapResult.put("textureId", textureId); - toMapResult.put("width", width); - toMapResult.put("height", height); - toMapResult.put("backgroundColor", backgroundColor); - toMapResult.put("sourceX", sourceX); - toMapResult.put("sourceY", sourceY); - toMapResult.put("destinationX", destinationX); - toMapResult.put("destinationY", destinationY); - toMapResult.put("fullWidth", fullWidth); - toMapResult.put("fullHeight", fullHeight); - toMapResult.put("textureWidth", textureWidth); - toMapResult.put("textureHeight", textureHeight); - toMapResult.put("allowAntiAliasing", allowAntiAliasing); - return toMapResult; - } - static @NonNull UpdateTextureMessage fromMap(@NonNull Map map) { + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(16); + toListResult.add(documentId); + toListResult.add(pageNumber); + toListResult.add(pageId); + toListResult.add(textureId); + toListResult.add(width); + toListResult.add(height); + toListResult.add(backgroundColor); + toListResult.add(sourceX); + toListResult.add(sourceY); + toListResult.add(destinationX); + toListResult.add(destinationY); + toListResult.add(fullWidth); + toListResult.add(fullHeight); + toListResult.add(textureWidth); + toListResult.add(textureHeight); + toListResult.add(allowAntiAliasing); + return toListResult; + } + static @NonNull UpdateTextureMessage fromList(@NonNull ArrayList list) { UpdateTextureMessage pigeonResult = new UpdateTextureMessage(); - Object documentId = map.get("documentId"); + Object documentId = list.get(0); pigeonResult.setDocumentId((String)documentId); - Object pageNumber = map.get("pageNumber"); + Object pageNumber = list.get(1); pigeonResult.setPageNumber((pageNumber == null) ? null : ((pageNumber instanceof Integer) ? (Integer)pageNumber : (Long)pageNumber)); - Object pageId = map.get("pageId"); + Object pageId = list.get(2); pigeonResult.setPageId((String)pageId); - Object textureId = map.get("textureId"); + Object textureId = list.get(3); pigeonResult.setTextureId((textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId)); - Object width = map.get("width"); + Object width = list.get(4); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = map.get("height"); + Object height = list.get(5); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object backgroundColor = map.get("backgroundColor"); + Object backgroundColor = list.get(6); pigeonResult.setBackgroundColor((String)backgroundColor); - Object sourceX = map.get("sourceX"); + Object sourceX = list.get(7); pigeonResult.setSourceX((sourceX == null) ? null : ((sourceX instanceof Integer) ? (Integer)sourceX : (Long)sourceX)); - Object sourceY = map.get("sourceY"); + Object sourceY = list.get(8); pigeonResult.setSourceY((sourceY == null) ? null : ((sourceY instanceof Integer) ? (Integer)sourceY : (Long)sourceY)); - Object destinationX = map.get("destinationX"); + Object destinationX = list.get(9); pigeonResult.setDestinationX((destinationX == null) ? null : ((destinationX instanceof Integer) ? (Integer)destinationX : (Long)destinationX)); - Object destinationY = map.get("destinationY"); + Object destinationY = list.get(10); pigeonResult.setDestinationY((destinationY == null) ? null : ((destinationY instanceof Integer) ? (Integer)destinationY : (Long)destinationY)); - Object fullWidth = map.get("fullWidth"); + Object fullWidth = list.get(11); pigeonResult.setFullWidth((Double)fullWidth); - Object fullHeight = map.get("fullHeight"); + Object fullHeight = list.get(12); pigeonResult.setFullHeight((Double)fullHeight); - Object textureWidth = map.get("textureWidth"); + Object textureWidth = list.get(13); pigeonResult.setTextureWidth((textureWidth == null) ? null : ((textureWidth instanceof Integer) ? (Integer)textureWidth : (Long)textureWidth)); - Object textureHeight = map.get("textureHeight"); + Object textureHeight = list.get(14); pigeonResult.setTextureHeight((textureHeight == null) ? null : ((textureHeight instanceof Integer) ? (Integer)textureHeight : (Long)textureHeight)); - Object allowAntiAliasing = map.get("allowAntiAliasing"); + Object allowAntiAliasing = list.get(15); pigeonResult.setAllowAntiAliasing((Boolean)allowAntiAliasing); return pigeonResult; } @@ -936,20 +937,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("textureId", textureId); - toMapResult.put("width", width); - toMapResult.put("height", height); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(3); + toListResult.add(textureId); + toListResult.add(width); + toListResult.add(height); + return toListResult; } - static @NonNull ResizeTextureMessage fromMap(@NonNull Map map) { + static @NonNull ResizeTextureMessage fromList(@NonNull ArrayList list) { ResizeTextureMessage pigeonResult = new ResizeTextureMessage(); - Object textureId = map.get("textureId"); + Object textureId = list.get(0); pigeonResult.setTextureId((textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId)); - Object width = map.get("width"); + Object width = list.get(1); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = map.get("height"); + Object height = list.get(2); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); return pigeonResult; } @@ -975,14 +976,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(1); + toListResult.add(id); + return toListResult; } - static @NonNull UnregisterTextureMessage fromMap(@NonNull Map map) { + static @NonNull UnregisterTextureMessage fromList(@NonNull ArrayList list) { UnregisterTextureMessage pigeonResult = new UnregisterTextureMessage(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((id == null) ? null : ((id instanceof Integer) ? (Integer)id : (Long)id)); return pigeonResult; } @@ -999,40 +1000,40 @@ private PdfxApiCodec() {} protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { switch (type) { case (byte)128: - return GetPageMessage.fromMap((Map) readValue(buffer)); + return GetPageMessage.fromList((ArrayList) readValue(buffer)); case (byte)129: - return GetPageReply.fromMap((Map) readValue(buffer)); + return GetPageReply.fromList((ArrayList) readValue(buffer)); case (byte)130: - return IdMessage.fromMap((Map) readValue(buffer)); + return IdMessage.fromList((ArrayList) readValue(buffer)); case (byte)131: - return OpenDataMessage.fromMap((Map) readValue(buffer)); + return OpenDataMessage.fromList((ArrayList) readValue(buffer)); case (byte)132: - return OpenPathMessage.fromMap((Map) readValue(buffer)); + return OpenPathMessage.fromList((ArrayList) readValue(buffer)); case (byte)133: - return OpenReply.fromMap((Map) readValue(buffer)); + return OpenReply.fromList((ArrayList) readValue(buffer)); case (byte)134: - return RegisterTextureReply.fromMap((Map) readValue(buffer)); + return RegisterTextureReply.fromList((ArrayList) readValue(buffer)); case (byte)135: - return RenderPageMessage.fromMap((Map) readValue(buffer)); + return RenderPageMessage.fromList((ArrayList) readValue(buffer)); case (byte)136: - return RenderPageReply.fromMap((Map) readValue(buffer)); + return RenderPageReply.fromList((ArrayList) readValue(buffer)); case (byte)137: - return ResizeTextureMessage.fromMap((Map) readValue(buffer)); + return ResizeTextureMessage.fromList((ArrayList) readValue(buffer)); case (byte)138: - return UnregisterTextureMessage.fromMap((Map) readValue(buffer)); + return UnregisterTextureMessage.fromList((ArrayList) readValue(buffer)); case (byte)139: - return UpdateTextureMessage.fromMap((Map) readValue(buffer)); + return UpdateTextureMessage.fromList((ArrayList) readValue(buffer)); default: return super.readValueOfType(type, buffer); @@ -1043,51 +1044,51 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { if (value instanceof GetPageMessage) { stream.write(128); - writeValue(stream, ((GetPageMessage) value).toMap()); + writeValue(stream, ((GetPageMessage) value).toList()); } else if (value instanceof GetPageReply) { stream.write(129); - writeValue(stream, ((GetPageReply) value).toMap()); + writeValue(stream, ((GetPageReply) value).toList()); } else if (value instanceof IdMessage) { stream.write(130); - writeValue(stream, ((IdMessage) value).toMap()); + writeValue(stream, ((IdMessage) value).toList()); } else if (value instanceof OpenDataMessage) { stream.write(131); - writeValue(stream, ((OpenDataMessage) value).toMap()); + writeValue(stream, ((OpenDataMessage) value).toList()); } else if (value instanceof OpenPathMessage) { stream.write(132); - writeValue(stream, ((OpenPathMessage) value).toMap()); + writeValue(stream, ((OpenPathMessage) value).toList()); } else if (value instanceof OpenReply) { stream.write(133); - writeValue(stream, ((OpenReply) value).toMap()); + writeValue(stream, ((OpenReply) value).toList()); } else if (value instanceof RegisterTextureReply) { stream.write(134); - writeValue(stream, ((RegisterTextureReply) value).toMap()); + writeValue(stream, ((RegisterTextureReply) value).toList()); } else if (value instanceof RenderPageMessage) { stream.write(135); - writeValue(stream, ((RenderPageMessage) value).toMap()); + writeValue(stream, ((RenderPageMessage) value).toList()); } else if (value instanceof RenderPageReply) { stream.write(136); - writeValue(stream, ((RenderPageReply) value).toMap()); + writeValue(stream, ((RenderPageReply) value).toList()); } else if (value instanceof ResizeTextureMessage) { stream.write(137); - writeValue(stream, ((ResizeTextureMessage) value).toMap()); + writeValue(stream, ((ResizeTextureMessage) value).toList()); } else if (value instanceof UnregisterTextureMessage) { stream.write(138); - writeValue(stream, ((UnregisterTextureMessage) value).toMap()); + writeValue(stream, ((UnregisterTextureMessage) value).toList()); } else if (value instanceof UpdateTextureMessage) { stream.write(139); - writeValue(stream, ((UpdateTextureMessage) value).toMap()); + writeValue(stream, ((UpdateTextureMessage) value).toList()); } else { super.writeValue(stream, value); @@ -1120,9 +1121,7 @@ public interface PdfxApi { /** The codec used by PdfxApi. */ static MessageCodec getCodec() { - return PdfxApiCodec.INSTANCE; - } - + return PdfxApiCodec.INSTANCE; } /**Sets up an instance of `PdfxApi` to handle messages through the `binaryMessenger`. */ static void setup(BinaryMessenger binaryMessenger, PdfxApi api) { { @@ -1130,29 +1129,30 @@ static void setup(BinaryMessenger binaryMessenger, PdfxApi api) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentData", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; OpenDataMessage messageArg = (OpenDataMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.openDocumentData(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1164,29 +1164,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentFile", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; OpenPathMessage messageArg = (OpenPathMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.openDocumentFile(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1198,29 +1199,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentAsset", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; OpenPathMessage messageArg = (OpenPathMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.openDocumentAsset(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1232,18 +1234,20 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.closeDocument", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; IdMessage messageArg = (IdMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.closeDocument(messageArg); - wrapped.put("result", null); + wrapped.add(0, null); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; } reply.reply(wrapped); }); @@ -1256,29 +1260,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.getPage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; GetPageMessage messageArg = (GetPageMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(GetPageReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.getPage(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1290,29 +1295,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.renderPage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; RenderPageMessage messageArg = (RenderPageMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(RenderPageReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.renderPage(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1324,18 +1330,20 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.closePage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; IdMessage messageArg = (IdMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.closePage(messageArg); - wrapped.put("result", null); + wrapped.add(0, null); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; } reply.reply(wrapped); }); @@ -1348,13 +1356,14 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.registerTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { RegisterTextureReply output = api.registerTexture(); - wrapped.put("result", output); + wrapped.add(0, output); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; } reply.reply(wrapped); }); @@ -1367,29 +1376,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.updateTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; UpdateTextureMessage messageArg = (UpdateTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(Void result) { - wrapped.put("result", null); + wrapped.add(0, null); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.updateTexture(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1401,29 +1411,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.resizeTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; ResizeTextureMessage messageArg = (ResizeTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(Void result) { - wrapped.put("result", null); + wrapped.add(0, null); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.resizeTexture(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1435,18 +1446,20 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.unregisterTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; UnregisterTextureMessage messageArg = (UnregisterTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.unregisterTexture(messageArg); - wrapped.put("result", null); + wrapped.add(0, null); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; } reply.reply(wrapped); }); @@ -1456,11 +1469,11 @@ public void error(Throwable error) { } } } - @NonNull private static Map wrapError(@NonNull Throwable exception) { - Map errorMap = new HashMap<>(); - errorMap.put("message", exception.toString()); - errorMap.put("code", exception.getClass().getSimpleName()); - errorMap.put("details", "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); - return errorMap; + @NonNull private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(3); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add("Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; } } diff --git a/packages/pdfx/ios/Classes/messages.h b/packages/pdfx/ios/Classes/messages.h index 5b0aef71..3d3134b5 100644 --- a/packages/pdfx/ios/Classes/messages.h +++ b/packages/pdfx/ios/Classes/messages.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @protocol FlutterBinaryMessenger; @@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong, nullable) NSNumber * id; @end -///The codec used by PdfxApi. +/// The codec used by PdfxApi. NSObject *PdfxApiGetCodec(void); /// Rebuild: `flutter pub run pigeon --input pigeons/message.dart` diff --git a/packages/pdfx/ios/Classes/messages.m b/packages/pdfx/ios/Classes/messages.m index 6070a468..c5d4bfab 100644 --- a/packages/pdfx/ios/Classes/messages.m +++ b/packages/pdfx/ios/Classes/messages.m @@ -1,29 +1,17 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.h" -#if TARGET_OS_IOS #import -#else -#import -#endif #if !__has_feature(objc_arc) #error File requires ARC to be enabled. #endif -static NSDictionary *wrapResult(id result, FlutterError *error) { - NSDictionary *errorDict = (NSDictionary *)[NSNull null]; +static NSArray *wrapResult(id result, FlutterError *error) { if (error) { - errorDict = @{ - @"code": (error.code ?: [NSNull null]), - @"message": (error.message ?: [NSNull null]), - @"details": (error.details ?: [NSNull null]), - }; + return @[ error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] ]; } - return @{ - @"result": (result ?: [NSNull null]), - @"error": errorDict, - }; + return @[ result ?: [NSNull null] ]; } static id GetNullableObject(NSDictionary* dict, id key) { id result = dict[key]; @@ -36,64 +24,64 @@ static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { @interface OpenDataMessage () -+ (OpenDataMessage *)fromMap:(NSDictionary *)dict; -+ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenDataMessage *)fromList:(NSArray *)list; ++ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface OpenPathMessage () -+ (OpenPathMessage *)fromMap:(NSDictionary *)dict; -+ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenPathMessage *)fromList:(NSArray *)list; ++ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface OpenReply () -+ (OpenReply *)fromMap:(NSDictionary *)dict; -+ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenReply *)fromList:(NSArray *)list; ++ (nullable OpenReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface IdMessage () -+ (IdMessage *)fromMap:(NSDictionary *)dict; -+ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (IdMessage *)fromList:(NSArray *)list; ++ (nullable IdMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface GetPageMessage () -+ (GetPageMessage *)fromMap:(NSDictionary *)dict; -+ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (GetPageMessage *)fromList:(NSArray *)list; ++ (nullable GetPageMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface GetPageReply () -+ (GetPageReply *)fromMap:(NSDictionary *)dict; -+ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (GetPageReply *)fromList:(NSArray *)list; ++ (nullable GetPageReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RenderPageMessage () -+ (RenderPageMessage *)fromMap:(NSDictionary *)dict; -+ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RenderPageMessage *)fromList:(NSArray *)list; ++ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RenderPageReply () -+ (RenderPageReply *)fromMap:(NSDictionary *)dict; -+ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RenderPageReply *)fromList:(NSArray *)list; ++ (nullable RenderPageReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RegisterTextureReply () -+ (RegisterTextureReply *)fromMap:(NSDictionary *)dict; -+ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RegisterTextureReply *)fromList:(NSArray *)list; ++ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface UpdateTextureMessage () -+ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (UpdateTextureMessage *)fromList:(NSArray *)list; ++ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface ResizeTextureMessage () -+ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (ResizeTextureMessage *)fromList:(NSArray *)list; ++ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface UnregisterTextureMessage () -+ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (UnregisterTextureMessage *)fromList:(NSArray *)list; ++ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @implementation OpenDataMessage @@ -104,18 +92,18 @@ + (instancetype)makeWithData:(nullable FlutterStandardTypedData *)data pigeonResult.password = password; return pigeonResult; } -+ (OpenDataMessage *)fromMap:(NSDictionary *)dict { ++ (OpenDataMessage *)fromList:(NSArray *)list { OpenDataMessage *pigeonResult = [[OpenDataMessage alloc] init]; - pigeonResult.data = GetNullableObject(dict, @"data"); - pigeonResult.password = GetNullableObject(dict, @"password"); + pigeonResult.data = GetNullableObjectAtIndex(list, 0); + pigeonResult.password = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenDataMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"data" : (self.data ?: [NSNull null]), - @"password" : (self.password ?: [NSNull null]), - }; ++ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenDataMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.data ?: [NSNull null]), + (self.password ?: [NSNull null]), + ]; } @end @@ -127,18 +115,18 @@ + (instancetype)makeWithPath:(nullable NSString *)path pigeonResult.password = password; return pigeonResult; } -+ (OpenPathMessage *)fromMap:(NSDictionary *)dict { ++ (OpenPathMessage *)fromList:(NSArray *)list { OpenPathMessage *pigeonResult = [[OpenPathMessage alloc] init]; - pigeonResult.path = GetNullableObject(dict, @"path"); - pigeonResult.password = GetNullableObject(dict, @"password"); + pigeonResult.path = GetNullableObjectAtIndex(list, 0); + pigeonResult.password = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenPathMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"path" : (self.path ?: [NSNull null]), - @"password" : (self.password ?: [NSNull null]), - }; ++ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenPathMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.path ?: [NSNull null]), + (self.password ?: [NSNull null]), + ]; } @end @@ -150,18 +138,18 @@ + (instancetype)makeWithId:(nullable NSString *)id pigeonResult.pagesCount = pagesCount; return pigeonResult; } -+ (OpenReply *)fromMap:(NSDictionary *)dict { ++ (OpenReply *)fromList:(NSArray *)list { OpenReply *pigeonResult = [[OpenReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); - pigeonResult.pagesCount = GetNullableObject(dict, @"pagesCount"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.pagesCount = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - @"pagesCount" : (self.pagesCount ?: [NSNull null]), - }; ++ (nullable OpenReply *)nullableFromList:(NSArray *)list { return (list) ? [OpenReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + (self.pagesCount ?: [NSNull null]), + ]; } @end @@ -171,16 +159,16 @@ + (instancetype)makeWithId:(nullable NSString *)id { pigeonResult.id = id; return pigeonResult; } -+ (IdMessage *)fromMap:(NSDictionary *)dict { ++ (IdMessage *)fromList:(NSArray *)list { IdMessage *pigeonResult = [[IdMessage alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [IdMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable IdMessage *)nullableFromList:(NSArray *)list { return (list) ? [IdMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -194,20 +182,20 @@ + (instancetype)makeWithDocumentId:(nullable NSString *)documentId pigeonResult.autoCloseAndroid = autoCloseAndroid; return pigeonResult; } -+ (GetPageMessage *)fromMap:(NSDictionary *)dict { ++ (GetPageMessage *)fromList:(NSArray *)list { GetPageMessage *pigeonResult = [[GetPageMessage alloc] init]; - pigeonResult.documentId = GetNullableObject(dict, @"documentId"); - pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); - pigeonResult.autoCloseAndroid = GetNullableObject(dict, @"autoCloseAndroid"); + pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); + pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); + pigeonResult.autoCloseAndroid = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"documentId" : (self.documentId ?: [NSNull null]), - @"pageNumber" : (self.pageNumber ?: [NSNull null]), - @"autoCloseAndroid" : (self.autoCloseAndroid ?: [NSNull null]), - }; ++ (nullable GetPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [GetPageMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.documentId ?: [NSNull null]), + (self.pageNumber ?: [NSNull null]), + (self.autoCloseAndroid ?: [NSNull null]), + ]; } @end @@ -221,20 +209,20 @@ + (instancetype)makeWithId:(nullable NSString *)id pigeonResult.height = height; return pigeonResult; } -+ (GetPageReply *)fromMap:(NSDictionary *)dict { ++ (GetPageReply *)fromList:(NSArray *)list { GetPageReply *pigeonResult = [[GetPageReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - }; ++ (nullable GetPageReply *)nullableFromList:(NSArray *)list { return (list) ? [GetPageReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + ]; } @end @@ -266,38 +254,38 @@ + (instancetype)makeWithPageId:(nullable NSString *)pageId pigeonResult.forPrint = forPrint; return pigeonResult; } -+ (RenderPageMessage *)fromMap:(NSDictionary *)dict { ++ (RenderPageMessage *)fromList:(NSArray *)list { RenderPageMessage *pigeonResult = [[RenderPageMessage alloc] init]; - pigeonResult.pageId = GetNullableObject(dict, @"pageId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.format = GetNullableObject(dict, @"format"); - pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); - pigeonResult.crop = GetNullableObject(dict, @"crop"); - pigeonResult.cropX = GetNullableObject(dict, @"cropX"); - pigeonResult.cropY = GetNullableObject(dict, @"cropY"); - pigeonResult.cropHeight = GetNullableObject(dict, @"cropHeight"); - pigeonResult.cropWidth = GetNullableObject(dict, @"cropWidth"); - pigeonResult.quality = GetNullableObject(dict, @"quality"); - pigeonResult.forPrint = GetNullableObject(dict, @"forPrint"); + pigeonResult.pageId = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); + pigeonResult.format = GetNullableObjectAtIndex(list, 3); + pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 4); + pigeonResult.crop = GetNullableObjectAtIndex(list, 5); + pigeonResult.cropX = GetNullableObjectAtIndex(list, 6); + pigeonResult.cropY = GetNullableObjectAtIndex(list, 7); + pigeonResult.cropHeight = GetNullableObjectAtIndex(list, 8); + pigeonResult.cropWidth = GetNullableObjectAtIndex(list, 9); + pigeonResult.quality = GetNullableObjectAtIndex(list, 10); + pigeonResult.forPrint = GetNullableObjectAtIndex(list, 11); return pigeonResult; } -+ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"pageId" : (self.pageId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"format" : (self.format ?: [NSNull null]), - @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), - @"crop" : (self.crop ?: [NSNull null]), - @"cropX" : (self.cropX ?: [NSNull null]), - @"cropY" : (self.cropY ?: [NSNull null]), - @"cropHeight" : (self.cropHeight ?: [NSNull null]), - @"cropWidth" : (self.cropWidth ?: [NSNull null]), - @"quality" : (self.quality ?: [NSNull null]), - @"forPrint" : (self.forPrint ?: [NSNull null]), - }; ++ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.pageId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.format ?: [NSNull null]), + (self.backgroundColor ?: [NSNull null]), + (self.crop ?: [NSNull null]), + (self.cropX ?: [NSNull null]), + (self.cropY ?: [NSNull null]), + (self.cropHeight ?: [NSNull null]), + (self.cropWidth ?: [NSNull null]), + (self.quality ?: [NSNull null]), + (self.forPrint ?: [NSNull null]), + ]; } @end @@ -313,22 +301,22 @@ + (instancetype)makeWithWidth:(nullable NSNumber *)width pigeonResult.data = data; return pigeonResult; } -+ (RenderPageReply *)fromMap:(NSDictionary *)dict { ++ (RenderPageReply *)fromList:(NSArray *)list { RenderPageReply *pigeonResult = [[RenderPageReply alloc] init]; - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.path = GetNullableObject(dict, @"path"); - pigeonResult.data = GetNullableObject(dict, @"data"); + pigeonResult.width = GetNullableObjectAtIndex(list, 0); + pigeonResult.height = GetNullableObjectAtIndex(list, 1); + pigeonResult.path = GetNullableObjectAtIndex(list, 2); + pigeonResult.data = GetNullableObjectAtIndex(list, 3); return pigeonResult; } -+ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"path" : (self.path ?: [NSNull null]), - @"data" : (self.data ?: [NSNull null]), - }; ++ (nullable RenderPageReply *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.path ?: [NSNull null]), + (self.data ?: [NSNull null]), + ]; } @end @@ -338,16 +326,16 @@ + (instancetype)makeWithId:(nullable NSNumber *)id { pigeonResult.id = id; return pigeonResult; } -+ (RegisterTextureReply *)fromMap:(NSDictionary *)dict { ++ (RegisterTextureReply *)fromList:(NSArray *)list { RegisterTextureReply *pigeonResult = [[RegisterTextureReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RegisterTextureReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list { return (list) ? [RegisterTextureReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -387,46 +375,46 @@ + (instancetype)makeWithDocumentId:(nullable NSString *)documentId pigeonResult.allowAntiAliasing = allowAntiAliasing; return pigeonResult; } -+ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict { ++ (UpdateTextureMessage *)fromList:(NSArray *)list { UpdateTextureMessage *pigeonResult = [[UpdateTextureMessage alloc] init]; - pigeonResult.documentId = GetNullableObject(dict, @"documentId"); - pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); - pigeonResult.pageId = GetNullableObject(dict, @"pageId"); - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); - pigeonResult.sourceX = GetNullableObject(dict, @"sourceX"); - pigeonResult.sourceY = GetNullableObject(dict, @"sourceY"); - pigeonResult.destinationX = GetNullableObject(dict, @"destinationX"); - pigeonResult.destinationY = GetNullableObject(dict, @"destinationY"); - pigeonResult.fullWidth = GetNullableObject(dict, @"fullWidth"); - pigeonResult.fullHeight = GetNullableObject(dict, @"fullHeight"); - pigeonResult.textureWidth = GetNullableObject(dict, @"textureWidth"); - pigeonResult.textureHeight = GetNullableObject(dict, @"textureHeight"); - pigeonResult.allowAntiAliasing = GetNullableObject(dict, @"allowAntiAliasing"); + pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); + pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); + pigeonResult.pageId = GetNullableObjectAtIndex(list, 2); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 3); + pigeonResult.width = GetNullableObjectAtIndex(list, 4); + pigeonResult.height = GetNullableObjectAtIndex(list, 5); + pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 6); + pigeonResult.sourceX = GetNullableObjectAtIndex(list, 7); + pigeonResult.sourceY = GetNullableObjectAtIndex(list, 8); + pigeonResult.destinationX = GetNullableObjectAtIndex(list, 9); + pigeonResult.destinationY = GetNullableObjectAtIndex(list, 10); + pigeonResult.fullWidth = GetNullableObjectAtIndex(list, 11); + pigeonResult.fullHeight = GetNullableObjectAtIndex(list, 12); + pigeonResult.textureWidth = GetNullableObjectAtIndex(list, 13); + pigeonResult.textureHeight = GetNullableObjectAtIndex(list, 14); + pigeonResult.allowAntiAliasing = GetNullableObjectAtIndex(list, 15); return pigeonResult; } -+ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UpdateTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"documentId" : (self.documentId ?: [NSNull null]), - @"pageNumber" : (self.pageNumber ?: [NSNull null]), - @"pageId" : (self.pageId ?: [NSNull null]), - @"textureId" : (self.textureId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), - @"sourceX" : (self.sourceX ?: [NSNull null]), - @"sourceY" : (self.sourceY ?: [NSNull null]), - @"destinationX" : (self.destinationX ?: [NSNull null]), - @"destinationY" : (self.destinationY ?: [NSNull null]), - @"fullWidth" : (self.fullWidth ?: [NSNull null]), - @"fullHeight" : (self.fullHeight ?: [NSNull null]), - @"textureWidth" : (self.textureWidth ?: [NSNull null]), - @"textureHeight" : (self.textureHeight ?: [NSNull null]), - @"allowAntiAliasing" : (self.allowAntiAliasing ?: [NSNull null]), - }; ++ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UpdateTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.documentId ?: [NSNull null]), + (self.pageNumber ?: [NSNull null]), + (self.pageId ?: [NSNull null]), + (self.textureId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.backgroundColor ?: [NSNull null]), + (self.sourceX ?: [NSNull null]), + (self.sourceY ?: [NSNull null]), + (self.destinationX ?: [NSNull null]), + (self.destinationY ?: [NSNull null]), + (self.fullWidth ?: [NSNull null]), + (self.fullHeight ?: [NSNull null]), + (self.textureWidth ?: [NSNull null]), + (self.textureHeight ?: [NSNull null]), + (self.allowAntiAliasing ?: [NSNull null]), + ]; } @end @@ -440,20 +428,20 @@ + (instancetype)makeWithTextureId:(nullable NSNumber *)textureId pigeonResult.height = height; return pigeonResult; } -+ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict { ++ (ResizeTextureMessage *)fromList:(NSArray *)list { ResizeTextureMessage *pigeonResult = [[ResizeTextureMessage alloc] init]; - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [ResizeTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"textureId" : (self.textureId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - }; ++ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [ResizeTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.textureId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + ]; } @end @@ -463,16 +451,16 @@ + (instancetype)makeWithId:(nullable NSNumber *)id { pigeonResult.id = id; return pigeonResult; } -+ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict { ++ (UnregisterTextureMessage *)fromList:(NSArray *)list { UnregisterTextureMessage *pigeonResult = [[UnregisterTextureMessage alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UnregisterTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UnregisterTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -483,40 +471,40 @@ - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 128: - return [GetPageMessage fromMap:[self readValue]]; + return [GetPageMessage fromList:[self readValue]]; case 129: - return [GetPageReply fromMap:[self readValue]]; + return [GetPageReply fromList:[self readValue]]; case 130: - return [IdMessage fromMap:[self readValue]]; + return [IdMessage fromList:[self readValue]]; case 131: - return [OpenDataMessage fromMap:[self readValue]]; + return [OpenDataMessage fromList:[self readValue]]; case 132: - return [OpenPathMessage fromMap:[self readValue]]; + return [OpenPathMessage fromList:[self readValue]]; case 133: - return [OpenReply fromMap:[self readValue]]; + return [OpenReply fromList:[self readValue]]; case 134: - return [RegisterTextureReply fromMap:[self readValue]]; + return [RegisterTextureReply fromList:[self readValue]]; case 135: - return [RenderPageMessage fromMap:[self readValue]]; + return [RenderPageMessage fromList:[self readValue]]; case 136: - return [RenderPageReply fromMap:[self readValue]]; + return [RenderPageReply fromList:[self readValue]]; case 137: - return [ResizeTextureMessage fromMap:[self readValue]]; + return [ResizeTextureMessage fromList:[self readValue]]; case 138: - return [UnregisterTextureMessage fromMap:[self readValue]]; + return [UnregisterTextureMessage fromList:[self readValue]]; case 139: - return [UpdateTextureMessage fromMap:[self readValue]]; + return [UpdateTextureMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -532,51 +520,51 @@ - (void)writeValue:(id)value { if ([value isKindOfClass:[GetPageMessage class]]) { [self writeByte:128]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[GetPageReply class]]) { [self writeByte:129]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[IdMessage class]]) { [self writeByte:130]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenDataMessage class]]) { [self writeByte:131]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenPathMessage class]]) { [self writeByte:132]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenReply class]]) { [self writeByte:133]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RegisterTextureReply class]]) { [self writeByte:134]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RenderPageMessage class]]) { [self writeByte:135]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RenderPageReply class]]) { [self writeByte:136]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[ResizeTextureMessage class]]) { [self writeByte:137]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[UnregisterTextureMessage class]]) { [self writeByte:138]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[UpdateTextureMessage class]]) { [self writeByte:139]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else { [super writeValue:value]; @@ -595,9 +583,10 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { } @end -NSObject *PdfxApiGetCodec(void) { - static dispatch_once_t sPred = 0; + +NSObject *PdfxApiGetCodec() { static FlutterStandardMessageCodec *sSharedObject = nil; + static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ PdfxApiCodecReaderWriter *readerWriter = [[PdfxApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; @@ -605,14 +594,13 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { return sSharedObject; } - void PdfxApiSetup(id binaryMessenger, NSObject *api) { { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentData" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentDataMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentDataMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -632,7 +620,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentFile" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentFileMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentFileMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -652,7 +640,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentAsset" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentAssetMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentAssetMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -672,7 +660,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.closeDocument" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(closeDocumentMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closeDocumentMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -692,7 +680,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.getPage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(getPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(getPageMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -712,7 +700,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.renderPage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(renderPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(renderPageMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -732,7 +720,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.closePage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(closePageMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closePageMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -752,7 +740,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.registerTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(registerTextureWithError:)], @"PdfxApi api (%@) doesn't respond to @selector(registerTextureWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -770,7 +758,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.updateTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(updateTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(updateTextureMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -790,7 +778,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.resizeTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(resizeTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(resizeTextureMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -810,7 +798,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.unregisterTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(unregisterTextureMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(unregisterTextureMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { diff --git a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h index 5b0aef71..3d3134b5 100644 --- a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h +++ b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @protocol FlutterBinaryMessenger; @@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong, nullable) NSNumber * id; @end -///The codec used by PdfxApi. +/// The codec used by PdfxApi. NSObject *PdfxApiGetCodec(void); /// Rebuild: `flutter pub run pigeon --input pigeons/message.dart` diff --git a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m index 6070a468..c5d4bfab 100644 --- a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m +++ b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m @@ -1,29 +1,17 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.h" -#if TARGET_OS_IOS #import -#else -#import -#endif #if !__has_feature(objc_arc) #error File requires ARC to be enabled. #endif -static NSDictionary *wrapResult(id result, FlutterError *error) { - NSDictionary *errorDict = (NSDictionary *)[NSNull null]; +static NSArray *wrapResult(id result, FlutterError *error) { if (error) { - errorDict = @{ - @"code": (error.code ?: [NSNull null]), - @"message": (error.message ?: [NSNull null]), - @"details": (error.details ?: [NSNull null]), - }; + return @[ error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] ]; } - return @{ - @"result": (result ?: [NSNull null]), - @"error": errorDict, - }; + return @[ result ?: [NSNull null] ]; } static id GetNullableObject(NSDictionary* dict, id key) { id result = dict[key]; @@ -36,64 +24,64 @@ static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { @interface OpenDataMessage () -+ (OpenDataMessage *)fromMap:(NSDictionary *)dict; -+ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenDataMessage *)fromList:(NSArray *)list; ++ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface OpenPathMessage () -+ (OpenPathMessage *)fromMap:(NSDictionary *)dict; -+ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenPathMessage *)fromList:(NSArray *)list; ++ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface OpenReply () -+ (OpenReply *)fromMap:(NSDictionary *)dict; -+ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenReply *)fromList:(NSArray *)list; ++ (nullable OpenReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface IdMessage () -+ (IdMessage *)fromMap:(NSDictionary *)dict; -+ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (IdMessage *)fromList:(NSArray *)list; ++ (nullable IdMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface GetPageMessage () -+ (GetPageMessage *)fromMap:(NSDictionary *)dict; -+ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (GetPageMessage *)fromList:(NSArray *)list; ++ (nullable GetPageMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface GetPageReply () -+ (GetPageReply *)fromMap:(NSDictionary *)dict; -+ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (GetPageReply *)fromList:(NSArray *)list; ++ (nullable GetPageReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RenderPageMessage () -+ (RenderPageMessage *)fromMap:(NSDictionary *)dict; -+ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RenderPageMessage *)fromList:(NSArray *)list; ++ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RenderPageReply () -+ (RenderPageReply *)fromMap:(NSDictionary *)dict; -+ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RenderPageReply *)fromList:(NSArray *)list; ++ (nullable RenderPageReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RegisterTextureReply () -+ (RegisterTextureReply *)fromMap:(NSDictionary *)dict; -+ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RegisterTextureReply *)fromList:(NSArray *)list; ++ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface UpdateTextureMessage () -+ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (UpdateTextureMessage *)fromList:(NSArray *)list; ++ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface ResizeTextureMessage () -+ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (ResizeTextureMessage *)fromList:(NSArray *)list; ++ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface UnregisterTextureMessage () -+ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (UnregisterTextureMessage *)fromList:(NSArray *)list; ++ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @implementation OpenDataMessage @@ -104,18 +92,18 @@ + (instancetype)makeWithData:(nullable FlutterStandardTypedData *)data pigeonResult.password = password; return pigeonResult; } -+ (OpenDataMessage *)fromMap:(NSDictionary *)dict { ++ (OpenDataMessage *)fromList:(NSArray *)list { OpenDataMessage *pigeonResult = [[OpenDataMessage alloc] init]; - pigeonResult.data = GetNullableObject(dict, @"data"); - pigeonResult.password = GetNullableObject(dict, @"password"); + pigeonResult.data = GetNullableObjectAtIndex(list, 0); + pigeonResult.password = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenDataMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"data" : (self.data ?: [NSNull null]), - @"password" : (self.password ?: [NSNull null]), - }; ++ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenDataMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.data ?: [NSNull null]), + (self.password ?: [NSNull null]), + ]; } @end @@ -127,18 +115,18 @@ + (instancetype)makeWithPath:(nullable NSString *)path pigeonResult.password = password; return pigeonResult; } -+ (OpenPathMessage *)fromMap:(NSDictionary *)dict { ++ (OpenPathMessage *)fromList:(NSArray *)list { OpenPathMessage *pigeonResult = [[OpenPathMessage alloc] init]; - pigeonResult.path = GetNullableObject(dict, @"path"); - pigeonResult.password = GetNullableObject(dict, @"password"); + pigeonResult.path = GetNullableObjectAtIndex(list, 0); + pigeonResult.password = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenPathMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"path" : (self.path ?: [NSNull null]), - @"password" : (self.password ?: [NSNull null]), - }; ++ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenPathMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.path ?: [NSNull null]), + (self.password ?: [NSNull null]), + ]; } @end @@ -150,18 +138,18 @@ + (instancetype)makeWithId:(nullable NSString *)id pigeonResult.pagesCount = pagesCount; return pigeonResult; } -+ (OpenReply *)fromMap:(NSDictionary *)dict { ++ (OpenReply *)fromList:(NSArray *)list { OpenReply *pigeonResult = [[OpenReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); - pigeonResult.pagesCount = GetNullableObject(dict, @"pagesCount"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.pagesCount = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - @"pagesCount" : (self.pagesCount ?: [NSNull null]), - }; ++ (nullable OpenReply *)nullableFromList:(NSArray *)list { return (list) ? [OpenReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + (self.pagesCount ?: [NSNull null]), + ]; } @end @@ -171,16 +159,16 @@ + (instancetype)makeWithId:(nullable NSString *)id { pigeonResult.id = id; return pigeonResult; } -+ (IdMessage *)fromMap:(NSDictionary *)dict { ++ (IdMessage *)fromList:(NSArray *)list { IdMessage *pigeonResult = [[IdMessage alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [IdMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable IdMessage *)nullableFromList:(NSArray *)list { return (list) ? [IdMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -194,20 +182,20 @@ + (instancetype)makeWithDocumentId:(nullable NSString *)documentId pigeonResult.autoCloseAndroid = autoCloseAndroid; return pigeonResult; } -+ (GetPageMessage *)fromMap:(NSDictionary *)dict { ++ (GetPageMessage *)fromList:(NSArray *)list { GetPageMessage *pigeonResult = [[GetPageMessage alloc] init]; - pigeonResult.documentId = GetNullableObject(dict, @"documentId"); - pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); - pigeonResult.autoCloseAndroid = GetNullableObject(dict, @"autoCloseAndroid"); + pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); + pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); + pigeonResult.autoCloseAndroid = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"documentId" : (self.documentId ?: [NSNull null]), - @"pageNumber" : (self.pageNumber ?: [NSNull null]), - @"autoCloseAndroid" : (self.autoCloseAndroid ?: [NSNull null]), - }; ++ (nullable GetPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [GetPageMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.documentId ?: [NSNull null]), + (self.pageNumber ?: [NSNull null]), + (self.autoCloseAndroid ?: [NSNull null]), + ]; } @end @@ -221,20 +209,20 @@ + (instancetype)makeWithId:(nullable NSString *)id pigeonResult.height = height; return pigeonResult; } -+ (GetPageReply *)fromMap:(NSDictionary *)dict { ++ (GetPageReply *)fromList:(NSArray *)list { GetPageReply *pigeonResult = [[GetPageReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - }; ++ (nullable GetPageReply *)nullableFromList:(NSArray *)list { return (list) ? [GetPageReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + ]; } @end @@ -266,38 +254,38 @@ + (instancetype)makeWithPageId:(nullable NSString *)pageId pigeonResult.forPrint = forPrint; return pigeonResult; } -+ (RenderPageMessage *)fromMap:(NSDictionary *)dict { ++ (RenderPageMessage *)fromList:(NSArray *)list { RenderPageMessage *pigeonResult = [[RenderPageMessage alloc] init]; - pigeonResult.pageId = GetNullableObject(dict, @"pageId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.format = GetNullableObject(dict, @"format"); - pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); - pigeonResult.crop = GetNullableObject(dict, @"crop"); - pigeonResult.cropX = GetNullableObject(dict, @"cropX"); - pigeonResult.cropY = GetNullableObject(dict, @"cropY"); - pigeonResult.cropHeight = GetNullableObject(dict, @"cropHeight"); - pigeonResult.cropWidth = GetNullableObject(dict, @"cropWidth"); - pigeonResult.quality = GetNullableObject(dict, @"quality"); - pigeonResult.forPrint = GetNullableObject(dict, @"forPrint"); + pigeonResult.pageId = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); + pigeonResult.format = GetNullableObjectAtIndex(list, 3); + pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 4); + pigeonResult.crop = GetNullableObjectAtIndex(list, 5); + pigeonResult.cropX = GetNullableObjectAtIndex(list, 6); + pigeonResult.cropY = GetNullableObjectAtIndex(list, 7); + pigeonResult.cropHeight = GetNullableObjectAtIndex(list, 8); + pigeonResult.cropWidth = GetNullableObjectAtIndex(list, 9); + pigeonResult.quality = GetNullableObjectAtIndex(list, 10); + pigeonResult.forPrint = GetNullableObjectAtIndex(list, 11); return pigeonResult; } -+ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"pageId" : (self.pageId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"format" : (self.format ?: [NSNull null]), - @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), - @"crop" : (self.crop ?: [NSNull null]), - @"cropX" : (self.cropX ?: [NSNull null]), - @"cropY" : (self.cropY ?: [NSNull null]), - @"cropHeight" : (self.cropHeight ?: [NSNull null]), - @"cropWidth" : (self.cropWidth ?: [NSNull null]), - @"quality" : (self.quality ?: [NSNull null]), - @"forPrint" : (self.forPrint ?: [NSNull null]), - }; ++ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.pageId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.format ?: [NSNull null]), + (self.backgroundColor ?: [NSNull null]), + (self.crop ?: [NSNull null]), + (self.cropX ?: [NSNull null]), + (self.cropY ?: [NSNull null]), + (self.cropHeight ?: [NSNull null]), + (self.cropWidth ?: [NSNull null]), + (self.quality ?: [NSNull null]), + (self.forPrint ?: [NSNull null]), + ]; } @end @@ -313,22 +301,22 @@ + (instancetype)makeWithWidth:(nullable NSNumber *)width pigeonResult.data = data; return pigeonResult; } -+ (RenderPageReply *)fromMap:(NSDictionary *)dict { ++ (RenderPageReply *)fromList:(NSArray *)list { RenderPageReply *pigeonResult = [[RenderPageReply alloc] init]; - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.path = GetNullableObject(dict, @"path"); - pigeonResult.data = GetNullableObject(dict, @"data"); + pigeonResult.width = GetNullableObjectAtIndex(list, 0); + pigeonResult.height = GetNullableObjectAtIndex(list, 1); + pigeonResult.path = GetNullableObjectAtIndex(list, 2); + pigeonResult.data = GetNullableObjectAtIndex(list, 3); return pigeonResult; } -+ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"path" : (self.path ?: [NSNull null]), - @"data" : (self.data ?: [NSNull null]), - }; ++ (nullable RenderPageReply *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.path ?: [NSNull null]), + (self.data ?: [NSNull null]), + ]; } @end @@ -338,16 +326,16 @@ + (instancetype)makeWithId:(nullable NSNumber *)id { pigeonResult.id = id; return pigeonResult; } -+ (RegisterTextureReply *)fromMap:(NSDictionary *)dict { ++ (RegisterTextureReply *)fromList:(NSArray *)list { RegisterTextureReply *pigeonResult = [[RegisterTextureReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RegisterTextureReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list { return (list) ? [RegisterTextureReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -387,46 +375,46 @@ + (instancetype)makeWithDocumentId:(nullable NSString *)documentId pigeonResult.allowAntiAliasing = allowAntiAliasing; return pigeonResult; } -+ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict { ++ (UpdateTextureMessage *)fromList:(NSArray *)list { UpdateTextureMessage *pigeonResult = [[UpdateTextureMessage alloc] init]; - pigeonResult.documentId = GetNullableObject(dict, @"documentId"); - pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); - pigeonResult.pageId = GetNullableObject(dict, @"pageId"); - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); - pigeonResult.sourceX = GetNullableObject(dict, @"sourceX"); - pigeonResult.sourceY = GetNullableObject(dict, @"sourceY"); - pigeonResult.destinationX = GetNullableObject(dict, @"destinationX"); - pigeonResult.destinationY = GetNullableObject(dict, @"destinationY"); - pigeonResult.fullWidth = GetNullableObject(dict, @"fullWidth"); - pigeonResult.fullHeight = GetNullableObject(dict, @"fullHeight"); - pigeonResult.textureWidth = GetNullableObject(dict, @"textureWidth"); - pigeonResult.textureHeight = GetNullableObject(dict, @"textureHeight"); - pigeonResult.allowAntiAliasing = GetNullableObject(dict, @"allowAntiAliasing"); + pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); + pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); + pigeonResult.pageId = GetNullableObjectAtIndex(list, 2); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 3); + pigeonResult.width = GetNullableObjectAtIndex(list, 4); + pigeonResult.height = GetNullableObjectAtIndex(list, 5); + pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 6); + pigeonResult.sourceX = GetNullableObjectAtIndex(list, 7); + pigeonResult.sourceY = GetNullableObjectAtIndex(list, 8); + pigeonResult.destinationX = GetNullableObjectAtIndex(list, 9); + pigeonResult.destinationY = GetNullableObjectAtIndex(list, 10); + pigeonResult.fullWidth = GetNullableObjectAtIndex(list, 11); + pigeonResult.fullHeight = GetNullableObjectAtIndex(list, 12); + pigeonResult.textureWidth = GetNullableObjectAtIndex(list, 13); + pigeonResult.textureHeight = GetNullableObjectAtIndex(list, 14); + pigeonResult.allowAntiAliasing = GetNullableObjectAtIndex(list, 15); return pigeonResult; } -+ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UpdateTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"documentId" : (self.documentId ?: [NSNull null]), - @"pageNumber" : (self.pageNumber ?: [NSNull null]), - @"pageId" : (self.pageId ?: [NSNull null]), - @"textureId" : (self.textureId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), - @"sourceX" : (self.sourceX ?: [NSNull null]), - @"sourceY" : (self.sourceY ?: [NSNull null]), - @"destinationX" : (self.destinationX ?: [NSNull null]), - @"destinationY" : (self.destinationY ?: [NSNull null]), - @"fullWidth" : (self.fullWidth ?: [NSNull null]), - @"fullHeight" : (self.fullHeight ?: [NSNull null]), - @"textureWidth" : (self.textureWidth ?: [NSNull null]), - @"textureHeight" : (self.textureHeight ?: [NSNull null]), - @"allowAntiAliasing" : (self.allowAntiAliasing ?: [NSNull null]), - }; ++ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UpdateTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.documentId ?: [NSNull null]), + (self.pageNumber ?: [NSNull null]), + (self.pageId ?: [NSNull null]), + (self.textureId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.backgroundColor ?: [NSNull null]), + (self.sourceX ?: [NSNull null]), + (self.sourceY ?: [NSNull null]), + (self.destinationX ?: [NSNull null]), + (self.destinationY ?: [NSNull null]), + (self.fullWidth ?: [NSNull null]), + (self.fullHeight ?: [NSNull null]), + (self.textureWidth ?: [NSNull null]), + (self.textureHeight ?: [NSNull null]), + (self.allowAntiAliasing ?: [NSNull null]), + ]; } @end @@ -440,20 +428,20 @@ + (instancetype)makeWithTextureId:(nullable NSNumber *)textureId pigeonResult.height = height; return pigeonResult; } -+ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict { ++ (ResizeTextureMessage *)fromList:(NSArray *)list { ResizeTextureMessage *pigeonResult = [[ResizeTextureMessage alloc] init]; - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [ResizeTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"textureId" : (self.textureId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - }; ++ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [ResizeTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.textureId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + ]; } @end @@ -463,16 +451,16 @@ + (instancetype)makeWithId:(nullable NSNumber *)id { pigeonResult.id = id; return pigeonResult; } -+ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict { ++ (UnregisterTextureMessage *)fromList:(NSArray *)list { UnregisterTextureMessage *pigeonResult = [[UnregisterTextureMessage alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UnregisterTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UnregisterTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -483,40 +471,40 @@ - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 128: - return [GetPageMessage fromMap:[self readValue]]; + return [GetPageMessage fromList:[self readValue]]; case 129: - return [GetPageReply fromMap:[self readValue]]; + return [GetPageReply fromList:[self readValue]]; case 130: - return [IdMessage fromMap:[self readValue]]; + return [IdMessage fromList:[self readValue]]; case 131: - return [OpenDataMessage fromMap:[self readValue]]; + return [OpenDataMessage fromList:[self readValue]]; case 132: - return [OpenPathMessage fromMap:[self readValue]]; + return [OpenPathMessage fromList:[self readValue]]; case 133: - return [OpenReply fromMap:[self readValue]]; + return [OpenReply fromList:[self readValue]]; case 134: - return [RegisterTextureReply fromMap:[self readValue]]; + return [RegisterTextureReply fromList:[self readValue]]; case 135: - return [RenderPageMessage fromMap:[self readValue]]; + return [RenderPageMessage fromList:[self readValue]]; case 136: - return [RenderPageReply fromMap:[self readValue]]; + return [RenderPageReply fromList:[self readValue]]; case 137: - return [ResizeTextureMessage fromMap:[self readValue]]; + return [ResizeTextureMessage fromList:[self readValue]]; case 138: - return [UnregisterTextureMessage fromMap:[self readValue]]; + return [UnregisterTextureMessage fromList:[self readValue]]; case 139: - return [UpdateTextureMessage fromMap:[self readValue]]; + return [UpdateTextureMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -532,51 +520,51 @@ - (void)writeValue:(id)value { if ([value isKindOfClass:[GetPageMessage class]]) { [self writeByte:128]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[GetPageReply class]]) { [self writeByte:129]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[IdMessage class]]) { [self writeByte:130]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenDataMessage class]]) { [self writeByte:131]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenPathMessage class]]) { [self writeByte:132]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenReply class]]) { [self writeByte:133]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RegisterTextureReply class]]) { [self writeByte:134]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RenderPageMessage class]]) { [self writeByte:135]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RenderPageReply class]]) { [self writeByte:136]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[ResizeTextureMessage class]]) { [self writeByte:137]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[UnregisterTextureMessage class]]) { [self writeByte:138]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[UpdateTextureMessage class]]) { [self writeByte:139]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else { [super writeValue:value]; @@ -595,9 +583,10 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { } @end -NSObject *PdfxApiGetCodec(void) { - static dispatch_once_t sPred = 0; + +NSObject *PdfxApiGetCodec() { static FlutterStandardMessageCodec *sSharedObject = nil; + static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ PdfxApiCodecReaderWriter *readerWriter = [[PdfxApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; @@ -605,14 +594,13 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { return sSharedObject; } - void PdfxApiSetup(id binaryMessenger, NSObject *api) { { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentData" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentDataMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentDataMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -632,7 +620,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentFile" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentFileMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentFileMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -652,7 +640,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentAsset" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentAssetMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentAssetMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -672,7 +660,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.closeDocument" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(closeDocumentMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closeDocumentMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -692,7 +680,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.getPage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(getPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(getPageMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -712,7 +700,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.renderPage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(renderPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(renderPageMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -732,7 +720,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.closePage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(closePageMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closePageMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -752,7 +740,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.registerTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(registerTextureWithError:)], @"PdfxApi api (%@) doesn't respond to @selector(registerTextureWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -770,7 +758,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.updateTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(updateTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(updateTextureMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -790,7 +778,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.resizeTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(resizeTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(resizeTextureMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -810,7 +798,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.unregisterTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(unregisterTextureMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(unregisterTextureMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift index bb2a3b0a..1d4970ba 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift @@ -1,8 +1,397 @@ +#if os(iOS) import Flutter +import UIKit import PdfxCodec +#elseif os(macOS) +import Cocoa +import FlutterMacOS +#endif +import CoreGraphics + +public class PdfxPlugin: NSObject, FlutterPlugin, PdfxApi { + let registrar: FlutterPluginRegistrar + static let invalid = NSNumber(value: -1) + let dispQueue = DispatchQueue(label: "io.scer.pdf_renderer") + + let documents = DocumentRepository() + let pages = PageRepository() + var textures: [Int64: PdfPageTexture] = [:] + + init(registrar: FlutterPluginRegistrar) { + self.registrar = registrar + } -public class PdfxPlugin: NSObject, FlutterPlugin { public static func register(with registrar: FlutterPluginRegistrar) { - SwiftPdfxPlugin.register(with: registrar) + #if os(iOS) + let messenger: FlutterBinaryMessenger = registrar.messenger() + #elseif os(macOS) + let messenger: FlutterBinaryMessenger = registrar.messenger + #endif + let api: PdfxApi & NSObjectProtocol = PdfxPlugin.init(registrar: registrar) + PdfxApiSetup(messenger, api); + } + + public func openDocumentDataMessage(_ message: OpenDataMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let data = message.data else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Arguments not sended", + details: nil)) + } + guard let renderer = openDataDocument(data: data.data) else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Invalid PDF format", + details: nil)) + } + + let document = documents.register(renderer: renderer); + let result = OpenReply.init() + result.id = document.id + result.pagesCount = NSNumber.init(value: document.pagesCount) + + completion(result, nil); + } + + public func openDocumentFileMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let pdfFilePath = message.path else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Arguments not sended", + details: nil)) + } + guard let renderer = openFileDocument(pdfFilePath: pdfFilePath) else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Invalid PDF format", + details: nil)) + } + + let document = documents.register(renderer: renderer); + let result = OpenReply.init() + result.id = document.id + result.pagesCount = NSNumber.init(value: document.pagesCount) + + completion(result, nil); + } + + public func openDocumentAssetMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let name = message.path else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Arguments not sended", + details: nil)) + } + guard let renderer = openAssetDocument(name: name) else { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Invalid PDF format", + details: nil)) + } + + let document = documents.register(renderer: renderer); + let result = OpenReply.init() + result.id = document.id + result.pagesCount = NSNumber.init(value: document.pagesCount) + + completion(result, nil); + } + + public func closeDocumentMessage(_ message: IdMessage, error: AutoreleasingUnsafeMutablePointer) { + if let id = message.id { + documents.close(id: id) + } } + + public func getPageMessage(_ message: GetPageMessage, completion: @escaping (GetPageReply?, FlutterError?) -> Void) { + do { + let documentId = message.documentId + let pageNumber = message.pageNumber + + let result = GetPageReply.init(); + + let renderer = try documents.get(id: documentId!).openPage(pageNumber: pageNumber as! Int) + if (renderer == nil) { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Unexpected error: renderer is nil.", + details: nil)) + } + + let page = pages.register(documentId: documentId!, renderer: renderer!) + result.id = page.id + result.width = NSNumber.init(value: page.width) + result.height = NSNumber.init(value: page.height) + completion(result, nil) + } catch let err { + return completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Unexpected error: \(err).", + details: nil)) + } + } + + public func renderPageMessage(_ message: RenderPageMessage, completion: @escaping (RenderPageReply?, FlutterError?) -> Void) { + // Set crop if required + var cropZone: CGRect? = nil + if (message.crop!.boolValue){ + let cWidth = message.cropWidth!.intValue + let cHeight = message.cropHeight!.intValue + if (cWidth != message.width!.intValue || cHeight != message.height!.intValue){ + cropZone = CGRect(x: message.cropX as! Int, + y: message.cropY as! Int, + width: cWidth, + height: cHeight) + } + } + + dispQueue.async { + let result = RenderPageReply.init() + do { + let page = try self.pages.get(id: message.pageId!) + if let data = page.render( + width: message.width!.intValue, + height: message.height!.intValue, + crop: cropZone, + compressFormat: CompressFormat(rawValue: message.format!.intValue)!, + backgroundColor: message.backgroundColor!, + quality: message.quality!.intValue + ) { + result.width = NSNumber.init(value: data.width) + result.height = NSNumber.init(value: data.height) + result.path = data.path + } + } catch { + completion(nil, FlutterError(code: "RENDER_ERROR", + message: "Unexpected error: \(error).", + details: nil)) + } + DispatchQueue.main.async { + completion(result.path != nil ? result : nil, nil) + } + } + } + + public func closePageMessage(_ message: IdMessage, error: AutoreleasingUnsafeMutablePointer) { + if let id = message.id { + pages.close(id: id) + } + } + + public func registerTextureWithError(_ error: AutoreleasingUnsafeMutablePointer) -> RegisterTextureReply? { + let result = RegisterTextureReply.init() + let pageTex = PdfPageTexture(registrar: registrar) + #if os(iOS) + let texId = registrar.textures().register(pageTex) + #elseif os(macOS) + let texId = registrar.textures.register(pageTex) + #endif + textures[texId] = pageTex + pageTex.texId = texId + result.id = NSNumber.init(value: texId) + return result + } + + public func unregisterTextureMessage(_ message: UnregisterTextureMessage, error: AutoreleasingUnsafeMutablePointer) { + let texId = message.id?.int64Value + #if os(iOS) + registrar.textures().unregisterTexture(texId!) + #elseif os(macOS) + registrar.textures.unregisterTexture(texId!) + #endif + textures[texId!] = nil + } + + public func resizeTextureMessage(_ message: ResizeTextureMessage, completion: @escaping (FlutterError?) -> Void) { + let texId = message.textureId?.int64Value + guard let pageTex = textures[texId!] else { + return completion(FlutterError(code: "RENDER_ERROR", + message: "No texture of texId=\(String(describing: texId!))", + details: nil)) + } + let width = message.width?.intValue, + height = message.height?.intValue + pageTex.resize(width: width!, height: height!) + return completion(nil) + } + + public func updateTextureMessage(_ message: UpdateTextureMessage, completion: @escaping (FlutterError?) -> Void) { + let texId = message.textureId?.int64Value + let pageId = message.pageId! + let destX = message.destinationX?.intValue + let destY = message.destinationY?.intValue + let width = message.width?.intValue + let height = message.height?.intValue + let srcX = message.sourceX?.intValue + let srcY = message.sourceY?.intValue + let fw = message.fullWidth?.doubleValue + let fh = message.fullHeight?.doubleValue + let backgroundColor = message.backgroundColor + let allowAntialiasing = message.allowAntiAliasing?.boolValue + + let tw = message.textureWidth?.intValue + let th = message.textureHeight?.intValue + + let pageTex = textures[texId!]! + + if tw != nil && th != nil { + pageTex.resize(width: tw!, height: th!) + } + + if width == nil || height == nil { + return completion(FlutterError(code: "RENDER_ERROR", + message: "width/height nil", + details: nil)) + } + do { + let page = try self.pages.get(id: pageId) + + try pageTex.updateTex( + page: page.renderer, + destX: destX!, + destY: destY!, + width: width!, + height: height!, + srcX: srcX!, + srcY: srcY!, + fullWidth: fw, + fullHeight: fh, + backgroundColor: backgroundColor, + allowAntialiasing: allowAntialiasing! + ) + return completion(nil) + } catch { + return completion(FlutterError(code: "RENDER_ERROR", + message: "Cannot render texture", + details: nil)) + } + + } + + func openDataDocument(data: Data) -> CGPDFDocument? { + guard let datProv = CGDataProvider(data: data as CFData) else { return nil } + let docment = CGPDFDocument(datProv) + if docment?.isUnlocked == false { + return nil + } + return docment + } + + func openFileDocument(pdfFilePath: String) -> CGPDFDocument? { + let docment = CGPDFDocument(URL(fileURLWithPath: pdfFilePath) as CFURL) + if docment?.isEncrypted == true { + return nil + } + return docment + } + + func openAssetDocument(name: String) -> CGPDFDocument? { + #if os(iOS) + guard let path = Bundle.main.path(forResource: "Frameworks/App.framework/flutter_assets/" + name, ofType: "") else { + return nil + } + #elseif os(macOS) + let path = Bundle.main.bundlePath + "/Contents/Frameworks/App.framework/Resources/flutter_assets/" + name; + #endif + + return openFileDocument(pdfFilePath: path) + } +} + +enum PdfRenderError : Error { + case operationFailed(String) + case invalidArgument(String) + case notSupported(String) +} + +class PdfPageTexture : NSObject { + var pixBuf : CVPixelBuffer? + weak var registrar: FlutterPluginRegistrar? + var texId: Int64 = 0 + var texWidth: Int = 0 + var texHeight: Int = 0 + + init(registrar: FlutterPluginRegistrar?) { + self.registrar = registrar + } + + func resize(width: Int, height: Int) { + if self.texWidth == width && self.texHeight == height { + return + } + self.texWidth = width + self.texHeight = height + } + + func updateTex( + page: CGPDFPage, + destX: Int, + destY: Int, + width: Int, + height: Int, + srcX: Int, + srcY: Int, + fullWidth: Double?, + fullHeight: Double?, + backgroundColor: String?, + allowAntialiasing: Bool = true + ) throws { + + let rotatedSize = page.getRotatedSize() + let fw = fullWidth ?? Double(rotatedSize.width) + let fh = fullHeight ?? Double(rotatedSize.height) + let sx = CGFloat(fw) / rotatedSize.width + let sy = CGFloat(fh) / rotatedSize.height + + var pixBuf: CVPixelBuffer? + let options = [ + kCVPixelBufferCGImageCompatibilityKey as String: true, + kCVPixelBufferCGBitmapContextCompatibilityKey as String: true, + kCVPixelBufferIOSurfacePropertiesKey as String: [:] + ] as [String : Any] + let cvRet = CVPixelBufferCreate(kCFAllocatorDefault, texWidth, texHeight, kCVPixelFormatType_32BGRA, options as CFDictionary?, &pixBuf) + if pixBuf == nil { + throw PdfRenderError.operationFailed("CVPixelBufferCreate failed: result code=\(cvRet)") + } + + let lockFlags = CVPixelBufferLockFlags(rawValue: 0) + let _ = CVPixelBufferLockBaseAddress(pixBuf!, lockFlags) + defer { + CVPixelBufferUnlockBaseAddress(pixBuf!, lockFlags) + } + + let bufferAddress = CVPixelBufferGetBaseAddress(pixBuf!) + let bytesPerRow = CVPixelBufferGetBytesPerRow(pixBuf!) + let rgbColorSpace = CGColorSpaceCreateDeviceRGB() + let context = CGContext(data: bufferAddress?.advanced(by: destX * 4 + destY * bytesPerRow), + width: width, + height: height, + bitsPerComponent: 8, + bytesPerRow: bytesPerRow, + space: rgbColorSpace, + bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue | CGBitmapInfo.byteOrder32Little.rawValue) + + + if backgroundColor != nil { + #if os(iOS) + context?.setFillColor(UIColor(hexString: backgroundColor!).cgColor) + #elseif os(macOS) + context?.setFillColor(NSColor(hexString: backgroundColor!).cgColor) + #endif + context?.fill(CGRect(x: 0, y: 0, width: width, height: height)) + } + + context?.setAllowsAntialiasing(allowAntialiasing) + + context?.translateBy(x: CGFloat(-srcX), y: CGFloat(Double(srcY + height) - fh)) + context?.scaleBy(x: sx, y: sy) + context?.concatenate(page.getRotationTransform()) + context?.drawPDFPage(page) + context?.flush() + + self.pixBuf = pixBuf + #if os(iOS) + registrar?.textures().textureFrameAvailable(texId) + #elseif os(macOS) + registrar?.textures.textureFrameAvailable(texId) + #endif + } +} + +extension PdfPageTexture : FlutterTexture { + func copyPixelBuffer() -> Unmanaged? { + return pixBuf != nil ? Unmanaged.passRetained(pixBuf!) : nil + } } diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift deleted file mode 100644 index a8fdd2e4..00000000 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift +++ /dev/null @@ -1,397 +0,0 @@ -#if os(iOS) -import Flutter -import UIKit -import PdfxCodec -#elseif os(macOS) -import Cocoa -import FlutterMacOS -#endif -import CoreGraphics - -public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { - let registrar: FlutterPluginRegistrar - static let invalid = NSNumber(value: -1) - let dispQueue = DispatchQueue(label: "io.scer.pdf_renderer") - - let documents = DocumentRepository() - let pages = PageRepository() - var textures: [Int64: PdfPageTexture] = [:] - - init(registrar: FlutterPluginRegistrar) { - self.registrar = registrar - } - - public static func register(with registrar: FlutterPluginRegistrar) { - #if os(iOS) - let messenger: FlutterBinaryMessenger = registrar.messenger() - #elseif os(macOS) - let messenger: FlutterBinaryMessenger = registrar.messenger - #endif - let api: PdfxApi & NSObjectProtocol = SwiftPdfxPlugin.init(registrar: registrar) - PdfxApiSetup(messenger, api); - } - - public func openDocumentDataMessage(_ message: OpenDataMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { - guard let data = message.data else { - return completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Arguments not sended", - details: nil)) - } - guard let renderer = openDataDocument(data: data.data) else { - return completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Invalid PDF format", - details: nil)) - } - - let document = documents.register(renderer: renderer); - let result = OpenReply.init() - result.id = document.id - result.pagesCount = NSNumber.init(value: document.pagesCount) - - completion(result, nil); - } - - public func openDocumentFileMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { - guard let pdfFilePath = message.path else { - return completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Arguments not sended", - details: nil)) - } - guard let renderer = openFileDocument(pdfFilePath: pdfFilePath) else { - return completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Invalid PDF format", - details: nil)) - } - - let document = documents.register(renderer: renderer); - let result = OpenReply.init() - result.id = document.id - result.pagesCount = NSNumber.init(value: document.pagesCount) - - completion(result, nil); - } - - public func openDocumentAssetMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { - guard let name = message.path else { - return completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Arguments not sended", - details: nil)) - } - guard let renderer = openAssetDocument(name: name) else { - return completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Invalid PDF format", - details: nil)) - } - - let document = documents.register(renderer: renderer); - let result = OpenReply.init() - result.id = document.id - result.pagesCount = NSNumber.init(value: document.pagesCount) - - completion(result, nil); - } - - public func closeDocumentMessage(_ message: IdMessage, error: AutoreleasingUnsafeMutablePointer) { - if let id = message.id { - documents.close(id: id) - } - } - - public func getPageMessage(_ message: GetPageMessage, completion: @escaping (GetPageReply?, FlutterError?) -> Void) { - do { - let documentId = message.documentId - let pageNumber = message.pageNumber - - let result = GetPageReply.init(); - - let renderer = try documents.get(id: documentId!).openPage(pageNumber: pageNumber as! Int) - if (renderer == nil) { - return completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Unexpected error: renderer is nil.", - details: nil)) - } - - let page = pages.register(documentId: documentId!, renderer: renderer!) - result.id = page.id - result.width = NSNumber.init(value: page.width) - result.height = NSNumber.init(value: page.height) - completion(result, nil) - } catch let err { - return completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Unexpected error: \(err).", - details: nil)) - } - } - - public func renderPageMessage(_ message: RenderPageMessage, completion: @escaping (RenderPageReply?, FlutterError?) -> Void) { - // Set crop if required - var cropZone: CGRect? = nil - if (message.crop!.boolValue){ - let cWidth = message.cropWidth!.intValue - let cHeight = message.cropHeight!.intValue - if (cWidth != message.width!.intValue || cHeight != message.height!.intValue){ - cropZone = CGRect(x: message.cropX as! Int, - y: message.cropY as! Int, - width: cWidth, - height: cHeight) - } - } - - dispQueue.async { - let result = RenderPageReply.init() - do { - let page = try self.pages.get(id: message.pageId!) - if let data = page.render( - width: message.width!.intValue, - height: message.height!.intValue, - crop: cropZone, - compressFormat: CompressFormat(rawValue: message.format!.intValue)!, - backgroundColor: message.backgroundColor!, - quality: message.quality!.intValue - ) { - result.width = NSNumber.init(value: data.width) - result.height = NSNumber.init(value: data.height) - result.path = data.path - } - } catch { - completion(nil, FlutterError(code: "RENDER_ERROR", - message: "Unexpected error: \(error).", - details: nil)) - } - DispatchQueue.main.async { - completion(result.path != nil ? result : nil, nil) - } - } - } - - public func closePageMessage(_ message: IdMessage, error: AutoreleasingUnsafeMutablePointer) { - if let id = message.id { - pages.close(id: id) - } - } - - public func registerTextureWithError(_ error: AutoreleasingUnsafeMutablePointer) -> RegisterTextureReply? { - let result = RegisterTextureReply.init() - let pageTex = PdfPageTexture(registrar: registrar) - #if os(iOS) - let texId = registrar.textures().register(pageTex) - #elseif os(macOS) - let texId = registrar.textures.register(pageTex) - #endif - textures[texId] = pageTex - pageTex.texId = texId - result.id = NSNumber.init(value: texId) - return result - } - - public func unregisterTextureMessage(_ message: UnregisterTextureMessage, error: AutoreleasingUnsafeMutablePointer) { - let texId = message.id?.int64Value - #if os(iOS) - registrar.textures().unregisterTexture(texId!) - #elseif os(macOS) - registrar.textures.unregisterTexture(texId!) - #endif - textures[texId!] = nil - } - - public func resizeTextureMessage(_ message: ResizeTextureMessage, completion: @escaping (FlutterError?) -> Void) { - let texId = message.textureId?.int64Value - guard let pageTex = textures[texId!] else { - return completion(FlutterError(code: "RENDER_ERROR", - message: "No texture of texId=\(String(describing: texId!))", - details: nil)) - } - let width = message.width?.intValue, - height = message.height?.intValue - pageTex.resize(width: width!, height: height!) - return completion(nil) - } - - public func updateTextureMessage(_ message: UpdateTextureMessage, completion: @escaping (FlutterError?) -> Void) { - let texId = message.textureId?.int64Value - let pageId = message.pageId! - let destX = message.destinationX?.intValue - let destY = message.destinationY?.intValue - let width = message.width?.intValue - let height = message.height?.intValue - let srcX = message.sourceX?.intValue - let srcY = message.sourceY?.intValue - let fw = message.fullWidth?.doubleValue - let fh = message.fullHeight?.doubleValue - let backgroundColor = message.backgroundColor - let allowAntialiasing = message.allowAntiAliasing?.boolValue - - let tw = message.textureWidth?.intValue - let th = message.textureHeight?.intValue - - let pageTex = textures[texId!]! - - if tw != nil && th != nil { - pageTex.resize(width: tw!, height: th!) - } - - if width == nil || height == nil { - return completion(FlutterError(code: "RENDER_ERROR", - message: "width/height nil", - details: nil)) - } - do { - let page = try self.pages.get(id: pageId) - - try pageTex.updateTex( - page: page.renderer, - destX: destX!, - destY: destY!, - width: width!, - height: height!, - srcX: srcX!, - srcY: srcY!, - fullWidth: fw, - fullHeight: fh, - backgroundColor: backgroundColor, - allowAntialiasing: allowAntialiasing! - ) - return completion(nil) - } catch { - return completion(FlutterError(code: "RENDER_ERROR", - message: "Cannot render texture", - details: nil)) - } - - } - - func openDataDocument(data: Data) -> CGPDFDocument? { - guard let datProv = CGDataProvider(data: data as CFData) else { return nil } - let docment = CGPDFDocument(datProv) - if docment?.isUnlocked == false { - return nil - } - return docment - } - - func openFileDocument(pdfFilePath: String) -> CGPDFDocument? { - let docment = CGPDFDocument(URL(fileURLWithPath: pdfFilePath) as CFURL) - if docment?.isEncrypted == true { - return nil - } - return docment - } - - func openAssetDocument(name: String) -> CGPDFDocument? { - #if os(iOS) - guard let path = Bundle.main.path(forResource: "Frameworks/App.framework/flutter_assets/" + name, ofType: "") else { - return nil - } - #elseif os(macOS) - let path = Bundle.main.bundlePath + "/Contents/Frameworks/App.framework/Resources/flutter_assets/" + name; - #endif - - return openFileDocument(pdfFilePath: path) - } -} - -enum PdfRenderError : Error { - case operationFailed(String) - case invalidArgument(String) - case notSupported(String) -} - -class PdfPageTexture : NSObject { - var pixBuf : CVPixelBuffer? - weak var registrar: FlutterPluginRegistrar? - var texId: Int64 = 0 - var texWidth: Int = 0 - var texHeight: Int = 0 - - init(registrar: FlutterPluginRegistrar?) { - self.registrar = registrar - } - - func resize(width: Int, height: Int) { - if self.texWidth == width && self.texHeight == height { - return - } - self.texWidth = width - self.texHeight = height - } - - func updateTex( - page: CGPDFPage, - destX: Int, - destY: Int, - width: Int, - height: Int, - srcX: Int, - srcY: Int, - fullWidth: Double?, - fullHeight: Double?, - backgroundColor: String?, - allowAntialiasing: Bool = true - ) throws { - - let rotatedSize = page.getRotatedSize() - let fw = fullWidth ?? Double(rotatedSize.width) - let fh = fullHeight ?? Double(rotatedSize.height) - let sx = CGFloat(fw) / rotatedSize.width - let sy = CGFloat(fh) / rotatedSize.height - - var pixBuf: CVPixelBuffer? - let options = [ - kCVPixelBufferCGImageCompatibilityKey as String: true, - kCVPixelBufferCGBitmapContextCompatibilityKey as String: true, - kCVPixelBufferIOSurfacePropertiesKey as String: [:] - ] as [String : Any] - let cvRet = CVPixelBufferCreate(kCFAllocatorDefault, texWidth, texHeight, kCVPixelFormatType_32BGRA, options as CFDictionary?, &pixBuf) - if pixBuf == nil { - throw PdfRenderError.operationFailed("CVPixelBufferCreate failed: result code=\(cvRet)") - } - - let lockFlags = CVPixelBufferLockFlags(rawValue: 0) - let _ = CVPixelBufferLockBaseAddress(pixBuf!, lockFlags) - defer { - CVPixelBufferUnlockBaseAddress(pixBuf!, lockFlags) - } - - let bufferAddress = CVPixelBufferGetBaseAddress(pixBuf!) - let bytesPerRow = CVPixelBufferGetBytesPerRow(pixBuf!) - let rgbColorSpace = CGColorSpaceCreateDeviceRGB() - let context = CGContext(data: bufferAddress?.advanced(by: destX * 4 + destY * bytesPerRow), - width: width, - height: height, - bitsPerComponent: 8, - bytesPerRow: bytesPerRow, - space: rgbColorSpace, - bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue | CGBitmapInfo.byteOrder32Little.rawValue) - - - if backgroundColor != nil { - #if os(iOS) - context?.setFillColor(UIColor(hexString: backgroundColor!).cgColor) - #elseif os(macOS) - context?.setFillColor(NSColor(hexString: backgroundColor!).cgColor) - #endif - context?.fill(CGRect(x: 0, y: 0, width: width, height: height)) - } - - context?.setAllowsAntialiasing(allowAntialiasing) - - context?.translateBy(x: CGFloat(-srcX), y: CGFloat(Double(srcY + height) - fh)) - context?.scaleBy(x: sx, y: sy) - context?.concatenate(page.getRotationTransform()) - context?.drawPDFPage(page) - context?.flush() - - self.pixBuf = pixBuf - #if os(iOS) - registrar?.textures().textureFrameAvailable(texId) - #elseif os(macOS) - registrar?.textures.textureFrameAvailable(texId) - #endif - } -} - -extension PdfPageTexture : FlutterTexture { - func copyPixelBuffer() -> Unmanaged? { - return pixBuf != nil ? Unmanaged.passRetained(pixBuf!) : nil - } -} diff --git a/packages/pdfx/lib/src/renderer/io/pigeon.dart b/packages/pdfx/lib/src/renderer/io/pigeon.dart index 8b7ce8ff..4295e383 100644 --- a/packages/pdfx/lib/src/renderer/io/pigeon.dart +++ b/packages/pdfx/lib/src/renderer/io/pigeon.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import import 'dart:async'; @@ -14,20 +14,21 @@ class OpenDataMessage { }); Uint8List? data; + String? password; Object encode() { - final Map pigeonMap = {}; - pigeonMap['data'] = data; - pigeonMap['password'] = password; - return pigeonMap; + return [ + data, + password, + ]; } - static OpenDataMessage decode(Object message) { - final Map pigeonMap = message as Map; + static OpenDataMessage decode(Object result) { + result as List; return OpenDataMessage( - data: pigeonMap['data'] as Uint8List?, - password: pigeonMap['password'] as String?, + data: result[0] as Uint8List?, + password: result[1] as String?, ); } } @@ -39,20 +40,21 @@ class OpenPathMessage { }); String? path; + String? password; Object encode() { - final Map pigeonMap = {}; - pigeonMap['path'] = path; - pigeonMap['password'] = password; - return pigeonMap; + return [ + path, + password, + ]; } - static OpenPathMessage decode(Object message) { - final Map pigeonMap = message as Map; + static OpenPathMessage decode(Object result) { + result as List; return OpenPathMessage( - path: pigeonMap['path'] as String?, - password: pigeonMap['password'] as String?, + path: result[0] as String?, + password: result[1] as String?, ); } } @@ -64,20 +66,21 @@ class OpenReply { }); String? id; + int? pagesCount; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - pigeonMap['pagesCount'] = pagesCount; - return pigeonMap; + return [ + id, + pagesCount, + ]; } - static OpenReply decode(Object message) { - final Map pigeonMap = message as Map; + static OpenReply decode(Object result) { + result as List; return OpenReply( - id: pigeonMap['id'] as String?, - pagesCount: pigeonMap['pagesCount'] as int?, + id: result[0] as String?, + pagesCount: result[1] as int?, ); } } @@ -90,15 +93,15 @@ class IdMessage { String? id; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - return pigeonMap; + return [ + id, + ]; } - static IdMessage decode(Object message) { - final Map pigeonMap = message as Map; + static IdMessage decode(Object result) { + result as List; return IdMessage( - id: pigeonMap['id'] as String?, + id: result[0] as String?, ); } } @@ -111,23 +114,25 @@ class GetPageMessage { }); String? documentId; + int? pageNumber; + bool? autoCloseAndroid; Object encode() { - final Map pigeonMap = {}; - pigeonMap['documentId'] = documentId; - pigeonMap['pageNumber'] = pageNumber; - pigeonMap['autoCloseAndroid'] = autoCloseAndroid; - return pigeonMap; + return [ + documentId, + pageNumber, + autoCloseAndroid, + ]; } - static GetPageMessage decode(Object message) { - final Map pigeonMap = message as Map; + static GetPageMessage decode(Object result) { + result as List; return GetPageMessage( - documentId: pigeonMap['documentId'] as String?, - pageNumber: pigeonMap['pageNumber'] as int?, - autoCloseAndroid: pigeonMap['autoCloseAndroid'] as bool?, + documentId: result[0] as String?, + pageNumber: result[1] as int?, + autoCloseAndroid: result[2] as bool?, ); } } @@ -140,23 +145,25 @@ class GetPageReply { }); String? id; + double? width; + double? height; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - return pigeonMap; + return [ + id, + width, + height, + ]; } - static GetPageReply decode(Object message) { - final Map pigeonMap = message as Map; + static GetPageReply decode(Object result) { + result as List; return GetPageReply( - id: pigeonMap['id'] as String?, - width: pigeonMap['width'] as double?, - height: pigeonMap['height'] as double?, + id: result[0] as String?, + width: result[1] as double?, + height: result[2] as double?, ); } } @@ -178,50 +185,61 @@ class RenderPageMessage { }); String? pageId; + int? width; + int? height; + int? format; + String? backgroundColor; + bool? crop; + int? cropX; + int? cropY; + int? cropHeight; + int? cropWidth; + int? quality; + bool? forPrint; Object encode() { - final Map pigeonMap = {}; - pigeonMap['pageId'] = pageId; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - pigeonMap['format'] = format; - pigeonMap['backgroundColor'] = backgroundColor; - pigeonMap['crop'] = crop; - pigeonMap['cropX'] = cropX; - pigeonMap['cropY'] = cropY; - pigeonMap['cropHeight'] = cropHeight; - pigeonMap['cropWidth'] = cropWidth; - pigeonMap['quality'] = quality; - pigeonMap['forPrint'] = forPrint; - return pigeonMap; - } - - static RenderPageMessage decode(Object message) { - final Map pigeonMap = message as Map; + return [ + pageId, + width, + height, + format, + backgroundColor, + crop, + cropX, + cropY, + cropHeight, + cropWidth, + quality, + forPrint, + ]; + } + + static RenderPageMessage decode(Object result) { + result as List; return RenderPageMessage( - pageId: pigeonMap['pageId'] as String?, - width: pigeonMap['width'] as int?, - height: pigeonMap['height'] as int?, - format: pigeonMap['format'] as int?, - backgroundColor: pigeonMap['backgroundColor'] as String?, - crop: pigeonMap['crop'] as bool?, - cropX: pigeonMap['cropX'] as int?, - cropY: pigeonMap['cropY'] as int?, - cropHeight: pigeonMap['cropHeight'] as int?, - cropWidth: pigeonMap['cropWidth'] as int?, - quality: pigeonMap['quality'] as int?, - forPrint: pigeonMap['forPrint'] as bool?, + pageId: result[0] as String?, + width: result[1] as int?, + height: result[2] as int?, + format: result[3] as int?, + backgroundColor: result[4] as String?, + crop: result[5] as bool?, + cropX: result[6] as int?, + cropY: result[7] as int?, + cropHeight: result[8] as int?, + cropWidth: result[9] as int?, + quality: result[10] as int?, + forPrint: result[11] as bool?, ); } } @@ -235,26 +253,29 @@ class RenderPageReply { }); int? width; + int? height; + String? path; + Uint8List? data; Object encode() { - final Map pigeonMap = {}; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - pigeonMap['path'] = path; - pigeonMap['data'] = data; - return pigeonMap; + return [ + width, + height, + path, + data, + ]; } - static RenderPageReply decode(Object message) { - final Map pigeonMap = message as Map; + static RenderPageReply decode(Object result) { + result as List; return RenderPageReply( - width: pigeonMap['width'] as int?, - height: pigeonMap['height'] as int?, - path: pigeonMap['path'] as String?, - data: pigeonMap['data'] as Uint8List?, + width: result[0] as int?, + height: result[1] as int?, + path: result[2] as String?, + data: result[3] as Uint8List?, ); } } @@ -267,15 +288,15 @@ class RegisterTextureReply { int? id; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - return pigeonMap; + return [ + id, + ]; } - static RegisterTextureReply decode(Object message) { - final Map pigeonMap = message as Map; + static RegisterTextureReply decode(Object result) { + result as List; return RegisterTextureReply( - id: pigeonMap['id'] as int?, + id: result[0] as int?, ); } } @@ -301,62 +322,77 @@ class UpdateTextureMessage { }); String? documentId; + int? pageNumber; + String? pageId; + int? textureId; + int? width; + int? height; + String? backgroundColor; + int? sourceX; + int? sourceY; + int? destinationX; + int? destinationY; + double? fullWidth; + double? fullHeight; + int? textureWidth; + int? textureHeight; + bool? allowAntiAliasing; Object encode() { - final Map pigeonMap = {}; - pigeonMap['documentId'] = documentId; - pigeonMap['pageNumber'] = pageNumber; - pigeonMap['pageId'] = pageId; - pigeonMap['textureId'] = textureId; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - pigeonMap['backgroundColor'] = backgroundColor; - pigeonMap['sourceX'] = sourceX; - pigeonMap['sourceY'] = sourceY; - pigeonMap['destinationX'] = destinationX; - pigeonMap['destinationY'] = destinationY; - pigeonMap['fullWidth'] = fullWidth; - pigeonMap['fullHeight'] = fullHeight; - pigeonMap['textureWidth'] = textureWidth; - pigeonMap['textureHeight'] = textureHeight; - pigeonMap['allowAntiAliasing'] = allowAntiAliasing; - return pigeonMap; - } - - static UpdateTextureMessage decode(Object message) { - final Map pigeonMap = message as Map; + return [ + documentId, + pageNumber, + pageId, + textureId, + width, + height, + backgroundColor, + sourceX, + sourceY, + destinationX, + destinationY, + fullWidth, + fullHeight, + textureWidth, + textureHeight, + allowAntiAliasing, + ]; + } + + static UpdateTextureMessage decode(Object result) { + result as List; return UpdateTextureMessage( - documentId: pigeonMap['documentId'] as String?, - pageNumber: pigeonMap['pageNumber'] as int?, - pageId: pigeonMap['pageId'] as String?, - textureId: pigeonMap['textureId'] as int?, - width: pigeonMap['width'] as int?, - height: pigeonMap['height'] as int?, - backgroundColor: pigeonMap['backgroundColor'] as String?, - sourceX: pigeonMap['sourceX'] as int?, - sourceY: pigeonMap['sourceY'] as int?, - destinationX: pigeonMap['destinationX'] as int?, - destinationY: pigeonMap['destinationY'] as int?, - fullWidth: pigeonMap['fullWidth'] as double?, - fullHeight: pigeonMap['fullHeight'] as double?, - textureWidth: pigeonMap['textureWidth'] as int?, - textureHeight: pigeonMap['textureHeight'] as int?, - allowAntiAliasing: pigeonMap['allowAntiAliasing'] as bool?, + documentId: result[0] as String?, + pageNumber: result[1] as int?, + pageId: result[2] as String?, + textureId: result[3] as int?, + width: result[4] as int?, + height: result[5] as int?, + backgroundColor: result[6] as String?, + sourceX: result[7] as int?, + sourceY: result[8] as int?, + destinationX: result[9] as int?, + destinationY: result[10] as int?, + fullWidth: result[11] as double?, + fullHeight: result[12] as double?, + textureWidth: result[13] as int?, + textureHeight: result[14] as int?, + allowAntiAliasing: result[15] as bool?, ); } } @@ -369,23 +405,25 @@ class ResizeTextureMessage { }); int? textureId; + int? width; + int? height; Object encode() { - final Map pigeonMap = {}; - pigeonMap['textureId'] = textureId; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - return pigeonMap; + return [ + textureId, + width, + height, + ]; } - static ResizeTextureMessage decode(Object message) { - final Map pigeonMap = message as Map; + static ResizeTextureMessage decode(Object result) { + result as List; return ResizeTextureMessage( - textureId: pigeonMap['textureId'] as int?, - width: pigeonMap['width'] as int?, - height: pigeonMap['height'] as int?, + textureId: result[0] as int?, + width: result[1] as int?, + height: result[2] as int?, ); } } @@ -398,15 +436,15 @@ class UnregisterTextureMessage { int? id; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - return pigeonMap; + return [ + id, + ]; } - static UnregisterTextureMessage decode(Object message) { - final Map pigeonMap = message as Map; + static UnregisterTextureMessage decode(Object result) { + result as List; return UnregisterTextureMessage( - id: pigeonMap['id'] as int?, + id: result[0] as int?, ); } } @@ -418,55 +456,44 @@ class _PdfxApiCodec extends StandardMessageCodec { if (value is GetPageMessage) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is GetPageReply) { + } else if (value is GetPageReply) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else - if (value is IdMessage) { + } else if (value is IdMessage) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else - if (value is OpenDataMessage) { + } else if (value is OpenDataMessage) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else - if (value is OpenPathMessage) { + } else if (value is OpenPathMessage) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else - if (value is OpenReply) { + } else if (value is OpenReply) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else - if (value is RegisterTextureReply) { + } else if (value is RegisterTextureReply) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else - if (value is RenderPageMessage) { + } else if (value is RenderPageMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else - if (value is RenderPageReply) { + } else if (value is RenderPageReply) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else - if (value is ResizeTextureMessage) { + } else if (value is ResizeTextureMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else - if (value is UnregisterTextureMessage) { + } else if (value is UnregisterTextureMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else - if (value is UpdateTextureMessage) { + } else if (value is UpdateTextureMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { @@ -506,7 +533,8 @@ class _PdfxApiCodec extends StandardMessageCodec { case 139: return UpdateTextureMessage.decode(readValue(buffer)!); - default: + default: + return super.readValueOfType(type, buffer); } @@ -523,109 +551,109 @@ class PdfxApi { /// Constructor for [PdfxApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - PdfxApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; - + PdfxApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _PdfxApiCodec(); Future openDocumentData(OpenDataMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentData', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentData', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as OpenReply?)!; + return (replyList[0] as OpenReply?)!; } } Future openDocumentFile(OpenPathMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentFile', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentFile', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as OpenReply?)!; + return (replyList[0] as OpenReply?)!; } } Future openDocumentAsset(OpenPathMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentAsset', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentAsset', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as OpenReply?)!; + return (replyList[0] as OpenReply?)!; } } Future closeDocument(IdMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.closeDocument', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.closeDocument', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -634,74 +662,74 @@ class PdfxApi { Future getPage(GetPageMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.getPage', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.getPage', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as GetPageReply?)!; + return (replyList[0] as GetPageReply?)!; } } Future renderPage(RenderPageMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.renderPage', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.renderPage', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as RenderPageReply?)!; + return (replyList[0] as RenderPageReply?)!; } } Future closePage(IdMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.closePage', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.closePage', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -710,47 +738,47 @@ class PdfxApi { Future registerTexture() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.registerTexture', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send(null) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.registerTexture', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send(null) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as RegisterTextureReply?)!; + return (replyList[0] as RegisterTextureReply?)!; } } Future updateTexture(UpdateTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.updateTexture', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.updateTexture', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -759,20 +787,20 @@ class PdfxApi { Future resizeTexture(ResizeTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.resizeTexture', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.resizeTexture', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -781,20 +809,20 @@ class PdfxApi { Future unregisterTexture(UnregisterTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.unregisterTexture', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.unregisterTexture', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; diff --git a/packages/pdfx/pigeons/messages.dart b/packages/pdfx/pigeons/messages.dart index 5c94f824..786088b5 100644 --- a/packages/pdfx/pigeons/messages.dart +++ b/packages/pdfx/pigeons/messages.dart @@ -4,6 +4,7 @@ import 'package:pigeon/pigeon.dart'; dartOut: 'lib/src/renderer/io/pigeon.dart', objcHeaderOut: './ios/Classes/messages.h', objcSourceOut: './ios/Classes/messages.m', + swiftOut: './ios/pdfx/Sources/pdfx/Messages.g.swift', javaOut: './android/src/main/java/dev/flutter/pigeon/Pigeon.java', javaOptions: JavaOptions( package: 'dev.flutter.pigeon', From 5ffdcbd89d301d3171797de12e9256a1fa1f16ee Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Thu, 2 Apr 2026 16:53:59 +0200 Subject: [PATCH 05/11] ESA-42 try differnt --- .../Sources/pdfx/{PdfxPlugin.swift => SwiftPdfxPlugin.swift} | 4 ++-- packages/pdfx/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename packages/pdfx/ios/pdfx/Sources/pdfx/{PdfxPlugin.swift => SwiftPdfxPlugin.swift} (98%) diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift similarity index 98% rename from packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift rename to packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift index 1d4970ba..a8fdd2e4 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/PdfxPlugin.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift @@ -8,7 +8,7 @@ import FlutterMacOS #endif import CoreGraphics -public class PdfxPlugin: NSObject, FlutterPlugin, PdfxApi { +public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { let registrar: FlutterPluginRegistrar static let invalid = NSNumber(value: -1) let dispQueue = DispatchQueue(label: "io.scer.pdf_renderer") @@ -27,7 +27,7 @@ public class PdfxPlugin: NSObject, FlutterPlugin, PdfxApi { #elseif os(macOS) let messenger: FlutterBinaryMessenger = registrar.messenger #endif - let api: PdfxApi & NSObjectProtocol = PdfxPlugin.init(registrar: registrar) + let api: PdfxApi & NSObjectProtocol = SwiftPdfxPlugin.init(registrar: registrar) PdfxApiSetup(messenger, api); } diff --git a/packages/pdfx/pubspec.yaml b/packages/pdfx/pubspec.yaml index 7b4ae35f..e72de8f2 100644 --- a/packages/pdfx/pubspec.yaml +++ b/packages/pdfx/pubspec.yaml @@ -36,7 +36,7 @@ flutter: package: io.scer.pdfx pluginClass: PdfxPlugin ios: - pluginClass: PdfxPlugin + pluginClass: SwiftPdfxPlugin macos: pluginClass: PdfxPlugin windows: From 3f6bb8b34b6f745216ad366c78e90927d17f3195 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Thu, 2 Apr 2026 17:00:19 +0200 Subject: [PATCH 06/11] ESA-42 try differnt approach (full swift) --- packages/pdfx/ios/pdfx/Package.swift | 10 +- .../pdfx/Sources/PdfxCodec/include/messages.h | 186 ---- .../ios/pdfx/Sources/PdfxCodec/messages.m | 816 ------------------ .../pdfx/ios/pdfx/Sources/pdfx/Messages.swift | 438 ++++++++++ .../pdfx/Sources/pdfx/SwiftPdfxPlugin.swift | 1 - 5 files changed, 440 insertions(+), 1011 deletions(-) delete mode 100644 packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h delete mode 100644 packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m create mode 100644 packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift diff --git a/packages/pdfx/ios/pdfx/Package.swift b/packages/pdfx/ios/pdfx/Package.swift index d6b77963..b0c072a1 100644 --- a/packages/pdfx/ios/pdfx/Package.swift +++ b/packages/pdfx/ios/pdfx/Package.swift @@ -7,19 +7,13 @@ let package = Package( .iOS(.v13), ], products: [ - .library(name: "pdfx", targets: ["pdfx", "PdfxCodec"]), + .library(name: "pdfx", targets: ["pdfx"]), ], dependencies: [], targets: [ - .target( - name: "PdfxCodec", - dependencies: [], - path: "Sources/PdfxCodec", - publicHeadersPath: "include" - ), .target( name: "pdfx", - dependencies: ["PdfxCodec"], + dependencies: [], path: "Sources/pdfx" ), ] diff --git a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h deleted file mode 100644 index 3d3134b5..00000000 --- a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/include/messages.h +++ /dev/null @@ -1,186 +0,0 @@ -// Autogenerated from Pigeon (v4.2.14), do not edit directly. -// See also: https://pub.dev/packages/pigeon -#import -@protocol FlutterBinaryMessenger; -@protocol FlutterMessageCodec; -@class FlutterError; -@class FlutterStandardTypedData; - -NS_ASSUME_NONNULL_BEGIN - -@class OpenDataMessage; -@class OpenPathMessage; -@class OpenReply; -@class IdMessage; -@class GetPageMessage; -@class GetPageReply; -@class RenderPageMessage; -@class RenderPageReply; -@class RegisterTextureReply; -@class UpdateTextureMessage; -@class ResizeTextureMessage; -@class UnregisterTextureMessage; - -@interface OpenDataMessage : NSObject -+ (instancetype)makeWithData:(nullable FlutterStandardTypedData *)data - password:(nullable NSString *)password; -@property(nonatomic, strong, nullable) FlutterStandardTypedData * data; -@property(nonatomic, copy, nullable) NSString * password; -@end - -@interface OpenPathMessage : NSObject -+ (instancetype)makeWithPath:(nullable NSString *)path - password:(nullable NSString *)password; -@property(nonatomic, copy, nullable) NSString * path; -@property(nonatomic, copy, nullable) NSString * password; -@end - -@interface OpenReply : NSObject -+ (instancetype)makeWithId:(nullable NSString *)id - pagesCount:(nullable NSNumber *)pagesCount; -@property(nonatomic, copy, nullable) NSString * id; -@property(nonatomic, strong, nullable) NSNumber * pagesCount; -@end - -@interface IdMessage : NSObject -+ (instancetype)makeWithId:(nullable NSString *)id; -@property(nonatomic, copy, nullable) NSString * id; -@end - -@interface GetPageMessage : NSObject -+ (instancetype)makeWithDocumentId:(nullable NSString *)documentId - pageNumber:(nullable NSNumber *)pageNumber - autoCloseAndroid:(nullable NSNumber *)autoCloseAndroid; -@property(nonatomic, copy, nullable) NSString * documentId; -@property(nonatomic, strong, nullable) NSNumber * pageNumber; -@property(nonatomic, strong, nullable) NSNumber * autoCloseAndroid; -@end - -@interface GetPageReply : NSObject -+ (instancetype)makeWithId:(nullable NSString *)id - width:(nullable NSNumber *)width - height:(nullable NSNumber *)height; -@property(nonatomic, copy, nullable) NSString * id; -@property(nonatomic, strong, nullable) NSNumber * width; -@property(nonatomic, strong, nullable) NSNumber * height; -@end - -@interface RenderPageMessage : NSObject -+ (instancetype)makeWithPageId:(nullable NSString *)pageId - width:(nullable NSNumber *)width - height:(nullable NSNumber *)height - format:(nullable NSNumber *)format - backgroundColor:(nullable NSString *)backgroundColor - crop:(nullable NSNumber *)crop - cropX:(nullable NSNumber *)cropX - cropY:(nullable NSNumber *)cropY - cropHeight:(nullable NSNumber *)cropHeight - cropWidth:(nullable NSNumber *)cropWidth - quality:(nullable NSNumber *)quality - forPrint:(nullable NSNumber *)forPrint; -@property(nonatomic, copy, nullable) NSString * pageId; -@property(nonatomic, strong, nullable) NSNumber * width; -@property(nonatomic, strong, nullable) NSNumber * height; -@property(nonatomic, strong, nullable) NSNumber * format; -@property(nonatomic, copy, nullable) NSString * backgroundColor; -@property(nonatomic, strong, nullable) NSNumber * crop; -@property(nonatomic, strong, nullable) NSNumber * cropX; -@property(nonatomic, strong, nullable) NSNumber * cropY; -@property(nonatomic, strong, nullable) NSNumber * cropHeight; -@property(nonatomic, strong, nullable) NSNumber * cropWidth; -@property(nonatomic, strong, nullable) NSNumber * quality; -@property(nonatomic, strong, nullable) NSNumber * forPrint; -@end - -@interface RenderPageReply : NSObject -+ (instancetype)makeWithWidth:(nullable NSNumber *)width - height:(nullable NSNumber *)height - path:(nullable NSString *)path - data:(nullable FlutterStandardTypedData *)data; -@property(nonatomic, strong, nullable) NSNumber * width; -@property(nonatomic, strong, nullable) NSNumber * height; -@property(nonatomic, copy, nullable) NSString * path; -@property(nonatomic, strong, nullable) FlutterStandardTypedData * data; -@end - -@interface RegisterTextureReply : NSObject -+ (instancetype)makeWithId:(nullable NSNumber *)id; -@property(nonatomic, strong, nullable) NSNumber * id; -@end - -@interface UpdateTextureMessage : NSObject -+ (instancetype)makeWithDocumentId:(nullable NSString *)documentId - pageNumber:(nullable NSNumber *)pageNumber - pageId:(nullable NSString *)pageId - textureId:(nullable NSNumber *)textureId - width:(nullable NSNumber *)width - height:(nullable NSNumber *)height - backgroundColor:(nullable NSString *)backgroundColor - sourceX:(nullable NSNumber *)sourceX - sourceY:(nullable NSNumber *)sourceY - destinationX:(nullable NSNumber *)destinationX - destinationY:(nullable NSNumber *)destinationY - fullWidth:(nullable NSNumber *)fullWidth - fullHeight:(nullable NSNumber *)fullHeight - textureWidth:(nullable NSNumber *)textureWidth - textureHeight:(nullable NSNumber *)textureHeight - allowAntiAliasing:(nullable NSNumber *)allowAntiAliasing; -@property(nonatomic, copy, nullable) NSString * documentId; -@property(nonatomic, strong, nullable) NSNumber * pageNumber; -@property(nonatomic, copy, nullable) NSString * pageId; -@property(nonatomic, strong, nullable) NSNumber * textureId; -@property(nonatomic, strong, nullable) NSNumber * width; -@property(nonatomic, strong, nullable) NSNumber * height; -@property(nonatomic, copy, nullable) NSString * backgroundColor; -@property(nonatomic, strong, nullable) NSNumber * sourceX; -@property(nonatomic, strong, nullable) NSNumber * sourceY; -@property(nonatomic, strong, nullable) NSNumber * destinationX; -@property(nonatomic, strong, nullable) NSNumber * destinationY; -@property(nonatomic, strong, nullable) NSNumber * fullWidth; -@property(nonatomic, strong, nullable) NSNumber * fullHeight; -@property(nonatomic, strong, nullable) NSNumber * textureWidth; -@property(nonatomic, strong, nullable) NSNumber * textureHeight; -@property(nonatomic, strong, nullable) NSNumber * allowAntiAliasing; -@end - -@interface ResizeTextureMessage : NSObject -+ (instancetype)makeWithTextureId:(nullable NSNumber *)textureId - width:(nullable NSNumber *)width - height:(nullable NSNumber *)height; -@property(nonatomic, strong, nullable) NSNumber * textureId; -@property(nonatomic, strong, nullable) NSNumber * width; -@property(nonatomic, strong, nullable) NSNumber * height; -@end - -@interface UnregisterTextureMessage : NSObject -+ (instancetype)makeWithId:(nullable NSNumber *)id; -@property(nonatomic, strong, nullable) NSNumber * id; -@end - -/// The codec used by PdfxApi. -NSObject *PdfxApiGetCodec(void); - -/// Rebuild: `flutter pub run pigeon --input pigeons/message.dart` -/// After build edit ios/Classes/pigeon/messages.m -/// replace `#import ` to -/// ```` -/// ```` -/// -@protocol PdfxApi -- (void)openDocumentDataMessage:(OpenDataMessage *)message completion:(void(^)(OpenReply *_Nullable, FlutterError *_Nullable))completion; -- (void)openDocumentFileMessage:(OpenPathMessage *)message completion:(void(^)(OpenReply *_Nullable, FlutterError *_Nullable))completion; -- (void)openDocumentAssetMessage:(OpenPathMessage *)message completion:(void(^)(OpenReply *_Nullable, FlutterError *_Nullable))completion; -- (void)closeDocumentMessage:(IdMessage *)message error:(FlutterError *_Nullable *_Nonnull)error; -- (void)getPageMessage:(GetPageMessage *)message completion:(void(^)(GetPageReply *_Nullable, FlutterError *_Nullable))completion; -- (void)renderPageMessage:(RenderPageMessage *)message completion:(void(^)(RenderPageReply *_Nullable, FlutterError *_Nullable))completion; -- (void)closePageMessage:(IdMessage *)message error:(FlutterError *_Nullable *_Nonnull)error; -/// @return `nil` only when `error != nil`. -- (nullable RegisterTextureReply *)registerTextureWithError:(FlutterError *_Nullable *_Nonnull)error; -- (void)updateTextureMessage:(UpdateTextureMessage *)message completion:(void(^)(FlutterError *_Nullable))completion; -- (void)resizeTextureMessage:(ResizeTextureMessage *)message completion:(void(^)(FlutterError *_Nullable))completion; -- (void)unregisterTextureMessage:(UnregisterTextureMessage *)message error:(FlutterError *_Nullable *_Nonnull)error; -@end - -extern void PdfxApiSetup(id binaryMessenger, NSObject *_Nullable api); - -NS_ASSUME_NONNULL_END diff --git a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m b/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m deleted file mode 100644 index c5d4bfab..00000000 --- a/packages/pdfx/ios/pdfx/Sources/PdfxCodec/messages.m +++ /dev/null @@ -1,816 +0,0 @@ -// Autogenerated from Pigeon (v4.2.14), do not edit directly. -// See also: https://pub.dev/packages/pigeon -#import "messages.h" -#import - -#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 GetNullableObject(NSDictionary* dict, id key) { - id result = dict[key]; - return (result == [NSNull null]) ? nil : result; -} -static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { - id result = array[key]; - return (result == [NSNull null]) ? nil : result; -} - - -@interface OpenDataMessage () -+ (OpenDataMessage *)fromList:(NSArray *)list; -+ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface OpenPathMessage () -+ (OpenPathMessage *)fromList:(NSArray *)list; -+ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface OpenReply () -+ (OpenReply *)fromList:(NSArray *)list; -+ (nullable OpenReply *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface IdMessage () -+ (IdMessage *)fromList:(NSArray *)list; -+ (nullable IdMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface GetPageMessage () -+ (GetPageMessage *)fromList:(NSArray *)list; -+ (nullable GetPageMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface GetPageReply () -+ (GetPageReply *)fromList:(NSArray *)list; -+ (nullable GetPageReply *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface RenderPageMessage () -+ (RenderPageMessage *)fromList:(NSArray *)list; -+ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface RenderPageReply () -+ (RenderPageReply *)fromList:(NSArray *)list; -+ (nullable RenderPageReply *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface RegisterTextureReply () -+ (RegisterTextureReply *)fromList:(NSArray *)list; -+ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface UpdateTextureMessage () -+ (UpdateTextureMessage *)fromList:(NSArray *)list; -+ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface ResizeTextureMessage () -+ (ResizeTextureMessage *)fromList:(NSArray *)list; -+ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end -@interface UnregisterTextureMessage () -+ (UnregisterTextureMessage *)fromList:(NSArray *)list; -+ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end - -@implementation OpenDataMessage -+ (instancetype)makeWithData:(nullable FlutterStandardTypedData *)data - password:(nullable NSString *)password { - OpenDataMessage* pigeonResult = [[OpenDataMessage alloc] init]; - pigeonResult.data = data; - pigeonResult.password = password; - return pigeonResult; -} -+ (OpenDataMessage *)fromList:(NSArray *)list { - OpenDataMessage *pigeonResult = [[OpenDataMessage alloc] init]; - pigeonResult.data = GetNullableObjectAtIndex(list, 0); - pigeonResult.password = GetNullableObjectAtIndex(list, 1); - return pigeonResult; -} -+ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenDataMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.data ?: [NSNull null]), - (self.password ?: [NSNull null]), - ]; -} -@end - -@implementation OpenPathMessage -+ (instancetype)makeWithPath:(nullable NSString *)path - password:(nullable NSString *)password { - OpenPathMessage* pigeonResult = [[OpenPathMessage alloc] init]; - pigeonResult.path = path; - pigeonResult.password = password; - return pigeonResult; -} -+ (OpenPathMessage *)fromList:(NSArray *)list { - OpenPathMessage *pigeonResult = [[OpenPathMessage alloc] init]; - pigeonResult.path = GetNullableObjectAtIndex(list, 0); - pigeonResult.password = GetNullableObjectAtIndex(list, 1); - return pigeonResult; -} -+ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenPathMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.path ?: [NSNull null]), - (self.password ?: [NSNull null]), - ]; -} -@end - -@implementation OpenReply -+ (instancetype)makeWithId:(nullable NSString *)id - pagesCount:(nullable NSNumber *)pagesCount { - OpenReply* pigeonResult = [[OpenReply alloc] init]; - pigeonResult.id = id; - pigeonResult.pagesCount = pagesCount; - return pigeonResult; -} -+ (OpenReply *)fromList:(NSArray *)list { - OpenReply *pigeonResult = [[OpenReply alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); - pigeonResult.pagesCount = GetNullableObjectAtIndex(list, 1); - return pigeonResult; -} -+ (nullable OpenReply *)nullableFromList:(NSArray *)list { return (list) ? [OpenReply fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - (self.pagesCount ?: [NSNull null]), - ]; -} -@end - -@implementation IdMessage -+ (instancetype)makeWithId:(nullable NSString *)id { - IdMessage* pigeonResult = [[IdMessage alloc] init]; - pigeonResult.id = id; - return pigeonResult; -} -+ (IdMessage *)fromList:(NSArray *)list { - IdMessage *pigeonResult = [[IdMessage alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); - return pigeonResult; -} -+ (nullable IdMessage *)nullableFromList:(NSArray *)list { return (list) ? [IdMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - ]; -} -@end - -@implementation GetPageMessage -+ (instancetype)makeWithDocumentId:(nullable NSString *)documentId - pageNumber:(nullable NSNumber *)pageNumber - autoCloseAndroid:(nullable NSNumber *)autoCloseAndroid { - GetPageMessage* pigeonResult = [[GetPageMessage alloc] init]; - pigeonResult.documentId = documentId; - pigeonResult.pageNumber = pageNumber; - pigeonResult.autoCloseAndroid = autoCloseAndroid; - return pigeonResult; -} -+ (GetPageMessage *)fromList:(NSArray *)list { - GetPageMessage *pigeonResult = [[GetPageMessage alloc] init]; - pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); - pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); - pigeonResult.autoCloseAndroid = GetNullableObjectAtIndex(list, 2); - return pigeonResult; -} -+ (nullable GetPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [GetPageMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.documentId ?: [NSNull null]), - (self.pageNumber ?: [NSNull null]), - (self.autoCloseAndroid ?: [NSNull null]), - ]; -} -@end - -@implementation GetPageReply -+ (instancetype)makeWithId:(nullable NSString *)id - width:(nullable NSNumber *)width - height:(nullable NSNumber *)height { - GetPageReply* pigeonResult = [[GetPageReply alloc] init]; - pigeonResult.id = id; - pigeonResult.width = width; - pigeonResult.height = height; - return pigeonResult; -} -+ (GetPageReply *)fromList:(NSArray *)list { - GetPageReply *pigeonResult = [[GetPageReply alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); - pigeonResult.width = GetNullableObjectAtIndex(list, 1); - pigeonResult.height = GetNullableObjectAtIndex(list, 2); - return pigeonResult; -} -+ (nullable GetPageReply *)nullableFromList:(NSArray *)list { return (list) ? [GetPageReply fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - ]; -} -@end - -@implementation RenderPageMessage -+ (instancetype)makeWithPageId:(nullable NSString *)pageId - width:(nullable NSNumber *)width - height:(nullable NSNumber *)height - format:(nullable NSNumber *)format - backgroundColor:(nullable NSString *)backgroundColor - crop:(nullable NSNumber *)crop - cropX:(nullable NSNumber *)cropX - cropY:(nullable NSNumber *)cropY - cropHeight:(nullable NSNumber *)cropHeight - cropWidth:(nullable NSNumber *)cropWidth - quality:(nullable NSNumber *)quality - forPrint:(nullable NSNumber *)forPrint { - RenderPageMessage* pigeonResult = [[RenderPageMessage alloc] init]; - pigeonResult.pageId = pageId; - pigeonResult.width = width; - pigeonResult.height = height; - pigeonResult.format = format; - pigeonResult.backgroundColor = backgroundColor; - pigeonResult.crop = crop; - pigeonResult.cropX = cropX; - pigeonResult.cropY = cropY; - pigeonResult.cropHeight = cropHeight; - pigeonResult.cropWidth = cropWidth; - pigeonResult.quality = quality; - pigeonResult.forPrint = forPrint; - return pigeonResult; -} -+ (RenderPageMessage *)fromList:(NSArray *)list { - RenderPageMessage *pigeonResult = [[RenderPageMessage alloc] init]; - pigeonResult.pageId = GetNullableObjectAtIndex(list, 0); - pigeonResult.width = GetNullableObjectAtIndex(list, 1); - pigeonResult.height = GetNullableObjectAtIndex(list, 2); - pigeonResult.format = GetNullableObjectAtIndex(list, 3); - pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 4); - pigeonResult.crop = GetNullableObjectAtIndex(list, 5); - pigeonResult.cropX = GetNullableObjectAtIndex(list, 6); - pigeonResult.cropY = GetNullableObjectAtIndex(list, 7); - pigeonResult.cropHeight = GetNullableObjectAtIndex(list, 8); - pigeonResult.cropWidth = GetNullableObjectAtIndex(list, 9); - pigeonResult.quality = GetNullableObjectAtIndex(list, 10); - pigeonResult.forPrint = GetNullableObjectAtIndex(list, 11); - return pigeonResult; -} -+ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.pageId ?: [NSNull null]), - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - (self.format ?: [NSNull null]), - (self.backgroundColor ?: [NSNull null]), - (self.crop ?: [NSNull null]), - (self.cropX ?: [NSNull null]), - (self.cropY ?: [NSNull null]), - (self.cropHeight ?: [NSNull null]), - (self.cropWidth ?: [NSNull null]), - (self.quality ?: [NSNull null]), - (self.forPrint ?: [NSNull null]), - ]; -} -@end - -@implementation RenderPageReply -+ (instancetype)makeWithWidth:(nullable NSNumber *)width - height:(nullable NSNumber *)height - path:(nullable NSString *)path - data:(nullable FlutterStandardTypedData *)data { - RenderPageReply* pigeonResult = [[RenderPageReply alloc] init]; - pigeonResult.width = width; - pigeonResult.height = height; - pigeonResult.path = path; - pigeonResult.data = data; - return pigeonResult; -} -+ (RenderPageReply *)fromList:(NSArray *)list { - RenderPageReply *pigeonResult = [[RenderPageReply alloc] init]; - pigeonResult.width = GetNullableObjectAtIndex(list, 0); - pigeonResult.height = GetNullableObjectAtIndex(list, 1); - pigeonResult.path = GetNullableObjectAtIndex(list, 2); - pigeonResult.data = GetNullableObjectAtIndex(list, 3); - return pigeonResult; -} -+ (nullable RenderPageReply *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageReply fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - (self.path ?: [NSNull null]), - (self.data ?: [NSNull null]), - ]; -} -@end - -@implementation RegisterTextureReply -+ (instancetype)makeWithId:(nullable NSNumber *)id { - RegisterTextureReply* pigeonResult = [[RegisterTextureReply alloc] init]; - pigeonResult.id = id; - return pigeonResult; -} -+ (RegisterTextureReply *)fromList:(NSArray *)list { - RegisterTextureReply *pigeonResult = [[RegisterTextureReply alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); - return pigeonResult; -} -+ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list { return (list) ? [RegisterTextureReply fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - ]; -} -@end - -@implementation UpdateTextureMessage -+ (instancetype)makeWithDocumentId:(nullable NSString *)documentId - pageNumber:(nullable NSNumber *)pageNumber - pageId:(nullable NSString *)pageId - textureId:(nullable NSNumber *)textureId - width:(nullable NSNumber *)width - height:(nullable NSNumber *)height - backgroundColor:(nullable NSString *)backgroundColor - sourceX:(nullable NSNumber *)sourceX - sourceY:(nullable NSNumber *)sourceY - destinationX:(nullable NSNumber *)destinationX - destinationY:(nullable NSNumber *)destinationY - fullWidth:(nullable NSNumber *)fullWidth - fullHeight:(nullable NSNumber *)fullHeight - textureWidth:(nullable NSNumber *)textureWidth - textureHeight:(nullable NSNumber *)textureHeight - allowAntiAliasing:(nullable NSNumber *)allowAntiAliasing { - UpdateTextureMessage* pigeonResult = [[UpdateTextureMessage alloc] init]; - pigeonResult.documentId = documentId; - pigeonResult.pageNumber = pageNumber; - pigeonResult.pageId = pageId; - pigeonResult.textureId = textureId; - pigeonResult.width = width; - pigeonResult.height = height; - pigeonResult.backgroundColor = backgroundColor; - pigeonResult.sourceX = sourceX; - pigeonResult.sourceY = sourceY; - pigeonResult.destinationX = destinationX; - pigeonResult.destinationY = destinationY; - pigeonResult.fullWidth = fullWidth; - pigeonResult.fullHeight = fullHeight; - pigeonResult.textureWidth = textureWidth; - pigeonResult.textureHeight = textureHeight; - pigeonResult.allowAntiAliasing = allowAntiAliasing; - return pigeonResult; -} -+ (UpdateTextureMessage *)fromList:(NSArray *)list { - UpdateTextureMessage *pigeonResult = [[UpdateTextureMessage alloc] init]; - pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); - pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); - pigeonResult.pageId = GetNullableObjectAtIndex(list, 2); - pigeonResult.textureId = GetNullableObjectAtIndex(list, 3); - pigeonResult.width = GetNullableObjectAtIndex(list, 4); - pigeonResult.height = GetNullableObjectAtIndex(list, 5); - pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 6); - pigeonResult.sourceX = GetNullableObjectAtIndex(list, 7); - pigeonResult.sourceY = GetNullableObjectAtIndex(list, 8); - pigeonResult.destinationX = GetNullableObjectAtIndex(list, 9); - pigeonResult.destinationY = GetNullableObjectAtIndex(list, 10); - pigeonResult.fullWidth = GetNullableObjectAtIndex(list, 11); - pigeonResult.fullHeight = GetNullableObjectAtIndex(list, 12); - pigeonResult.textureWidth = GetNullableObjectAtIndex(list, 13); - pigeonResult.textureHeight = GetNullableObjectAtIndex(list, 14); - pigeonResult.allowAntiAliasing = GetNullableObjectAtIndex(list, 15); - return pigeonResult; -} -+ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UpdateTextureMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.documentId ?: [NSNull null]), - (self.pageNumber ?: [NSNull null]), - (self.pageId ?: [NSNull null]), - (self.textureId ?: [NSNull null]), - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - (self.backgroundColor ?: [NSNull null]), - (self.sourceX ?: [NSNull null]), - (self.sourceY ?: [NSNull null]), - (self.destinationX ?: [NSNull null]), - (self.destinationY ?: [NSNull null]), - (self.fullWidth ?: [NSNull null]), - (self.fullHeight ?: [NSNull null]), - (self.textureWidth ?: [NSNull null]), - (self.textureHeight ?: [NSNull null]), - (self.allowAntiAliasing ?: [NSNull null]), - ]; -} -@end - -@implementation ResizeTextureMessage -+ (instancetype)makeWithTextureId:(nullable NSNumber *)textureId - width:(nullable NSNumber *)width - height:(nullable NSNumber *)height { - ResizeTextureMessage* pigeonResult = [[ResizeTextureMessage alloc] init]; - pigeonResult.textureId = textureId; - pigeonResult.width = width; - pigeonResult.height = height; - return pigeonResult; -} -+ (ResizeTextureMessage *)fromList:(NSArray *)list { - ResizeTextureMessage *pigeonResult = [[ResizeTextureMessage alloc] init]; - pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); - pigeonResult.width = GetNullableObjectAtIndex(list, 1); - pigeonResult.height = GetNullableObjectAtIndex(list, 2); - return pigeonResult; -} -+ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [ResizeTextureMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.textureId ?: [NSNull null]), - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - ]; -} -@end - -@implementation UnregisterTextureMessage -+ (instancetype)makeWithId:(nullable NSNumber *)id { - UnregisterTextureMessage* pigeonResult = [[UnregisterTextureMessage alloc] init]; - pigeonResult.id = id; - return pigeonResult; -} -+ (UnregisterTextureMessage *)fromList:(NSArray *)list { - UnregisterTextureMessage *pigeonResult = [[UnregisterTextureMessage alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); - return pigeonResult; -} -+ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UnregisterTextureMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - ]; -} -@end - -@interface PdfxApiCodecReader : FlutterStandardReader -@end -@implementation PdfxApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ - switch (type) { - case 128: - return [GetPageMessage fromList:[self readValue]]; - - case 129: - return [GetPageReply fromList:[self readValue]]; - - case 130: - return [IdMessage fromList:[self readValue]]; - - case 131: - return [OpenDataMessage fromList:[self readValue]]; - - case 132: - return [OpenPathMessage fromList:[self readValue]]; - - case 133: - return [OpenReply fromList:[self readValue]]; - - case 134: - return [RegisterTextureReply fromList:[self readValue]]; - - case 135: - return [RenderPageMessage fromList:[self readValue]]; - - case 136: - return [RenderPageReply fromList:[self readValue]]; - - case 137: - return [ResizeTextureMessage fromList:[self readValue]]; - - case 138: - return [UnregisterTextureMessage fromList:[self readValue]]; - - case 139: - return [UpdateTextureMessage fromList:[self readValue]]; - - default: - return [super readValueOfType:type]; - - } -} -@end - -@interface PdfxApiCodecWriter : FlutterStandardWriter -@end -@implementation PdfxApiCodecWriter -- (void)writeValue:(id)value -{ - if ([value isKindOfClass:[GetPageMessage class]]) { - [self writeByte:128]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[GetPageReply class]]) { - [self writeByte:129]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[IdMessage class]]) { - [self writeByte:130]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[OpenDataMessage class]]) { - [self writeByte:131]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[OpenPathMessage class]]) { - [self writeByte:132]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[OpenReply class]]) { - [self writeByte:133]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[RegisterTextureReply class]]) { - [self writeByte:134]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[RenderPageMessage class]]) { - [self writeByte:135]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[RenderPageReply class]]) { - [self writeByte:136]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[ResizeTextureMessage class]]) { - [self writeByte:137]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[UnregisterTextureMessage class]]) { - [self writeByte:138]; - [self writeValue:[value toList]]; - } else - if ([value isKindOfClass:[UpdateTextureMessage class]]) { - [self writeByte:139]; - [self writeValue:[value toList]]; - } else -{ - [super writeValue:value]; - } -} -@end - -@interface PdfxApiCodecReaderWriter : FlutterStandardReaderWriter -@end -@implementation PdfxApiCodecReaderWriter -- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { - return [[PdfxApiCodecWriter alloc] initWithData:data]; -} -- (FlutterStandardReader *)readerWithData:(NSData *)data { - return [[PdfxApiCodecReader alloc] initWithData:data]; -} -@end - - -NSObject *PdfxApiGetCodec() { - static FlutterStandardMessageCodec *sSharedObject = nil; - static dispatch_once_t sPred = 0; - dispatch_once(&sPred, ^{ - PdfxApiCodecReaderWriter *readerWriter = [[PdfxApiCodecReaderWriter alloc] init]; - sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; - }); - return sSharedObject; -} - -void PdfxApiSetup(id binaryMessenger, NSObject *api) { - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentData" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(openDocumentDataMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentDataMessage:completion:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - OpenDataMessage *arg_message = GetNullableObjectAtIndex(args, 0); - [api openDocumentDataMessage:arg_message completion:^(OpenReply *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentFile" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(openDocumentFileMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentFileMessage:completion:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - OpenPathMessage *arg_message = GetNullableObjectAtIndex(args, 0); - [api openDocumentFileMessage:arg_message completion:^(OpenReply *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentAsset" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(openDocumentAssetMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentAssetMessage:completion:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - OpenPathMessage *arg_message = GetNullableObjectAtIndex(args, 0); - [api openDocumentAssetMessage:arg_message completion:^(OpenReply *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.closeDocument" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(closeDocumentMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closeDocumentMessage:error:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - IdMessage *arg_message = GetNullableObjectAtIndex(args, 0); - FlutterError *error; - [api closeDocumentMessage:arg_message error:&error]; - callback(wrapResult(nil, error)); - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.getPage" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(getPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(getPageMessage:completion:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - GetPageMessage *arg_message = GetNullableObjectAtIndex(args, 0); - [api getPageMessage:arg_message completion:^(GetPageReply *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.renderPage" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(renderPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(renderPageMessage:completion:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - RenderPageMessage *arg_message = GetNullableObjectAtIndex(args, 0); - [api renderPageMessage:arg_message completion:^(RenderPageReply *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.closePage" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(closePageMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closePageMessage:error:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - IdMessage *arg_message = GetNullableObjectAtIndex(args, 0); - FlutterError *error; - [api closePageMessage:arg_message error:&error]; - callback(wrapResult(nil, error)); - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.registerTexture" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(registerTextureWithError:)], @"PdfxApi api (%@) doesn't respond to @selector(registerTextureWithError:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - FlutterError *error; - RegisterTextureReply *output = [api registerTextureWithError:&error]; - callback(wrapResult(output, error)); - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.updateTexture" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(updateTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(updateTextureMessage:completion:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - UpdateTextureMessage *arg_message = GetNullableObjectAtIndex(args, 0); - [api updateTextureMessage:arg_message completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.resizeTexture" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(resizeTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(resizeTextureMessage:completion:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - ResizeTextureMessage *arg_message = GetNullableObjectAtIndex(args, 0); - [api resizeTextureMessage:arg_message completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; - }]; - } - else { - [channel setMessageHandler:nil]; - } - } - { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.PdfxApi.unregisterTexture" - binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; - if (api) { - NSCAssert([api respondsToSelector:@selector(unregisterTextureMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(unregisterTextureMessage:error:)", api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - UnregisterTextureMessage *arg_message = GetNullableObjectAtIndex(args, 0); - FlutterError *error; - [api unregisterTextureMessage:arg_message error:&error]; - callback(wrapResult(nil, error)); - }]; - } - else { - [channel setMessageHandler:nil]; - } - } -} diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift new file mode 100644 index 00000000..e3251aca --- /dev/null +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift @@ -0,0 +1,438 @@ +// Manually translated from Pigeon-generated Obj-C (messages.h/m) to Swift. +// Preserves the exact same NSObject-based API so SwiftPdfxPlugin needs no changes. + +import Foundation +#if os(iOS) +import Flutter +#elseif os(macOS) +import FlutterMacOS +#endif + +// MARK: - Helper functions + +private func wrapResult(_ result: Any?, _ error: FlutterError?) -> [Any?] { + if let error = error { + return [error.code, error.message, error.details] + } + return [result as Any] +} + +private func getNullableObject(_ array: [Any?], _ index: Int) -> Any? { + let result = array[index] + return result is NSNull ? nil : result +} + +// MARK: - Message classes + +@objc public class OpenDataMessage: NSObject { + @objc public var data: FlutterStandardTypedData? + @objc public var password: String? + + @objc public static func make(withData data: FlutterStandardTypedData?, password: String?) -> OpenDataMessage { + let msg = OpenDataMessage() + msg.data = data + msg.password = password + return msg + } + static func fromList(_ list: [Any?]) -> OpenDataMessage { + let msg = OpenDataMessage() + msg.data = getNullableObject(list, 0) as? FlutterStandardTypedData + msg.password = getNullableObject(list, 1) as? String + return msg + } + func toList() -> [Any?] { [data ?? NSNull(), password ?? NSNull()] } +} + +@objc public class OpenPathMessage: NSObject { + @objc public var path: String? + @objc public var password: String? + + @objc public static func make(withPath path: String?, password: String?) -> OpenPathMessage { + let msg = OpenPathMessage() + msg.path = path + msg.password = password + return msg + } + static func fromList(_ list: [Any?]) -> OpenPathMessage { + let msg = OpenPathMessage() + msg.path = getNullableObject(list, 0) as? String + msg.password = getNullableObject(list, 1) as? String + return msg + } + func toList() -> [Any?] { [path ?? NSNull(), password ?? NSNull()] } +} + +@objc public class OpenReply: NSObject { + @objc public var id: String? + @objc public var pagesCount: NSNumber? + + static func fromList(_ list: [Any?]) -> OpenReply { + let msg = OpenReply() + msg.id = getNullableObject(list, 0) as? String + msg.pagesCount = getNullableObject(list, 1) as? NSNumber + return msg + } + func toList() -> [Any?] { [id ?? NSNull(), pagesCount ?? NSNull()] } +} + +@objc public class IdMessage: NSObject { + @objc public var id: String? + + static func fromList(_ list: [Any?]) -> IdMessage { + let msg = IdMessage() + msg.id = getNullableObject(list, 0) as? String + return msg + } + func toList() -> [Any?] { [id ?? NSNull()] } +} + +@objc public class GetPageMessage: NSObject { + @objc public var documentId: String? + @objc public var pageNumber: NSNumber? + @objc public var autoCloseAndroid: NSNumber? + + static func fromList(_ list: [Any?]) -> GetPageMessage { + let msg = GetPageMessage() + msg.documentId = getNullableObject(list, 0) as? String + msg.pageNumber = getNullableObject(list, 1) as? NSNumber + msg.autoCloseAndroid = getNullableObject(list, 2) as? NSNumber + return msg + } + func toList() -> [Any?] { [documentId ?? NSNull(), pageNumber ?? NSNull(), autoCloseAndroid ?? NSNull()] } +} + +@objc public class GetPageReply: NSObject { + @objc public var id: String? + @objc public var width: NSNumber? + @objc public var height: NSNumber? + + static func fromList(_ list: [Any?]) -> GetPageReply { + let msg = GetPageReply() + msg.id = getNullableObject(list, 0) as? String + msg.width = getNullableObject(list, 1) as? NSNumber + msg.height = getNullableObject(list, 2) as? NSNumber + return msg + } + func toList() -> [Any?] { [id ?? NSNull(), width ?? NSNull(), height ?? NSNull()] } +} + +@objc public class RenderPageMessage: NSObject { + @objc public var pageId: String? + @objc public var width: NSNumber? + @objc public var height: NSNumber? + @objc public var format: NSNumber? + @objc public var backgroundColor: String? + @objc public var crop: NSNumber? + @objc public var cropX: NSNumber? + @objc public var cropY: NSNumber? + @objc public var cropHeight: NSNumber? + @objc public var cropWidth: NSNumber? + @objc public var quality: NSNumber? + @objc public var forPrint: NSNumber? + + static func fromList(_ list: [Any?]) -> RenderPageMessage { + let msg = RenderPageMessage() + msg.pageId = getNullableObject(list, 0) as? String + msg.width = getNullableObject(list, 1) as? NSNumber + msg.height = getNullableObject(list, 2) as? NSNumber + msg.format = getNullableObject(list, 3) as? NSNumber + msg.backgroundColor = getNullableObject(list, 4) as? String + msg.crop = getNullableObject(list, 5) as? NSNumber + msg.cropX = getNullableObject(list, 6) as? NSNumber + msg.cropY = getNullableObject(list, 7) as? NSNumber + msg.cropHeight = getNullableObject(list, 8) as? NSNumber + msg.cropWidth = getNullableObject(list, 9) as? NSNumber + msg.quality = getNullableObject(list, 10) as? NSNumber + msg.forPrint = getNullableObject(list, 11) as? NSNumber + return msg + } + func toList() -> [Any?] { + [pageId ?? NSNull(), width ?? NSNull(), height ?? NSNull(), format ?? NSNull(), + backgroundColor ?? NSNull(), crop ?? NSNull(), cropX ?? NSNull(), cropY ?? NSNull(), + cropHeight ?? NSNull(), cropWidth ?? NSNull(), quality ?? NSNull(), forPrint ?? NSNull()] + } +} + +@objc public class RenderPageReply: NSObject { + @objc public var width: NSNumber? + @objc public var height: NSNumber? + @objc public var path: String? + @objc public var data: FlutterStandardTypedData? + + static func fromList(_ list: [Any?]) -> RenderPageReply { + let msg = RenderPageReply() + msg.width = getNullableObject(list, 0) as? NSNumber + msg.height = getNullableObject(list, 1) as? NSNumber + msg.path = getNullableObject(list, 2) as? String + msg.data = getNullableObject(list, 3) as? FlutterStandardTypedData + return msg + } + func toList() -> [Any?] { [width ?? NSNull(), height ?? NSNull(), path ?? NSNull(), data ?? NSNull()] } +} + +@objc public class RegisterTextureReply: NSObject { + @objc public var id: NSNumber? + + static func fromList(_ list: [Any?]) -> RegisterTextureReply { + let msg = RegisterTextureReply() + msg.id = getNullableObject(list, 0) as? NSNumber + return msg + } + func toList() -> [Any?] { [id ?? NSNull()] } +} + +@objc public class UpdateTextureMessage: NSObject { + @objc public var documentId: String? + @objc public var pageNumber: NSNumber? + @objc public var pageId: String? + @objc public var textureId: NSNumber? + @objc public var width: NSNumber? + @objc public var height: NSNumber? + @objc public var backgroundColor: String? + @objc public var sourceX: NSNumber? + @objc public var sourceY: NSNumber? + @objc public var destinationX: NSNumber? + @objc public var destinationY: NSNumber? + @objc public var fullWidth: NSNumber? + @objc public var fullHeight: NSNumber? + @objc public var textureWidth: NSNumber? + @objc public var textureHeight: NSNumber? + @objc public var allowAntiAliasing: NSNumber? + + static func fromList(_ list: [Any?]) -> UpdateTextureMessage { + let msg = UpdateTextureMessage() + msg.documentId = getNullableObject(list, 0) as? String + msg.pageNumber = getNullableObject(list, 1) as? NSNumber + msg.pageId = getNullableObject(list, 2) as? String + msg.textureId = getNullableObject(list, 3) as? NSNumber + msg.width = getNullableObject(list, 4) as? NSNumber + msg.height = getNullableObject(list, 5) as? NSNumber + msg.backgroundColor = getNullableObject(list, 6) as? String + msg.sourceX = getNullableObject(list, 7) as? NSNumber + msg.sourceY = getNullableObject(list, 8) as? NSNumber + msg.destinationX = getNullableObject(list, 9) as? NSNumber + msg.destinationY = getNullableObject(list, 10) as? NSNumber + msg.fullWidth = getNullableObject(list, 11) as? NSNumber + msg.fullHeight = getNullableObject(list, 12) as? NSNumber + msg.textureWidth = getNullableObject(list, 13) as? NSNumber + msg.textureHeight = getNullableObject(list, 14) as? NSNumber + msg.allowAntiAliasing = getNullableObject(list, 15) as? NSNumber + return msg + } + func toList() -> [Any?] { + [documentId ?? NSNull(), pageNumber ?? NSNull(), pageId ?? NSNull(), textureId ?? NSNull(), + width ?? NSNull(), height ?? NSNull(), backgroundColor ?? NSNull(), + sourceX ?? NSNull(), sourceY ?? NSNull(), destinationX ?? NSNull(), destinationY ?? NSNull(), + fullWidth ?? NSNull(), fullHeight ?? NSNull(), textureWidth ?? NSNull(), textureHeight ?? NSNull(), + allowAntiAliasing ?? NSNull()] + } +} + +@objc public class ResizeTextureMessage: NSObject { + @objc public var textureId: NSNumber? + @objc public var width: NSNumber? + @objc public var height: NSNumber? + + static func fromList(_ list: [Any?]) -> ResizeTextureMessage { + let msg = ResizeTextureMessage() + msg.textureId = getNullableObject(list, 0) as? NSNumber + msg.width = getNullableObject(list, 1) as? NSNumber + msg.height = getNullableObject(list, 2) as? NSNumber + return msg + } + func toList() -> [Any?] { [textureId ?? NSNull(), width ?? NSNull(), height ?? NSNull()] } +} + +@objc public class UnregisterTextureMessage: NSObject { + @objc public var id: NSNumber? + + static func fromList(_ list: [Any?]) -> UnregisterTextureMessage { + let msg = UnregisterTextureMessage() + msg.id = getNullableObject(list, 0) as? NSNumber + return msg + } + func toList() -> [Any?] { [id ?? NSNull()] } +} + +// MARK: - Codec + +private class PdfxApiCodecReader: FlutterStandardReader { + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: return GetPageMessage.fromList(readValue() as! [Any?]) + case 129: return GetPageReply.fromList(readValue() as! [Any?]) + case 130: return IdMessage.fromList(readValue() as! [Any?]) + case 131: return OpenDataMessage.fromList(readValue() as! [Any?]) + case 132: return OpenPathMessage.fromList(readValue() as! [Any?]) + case 133: return OpenReply.fromList(readValue() as! [Any?]) + case 134: return RegisterTextureReply.fromList(readValue() as! [Any?]) + case 135: return RenderPageMessage.fromList(readValue() as! [Any?]) + case 136: return RenderPageReply.fromList(readValue() as! [Any?]) + case 137: return ResizeTextureMessage.fromList(readValue() as! [Any?]) + case 138: return UnregisterTextureMessage.fromList(readValue() as! [Any?]) + case 139: return UpdateTextureMessage.fromList(readValue() as! [Any?]) + default: return super.readValue(ofType: type) + } + } +} + +private class PdfxApiCodecWriter: FlutterStandardWriter { + override func writeValue(_ value: Any) { + if let v = value as? GetPageMessage { writeByte(128); writeValue(v.toList()) } + else if let v = value as? GetPageReply { writeByte(129); writeValue(v.toList()) } + else if let v = value as? IdMessage { writeByte(130); writeValue(v.toList()) } + else if let v = value as? OpenDataMessage { writeByte(131); writeValue(v.toList()) } + else if let v = value as? OpenPathMessage { writeByte(132); writeValue(v.toList()) } + else if let v = value as? OpenReply { writeByte(133); writeValue(v.toList()) } + else if let v = value as? RegisterTextureReply { writeByte(134); writeValue(v.toList()) } + else if let v = value as? RenderPageMessage { writeByte(135); writeValue(v.toList()) } + else if let v = value as? RenderPageReply { writeByte(136); writeValue(v.toList()) } + else if let v = value as? ResizeTextureMessage { writeByte(137); writeValue(v.toList()) } + else if let v = value as? UnregisterTextureMessage { writeByte(138); writeValue(v.toList()) } + else if let v = value as? UpdateTextureMessage { writeByte(139); writeValue(v.toList()) } + else { super.writeValue(value) } + } +} + +private class PdfxApiCodecReaderWriter: FlutterStandardReaderWriter { + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + PdfxApiCodecWriter(data: data) + } + override func reader(with data: Data) -> FlutterStandardReader { + PdfxApiCodecReader(data: data) + } +} + +// MARK: - Protocol & Setup + +@objc public protocol PdfxApi { + func openDocumentDataMessage(_ message: OpenDataMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) + func openDocumentFileMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) + func openDocumentAssetMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) + func closeDocumentMessage(_ message: IdMessage, error: AutoreleasingUnsafeMutablePointer) + func getPageMessage(_ message: GetPageMessage, completion: @escaping (GetPageReply?, FlutterError?) -> Void) + func renderPageMessage(_ message: RenderPageMessage, completion: @escaping (RenderPageReply?, FlutterError?) -> Void) + func closePageMessage(_ message: IdMessage, error: AutoreleasingUnsafeMutablePointer) + func registerTextureWithError(_ error: AutoreleasingUnsafeMutablePointer) -> RegisterTextureReply? + func updateTextureMessage(_ message: UpdateTextureMessage, completion: @escaping (FlutterError?) -> Void) + func resizeTextureMessage(_ message: ResizeTextureMessage, completion: @escaping (FlutterError?) -> Void) + func unregisterTextureMessage(_ message: UnregisterTextureMessage, error: AutoreleasingUnsafeMutablePointer) +} + +private var _codecInstance: FlutterStandardMessageCodec? + +@objc public func PdfxApiGetCodec() -> NSObject & FlutterMessageCodec { + if _codecInstance == nil { + _codecInstance = FlutterStandardMessageCodec(readerWriter: PdfxApiCodecReaderWriter()) + } + return _codecInstance! +} + +@objc public func PdfxApiSetup(_ binaryMessenger: FlutterBinaryMessenger, _ api: (NSObjectProtocol & PdfxApi)?) { + let codec = PdfxApiGetCodec() + + let openDocumentDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.openDocumentData", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + openDocumentDataChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! OpenDataMessage + api.openDocumentDataMessage(argMessage) { output, error in callback(wrapResult(output, error)) } + } + } else { openDocumentDataChannel.setMessageHandler(nil) } + + let openDocumentFileChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.openDocumentFile", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + openDocumentFileChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! OpenPathMessage + api.openDocumentFileMessage(argMessage) { output, error in callback(wrapResult(output, error)) } + } + } else { openDocumentFileChannel.setMessageHandler(nil) } + + let openDocumentAssetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.openDocumentAsset", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + openDocumentAssetChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! OpenPathMessage + api.openDocumentAssetMessage(argMessage) { output, error in callback(wrapResult(output, error)) } + } + } else { openDocumentAssetChannel.setMessageHandler(nil) } + + let closeDocumentChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.closeDocument", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + closeDocumentChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! IdMessage + var error: FlutterError? + api.closeDocumentMessage(argMessage, error: &error) + callback(wrapResult(nil, error)) + } + } else { closeDocumentChannel.setMessageHandler(nil) } + + let getPageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.getPage", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + getPageChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! GetPageMessage + api.getPageMessage(argMessage) { output, error in callback(wrapResult(output, error)) } + } + } else { getPageChannel.setMessageHandler(nil) } + + let renderPageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.renderPage", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + renderPageChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! RenderPageMessage + api.renderPageMessage(argMessage) { output, error in callback(wrapResult(output, error)) } + } + } else { renderPageChannel.setMessageHandler(nil) } + + let closePageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.closePage", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + closePageChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! IdMessage + var error: FlutterError? + api.closePageMessage(argMessage, error: &error) + callback(wrapResult(nil, error)) + } + } else { closePageChannel.setMessageHandler(nil) } + + let registerTextureChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.registerTexture", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + registerTextureChannel.setMessageHandler { _, callback in + var error: FlutterError? + let output = api.registerTextureWithError(&error) + callback(wrapResult(output, error)) + } + } else { registerTextureChannel.setMessageHandler(nil) } + + let updateTextureChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.updateTexture", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + updateTextureChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! UpdateTextureMessage + api.updateTextureMessage(argMessage) { error in callback(wrapResult(nil, error)) } + } + } else { updateTextureChannel.setMessageHandler(nil) } + + let resizeTextureChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.resizeTexture", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + resizeTextureChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! ResizeTextureMessage + api.resizeTextureMessage(argMessage) { error in callback(wrapResult(nil, error)) } + } + } else { resizeTextureChannel.setMessageHandler(nil) } + + let unregisterTextureChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.unregisterTexture", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + unregisterTextureChannel.setMessageHandler { message, callback in + let args = message as! [Any?] + let argMessage = getNullableObject(args, 0) as! UnregisterTextureMessage + var error: FlutterError? + api.unregisterTextureMessage(argMessage, error: &error) + callback(wrapResult(nil, error)) + } + } else { unregisterTextureChannel.setMessageHandler(nil) } +} diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift index a8fdd2e4..48ece3fa 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift @@ -1,7 +1,6 @@ #if os(iOS) import Flutter import UIKit -import PdfxCodec #elseif os(macOS) import Cocoa import FlutterMacOS From 7e883dbe043549937c4fd5daeb5bb99914f46539 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Thu, 2 Apr 2026 17:04:16 +0200 Subject: [PATCH 07/11] ESA-42 try again --- packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift index e3251aca..02108813 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/Messages.swift @@ -321,14 +321,14 @@ private class PdfxApiCodecReaderWriter: FlutterStandardReaderWriter { private var _codecInstance: FlutterStandardMessageCodec? -@objc public func PdfxApiGetCodec() -> NSObject & FlutterMessageCodec { +public func PdfxApiGetCodec() -> NSObject & FlutterMessageCodec { if _codecInstance == nil { _codecInstance = FlutterStandardMessageCodec(readerWriter: PdfxApiCodecReaderWriter()) } return _codecInstance! } -@objc public func PdfxApiSetup(_ binaryMessenger: FlutterBinaryMessenger, _ api: (NSObjectProtocol & PdfxApi)?) { +public func PdfxApiSetup(_ binaryMessenger: FlutterBinaryMessenger, _ api: (NSObjectProtocol & PdfxApi)?) { let codec = PdfxApiGetCodec() let openDocumentDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.PdfxApi.openDocumentData", binaryMessenger: binaryMessenger, codec: codec) From 9438f17f7b4596e0545d67af60963c9cc2bf7ce4 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Thu, 2 Apr 2026 17:44:38 +0200 Subject: [PATCH 08/11] ESA-42 try again --- .../pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift index 48ece3fa..af153687 100644 --- a/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift +++ b/packages/pdfx/ios/pdfx/Sources/pdfx/SwiftPdfxPlugin.swift @@ -296,7 +296,8 @@ enum PdfRenderError : Error { } class PdfPageTexture : NSObject { - var pixBuf : CVPixelBuffer? + private var pixBuf : CVPixelBuffer? + private let lock = NSLock() weak var registrar: FlutterPluginRegistrar? var texId: Int64 = 0 var texWidth: Int = 0 @@ -380,7 +381,9 @@ class PdfPageTexture : NSObject { context?.drawPDFPage(page) context?.flush() + lock.lock() self.pixBuf = pixBuf + lock.unlock() #if os(iOS) registrar?.textures().textureFrameAvailable(texId) #elseif os(macOS) @@ -391,6 +394,9 @@ class PdfPageTexture : NSObject { extension PdfPageTexture : FlutterTexture { func copyPixelBuffer() -> Unmanaged? { - return pixBuf != nil ? Unmanaged.passRetained(pixBuf!) : nil + lock.lock() + let buf = pixBuf + lock.unlock() + return buf != nil ? Unmanaged.passRetained(buf!) : nil } } From bb6718900c0eb878eb13dc574b2949c628b05996 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Tue, 7 Apr 2026 09:02:15 +0200 Subject: [PATCH 09/11] ESA-42 rollback --- .../main/java/dev/flutter/pigeon/Pigeon.java | 491 +++++++------- packages/pdfx/ios/Classes/messages.h | 4 +- packages/pdfx/ios/Classes/messages.m | 488 +++++++------- packages/pdfx/lib/src/renderer/io/pigeon.dart | 610 +++++++++--------- packages/pdfx/pigeons/messages.dart | 1 - 5 files changed, 782 insertions(+), 812 deletions(-) diff --git a/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java b/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java index e7e26b74..53ad753f 100644 --- a/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java +++ b/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.14), do not edit directly. +// Autogenerated from Pigeon (v4.2.0), do not edit directly. // See also: https://pub.dev/packages/pigeon package dev.flutter.pigeon; @@ -14,12 +14,11 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.HashMap; -/** Generated class from Pigeon. */ +/**Generated class from Pigeon. */ @SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) public class Pigeon { @@ -55,17 +54,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(2); - toListResult.add(data); - toListResult.add(password); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("data", data); + toMapResult.put("password", password); + return toMapResult; } - static @NonNull OpenDataMessage fromList(@NonNull ArrayList list) { + static @NonNull OpenDataMessage fromMap(@NonNull Map map) { OpenDataMessage pigeonResult = new OpenDataMessage(); - Object data = list.get(0); + Object data = map.get("data"); pigeonResult.setData((byte[])data); - Object password = list.get(1); + Object password = map.get("password"); pigeonResult.setPassword((String)password); return pigeonResult; } @@ -103,17 +102,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(2); - toListResult.add(path); - toListResult.add(password); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("path", path); + toMapResult.put("password", password); + return toMapResult; } - static @NonNull OpenPathMessage fromList(@NonNull ArrayList list) { + static @NonNull OpenPathMessage fromMap(@NonNull Map map) { OpenPathMessage pigeonResult = new OpenPathMessage(); - Object path = list.get(0); + Object path = map.get("path"); pigeonResult.setPath((String)path); - Object password = list.get(1); + Object password = map.get("password"); pigeonResult.setPassword((String)password); return pigeonResult; } @@ -151,17 +150,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(2); - toListResult.add(id); - toListResult.add(pagesCount); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("id", id); + toMapResult.put("pagesCount", pagesCount); + return toMapResult; } - static @NonNull OpenReply fromList(@NonNull ArrayList list) { + static @NonNull OpenReply fromMap(@NonNull Map map) { OpenReply pigeonResult = new OpenReply(); - Object id = list.get(0); + Object id = map.get("id"); pigeonResult.setId((String)id); - Object pagesCount = list.get(1); + Object pagesCount = map.get("pagesCount"); pigeonResult.setPagesCount((pagesCount == null) ? null : ((pagesCount instanceof Integer) ? (Integer)pagesCount : (Long)pagesCount)); return pigeonResult; } @@ -187,14 +186,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(1); - toListResult.add(id); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("id", id); + return toMapResult; } - static @NonNull IdMessage fromList(@NonNull ArrayList list) { + static @NonNull IdMessage fromMap(@NonNull Map map) { IdMessage pigeonResult = new IdMessage(); - Object id = list.get(0); + Object id = map.get("id"); pigeonResult.setId((String)id); return pigeonResult; } @@ -244,20 +243,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(3); - toListResult.add(documentId); - toListResult.add(pageNumber); - toListResult.add(autoCloseAndroid); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("documentId", documentId); + toMapResult.put("pageNumber", pageNumber); + toMapResult.put("autoCloseAndroid", autoCloseAndroid); + return toMapResult; } - static @NonNull GetPageMessage fromList(@NonNull ArrayList list) { + static @NonNull GetPageMessage fromMap(@NonNull Map map) { GetPageMessage pigeonResult = new GetPageMessage(); - Object documentId = list.get(0); + Object documentId = map.get("documentId"); pigeonResult.setDocumentId((String)documentId); - Object pageNumber = list.get(1); + Object pageNumber = map.get("pageNumber"); pigeonResult.setPageNumber((pageNumber == null) ? null : ((pageNumber instanceof Integer) ? (Integer)pageNumber : (Long)pageNumber)); - Object autoCloseAndroid = list.get(2); + Object autoCloseAndroid = map.get("autoCloseAndroid"); pigeonResult.setAutoCloseAndroid((Boolean)autoCloseAndroid); return pigeonResult; } @@ -307,20 +306,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(3); - toListResult.add(id); - toListResult.add(width); - toListResult.add(height); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("id", id); + toMapResult.put("width", width); + toMapResult.put("height", height); + return toMapResult; } - static @NonNull GetPageReply fromList(@NonNull ArrayList list) { + static @NonNull GetPageReply fromMap(@NonNull Map map) { GetPageReply pigeonResult = new GetPageReply(); - Object id = list.get(0); + Object id = map.get("id"); pigeonResult.setId((String)id); - Object width = list.get(1); + Object width = map.get("width"); pigeonResult.setWidth((Double)width); - Object height = list.get(2); + Object height = map.get("height"); pigeonResult.setHeight((Double)height); return pigeonResult; } @@ -478,47 +477,47 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(12); - toListResult.add(pageId); - toListResult.add(width); - toListResult.add(height); - toListResult.add(format); - toListResult.add(backgroundColor); - toListResult.add(crop); - toListResult.add(cropX); - toListResult.add(cropY); - toListResult.add(cropHeight); - toListResult.add(cropWidth); - toListResult.add(quality); - toListResult.add(forPrint); - return toListResult; - } - static @NonNull RenderPageMessage fromList(@NonNull ArrayList list) { + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("pageId", pageId); + toMapResult.put("width", width); + toMapResult.put("height", height); + toMapResult.put("format", format); + toMapResult.put("backgroundColor", backgroundColor); + toMapResult.put("crop", crop); + toMapResult.put("cropX", cropX); + toMapResult.put("cropY", cropY); + toMapResult.put("cropHeight", cropHeight); + toMapResult.put("cropWidth", cropWidth); + toMapResult.put("quality", quality); + toMapResult.put("forPrint", forPrint); + return toMapResult; + } + static @NonNull RenderPageMessage fromMap(@NonNull Map map) { RenderPageMessage pigeonResult = new RenderPageMessage(); - Object pageId = list.get(0); + Object pageId = map.get("pageId"); pigeonResult.setPageId((String)pageId); - Object width = list.get(1); + Object width = map.get("width"); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = list.get(2); + Object height = map.get("height"); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object format = list.get(3); + Object format = map.get("format"); pigeonResult.setFormat((format == null) ? null : ((format instanceof Integer) ? (Integer)format : (Long)format)); - Object backgroundColor = list.get(4); + Object backgroundColor = map.get("backgroundColor"); pigeonResult.setBackgroundColor((String)backgroundColor); - Object crop = list.get(5); + Object crop = map.get("crop"); pigeonResult.setCrop((Boolean)crop); - Object cropX = list.get(6); + Object cropX = map.get("cropX"); pigeonResult.setCropX((cropX == null) ? null : ((cropX instanceof Integer) ? (Integer)cropX : (Long)cropX)); - Object cropY = list.get(7); + Object cropY = map.get("cropY"); pigeonResult.setCropY((cropY == null) ? null : ((cropY instanceof Integer) ? (Integer)cropY : (Long)cropY)); - Object cropHeight = list.get(8); + Object cropHeight = map.get("cropHeight"); pigeonResult.setCropHeight((cropHeight == null) ? null : ((cropHeight instanceof Integer) ? (Integer)cropHeight : (Long)cropHeight)); - Object cropWidth = list.get(9); + Object cropWidth = map.get("cropWidth"); pigeonResult.setCropWidth((cropWidth == null) ? null : ((cropWidth instanceof Integer) ? (Integer)cropWidth : (Long)cropWidth)); - Object quality = list.get(10); + Object quality = map.get("quality"); pigeonResult.setQuality((quality == null) ? null : ((quality instanceof Integer) ? (Integer)quality : (Long)quality)); - Object forPrint = list.get(11); + Object forPrint = map.get("forPrint"); pigeonResult.setForPrint((Boolean)forPrint); return pigeonResult; } @@ -580,23 +579,23 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(4); - toListResult.add(width); - toListResult.add(height); - toListResult.add(path); - toListResult.add(data); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("width", width); + toMapResult.put("height", height); + toMapResult.put("path", path); + toMapResult.put("data", data); + return toMapResult; } - static @NonNull RenderPageReply fromList(@NonNull ArrayList list) { + static @NonNull RenderPageReply fromMap(@NonNull Map map) { RenderPageReply pigeonResult = new RenderPageReply(); - Object width = list.get(0); + Object width = map.get("width"); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = list.get(1); + Object height = map.get("height"); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object path = list.get(2); + Object path = map.get("path"); pigeonResult.setPath((String)path); - Object data = list.get(3); + Object data = map.get("data"); pigeonResult.setData((byte[])data); return pigeonResult; } @@ -622,14 +621,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(1); - toListResult.add(id); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("id", id); + return toMapResult; } - static @NonNull RegisterTextureReply fromList(@NonNull ArrayList list) { + static @NonNull RegisterTextureReply fromMap(@NonNull Map map) { RegisterTextureReply pigeonResult = new RegisterTextureReply(); - Object id = list.get(0); + Object id = map.get("id"); pigeonResult.setId((id == null) ? null : ((id instanceof Integer) ? (Integer)id : (Long)id)); return pigeonResult; } @@ -835,59 +834,59 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(16); - toListResult.add(documentId); - toListResult.add(pageNumber); - toListResult.add(pageId); - toListResult.add(textureId); - toListResult.add(width); - toListResult.add(height); - toListResult.add(backgroundColor); - toListResult.add(sourceX); - toListResult.add(sourceY); - toListResult.add(destinationX); - toListResult.add(destinationY); - toListResult.add(fullWidth); - toListResult.add(fullHeight); - toListResult.add(textureWidth); - toListResult.add(textureHeight); - toListResult.add(allowAntiAliasing); - return toListResult; - } - static @NonNull UpdateTextureMessage fromList(@NonNull ArrayList list) { + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("documentId", documentId); + toMapResult.put("pageNumber", pageNumber); + toMapResult.put("pageId", pageId); + toMapResult.put("textureId", textureId); + toMapResult.put("width", width); + toMapResult.put("height", height); + toMapResult.put("backgroundColor", backgroundColor); + toMapResult.put("sourceX", sourceX); + toMapResult.put("sourceY", sourceY); + toMapResult.put("destinationX", destinationX); + toMapResult.put("destinationY", destinationY); + toMapResult.put("fullWidth", fullWidth); + toMapResult.put("fullHeight", fullHeight); + toMapResult.put("textureWidth", textureWidth); + toMapResult.put("textureHeight", textureHeight); + toMapResult.put("allowAntiAliasing", allowAntiAliasing); + return toMapResult; + } + static @NonNull UpdateTextureMessage fromMap(@NonNull Map map) { UpdateTextureMessage pigeonResult = new UpdateTextureMessage(); - Object documentId = list.get(0); + Object documentId = map.get("documentId"); pigeonResult.setDocumentId((String)documentId); - Object pageNumber = list.get(1); + Object pageNumber = map.get("pageNumber"); pigeonResult.setPageNumber((pageNumber == null) ? null : ((pageNumber instanceof Integer) ? (Integer)pageNumber : (Long)pageNumber)); - Object pageId = list.get(2); + Object pageId = map.get("pageId"); pigeonResult.setPageId((String)pageId); - Object textureId = list.get(3); + Object textureId = map.get("textureId"); pigeonResult.setTextureId((textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId)); - Object width = list.get(4); + Object width = map.get("width"); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = list.get(5); + Object height = map.get("height"); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object backgroundColor = list.get(6); + Object backgroundColor = map.get("backgroundColor"); pigeonResult.setBackgroundColor((String)backgroundColor); - Object sourceX = list.get(7); + Object sourceX = map.get("sourceX"); pigeonResult.setSourceX((sourceX == null) ? null : ((sourceX instanceof Integer) ? (Integer)sourceX : (Long)sourceX)); - Object sourceY = list.get(8); + Object sourceY = map.get("sourceY"); pigeonResult.setSourceY((sourceY == null) ? null : ((sourceY instanceof Integer) ? (Integer)sourceY : (Long)sourceY)); - Object destinationX = list.get(9); + Object destinationX = map.get("destinationX"); pigeonResult.setDestinationX((destinationX == null) ? null : ((destinationX instanceof Integer) ? (Integer)destinationX : (Long)destinationX)); - Object destinationY = list.get(10); + Object destinationY = map.get("destinationY"); pigeonResult.setDestinationY((destinationY == null) ? null : ((destinationY instanceof Integer) ? (Integer)destinationY : (Long)destinationY)); - Object fullWidth = list.get(11); + Object fullWidth = map.get("fullWidth"); pigeonResult.setFullWidth((Double)fullWidth); - Object fullHeight = list.get(12); + Object fullHeight = map.get("fullHeight"); pigeonResult.setFullHeight((Double)fullHeight); - Object textureWidth = list.get(13); + Object textureWidth = map.get("textureWidth"); pigeonResult.setTextureWidth((textureWidth == null) ? null : ((textureWidth instanceof Integer) ? (Integer)textureWidth : (Long)textureWidth)); - Object textureHeight = list.get(14); + Object textureHeight = map.get("textureHeight"); pigeonResult.setTextureHeight((textureHeight == null) ? null : ((textureHeight instanceof Integer) ? (Integer)textureHeight : (Long)textureHeight)); - Object allowAntiAliasing = list.get(15); + Object allowAntiAliasing = map.get("allowAntiAliasing"); pigeonResult.setAllowAntiAliasing((Boolean)allowAntiAliasing); return pigeonResult; } @@ -937,20 +936,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(3); - toListResult.add(textureId); - toListResult.add(width); - toListResult.add(height); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("textureId", textureId); + toMapResult.put("width", width); + toMapResult.put("height", height); + return toMapResult; } - static @NonNull ResizeTextureMessage fromList(@NonNull ArrayList list) { + static @NonNull ResizeTextureMessage fromMap(@NonNull Map map) { ResizeTextureMessage pigeonResult = new ResizeTextureMessage(); - Object textureId = list.get(0); + Object textureId = map.get("textureId"); pigeonResult.setTextureId((textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId)); - Object width = list.get(1); + Object width = map.get("width"); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = list.get(2); + Object height = map.get("height"); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); return pigeonResult; } @@ -976,14 +975,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(1); - toListResult.add(id); - return toListResult; + @NonNull Map toMap() { + Map toMapResult = new HashMap<>(); + toMapResult.put("id", id); + return toMapResult; } - static @NonNull UnregisterTextureMessage fromList(@NonNull ArrayList list) { + static @NonNull UnregisterTextureMessage fromMap(@NonNull Map map) { UnregisterTextureMessage pigeonResult = new UnregisterTextureMessage(); - Object id = list.get(0); + Object id = map.get("id"); pigeonResult.setId((id == null) ? null : ((id instanceof Integer) ? (Integer)id : (Long)id)); return pigeonResult; } @@ -1000,40 +999,40 @@ private PdfxApiCodec() {} protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { switch (type) { case (byte)128: - return GetPageMessage.fromList((ArrayList) readValue(buffer)); + return GetPageMessage.fromMap((Map) readValue(buffer)); case (byte)129: - return GetPageReply.fromList((ArrayList) readValue(buffer)); + return GetPageReply.fromMap((Map) readValue(buffer)); case (byte)130: - return IdMessage.fromList((ArrayList) readValue(buffer)); + return IdMessage.fromMap((Map) readValue(buffer)); case (byte)131: - return OpenDataMessage.fromList((ArrayList) readValue(buffer)); + return OpenDataMessage.fromMap((Map) readValue(buffer)); case (byte)132: - return OpenPathMessage.fromList((ArrayList) readValue(buffer)); + return OpenPathMessage.fromMap((Map) readValue(buffer)); case (byte)133: - return OpenReply.fromList((ArrayList) readValue(buffer)); + return OpenReply.fromMap((Map) readValue(buffer)); case (byte)134: - return RegisterTextureReply.fromList((ArrayList) readValue(buffer)); + return RegisterTextureReply.fromMap((Map) readValue(buffer)); case (byte)135: - return RenderPageMessage.fromList((ArrayList) readValue(buffer)); + return RenderPageMessage.fromMap((Map) readValue(buffer)); case (byte)136: - return RenderPageReply.fromList((ArrayList) readValue(buffer)); + return RenderPageReply.fromMap((Map) readValue(buffer)); case (byte)137: - return ResizeTextureMessage.fromList((ArrayList) readValue(buffer)); + return ResizeTextureMessage.fromMap((Map) readValue(buffer)); case (byte)138: - return UnregisterTextureMessage.fromList((ArrayList) readValue(buffer)); + return UnregisterTextureMessage.fromMap((Map) readValue(buffer)); case (byte)139: - return UpdateTextureMessage.fromList((ArrayList) readValue(buffer)); + return UpdateTextureMessage.fromMap((Map) readValue(buffer)); default: return super.readValueOfType(type, buffer); @@ -1044,51 +1043,51 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { if (value instanceof GetPageMessage) { stream.write(128); - writeValue(stream, ((GetPageMessage) value).toList()); + writeValue(stream, ((GetPageMessage) value).toMap()); } else if (value instanceof GetPageReply) { stream.write(129); - writeValue(stream, ((GetPageReply) value).toList()); + writeValue(stream, ((GetPageReply) value).toMap()); } else if (value instanceof IdMessage) { stream.write(130); - writeValue(stream, ((IdMessage) value).toList()); + writeValue(stream, ((IdMessage) value).toMap()); } else if (value instanceof OpenDataMessage) { stream.write(131); - writeValue(stream, ((OpenDataMessage) value).toList()); + writeValue(stream, ((OpenDataMessage) value).toMap()); } else if (value instanceof OpenPathMessage) { stream.write(132); - writeValue(stream, ((OpenPathMessage) value).toList()); + writeValue(stream, ((OpenPathMessage) value).toMap()); } else if (value instanceof OpenReply) { stream.write(133); - writeValue(stream, ((OpenReply) value).toList()); + writeValue(stream, ((OpenReply) value).toMap()); } else if (value instanceof RegisterTextureReply) { stream.write(134); - writeValue(stream, ((RegisterTextureReply) value).toList()); + writeValue(stream, ((RegisterTextureReply) value).toMap()); } else if (value instanceof RenderPageMessage) { stream.write(135); - writeValue(stream, ((RenderPageMessage) value).toList()); + writeValue(stream, ((RenderPageMessage) value).toMap()); } else if (value instanceof RenderPageReply) { stream.write(136); - writeValue(stream, ((RenderPageReply) value).toList()); + writeValue(stream, ((RenderPageReply) value).toMap()); } else if (value instanceof ResizeTextureMessage) { stream.write(137); - writeValue(stream, ((ResizeTextureMessage) value).toList()); + writeValue(stream, ((ResizeTextureMessage) value).toMap()); } else if (value instanceof UnregisterTextureMessage) { stream.write(138); - writeValue(stream, ((UnregisterTextureMessage) value).toList()); + writeValue(stream, ((UnregisterTextureMessage) value).toMap()); } else if (value instanceof UpdateTextureMessage) { stream.write(139); - writeValue(stream, ((UpdateTextureMessage) value).toList()); + writeValue(stream, ((UpdateTextureMessage) value).toMap()); } else { super.writeValue(stream, value); @@ -1121,7 +1120,9 @@ public interface PdfxApi { /** The codec used by PdfxApi. */ static MessageCodec getCodec() { - return PdfxApiCodec.INSTANCE; } + return PdfxApiCodec.INSTANCE; + } + /**Sets up an instance of `PdfxApi` to handle messages through the `binaryMessenger`. */ static void setup(BinaryMessenger binaryMessenger, PdfxApi api) { { @@ -1129,30 +1130,29 @@ static void setup(BinaryMessenger binaryMessenger, PdfxApi api) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentData", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; OpenDataMessage messageArg = (OpenDataMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.add(0, result); + wrapped.put("result", result); reply.reply(wrapped); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); } }; api.openDocumentData(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - reply.reply(wrappedError); + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); } }); } else { @@ -1164,30 +1164,29 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentFile", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; OpenPathMessage messageArg = (OpenPathMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.add(0, result); + wrapped.put("result", result); reply.reply(wrapped); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); } }; api.openDocumentFile(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - reply.reply(wrappedError); + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); } }); } else { @@ -1199,30 +1198,29 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentAsset", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; OpenPathMessage messageArg = (OpenPathMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.add(0, result); + wrapped.put("result", result); reply.reply(wrapped); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); } }; api.openDocumentAsset(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - reply.reply(wrappedError); + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); } }); } else { @@ -1234,20 +1232,18 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.closeDocument", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; IdMessage messageArg = (IdMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.closeDocument(messageArg); - wrapped.add(0, null); + wrapped.put("result", null); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - wrapped = wrappedError; + wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); }); @@ -1260,30 +1256,29 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.getPage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; GetPageMessage messageArg = (GetPageMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(GetPageReply result) { - wrapped.add(0, result); + wrapped.put("result", result); reply.reply(wrapped); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); } }; api.getPage(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - reply.reply(wrappedError); + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); } }); } else { @@ -1295,30 +1290,29 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.renderPage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; RenderPageMessage messageArg = (RenderPageMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(RenderPageReply result) { - wrapped.add(0, result); + wrapped.put("result", result); reply.reply(wrapped); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); } }; api.renderPage(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - reply.reply(wrappedError); + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); } }); } else { @@ -1330,20 +1324,18 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.closePage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; IdMessage messageArg = (IdMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.closePage(messageArg); - wrapped.add(0, null); + wrapped.put("result", null); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - wrapped = wrappedError; + wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); }); @@ -1356,14 +1348,13 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.registerTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { RegisterTextureReply output = api.registerTexture(); - wrapped.add(0, output); + wrapped.put("result", output); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - wrapped = wrappedError; + wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); }); @@ -1376,30 +1367,29 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.updateTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; UpdateTextureMessage messageArg = (UpdateTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(Void result) { - wrapped.add(0, null); + wrapped.put("result", null); reply.reply(wrapped); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); } }; api.updateTexture(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - reply.reply(wrappedError); + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); } }); } else { @@ -1411,30 +1401,29 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.resizeTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; ResizeTextureMessage messageArg = (ResizeTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(Void result) { - wrapped.add(0, null); + wrapped.put("result", null); reply.reply(wrapped); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + wrapped.put("error", wrapError(error)); + reply.reply(wrapped); } }; api.resizeTexture(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - reply.reply(wrappedError); + wrapped.put("error", wrapError(exception)); + reply.reply(wrapped); } }); } else { @@ -1446,20 +1435,18 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.unregisterTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - ArrayList wrapped = new ArrayList<>(); + Map wrapped = new HashMap<>(); try { ArrayList args = (ArrayList)message; - assert args != null; UnregisterTextureMessage messageArg = (UnregisterTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.unregisterTexture(messageArg); - wrapped.add(0, null); + wrapped.put("result", null); } catch (Error | RuntimeException exception) { - ArrayList wrappedError = wrapError(exception); - wrapped = wrappedError; + wrapped.put("error", wrapError(exception)); } reply.reply(wrapped); }); @@ -1469,11 +1456,11 @@ public void error(Throwable error) { } } } - @NonNull private static ArrayList wrapError(@NonNull Throwable exception) { - ArrayList errorList = new ArrayList<>(3); - errorList.add(exception.toString()); - errorList.add(exception.getClass().getSimpleName()); - errorList.add("Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); - return errorList; + @NonNull private static Map wrapError(@NonNull Throwable exception) { + Map errorMap = new HashMap<>(); + errorMap.put("message", exception.toString()); + errorMap.put("code", exception.getClass().getSimpleName()); + errorMap.put("details", "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorMap; } } diff --git a/packages/pdfx/ios/Classes/messages.h b/packages/pdfx/ios/Classes/messages.h index 3d3134b5..5b0aef71 100644 --- a/packages/pdfx/ios/Classes/messages.h +++ b/packages/pdfx/ios/Classes/messages.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.14), do not edit directly. +// Autogenerated from Pigeon (v4.2.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @protocol FlutterBinaryMessenger; @@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong, nullable) NSNumber * id; @end -/// The codec used by PdfxApi. +///The codec used by PdfxApi. NSObject *PdfxApiGetCodec(void); /// Rebuild: `flutter pub run pigeon --input pigeons/message.dart` diff --git a/packages/pdfx/ios/Classes/messages.m b/packages/pdfx/ios/Classes/messages.m index c5d4bfab..6070a468 100644 --- a/packages/pdfx/ios/Classes/messages.m +++ b/packages/pdfx/ios/Classes/messages.m @@ -1,17 +1,29 @@ -// Autogenerated from Pigeon (v4.2.14), do not edit directly. +// Autogenerated from Pigeon (v4.2.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.h" +#if TARGET_OS_IOS #import +#else +#import +#endif #if !__has_feature(objc_arc) #error File requires ARC to be enabled. #endif -static NSArray *wrapResult(id result, FlutterError *error) { +static NSDictionary *wrapResult(id result, FlutterError *error) { + NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { - return @[ error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] ]; + errorDict = @{ + @"code": (error.code ?: [NSNull null]), + @"message": (error.message ?: [NSNull null]), + @"details": (error.details ?: [NSNull null]), + }; } - return @[ result ?: [NSNull null] ]; + return @{ + @"result": (result ?: [NSNull null]), + @"error": errorDict, + }; } static id GetNullableObject(NSDictionary* dict, id key) { id result = dict[key]; @@ -24,64 +36,64 @@ static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { @interface OpenDataMessage () -+ (OpenDataMessage *)fromList:(NSArray *)list; -+ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (OpenDataMessage *)fromMap:(NSDictionary *)dict; ++ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface OpenPathMessage () -+ (OpenPathMessage *)fromList:(NSArray *)list; -+ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (OpenPathMessage *)fromMap:(NSDictionary *)dict; ++ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface OpenReply () -+ (OpenReply *)fromList:(NSArray *)list; -+ (nullable OpenReply *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (OpenReply *)fromMap:(NSDictionary *)dict; ++ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface IdMessage () -+ (IdMessage *)fromList:(NSArray *)list; -+ (nullable IdMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (IdMessage *)fromMap:(NSDictionary *)dict; ++ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface GetPageMessage () -+ (GetPageMessage *)fromList:(NSArray *)list; -+ (nullable GetPageMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (GetPageMessage *)fromMap:(NSDictionary *)dict; ++ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface GetPageReply () -+ (GetPageReply *)fromList:(NSArray *)list; -+ (nullable GetPageReply *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (GetPageReply *)fromMap:(NSDictionary *)dict; ++ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface RenderPageMessage () -+ (RenderPageMessage *)fromList:(NSArray *)list; -+ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (RenderPageMessage *)fromMap:(NSDictionary *)dict; ++ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface RenderPageReply () -+ (RenderPageReply *)fromList:(NSArray *)list; -+ (nullable RenderPageReply *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (RenderPageReply *)fromMap:(NSDictionary *)dict; ++ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface RegisterTextureReply () -+ (RegisterTextureReply *)fromList:(NSArray *)list; -+ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (RegisterTextureReply *)fromMap:(NSDictionary *)dict; ++ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface UpdateTextureMessage () -+ (UpdateTextureMessage *)fromList:(NSArray *)list; -+ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict; ++ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface ResizeTextureMessage () -+ (ResizeTextureMessage *)fromList:(NSArray *)list; -+ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict; ++ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @interface UnregisterTextureMessage () -+ (UnregisterTextureMessage *)fromList:(NSArray *)list; -+ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict; ++ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict; +- (NSDictionary *)toMap; @end @implementation OpenDataMessage @@ -92,18 +104,18 @@ + (instancetype)makeWithData:(nullable FlutterStandardTypedData *)data pigeonResult.password = password; return pigeonResult; } -+ (OpenDataMessage *)fromList:(NSArray *)list { ++ (OpenDataMessage *)fromMap:(NSDictionary *)dict { OpenDataMessage *pigeonResult = [[OpenDataMessage alloc] init]; - pigeonResult.data = GetNullableObjectAtIndex(list, 0); - pigeonResult.password = GetNullableObjectAtIndex(list, 1); + pigeonResult.data = GetNullableObject(dict, @"data"); + pigeonResult.password = GetNullableObject(dict, @"password"); return pigeonResult; } -+ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenDataMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.data ?: [NSNull null]), - (self.password ?: [NSNull null]), - ]; ++ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenDataMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"data" : (self.data ?: [NSNull null]), + @"password" : (self.password ?: [NSNull null]), + }; } @end @@ -115,18 +127,18 @@ + (instancetype)makeWithPath:(nullable NSString *)path pigeonResult.password = password; return pigeonResult; } -+ (OpenPathMessage *)fromList:(NSArray *)list { ++ (OpenPathMessage *)fromMap:(NSDictionary *)dict { OpenPathMessage *pigeonResult = [[OpenPathMessage alloc] init]; - pigeonResult.path = GetNullableObjectAtIndex(list, 0); - pigeonResult.password = GetNullableObjectAtIndex(list, 1); + pigeonResult.path = GetNullableObject(dict, @"path"); + pigeonResult.password = GetNullableObject(dict, @"password"); return pigeonResult; } -+ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenPathMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.path ?: [NSNull null]), - (self.password ?: [NSNull null]), - ]; ++ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenPathMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"path" : (self.path ?: [NSNull null]), + @"password" : (self.password ?: [NSNull null]), + }; } @end @@ -138,18 +150,18 @@ + (instancetype)makeWithId:(nullable NSString *)id pigeonResult.pagesCount = pagesCount; return pigeonResult; } -+ (OpenReply *)fromList:(NSArray *)list { ++ (OpenReply *)fromMap:(NSDictionary *)dict { OpenReply *pigeonResult = [[OpenReply alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); - pigeonResult.pagesCount = GetNullableObjectAtIndex(list, 1); + pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.pagesCount = GetNullableObject(dict, @"pagesCount"); return pigeonResult; } -+ (nullable OpenReply *)nullableFromList:(NSArray *)list { return (list) ? [OpenReply fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - (self.pagesCount ?: [NSNull null]), - ]; ++ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenReply fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + @"pagesCount" : (self.pagesCount ?: [NSNull null]), + }; } @end @@ -159,16 +171,16 @@ + (instancetype)makeWithId:(nullable NSString *)id { pigeonResult.id = id; return pigeonResult; } -+ (IdMessage *)fromList:(NSArray *)list { ++ (IdMessage *)fromMap:(NSDictionary *)dict { IdMessage *pigeonResult = [[IdMessage alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.id = GetNullableObject(dict, @"id"); return pigeonResult; } -+ (nullable IdMessage *)nullableFromList:(NSArray *)list { return (list) ? [IdMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - ]; ++ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [IdMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + }; } @end @@ -182,20 +194,20 @@ + (instancetype)makeWithDocumentId:(nullable NSString *)documentId pigeonResult.autoCloseAndroid = autoCloseAndroid; return pigeonResult; } -+ (GetPageMessage *)fromList:(NSArray *)list { ++ (GetPageMessage *)fromMap:(NSDictionary *)dict { GetPageMessage *pigeonResult = [[GetPageMessage alloc] init]; - pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); - pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); - pigeonResult.autoCloseAndroid = GetNullableObjectAtIndex(list, 2); + pigeonResult.documentId = GetNullableObject(dict, @"documentId"); + pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); + pigeonResult.autoCloseAndroid = GetNullableObject(dict, @"autoCloseAndroid"); return pigeonResult; } -+ (nullable GetPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [GetPageMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.documentId ?: [NSNull null]), - (self.pageNumber ?: [NSNull null]), - (self.autoCloseAndroid ?: [NSNull null]), - ]; ++ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"documentId" : (self.documentId ?: [NSNull null]), + @"pageNumber" : (self.pageNumber ?: [NSNull null]), + @"autoCloseAndroid" : (self.autoCloseAndroid ?: [NSNull null]), + }; } @end @@ -209,20 +221,20 @@ + (instancetype)makeWithId:(nullable NSString *)id pigeonResult.height = height; return pigeonResult; } -+ (GetPageReply *)fromList:(NSArray *)list { ++ (GetPageReply *)fromMap:(NSDictionary *)dict { GetPageReply *pigeonResult = [[GetPageReply alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); - pigeonResult.width = GetNullableObjectAtIndex(list, 1); - pigeonResult.height = GetNullableObjectAtIndex(list, 2); + pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); return pigeonResult; } -+ (nullable GetPageReply *)nullableFromList:(NSArray *)list { return (list) ? [GetPageReply fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - ]; ++ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageReply fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + }; } @end @@ -254,38 +266,38 @@ + (instancetype)makeWithPageId:(nullable NSString *)pageId pigeonResult.forPrint = forPrint; return pigeonResult; } -+ (RenderPageMessage *)fromList:(NSArray *)list { ++ (RenderPageMessage *)fromMap:(NSDictionary *)dict { RenderPageMessage *pigeonResult = [[RenderPageMessage alloc] init]; - pigeonResult.pageId = GetNullableObjectAtIndex(list, 0); - pigeonResult.width = GetNullableObjectAtIndex(list, 1); - pigeonResult.height = GetNullableObjectAtIndex(list, 2); - pigeonResult.format = GetNullableObjectAtIndex(list, 3); - pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 4); - pigeonResult.crop = GetNullableObjectAtIndex(list, 5); - pigeonResult.cropX = GetNullableObjectAtIndex(list, 6); - pigeonResult.cropY = GetNullableObjectAtIndex(list, 7); - pigeonResult.cropHeight = GetNullableObjectAtIndex(list, 8); - pigeonResult.cropWidth = GetNullableObjectAtIndex(list, 9); - pigeonResult.quality = GetNullableObjectAtIndex(list, 10); - pigeonResult.forPrint = GetNullableObjectAtIndex(list, 11); + pigeonResult.pageId = GetNullableObject(dict, @"pageId"); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.format = GetNullableObject(dict, @"format"); + pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); + pigeonResult.crop = GetNullableObject(dict, @"crop"); + pigeonResult.cropX = GetNullableObject(dict, @"cropX"); + pigeonResult.cropY = GetNullableObject(dict, @"cropY"); + pigeonResult.cropHeight = GetNullableObject(dict, @"cropHeight"); + pigeonResult.cropWidth = GetNullableObject(dict, @"cropWidth"); + pigeonResult.quality = GetNullableObject(dict, @"quality"); + pigeonResult.forPrint = GetNullableObject(dict, @"forPrint"); return pigeonResult; } -+ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.pageId ?: [NSNull null]), - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - (self.format ?: [NSNull null]), - (self.backgroundColor ?: [NSNull null]), - (self.crop ?: [NSNull null]), - (self.cropX ?: [NSNull null]), - (self.cropY ?: [NSNull null]), - (self.cropHeight ?: [NSNull null]), - (self.cropWidth ?: [NSNull null]), - (self.quality ?: [NSNull null]), - (self.forPrint ?: [NSNull null]), - ]; ++ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"pageId" : (self.pageId ?: [NSNull null]), + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + @"format" : (self.format ?: [NSNull null]), + @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), + @"crop" : (self.crop ?: [NSNull null]), + @"cropX" : (self.cropX ?: [NSNull null]), + @"cropY" : (self.cropY ?: [NSNull null]), + @"cropHeight" : (self.cropHeight ?: [NSNull null]), + @"cropWidth" : (self.cropWidth ?: [NSNull null]), + @"quality" : (self.quality ?: [NSNull null]), + @"forPrint" : (self.forPrint ?: [NSNull null]), + }; } @end @@ -301,22 +313,22 @@ + (instancetype)makeWithWidth:(nullable NSNumber *)width pigeonResult.data = data; return pigeonResult; } -+ (RenderPageReply *)fromList:(NSArray *)list { ++ (RenderPageReply *)fromMap:(NSDictionary *)dict { RenderPageReply *pigeonResult = [[RenderPageReply alloc] init]; - pigeonResult.width = GetNullableObjectAtIndex(list, 0); - pigeonResult.height = GetNullableObjectAtIndex(list, 1); - pigeonResult.path = GetNullableObjectAtIndex(list, 2); - pigeonResult.data = GetNullableObjectAtIndex(list, 3); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.path = GetNullableObject(dict, @"path"); + pigeonResult.data = GetNullableObject(dict, @"data"); return pigeonResult; } -+ (nullable RenderPageReply *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageReply fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - (self.path ?: [NSNull null]), - (self.data ?: [NSNull null]), - ]; ++ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageReply fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + @"path" : (self.path ?: [NSNull null]), + @"data" : (self.data ?: [NSNull null]), + }; } @end @@ -326,16 +338,16 @@ + (instancetype)makeWithId:(nullable NSNumber *)id { pigeonResult.id = id; return pigeonResult; } -+ (RegisterTextureReply *)fromList:(NSArray *)list { ++ (RegisterTextureReply *)fromMap:(NSDictionary *)dict { RegisterTextureReply *pigeonResult = [[RegisterTextureReply alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.id = GetNullableObject(dict, @"id"); return pigeonResult; } -+ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list { return (list) ? [RegisterTextureReply fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - ]; ++ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RegisterTextureReply fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + }; } @end @@ -375,46 +387,46 @@ + (instancetype)makeWithDocumentId:(nullable NSString *)documentId pigeonResult.allowAntiAliasing = allowAntiAliasing; return pigeonResult; } -+ (UpdateTextureMessage *)fromList:(NSArray *)list { ++ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict { UpdateTextureMessage *pigeonResult = [[UpdateTextureMessage alloc] init]; - pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); - pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); - pigeonResult.pageId = GetNullableObjectAtIndex(list, 2); - pigeonResult.textureId = GetNullableObjectAtIndex(list, 3); - pigeonResult.width = GetNullableObjectAtIndex(list, 4); - pigeonResult.height = GetNullableObjectAtIndex(list, 5); - pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 6); - pigeonResult.sourceX = GetNullableObjectAtIndex(list, 7); - pigeonResult.sourceY = GetNullableObjectAtIndex(list, 8); - pigeonResult.destinationX = GetNullableObjectAtIndex(list, 9); - pigeonResult.destinationY = GetNullableObjectAtIndex(list, 10); - pigeonResult.fullWidth = GetNullableObjectAtIndex(list, 11); - pigeonResult.fullHeight = GetNullableObjectAtIndex(list, 12); - pigeonResult.textureWidth = GetNullableObjectAtIndex(list, 13); - pigeonResult.textureHeight = GetNullableObjectAtIndex(list, 14); - pigeonResult.allowAntiAliasing = GetNullableObjectAtIndex(list, 15); + pigeonResult.documentId = GetNullableObject(dict, @"documentId"); + pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); + pigeonResult.pageId = GetNullableObject(dict, @"pageId"); + pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); + pigeonResult.sourceX = GetNullableObject(dict, @"sourceX"); + pigeonResult.sourceY = GetNullableObject(dict, @"sourceY"); + pigeonResult.destinationX = GetNullableObject(dict, @"destinationX"); + pigeonResult.destinationY = GetNullableObject(dict, @"destinationY"); + pigeonResult.fullWidth = GetNullableObject(dict, @"fullWidth"); + pigeonResult.fullHeight = GetNullableObject(dict, @"fullHeight"); + pigeonResult.textureWidth = GetNullableObject(dict, @"textureWidth"); + pigeonResult.textureHeight = GetNullableObject(dict, @"textureHeight"); + pigeonResult.allowAntiAliasing = GetNullableObject(dict, @"allowAntiAliasing"); return pigeonResult; } -+ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UpdateTextureMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.documentId ?: [NSNull null]), - (self.pageNumber ?: [NSNull null]), - (self.pageId ?: [NSNull null]), - (self.textureId ?: [NSNull null]), - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - (self.backgroundColor ?: [NSNull null]), - (self.sourceX ?: [NSNull null]), - (self.sourceY ?: [NSNull null]), - (self.destinationX ?: [NSNull null]), - (self.destinationY ?: [NSNull null]), - (self.fullWidth ?: [NSNull null]), - (self.fullHeight ?: [NSNull null]), - (self.textureWidth ?: [NSNull null]), - (self.textureHeight ?: [NSNull null]), - (self.allowAntiAliasing ?: [NSNull null]), - ]; ++ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UpdateTextureMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"documentId" : (self.documentId ?: [NSNull null]), + @"pageNumber" : (self.pageNumber ?: [NSNull null]), + @"pageId" : (self.pageId ?: [NSNull null]), + @"textureId" : (self.textureId ?: [NSNull null]), + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), + @"sourceX" : (self.sourceX ?: [NSNull null]), + @"sourceY" : (self.sourceY ?: [NSNull null]), + @"destinationX" : (self.destinationX ?: [NSNull null]), + @"destinationY" : (self.destinationY ?: [NSNull null]), + @"fullWidth" : (self.fullWidth ?: [NSNull null]), + @"fullHeight" : (self.fullHeight ?: [NSNull null]), + @"textureWidth" : (self.textureWidth ?: [NSNull null]), + @"textureHeight" : (self.textureHeight ?: [NSNull null]), + @"allowAntiAliasing" : (self.allowAntiAliasing ?: [NSNull null]), + }; } @end @@ -428,20 +440,20 @@ + (instancetype)makeWithTextureId:(nullable NSNumber *)textureId pigeonResult.height = height; return pigeonResult; } -+ (ResizeTextureMessage *)fromList:(NSArray *)list { ++ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict { ResizeTextureMessage *pigeonResult = [[ResizeTextureMessage alloc] init]; - pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); - pigeonResult.width = GetNullableObjectAtIndex(list, 1); - pigeonResult.height = GetNullableObjectAtIndex(list, 2); + pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.width = GetNullableObject(dict, @"width"); + pigeonResult.height = GetNullableObject(dict, @"height"); return pigeonResult; } -+ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [ResizeTextureMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.textureId ?: [NSNull null]), - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), - ]; ++ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [ResizeTextureMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"textureId" : (self.textureId ?: [NSNull null]), + @"width" : (self.width ?: [NSNull null]), + @"height" : (self.height ?: [NSNull null]), + }; } @end @@ -451,16 +463,16 @@ + (instancetype)makeWithId:(nullable NSNumber *)id { pigeonResult.id = id; return pigeonResult; } -+ (UnregisterTextureMessage *)fromList:(NSArray *)list { ++ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict { UnregisterTextureMessage *pigeonResult = [[UnregisterTextureMessage alloc] init]; - pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.id = GetNullableObject(dict, @"id"); return pigeonResult; } -+ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UnregisterTextureMessage fromList:list] : nil; } -- (NSArray *)toList { - return @[ - (self.id ?: [NSNull null]), - ]; ++ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UnregisterTextureMessage fromMap:dict] : nil; } +- (NSDictionary *)toMap { + return @{ + @"id" : (self.id ?: [NSNull null]), + }; } @end @@ -471,40 +483,40 @@ - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 128: - return [GetPageMessage fromList:[self readValue]]; + return [GetPageMessage fromMap:[self readValue]]; case 129: - return [GetPageReply fromList:[self readValue]]; + return [GetPageReply fromMap:[self readValue]]; case 130: - return [IdMessage fromList:[self readValue]]; + return [IdMessage fromMap:[self readValue]]; case 131: - return [OpenDataMessage fromList:[self readValue]]; + return [OpenDataMessage fromMap:[self readValue]]; case 132: - return [OpenPathMessage fromList:[self readValue]]; + return [OpenPathMessage fromMap:[self readValue]]; case 133: - return [OpenReply fromList:[self readValue]]; + return [OpenReply fromMap:[self readValue]]; case 134: - return [RegisterTextureReply fromList:[self readValue]]; + return [RegisterTextureReply fromMap:[self readValue]]; case 135: - return [RenderPageMessage fromList:[self readValue]]; + return [RenderPageMessage fromMap:[self readValue]]; case 136: - return [RenderPageReply fromList:[self readValue]]; + return [RenderPageReply fromMap:[self readValue]]; case 137: - return [ResizeTextureMessage fromList:[self readValue]]; + return [ResizeTextureMessage fromMap:[self readValue]]; case 138: - return [UnregisterTextureMessage fromList:[self readValue]]; + return [UnregisterTextureMessage fromMap:[self readValue]]; case 139: - return [UpdateTextureMessage fromList:[self readValue]]; + return [UpdateTextureMessage fromMap:[self readValue]]; default: return [super readValueOfType:type]; @@ -520,51 +532,51 @@ - (void)writeValue:(id)value { if ([value isKindOfClass:[GetPageMessage class]]) { [self writeByte:128]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[GetPageReply class]]) { [self writeByte:129]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[IdMessage class]]) { [self writeByte:130]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[OpenDataMessage class]]) { [self writeByte:131]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[OpenPathMessage class]]) { [self writeByte:132]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[OpenReply class]]) { [self writeByte:133]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[RegisterTextureReply class]]) { [self writeByte:134]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[RenderPageMessage class]]) { [self writeByte:135]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[RenderPageReply class]]) { [self writeByte:136]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[ResizeTextureMessage class]]) { [self writeByte:137]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[UnregisterTextureMessage class]]) { [self writeByte:138]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else if ([value isKindOfClass:[UpdateTextureMessage class]]) { [self writeByte:139]; - [self writeValue:[value toList]]; + [self writeValue:[value toMap]]; } else { [super writeValue:value]; @@ -583,10 +595,9 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { } @end - -NSObject *PdfxApiGetCodec() { - static FlutterStandardMessageCodec *sSharedObject = nil; +NSObject *PdfxApiGetCodec(void) { static dispatch_once_t sPred = 0; + static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ PdfxApiCodecReaderWriter *readerWriter = [[PdfxApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; @@ -594,13 +605,14 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { return sSharedObject; } + void PdfxApiSetup(id binaryMessenger, NSObject *api) { { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentData" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentDataMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentDataMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -620,7 +632,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentFile" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentFileMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentFileMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -640,7 +652,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentAsset" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentAssetMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentAssetMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -660,7 +672,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.closeDocument" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(closeDocumentMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closeDocumentMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -680,7 +692,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.getPage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(getPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(getPageMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -700,7 +712,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.renderPage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(renderPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(renderPageMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -720,7 +732,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.closePage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(closePageMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closePageMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -740,7 +752,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.registerTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(registerTextureWithError:)], @"PdfxApi api (%@) doesn't respond to @selector(registerTextureWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -758,7 +770,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.updateTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(updateTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(updateTextureMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -778,7 +790,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.resizeTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(resizeTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(resizeTextureMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -798,7 +810,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.unregisterTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec()]; + codec:PdfxApiGetCodec() ]; if (api) { NSCAssert([api respondsToSelector:@selector(unregisterTextureMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(unregisterTextureMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { diff --git a/packages/pdfx/lib/src/renderer/io/pigeon.dart b/packages/pdfx/lib/src/renderer/io/pigeon.dart index 4295e383..8b7ce8ff 100644 --- a/packages/pdfx/lib/src/renderer/io/pigeon.dart +++ b/packages/pdfx/lib/src/renderer/io/pigeon.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.14), do not edit directly. +// Autogenerated from Pigeon (v4.2.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import import 'dart:async'; @@ -14,21 +14,20 @@ class OpenDataMessage { }); Uint8List? data; - String? password; Object encode() { - return [ - data, - password, - ]; + final Map pigeonMap = {}; + pigeonMap['data'] = data; + pigeonMap['password'] = password; + return pigeonMap; } - static OpenDataMessage decode(Object result) { - result as List; + static OpenDataMessage decode(Object message) { + final Map pigeonMap = message as Map; return OpenDataMessage( - data: result[0] as Uint8List?, - password: result[1] as String?, + data: pigeonMap['data'] as Uint8List?, + password: pigeonMap['password'] as String?, ); } } @@ -40,21 +39,20 @@ class OpenPathMessage { }); String? path; - String? password; Object encode() { - return [ - path, - password, - ]; + final Map pigeonMap = {}; + pigeonMap['path'] = path; + pigeonMap['password'] = password; + return pigeonMap; } - static OpenPathMessage decode(Object result) { - result as List; + static OpenPathMessage decode(Object message) { + final Map pigeonMap = message as Map; return OpenPathMessage( - path: result[0] as String?, - password: result[1] as String?, + path: pigeonMap['path'] as String?, + password: pigeonMap['password'] as String?, ); } } @@ -66,21 +64,20 @@ class OpenReply { }); String? id; - int? pagesCount; Object encode() { - return [ - id, - pagesCount, - ]; + final Map pigeonMap = {}; + pigeonMap['id'] = id; + pigeonMap['pagesCount'] = pagesCount; + return pigeonMap; } - static OpenReply decode(Object result) { - result as List; + static OpenReply decode(Object message) { + final Map pigeonMap = message as Map; return OpenReply( - id: result[0] as String?, - pagesCount: result[1] as int?, + id: pigeonMap['id'] as String?, + pagesCount: pigeonMap['pagesCount'] as int?, ); } } @@ -93,15 +90,15 @@ class IdMessage { String? id; Object encode() { - return [ - id, - ]; + final Map pigeonMap = {}; + pigeonMap['id'] = id; + return pigeonMap; } - static IdMessage decode(Object result) { - result as List; + static IdMessage decode(Object message) { + final Map pigeonMap = message as Map; return IdMessage( - id: result[0] as String?, + id: pigeonMap['id'] as String?, ); } } @@ -114,25 +111,23 @@ class GetPageMessage { }); String? documentId; - int? pageNumber; - bool? autoCloseAndroid; Object encode() { - return [ - documentId, - pageNumber, - autoCloseAndroid, - ]; + final Map pigeonMap = {}; + pigeonMap['documentId'] = documentId; + pigeonMap['pageNumber'] = pageNumber; + pigeonMap['autoCloseAndroid'] = autoCloseAndroid; + return pigeonMap; } - static GetPageMessage decode(Object result) { - result as List; + static GetPageMessage decode(Object message) { + final Map pigeonMap = message as Map; return GetPageMessage( - documentId: result[0] as String?, - pageNumber: result[1] as int?, - autoCloseAndroid: result[2] as bool?, + documentId: pigeonMap['documentId'] as String?, + pageNumber: pigeonMap['pageNumber'] as int?, + autoCloseAndroid: pigeonMap['autoCloseAndroid'] as bool?, ); } } @@ -145,25 +140,23 @@ class GetPageReply { }); String? id; - double? width; - double? height; Object encode() { - return [ - id, - width, - height, - ]; + final Map pigeonMap = {}; + pigeonMap['id'] = id; + pigeonMap['width'] = width; + pigeonMap['height'] = height; + return pigeonMap; } - static GetPageReply decode(Object result) { - result as List; + static GetPageReply decode(Object message) { + final Map pigeonMap = message as Map; return GetPageReply( - id: result[0] as String?, - width: result[1] as double?, - height: result[2] as double?, + id: pigeonMap['id'] as String?, + width: pigeonMap['width'] as double?, + height: pigeonMap['height'] as double?, ); } } @@ -185,61 +178,50 @@ class RenderPageMessage { }); String? pageId; - int? width; - int? height; - int? format; - String? backgroundColor; - bool? crop; - int? cropX; - int? cropY; - int? cropHeight; - int? cropWidth; - int? quality; - bool? forPrint; Object encode() { - return [ - pageId, - width, - height, - format, - backgroundColor, - crop, - cropX, - cropY, - cropHeight, - cropWidth, - quality, - forPrint, - ]; - } - - static RenderPageMessage decode(Object result) { - result as List; + final Map pigeonMap = {}; + pigeonMap['pageId'] = pageId; + pigeonMap['width'] = width; + pigeonMap['height'] = height; + pigeonMap['format'] = format; + pigeonMap['backgroundColor'] = backgroundColor; + pigeonMap['crop'] = crop; + pigeonMap['cropX'] = cropX; + pigeonMap['cropY'] = cropY; + pigeonMap['cropHeight'] = cropHeight; + pigeonMap['cropWidth'] = cropWidth; + pigeonMap['quality'] = quality; + pigeonMap['forPrint'] = forPrint; + return pigeonMap; + } + + static RenderPageMessage decode(Object message) { + final Map pigeonMap = message as Map; return RenderPageMessage( - pageId: result[0] as String?, - width: result[1] as int?, - height: result[2] as int?, - format: result[3] as int?, - backgroundColor: result[4] as String?, - crop: result[5] as bool?, - cropX: result[6] as int?, - cropY: result[7] as int?, - cropHeight: result[8] as int?, - cropWidth: result[9] as int?, - quality: result[10] as int?, - forPrint: result[11] as bool?, + pageId: pigeonMap['pageId'] as String?, + width: pigeonMap['width'] as int?, + height: pigeonMap['height'] as int?, + format: pigeonMap['format'] as int?, + backgroundColor: pigeonMap['backgroundColor'] as String?, + crop: pigeonMap['crop'] as bool?, + cropX: pigeonMap['cropX'] as int?, + cropY: pigeonMap['cropY'] as int?, + cropHeight: pigeonMap['cropHeight'] as int?, + cropWidth: pigeonMap['cropWidth'] as int?, + quality: pigeonMap['quality'] as int?, + forPrint: pigeonMap['forPrint'] as bool?, ); } } @@ -253,29 +235,26 @@ class RenderPageReply { }); int? width; - int? height; - String? path; - Uint8List? data; Object encode() { - return [ - width, - height, - path, - data, - ]; + final Map pigeonMap = {}; + pigeonMap['width'] = width; + pigeonMap['height'] = height; + pigeonMap['path'] = path; + pigeonMap['data'] = data; + return pigeonMap; } - static RenderPageReply decode(Object result) { - result as List; + static RenderPageReply decode(Object message) { + final Map pigeonMap = message as Map; return RenderPageReply( - width: result[0] as int?, - height: result[1] as int?, - path: result[2] as String?, - data: result[3] as Uint8List?, + width: pigeonMap['width'] as int?, + height: pigeonMap['height'] as int?, + path: pigeonMap['path'] as String?, + data: pigeonMap['data'] as Uint8List?, ); } } @@ -288,15 +267,15 @@ class RegisterTextureReply { int? id; Object encode() { - return [ - id, - ]; + final Map pigeonMap = {}; + pigeonMap['id'] = id; + return pigeonMap; } - static RegisterTextureReply decode(Object result) { - result as List; + static RegisterTextureReply decode(Object message) { + final Map pigeonMap = message as Map; return RegisterTextureReply( - id: result[0] as int?, + id: pigeonMap['id'] as int?, ); } } @@ -322,77 +301,62 @@ class UpdateTextureMessage { }); String? documentId; - int? pageNumber; - String? pageId; - int? textureId; - int? width; - int? height; - String? backgroundColor; - int? sourceX; - int? sourceY; - int? destinationX; - int? destinationY; - double? fullWidth; - double? fullHeight; - int? textureWidth; - int? textureHeight; - bool? allowAntiAliasing; Object encode() { - return [ - documentId, - pageNumber, - pageId, - textureId, - width, - height, - backgroundColor, - sourceX, - sourceY, - destinationX, - destinationY, - fullWidth, - fullHeight, - textureWidth, - textureHeight, - allowAntiAliasing, - ]; - } - - static UpdateTextureMessage decode(Object result) { - result as List; + final Map pigeonMap = {}; + pigeonMap['documentId'] = documentId; + pigeonMap['pageNumber'] = pageNumber; + pigeonMap['pageId'] = pageId; + pigeonMap['textureId'] = textureId; + pigeonMap['width'] = width; + pigeonMap['height'] = height; + pigeonMap['backgroundColor'] = backgroundColor; + pigeonMap['sourceX'] = sourceX; + pigeonMap['sourceY'] = sourceY; + pigeonMap['destinationX'] = destinationX; + pigeonMap['destinationY'] = destinationY; + pigeonMap['fullWidth'] = fullWidth; + pigeonMap['fullHeight'] = fullHeight; + pigeonMap['textureWidth'] = textureWidth; + pigeonMap['textureHeight'] = textureHeight; + pigeonMap['allowAntiAliasing'] = allowAntiAliasing; + return pigeonMap; + } + + static UpdateTextureMessage decode(Object message) { + final Map pigeonMap = message as Map; return UpdateTextureMessage( - documentId: result[0] as String?, - pageNumber: result[1] as int?, - pageId: result[2] as String?, - textureId: result[3] as int?, - width: result[4] as int?, - height: result[5] as int?, - backgroundColor: result[6] as String?, - sourceX: result[7] as int?, - sourceY: result[8] as int?, - destinationX: result[9] as int?, - destinationY: result[10] as int?, - fullWidth: result[11] as double?, - fullHeight: result[12] as double?, - textureWidth: result[13] as int?, - textureHeight: result[14] as int?, - allowAntiAliasing: result[15] as bool?, + documentId: pigeonMap['documentId'] as String?, + pageNumber: pigeonMap['pageNumber'] as int?, + pageId: pigeonMap['pageId'] as String?, + textureId: pigeonMap['textureId'] as int?, + width: pigeonMap['width'] as int?, + height: pigeonMap['height'] as int?, + backgroundColor: pigeonMap['backgroundColor'] as String?, + sourceX: pigeonMap['sourceX'] as int?, + sourceY: pigeonMap['sourceY'] as int?, + destinationX: pigeonMap['destinationX'] as int?, + destinationY: pigeonMap['destinationY'] as int?, + fullWidth: pigeonMap['fullWidth'] as double?, + fullHeight: pigeonMap['fullHeight'] as double?, + textureWidth: pigeonMap['textureWidth'] as int?, + textureHeight: pigeonMap['textureHeight'] as int?, + allowAntiAliasing: pigeonMap['allowAntiAliasing'] as bool?, ); } } @@ -405,25 +369,23 @@ class ResizeTextureMessage { }); int? textureId; - int? width; - int? height; Object encode() { - return [ - textureId, - width, - height, - ]; + final Map pigeonMap = {}; + pigeonMap['textureId'] = textureId; + pigeonMap['width'] = width; + pigeonMap['height'] = height; + return pigeonMap; } - static ResizeTextureMessage decode(Object result) { - result as List; + static ResizeTextureMessage decode(Object message) { + final Map pigeonMap = message as Map; return ResizeTextureMessage( - textureId: result[0] as int?, - width: result[1] as int?, - height: result[2] as int?, + textureId: pigeonMap['textureId'] as int?, + width: pigeonMap['width'] as int?, + height: pigeonMap['height'] as int?, ); } } @@ -436,15 +398,15 @@ class UnregisterTextureMessage { int? id; Object encode() { - return [ - id, - ]; + final Map pigeonMap = {}; + pigeonMap['id'] = id; + return pigeonMap; } - static UnregisterTextureMessage decode(Object result) { - result as List; + static UnregisterTextureMessage decode(Object message) { + final Map pigeonMap = message as Map; return UnregisterTextureMessage( - id: result[0] as int?, + id: pigeonMap['id'] as int?, ); } } @@ -456,44 +418,55 @@ class _PdfxApiCodec extends StandardMessageCodec { if (value is GetPageMessage) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value is GetPageReply) { + } else + if (value is GetPageReply) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is IdMessage) { + } else + if (value is IdMessage) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is OpenDataMessage) { + } else + if (value is OpenDataMessage) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is OpenPathMessage) { + } else + if (value is OpenPathMessage) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is OpenReply) { + } else + if (value is OpenReply) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is RegisterTextureReply) { + } else + if (value is RegisterTextureReply) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is RenderPageMessage) { + } else + if (value is RenderPageMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is RenderPageReply) { + } else + if (value is RenderPageReply) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is ResizeTextureMessage) { + } else + if (value is ResizeTextureMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is UnregisterTextureMessage) { + } else + if (value is UnregisterTextureMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is UpdateTextureMessage) { + } else + if (value is UpdateTextureMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { @@ -533,8 +506,7 @@ class _PdfxApiCodec extends StandardMessageCodec { case 139: return UpdateTextureMessage.decode(readValue(buffer)!); - default: - + default: return super.readValueOfType(type, buffer); } @@ -551,109 +523,109 @@ class PdfxApi { /// Constructor for [PdfxApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - PdfxApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + PdfxApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _PdfxApiCodec(); Future openDocumentData(OpenDataMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentData', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentData', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); - } else if (replyList[0] == null) { + } else if (replyMap['result'] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyList[0] as OpenReply?)!; + return (replyMap['result'] as OpenReply?)!; } } Future openDocumentFile(OpenPathMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentFile', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentFile', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); - } else if (replyList[0] == null) { + } else if (replyMap['result'] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyList[0] as OpenReply?)!; + return (replyMap['result'] as OpenReply?)!; } } Future openDocumentAsset(OpenPathMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentAsset', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentAsset', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); - } else if (replyList[0] == null) { + } else if (replyMap['result'] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyList[0] as OpenReply?)!; + return (replyMap['result'] as OpenReply?)!; } } Future closeDocument(IdMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.closeDocument', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.closeDocument', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); } else { return; @@ -662,74 +634,74 @@ class PdfxApi { Future getPage(GetPageMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.getPage', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.getPage', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); - } else if (replyList[0] == null) { + } else if (replyMap['result'] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyList[0] as GetPageReply?)!; + return (replyMap['result'] as GetPageReply?)!; } } Future renderPage(RenderPageMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.renderPage', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.renderPage', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); - } else if (replyList[0] == null) { + } else if (replyMap['result'] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyList[0] as RenderPageReply?)!; + return (replyMap['result'] as RenderPageReply?)!; } } Future closePage(IdMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.closePage', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.closePage', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); } else { return; @@ -738,47 +710,47 @@ class PdfxApi { Future registerTexture() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.registerTexture', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.registerTexture', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send(null) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); - } else if (replyList[0] == null) { + } else if (replyMap['result'] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyList[0] as RegisterTextureReply?)!; + return (replyMap['result'] as RegisterTextureReply?)!; } } Future updateTexture(UpdateTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.updateTexture', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.updateTexture', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); } else { return; @@ -787,20 +759,20 @@ class PdfxApi { Future resizeTexture(ResizeTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.resizeTexture', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.resizeTexture', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); } else { return; @@ -809,20 +781,20 @@ class PdfxApi { Future unregisterTexture(UnregisterTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.unregisterTexture', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_message]) as List?; - if (replyList == null) { + 'dev.flutter.pigeon.PdfxApi.unregisterTexture', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_message]) as Map?; + if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyList.length > 1) { + } else if (replyMap['error'] != null) { + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], ); } else { return; diff --git a/packages/pdfx/pigeons/messages.dart b/packages/pdfx/pigeons/messages.dart index 786088b5..5c94f824 100644 --- a/packages/pdfx/pigeons/messages.dart +++ b/packages/pdfx/pigeons/messages.dart @@ -4,7 +4,6 @@ import 'package:pigeon/pigeon.dart'; dartOut: 'lib/src/renderer/io/pigeon.dart', objcHeaderOut: './ios/Classes/messages.h', objcSourceOut: './ios/Classes/messages.m', - swiftOut: './ios/pdfx/Sources/pdfx/Messages.g.swift', javaOut: './android/src/main/java/dev/flutter/pigeon/Pigeon.java', javaOptions: JavaOptions( package: 'dev.flutter.pigeon', From d4953f1eeb4d168e0d5b41606c90a467f6d1c602 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Tue, 7 Apr 2026 10:06:37 +0200 Subject: [PATCH 10/11] ESA-42 rollback --- .../main/java/dev/flutter/pigeon/Pigeon.java | 491 +++++++------- packages/pdfx/ios/Classes/messages.h | 4 +- packages/pdfx/ios/Classes/messages.m | 488 +++++++------- packages/pdfx/lib/src/renderer/io/pigeon.dart | 610 +++++++++--------- 4 files changed, 811 insertions(+), 782 deletions(-) diff --git a/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java b/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java index 53ad753f..e7e26b74 100644 --- a/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java +++ b/packages/pdfx/android/src/main/java/dev/flutter/pigeon/Pigeon.java @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon package dev.flutter.pigeon; @@ -14,11 +14,12 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.HashMap; -/**Generated class from Pigeon. */ +/** Generated class from Pigeon. */ @SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) public class Pigeon { @@ -54,17 +55,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("data", data); - toMapResult.put("password", password); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(2); + toListResult.add(data); + toListResult.add(password); + return toListResult; } - static @NonNull OpenDataMessage fromMap(@NonNull Map map) { + static @NonNull OpenDataMessage fromList(@NonNull ArrayList list) { OpenDataMessage pigeonResult = new OpenDataMessage(); - Object data = map.get("data"); + Object data = list.get(0); pigeonResult.setData((byte[])data); - Object password = map.get("password"); + Object password = list.get(1); pigeonResult.setPassword((String)password); return pigeonResult; } @@ -102,17 +103,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("path", path); - toMapResult.put("password", password); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(2); + toListResult.add(path); + toListResult.add(password); + return toListResult; } - static @NonNull OpenPathMessage fromMap(@NonNull Map map) { + static @NonNull OpenPathMessage fromList(@NonNull ArrayList list) { OpenPathMessage pigeonResult = new OpenPathMessage(); - Object path = map.get("path"); + Object path = list.get(0); pigeonResult.setPath((String)path); - Object password = map.get("password"); + Object password = list.get(1); pigeonResult.setPassword((String)password); return pigeonResult; } @@ -150,17 +151,17 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - toMapResult.put("pagesCount", pagesCount); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(2); + toListResult.add(id); + toListResult.add(pagesCount); + return toListResult; } - static @NonNull OpenReply fromMap(@NonNull Map map) { + static @NonNull OpenReply fromList(@NonNull ArrayList list) { OpenReply pigeonResult = new OpenReply(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((String)id); - Object pagesCount = map.get("pagesCount"); + Object pagesCount = list.get(1); pigeonResult.setPagesCount((pagesCount == null) ? null : ((pagesCount instanceof Integer) ? (Integer)pagesCount : (Long)pagesCount)); return pigeonResult; } @@ -186,14 +187,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(1); + toListResult.add(id); + return toListResult; } - static @NonNull IdMessage fromMap(@NonNull Map map) { + static @NonNull IdMessage fromList(@NonNull ArrayList list) { IdMessage pigeonResult = new IdMessage(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((String)id); return pigeonResult; } @@ -243,20 +244,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("documentId", documentId); - toMapResult.put("pageNumber", pageNumber); - toMapResult.put("autoCloseAndroid", autoCloseAndroid); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(3); + toListResult.add(documentId); + toListResult.add(pageNumber); + toListResult.add(autoCloseAndroid); + return toListResult; } - static @NonNull GetPageMessage fromMap(@NonNull Map map) { + static @NonNull GetPageMessage fromList(@NonNull ArrayList list) { GetPageMessage pigeonResult = new GetPageMessage(); - Object documentId = map.get("documentId"); + Object documentId = list.get(0); pigeonResult.setDocumentId((String)documentId); - Object pageNumber = map.get("pageNumber"); + Object pageNumber = list.get(1); pigeonResult.setPageNumber((pageNumber == null) ? null : ((pageNumber instanceof Integer) ? (Integer)pageNumber : (Long)pageNumber)); - Object autoCloseAndroid = map.get("autoCloseAndroid"); + Object autoCloseAndroid = list.get(2); pigeonResult.setAutoCloseAndroid((Boolean)autoCloseAndroid); return pigeonResult; } @@ -306,20 +307,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - toMapResult.put("width", width); - toMapResult.put("height", height); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(3); + toListResult.add(id); + toListResult.add(width); + toListResult.add(height); + return toListResult; } - static @NonNull GetPageReply fromMap(@NonNull Map map) { + static @NonNull GetPageReply fromList(@NonNull ArrayList list) { GetPageReply pigeonResult = new GetPageReply(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((String)id); - Object width = map.get("width"); + Object width = list.get(1); pigeonResult.setWidth((Double)width); - Object height = map.get("height"); + Object height = list.get(2); pigeonResult.setHeight((Double)height); return pigeonResult; } @@ -477,47 +478,47 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("pageId", pageId); - toMapResult.put("width", width); - toMapResult.put("height", height); - toMapResult.put("format", format); - toMapResult.put("backgroundColor", backgroundColor); - toMapResult.put("crop", crop); - toMapResult.put("cropX", cropX); - toMapResult.put("cropY", cropY); - toMapResult.put("cropHeight", cropHeight); - toMapResult.put("cropWidth", cropWidth); - toMapResult.put("quality", quality); - toMapResult.put("forPrint", forPrint); - return toMapResult; - } - static @NonNull RenderPageMessage fromMap(@NonNull Map map) { + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(12); + toListResult.add(pageId); + toListResult.add(width); + toListResult.add(height); + toListResult.add(format); + toListResult.add(backgroundColor); + toListResult.add(crop); + toListResult.add(cropX); + toListResult.add(cropY); + toListResult.add(cropHeight); + toListResult.add(cropWidth); + toListResult.add(quality); + toListResult.add(forPrint); + return toListResult; + } + static @NonNull RenderPageMessage fromList(@NonNull ArrayList list) { RenderPageMessage pigeonResult = new RenderPageMessage(); - Object pageId = map.get("pageId"); + Object pageId = list.get(0); pigeonResult.setPageId((String)pageId); - Object width = map.get("width"); + Object width = list.get(1); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = map.get("height"); + Object height = list.get(2); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object format = map.get("format"); + Object format = list.get(3); pigeonResult.setFormat((format == null) ? null : ((format instanceof Integer) ? (Integer)format : (Long)format)); - Object backgroundColor = map.get("backgroundColor"); + Object backgroundColor = list.get(4); pigeonResult.setBackgroundColor((String)backgroundColor); - Object crop = map.get("crop"); + Object crop = list.get(5); pigeonResult.setCrop((Boolean)crop); - Object cropX = map.get("cropX"); + Object cropX = list.get(6); pigeonResult.setCropX((cropX == null) ? null : ((cropX instanceof Integer) ? (Integer)cropX : (Long)cropX)); - Object cropY = map.get("cropY"); + Object cropY = list.get(7); pigeonResult.setCropY((cropY == null) ? null : ((cropY instanceof Integer) ? (Integer)cropY : (Long)cropY)); - Object cropHeight = map.get("cropHeight"); + Object cropHeight = list.get(8); pigeonResult.setCropHeight((cropHeight == null) ? null : ((cropHeight instanceof Integer) ? (Integer)cropHeight : (Long)cropHeight)); - Object cropWidth = map.get("cropWidth"); + Object cropWidth = list.get(9); pigeonResult.setCropWidth((cropWidth == null) ? null : ((cropWidth instanceof Integer) ? (Integer)cropWidth : (Long)cropWidth)); - Object quality = map.get("quality"); + Object quality = list.get(10); pigeonResult.setQuality((quality == null) ? null : ((quality instanceof Integer) ? (Integer)quality : (Long)quality)); - Object forPrint = map.get("forPrint"); + Object forPrint = list.get(11); pigeonResult.setForPrint((Boolean)forPrint); return pigeonResult; } @@ -579,23 +580,23 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("width", width); - toMapResult.put("height", height); - toMapResult.put("path", path); - toMapResult.put("data", data); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(4); + toListResult.add(width); + toListResult.add(height); + toListResult.add(path); + toListResult.add(data); + return toListResult; } - static @NonNull RenderPageReply fromMap(@NonNull Map map) { + static @NonNull RenderPageReply fromList(@NonNull ArrayList list) { RenderPageReply pigeonResult = new RenderPageReply(); - Object width = map.get("width"); + Object width = list.get(0); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = map.get("height"); + Object height = list.get(1); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object path = map.get("path"); + Object path = list.get(2); pigeonResult.setPath((String)path); - Object data = map.get("data"); + Object data = list.get(3); pigeonResult.setData((byte[])data); return pigeonResult; } @@ -621,14 +622,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(1); + toListResult.add(id); + return toListResult; } - static @NonNull RegisterTextureReply fromMap(@NonNull Map map) { + static @NonNull RegisterTextureReply fromList(@NonNull ArrayList list) { RegisterTextureReply pigeonResult = new RegisterTextureReply(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((id == null) ? null : ((id instanceof Integer) ? (Integer)id : (Long)id)); return pigeonResult; } @@ -834,59 +835,59 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("documentId", documentId); - toMapResult.put("pageNumber", pageNumber); - toMapResult.put("pageId", pageId); - toMapResult.put("textureId", textureId); - toMapResult.put("width", width); - toMapResult.put("height", height); - toMapResult.put("backgroundColor", backgroundColor); - toMapResult.put("sourceX", sourceX); - toMapResult.put("sourceY", sourceY); - toMapResult.put("destinationX", destinationX); - toMapResult.put("destinationY", destinationY); - toMapResult.put("fullWidth", fullWidth); - toMapResult.put("fullHeight", fullHeight); - toMapResult.put("textureWidth", textureWidth); - toMapResult.put("textureHeight", textureHeight); - toMapResult.put("allowAntiAliasing", allowAntiAliasing); - return toMapResult; - } - static @NonNull UpdateTextureMessage fromMap(@NonNull Map map) { + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(16); + toListResult.add(documentId); + toListResult.add(pageNumber); + toListResult.add(pageId); + toListResult.add(textureId); + toListResult.add(width); + toListResult.add(height); + toListResult.add(backgroundColor); + toListResult.add(sourceX); + toListResult.add(sourceY); + toListResult.add(destinationX); + toListResult.add(destinationY); + toListResult.add(fullWidth); + toListResult.add(fullHeight); + toListResult.add(textureWidth); + toListResult.add(textureHeight); + toListResult.add(allowAntiAliasing); + return toListResult; + } + static @NonNull UpdateTextureMessage fromList(@NonNull ArrayList list) { UpdateTextureMessage pigeonResult = new UpdateTextureMessage(); - Object documentId = map.get("documentId"); + Object documentId = list.get(0); pigeonResult.setDocumentId((String)documentId); - Object pageNumber = map.get("pageNumber"); + Object pageNumber = list.get(1); pigeonResult.setPageNumber((pageNumber == null) ? null : ((pageNumber instanceof Integer) ? (Integer)pageNumber : (Long)pageNumber)); - Object pageId = map.get("pageId"); + Object pageId = list.get(2); pigeonResult.setPageId((String)pageId); - Object textureId = map.get("textureId"); + Object textureId = list.get(3); pigeonResult.setTextureId((textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId)); - Object width = map.get("width"); + Object width = list.get(4); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = map.get("height"); + Object height = list.get(5); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); - Object backgroundColor = map.get("backgroundColor"); + Object backgroundColor = list.get(6); pigeonResult.setBackgroundColor((String)backgroundColor); - Object sourceX = map.get("sourceX"); + Object sourceX = list.get(7); pigeonResult.setSourceX((sourceX == null) ? null : ((sourceX instanceof Integer) ? (Integer)sourceX : (Long)sourceX)); - Object sourceY = map.get("sourceY"); + Object sourceY = list.get(8); pigeonResult.setSourceY((sourceY == null) ? null : ((sourceY instanceof Integer) ? (Integer)sourceY : (Long)sourceY)); - Object destinationX = map.get("destinationX"); + Object destinationX = list.get(9); pigeonResult.setDestinationX((destinationX == null) ? null : ((destinationX instanceof Integer) ? (Integer)destinationX : (Long)destinationX)); - Object destinationY = map.get("destinationY"); + Object destinationY = list.get(10); pigeonResult.setDestinationY((destinationY == null) ? null : ((destinationY instanceof Integer) ? (Integer)destinationY : (Long)destinationY)); - Object fullWidth = map.get("fullWidth"); + Object fullWidth = list.get(11); pigeonResult.setFullWidth((Double)fullWidth); - Object fullHeight = map.get("fullHeight"); + Object fullHeight = list.get(12); pigeonResult.setFullHeight((Double)fullHeight); - Object textureWidth = map.get("textureWidth"); + Object textureWidth = list.get(13); pigeonResult.setTextureWidth((textureWidth == null) ? null : ((textureWidth instanceof Integer) ? (Integer)textureWidth : (Long)textureWidth)); - Object textureHeight = map.get("textureHeight"); + Object textureHeight = list.get(14); pigeonResult.setTextureHeight((textureHeight == null) ? null : ((textureHeight instanceof Integer) ? (Integer)textureHeight : (Long)textureHeight)); - Object allowAntiAliasing = map.get("allowAntiAliasing"); + Object allowAntiAliasing = list.get(15); pigeonResult.setAllowAntiAliasing((Boolean)allowAntiAliasing); return pigeonResult; } @@ -936,20 +937,20 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("textureId", textureId); - toMapResult.put("width", width); - toMapResult.put("height", height); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(3); + toListResult.add(textureId); + toListResult.add(width); + toListResult.add(height); + return toListResult; } - static @NonNull ResizeTextureMessage fromMap(@NonNull Map map) { + static @NonNull ResizeTextureMessage fromList(@NonNull ArrayList list) { ResizeTextureMessage pigeonResult = new ResizeTextureMessage(); - Object textureId = map.get("textureId"); + Object textureId = list.get(0); pigeonResult.setTextureId((textureId == null) ? null : ((textureId instanceof Integer) ? (Integer)textureId : (Long)textureId)); - Object width = map.get("width"); + Object width = list.get(1); pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer)width : (Long)width)); - Object height = map.get("height"); + Object height = list.get(2); pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer)height : (Long)height)); return pigeonResult; } @@ -975,14 +976,14 @@ public static final class Builder { return pigeonReturn; } } - @NonNull Map toMap() { - Map toMapResult = new HashMap<>(); - toMapResult.put("id", id); - return toMapResult; + @NonNull ArrayList toList() { + ArrayList toListResult = new ArrayList(1); + toListResult.add(id); + return toListResult; } - static @NonNull UnregisterTextureMessage fromMap(@NonNull Map map) { + static @NonNull UnregisterTextureMessage fromList(@NonNull ArrayList list) { UnregisterTextureMessage pigeonResult = new UnregisterTextureMessage(); - Object id = map.get("id"); + Object id = list.get(0); pigeonResult.setId((id == null) ? null : ((id instanceof Integer) ? (Integer)id : (Long)id)); return pigeonResult; } @@ -999,40 +1000,40 @@ private PdfxApiCodec() {} protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { switch (type) { case (byte)128: - return GetPageMessage.fromMap((Map) readValue(buffer)); + return GetPageMessage.fromList((ArrayList) readValue(buffer)); case (byte)129: - return GetPageReply.fromMap((Map) readValue(buffer)); + return GetPageReply.fromList((ArrayList) readValue(buffer)); case (byte)130: - return IdMessage.fromMap((Map) readValue(buffer)); + return IdMessage.fromList((ArrayList) readValue(buffer)); case (byte)131: - return OpenDataMessage.fromMap((Map) readValue(buffer)); + return OpenDataMessage.fromList((ArrayList) readValue(buffer)); case (byte)132: - return OpenPathMessage.fromMap((Map) readValue(buffer)); + return OpenPathMessage.fromList((ArrayList) readValue(buffer)); case (byte)133: - return OpenReply.fromMap((Map) readValue(buffer)); + return OpenReply.fromList((ArrayList) readValue(buffer)); case (byte)134: - return RegisterTextureReply.fromMap((Map) readValue(buffer)); + return RegisterTextureReply.fromList((ArrayList) readValue(buffer)); case (byte)135: - return RenderPageMessage.fromMap((Map) readValue(buffer)); + return RenderPageMessage.fromList((ArrayList) readValue(buffer)); case (byte)136: - return RenderPageReply.fromMap((Map) readValue(buffer)); + return RenderPageReply.fromList((ArrayList) readValue(buffer)); case (byte)137: - return ResizeTextureMessage.fromMap((Map) readValue(buffer)); + return ResizeTextureMessage.fromList((ArrayList) readValue(buffer)); case (byte)138: - return UnregisterTextureMessage.fromMap((Map) readValue(buffer)); + return UnregisterTextureMessage.fromList((ArrayList) readValue(buffer)); case (byte)139: - return UpdateTextureMessage.fromMap((Map) readValue(buffer)); + return UpdateTextureMessage.fromList((ArrayList) readValue(buffer)); default: return super.readValueOfType(type, buffer); @@ -1043,51 +1044,51 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { if (value instanceof GetPageMessage) { stream.write(128); - writeValue(stream, ((GetPageMessage) value).toMap()); + writeValue(stream, ((GetPageMessage) value).toList()); } else if (value instanceof GetPageReply) { stream.write(129); - writeValue(stream, ((GetPageReply) value).toMap()); + writeValue(stream, ((GetPageReply) value).toList()); } else if (value instanceof IdMessage) { stream.write(130); - writeValue(stream, ((IdMessage) value).toMap()); + writeValue(stream, ((IdMessage) value).toList()); } else if (value instanceof OpenDataMessage) { stream.write(131); - writeValue(stream, ((OpenDataMessage) value).toMap()); + writeValue(stream, ((OpenDataMessage) value).toList()); } else if (value instanceof OpenPathMessage) { stream.write(132); - writeValue(stream, ((OpenPathMessage) value).toMap()); + writeValue(stream, ((OpenPathMessage) value).toList()); } else if (value instanceof OpenReply) { stream.write(133); - writeValue(stream, ((OpenReply) value).toMap()); + writeValue(stream, ((OpenReply) value).toList()); } else if (value instanceof RegisterTextureReply) { stream.write(134); - writeValue(stream, ((RegisterTextureReply) value).toMap()); + writeValue(stream, ((RegisterTextureReply) value).toList()); } else if (value instanceof RenderPageMessage) { stream.write(135); - writeValue(stream, ((RenderPageMessage) value).toMap()); + writeValue(stream, ((RenderPageMessage) value).toList()); } else if (value instanceof RenderPageReply) { stream.write(136); - writeValue(stream, ((RenderPageReply) value).toMap()); + writeValue(stream, ((RenderPageReply) value).toList()); } else if (value instanceof ResizeTextureMessage) { stream.write(137); - writeValue(stream, ((ResizeTextureMessage) value).toMap()); + writeValue(stream, ((ResizeTextureMessage) value).toList()); } else if (value instanceof UnregisterTextureMessage) { stream.write(138); - writeValue(stream, ((UnregisterTextureMessage) value).toMap()); + writeValue(stream, ((UnregisterTextureMessage) value).toList()); } else if (value instanceof UpdateTextureMessage) { stream.write(139); - writeValue(stream, ((UpdateTextureMessage) value).toMap()); + writeValue(stream, ((UpdateTextureMessage) value).toList()); } else { super.writeValue(stream, value); @@ -1120,9 +1121,7 @@ public interface PdfxApi { /** The codec used by PdfxApi. */ static MessageCodec getCodec() { - return PdfxApiCodec.INSTANCE; - } - + return PdfxApiCodec.INSTANCE; } /**Sets up an instance of `PdfxApi` to handle messages through the `binaryMessenger`. */ static void setup(BinaryMessenger binaryMessenger, PdfxApi api) { { @@ -1130,29 +1129,30 @@ static void setup(BinaryMessenger binaryMessenger, PdfxApi api) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentData", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; OpenDataMessage messageArg = (OpenDataMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.openDocumentData(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1164,29 +1164,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentFile", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; OpenPathMessage messageArg = (OpenPathMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.openDocumentFile(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1198,29 +1199,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.openDocumentAsset", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; OpenPathMessage messageArg = (OpenPathMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(OpenReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.openDocumentAsset(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1232,18 +1234,20 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.closeDocument", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; IdMessage messageArg = (IdMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.closeDocument(messageArg); - wrapped.put("result", null); + wrapped.add(0, null); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; } reply.reply(wrapped); }); @@ -1256,29 +1260,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.getPage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; GetPageMessage messageArg = (GetPageMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(GetPageReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.getPage(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1290,29 +1295,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.renderPage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; RenderPageMessage messageArg = (RenderPageMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(RenderPageReply result) { - wrapped.put("result", result); + wrapped.add(0, result); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.renderPage(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1324,18 +1330,20 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.closePage", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; IdMessage messageArg = (IdMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.closePage(messageArg); - wrapped.put("result", null); + wrapped.add(0, null); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; } reply.reply(wrapped); }); @@ -1348,13 +1356,14 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.registerTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { RegisterTextureReply output = api.registerTexture(); - wrapped.put("result", output); + wrapped.add(0, output); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; } reply.reply(wrapped); }); @@ -1367,29 +1376,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.updateTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; UpdateTextureMessage messageArg = (UpdateTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(Void result) { - wrapped.put("result", null); + wrapped.add(0, null); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.updateTexture(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1401,29 +1411,30 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.resizeTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; ResizeTextureMessage messageArg = (ResizeTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } Result resultCallback = new Result() { public void success(Void result) { - wrapped.put("result", null); + wrapped.add(0, null); reply.reply(wrapped); } public void error(Throwable error) { - wrapped.put("error", wrapError(error)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); } }; api.resizeTexture(messageArg, resultCallback); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); - reply.reply(wrapped); + ArrayList wrappedError = wrapError(exception); + reply.reply(wrappedError); } }); } else { @@ -1435,18 +1446,20 @@ public void error(Throwable error) { new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.PdfxApi.unregisterTexture", getCodec()); if (api != null) { channel.setMessageHandler((message, reply) -> { - Map wrapped = new HashMap<>(); + ArrayList wrapped = new ArrayList<>(); try { ArrayList args = (ArrayList)message; + assert args != null; UnregisterTextureMessage messageArg = (UnregisterTextureMessage)args.get(0); if (messageArg == null) { throw new NullPointerException("messageArg unexpectedly null."); } api.unregisterTexture(messageArg); - wrapped.put("result", null); + wrapped.add(0, null); } catch (Error | RuntimeException exception) { - wrapped.put("error", wrapError(exception)); + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; } reply.reply(wrapped); }); @@ -1456,11 +1469,11 @@ public void error(Throwable error) { } } } - @NonNull private static Map wrapError(@NonNull Throwable exception) { - Map errorMap = new HashMap<>(); - errorMap.put("message", exception.toString()); - errorMap.put("code", exception.getClass().getSimpleName()); - errorMap.put("details", "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); - return errorMap; + @NonNull private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(3); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add("Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; } } diff --git a/packages/pdfx/ios/Classes/messages.h b/packages/pdfx/ios/Classes/messages.h index 5b0aef71..3d3134b5 100644 --- a/packages/pdfx/ios/Classes/messages.h +++ b/packages/pdfx/ios/Classes/messages.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @protocol FlutterBinaryMessenger; @@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong, nullable) NSNumber * id; @end -///The codec used by PdfxApi. +/// The codec used by PdfxApi. NSObject *PdfxApiGetCodec(void); /// Rebuild: `flutter pub run pigeon --input pigeons/message.dart` diff --git a/packages/pdfx/ios/Classes/messages.m b/packages/pdfx/ios/Classes/messages.m index 6070a468..c5d4bfab 100644 --- a/packages/pdfx/ios/Classes/messages.m +++ b/packages/pdfx/ios/Classes/messages.m @@ -1,29 +1,17 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.h" -#if TARGET_OS_IOS #import -#else -#import -#endif #if !__has_feature(objc_arc) #error File requires ARC to be enabled. #endif -static NSDictionary *wrapResult(id result, FlutterError *error) { - NSDictionary *errorDict = (NSDictionary *)[NSNull null]; +static NSArray *wrapResult(id result, FlutterError *error) { if (error) { - errorDict = @{ - @"code": (error.code ?: [NSNull null]), - @"message": (error.message ?: [NSNull null]), - @"details": (error.details ?: [NSNull null]), - }; + return @[ error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] ]; } - return @{ - @"result": (result ?: [NSNull null]), - @"error": errorDict, - }; + return @[ result ?: [NSNull null] ]; } static id GetNullableObject(NSDictionary* dict, id key) { id result = dict[key]; @@ -36,64 +24,64 @@ static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { @interface OpenDataMessage () -+ (OpenDataMessage *)fromMap:(NSDictionary *)dict; -+ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenDataMessage *)fromList:(NSArray *)list; ++ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface OpenPathMessage () -+ (OpenPathMessage *)fromMap:(NSDictionary *)dict; -+ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenPathMessage *)fromList:(NSArray *)list; ++ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface OpenReply () -+ (OpenReply *)fromMap:(NSDictionary *)dict; -+ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (OpenReply *)fromList:(NSArray *)list; ++ (nullable OpenReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface IdMessage () -+ (IdMessage *)fromMap:(NSDictionary *)dict; -+ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (IdMessage *)fromList:(NSArray *)list; ++ (nullable IdMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface GetPageMessage () -+ (GetPageMessage *)fromMap:(NSDictionary *)dict; -+ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (GetPageMessage *)fromList:(NSArray *)list; ++ (nullable GetPageMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface GetPageReply () -+ (GetPageReply *)fromMap:(NSDictionary *)dict; -+ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (GetPageReply *)fromList:(NSArray *)list; ++ (nullable GetPageReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RenderPageMessage () -+ (RenderPageMessage *)fromMap:(NSDictionary *)dict; -+ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RenderPageMessage *)fromList:(NSArray *)list; ++ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RenderPageReply () -+ (RenderPageReply *)fromMap:(NSDictionary *)dict; -+ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RenderPageReply *)fromList:(NSArray *)list; ++ (nullable RenderPageReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface RegisterTextureReply () -+ (RegisterTextureReply *)fromMap:(NSDictionary *)dict; -+ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (RegisterTextureReply *)fromList:(NSArray *)list; ++ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface UpdateTextureMessage () -+ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (UpdateTextureMessage *)fromList:(NSArray *)list; ++ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface ResizeTextureMessage () -+ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (ResizeTextureMessage *)fromList:(NSArray *)list; ++ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface UnregisterTextureMessage () -+ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict; -+ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (UnregisterTextureMessage *)fromList:(NSArray *)list; ++ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @implementation OpenDataMessage @@ -104,18 +92,18 @@ + (instancetype)makeWithData:(nullable FlutterStandardTypedData *)data pigeonResult.password = password; return pigeonResult; } -+ (OpenDataMessage *)fromMap:(NSDictionary *)dict { ++ (OpenDataMessage *)fromList:(NSArray *)list { OpenDataMessage *pigeonResult = [[OpenDataMessage alloc] init]; - pigeonResult.data = GetNullableObject(dict, @"data"); - pigeonResult.password = GetNullableObject(dict, @"password"); + pigeonResult.data = GetNullableObjectAtIndex(list, 0); + pigeonResult.password = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenDataMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenDataMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"data" : (self.data ?: [NSNull null]), - @"password" : (self.password ?: [NSNull null]), - }; ++ (nullable OpenDataMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenDataMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.data ?: [NSNull null]), + (self.password ?: [NSNull null]), + ]; } @end @@ -127,18 +115,18 @@ + (instancetype)makeWithPath:(nullable NSString *)path pigeonResult.password = password; return pigeonResult; } -+ (OpenPathMessage *)fromMap:(NSDictionary *)dict { ++ (OpenPathMessage *)fromList:(NSArray *)list { OpenPathMessage *pigeonResult = [[OpenPathMessage alloc] init]; - pigeonResult.path = GetNullableObject(dict, @"path"); - pigeonResult.password = GetNullableObject(dict, @"password"); + pigeonResult.path = GetNullableObjectAtIndex(list, 0); + pigeonResult.password = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenPathMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenPathMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"path" : (self.path ?: [NSNull null]), - @"password" : (self.password ?: [NSNull null]), - }; ++ (nullable OpenPathMessage *)nullableFromList:(NSArray *)list { return (list) ? [OpenPathMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.path ?: [NSNull null]), + (self.password ?: [NSNull null]), + ]; } @end @@ -150,18 +138,18 @@ + (instancetype)makeWithId:(nullable NSString *)id pigeonResult.pagesCount = pagesCount; return pigeonResult; } -+ (OpenReply *)fromMap:(NSDictionary *)dict { ++ (OpenReply *)fromList:(NSArray *)list { OpenReply *pigeonResult = [[OpenReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); - pigeonResult.pagesCount = GetNullableObject(dict, @"pagesCount"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.pagesCount = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable OpenReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [OpenReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - @"pagesCount" : (self.pagesCount ?: [NSNull null]), - }; ++ (nullable OpenReply *)nullableFromList:(NSArray *)list { return (list) ? [OpenReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + (self.pagesCount ?: [NSNull null]), + ]; } @end @@ -171,16 +159,16 @@ + (instancetype)makeWithId:(nullable NSString *)id { pigeonResult.id = id; return pigeonResult; } -+ (IdMessage *)fromMap:(NSDictionary *)dict { ++ (IdMessage *)fromList:(NSArray *)list { IdMessage *pigeonResult = [[IdMessage alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable IdMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [IdMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable IdMessage *)nullableFromList:(NSArray *)list { return (list) ? [IdMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -194,20 +182,20 @@ + (instancetype)makeWithDocumentId:(nullable NSString *)documentId pigeonResult.autoCloseAndroid = autoCloseAndroid; return pigeonResult; } -+ (GetPageMessage *)fromMap:(NSDictionary *)dict { ++ (GetPageMessage *)fromList:(NSArray *)list { GetPageMessage *pigeonResult = [[GetPageMessage alloc] init]; - pigeonResult.documentId = GetNullableObject(dict, @"documentId"); - pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); - pigeonResult.autoCloseAndroid = GetNullableObject(dict, @"autoCloseAndroid"); + pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); + pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); + pigeonResult.autoCloseAndroid = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable GetPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"documentId" : (self.documentId ?: [NSNull null]), - @"pageNumber" : (self.pageNumber ?: [NSNull null]), - @"autoCloseAndroid" : (self.autoCloseAndroid ?: [NSNull null]), - }; ++ (nullable GetPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [GetPageMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.documentId ?: [NSNull null]), + (self.pageNumber ?: [NSNull null]), + (self.autoCloseAndroid ?: [NSNull null]), + ]; } @end @@ -221,20 +209,20 @@ + (instancetype)makeWithId:(nullable NSString *)id pigeonResult.height = height; return pigeonResult; } -+ (GetPageReply *)fromMap:(NSDictionary *)dict { ++ (GetPageReply *)fromList:(NSArray *)list { GetPageReply *pigeonResult = [[GetPageReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable GetPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [GetPageReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - }; ++ (nullable GetPageReply *)nullableFromList:(NSArray *)list { return (list) ? [GetPageReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + ]; } @end @@ -266,38 +254,38 @@ + (instancetype)makeWithPageId:(nullable NSString *)pageId pigeonResult.forPrint = forPrint; return pigeonResult; } -+ (RenderPageMessage *)fromMap:(NSDictionary *)dict { ++ (RenderPageMessage *)fromList:(NSArray *)list { RenderPageMessage *pigeonResult = [[RenderPageMessage alloc] init]; - pigeonResult.pageId = GetNullableObject(dict, @"pageId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.format = GetNullableObject(dict, @"format"); - pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); - pigeonResult.crop = GetNullableObject(dict, @"crop"); - pigeonResult.cropX = GetNullableObject(dict, @"cropX"); - pigeonResult.cropY = GetNullableObject(dict, @"cropY"); - pigeonResult.cropHeight = GetNullableObject(dict, @"cropHeight"); - pigeonResult.cropWidth = GetNullableObject(dict, @"cropWidth"); - pigeonResult.quality = GetNullableObject(dict, @"quality"); - pigeonResult.forPrint = GetNullableObject(dict, @"forPrint"); + pigeonResult.pageId = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); + pigeonResult.format = GetNullableObjectAtIndex(list, 3); + pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 4); + pigeonResult.crop = GetNullableObjectAtIndex(list, 5); + pigeonResult.cropX = GetNullableObjectAtIndex(list, 6); + pigeonResult.cropY = GetNullableObjectAtIndex(list, 7); + pigeonResult.cropHeight = GetNullableObjectAtIndex(list, 8); + pigeonResult.cropWidth = GetNullableObjectAtIndex(list, 9); + pigeonResult.quality = GetNullableObjectAtIndex(list, 10); + pigeonResult.forPrint = GetNullableObjectAtIndex(list, 11); return pigeonResult; } -+ (nullable RenderPageMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"pageId" : (self.pageId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"format" : (self.format ?: [NSNull null]), - @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), - @"crop" : (self.crop ?: [NSNull null]), - @"cropX" : (self.cropX ?: [NSNull null]), - @"cropY" : (self.cropY ?: [NSNull null]), - @"cropHeight" : (self.cropHeight ?: [NSNull null]), - @"cropWidth" : (self.cropWidth ?: [NSNull null]), - @"quality" : (self.quality ?: [NSNull null]), - @"forPrint" : (self.forPrint ?: [NSNull null]), - }; ++ (nullable RenderPageMessage *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.pageId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.format ?: [NSNull null]), + (self.backgroundColor ?: [NSNull null]), + (self.crop ?: [NSNull null]), + (self.cropX ?: [NSNull null]), + (self.cropY ?: [NSNull null]), + (self.cropHeight ?: [NSNull null]), + (self.cropWidth ?: [NSNull null]), + (self.quality ?: [NSNull null]), + (self.forPrint ?: [NSNull null]), + ]; } @end @@ -313,22 +301,22 @@ + (instancetype)makeWithWidth:(nullable NSNumber *)width pigeonResult.data = data; return pigeonResult; } -+ (RenderPageReply *)fromMap:(NSDictionary *)dict { ++ (RenderPageReply *)fromList:(NSArray *)list { RenderPageReply *pigeonResult = [[RenderPageReply alloc] init]; - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.path = GetNullableObject(dict, @"path"); - pigeonResult.data = GetNullableObject(dict, @"data"); + pigeonResult.width = GetNullableObjectAtIndex(list, 0); + pigeonResult.height = GetNullableObjectAtIndex(list, 1); + pigeonResult.path = GetNullableObjectAtIndex(list, 2); + pigeonResult.data = GetNullableObjectAtIndex(list, 3); return pigeonResult; } -+ (nullable RenderPageReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RenderPageReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"path" : (self.path ?: [NSNull null]), - @"data" : (self.data ?: [NSNull null]), - }; ++ (nullable RenderPageReply *)nullableFromList:(NSArray *)list { return (list) ? [RenderPageReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.path ?: [NSNull null]), + (self.data ?: [NSNull null]), + ]; } @end @@ -338,16 +326,16 @@ + (instancetype)makeWithId:(nullable NSNumber *)id { pigeonResult.id = id; return pigeonResult; } -+ (RegisterTextureReply *)fromMap:(NSDictionary *)dict { ++ (RegisterTextureReply *)fromList:(NSArray *)list { RegisterTextureReply *pigeonResult = [[RegisterTextureReply alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable RegisterTextureReply *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [RegisterTextureReply fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable RegisterTextureReply *)nullableFromList:(NSArray *)list { return (list) ? [RegisterTextureReply fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -387,46 +375,46 @@ + (instancetype)makeWithDocumentId:(nullable NSString *)documentId pigeonResult.allowAntiAliasing = allowAntiAliasing; return pigeonResult; } -+ (UpdateTextureMessage *)fromMap:(NSDictionary *)dict { ++ (UpdateTextureMessage *)fromList:(NSArray *)list { UpdateTextureMessage *pigeonResult = [[UpdateTextureMessage alloc] init]; - pigeonResult.documentId = GetNullableObject(dict, @"documentId"); - pigeonResult.pageNumber = GetNullableObject(dict, @"pageNumber"); - pigeonResult.pageId = GetNullableObject(dict, @"pageId"); - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); - pigeonResult.backgroundColor = GetNullableObject(dict, @"backgroundColor"); - pigeonResult.sourceX = GetNullableObject(dict, @"sourceX"); - pigeonResult.sourceY = GetNullableObject(dict, @"sourceY"); - pigeonResult.destinationX = GetNullableObject(dict, @"destinationX"); - pigeonResult.destinationY = GetNullableObject(dict, @"destinationY"); - pigeonResult.fullWidth = GetNullableObject(dict, @"fullWidth"); - pigeonResult.fullHeight = GetNullableObject(dict, @"fullHeight"); - pigeonResult.textureWidth = GetNullableObject(dict, @"textureWidth"); - pigeonResult.textureHeight = GetNullableObject(dict, @"textureHeight"); - pigeonResult.allowAntiAliasing = GetNullableObject(dict, @"allowAntiAliasing"); + pigeonResult.documentId = GetNullableObjectAtIndex(list, 0); + pigeonResult.pageNumber = GetNullableObjectAtIndex(list, 1); + pigeonResult.pageId = GetNullableObjectAtIndex(list, 2); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 3); + pigeonResult.width = GetNullableObjectAtIndex(list, 4); + pigeonResult.height = GetNullableObjectAtIndex(list, 5); + pigeonResult.backgroundColor = GetNullableObjectAtIndex(list, 6); + pigeonResult.sourceX = GetNullableObjectAtIndex(list, 7); + pigeonResult.sourceY = GetNullableObjectAtIndex(list, 8); + pigeonResult.destinationX = GetNullableObjectAtIndex(list, 9); + pigeonResult.destinationY = GetNullableObjectAtIndex(list, 10); + pigeonResult.fullWidth = GetNullableObjectAtIndex(list, 11); + pigeonResult.fullHeight = GetNullableObjectAtIndex(list, 12); + pigeonResult.textureWidth = GetNullableObjectAtIndex(list, 13); + pigeonResult.textureHeight = GetNullableObjectAtIndex(list, 14); + pigeonResult.allowAntiAliasing = GetNullableObjectAtIndex(list, 15); return pigeonResult; } -+ (nullable UpdateTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UpdateTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"documentId" : (self.documentId ?: [NSNull null]), - @"pageNumber" : (self.pageNumber ?: [NSNull null]), - @"pageId" : (self.pageId ?: [NSNull null]), - @"textureId" : (self.textureId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - @"backgroundColor" : (self.backgroundColor ?: [NSNull null]), - @"sourceX" : (self.sourceX ?: [NSNull null]), - @"sourceY" : (self.sourceY ?: [NSNull null]), - @"destinationX" : (self.destinationX ?: [NSNull null]), - @"destinationY" : (self.destinationY ?: [NSNull null]), - @"fullWidth" : (self.fullWidth ?: [NSNull null]), - @"fullHeight" : (self.fullHeight ?: [NSNull null]), - @"textureWidth" : (self.textureWidth ?: [NSNull null]), - @"textureHeight" : (self.textureHeight ?: [NSNull null]), - @"allowAntiAliasing" : (self.allowAntiAliasing ?: [NSNull null]), - }; ++ (nullable UpdateTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UpdateTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.documentId ?: [NSNull null]), + (self.pageNumber ?: [NSNull null]), + (self.pageId ?: [NSNull null]), + (self.textureId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + (self.backgroundColor ?: [NSNull null]), + (self.sourceX ?: [NSNull null]), + (self.sourceY ?: [NSNull null]), + (self.destinationX ?: [NSNull null]), + (self.destinationY ?: [NSNull null]), + (self.fullWidth ?: [NSNull null]), + (self.fullHeight ?: [NSNull null]), + (self.textureWidth ?: [NSNull null]), + (self.textureHeight ?: [NSNull null]), + (self.allowAntiAliasing ?: [NSNull null]), + ]; } @end @@ -440,20 +428,20 @@ + (instancetype)makeWithTextureId:(nullable NSNumber *)textureId pigeonResult.height = height; return pigeonResult; } -+ (ResizeTextureMessage *)fromMap:(NSDictionary *)dict { ++ (ResizeTextureMessage *)fromList:(NSArray *)list { ResizeTextureMessage *pigeonResult = [[ResizeTextureMessage alloc] init]; - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); - pigeonResult.width = GetNullableObject(dict, @"width"); - pigeonResult.height = GetNullableObject(dict, @"height"); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); + pigeonResult.width = GetNullableObjectAtIndex(list, 1); + pigeonResult.height = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable ResizeTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [ResizeTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"textureId" : (self.textureId ?: [NSNull null]), - @"width" : (self.width ?: [NSNull null]), - @"height" : (self.height ?: [NSNull null]), - }; ++ (nullable ResizeTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [ResizeTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.textureId ?: [NSNull null]), + (self.width ?: [NSNull null]), + (self.height ?: [NSNull null]), + ]; } @end @@ -463,16 +451,16 @@ + (instancetype)makeWithId:(nullable NSNumber *)id { pigeonResult.id = id; return pigeonResult; } -+ (UnregisterTextureMessage *)fromMap:(NSDictionary *)dict { ++ (UnregisterTextureMessage *)fromList:(NSArray *)list { UnregisterTextureMessage *pigeonResult = [[UnregisterTextureMessage alloc] init]; - pigeonResult.id = GetNullableObject(dict, @"id"); + pigeonResult.id = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable UnregisterTextureMessage *)nullableFromMap:(NSDictionary *)dict { return (dict) ? [UnregisterTextureMessage fromMap:dict] : nil; } -- (NSDictionary *)toMap { - return @{ - @"id" : (self.id ?: [NSNull null]), - }; ++ (nullable UnregisterTextureMessage *)nullableFromList:(NSArray *)list { return (list) ? [UnregisterTextureMessage fromList:list] : nil; } +- (NSArray *)toList { + return @[ + (self.id ?: [NSNull null]), + ]; } @end @@ -483,40 +471,40 @@ - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 128: - return [GetPageMessage fromMap:[self readValue]]; + return [GetPageMessage fromList:[self readValue]]; case 129: - return [GetPageReply fromMap:[self readValue]]; + return [GetPageReply fromList:[self readValue]]; case 130: - return [IdMessage fromMap:[self readValue]]; + return [IdMessage fromList:[self readValue]]; case 131: - return [OpenDataMessage fromMap:[self readValue]]; + return [OpenDataMessage fromList:[self readValue]]; case 132: - return [OpenPathMessage fromMap:[self readValue]]; + return [OpenPathMessage fromList:[self readValue]]; case 133: - return [OpenReply fromMap:[self readValue]]; + return [OpenReply fromList:[self readValue]]; case 134: - return [RegisterTextureReply fromMap:[self readValue]]; + return [RegisterTextureReply fromList:[self readValue]]; case 135: - return [RenderPageMessage fromMap:[self readValue]]; + return [RenderPageMessage fromList:[self readValue]]; case 136: - return [RenderPageReply fromMap:[self readValue]]; + return [RenderPageReply fromList:[self readValue]]; case 137: - return [ResizeTextureMessage fromMap:[self readValue]]; + return [ResizeTextureMessage fromList:[self readValue]]; case 138: - return [UnregisterTextureMessage fromMap:[self readValue]]; + return [UnregisterTextureMessage fromList:[self readValue]]; case 139: - return [UpdateTextureMessage fromMap:[self readValue]]; + return [UpdateTextureMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -532,51 +520,51 @@ - (void)writeValue:(id)value { if ([value isKindOfClass:[GetPageMessage class]]) { [self writeByte:128]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[GetPageReply class]]) { [self writeByte:129]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[IdMessage class]]) { [self writeByte:130]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenDataMessage class]]) { [self writeByte:131]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenPathMessage class]]) { [self writeByte:132]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[OpenReply class]]) { [self writeByte:133]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RegisterTextureReply class]]) { [self writeByte:134]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RenderPageMessage class]]) { [self writeByte:135]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[RenderPageReply class]]) { [self writeByte:136]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[ResizeTextureMessage class]]) { [self writeByte:137]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[UnregisterTextureMessage class]]) { [self writeByte:138]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[UpdateTextureMessage class]]) { [self writeByte:139]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else { [super writeValue:value]; @@ -595,9 +583,10 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { } @end -NSObject *PdfxApiGetCodec(void) { - static dispatch_once_t sPred = 0; + +NSObject *PdfxApiGetCodec() { static FlutterStandardMessageCodec *sSharedObject = nil; + static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ PdfxApiCodecReaderWriter *readerWriter = [[PdfxApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; @@ -605,14 +594,13 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { return sSharedObject; } - void PdfxApiSetup(id binaryMessenger, NSObject *api) { { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentData" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentDataMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentDataMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -632,7 +620,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentFile" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentFileMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentFileMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -652,7 +640,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.openDocumentAsset" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(openDocumentAssetMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(openDocumentAssetMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -672,7 +660,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.closeDocument" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(closeDocumentMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closeDocumentMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -692,7 +680,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.getPage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(getPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(getPageMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -712,7 +700,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.renderPage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(renderPageMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(renderPageMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -732,7 +720,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.closePage" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(closePageMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(closePageMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -752,7 +740,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.registerTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(registerTextureWithError:)], @"PdfxApi api (%@) doesn't respond to @selector(registerTextureWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -770,7 +758,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.updateTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(updateTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(updateTextureMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -790,7 +778,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.resizeTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(resizeTextureMessage:completion:)], @"PdfxApi api (%@) doesn't respond to @selector(resizeTextureMessage:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -810,7 +798,7 @@ void PdfxApiSetup(id binaryMessenger, NSObject [[FlutterBasicMessageChannel alloc] initWithName:@"dev.flutter.pigeon.PdfxApi.unregisterTexture" binaryMessenger:binaryMessenger - codec:PdfxApiGetCodec() ]; + codec:PdfxApiGetCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(unregisterTextureMessage:error:)], @"PdfxApi api (%@) doesn't respond to @selector(unregisterTextureMessage:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { diff --git a/packages/pdfx/lib/src/renderer/io/pigeon.dart b/packages/pdfx/lib/src/renderer/io/pigeon.dart index 8b7ce8ff..4295e383 100644 --- a/packages/pdfx/lib/src/renderer/io/pigeon.dart +++ b/packages/pdfx/lib/src/renderer/io/pigeon.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v4.2.0), do not edit directly. +// Autogenerated from Pigeon (v4.2.14), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import import 'dart:async'; @@ -14,20 +14,21 @@ class OpenDataMessage { }); Uint8List? data; + String? password; Object encode() { - final Map pigeonMap = {}; - pigeonMap['data'] = data; - pigeonMap['password'] = password; - return pigeonMap; + return [ + data, + password, + ]; } - static OpenDataMessage decode(Object message) { - final Map pigeonMap = message as Map; + static OpenDataMessage decode(Object result) { + result as List; return OpenDataMessage( - data: pigeonMap['data'] as Uint8List?, - password: pigeonMap['password'] as String?, + data: result[0] as Uint8List?, + password: result[1] as String?, ); } } @@ -39,20 +40,21 @@ class OpenPathMessage { }); String? path; + String? password; Object encode() { - final Map pigeonMap = {}; - pigeonMap['path'] = path; - pigeonMap['password'] = password; - return pigeonMap; + return [ + path, + password, + ]; } - static OpenPathMessage decode(Object message) { - final Map pigeonMap = message as Map; + static OpenPathMessage decode(Object result) { + result as List; return OpenPathMessage( - path: pigeonMap['path'] as String?, - password: pigeonMap['password'] as String?, + path: result[0] as String?, + password: result[1] as String?, ); } } @@ -64,20 +66,21 @@ class OpenReply { }); String? id; + int? pagesCount; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - pigeonMap['pagesCount'] = pagesCount; - return pigeonMap; + return [ + id, + pagesCount, + ]; } - static OpenReply decode(Object message) { - final Map pigeonMap = message as Map; + static OpenReply decode(Object result) { + result as List; return OpenReply( - id: pigeonMap['id'] as String?, - pagesCount: pigeonMap['pagesCount'] as int?, + id: result[0] as String?, + pagesCount: result[1] as int?, ); } } @@ -90,15 +93,15 @@ class IdMessage { String? id; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - return pigeonMap; + return [ + id, + ]; } - static IdMessage decode(Object message) { - final Map pigeonMap = message as Map; + static IdMessage decode(Object result) { + result as List; return IdMessage( - id: pigeonMap['id'] as String?, + id: result[0] as String?, ); } } @@ -111,23 +114,25 @@ class GetPageMessage { }); String? documentId; + int? pageNumber; + bool? autoCloseAndroid; Object encode() { - final Map pigeonMap = {}; - pigeonMap['documentId'] = documentId; - pigeonMap['pageNumber'] = pageNumber; - pigeonMap['autoCloseAndroid'] = autoCloseAndroid; - return pigeonMap; + return [ + documentId, + pageNumber, + autoCloseAndroid, + ]; } - static GetPageMessage decode(Object message) { - final Map pigeonMap = message as Map; + static GetPageMessage decode(Object result) { + result as List; return GetPageMessage( - documentId: pigeonMap['documentId'] as String?, - pageNumber: pigeonMap['pageNumber'] as int?, - autoCloseAndroid: pigeonMap['autoCloseAndroid'] as bool?, + documentId: result[0] as String?, + pageNumber: result[1] as int?, + autoCloseAndroid: result[2] as bool?, ); } } @@ -140,23 +145,25 @@ class GetPageReply { }); String? id; + double? width; + double? height; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - return pigeonMap; + return [ + id, + width, + height, + ]; } - static GetPageReply decode(Object message) { - final Map pigeonMap = message as Map; + static GetPageReply decode(Object result) { + result as List; return GetPageReply( - id: pigeonMap['id'] as String?, - width: pigeonMap['width'] as double?, - height: pigeonMap['height'] as double?, + id: result[0] as String?, + width: result[1] as double?, + height: result[2] as double?, ); } } @@ -178,50 +185,61 @@ class RenderPageMessage { }); String? pageId; + int? width; + int? height; + int? format; + String? backgroundColor; + bool? crop; + int? cropX; + int? cropY; + int? cropHeight; + int? cropWidth; + int? quality; + bool? forPrint; Object encode() { - final Map pigeonMap = {}; - pigeonMap['pageId'] = pageId; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - pigeonMap['format'] = format; - pigeonMap['backgroundColor'] = backgroundColor; - pigeonMap['crop'] = crop; - pigeonMap['cropX'] = cropX; - pigeonMap['cropY'] = cropY; - pigeonMap['cropHeight'] = cropHeight; - pigeonMap['cropWidth'] = cropWidth; - pigeonMap['quality'] = quality; - pigeonMap['forPrint'] = forPrint; - return pigeonMap; - } - - static RenderPageMessage decode(Object message) { - final Map pigeonMap = message as Map; + return [ + pageId, + width, + height, + format, + backgroundColor, + crop, + cropX, + cropY, + cropHeight, + cropWidth, + quality, + forPrint, + ]; + } + + static RenderPageMessage decode(Object result) { + result as List; return RenderPageMessage( - pageId: pigeonMap['pageId'] as String?, - width: pigeonMap['width'] as int?, - height: pigeonMap['height'] as int?, - format: pigeonMap['format'] as int?, - backgroundColor: pigeonMap['backgroundColor'] as String?, - crop: pigeonMap['crop'] as bool?, - cropX: pigeonMap['cropX'] as int?, - cropY: pigeonMap['cropY'] as int?, - cropHeight: pigeonMap['cropHeight'] as int?, - cropWidth: pigeonMap['cropWidth'] as int?, - quality: pigeonMap['quality'] as int?, - forPrint: pigeonMap['forPrint'] as bool?, + pageId: result[0] as String?, + width: result[1] as int?, + height: result[2] as int?, + format: result[3] as int?, + backgroundColor: result[4] as String?, + crop: result[5] as bool?, + cropX: result[6] as int?, + cropY: result[7] as int?, + cropHeight: result[8] as int?, + cropWidth: result[9] as int?, + quality: result[10] as int?, + forPrint: result[11] as bool?, ); } } @@ -235,26 +253,29 @@ class RenderPageReply { }); int? width; + int? height; + String? path; + Uint8List? data; Object encode() { - final Map pigeonMap = {}; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - pigeonMap['path'] = path; - pigeonMap['data'] = data; - return pigeonMap; + return [ + width, + height, + path, + data, + ]; } - static RenderPageReply decode(Object message) { - final Map pigeonMap = message as Map; + static RenderPageReply decode(Object result) { + result as List; return RenderPageReply( - width: pigeonMap['width'] as int?, - height: pigeonMap['height'] as int?, - path: pigeonMap['path'] as String?, - data: pigeonMap['data'] as Uint8List?, + width: result[0] as int?, + height: result[1] as int?, + path: result[2] as String?, + data: result[3] as Uint8List?, ); } } @@ -267,15 +288,15 @@ class RegisterTextureReply { int? id; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - return pigeonMap; + return [ + id, + ]; } - static RegisterTextureReply decode(Object message) { - final Map pigeonMap = message as Map; + static RegisterTextureReply decode(Object result) { + result as List; return RegisterTextureReply( - id: pigeonMap['id'] as int?, + id: result[0] as int?, ); } } @@ -301,62 +322,77 @@ class UpdateTextureMessage { }); String? documentId; + int? pageNumber; + String? pageId; + int? textureId; + int? width; + int? height; + String? backgroundColor; + int? sourceX; + int? sourceY; + int? destinationX; + int? destinationY; + double? fullWidth; + double? fullHeight; + int? textureWidth; + int? textureHeight; + bool? allowAntiAliasing; Object encode() { - final Map pigeonMap = {}; - pigeonMap['documentId'] = documentId; - pigeonMap['pageNumber'] = pageNumber; - pigeonMap['pageId'] = pageId; - pigeonMap['textureId'] = textureId; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - pigeonMap['backgroundColor'] = backgroundColor; - pigeonMap['sourceX'] = sourceX; - pigeonMap['sourceY'] = sourceY; - pigeonMap['destinationX'] = destinationX; - pigeonMap['destinationY'] = destinationY; - pigeonMap['fullWidth'] = fullWidth; - pigeonMap['fullHeight'] = fullHeight; - pigeonMap['textureWidth'] = textureWidth; - pigeonMap['textureHeight'] = textureHeight; - pigeonMap['allowAntiAliasing'] = allowAntiAliasing; - return pigeonMap; - } - - static UpdateTextureMessage decode(Object message) { - final Map pigeonMap = message as Map; + return [ + documentId, + pageNumber, + pageId, + textureId, + width, + height, + backgroundColor, + sourceX, + sourceY, + destinationX, + destinationY, + fullWidth, + fullHeight, + textureWidth, + textureHeight, + allowAntiAliasing, + ]; + } + + static UpdateTextureMessage decode(Object result) { + result as List; return UpdateTextureMessage( - documentId: pigeonMap['documentId'] as String?, - pageNumber: pigeonMap['pageNumber'] as int?, - pageId: pigeonMap['pageId'] as String?, - textureId: pigeonMap['textureId'] as int?, - width: pigeonMap['width'] as int?, - height: pigeonMap['height'] as int?, - backgroundColor: pigeonMap['backgroundColor'] as String?, - sourceX: pigeonMap['sourceX'] as int?, - sourceY: pigeonMap['sourceY'] as int?, - destinationX: pigeonMap['destinationX'] as int?, - destinationY: pigeonMap['destinationY'] as int?, - fullWidth: pigeonMap['fullWidth'] as double?, - fullHeight: pigeonMap['fullHeight'] as double?, - textureWidth: pigeonMap['textureWidth'] as int?, - textureHeight: pigeonMap['textureHeight'] as int?, - allowAntiAliasing: pigeonMap['allowAntiAliasing'] as bool?, + documentId: result[0] as String?, + pageNumber: result[1] as int?, + pageId: result[2] as String?, + textureId: result[3] as int?, + width: result[4] as int?, + height: result[5] as int?, + backgroundColor: result[6] as String?, + sourceX: result[7] as int?, + sourceY: result[8] as int?, + destinationX: result[9] as int?, + destinationY: result[10] as int?, + fullWidth: result[11] as double?, + fullHeight: result[12] as double?, + textureWidth: result[13] as int?, + textureHeight: result[14] as int?, + allowAntiAliasing: result[15] as bool?, ); } } @@ -369,23 +405,25 @@ class ResizeTextureMessage { }); int? textureId; + int? width; + int? height; Object encode() { - final Map pigeonMap = {}; - pigeonMap['textureId'] = textureId; - pigeonMap['width'] = width; - pigeonMap['height'] = height; - return pigeonMap; + return [ + textureId, + width, + height, + ]; } - static ResizeTextureMessage decode(Object message) { - final Map pigeonMap = message as Map; + static ResizeTextureMessage decode(Object result) { + result as List; return ResizeTextureMessage( - textureId: pigeonMap['textureId'] as int?, - width: pigeonMap['width'] as int?, - height: pigeonMap['height'] as int?, + textureId: result[0] as int?, + width: result[1] as int?, + height: result[2] as int?, ); } } @@ -398,15 +436,15 @@ class UnregisterTextureMessage { int? id; Object encode() { - final Map pigeonMap = {}; - pigeonMap['id'] = id; - return pigeonMap; + return [ + id, + ]; } - static UnregisterTextureMessage decode(Object message) { - final Map pigeonMap = message as Map; + static UnregisterTextureMessage decode(Object result) { + result as List; return UnregisterTextureMessage( - id: pigeonMap['id'] as int?, + id: result[0] as int?, ); } } @@ -418,55 +456,44 @@ class _PdfxApiCodec extends StandardMessageCodec { if (value is GetPageMessage) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is GetPageReply) { + } else if (value is GetPageReply) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else - if (value is IdMessage) { + } else if (value is IdMessage) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else - if (value is OpenDataMessage) { + } else if (value is OpenDataMessage) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else - if (value is OpenPathMessage) { + } else if (value is OpenPathMessage) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else - if (value is OpenReply) { + } else if (value is OpenReply) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else - if (value is RegisterTextureReply) { + } else if (value is RegisterTextureReply) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else - if (value is RenderPageMessage) { + } else if (value is RenderPageMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else - if (value is RenderPageReply) { + } else if (value is RenderPageReply) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else - if (value is ResizeTextureMessage) { + } else if (value is ResizeTextureMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else - if (value is UnregisterTextureMessage) { + } else if (value is UnregisterTextureMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else - if (value is UpdateTextureMessage) { + } else if (value is UpdateTextureMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { @@ -506,7 +533,8 @@ class _PdfxApiCodec extends StandardMessageCodec { case 139: return UpdateTextureMessage.decode(readValue(buffer)!); - default: + default: + return super.readValueOfType(type, buffer); } @@ -523,109 +551,109 @@ class PdfxApi { /// Constructor for [PdfxApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - PdfxApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; - + PdfxApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _PdfxApiCodec(); Future openDocumentData(OpenDataMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentData', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentData', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as OpenReply?)!; + return (replyList[0] as OpenReply?)!; } } Future openDocumentFile(OpenPathMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentFile', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentFile', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as OpenReply?)!; + return (replyList[0] as OpenReply?)!; } } Future openDocumentAsset(OpenPathMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.openDocumentAsset', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.openDocumentAsset', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as OpenReply?)!; + return (replyList[0] as OpenReply?)!; } } Future closeDocument(IdMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.closeDocument', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.closeDocument', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -634,74 +662,74 @@ class PdfxApi { Future getPage(GetPageMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.getPage', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.getPage', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as GetPageReply?)!; + return (replyList[0] as GetPageReply?)!; } } Future renderPage(RenderPageMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.renderPage', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.renderPage', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as RenderPageReply?)!; + return (replyList[0] as RenderPageReply?)!; } } Future closePage(IdMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.closePage', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.closePage', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -710,47 +738,47 @@ class PdfxApi { Future registerTexture() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.registerTexture', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send(null) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.registerTexture', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send(null) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as RegisterTextureReply?)!; + return (replyList[0] as RegisterTextureReply?)!; } } Future updateTexture(UpdateTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.updateTexture', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.updateTexture', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -759,20 +787,20 @@ class PdfxApi { Future resizeTexture(ResizeTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.resizeTexture', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.resizeTexture', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -781,20 +809,20 @@ class PdfxApi { Future unregisterTexture(UnregisterTextureMessage arg_message) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PdfxApi.unregisterTexture', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_message]) as Map?; - if (replyMap == null) { + 'dev.flutter.pigeon.PdfxApi.unregisterTexture', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_message]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; From e55237f7ab9f9bce47d4abde855410f28c38c251 Mon Sep 17 00:00:00 2001 From: Bernd Wahlen Date: Fri, 10 Apr 2026 14:53:38 +0200 Subject: [PATCH 11/11] pdfx: migrate build.gradle to Kotlin DSL with AGP 9 conditional --- packages/pdfx/android/build.gradle | 56 -------------------------- packages/pdfx/android/build.gradle.kts | 32 +++++++++++++++ 2 files changed, 32 insertions(+), 56 deletions(-) delete mode 100644 packages/pdfx/android/build.gradle create mode 100644 packages/pdfx/android/build.gradle.kts diff --git a/packages/pdfx/android/build.gradle b/packages/pdfx/android/build.gradle deleted file mode 100644 index 0d59db2b..00000000 --- a/packages/pdfx/android/build.gradle +++ /dev/null @@ -1,56 +0,0 @@ -group 'io.scer.pdf_renderer' -version '1.0-SNAPSHOT' - -buildscript { - ext.kotlin_version = '1.9.23' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.5.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -rootProject.allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - -android { - // Conditional for compatibility with AGP <4.2. - if (project.android.hasProperty("namespace")) { - namespace 'io.scer.pdf_renderer' - } - - compileSdk 35 - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - defaultConfig { - minSdkVersion 16 - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - - kotlinOptions { - jvmTarget = '11' - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") -} diff --git a/packages/pdfx/android/build.gradle.kts b/packages/pdfx/android/build.gradle.kts new file mode 100644 index 00000000..4e3e2f90 --- /dev/null +++ b/packages/pdfx/android/build.gradle.kts @@ -0,0 +1,32 @@ +plugins { + id("com.android.library") +} + +val agpVersion: String = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION +if (agpVersion.split(".")[0].toInt() < 9) { + apply(plugin = "kotlin-android") +} + +android { + namespace = "io.scer.pdf_renderer" + compileSdk = 35 + + sourceSets { + getByName("main") { + java.srcDirs("src/main/kotlin") + } + } + + defaultConfig { + minSdk = 16 + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") +}