[pigeon] added support for explicit objects (#483)
diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md
index 9181db8..33ed27c 100644
--- a/packages/pigeon/CHANGELOG.md
+++ b/packages/pigeon/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 1.0.8
+
+* [front-end] Started accepting explicit Object references in type arguments.
+* [codecs] Fixed nuisance where duplicate entries could show up in custom codecs.
+
## 1.0.7
* [front-end] Fixed bug where nested classes' type arguments aren't included in
diff --git a/packages/pigeon/lib/ast.dart b/packages/pigeon/lib/ast.dart
index 8ad4ccf..f4da018 100644
--- a/packages/pigeon/lib/ast.dart
+++ b/packages/pigeon/lib/ast.dart
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:collection/collection.dart' show ListEquality;
+import 'package:meta/meta.dart';
+
+final Function _listEquals = const ListEquality<dynamic>().equals;
+
/// Enum that represents where an [Api] is located, on the host or Flutter.
enum ApiLocation {
/// The API is for calling functions defined on the host.
@@ -79,16 +84,17 @@
}
/// A specific instance of a type.
+@immutable
class TypeDeclaration {
/// Constructor for [TypeDeclaration].
- TypeDeclaration({
+ const TypeDeclaration({
required this.baseName,
required this.isNullable,
this.typeArguments = const <TypeDeclaration>[],
});
/// Void constructor.
- TypeDeclaration.voidDeclaration()
+ const TypeDeclaration.voidDeclaration()
: baseName = 'void',
isNullable = false,
typeArguments = const <TypeDeclaration>[];
@@ -106,6 +112,31 @@
final bool isNullable;
@override
+ int get hashCode {
+ // This has to be implemented because TypeDeclaration is used as a Key to a
+ // Map in generator_tools.dart.
+ int hash = 17;
+ hash = hash * 37 + baseName.hashCode;
+ hash = hash * 37 + isNullable.hashCode;
+ for (final TypeDeclaration typeArgument in typeArguments) {
+ hash = hash * 37 + typeArgument.hashCode;
+ }
+ return hash;
+ }
+
+ @override
+ bool operator ==(Object other) {
+ if (other.runtimeType != runtimeType) {
+ return false;
+ } else {
+ return other is TypeDeclaration &&
+ baseName == other.baseName &&
+ isNullable == other.isNullable &&
+ _listEquals(typeArguments, other.typeArguments);
+ }
+ }
+
+ @override
String toString() {
return '(TypeDeclaration baseName:$baseName isNullable:$isNullable typeArguments:$typeArguments)';
}
diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart
index cb74607..8164d24 100644
--- a/packages/pigeon/lib/generator_tools.dart
+++ b/packages/pigeon/lib/generator_tools.dart
@@ -8,7 +8,7 @@
import 'ast.dart';
/// The current version of pigeon. This must match the version in pubspec.yaml.
-const String pigeonVersion = '1.0.7';
+const String pigeonVersion = '1.0.8';
/// Read all the content from [stdin] to a String.
String readStdin() {
@@ -275,6 +275,7 @@
'Float64List',
'List',
'Map',
+ 'Object',
];
/// Custom codecs' custom types are enumerated from 255 down to this number to
diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart
index 1d21c5e..da9c4be 100644
--- a/packages/pigeon/lib/objc_generator.dart
+++ b/packages/pigeon/lib/objc_generator.dart
@@ -62,48 +62,58 @@
}
}
-String _callbackForType(TypeDeclaration type, String objcType) {
+String _callbackForType(TypeDeclaration type, _ObjcPtr objcType) {
return type.isVoid
? 'void(^)(NSError *_Nullable)'
- : 'void(^)($objcType *, NSError *_Nullable)';
+ : 'void(^)(${objcType.ptr.trim()}, NSError *_Nullable)';
}
-const Map<String, String> _objcTypeForDartTypeMap = <String, String>{
- 'bool': 'NSNumber',
- 'int': 'NSNumber',
- 'String': 'NSString',
- 'double': 'NSNumber',
- 'Uint8List': 'FlutterStandardTypedData',
- 'Int32List': 'FlutterStandardTypedData',
- 'Int64List': 'FlutterStandardTypedData',
- 'Float64List': 'FlutterStandardTypedData',
- 'List': 'NSArray',
- 'Map': 'NSDictionary',
+class _ObjcPtr {
+ const _ObjcPtr({required this.baseName}) : hasAsterisk = baseName != 'id';
+ final String baseName;
+ final bool hasAsterisk;
+ String get ptr => '$baseName${hasAsterisk ? ' *' : ' '}';
+}
+
+const Map<String, _ObjcPtr> _objcTypeForDartTypeMap = <String, _ObjcPtr>{
+ 'bool': _ObjcPtr(baseName: 'NSNumber'),
+ 'int': _ObjcPtr(baseName: 'NSNumber'),
+ 'String': _ObjcPtr(baseName: 'NSString'),
+ 'double': _ObjcPtr(baseName: 'NSNumber'),
+ 'Uint8List': _ObjcPtr(baseName: 'FlutterStandardTypedData'),
+ 'Int32List': _ObjcPtr(baseName: 'FlutterStandardTypedData'),
+ 'Int64List': _ObjcPtr(baseName: 'FlutterStandardTypedData'),
+ 'Float64List': _ObjcPtr(baseName: 'FlutterStandardTypedData'),
+ 'List': _ObjcPtr(baseName: 'NSArray'),
+ 'Map': _ObjcPtr(baseName: 'NSDictionary'),
+ 'Object': _ObjcPtr(baseName: 'id'),
};
String _flattenTypeArguments(String? classPrefix, List<TypeDeclaration> args) {
final String result = args
- .map<String>(
- (TypeDeclaration e) => '${_objcTypeForDartType(classPrefix, e)} *')
+ .map<String>((TypeDeclaration e) =>
+ _objcTypeForDartType(classPrefix, e).ptr.trim())
.join(', ');
return result;
}
String? _objcTypePtrForPrimitiveDartType(String? classPrefix, NamedType field) {
return _objcTypeForDartTypeMap.containsKey(field.type.baseName)
- ? '${_objcTypeForDartType(classPrefix, field.type)} *'
+ ? _objcTypeForDartType(classPrefix, field.type).ptr
: null;
}
/// Returns the objc type for a dart [type], prepending the [classPrefix] for
/// generated classes. For example:
/// _objcTypeForDartType(null, 'int') => 'NSNumber'.
-String _objcTypeForDartType(String? classPrefix, TypeDeclaration field) {
+_ObjcPtr _objcTypeForDartType(String? classPrefix, TypeDeclaration field) {
return _objcTypeForDartTypeMap.containsKey(field.baseName)
? field.typeArguments.isEmpty
? _objcTypeForDartTypeMap[field.baseName]!
- : '${_objcTypeForDartTypeMap[field.baseName]}<${_flattenTypeArguments(classPrefix, field.typeArguments)}>'
- : _className(classPrefix, field.baseName);
+ : _ObjcPtr(
+ baseName:
+ '${_objcTypeForDartTypeMap[field.baseName]!.baseName}<${_flattenTypeArguments(classPrefix, field.typeArguments)}>')
+ : _ObjcPtr(baseName: _className(classPrefix, field.baseName));
}
String _propertyTypeForDartType(NamedType field) {
@@ -293,8 +303,8 @@
final Iterable<String> argTypes = followedByOne(
func.arguments.map((NamedType arg) {
final String nullable = func.isAsynchronous ? 'nullable ' : '';
- final String argType = _objcTypeForDartType(options.prefix, arg.type);
- return '$nullable$argType *';
+ final _ObjcPtr argType = _objcTypeForDartType(options.prefix, arg.type);
+ return '$nullable${argType.ptr.trim()}';
}),
lastArgType,
);
@@ -313,7 +323,7 @@
final String apiName = _className(options.prefix, api.name);
indent.writeln('@protocol $apiName');
for (final Method func in api.methods) {
- final String returnTypeName =
+ final _ObjcPtr returnTypeName =
_objcTypeForDartType(options.prefix, func.returnType);
String? lastArgName;
@@ -326,12 +336,13 @@
lastArgName = 'completion';
} else {
lastArgType =
- 'void(^)($returnTypeName *_Nullable, FlutterError *_Nullable)';
+ 'void(^)(${returnTypeName.ptr}_Nullable, FlutterError *_Nullable)';
lastArgName = 'completion';
}
} else {
- returnType =
- func.returnType.isVoid ? 'void' : 'nullable $returnTypeName *';
+ returnType = func.returnType.isVoid
+ ? 'void'
+ : 'nullable ${returnTypeName.ptr.trim()}';
lastArgType = 'FlutterError *_Nullable *_Nonnull';
lastArgName = 'error';
}
@@ -356,7 +367,7 @@
indent.writeln(
'- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger;');
for (final Method func in api.methods) {
- final String returnType =
+ final _ObjcPtr returnType =
_objcTypeForDartType(options.prefix, func.returnType);
final String callbackType = _callbackForType(func.returnType, returnType);
indent.writeln(_makeObjcSignature(
@@ -492,7 +503,7 @@
indent.write(
'[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) ');
indent.scoped('{', '}];', () {
- final String returnType =
+ final _ObjcPtr returnType =
_objcTypeForDartType(options.prefix, func.returnType);
String syncCall;
String? callSignature;
@@ -506,9 +517,9 @@
indexMap(func.arguments, _getSafeArgName);
map3(wholeNumbers.take(func.arguments.length), argNames,
func.arguments, (int count, String argName, NamedType arg) {
- final String argType =
+ final _ObjcPtr argType =
_objcTypeForDartType(options.prefix, arg.type);
- return '$argType *$argName = args[$count];';
+ return '${argType.ptr}$argName = args[$count];';
}).forEach(indent.writeln);
callSignature =
map2(selectorComponents.take(argNames.length), argNames,
@@ -537,13 +548,13 @@
const String callback = 'callback(wrapResult(output, error));';
if (func.arguments.isEmpty) {
indent.writeScoped(
- '[api ${selectorComponents.first}:^($returnType *_Nullable output, FlutterError *_Nullable error) {',
+ '[api ${selectorComponents.first}:^(${returnType.ptr}_Nullable output, FlutterError *_Nullable error) {',
'}];', () {
indent.writeln(callback);
});
} else {
indent.writeScoped(
- '[api $callSignature ${selectorComponents.last}:^($returnType *_Nullable output, FlutterError *_Nullable error) {',
+ '[api $callSignature ${selectorComponents.last}:^(${returnType.ptr}_Nullable output, FlutterError *_Nullable error) {',
'}];', () {
indent.writeln(callback);
});
@@ -555,7 +566,7 @@
indent.writeln('$syncCall;');
indent.writeln('callback(wrapResult(nil, error));');
} else {
- indent.writeln('$returnType *output = $syncCall;');
+ indent.writeln('${returnType.ptr}output = $syncCall;');
indent.writeln('callback(wrapResult(output, error));');
}
}
@@ -591,7 +602,7 @@
});
indent.addln('');
for (final Method func in api.methods) {
- final String returnType =
+ final _ObjcPtr returnType =
_objcTypeForDartType(options.prefix, func.returnType);
final String callbackType = _callbackForType(func.returnType, returnType);
@@ -627,7 +638,7 @@
if (func.returnType.isVoid) {
indent.writeln('completion(nil);');
} else {
- indent.writeln('$returnType *output = reply;');
+ indent.writeln('${returnType.ptr}output = reply;');
indent.writeln('completion(output, nil);');
}
});
diff --git a/packages/pigeon/lib/pigeon_lib.dart b/packages/pigeon/lib/pigeon_lib.dart
index 3c29fc7..439f5cd 100644
--- a/packages/pigeon/lib/pigeon_lib.dart
+++ b/packages/pigeon/lib/pigeon_lib.dart
@@ -565,6 +565,7 @@
!validTypes.contains(element.key.baseName) &&
!element.key.isVoid &&
element.key.baseName != 'dynamic' &&
+ element.key.baseName != 'Object' &&
element.key.baseName.isNotEmpty) {
final int? lineNumber = element.value.isEmpty
? null
@@ -709,7 +710,7 @@
} else {
return NamedType(
name: '',
- type: TypeDeclaration(baseName: '', isNullable: false),
+ type: const TypeDeclaration(baseName: '', isNullable: false),
offset: parameter.offset,
);
}
diff --git a/packages/pigeon/pigeons/all_datatypes.dart b/packages/pigeon/pigeons/all_datatypes.dart
index 138b4ca..8a260d2 100644
--- a/packages/pigeon/pigeons/all_datatypes.dart
+++ b/packages/pigeon/pigeons/all_datatypes.dart
@@ -19,6 +19,7 @@
Map? aMap;
List<List<bool?>?>? nestedList;
Map<String?, String?>? mapWithAnnotations;
+ Map<String?, Object?>? mapWithObject;
}
@HostApi()
diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/test/java/com/example/android_unit_tests/AllDatatypesTest.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/test/java/com/example/android_unit_tests/AllDatatypesTest.java
index b6a8cf1..6cef5dd 100644
--- a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/test/java/com/example/android_unit_tests/AllDatatypesTest.java
+++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/test/java/com/example/android_unit_tests/AllDatatypesTest.java
@@ -51,6 +51,7 @@
assertNull(everything.getAFloatArray());
assertNull(everything.getAList());
assertNull(everything.getAMap());
+ assertNull(everything.getMapWithObject());
});
assertTrue(didCall[0]);
}
@@ -61,6 +62,12 @@
return result;
}
+ private static HashMap<String, Object> makeStringMap(String key, Integer value) {
+ HashMap<String, Object> result = new HashMap<String, Object>();
+ result.put(key, value);
+ return result;
+ }
+
private static boolean floatArraysEqual(double[] x, double[] y) {
if (x.length != y.length) {
return false;
@@ -86,6 +93,7 @@
everything.setAFloatArray(new double[] {0.5, 0.25, 1.5, 1.25});
everything.setAList(Arrays.asList(new int[] {1, 2, 3}));
everything.setAMap(makeMap("hello", 1234));
+ everything.setMapWithObject(makeStringMap("hello", 1234));
BinaryMessenger binaryMessenger = mock(BinaryMessenger.class);
doAnswer(
invocation -> {
@@ -120,6 +128,9 @@
everything.getAMap().keySet().toArray(), result.getAMap().keySet().toArray());
assertArrayEquals(
everything.getAMap().values().toArray(), result.getAMap().values().toArray());
+ assertArrayEquals(
+ everything.getMapWithObject().values().toArray(),
+ result.getMapWithObject().values().toArray());
});
assertTrue(didCall[0]);
}
diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart
index 4c983f3..06ba8f5 100644
--- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart
+++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Autogenerated from Pigeon (v0.3.0), do not edit directly.
+// Autogenerated from Pigeon (v1.0.8), 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
// @dart = 2.12
@@ -25,6 +25,7 @@
Map<Object?, Object?>? aMap;
List<List<bool?>?>? nestedList;
Map<String?, String?>? mapWithAnnotations;
+ Map<String?, Object?>? mapWithObject;
Object encode() {
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
@@ -40,6 +41,7 @@
pigeonMap['aMap'] = aMap;
pigeonMap['nestedList'] = nestedList;
pigeonMap['mapWithAnnotations'] = mapWithAnnotations;
+ pigeonMap['mapWithObject'] = mapWithObject;
return pigeonMap;
}
@@ -60,7 +62,9 @@
(pigeonMap['nestedList'] as List<Object?>?)?.cast<List<bool?>?>()
..mapWithAnnotations =
(pigeonMap['mapWithAnnotations'] as Map<Object?, Object?>?)
- ?.cast<String?, String?>();
+ ?.cast<String?, String?>()
+ ..mapWithObject = (pigeonMap['mapWithObject'] as Map<Object?, Object?>?)
+ ?.cast<String?, Object?>();
}
}
diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/all_datatypes_test.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/all_datatypes_test.dart
index 78accde..6d82d91 100644
--- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/all_datatypes_test.dart
+++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/all_datatypes_test.dart
@@ -35,6 +35,7 @@
expect(result.aMap, isNull);
expect(result.nestedList, isNull);
expect(result.mapWithAnnotations, isNull);
+ expect(result.mapWithObject, isNull);
});
test('with values', () async {
@@ -54,6 +55,7 @@
<bool?>[true]
];
everything.mapWithAnnotations = <String?, String?>{'hello': 'world'};
+ everything.mapWithObject = <String?, Object?>{'hello': 1234};
final BinaryMessenger mockMessenger = MockBinaryMessenger();
echoOneArgument(
mockMessenger,
@@ -74,5 +76,6 @@
expect(result.aMap, everything.aMap);
expect(result.aList, everything.aList);
expect(result.mapWithAnnotations, everything.mapWithAnnotations);
+ expect(result.mapWithObject, everything.mapWithObject);
});
}
diff --git a/packages/pigeon/platform_tests/ios_unit_tests/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/pigeon/platform_tests/ios_unit_tests/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index 97e0ecb..20fcf69 100644
--- a/packages/pigeon/platform_tests/ios_unit_tests/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/packages/pigeon/platform_tests/ios_unit_tests/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "1020"
+ LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/packages/pigeon/platform_tests/ios_unit_tests/ios/RunnerTests/AllDatatypesTest.m b/packages/pigeon/platform_tests/ios_unit_tests/ios/RunnerTests/AllDatatypesTest.m
index 93c0896..67bb71c 100644
--- a/packages/pigeon/platform_tests/ios_unit_tests/ios/RunnerTests/AllDatatypesTest.m
+++ b/packages/pigeon/platform_tests/ios_unit_tests/ios/RunnerTests/AllDatatypesTest.m
@@ -53,6 +53,7 @@
typedDataWithFloat64:[@"12345678" dataUsingEncoding:NSUTF8StringEncoding]];
everything.aList = @[ @(1), @(2) ];
everything.aMap = @{ @"hello" : @(1234) };
+ everything.mapWithObject = @{ @"hello" : @(1234), @"goodbye" : @"world" };
EchoBinaryMessenger* binaryMessenger =
[[EchoBinaryMessenger alloc] initWithCodec:FlutterEverythingGetCodec()];
FlutterEverything* api = [[FlutterEverything alloc] initWithBinaryMessenger:binaryMessenger];
@@ -69,6 +70,7 @@
XCTAssertEqualObjects(result.aFloatArray.data, everything.aFloatArray.data);
XCTAssertEqualObjects(result.aList, everything.aList);
XCTAssertEqualObjects(result.aMap, everything.aMap);
+ XCTAssertEqualObjects(result.mapWithObject, everything.mapWithObject);
[expectation fulfill];
}];
[self waitForExpectations:@[ expectation ] timeout:1.0];
diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml
index 8a451a9..9d711f2 100644
--- a/packages/pigeon/pubspec.yaml
+++ b/packages/pigeon/pubspec.yaml
@@ -2,7 +2,7 @@
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
repository: https://github.com/flutter/packages/tree/master/packages/pigeon
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
-version: 1.0.7 # This must match the version in lib/generator_tools.dart
+version: 1.0.8 # This must match the version in lib/generator_tools.dart
environment:
sdk: '>=2.12.0 <3.0.0'
@@ -10,6 +10,8 @@
dependencies:
analyzer: ^2.4.0
args: ^2.0.0
+ collection: ^1.15.0
+ meta: ^1.7.0
path: ^1.8.0
dev_dependencies:
diff --git a/packages/pigeon/run_tests.sh b/packages/pigeon/run_tests.sh
index 660055a..aaa73dd 100755
--- a/packages/pigeon/run_tests.sh
+++ b/packages/pigeon/run_tests.sh
@@ -234,8 +234,8 @@
--input pigeons/message.dart \
--dart_out mock_handler_tester/test/message.dart \
--dart_test_out mock_handler_tester/test/test.dart
- dartfmt -w mock_handler_tester/test/message.dart
- dartfmt -w mock_handler_tester/test/test.dart
+ dart format mock_handler_tester/test/message.dart
+ dart format mock_handler_tester/test/test.dart
cd mock_handler_tester
flutter test
popd
@@ -299,7 +299,7 @@
--objc_header_out $DARTLE_H \
--objc_source_out $DARTLE_M \
--java_out $PIGEON_JAVA
- dartfmt -w $DARTLE_DART
+ dart format $DARTLE_DART
pushd $PWD
cd e2e_tests/test_objc
diff --git a/packages/pigeon/test/dart_generator_test.dart b/packages/pigeon/test/dart_generator_test.dart
index 02aa5ad..92b73f8 100644
--- a/packages/pigeon/test/dart_generator_test.dart
+++ b/packages/pigeon/test/dart_generator_test.dart
@@ -13,7 +13,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'dataType1',
isNullable: true,
),
@@ -61,21 +61,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: 'input',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -84,7 +85,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -107,12 +108,14 @@
arguments: <NamedType>[
NamedType(
name: 'x',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
NamedType(
name: 'y',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
],
- returnType: TypeDeclaration(baseName: 'int', isNullable: false),
+ returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
isAsynchronous: false,
)
])
@@ -133,12 +136,14 @@
arguments: <NamedType>[
NamedType(
name: 'x',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
NamedType(
name: 'y',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
],
- returnType: TypeDeclaration(baseName: 'int', isNullable: false),
+ returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
isAsynchronous: false,
)
])
@@ -161,7 +166,7 @@
name: 'Input',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -173,7 +178,7 @@
name: 'Nested',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: true,
),
@@ -206,21 +211,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: 'input',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -229,7 +235,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -252,21 +258,21 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -288,21 +294,21 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -326,14 +332,15 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -355,21 +362,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'EnumClass',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'EnumClass', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'EnumClass', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'EnumClass', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Enum',
isNullable: true,
),
@@ -401,21 +409,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'EnumClass',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'EnumClass', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'EnumClass', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'EnumClass', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Enum',
isNullable: true,
),
@@ -448,14 +457,15 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -480,7 +490,7 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
@@ -488,28 +498,28 @@
offset: null)
],
returnType:
- TypeDeclaration(baseName: 'Output', isNullable: false),
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
),
Method(
name: 'voidReturner',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -518,7 +528,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -552,7 +562,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'dataType1',
isNullable: true,
),
@@ -578,21 +588,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -601,7 +612,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -625,21 +636,21 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: true,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -648,7 +659,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -671,21 +682,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -694,7 +706,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -715,14 +727,15 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true,
)
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -758,7 +771,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: true,
typeArguments: <TypeDeclaration>[
@@ -785,7 +798,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Map',
isNullable: true,
typeArguments: <TypeDeclaration>[
@@ -814,10 +827,10 @@
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -843,10 +856,10 @@
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -872,7 +885,7 @@
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration(
+ returnType: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -900,7 +913,7 @@
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration(
+ returnType: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -908,7 +921,7 @@
]),
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
diff --git a/packages/pigeon/test/generator_tools_test.dart b/packages/pigeon/test/generator_tools_test.dart
index 6daaf0c..b50dea6 100644
--- a/packages/pigeon/test/generator_tools_test.dart
+++ b/packages/pigeon/test/generator_tools_test.dart
@@ -72,7 +72,7 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -83,7 +83,8 @@
offset: null,
)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true,
)
]);
@@ -110,12 +111,12 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'Output', isNullable: false),
+ type: const TypeDeclaration(baseName: 'Output', isNullable: false),
name: '',
offset: null,
)
],
- returnType: TypeDeclaration(
+ returnType: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -148,17 +149,17 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'Foo', isNullable: false),
+ type: const TypeDeclaration(baseName: 'Foo', isNullable: false),
name: '',
offset: null,
),
NamedType(
- type: TypeDeclaration(baseName: 'Bar', isNullable: false),
+ type: const TypeDeclaration(baseName: 'Bar', isNullable: false),
name: '',
offset: null,
),
],
- returnType: TypeDeclaration(
+ returnType: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[TypeDeclaration.voidDeclaration()],
@@ -190,14 +191,14 @@
arguments: <NamedType>[
NamedType(
name: 'x',
- type: TypeDeclaration(
+ type: const TypeDeclaration(
isNullable: false,
baseName: 'List',
typeArguments: <TypeDeclaration>[
TypeDeclaration(baseName: 'Foo', isNullable: true)
])),
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: false,
)
])
@@ -205,12 +206,12 @@
Class(name: 'Foo', fields: <NamedType>[
NamedType(
name: 'bar',
- type: TypeDeclaration(baseName: 'Bar', isNullable: true)),
+ type: const TypeDeclaration(baseName: 'Bar', isNullable: true)),
]),
Class(name: 'Bar', fields: <NamedType>[
NamedType(
name: 'value',
- type: TypeDeclaration(baseName: 'int', isNullable: true))
+ type: const TypeDeclaration(baseName: 'int', isNullable: true))
])
], enums: <Enum>[]);
final List<EnumeratedClass> classes =
@@ -227,4 +228,57 @@
.length,
1);
});
+
+ test('getCodecClasses: unique entries', () {
+ final Root root = Root(apis: <Api>[
+ Api(
+ name: 'Api1',
+ location: ApiLocation.flutter,
+ methods: <Method>[
+ Method(
+ name: 'foo',
+ arguments: <NamedType>[
+ NamedType(
+ name: 'x',
+ type: const TypeDeclaration(
+ isNullable: false, baseName: 'Foo')),
+ ],
+ returnType: const TypeDeclaration.voidDeclaration(),
+ isAsynchronous: false,
+ )
+ ],
+ ),
+ Api(
+ name: 'Api2',
+ location: ApiLocation.host,
+ methods: <Method>[
+ Method(
+ name: 'foo',
+ arguments: <NamedType>[
+ NamedType(
+ name: 'x',
+ type: const TypeDeclaration(
+ isNullable: false, baseName: 'Foo')),
+ ],
+ returnType: const TypeDeclaration.voidDeclaration(),
+ isAsynchronous: false,
+ )
+ ],
+ )
+ ], classes: <Class>[
+ Class(name: 'Foo', fields: <NamedType>[
+ NamedType(
+ name: 'bar',
+ type: const TypeDeclaration(baseName: 'int', isNullable: true)),
+ ]),
+ ], enums: <Enum>[]);
+ final List<EnumeratedClass> classes =
+ getCodecClasses(root.apis[0], root).toList();
+ expect(classes.length, 1);
+ expect(
+ classes
+ .where((EnumeratedClass element) => element.name == 'Foo')
+ .length,
+ 1);
+ });
}
diff --git a/packages/pigeon/test/java_generator_test.dart b/packages/pigeon/test/java_generator_test.dart
index 835725a..461a806 100644
--- a/packages/pigeon/test/java_generator_test.dart
+++ b/packages/pigeon/test/java_generator_test.dart
@@ -12,7 +12,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'int',
isNullable: true,
),
@@ -64,7 +64,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'int',
isNullable: true,
),
@@ -93,21 +93,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -116,7 +117,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -137,56 +138,56 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'bool',
isNullable: true,
),
name: 'aBool',
offset: null),
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'int',
isNullable: true,
),
name: 'aInt',
offset: null),
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'double',
isNullable: true,
),
name: 'aDouble',
offset: null),
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
name: 'aString',
offset: null),
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Uint8List',
isNullable: true,
),
name: 'aUint8List',
offset: null),
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Int32List',
isNullable: true,
),
name: 'aInt32List',
offset: null),
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Int64List',
isNullable: true,
),
name: 'aInt64List',
offset: null),
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Float64List',
isNullable: true,
),
@@ -216,21 +217,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -239,7 +241,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -262,21 +264,21 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -299,21 +301,21 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -335,14 +337,15 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -364,14 +367,15 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: false,
)
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -391,7 +395,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: true,
),
@@ -411,7 +415,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Map',
isNullable: true,
),
@@ -432,7 +436,7 @@
name: 'Outer',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Nested',
isNullable: true,
),
@@ -444,7 +448,7 @@
name: 'Nested',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'int',
isNullable: true,
),
@@ -477,21 +481,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: 'arg',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -500,7 +505,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -528,21 +533,22 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true,
)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -551,7 +557,7 @@
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'String',
isNullable: true,
),
@@ -579,7 +585,7 @@
name: 'EnumClass',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Enum1',
isNullable: true,
),
@@ -628,7 +634,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: true,
typeArguments: <TypeDeclaration>[
@@ -656,7 +662,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Map',
isNullable: true,
typeArguments: <TypeDeclaration>[
@@ -686,10 +692,10 @@
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -716,10 +722,10 @@
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -746,7 +752,7 @@
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration(
+ returnType: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -772,7 +778,7 @@
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration(
+ returnType: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -800,12 +806,14 @@
arguments: <NamedType>[
NamedType(
name: 'x',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
NamedType(
name: 'y',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
],
- returnType: TypeDeclaration(baseName: 'int', isNullable: false),
+ returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
isAsynchronous: false,
)
])
@@ -832,12 +840,14 @@
arguments: <NamedType>[
NamedType(
name: 'x',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
NamedType(
name: 'y',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
],
- returnType: TypeDeclaration(baseName: 'int', isNullable: false),
+ returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
isAsynchronous: false,
)
])
diff --git a/packages/pigeon/test/objc_generator_test.dart b/packages/pigeon/test/objc_generator_test.dart
index 241ba81..d1ddbc3 100644
--- a/packages/pigeon/test/objc_generator_test.dart
+++ b/packages/pigeon/test/objc_generator_test.dart
@@ -11,7 +11,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'field1',
offset: null)
]),
@@ -27,7 +27,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'field1',
offset: null)
]),
@@ -83,11 +83,13 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type:
+ const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'field1',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'Enum1', isNullable: true),
+ type:
+ const TypeDeclaration(baseName: 'Enum1', isNullable: true),
name: 'enum1',
offset: null),
],
@@ -119,11 +121,13 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type:
+ const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'field1',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'Enum1', isNullable: true),
+ type:
+ const TypeDeclaration(baseName: 'Enum1', isNullable: true),
name: 'enum1',
offset: null),
],
@@ -152,22 +156,24 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'Input', isNullable: false),
+ type: const TypeDeclaration(
+ baseName: 'Input', isNullable: false),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false))
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
])
@@ -189,25 +195,26 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false))
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
])
@@ -229,35 +236,39 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'bool', isNullable: true),
+ type: const TypeDeclaration(baseName: 'bool', isNullable: true),
name: 'aBool',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'int', isNullable: true),
+ type: const TypeDeclaration(baseName: 'int', isNullable: true),
name: 'aInt',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'double', isNullable: true),
+ type: const TypeDeclaration(baseName: 'double', isNullable: true),
name: 'aDouble',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'aString',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'Uint8List', isNullable: true),
+ type:
+ const TypeDeclaration(baseName: 'Uint8List', isNullable: true),
name: 'aUint8List',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'Int32List', isNullable: true),
+ type:
+ const TypeDeclaration(baseName: 'Int32List', isNullable: true),
name: 'aInt32List',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'Int64List', isNullable: true),
+ type:
+ const TypeDeclaration(baseName: 'Int64List', isNullable: true),
name: 'aInt64List',
offset: null),
NamedType(
- type: TypeDeclaration(baseName: 'Float64List', isNullable: true),
+ type: const TypeDeclaration(
+ baseName: 'Float64List', isNullable: true),
name: 'aFloat64List',
offset: null),
]),
@@ -286,7 +297,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'bool', isNullable: true),
+ type: const TypeDeclaration(baseName: 'bool', isNullable: true),
name: 'aBool',
offset: null),
]),
@@ -303,13 +314,13 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Nested', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'Input', isNullable: true),
+ type: const TypeDeclaration(baseName: 'Input', isNullable: true),
name: 'nested',
offset: null)
])
@@ -325,13 +336,13 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Nested', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'Input', isNullable: true),
+ type: const TypeDeclaration(baseName: 'Input', isNullable: true),
name: 'nested',
offset: null)
])
@@ -347,7 +358,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'field1',
offset: null)
]),
@@ -362,7 +373,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'field1',
offset: null)
]),
@@ -380,25 +391,26 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Nested', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Nested', isNullable: false))
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Nested', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'Input', isNullable: true),
+ type: const TypeDeclaration(baseName: 'Input', isNullable: true),
name: 'nested',
offset: null)
])
@@ -418,25 +430,26 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Nested', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Nested', isNullable: false))
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Nested', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'Input', isNullable: true),
+ type: const TypeDeclaration(baseName: 'Input', isNullable: true),
name: 'nested',
offset: null)
])
@@ -456,25 +469,26 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false))
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
])
@@ -497,25 +511,26 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false))
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
])
@@ -534,19 +549,19 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration())
+ returnType: const TypeDeclaration.voidDeclaration())
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
@@ -565,19 +580,19 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration())
+ returnType: const TypeDeclaration.voidDeclaration())
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
@@ -598,19 +613,19 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration())
+ returnType: const TypeDeclaration.voidDeclaration())
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
@@ -629,19 +644,19 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration())
+ returnType: const TypeDeclaration.voidDeclaration())
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
@@ -660,12 +675,13 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false))
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -683,12 +699,13 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false))
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -706,12 +723,13 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false))
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -732,12 +750,13 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false))
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -757,7 +776,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'List', isNullable: true),
+ type: const TypeDeclaration(baseName: 'List', isNullable: true),
name: 'field1',
offset: null)
]),
@@ -773,7 +792,7 @@
final Root root = Root(apis: <Api>[], classes: <Class>[
Class(name: 'Foobar', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'Map', isNullable: true),
+ type: const TypeDeclaration(baseName: 'Map', isNullable: true),
name: 'field1',
offset: null)
]),
@@ -785,6 +804,56 @@
expect(code, matches('@property.*NSDictionary.*field1'));
});
+ test('gen map field with object', () {
+ final Root root = Root(apis: <Api>[], classes: <Class>[
+ Class(name: 'Foobar', fields: <NamedType>[
+ NamedType(
+ type: const TypeDeclaration(
+ baseName: 'Map',
+ isNullable: true,
+ typeArguments: <TypeDeclaration>[
+ TypeDeclaration(baseName: 'String', isNullable: true),
+ TypeDeclaration(baseName: 'Object', isNullable: true),
+ ]),
+ name: 'field1',
+ offset: null)
+ ]),
+ ], enums: <Enum>[]);
+ final StringBuffer sink = StringBuffer();
+ generateObjcHeader(const ObjcOptions(), root, sink);
+ final String code = sink.toString();
+ expect(code, contains('@interface Foobar'));
+ expect(
+ code,
+ contains(
+ '@property(nonatomic, strong, nullable) NSDictionary<NSString *, id> *'));
+ });
+
+ test('gen map argument with object', () {
+ final Root root = Root(apis: <Api>[
+ Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
+ Method(
+ name: 'doit',
+ returnType: const TypeDeclaration.voidDeclaration(),
+ arguments: <NamedType>[
+ NamedType(
+ name: 'foo',
+ type: const TypeDeclaration(
+ baseName: 'Map',
+ isNullable: true,
+ typeArguments: <TypeDeclaration>[
+ TypeDeclaration(baseName: 'String', isNullable: true),
+ TypeDeclaration(baseName: 'Object', isNullable: true),
+ ]))
+ ]),
+ ])
+ ], classes: <Class>[], enums: <Enum>[]);
+ final StringBuffer sink = StringBuffer();
+ generateObjcHeader(const ObjcOptions(), root, sink);
+ final String code = sink.toString();
+ expect(code, contains('(NSDictionary<NSString *, id> *)foo'));
+ });
+
test('async void(input) HostApi header', () {
final Root root = Root(apis: <Api>[
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
@@ -792,26 +861,26 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: 'input',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: true)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -833,26 +902,27 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: 'input',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -873,13 +943,14 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true)
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -900,7 +971,7 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: true)
])
], classes: <Class>[], enums: <Enum>[]);
@@ -921,26 +992,27 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: '',
offset: null)
],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -962,26 +1034,26 @@
name: 'doSomething',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'Input',
isNullable: false,
),
name: 'foo',
offset: null)
],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: true)
])
], classes: <Class>[
Class(name: 'Input', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'input',
offset: null)
]),
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -1002,7 +1074,7 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
isAsynchronous: true)
])
], classes: <Class>[], enums: <Enum>[]);
@@ -1022,13 +1094,14 @@
Method(
name: 'doSomething',
arguments: <NamedType>[],
- returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
+ returnType:
+ const TypeDeclaration(baseName: 'Output', isNullable: false),
isAsynchronous: true)
])
], classes: <Class>[
Class(name: 'Output', fields: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'String', isNullable: true),
+ type: const TypeDeclaration(baseName: 'String', isNullable: true),
name: 'output',
offset: null)
]),
@@ -1082,7 +1155,7 @@
name: 'Foobar',
fields: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: true,
typeArguments: <TypeDeclaration>[
@@ -1110,10 +1183,10 @@
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -1149,10 +1222,10 @@
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -1188,10 +1261,10 @@
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration.voidDeclaration(),
+ returnType: const TypeDeclaration.voidDeclaration(),
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(
+ type: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -1226,7 +1299,7 @@
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration(
+ returnType: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -1261,7 +1334,7 @@
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
Method(
name: 'doit',
- returnType: TypeDeclaration(
+ returnType: const TypeDeclaration(
baseName: 'List',
isNullable: false,
typeArguments: <TypeDeclaration>[
@@ -1299,12 +1372,14 @@
arguments: <NamedType>[
NamedType(
name: 'x',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
NamedType(
name: 'y',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
],
- returnType: TypeDeclaration(baseName: 'int', isNullable: false),
+ returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
isAsynchronous: false,
)
])
@@ -1340,12 +1415,14 @@
arguments: <NamedType>[
NamedType(
name: 'x',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
NamedType(
name: 'y',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
],
- returnType: TypeDeclaration(baseName: 'int', isNullable: false),
+ returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
isAsynchronous: true,
)
])
@@ -1380,12 +1457,14 @@
arguments: <NamedType>[
NamedType(
name: 'x',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
NamedType(
name: 'y',
- type: TypeDeclaration(isNullable: false, baseName: 'int')),
+ type:
+ const TypeDeclaration(isNullable: false, baseName: 'int')),
],
- returnType: TypeDeclaration(baseName: 'int', isNullable: false),
+ returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
isAsynchronous: false,
)
])
@@ -1421,16 +1500,18 @@
objcSelector: 'divideValue:by:',
arguments: <NamedType>[
NamedType(
- type: TypeDeclaration(baseName: 'int', isNullable: false),
+ type: const TypeDeclaration(
+ baseName: 'int', isNullable: false),
name: 'x',
),
NamedType(
- type: TypeDeclaration(baseName: 'int', isNullable: false),
+ type: const TypeDeclaration(
+ baseName: 'int', isNullable: false),
name: 'y',
),
],
- returnType:
- TypeDeclaration(baseName: 'double', isNullable: false))
+ returnType: const TypeDeclaration(
+ baseName: 'double', isNullable: false))
])
],
classes: <Class>[],
diff --git a/packages/pigeon/test/pigeon_lib_test.dart b/packages/pigeon/test/pigeon_lib_test.dart
index 8f2a587..63c9498 100644
--- a/packages/pigeon/test/pigeon_lib_test.dart
+++ b/packages/pigeon/test/pigeon_lib_test.dart
@@ -890,4 +890,15 @@
expect(results.errors[0].lineNumber, 3);
expect(results.errors[0].message, contains('Unknown type: Foo'));
});
+
+ test('Object type argument', () {
+ const String code = '''
+@HostApi()
+abstract class Api {
+ void storeAll(List<Object?> foos);
+}
+''';
+ final ParseResults results = _parseSource(code);
+ expect(results.errors.length, 0);
+ });
}