From dbc913d3c008f2aa8e41d6d8475542f110636ac5 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Fri, 6 Sep 2024 12:58:21 -0700 Subject: [PATCH] nullable non-null --- .../AlternateLanguageTestPlugin.java | 84 +++++ .../ios/Classes/AlternateLanguageTestPlugin.m | 243 +++++++++---- .../Classes/AlternateLanguageTestPlugin.m | 243 +++++++++---- .../com/example/test_plugin/TestPlugin.kt | 70 ++++ .../test_plugin/ios/Classes/TestPlugin.swift | 156 ++++++-- .../test_plugin/linux/test_plugin.cc | 342 ++++++++++++++++++ .../macos/Classes/TestPlugin.swift | 156 ++++++-- .../test_plugin/windows/test_plugin.cpp | 114 ++++++ .../test_plugin/windows/test_plugin.h | 50 +++ 9 files changed, 1274 insertions(+), 184 deletions(-) diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java index ec8a509d86f1..8580645a27d7 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java @@ -305,6 +305,19 @@ public Map echoNonNullClassMap( return classList; } + @Nullable + @Override + public List echoNullableNonNullEnumList(@Nullable List enumList) { + return enumList; + } + + @Nullable + @Override + public List echoNullableNonNullClassList( + @Nullable List classList) { + return classList; + } + @Override public @Nullable Map echoNullableMap(@Nullable Map map) { return map; @@ -332,6 +345,31 @@ public Map echoNonNullClassMap( return classMap; } + @Nullable + @Override + public Map echoNullableNonNullStringMap(@Nullable Map stringMap) { + return stringMap; + } + + @Nullable + @Override + public Map echoNullableNonNullIntMap(@Nullable Map intMap) { + return intMap; + } + + @Nullable + @Override + public Map echoNullableNonNullEnumMap(@Nullable Map enumMap) { + return enumMap; + } + + @Nullable + @Override + public Map echoNullableNonNullClassMap( + @Nullable Map classMap) { + return classMap; + } + @Override public @Nullable AnEnum echoNullableEnum(@Nullable AnEnum anEnum) { return anEnum; @@ -839,6 +877,21 @@ public void callFlutterEchoNullableClassList( flutterApi.echoNullableClassList(classList, result); } + @Override + public void callFlutterEchoNullableNonNullEnumList( + @Nullable List enumList, @NonNull NullableResult> result) { + assert flutterApi != null; + flutterApi.echoNullableNonNullEnumList(enumList, result); + } + + @Override + public void callFlutterEchoNullableNonNullClassList( + @Nullable List classList, + @NonNull NullableResult> result) { + assert flutterApi != null; + flutterApi.echoNullableNonNullClassList(classList, result); + } + @Override public void callFlutterEchoNullableMap( @Nullable Map map, @NonNull NullableResult> result) { @@ -876,6 +929,37 @@ public void callFlutterEchoNullableClassMap( flutterApi.echoNullableClassMap(classMap, result); } + @Override + public void callFlutterEchoNullableNonNullStringMap( + @Nullable Map stringMap, + @NonNull NullableResult> result) { + + assert flutterApi != null; + flutterApi.echoNullableNonNullStringMap(stringMap, result); + } + + @Override + public void callFlutterEchoNullableNonNullIntMap( + @Nullable Map intMap, @NonNull NullableResult> result) { + assert flutterApi != null; + flutterApi.echoNullableNonNullIntMap(intMap, result); + } + + @Override + public void callFlutterEchoNullableNonNullEnumMap( + @Nullable Map enumMap, @NonNull NullableResult> result) { + assert flutterApi != null; + flutterApi.echoNullableNonNullEnumMap(enumMap, result); + } + + @Override + public void callFlutterEchoNullableNonNullClassMap( + @Nullable Map classMap, + @NonNull NullableResult> result) { + assert flutterApi != null; + flutterApi.echoNullableNonNullClassMap(classMap, result); + } + @Override public void callFlutterEchoNullableEnum( @Nullable AnEnum anEnum, @NonNull NullableResult result) { diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m index 432c118160fe..d684acfd55e6 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m @@ -106,6 +106,18 @@ - (nullable id)echoObject:(id)anObject error:(FlutterError *_Nullable *_Nonnull) return classList; } +- (nullable NSArray *) + echoNonNullEnumList:(nonnull NSArray *)enumList + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return enumList; +} + +- (nullable NSArray *) + echoNonNullClassList:(nonnull NSArray *)classList + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return classList; +} + - (nullable NSDictionary *)echoMap:(NSDictionary *)map error:(FlutterError *_Nullable *_Nonnull)error { return map; @@ -135,6 +147,30 @@ - (nullable id)echoObject:(id)anObject error:(FlutterError *_Nullable *_Nonnull) return classMap; } +- (nullable NSDictionary *) + echoNonNullStringMap:(nonnull NSDictionary *)stringMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return stringMap; +} + +- (nullable NSDictionary *) + echoNonNullIntMap:(nonnull NSDictionary *)intMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return intMap; +} + +- (nullable NSDictionary *) + echoNonNullEnumMap:(nonnull NSDictionary *)enumMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return enumMap; +} + +- (nullable NSDictionary *) + echoNonNullClassMap:(nonnull NSDictionary *)classMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return classMap; +} + - (nullable FLTAllClassesWrapper *)echoClassWrapper:(FLTAllClassesWrapper *)wrapper error:(FlutterError *_Nullable *_Nonnull)error { return wrapper; @@ -254,20 +290,20 @@ - (nullable id)echoNullableObject:(nullable id)aNullableObject } - (nullable NSArray *) - echoNullableClassList:(nullable NSArray *)FLTAllNullableTypes + echoNullableClassList:(nullable NSArray *)classList error:(FlutterError *_Nullable *_Nonnull)error { - return FLTAllNullableTypes; + return classList; } - (nullable NSArray *) - echoNonNullEnumList:(nonnull NSArray *)enumList - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullEnumList:(nullable NSArray *)enumList + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return enumList; } - (nullable NSArray *) - echoNonNullClassList:(nonnull NSArray *)classList - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullClassList:(nullable NSArray *)classList + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return classList; } @@ -301,26 +337,26 @@ - (nullable id)echoNullableObject:(nullable id)aNullableObject } - (nullable NSDictionary *) - echoNonNullStringMap:(nonnull NSDictionary *)stringMap - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullStringMap:(nullable NSDictionary *)stringMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return stringMap; } - (nullable NSDictionary *) - echoNonNullIntMap:(nonnull NSDictionary *)intMap - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullIntMap:(nullable NSDictionary *)intMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return intMap; } - (nullable NSDictionary *) - echoNonNullEnumMap:(nonnull NSDictionary *)enumMap - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullEnumMap:(nullable NSDictionary *)enumMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return enumMap; } - (nullable NSDictionary *) - echoNonNullClassMap:(nonnull NSDictionary *)classMap - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullClassMap:(nullable NSDictionary *)classMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return classMap; } @@ -692,6 +728,25 @@ - (void)callFlutterEchoClassList:(NSArray *)classList }]; } +- (void)callFlutterEchoNonNullEnumList:(nonnull NSArray *)enumList + completion:(nonnull void (^)(NSArray *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNonNullEnumList:enumList + completion:^(NSArray *value, FlutterError *error) { + completion(value, error); + }]; +} + +- (void)callFlutterEchoNonNullClassList:(nonnull NSArray *)classList + completion:(nonnull void (^)(NSArray *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNonNullClassList:classList + completion:^(NSArray *value, FlutterError *error) { + completion(value, error); + }]; +} + - (void)callFlutterEchoMap:(NSDictionary *)map completion: (void (^)(NSDictionary *_Nullable, FlutterError *_Nullable))completion { @@ -741,6 +796,53 @@ - (void)callFlutterEchoClassMap:(NSDictionary }]; } +- (void)callFlutterEchoNonNullStringMap:(nonnull NSDictionary *)stringMap + completion: + (nonnull void (^)(NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNonNullStringMap:stringMap + completion:^(NSDictionary *value, FlutterError *error) { + completion(value, error); + }]; +} + +- (void)callFlutterEchoNonNullIntMap:(nonnull NSDictionary *)intMap + completion: + (nonnull void (^)(NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNonNullIntMap:intMap + completion:^(NSDictionary *value, FlutterError *error) { + completion(value, error); + }]; +} + +- (void)callFlutterEchoNonNullEnumMap: + (nonnull NSDictionary *)enumMap + completion:(nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNonNullEnumMap:enumMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; +} + +- (void)callFlutterEchoNonNullClassMap: + (nonnull NSDictionary *)classMap + completion: + (nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNonNullClassMap:classMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; +} + - (void)callFlutterEchoEnum:(FLTAnEnum)anEnum completion:(void (^)(FLTAnEnumBox *_Nullable, FlutterError *_Nullable))completion { [self.flutterAPI echoEnum:anEnum @@ -854,23 +956,26 @@ - (void)callFlutterEchoNullableClassList:(nullable NSArray *)enumList - completion:(nonnull void (^)(NSArray *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI echoNonNullEnumList:enumList - completion:^(NSArray *value, FlutterError *error) { - completion(value, error); - }]; +- (void)callFlutterEchoNullableNonNullEnumList:(nullable NSArray *)enumList + completion: + (nonnull void (^)(NSArray *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNullableNonNullEnumList:enumList + completion:^(NSArray *value, FlutterError *error) { + completion(value, error); + }]; } -- (void)callFlutterEchoNonNullClassList:(nonnull NSArray *)classList - completion:(nonnull void (^)(NSArray *_Nullable, - FlutterError *_Nullable))completion { +- (void)callFlutterEchoNullableNonNullClassList:(nullable NSArray *)classList + completion:(nonnull void (^)( + NSArray *_Nullable, + FlutterError *_Nullable))completion { [self.flutterAPI - echoNonNullClassList:classList - completion:^(NSArray *value, FlutterError *error) { - completion(value, error); - }]; + echoNullableNonNullClassList:classList + completion:^(NSArray *value, FlutterError *error) { + completion(value, error); + }]; } - (void)callFlutterEchoNullableMap:(nullable NSDictionary *)map @@ -927,51 +1032,55 @@ - (void)callFlutterEchoNullableEnumMap: }]; } -- (void)callFlutterEchoNonNullStringMap:(nonnull NSDictionary *)stringMap - completion: - (nonnull void (^)(NSDictionary *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI - echoNonNullStringMap:stringMap - completion:^(NSDictionary *value, FlutterError *error) { - completion(value, error); - }]; +- (void)callFlutterEchoNullableNonNullStringMap: + (nullable NSDictionary *)stringMap + completion:(nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNullableNonNullStringMap:stringMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; } -- (void)callFlutterEchoNonNullIntMap:(nonnull NSDictionary *)intMap - completion: - (nonnull void (^)(NSDictionary *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI - echoNonNullIntMap:intMap - completion:^(NSDictionary *value, FlutterError *error) { - completion(value, error); - }]; +- (void)callFlutterEchoNullableNonNullIntMap:(nullable NSDictionary *)intMap + completion:(nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNullableNonNullIntMap:intMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; } -- (void)callFlutterEchoNonNullEnumMap: - (nonnull NSDictionary *)enumMap - completion:(nonnull void (^)( - NSDictionary *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI echoNonNullEnumMap:enumMap - completion:^(NSDictionary *value, - FlutterError *error) { - completion(value, error); - }]; +- (void)callFlutterEchoNullableNonNullEnumMap: + (nullable NSDictionary *)enumMap + completion: + (nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNullableNonNullEnumMap:enumMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; } -- (void)callFlutterEchoNonNullClassMap: - (nonnull NSDictionary *)classMap - completion: - (nonnull void (^)( - NSDictionary *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI echoNonNullClassMap:classMap - completion:^(NSDictionary *value, - FlutterError *error) { - completion(value, error); - }]; +- (void) + callFlutterEchoNullableNonNullClassMap: + (nullable NSDictionary *)classMap + completion: + (nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNullableNonNullClassMap:classMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; } - (void)callFlutterEchoNullableEnum:(nullable FLTAnEnumBox *)AnEnumBoxed diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/AlternateLanguageTestPlugin.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/AlternateLanguageTestPlugin.m index 432c118160fe..d684acfd55e6 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/AlternateLanguageTestPlugin.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/AlternateLanguageTestPlugin.m @@ -106,6 +106,18 @@ - (nullable id)echoObject:(id)anObject error:(FlutterError *_Nullable *_Nonnull) return classList; } +- (nullable NSArray *) + echoNonNullEnumList:(nonnull NSArray *)enumList + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return enumList; +} + +- (nullable NSArray *) + echoNonNullClassList:(nonnull NSArray *)classList + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return classList; +} + - (nullable NSDictionary *)echoMap:(NSDictionary *)map error:(FlutterError *_Nullable *_Nonnull)error { return map; @@ -135,6 +147,30 @@ - (nullable id)echoObject:(id)anObject error:(FlutterError *_Nullable *_Nonnull) return classMap; } +- (nullable NSDictionary *) + echoNonNullStringMap:(nonnull NSDictionary *)stringMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return stringMap; +} + +- (nullable NSDictionary *) + echoNonNullIntMap:(nonnull NSDictionary *)intMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return intMap; +} + +- (nullable NSDictionary *) + echoNonNullEnumMap:(nonnull NSDictionary *)enumMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return enumMap; +} + +- (nullable NSDictionary *) + echoNonNullClassMap:(nonnull NSDictionary *)classMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + return classMap; +} + - (nullable FLTAllClassesWrapper *)echoClassWrapper:(FLTAllClassesWrapper *)wrapper error:(FlutterError *_Nullable *_Nonnull)error { return wrapper; @@ -254,20 +290,20 @@ - (nullable id)echoNullableObject:(nullable id)aNullableObject } - (nullable NSArray *) - echoNullableClassList:(nullable NSArray *)FLTAllNullableTypes + echoNullableClassList:(nullable NSArray *)classList error:(FlutterError *_Nullable *_Nonnull)error { - return FLTAllNullableTypes; + return classList; } - (nullable NSArray *) - echoNonNullEnumList:(nonnull NSArray *)enumList - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullEnumList:(nullable NSArray *)enumList + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return enumList; } - (nullable NSArray *) - echoNonNullClassList:(nonnull NSArray *)classList - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullClassList:(nullable NSArray *)classList + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return classList; } @@ -301,26 +337,26 @@ - (nullable id)echoNullableObject:(nullable id)aNullableObject } - (nullable NSDictionary *) - echoNonNullStringMap:(nonnull NSDictionary *)stringMap - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullStringMap:(nullable NSDictionary *)stringMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return stringMap; } - (nullable NSDictionary *) - echoNonNullIntMap:(nonnull NSDictionary *)intMap - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullIntMap:(nullable NSDictionary *)intMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return intMap; } - (nullable NSDictionary *) - echoNonNullEnumMap:(nonnull NSDictionary *)enumMap - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullEnumMap:(nullable NSDictionary *)enumMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return enumMap; } - (nullable NSDictionary *) - echoNonNullClassMap:(nonnull NSDictionary *)classMap - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + echoNullableNonNullClassMap:(nullable NSDictionary *)classMap + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { return classMap; } @@ -692,6 +728,25 @@ - (void)callFlutterEchoClassList:(NSArray *)classList }]; } +- (void)callFlutterEchoNonNullEnumList:(nonnull NSArray *)enumList + completion:(nonnull void (^)(NSArray *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNonNullEnumList:enumList + completion:^(NSArray *value, FlutterError *error) { + completion(value, error); + }]; +} + +- (void)callFlutterEchoNonNullClassList:(nonnull NSArray *)classList + completion:(nonnull void (^)(NSArray *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNonNullClassList:classList + completion:^(NSArray *value, FlutterError *error) { + completion(value, error); + }]; +} + - (void)callFlutterEchoMap:(NSDictionary *)map completion: (void (^)(NSDictionary *_Nullable, FlutterError *_Nullable))completion { @@ -741,6 +796,53 @@ - (void)callFlutterEchoClassMap:(NSDictionary }]; } +- (void)callFlutterEchoNonNullStringMap:(nonnull NSDictionary *)stringMap + completion: + (nonnull void (^)(NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNonNullStringMap:stringMap + completion:^(NSDictionary *value, FlutterError *error) { + completion(value, error); + }]; +} + +- (void)callFlutterEchoNonNullIntMap:(nonnull NSDictionary *)intMap + completion: + (nonnull void (^)(NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNonNullIntMap:intMap + completion:^(NSDictionary *value, FlutterError *error) { + completion(value, error); + }]; +} + +- (void)callFlutterEchoNonNullEnumMap: + (nonnull NSDictionary *)enumMap + completion:(nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNonNullEnumMap:enumMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; +} + +- (void)callFlutterEchoNonNullClassMap: + (nonnull NSDictionary *)classMap + completion: + (nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNonNullClassMap:classMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; +} + - (void)callFlutterEchoEnum:(FLTAnEnum)anEnum completion:(void (^)(FLTAnEnumBox *_Nullable, FlutterError *_Nullable))completion { [self.flutterAPI echoEnum:anEnum @@ -854,23 +956,26 @@ - (void)callFlutterEchoNullableClassList:(nullable NSArray *)enumList - completion:(nonnull void (^)(NSArray *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI echoNonNullEnumList:enumList - completion:^(NSArray *value, FlutterError *error) { - completion(value, error); - }]; +- (void)callFlutterEchoNullableNonNullEnumList:(nullable NSArray *)enumList + completion: + (nonnull void (^)(NSArray *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNullableNonNullEnumList:enumList + completion:^(NSArray *value, FlutterError *error) { + completion(value, error); + }]; } -- (void)callFlutterEchoNonNullClassList:(nonnull NSArray *)classList - completion:(nonnull void (^)(NSArray *_Nullable, - FlutterError *_Nullable))completion { +- (void)callFlutterEchoNullableNonNullClassList:(nullable NSArray *)classList + completion:(nonnull void (^)( + NSArray *_Nullable, + FlutterError *_Nullable))completion { [self.flutterAPI - echoNonNullClassList:classList - completion:^(NSArray *value, FlutterError *error) { - completion(value, error); - }]; + echoNullableNonNullClassList:classList + completion:^(NSArray *value, FlutterError *error) { + completion(value, error); + }]; } - (void)callFlutterEchoNullableMap:(nullable NSDictionary *)map @@ -927,51 +1032,55 @@ - (void)callFlutterEchoNullableEnumMap: }]; } -- (void)callFlutterEchoNonNullStringMap:(nonnull NSDictionary *)stringMap - completion: - (nonnull void (^)(NSDictionary *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI - echoNonNullStringMap:stringMap - completion:^(NSDictionary *value, FlutterError *error) { - completion(value, error); - }]; +- (void)callFlutterEchoNullableNonNullStringMap: + (nullable NSDictionary *)stringMap + completion:(nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNullableNonNullStringMap:stringMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; } -- (void)callFlutterEchoNonNullIntMap:(nonnull NSDictionary *)intMap - completion: - (nonnull void (^)(NSDictionary *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI - echoNonNullIntMap:intMap - completion:^(NSDictionary *value, FlutterError *error) { - completion(value, error); - }]; +- (void)callFlutterEchoNullableNonNullIntMap:(nullable NSDictionary *)intMap + completion:(nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNullableNonNullIntMap:intMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; } -- (void)callFlutterEchoNonNullEnumMap: - (nonnull NSDictionary *)enumMap - completion:(nonnull void (^)( - NSDictionary *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI echoNonNullEnumMap:enumMap - completion:^(NSDictionary *value, - FlutterError *error) { - completion(value, error); - }]; +- (void)callFlutterEchoNullableNonNullEnumMap: + (nullable NSDictionary *)enumMap + completion: + (nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI echoNullableNonNullEnumMap:enumMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; } -- (void)callFlutterEchoNonNullClassMap: - (nonnull NSDictionary *)classMap - completion: - (nonnull void (^)( - NSDictionary *_Nullable, - FlutterError *_Nullable))completion { - [self.flutterAPI echoNonNullClassMap:classMap - completion:^(NSDictionary *value, - FlutterError *error) { - completion(value, error); - }]; +- (void) + callFlutterEchoNullableNonNullClassMap: + (nullable NSDictionary *)classMap + completion: + (nonnull void (^)( + NSDictionary *_Nullable, + FlutterError *_Nullable))completion { + [self.flutterAPI + echoNullableNonNullClassMap:classMap + completion:^(NSDictionary *value, + FlutterError *error) { + completion(value, error); + }]; } - (void)callFlutterEchoNullableEnum:(nullable FLTAnEnumBox *)AnEnumBoxed diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt index a0e8fb1a40e7..9563941624d7 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt @@ -241,6 +241,16 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { return classList } + override fun echoNullableNonNullEnumList(enumList: List?): List? { + return enumList + } + + override fun echoNullableNonNullClassList( + classList: List? + ): List? { + return classList + } + override fun echoNullableMap(map: Map?): Map? { return map } @@ -263,6 +273,24 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { return classMap } + override fun echoNullableNonNullStringMap(stringMap: Map?): Map? { + return stringMap + } + + override fun echoNullableNonNullIntMap(intMap: Map?): Map? { + return intMap + } + + override fun echoNullableNonNullEnumMap(enumMap: Map?): Map? { + return enumMap + } + + override fun echoNullableNonNullClassMap( + classMap: Map? + ): Map? { + return classMap + } + override fun echoNullableEnum(anEnum: AnEnum?): AnEnum? { return anEnum } @@ -718,6 +746,20 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { flutterApi!!.echoNullableClassList(classList) { echo -> callback(echo) } } + override fun callFlutterEchoNullableNonNullEnumList( + enumList: List?, + callback: (Result?>) -> Unit + ) { + flutterApi!!.echoNullableNonNullEnumList(enumList) { echo -> callback(echo) } + } + + override fun callFlutterEchoNullableNonNullClassList( + classList: List?, + callback: (Result?>) -> Unit + ) { + flutterApi!!.echoNullableNonNullClassList(classList) { echo -> callback(echo) } + } + override fun callFlutterEchoNullableMap( map: Map?, callback: (Result?>) -> Unit @@ -753,6 +795,34 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { flutterApi!!.echoNullableClassMap(classMap) { echo -> callback(echo) } } + override fun callFlutterEchoNullableNonNullStringMap( + stringMap: Map?, + callback: (Result?>) -> Unit + ) { + flutterApi!!.echoNullableNonNullStringMap(stringMap) { echo -> callback(echo) } + } + + override fun callFlutterEchoNullableNonNullIntMap( + intMap: Map?, + callback: (Result?>) -> Unit + ) { + flutterApi!!.echoNullableNonNullIntMap(intMap) { echo -> callback(echo) } + } + + override fun callFlutterEchoNullableNonNullEnumMap( + enumMap: Map?, + callback: (Result?>) -> Unit + ) { + flutterApi!!.echoNullableNonNullEnumMap(enumMap) { echo -> callback(echo) } + } + + override fun callFlutterEchoNullableNonNullClassMap( + classMap: Map?, + callback: (Result?>) -> Unit + ) { + flutterApi!!.echoNullableNonNullClassMap(classMap) { echo -> callback(echo) } + } + override fun callFlutterEchoNullableEnum(anEnum: AnEnum?, callback: (Result) -> Unit) { flutterApi!!.echoNullableEnum(anEnum) { echo -> callback(echo) } } diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift index e52532c4572b..f94d0be9effd 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift @@ -95,6 +95,14 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return classList } + func echoNonNull(enumList: [AnEnum]) throws -> [AnEnum] { + return enumList + } + + func echoNonNull(classList: [AllNullableTypes]) throws -> [AllNullableTypes] { + return classList + } + func echo(_ map: [AnyHashable?: Any?]) throws -> [AnyHashable?: Any?] { return map } @@ -115,6 +123,22 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return classMap } + func echoNonNull(stringMap: [String: String]) throws -> [String: String] { + return stringMap + } + + func echoNonNull(intMap: [Int64: Int64]) throws -> [Int64: Int64] { + return intMap + } + + func echoNonNull(enumMap: [AnEnum: AnEnum]) throws -> [AnEnum: AnEnum] { + return enumMap + } + + func echoNonNull(classMap: [Int64: AllNullableTypes]) throws -> [Int64: AllNullableTypes] { + return classMap + } + func echo(_ wrapper: AllClassesWrapper) throws -> AllClassesWrapper { return wrapper } @@ -201,11 +225,11 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return classList } - func echoNonNull(enumList: [AnEnum]) throws -> [AnEnum] { + func echoNullableNonNull(enumList: [AnEnum]?) throws -> [AnEnum]? { return enumList } - func echoNonNull(classList: [AllNullableTypes]) throws -> [AllNullableTypes] { + func echoNullableNonNull(classList: [AllNullableTypes]?) throws -> [AllNullableTypes]? { return classList } @@ -229,19 +253,21 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return classMap } - func echoNonNull(stringMap: [String: String]) throws -> [String: String] { + func echoNullableNonNull(stringMap: [String: String]?) throws -> [String: String]? { return stringMap } - func echoNonNull(intMap: [Int64: Int64]) throws -> [Int64: Int64] { + func echoNullableNonNull(intMap: [Int64: Int64]?) throws -> [Int64: Int64]? { return intMap } - func echoNonNull(enumMap: [AnEnum: AnEnum]) throws -> [AnEnum: AnEnum] { + func echoNullableNonNull(enumMap: [AnEnum: AnEnum]?) throws -> [AnEnum: AnEnum]? { return enumMap } - func echoNonNull(classMap: [Int64: AllNullableTypes]) throws -> [Int64: AllNullableTypes] { + func echoNullableNonNull(classMap: [Int64: AllNullableTypes]?) throws -> [Int64: + AllNullableTypes]? + { return classMap } @@ -677,6 +703,32 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } + func callFlutterEchoNonNull( + enumList: [AnEnum], completion: @escaping (Result<[AnEnum], Error>) -> Void + ) { + flutterAPI.echoNonNull(enumList: enumList) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + + func callFlutterEchoNonNull( + classList: [AllNullableTypes], completion: @escaping (Result<[AllNullableTypes], Error>) -> Void + ) { + flutterAPI.echoNonNull(classList: classList) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + func callFlutterEcho( _ map: [AnyHashable?: Any?], completion: @escaping (Result<[AnyHashable?: Any?], Error>) -> Void ) { @@ -743,6 +795,59 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } + func callFlutterEchoNonNull( + stringMap: [String: String], completion: @escaping (Result<[String: String], Error>) -> Void + ) { + flutterAPI.echoNonNull(stringMap: stringMap) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + + func callFlutterEchoNonNull( + intMap: [Int64: Int64], completion: @escaping (Result<[Int64: Int64], Error>) -> Void + ) { + flutterAPI.echoNonNull(intMap: intMap) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + + func callFlutterEchoNonNull( + enumMap: [AnEnum: AnEnum], completion: @escaping (Result<[AnEnum: AnEnum], Error>) -> Void + ) { + flutterAPI.echoNonNull(enumMap: enumMap) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + + func callFlutterEchoNonNull( + classMap: [Int64: AllNullableTypes], + completion: @escaping (Result<[Int64: AllNullableTypes], Error>) -> Void + ) { + flutterAPI.echoNonNull(classMap: classMap) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + func callFlutterEcho( _ anEnum: AnEnum, completion: @escaping (Result) -> Void ) { @@ -874,10 +979,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - enumList: [AnEnum], completion: @escaping (Result<[AnEnum], Error>) -> Void + func callFlutterEchoNullableNonNull( + enumList: [AnEnum]?, completion: @escaping (Result<[AnEnum]?, Error>) -> Void ) { - flutterAPI.echoNonNull(enumList: enumList) { response in + flutterAPI.echoNullableNonNull(enumList: enumList) { response in switch response { case .success(let res): completion(.success(res)) @@ -887,10 +992,11 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - classList: [AllNullableTypes], completion: @escaping (Result<[AllNullableTypes], Error>) -> Void + func callFlutterEchoNullableNonNull( + classList: [AllNullableTypes]?, + completion: @escaping (Result<[AllNullableTypes]?, Error>) -> Void ) { - flutterAPI.echoNonNull(classList: classList) { response in + flutterAPI.echoNullableNonNull(classList: classList) { response in switch response { case .success(let res): completion(.success(res)) @@ -968,10 +1074,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - stringMap: [String: String], completion: @escaping (Result<[String: String], Error>) -> Void + func callFlutterEchoNullableNonNull( + stringMap: [String: String]?, completion: @escaping (Result<[String: String]?, Error>) -> Void ) { - flutterAPI.echoNonNull(stringMap: stringMap) { response in + flutterAPI.echoNullableNonNull(stringMap: stringMap) { response in switch response { case .success(let res): completion(.success(res)) @@ -981,10 +1087,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - intMap: [Int64: Int64], completion: @escaping (Result<[Int64: Int64], Error>) -> Void + func callFlutterEchoNullableNonNull( + intMap: [Int64: Int64]?, completion: @escaping (Result<[Int64: Int64]?, Error>) -> Void ) { - flutterAPI.echoNonNull(intMap: intMap) { response in + flutterAPI.echoNullableNonNull(intMap: intMap) { response in switch response { case .success(let res): completion(.success(res)) @@ -994,10 +1100,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - enumMap: [AnEnum: AnEnum], completion: @escaping (Result<[AnEnum: AnEnum], Error>) -> Void + func callFlutterEchoNullableNonNull( + enumMap: [AnEnum: AnEnum]?, completion: @escaping (Result<[AnEnum: AnEnum]?, Error>) -> Void ) { - flutterAPI.echoNonNull(enumMap: enumMap) { response in + flutterAPI.echoNullableNonNull(enumMap: enumMap) { response in switch response { case .success(let res): completion(.success(res)) @@ -1007,11 +1113,11 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - classMap: [Int64: AllNullableTypes], - completion: @escaping (Result<[Int64: AllNullableTypes], Error>) -> Void + func callFlutterEchoNullableNonNull( + classMap: [Int64: AllNullableTypes]?, + completion: @escaping (Result<[Int64: AllNullableTypes]?, Error>) -> Void ) { - flutterAPI.echoNonNull(classMap: classMap) { response in + flutterAPI.echoNullableNonNull(classMap: classMap) { response in switch response { case .success(let res): completion(.success(res)) diff --git a/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc b/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc index 64ea447fc9b6..9f1ef2fbf494 100644 --- a/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc +++ b/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc @@ -375,6 +375,18 @@ echo_nullable_class_list(FlValue* class_list, gpointer user_data) { class_list); } +static CoreTestsPigeonTestHostIntegrationCoreApiEchoNullableNonNullEnumListResponse* +echo_nullable_non_null_enum_list(FlValue* enum_list, gpointer user_data) { + return core_tests_pigeon_test_host_integration_core_api_echo_nullable_non_null_enum_list_response_new( + enum_list); +} + +static CoreTestsPigeonTestHostIntegrationCoreApiEchoNullableNonNullClassListResponse* +echo_nullable_non_null_class_list(FlValue* class_list, gpointer user_data) { + return core_tests_pigeon_test_host_integration_core_api_echo_nullable_non_null_class_list_response_new( + class_list); +} + static CoreTestsPigeonTestHostIntegrationCoreApiEchoNullableMapResponse* echo_nullable_map(FlValue* map, gpointer user_data) { return core_tests_pigeon_test_host_integration_core_api_echo_nullable_map_response_new( @@ -405,6 +417,30 @@ echo_nullable_class_map(FlValue* class_map, gpointer user_data) { class_map); } +static CoreTestsPigeonTestHostIntegrationCoreApiEchoNullableNonNullStringMapResponse* +echo_nullable_non_null_string_map(FlValue* string_map, gpointer user_data) { + return core_tests_pigeon_test_host_integration_core_api_echo_nullable_non_null_string_map_response_new( + string_map); +} + +static CoreTestsPigeonTestHostIntegrationCoreApiEchoNullableNonNullIntMapResponse* +echo_nullable_non_null_int_map(FlValue* int_map, gpointer user_data) { + return core_tests_pigeon_test_host_integration_core_api_echo_nullable_non_null_int_map_response_new( + int_map); +} + +static CoreTestsPigeonTestHostIntegrationCoreApiEchoNullableNonNullEnumMapResponse* +echo_nullable_non_null_enum_map(FlValue* enum_map, gpointer user_data) { + return core_tests_pigeon_test_host_integration_core_api_echo_nullable_non_null_enum_map_response_new( + enum_map); +} + +static CoreTestsPigeonTestHostIntegrationCoreApiEchoNullableNonNullClassMapResponse* +echo_nullable_non_null_class_map(FlValue* class_map, gpointer user_data) { + return core_tests_pigeon_test_host_integration_core_api_echo_nullable_non_null_class_map_response_new( + class_map); +} + static CoreTestsPigeonTestHostIntegrationCoreApiEchoNullableEnumResponse* echo_nullable_enum(CoreTestsPigeonTestAnEnum* an_enum, gpointer user_data) { return core_tests_pigeon_test_host_integration_core_api_echo_nullable_enum_response_new( @@ -2446,6 +2482,102 @@ static void call_flutter_echo_nullable_class_list( echo_nullable_class_list_cb, callback_data_new(self, response_handle)); } +static void echo_nullable_non_null_enum_list_cb(GObject* object, + GAsyncResult* result, + gpointer user_data) { + g_autoptr(CallbackData) data = static_cast(user_data); + + g_autoptr(GError) error = nullptr; + g_autoptr( + CoreTestsPigeonTestFlutterIntegrationCoreApiEchoNullableNonNullEnumListResponse) + response = + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_list_finish( + CORE_TESTS_PIGEON_TEST_FLUTTER_INTEGRATION_CORE_API(object), + result, &error); + if (response == nullptr) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_nullable_non_null_enum_list( + data->response_handle, "Internal Error", error->message, nullptr); + return; + } + if (core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_list_response_is_error( + response)) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_bool( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_list_response_get_error_code( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_list_response_get_error_message( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_list_response_get_error_details( + response)); + return; + } + + core_tests_pigeon_test_host_integration_core_api_respond_call_flutter_echo_nullable_non_null_enum_list( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_list_response_get_return_value( + response)); +} + +static void call_flutter_echo_nullable_non_null_enum_list( + FlValue* enum_list, + CoreTestsPigeonTestHostIntegrationCoreApiResponseHandle* response_handle, + gpointer user_data) { + TestPlugin* self = TEST_PLUGIN(user_data); + + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_list( + self->flutter_core_api, enum_list, self->cancellable, + echo_nullable_non_null_enum_list_cb, + callback_data_new(self, response_handle)); +} + +static void echo_nullable_non_null_class_list_cb(GObject* object, + GAsyncResult* result, + gpointer user_data) { + g_autoptr(CallbackData) data = static_cast(user_data); + + g_autoptr(GError) error = nullptr; + g_autoptr( + CoreTestsPigeonTestFlutterIntegrationCoreApiEchoNullableNonNullClassListResponse) + response = + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_list_finish( + CORE_TESTS_PIGEON_TEST_FLUTTER_INTEGRATION_CORE_API(object), + result, &error); + if (response == nullptr) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_nullable_non_null_class_list( + data->response_handle, "Internal Error", error->message, nullptr); + return; + } + if (core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_list_response_is_error( + response)) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_bool( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_list_response_get_error_code( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_list_response_get_error_message( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_list_response_get_error_details( + response)); + return; + } + + core_tests_pigeon_test_host_integration_core_api_respond_call_flutter_echo_nullable_non_null_class_list( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_list_response_get_return_value( + response)); +} + +static void call_flutter_echo_nullable_non_null_class_list( + FlValue* class_list, + CoreTestsPigeonTestHostIntegrationCoreApiResponseHandle* response_handle, + gpointer user_data) { + TestPlugin* self = TEST_PLUGIN(user_data); + + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_list( + self->flutter_core_api, class_list, self->cancellable, + echo_nullable_non_null_class_list_cb, + callback_data_new(self, response_handle)); +} + static void echo_nullable_map_cb(GObject* object, GAsyncResult* result, gpointer user_data) { g_autoptr(CallbackData) data = static_cast(user_data); @@ -2675,6 +2807,198 @@ static void call_flutter_echo_nullable_class_map( echo_nullable_class_map_cb, callback_data_new(self, response_handle)); } +static void echo_nullable_non_null_string_map_cb(GObject* object, + GAsyncResult* result, + gpointer user_data) { + g_autoptr(CallbackData) data = static_cast(user_data); + + g_autoptr(GError) error = nullptr; + g_autoptr( + CoreTestsPigeonTestFlutterIntegrationCoreApiEchoNullableNonNullStringMapResponse) + response = + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_string_map_finish( + CORE_TESTS_PIGEON_TEST_FLUTTER_INTEGRATION_CORE_API(object), + result, &error); + if (response == nullptr) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_nullable_non_null_string_map( + data->response_handle, "Internal Error", error->message, nullptr); + return; + } + if (core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_string_map_response_is_error( + response)) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_bool( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_string_map_response_get_error_code( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_string_map_response_get_error_message( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_string_map_response_get_error_details( + response)); + return; + } + + core_tests_pigeon_test_host_integration_core_api_respond_call_flutter_echo_nullable_non_null_string_map( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_string_map_response_get_return_value( + response)); +} + +static void call_flutter_echo_nullable_non_null_string_map( + FlValue* string_map, + CoreTestsPigeonTestHostIntegrationCoreApiResponseHandle* response_handle, + gpointer user_data) { + TestPlugin* self = TEST_PLUGIN(user_data); + + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_string_map( + self->flutter_core_api, string_map, self->cancellable, + echo_nullable_non_null_string_map_cb, + callback_data_new(self, response_handle)); +} + +static void echo_nullable_non_null_int_map_cb(GObject* object, + GAsyncResult* result, + gpointer user_data) { + g_autoptr(CallbackData) data = static_cast(user_data); + + g_autoptr(GError) error = nullptr; + g_autoptr( + CoreTestsPigeonTestFlutterIntegrationCoreApiEchoNullableNonNullIntMapResponse) + response = + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_int_map_finish( + CORE_TESTS_PIGEON_TEST_FLUTTER_INTEGRATION_CORE_API(object), + result, &error); + if (response == nullptr) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_nullable_non_null_int_map( + data->response_handle, "Internal Error", error->message, nullptr); + return; + } + if (core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_int_map_response_is_error( + response)) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_bool( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_int_map_response_get_error_code( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_int_map_response_get_error_message( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_int_map_response_get_error_details( + response)); + return; + } + + core_tests_pigeon_test_host_integration_core_api_respond_call_flutter_echo_nullable_non_null_int_map( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_int_map_response_get_return_value( + response)); +} + +static void call_flutter_echo_nullable_non_null_int_map( + FlValue* int_map, + CoreTestsPigeonTestHostIntegrationCoreApiResponseHandle* response_handle, + gpointer user_data) { + TestPlugin* self = TEST_PLUGIN(user_data); + + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_int_map( + self->flutter_core_api, int_map, self->cancellable, + echo_nullable_non_null_int_map_cb, + callback_data_new(self, response_handle)); +} + +static void echo_nullable_non_null_enum_map_cb(GObject* object, + GAsyncResult* result, + gpointer user_data) { + g_autoptr(CallbackData) data = static_cast(user_data); + + g_autoptr(GError) error = nullptr; + g_autoptr( + CoreTestsPigeonTestFlutterIntegrationCoreApiEchoNullableNonNullEnumMapResponse) + response = + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_map_finish( + CORE_TESTS_PIGEON_TEST_FLUTTER_INTEGRATION_CORE_API(object), + result, &error); + if (response == nullptr) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_nullable_non_null_enum_map( + data->response_handle, "Internal Error", error->message, nullptr); + return; + } + if (core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_map_response_is_error( + response)) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_bool( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_map_response_get_error_code( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_map_response_get_error_message( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_map_response_get_error_details( + response)); + return; + } + + core_tests_pigeon_test_host_integration_core_api_respond_call_flutter_echo_nullable_non_null_enum_map( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_map_response_get_return_value( + response)); +} + +static void call_flutter_echo_nullable_non_null_enum_map( + FlValue* enum_map, + CoreTestsPigeonTestHostIntegrationCoreApiResponseHandle* response_handle, + gpointer user_data) { + TestPlugin* self = TEST_PLUGIN(user_data); + + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_map( + self->flutter_core_api, enum_map, self->cancellable, + echo_nullable_non_null_enum_map_cb, + callback_data_new(self, response_handle)); +} + +static void echo_nullable_non_null_class_map_cb(GObject* object, + GAsyncResult* result, + gpointer user_data) { + g_autoptr(CallbackData) data = static_cast(user_data); + + g_autoptr(GError) error = nullptr; + g_autoptr( + CoreTestsPigeonTestFlutterIntegrationCoreApiEchoNullableNonNullClassMapResponse) + response = + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_map_finish( + CORE_TESTS_PIGEON_TEST_FLUTTER_INTEGRATION_CORE_API(object), + result, &error); + if (response == nullptr) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_nullable_non_null_class_map( + data->response_handle, "Internal Error", error->message, nullptr); + return; + } + if (core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_map_response_is_error( + response)) { + core_tests_pigeon_test_host_integration_core_api_respond_error_call_flutter_echo_bool( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_map_response_get_error_code( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_map_response_get_error_message( + response), + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_map_response_get_error_details( + response)); + return; + } + + core_tests_pigeon_test_host_integration_core_api_respond_call_flutter_echo_nullable_non_null_class_map( + data->response_handle, + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_map_response_get_return_value( + response)); +} + +static void call_flutter_echo_nullable_non_null_class_map( + FlValue* class_map, + CoreTestsPigeonTestHostIntegrationCoreApiResponseHandle* response_handle, + gpointer user_data) { + TestPlugin* self = TEST_PLUGIN(user_data); + + core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class_map( + self->flutter_core_api, class_map, self->cancellable, + echo_nullable_non_null_class_map_cb, + callback_data_new(self, response_handle)); +} + static void echo_nullable_enum_cb(GObject* object, GAsyncResult* result, gpointer user_data) { g_autoptr(CallbackData) data = static_cast(user_data); @@ -2899,11 +3223,17 @@ static CoreTestsPigeonTestHostIntegrationCoreApiVTable host_core_api_vtable = { .echo_nullable_list = echo_nullable_list, .echo_nullable_enum_list = echo_nullable_enum_list, .echo_nullable_class_list = echo_nullable_class_list, + .echo_nullable_non_null_enum_list = echo_nullable_non_null_enum_list, + .echo_nullable_non_null_class_list = echo_nullable_non_null_class_list, .echo_nullable_map = echo_nullable_map, .echo_nullable_string_map = echo_nullable_string_map, .echo_nullable_int_map = echo_nullable_int_map, .echo_nullable_enum_map = echo_nullable_enum_map, .echo_nullable_class_map = echo_nullable_class_map, + .echo_nullable_non_null_string_map = echo_nullable_non_null_string_map, + .echo_nullable_non_null_int_map = echo_nullable_non_null_int_map, + .echo_nullable_non_null_enum_map = echo_nullable_non_null_enum_map, + .echo_nullable_non_null_class_map = echo_nullable_non_null_class_map, .echo_nullable_enum = echo_nullable_enum, .echo_another_nullable_enum = echo_another_nullable_enum, .echo_optional_nullable_int = echo_optional_nullable_int, @@ -2997,6 +3327,10 @@ static CoreTestsPigeonTestHostIntegrationCoreApiVTable host_core_api_vtable = { call_flutter_echo_nullable_enum_list, .call_flutter_echo_nullable_class_list = call_flutter_echo_nullable_class_list, + .call_flutter_echo_nullable_non_null_enum_list = + call_flutter_echo_nullable_non_null_enum_list, + .call_flutter_echo_nullable_non_null_class_list = + call_flutter_echo_nullable_non_null_class_list, .call_flutter_echo_nullable_map = call_flutter_echo_nullable_map, .call_flutter_echo_nullable_string_map = call_flutter_echo_nullable_string_map, @@ -3004,6 +3338,14 @@ static CoreTestsPigeonTestHostIntegrationCoreApiVTable host_core_api_vtable = { .call_flutter_echo_nullable_enum_map = call_flutter_echo_nullable_enum_map, .call_flutter_echo_nullable_class_map = call_flutter_echo_nullable_class_map, + .call_flutter_echo_nullable_non_null_string_map = + call_flutter_echo_nullable_non_null_string_map, + .call_flutter_echo_nullable_non_null_int_map = + call_flutter_echo_nullable_non_null_int_map, + .call_flutter_echo_nullable_non_null_enum_map = + call_flutter_echo_nullable_non_null_enum_map, + .call_flutter_echo_nullable_non_null_class_map = + call_flutter_echo_nullable_non_null_class_map, .call_flutter_echo_nullable_enum = call_flutter_echo_nullable_enum, .call_flutter_echo_another_nullable_enum = call_flutter_echo_another_nullable_enum, diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift index 9e3dcdd0075b..3244d62b8386 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift @@ -94,6 +94,14 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return classList } + func echoNonNull(enumList: [AnEnum]) throws -> [AnEnum] { + return enumList + } + + func echoNonNull(classList: [AllNullableTypes]) throws -> [AllNullableTypes] { + return classList + } + func echo(_ map: [AnyHashable?: Any?]) throws -> [AnyHashable?: Any?] { return map } @@ -114,6 +122,22 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return classMap } + func echoNonNull(stringMap: [String: String]) throws -> [String: String] { + return stringMap + } + + func echoNonNull(intMap: [Int64: Int64]) throws -> [Int64: Int64] { + return intMap + } + + func echoNonNull(enumMap: [AnEnum: AnEnum]) throws -> [AnEnum: AnEnum] { + return enumMap + } + + func echoNonNull(classMap: [Int64: AllNullableTypes]) throws -> [Int64: AllNullableTypes] { + return classMap + } + func echo(_ wrapper: AllClassesWrapper) throws -> AllClassesWrapper { return wrapper } @@ -200,11 +224,11 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return classList } - func echoNonNull(enumList: [AnEnum]) throws -> [AnEnum] { + func echoNullableNonNull(enumList: [AnEnum]?) throws -> [AnEnum]? { return enumList } - func echoNonNull(classList: [AllNullableTypes]) throws -> [AllNullableTypes] { + func echoNullableNonNull(classList: [AllNullableTypes]?) throws -> [AllNullableTypes]? { return classList } @@ -228,19 +252,21 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return classMap } - func echoNonNull(stringMap: [String: String]) throws -> [String: String] { + func echoNullableNonNull(stringMap: [String: String]?) throws -> [String: String]? { return stringMap } - func echoNonNull(intMap: [Int64: Int64]) throws -> [Int64: Int64] { + func echoNullableNonNull(intMap: [Int64: Int64]?) throws -> [Int64: Int64]? { return intMap } - func echoNonNull(enumMap: [AnEnum: AnEnum]) throws -> [AnEnum: AnEnum] { + func echoNullableNonNull(enumMap: [AnEnum: AnEnum]?) throws -> [AnEnum: AnEnum]? { return enumMap } - func echoNonNull(classMap: [Int64: AllNullableTypes]) throws -> [Int64: AllNullableTypes] { + func echoNullableNonNull(classMap: [Int64: AllNullableTypes]?) throws -> [Int64: + AllNullableTypes]? + { return classMap } @@ -676,6 +702,32 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } + func callFlutterEchoNonNull( + enumList: [AnEnum], completion: @escaping (Result<[AnEnum], Error>) -> Void + ) { + flutterAPI.echoNonNull(enumList: enumList) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + + func callFlutterEchoNonNull( + classList: [AllNullableTypes], completion: @escaping (Result<[AllNullableTypes], Error>) -> Void + ) { + flutterAPI.echoNonNull(classList: classList) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + func callFlutterEcho( _ map: [AnyHashable?: Any?], completion: @escaping (Result<[AnyHashable?: Any?], Error>) -> Void ) { @@ -742,6 +794,59 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } + func callFlutterEchoNonNull( + stringMap: [String: String], completion: @escaping (Result<[String: String], Error>) -> Void + ) { + flutterAPI.echoNonNull(stringMap: stringMap) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + + func callFlutterEchoNonNull( + intMap: [Int64: Int64], completion: @escaping (Result<[Int64: Int64], Error>) -> Void + ) { + flutterAPI.echoNonNull(intMap: intMap) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + + func callFlutterEchoNonNull( + enumMap: [AnEnum: AnEnum], completion: @escaping (Result<[AnEnum: AnEnum], Error>) -> Void + ) { + flutterAPI.echoNonNull(enumMap: enumMap) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + + func callFlutterEchoNonNull( + classMap: [Int64: AllNullableTypes], + completion: @escaping (Result<[Int64: AllNullableTypes], Error>) -> Void + ) { + flutterAPI.echoNonNull(classMap: classMap) { response in + switch response { + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } + } + } + func callFlutterEcho( _ anEnum: AnEnum, completion: @escaping (Result) -> Void ) { @@ -873,10 +978,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - enumList: [AnEnum], completion: @escaping (Result<[AnEnum], Error>) -> Void + func callFlutterEchoNullableNonNull( + enumList: [AnEnum]?, completion: @escaping (Result<[AnEnum]?, Error>) -> Void ) { - flutterAPI.echoNonNull(enumList: enumList) { response in + flutterAPI.echoNullableNonNull(enumList: enumList) { response in switch response { case .success(let res): completion(.success(res)) @@ -886,10 +991,11 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - classList: [AllNullableTypes], completion: @escaping (Result<[AllNullableTypes], Error>) -> Void + func callFlutterEchoNullableNonNull( + classList: [AllNullableTypes]?, + completion: @escaping (Result<[AllNullableTypes]?, Error>) -> Void ) { - flutterAPI.echoNonNull(classList: classList) { response in + flutterAPI.echoNullableNonNull(classList: classList) { response in switch response { case .success(let res): completion(.success(res)) @@ -967,10 +1073,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - stringMap: [String: String], completion: @escaping (Result<[String: String], Error>) -> Void + func callFlutterEchoNullableNonNull( + stringMap: [String: String]?, completion: @escaping (Result<[String: String]?, Error>) -> Void ) { - flutterAPI.echoNonNull(stringMap: stringMap) { response in + flutterAPI.echoNullableNonNull(stringMap: stringMap) { response in switch response { case .success(let res): completion(.success(res)) @@ -980,10 +1086,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - intMap: [Int64: Int64], completion: @escaping (Result<[Int64: Int64], Error>) -> Void + func callFlutterEchoNullableNonNull( + intMap: [Int64: Int64]?, completion: @escaping (Result<[Int64: Int64]?, Error>) -> Void ) { - flutterAPI.echoNonNull(intMap: intMap) { response in + flutterAPI.echoNullableNonNull(intMap: intMap) { response in switch response { case .success(let res): completion(.success(res)) @@ -993,10 +1099,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - enumMap: [AnEnum: AnEnum], completion: @escaping (Result<[AnEnum: AnEnum], Error>) -> Void + func callFlutterEchoNullableNonNull( + enumMap: [AnEnum: AnEnum]?, completion: @escaping (Result<[AnEnum: AnEnum]?, Error>) -> Void ) { - flutterAPI.echoNonNull(enumMap: enumMap) { response in + flutterAPI.echoNullableNonNull(enumMap: enumMap) { response in switch response { case .success(let res): completion(.success(res)) @@ -1006,11 +1112,11 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoNonNull( - classMap: [Int64: AllNullableTypes], - completion: @escaping (Result<[Int64: AllNullableTypes], Error>) -> Void + func callFlutterEchoNullableNonNull( + classMap: [Int64: AllNullableTypes]?, + completion: @escaping (Result<[Int64: AllNullableTypes]?, Error>) -> Void ) { - flutterAPI.echoNonNull(classMap: classMap) { response in + flutterAPI.echoNullableNonNull(classMap: classMap) { response in switch response { case .success(let res): completion(.success(res)) diff --git a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp index 1d9e8216190f..c6f69c0a8c07 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp +++ b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp @@ -357,6 +357,22 @@ ErrorOr> TestPlugin::EchoNullableClassList( return *class_list; }; +ErrorOr> TestPlugin::EchoNullableNonNullEnumList( + const EncodableList* enum_list) { + if (!enum_list) { + return std::nullopt; + } + return *enum_list; +}; + +ErrorOr> TestPlugin::EchoNullableNonNullClassList( + const EncodableList* class_list) { + if (!class_list) { + return std::nullopt; + } + return *class_list; +}; + ErrorOr> TestPlugin::EchoNullableMap( const EncodableMap* map) { if (!map) { @@ -397,6 +413,38 @@ ErrorOr> TestPlugin::EchoNullableClassMap( return *class_map; }; +ErrorOr> TestPlugin::EchoNullableNonNullStringMap( + const EncodableMap* string_map) { + if (!string_map) { + return std::nullopt; + } + return *string_map; +}; + +ErrorOr> TestPlugin::EchoNullableNonNullIntMap( + const EncodableMap* int_map) { + if (!int_map) { + return std::nullopt; + } + return *int_map; +}; + +ErrorOr> TestPlugin::EchoNullableNonNullEnumMap( + const EncodableMap* enum_map) { + if (!enum_map) { + return std::nullopt; + } + return *enum_map; +}; + +ErrorOr> TestPlugin::EchoNullableNonNullClassMap( + const EncodableMap* class_map) { + if (!class_map) { + return std::nullopt; + } + return *class_map; +}; + ErrorOr> TestPlugin::EchoNullableEnum( const AnEnum* an_enum) { if (!an_enum) { @@ -995,6 +1043,28 @@ void TestPlugin::CallFlutterEchoNullableClassList( [result](const FlutterError& error) { result(error); }); } +void TestPlugin::CallFlutterEchoNullableNonNullEnumList( + const EncodableList* enum_list, + std::function> reply)> result) { + flutter_api_->EchoNullableNonNullEnumList( + enum_list, + [result](const EncodableList* echo) { + result(echo ? std::optional(*echo) : std::nullopt); + }, + [result](const FlutterError& error) { result(error); }); +} + +void TestPlugin::CallFlutterEchoNullableNonNullClassList( + const EncodableList* class_list, + std::function> reply)> result) { + flutter_api_->EchoNullableNonNullClassList( + class_list, + [result](const EncodableList* echo) { + result(echo ? std::optional(*echo) : std::nullopt); + }, + [result](const FlutterError& error) { result(error); }); +} + void TestPlugin::CallFlutterEchoNullableMap( const EncodableMap* map, std::function> reply)> result) { @@ -1050,6 +1120,50 @@ void TestPlugin::CallFlutterEchoNullableClassMap( [result](const FlutterError& error) { result(error); }); } +void TestPlugin::CallFlutterEchoNullableNonNullStringMap( + const EncodableMap* string_map, + std::function> reply)> result) { + flutter_api_->EchoNullableNonNullStringMap( + string_map, + [result](const EncodableMap* echo) { + result(echo ? std::optional(*echo) : std::nullopt); + }, + [result](const FlutterError& error) { result(error); }); +} + +void TestPlugin::CallFlutterEchoNullableNonNullIntMap( + const EncodableMap* int_map, + std::function> reply)> result) { + flutter_api_->EchoNullableNonNullIntMap( + int_map, + [result](const EncodableMap* echo) { + result(echo ? std::optional(*echo) : std::nullopt); + }, + [result](const FlutterError& error) { result(error); }); +} + +void TestPlugin::CallFlutterEchoNullableNonNullEnumMap( + const EncodableMap* enum_map, + std::function> reply)> result) { + flutter_api_->EchoNullableNonNullEnumMap( + enum_map, + [result](const EncodableMap* echo) { + result(echo ? std::optional(*echo) : std::nullopt); + }, + [result](const FlutterError& error) { result(error); }); +} + +void TestPlugin::CallFlutterEchoNullableNonNullClassMap( + const EncodableMap* class_map, + std::function> reply)> result) { + flutter_api_->EchoNullableNonNullClassMap( + class_map, + [result](const EncodableMap* echo) { + result(echo ? std::optional(*echo) : std::nullopt); + }, + [result](const FlutterError& error) { result(error); }); +} + void TestPlugin::CallFlutterEchoNullableEnum( const AnEnum* an_enum, std::function> reply)> result) { diff --git a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h index dfaa55995f68..cabbe665ed58 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h +++ b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h @@ -154,6 +154,11 @@ class TestPlugin : public flutter::Plugin, EchoNullableEnumList(const flutter::EncodableList* enum_list) override; core_tests_pigeontest::ErrorOr> EchoNullableClassList(const flutter::EncodableList* class_list) override; + core_tests_pigeontest::ErrorOr> + EchoNullableNonNullEnumList(const flutter::EncodableList* enum_list) override; + core_tests_pigeontest::ErrorOr> + EchoNullableNonNullClassList( + const flutter::EncodableList* class_list) override; core_tests_pigeontest::ErrorOr> EchoNullableMap(const flutter::EncodableMap* map) override; core_tests_pigeontest::ErrorOr> @@ -164,6 +169,15 @@ class TestPlugin : public flutter::Plugin, EchoNullableEnumMap(const flutter::EncodableMap* enum_map) override; core_tests_pigeontest::ErrorOr> EchoNullableClassMap(const flutter::EncodableMap* class_map) override; + core_tests_pigeontest::ErrorOr> + EchoNullableNonNullStringMap( + const flutter::EncodableMap* string_map) override; + core_tests_pigeontest::ErrorOr> + EchoNullableNonNullIntMap(const flutter::EncodableMap* int_map) override; + core_tests_pigeontest::ErrorOr> + EchoNullableNonNullEnumMap(const flutter::EncodableMap* enum_map) override; + core_tests_pigeontest::ErrorOr> + EchoNullableNonNullClassMap(const flutter::EncodableMap* class_map) override; core_tests_pigeontest::ErrorOr> EchoNullableEnum(const core_tests_pigeontest::AnEnum* an_enum) override; core_tests_pigeontest::ErrorOr< @@ -572,6 +586,18 @@ class TestPlugin : public flutter::Plugin, core_tests_pigeontest::ErrorOr> reply)> result) override; + void CallFlutterEchoNullableNonNullEnumList( + const flutter::EncodableList* enum_list, + std::function> + reply)> + result) override; + void CallFlutterEchoNullableNonNullClassList( + const flutter::EncodableList* class_list, + std::function> + reply)> + result) override; void CallFlutterEchoNullableMap( const flutter::EncodableMap* map, std::function> reply)> result) override; + void CallFlutterEchoNullableNonNullStringMap( + const flutter::EncodableMap* string_map, + std::function> + reply)> + result) override; + void CallFlutterEchoNullableNonNullIntMap( + const flutter::EncodableMap* int_map, + std::function> + reply)> + result) override; + void CallFlutterEchoNullableNonNullEnumMap( + const flutter::EncodableMap* enum_map, + std::function> + reply)> + result) override; + void CallFlutterEchoNullableNonNullClassMap( + const flutter::EncodableMap* class_map, + std::function> + reply)> + result) override; void CallFlutterEchoNullableEnum( const core_tests_pigeontest::AnEnum* an_enum, std::function