From eb7cac6a6df9d4ece379324d1ff36e0b00c3c7cc Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 14 Apr 2025 17:04:44 -0700 Subject: [PATCH 1/4] methods, basic types, sync, nullable-sync, async, and classes --- analysis_options.yaml | 1 + .../pigeon/lib/src/dart/dart_generator.dart | 413 +- .../lib/src/kotlin/jnigen_yaml_generator.dart | 78 + .../lib/src/kotlin/kotlin_generator.dart | 141 +- packages/pigeon/lib/src/pigeon_lib.dart | 1 + .../pigeon/lib/src/pigeon_lib_internal.dart | 46 + packages/pigeon/pigeons/jni_tests.dart | 75 + .../lib/integration_tests.dart | 70 + .../lib/src/generated/jni_tests.gen.dart | 384 ++ .../lib/src/generated/jni_tests.gen.jni.dart | 3510 +++++++++++++++++ .../shared_test_plugin_code/pubspec.yaml | 1 + .../kotlin/com/example/test_plugin/.gitignore | 3 +- .../com/example/test_plugin/JniTests.gen.kt | 400 ++ .../com/example/test_plugin/TestPlugin.kt | 143 + .../test_plugin/example/jnigen.yaml | 26 + .../test_plugin/example/pubspec.yaml | 1 + .../platform_tests/test_plugin/pubspec.yaml | 1 + packages/pigeon/pubspec.yaml | 2 + packages/pigeon/tool/shared/generation.dart | 16 +- 19 files changed, 5271 insertions(+), 41 deletions(-) create mode 100644 packages/pigeon/lib/src/kotlin/jnigen_yaml_generator.dart create mode 100644 packages/pigeon/pigeons/jni_tests.dart create mode 100644 packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart create mode 100644 packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart create mode 100644 packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt create mode 100644 packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml diff --git a/analysis_options.yaml b/analysis_options.yaml index 736235588ba5..09a526583d93 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -19,6 +19,7 @@ analyzer: exclude: # DIFFERENT FROM FLUTTER/FLUTTER # Ignore generated files - '**/*.g.dart' + - '**/*.gen.jni.dart' - '**/*.mocks.dart' # Mockito @GenerateMocks linter: diff --git a/packages/pigeon/lib/src/dart/dart_generator.dart b/packages/pigeon/lib/src/dart/dart_generator.dart index a6955bcdfabc..44a8d3266101 100644 --- a/packages/pigeon/lib/src/dart/dart_generator.dart +++ b/packages/pigeon/lib/src/dart/dart_generator.dart @@ -45,6 +45,8 @@ class DartOptions { this.copyrightHeader, this.sourceOutPath, this.testOutPath, + this.useJni = false, + this.dartOut, }); /// A copyright header that will get prepended to generated code. @@ -56,6 +58,12 @@ class DartOptions { /// Path to output generated Test file for tests. final String? testOutPath; + /// Whether to use Jni for generating kotlin interop code. + final bool useJni; + + /// Path to output generated Dart file. + final String? dartOut; + /// Creates a [DartOptions] from a Map representation where: /// `x = DartOptions.fromMap(x.toMap())`. static DartOptions fromMap(Map map) { @@ -65,6 +73,8 @@ class DartOptions { copyrightHeader: copyrightHeader?.cast(), sourceOutPath: map['sourceOutPath'] as String?, testOutPath: map['testOutPath'] as String?, + useJni: map['useJni'] as bool? ?? false, + dartOut: map['dartOut'] as String?, ); } @@ -75,6 +85,8 @@ class DartOptions { if (copyrightHeader != null) 'copyrightHeader': copyrightHeader!, if (sourceOutPath != null) 'sourceOutPath': sourceOutPath!, if (testOutPath != null) 'testOutPath': testOutPath!, + if (useJni) 'useJni': useJni, + if (dartOut != null) 'dartOut': dartOut!, }; return result; } @@ -86,6 +98,152 @@ class DartOptions { } } +class _JniType { + const _JniType( + this.typeName, + this.jniName, + this.getterName, + this.conversionToDart, + this.conversionToJni, + this.conversionToNullableDart, + this.conversionToNullableJni, + this.isBuiltIn, { + this.nonNullableNeedsUnwrapping = false, + }); + + static _JniType fromTypeDeclaration(TypeDeclaration type) { + _JniType? jniType = _jniTypeForDartType[type.baseName]; + jniType = jniType ?? + _JniType( + type.baseName, + 'bridge.${type.baseName}', + 'get', + '${type.baseName}.fromJni', + '.toJni()', + '', + '', + false, + nonNullableNeedsUnwrapping: true, + ); + return jniType; + } + + final String typeName; + final String jniName; + final String getterName; + final String conversionToDart; + final String conversionToJni; + final String conversionToNullableDart; + final String conversionToNullableJni; + final bool isBuiltIn; + final bool nonNullableNeedsUnwrapping; + + String getToDartCall( + TypeDeclaration type, { + String? varName, + bool forceConversion = false, + }) { + varName = varName ?? ''; + if (isBuiltIn) { + return !type.isNullable && !nonNullableNeedsUnwrapping && !forceConversion + ? '' + : type.isNullable + ? '$varName$conversionToNullableDart' + : '$varName$conversionToDart'; + } + return '$conversionToDart($varName)${type.isNullable ? '' : '!'}'; + } + + String getToJniCall( + NamedType field, { + bool forceNonNull = false, + }) { + if (isBuiltIn) { + final String forceNonNullSymbol = forceNonNull ? '!' : ''; + return field.type.isNullable + ? '${field.name} != null ? $jniName$conversionToJni(${field.name}$forceNonNullSymbol) : null' + : nonNullableNeedsUnwrapping + ? '$jniName$conversionToJni(${field.name})' + : field.name; + } + return '${field.name}${field.type.isNullable ? '?' : ''}$conversionToJni'; + } + + String getJniGetterMethodName(String field) { + return '$getterName${toUpperCamelCase(field)}()'; + } + + String getApiCallReturnType(Method method) { + final String nullable = method.returnType.isNullable ? '?' : ''; + if (method.isAsynchronous || + method.returnType.isNullable || + nonNullableNeedsUnwrapping) { + return '$jniName$nullable'; + } + return typeName; + } +} + +const Map _jniTypeForDartType = { + 'String': _JniType( + 'String', + 'JString', + 'get', + '.toDartString(releaseOriginal: true)', + '.fromString', + '?.toDartString(releaseOriginal: true)', + '?.fromString', + true, + nonNullableNeedsUnwrapping: true, + ), + 'void': _JniType( + 'void', + 'JVoid', + '', + '', + '', + '', + '', + true, + ), + 'bool': _JniType( + 'bool', + 'JBoolean', + 'get', + '.booleanValue(releaseOriginal: true)', + '', + '?.booleanValue(releaseOriginal: true)', + '', + true, + ), + 'int': _JniType( + 'int', + 'JLong', + 'get', + '.intValue(releaseOriginal: true)', + '', + '?.intValue(releaseOriginal: true)', + '', + true, + ), + 'double': _JniType( + 'double', + 'JDouble', + 'get', + '.doubleValue(releaseOriginal: true)', + '', + '?.doubleValue(releaseOriginal: true)', + '', + true, + ), + // 'Uint8List': 'ByteArray', + // 'Int32List': 'IntArray', + // 'Int64List': 'LongArray', + // 'Float32List': 'FloatArray', + // 'Float64List': 'DoubleArray', + // 'Object': _JniType('Object', 'JObject', 'get', '', '', '', '',), +}; + /// Options that control how Dart code will be generated. class InternalDartOptions extends InternalOptions { /// Constructor for InternalDartOptions. @@ -93,6 +251,7 @@ class InternalDartOptions extends InternalOptions { this.copyrightHeader, this.dartOut, this.testOut, + this.useJni = false, }); /// Creates InternalDartOptions from DartOptions. @@ -103,7 +262,8 @@ class InternalDartOptions extends InternalOptions { String? testOut, }) : copyrightHeader = copyrightHeader ?? options.copyrightHeader, dartOut = (dartOut ?? options.sourceOutPath)!, - testOut = testOut ?? options.testOutPath; + testOut = testOut ?? options.testOutPath, + useJni = options.useJni; /// A copyright header that will get prepended to generated code. final Iterable? copyrightHeader; @@ -113,6 +273,9 @@ class InternalDartOptions extends InternalOptions { /// Path to output generated Test file for tests. final String? testOut; + + /// Whether to use Jni for generating kotlin interop code. + final bool useJni; } /// Class that manages all Dart code generation. @@ -159,6 +322,12 @@ class DartGenerator extends StructuredGenerator { "import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;", ); } + if (generatorOptions.useJni) { + indent.writeln("import 'package:jni/jni.dart';"); + final String jniFileImportName = path.basename(generatorOptions.dartOut!); + indent.writeln( + "import './${path.withoutExtension(jniFileImportName)}.jni.dart' as bridge;"); + } } @override @@ -258,17 +427,6 @@ class DartGenerator extends StructuredGenerator { }); } - void _writeToList(Indent indent, Class classDefinition) { - indent.writeScoped('List _toList() {', '}', () { - indent.writeScoped('return [', '];', () { - for (final NamedType field - in getFieldsInSerializationOrder(classDefinition)) { - indent.writeln('${field.name},'); - } - }); - }); - } - @override void writeClassEncode( InternalDartOptions generatorOptions, @@ -277,6 +435,10 @@ class DartGenerator extends StructuredGenerator { Class classDefinition, { required String dartPackageName, }) { + if (generatorOptions.useJni) { + _writeToJni(indent, classDefinition); + indent.newln(); + } indent.write('Object encode() '); indent.addScoped('{', '}', () { indent.write( @@ -285,6 +447,46 @@ class DartGenerator extends StructuredGenerator { }); } + void _writeToList(Indent indent, Class classDefinition) { + indent.writeScoped('List _toList() {', '}', () { + indent.writeScoped('return [', '];', () { + for (final NamedType field + in getFieldsInSerializationOrder(classDefinition)) { + indent.writeln('${field.name},'); + } + }); + }); + } + + void _writeToJni(Indent indent, Class classDefinition) { + indent.writeScoped('bridge.${classDefinition.name} toJni() {', '}', () { + indent.writeScoped('return bridge.${classDefinition.name} (', ');', () { + for (final NamedType field + in getFieldsInSerializationOrder(classDefinition)) { + final _JniType jniType = _JniType.fromTypeDeclaration(field.type); + indent.writeln('${jniType.getToJniCall(field, forceNonNull: true)},'); + } + }); + }); + } + + void _writeFromJni(Indent indent, Class classDefinition) { + indent.writeScoped( + 'static ${classDefinition.name}? fromJni(bridge.${classDefinition.name}? jniClass) {', + '}', () { + indent.writeScoped( + 'return jniClass == null ? null : ${classDefinition.name}(', ');', + () { + for (final NamedType field + in getFieldsInSerializationOrder(classDefinition)) { + final _JniType jniType = _JniType.fromTypeDeclaration(field.type); + indent.writeln( + '${field.name}: jniClass.${jniType.getJniGetterMethodName(field.name)}${jniType.getToDartCall(field.type)},'); + } + }); + }); + } + @override void writeClassDecode( InternalDartOptions generatorOptions, @@ -293,6 +495,10 @@ class DartGenerator extends StructuredGenerator { Class classDefinition, { required String dartPackageName, }) { + if (generatorOptions.useJni) { + _writeFromJni(indent, classDefinition); + indent.newln(); + } void writeValueDecode(NamedType field, int index) { final String resultAt = 'result[$index]'; final String castCallPrefix = field.type.isNullable ? '?' : '!'; @@ -315,10 +521,8 @@ class DartGenerator extends StructuredGenerator { } } - indent.write( - 'static ${classDefinition.name} decode(Object result) ', - ); - indent.addScoped('{', '}', () { + indent.writeScoped( + 'static ${classDefinition.name} decode(Object result) {', '}', () { indent.writeln('result as List;'); indent.write('return ${classDefinition.name}'); indent.addScoped('(', ');', () { @@ -376,6 +580,12 @@ class DartGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { + if (generatorOptions.useJni && + !root.containsProxyApi && + !root.containsEventChannel && + !root.containsFlutterApi) { + return; + } void writeEncodeLogic( EnumeratedType customType, int nonSerializedClassCount) { indent.writeScoped('else if (value is ${customType.name}) {', '}', () { @@ -555,6 +765,88 @@ class DartGenerator extends StructuredGenerator { }); } + @override + void writeApis(InternalDartOptions generatorOptions, Root root, Indent indent, + {required String dartPackageName}) { + if (generatorOptions.useJni) { + indent.writeln( + "const String defaultInstanceName = 'PigeonDefaultClassName32uh4ui3lh445uh4h3l2l455g4y34u';"); + } + super.writeApis(generatorOptions, root, indent, + dartPackageName: dartPackageName); + } + + void _writeJniApi( + InternalDartOptions generatorOptions, + Root root, + Indent indent, + AstHostApi api, { + required String dartPackageName, + }) { + final String dartApiName = api.name; + final String jniApiRegistrarName = 'bridge.${dartApiName}Registrar'; + indent.newln(); + indent.writeScoped('class $dartApiName {', '}', () { + indent.format(''' + $dartApiName._withRegistrar($jniApiRegistrarName api) : _api = api; + + /// Returns instance of $dartApiName with specified [channelName] if one has been registered. + static $dartApiName? getInstance({String channelName = defaultInstanceName}) { + final $jniApiRegistrarName? link = + $jniApiRegistrarName().getInstance(JString.fromString(channelName)); + if (link == null) { + String nameString = 'named \$channelName'; + if (channelName == defaultInstanceName) { + nameString = 'with no name'; + } + final String error = 'No instance \$nameString has been registered.'; + throw ArgumentError(error); + } + final $dartApiName res = $dartApiName._withRegistrar(link); + return res; + } + + late final $jniApiRegistrarName _api; +'''); + for (final Method method in api.methods) { + indent.writeScoped( + '${method.isAsynchronous ? 'Future<' : ''}${_addGenericTypesNullable(method.returnType)}${method.isAsynchronous ? '>' : ''} ${method.name}(${_getMethodParameterSignature(method.parameters)}) ${method.isAsynchronous ? 'async ' : ''}{', + '}', () { + final _JniType returnType = + _JniType.fromTypeDeclaration(method.returnType); + final String methodCallReturnString = returnType.typeName == 'void' && + method.isAsynchronous + ? '' + : (!returnType.nonNullableNeedsUnwrapping && + !method.returnType.isNullable && + !method.isAsynchronous) + ? 'return ' + : 'final ${returnType.getApiCallReturnType(method)} res = '; + indent.writeln( + '$methodCallReturnString${method.isAsynchronous ? 'await ' : ''}_api.${method.name}(${_getJniMethodCallArguments(method.parameters)});'); + if ((method.returnType.isNullable || + method.isAsynchronous || + returnType.nonNullableNeedsUnwrapping) && + returnType.typeName != 'void') { + final String nullable = method.returnType.isNullable ? '?' : ''; + indent.writeln( + 'final ${returnType.typeName}$nullable dartTypeRes = ${returnType.getToDartCall(method.returnType, varName: 'res', forceConversion: method.isAsynchronous)};'); + indent.writeln('return dartTypeRes;'); + } + }); + indent.newln(); + } + }); + } + + String _getJniMethodCallArguments(Iterable parameters) { + return parameters + .map((Parameter parameter) => + _JniType.fromTypeDeclaration(parameter.type) + .getToJniCall(parameter)) + .join(', '); + } + /// Writes the code for host [Api], [api]. /// Example: /// class FooCodec extends StandardMessageCodec {...} @@ -580,6 +872,11 @@ class DartGenerator extends StructuredGenerator { AstHostApi api, { required String dartPackageName, }) { + if (generatorOptions.useJni) { + _writeJniApi(generatorOptions, root, indent, api, + dartPackageName: dartPackageName); + return; + } indent.newln(); bool first = true; addDocumentationComments( @@ -1075,7 +1372,8 @@ final BinaryMessenger? ${varNamePrefix}binaryMessenger; Indent indent, { required String dartPackageName, }) { - if (root.containsHostApi || root.containsProxyApi) { + if ((root.containsHostApi && !generatorOptions.useJni) || + root.containsProxyApi) { _writeCreateConnectionError(indent); } if (root.containsFlutterApi || @@ -1088,6 +1386,51 @@ final BinaryMessenger? ${varNamePrefix}binaryMessenger; .any((NamedType field) => isCollectionType(field.type)))) { _writeDeepEquals(indent); } + if (generatorOptions.useJni) { + _writeConvertObject(indent); + } + } + + void _writeConvertObject(Indent indent) { + indent.newln(); + indent.format(''' +Object? convertObject(JObject? object) { + if (object == null) { + return null; + } + if (object.isA(JLong.type)) { + return (object.as(JLong.type)).intValue(); + } + if (object.isA(JDouble.type)) { + return (object.as(JDouble.type)).doubleValue(); + } + if (object.isA(JString.type)) { + return (object.as(JString.type)).toDartString(); + } + if (object.isA(JBoolean.type)) { + return (object.as(JBoolean.type)).booleanValue(); + } + if (object.isA>(JList.type(JObject.type))) { + final JList list = (object.as(JList.type(JObject.type))); + final List res = []; + for (int i = 0; i < list.length; i++) { + res.add(convertObject(list[i])); + } + return res; + } + if (object.isA>( + JMap.type(JObject.type, JObject.type))) { + final JMap map = + (object.as(JMap.type(JObject.type, JObject.type))); + final Map res = {}; + for (final MapEntry entry in map.entries) { + res[convertObject(entry.key)] = convertObject(entry.value); + } + return res; + } + return object; +} + '''); } /// Writes [wrapResponse] method. @@ -1222,15 +1565,10 @@ if (wrapped == null) { required bool addSuffixVariable, bool insideAsyncMethod = true, }) { - String sendArgument = 'null'; - if (parameters.isNotEmpty) { - final Iterable argExpressions = - indexMap(parameters, (int index, NamedType type) { - final String name = _getParameterName(index, type); - return name; - }); - sendArgument = '[${argExpressions.join(', ')}]'; - } + final String? arguments = _getArgumentsForMethodCall(parameters); + final String sendArgument = + arguments == null ? 'null' : '[$arguments]'; + final String channelSuffix = addSuffixVariable ? '\$$_suffixVarName' : ''; final String constOrFinal = addSuffixVariable ? 'final' : 'const'; indent.writeln( @@ -2343,7 +2681,7 @@ String _flattenTypeArguments(List args) { /// Creates the type declaration for use in Dart code from a [NamedType] making sure /// that type arguments are used for primitive generic types. -String _addGenericTypes(TypeDeclaration type) { +String _addGenericTypes(TypeDeclaration type, {bool useJni = false}) { final List typeArguments = type.typeArguments; switch (type.baseName) { case 'List': @@ -2355,13 +2693,16 @@ String _addGenericTypes(TypeDeclaration type) { ? 'Map' : 'Map<${_flattenTypeArguments(typeArguments)}>'; default: - return type.baseName; + return useJni + ? _JniType.fromTypeDeclaration(type).jniName + : type.baseName; } } -String _addGenericTypesNullable(TypeDeclaration type) { - final String genericType = _addGenericTypes(type); - return type.isNullable ? '$genericType?' : genericType; +String _addGenericTypesNullable(TypeDeclaration type, {bool useJni = false}) { + final String genericType = _addGenericTypes(type, useJni: useJni); + final String nullableSymbol = type.isNullable ? '?' : ''; + return '$genericType$nullableSymbol'; } /// Converts [inputPath] to a posix absolute path. @@ -2369,3 +2710,13 @@ String _posixify(String inputPath) { final path.Context context = path.Context(style: path.Style.posix); return context.fromUri(path.toUri(path.absolute(inputPath))); } + +String? _getArgumentsForMethodCall(Iterable parameters) { + if (parameters.isNotEmpty) { + return indexMap(parameters, (int index, NamedType type) { + final String name = _getParameterName(index, type); + return name; + }).join(', '); + } + return null; +} diff --git a/packages/pigeon/lib/src/kotlin/jnigen_yaml_generator.dart b/packages/pigeon/lib/src/kotlin/jnigen_yaml_generator.dart new file mode 100644 index 000000000000..acd6f8c422c8 --- /dev/null +++ b/packages/pigeon/lib/src/kotlin/jnigen_yaml_generator.dart @@ -0,0 +1,78 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:path/path.dart' as path; + +import '../ast.dart'; +import '../dart/dart_generator.dart' show InternalDartOptions; +import '../generator.dart'; +import '../generator_tools.dart'; +import 'kotlin_generator.dart' show InternalKotlinOptions; + +/// Options for [JnigenYamlGenerator]. +class InternalJnigenYamlOptions extends InternalOptions { + /// Creates a [InternalJnigenYamlOptions]. + InternalJnigenYamlOptions( + this.dartOptions, + this.kotlinOptions, + this.basePath, + this.dartOut, + this.exampleAppDirectory, + ); + + /// Dart options. + final InternalDartOptions dartOptions; + + /// Kotlin options. + final InternalKotlinOptions kotlinOptions; + + /// A base path to be prepended to all provided output paths. + final String? basePath; + + /// Dart output path. + final String? dartOut; + + /// Android example app directory. + final String? exampleAppDirectory; +} + +/// Generator for jnigen yaml configuration file. +class JnigenYamlGenerator extends Generator { + @override + void generate( + InternalJnigenYamlOptions generatorOptions, Root root, StringSink sink, + {required String dartPackageName}) { + final Indent indent = Indent(sink); + + indent.format(''' + android_sdk_config: + add_gradle_deps: true + android_example: '${generatorOptions.exampleAppDirectory ?? ''}' + + # source_path: + # - 'android/src/main/java' + + summarizer: + backend: asm + + output: + dart: + path: ${path.posix.join(generatorOptions.basePath ?? '', path.withoutExtension(generatorOptions.dartOut ?? ''))}.jni.dart + structure: single_file + + log_level: all + '''); + indent.writeScoped('classes:', '', () { + for (final Api api in root.apis) { + if (api is AstHostApi) { + indent.writeln("- '${api.name}'"); + indent.writeln("- '${api.name}Registrar'"); + } + } + for (final Class dataClass in root.classes) { + indent.writeln("- '${dataClass.name}'"); + } + }); + } +} diff --git a/packages/pigeon/lib/src/kotlin/kotlin_generator.dart b/packages/pigeon/lib/src/kotlin/kotlin_generator.dart index f64dacae70bb..b4c2b88f3330 100644 --- a/packages/pigeon/lib/src/kotlin/kotlin_generator.dart +++ b/packages/pigeon/lib/src/kotlin/kotlin_generator.dart @@ -41,6 +41,8 @@ class KotlinOptions { const KotlinOptions({ this.package, this.copyrightHeader, + this.useJni = false, + this.exampleAppDirectory, this.errorClassName, this.includeErrorClass = true, this.fileSpecificClassNameComponent, @@ -52,6 +54,12 @@ class KotlinOptions { /// A copyright header that will get prepended to generated code. final Iterable? copyrightHeader; + /// Whether to use Jni when possible. + final bool useJni; + + /// The directory that the example app exists in, this is required for Jni APIs. + final String? exampleAppDirectory; + /// The name of the error class used for passing custom error parameters. final String? errorClassName; @@ -69,6 +77,8 @@ class KotlinOptions { static KotlinOptions fromMap(Map map) { return KotlinOptions( package: map['package'] as String?, + useJni: map['useJni'] as bool? ?? false, + exampleAppDirectory: map['exampleAppDirectory'] as String?, copyrightHeader: map['copyrightHeader'] as Iterable?, errorClassName: map['errorClassName'] as String?, includeErrorClass: map['includeErrorClass'] as bool? ?? true, @@ -82,6 +92,9 @@ class KotlinOptions { Map toMap() { final Map result = { if (package != null) 'package': package!, + if (useJni) 'useJni': useJni, + if (exampleAppDirectory != null) + 'exampleAppDirectory': exampleAppDirectory!, if (copyrightHeader != null) 'copyrightHeader': copyrightHeader!, if (errorClassName != null) 'errorClassName': errorClassName!, 'includeErrorClass': includeErrorClass, @@ -107,6 +120,8 @@ class InternalKotlinOptions extends InternalOptions { this.copyrightHeader, this.errorClassName, this.includeErrorClass = true, + this.useJni = false, + this.exampleAppDirectory, this.fileSpecificClassNameComponent, }); @@ -119,6 +134,8 @@ class InternalKotlinOptions extends InternalOptions { copyrightHeader = options.copyrightHeader ?? copyrightHeader, errorClassName = options.errorClassName, includeErrorClass = options.includeErrorClass, + useJni = options.useJni, + exampleAppDirectory = options.exampleAppDirectory, fileSpecificClassNameComponent = options.fileSpecificClassNameComponent ?? kotlinOut.split('/').lastOrNull?.split('.').first; @@ -141,6 +158,12 @@ class InternalKotlinOptions extends InternalOptions { /// Kotlin file in the same directory. final bool includeErrorClass; + /// Whether to use Jni for generating kotlin interop code. + final bool useJni; + + /// The directory that the example app exists in, this is required for Jni APIs. + final String? exampleAppDirectory; + /// A String to augment class names to avoid cross file collisions. final String? fileSpecificClassNameComponent; } @@ -202,11 +225,14 @@ class KotlinGenerator extends StructuredGenerator { required String dartPackageName, }) { indent.newln(); - if (generatorOptions.package != null) { + if (generatorOptions.package != null && !generatorOptions.useJni) { indent.writeln('package ${generatorOptions.package}'); } indent.newln(); indent.writeln('import android.util.Log'); + if (generatorOptions.useJni) { + indent.writeln('import androidx.annotation.Keep'); + } indent.writeln('import io.flutter.plugin.common.BasicMessageChannel'); indent.writeln('import io.flutter.plugin.common.BinaryMessenger'); indent.writeln('import io.flutter.plugin.common.EventChannel'); @@ -448,6 +474,12 @@ class KotlinGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { + if (generatorOptions.useJni && + !root.containsEventChannel && + !root.containsFlutterApi && + !root.containsProxyApi) { + return; + } final List enumeratedTypes = getEnumeratedTypes(root, excludeSealedClasses: true).toList(); @@ -683,6 +715,86 @@ if (wrapped == null) { }); } + void _writeJniApi( + InternalKotlinOptions generatorOptions, + Root root, + Indent indent, + AstHostApi api, { + required String dartPackageName, + }) { + indent.writeln( + 'val ${api.name}Instances: MutableMap = mutableMapOf()'); + indent.writeln('@Keep'); + indent.writeScoped('abstract class ${api.name} {', '}', () { + for (final Method method in api.methods) { + _writeMethodDeclaration( + indent, + name: method.name, + documentationComments: method.documentationComments, + returnType: method.returnType, + parameters: method.parameters, + isAsynchronous: method.isAsynchronous, + useJni: true, + isAbstract: true, + ); + } + }); + + indent.writeln('@Keep'); + indent.writeScoped('class ${api.name}Registrar : ${api.name}() {', '}', () { + indent.writeln('var api: ${api.name}? = null'); + + indent.writeScoped('fun register(', '):', () { + indent.writeln('api: ${api.name},'); + indent.writeln( + 'name: String = "PigeonDefaultClassName32uh4ui3lh445uh4h3l2l455g4y34u"'); + }, addTrailingNewline: false); + indent.writeScoped(' ${api.name}Registrar {', '}', () { + indent.writeln('this.api = api'); + indent.writeln('${api.name}Instances[name] = this'); + indent.writeln('return this'); + }); + + indent.writeln('@Keep'); + indent.writeScoped( + 'fun getInstance(name: String): ${api.name}Registrar? {', '}', () { + indent.writeln('return ${api.name}Instances[name]'); + }); + + for (final Method method in api.methods) { + _writeMethodDeclaration( + indent, + name: method.name, + documentationComments: method.documentationComments, + returnType: method.returnType, + parameters: method.parameters, + isAsynchronous: method.isAsynchronous, + isOverride: true, + useJni: true, + ); + final String argNames = + method.parameters.map((Parameter arg) => arg.name).join(', '); + indent.addScoped(' {', '}', () { + indent.writeScoped('api?.let {', '}', () { + indent.writeScoped( + 'try {', + '}', + () { + indent.writeln('return api!!.${method.name}($argNames)'); + }, + addTrailingNewline: false, + ); + indent.addScoped(' catch (e: Exception) {', '}', () { + indent.writeln('throw e'); + }); + }); + + indent.writeln('error("${api.name} has not been set")'); + }); + } + }); + } + /// Write the kotlin code that represents a host [Api], [api]. /// Example: /// interface Foo { @@ -700,6 +812,11 @@ if (wrapped == null) { AstHostApi api, { required String dartPackageName, }) { + if (generatorOptions.useJni) { + _writeJniApi(generatorOptions, root, indent, api, + dartPackageName: dartPackageName); + return; + } final String apiName = api.name; const List generatedMessages = [ @@ -1293,7 +1410,8 @@ private fun deepEquals${generatorOptions.fileSpecificClassNameComponent}(a: Any? Indent indent, { required String dartPackageName, }) { - if (root.containsHostApi || root.containsProxyApi) { + if ((root.containsHostApi && !generatorOptions.useJni) || + root.containsProxyApi) { _writeWrapResult(indent); _writeWrapError(generatorOptions, indent); } @@ -1320,6 +1438,8 @@ private fun deepEquals${generatorOptions.fileSpecificClassNameComponent}(a: Any? bool isAsynchronous = false, bool isOpen = false, bool isAbstract = false, + bool isOverride = false, + bool useJni = false, String Function(int index, NamedType type) getArgumentName = _getArgumentName, }) { @@ -1352,20 +1472,25 @@ private fun deepEquals${generatorOptions.fileSpecificClassNameComponent}(a: Any? } final String openKeyword = isOpen ? 'open ' : ''; - final String abstractKeyword = isAbstract ? 'abstract ' : ''; - - if (isAsynchronous) { + final String inheritanceKeyword = isAbstract + ? 'abstract ' + : isOverride + ? 'override ' + : ''; + final String suspendKeyword = isAsynchronous && useJni ? 'suspend ' : ''; + + if (isAsynchronous && !useJni) { argSignature.add('callback: (Result<$resultType>) -> Unit'); indent.writeln( - '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')})', + '$openKeyword$inheritanceKeyword${suspendKeyword}fun $name(${argSignature.join(', ')})', ); } else if (returnType.isVoid) { indent.writeln( - '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')})', + '$openKeyword$inheritanceKeyword${suspendKeyword}fun $name(${argSignature.join(', ')})', ); } else { indent.writeln( - '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')}): $returnTypeString', + '$openKeyword$inheritanceKeyword${suspendKeyword}fun $name(${argSignature.join(', ')}): $returnTypeString', ); } } diff --git a/packages/pigeon/lib/src/pigeon_lib.dart b/packages/pigeon/lib/src/pigeon_lib.dart index a60659ac3c58..fc0643def497 100644 --- a/packages/pigeon/lib/src/pigeon_lib.dart +++ b/packages/pigeon/lib/src/pigeon_lib.dart @@ -658,6 +658,7 @@ ${_argParser.usage}'''; JavaGeneratorAdapter(), SwiftGeneratorAdapter(), KotlinGeneratorAdapter(), + JnigenYamlGeneratorAdapter(), CppGeneratorAdapter(), GObjectGeneratorAdapter(), DartTestGeneratorAdapter(), diff --git a/packages/pigeon/lib/src/pigeon_lib_internal.dart b/packages/pigeon/lib/src/pigeon_lib_internal.dart index 842fbe7c13da..128d2d37a182 100644 --- a/packages/pigeon/lib/src/pigeon_lib_internal.dart +++ b/packages/pigeon/lib/src/pigeon_lib_internal.dart @@ -23,6 +23,7 @@ import 'dart/dart_generator.dart'; import 'generator_tools.dart'; import 'gobject/gobject_generator.dart'; import 'java/java_generator.dart'; +import 'kotlin/jnigen_yaml_generator.dart'; import 'kotlin/kotlin_generator.dart'; import 'objc/objc_generator.dart'; import 'pigeon_lib.dart'; @@ -619,6 +620,51 @@ class KotlinGeneratorAdapter implements GeneratorAdapter { List validate(InternalPigeonOptions options, Root root) => []; } +/// A [GeneratorAdapter] that generates JnigenYaml source code. +class JnigenYamlGeneratorAdapter implements GeneratorAdapter { + /// Constructor for [JnigenYamlGeneratorAdapter]. + JnigenYamlGeneratorAdapter( + {this.fileTypeList = const [FileType.na]}); + + @override + List fileTypeList; + + @override + void generate(StringSink sink, InternalPigeonOptions options, Root root, + FileType fileType) { + if (options.kotlinOptions == null) { + return; + } + final JnigenYamlGenerator generator = JnigenYamlGenerator(); + final InternalJnigenYamlOptions jnigenYamlOptions = + InternalJnigenYamlOptions( + options.dartOptions!, + options.kotlinOptions!, + options.basePath, + options.dartOptions?.dartOut, + options.kotlinOptions!.exampleAppDirectory, + ); + + generator.generate( + jnigenYamlOptions, + root, + sink, + dartPackageName: options.dartPackageName, + ); + } + + @override + IOSink? shouldGenerate(InternalPigeonOptions options, FileType _) => + options.kotlinOptions?.kotlinOut != null && + (options.kotlinOptions?.useJni ?? false) + ? _openSink('jnigen.yaml', + basePath: options.kotlinOptions?.exampleAppDirectory ?? '') + : null; + + @override + List validate(InternalPigeonOptions options, Root root) => []; +} + dart_ast.Annotation? _findMetadata( dart_ast.NodeList metadata, String query) { final Iterable annotations = metadata diff --git a/packages/pigeon/pigeons/jni_tests.dart b/packages/pigeon/pigeons/jni_tests.dart new file mode 100644 index 000000000000..34ad4455213e --- /dev/null +++ b/packages/pigeon/pigeons/jni_tests.dart @@ -0,0 +1,75 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:pigeon/pigeon.dart'; + +@ConfigurePigeon(PigeonOptions( + dartOptions: DartOptions(useJni: true), + kotlinOptions: KotlinOptions(useJni: true), +)) +class SomeTypes { + const SomeTypes(this.aString, this.anInt, this.aDouble, this.aBool); + final String aString; + final int anInt; + final double aDouble; + final bool aBool; + // Object anObject; +} + +class SomeNullableTypes { + String? aString; + int? anInt; + double? aDouble; + bool? aBool; + // Object? anObject; +} + +@HostApi() +abstract class JniMessageApi { + void doNothing(); + String echoString(String request); + int echoInt(int request); + double echoDouble(double request); + bool echoBool(bool request); + SomeTypes sendSomeTypes(SomeTypes someTypes); +} + +@HostApi() +abstract class JniMessageApiNullable { + String? echoString(String? request); + int? echoInt(int? request); + double? echoDouble(double? request); + bool? echoBool(bool? request); + SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes); +} + +@HostApi() +abstract class JniMessageApiAsync { + @async + void doNothing(); + @async + String echoString(String request); + @async + int echoInt(int request); + @async + double echoDouble(double request); + @async + bool echoBool(bool request); + @async + SomeTypes sendSomeTypes(SomeTypes someTypes); +} + +// @HostApi() +// abstract class JniMessageApiNullableAsync { +// @async +// String? echoString(String? request); +// @async +// int? echoInt(int? request); +// @async +// double? echoDouble(double? request); +// @async +// bool? echoBool(bool? request); +// @async +// SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes); +// } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart index 48b495dd6a33..d0aa41d8b827 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart @@ -12,6 +12,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'generated.dart'; +import 'src/generated/jni_tests.gen.dart'; import 'test_types.dart'; /// Possible host languages that test can target. @@ -45,6 +46,75 @@ const Set proxyApiSupportedLanguages = { void runPigeonIntegrationTests(TargetGenerator targetGenerator) { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + testWidgets('jni', (WidgetTester _) async { + final JniMessageApi? jniMessage = JniMessageApi.getInstance(); + expect(jniMessage, isNotNull); + expect(jniMessage!.echoString('hello'), 'hello'); + final SomeTypes sync = jniMessage.sendSomeTypes(SomeTypes( + aString: 'hi', + anInt: 5, + aDouble: 5.0, + aBool: false, + )); + expect(sync.aString, 'hi'); + expect(sync.anInt, 5); + expect(sync.aDouble, 5.0); + expect(sync.aBool, false); + //nullable + // final JniMessageApiNullable? jniMessageNullable = + // JniMessageApiNullable.getInstance(); + // expect(jniMessageNullable, isNotNull); + // expect(jniMessageNullable!.echoString('hello'), 'hello'); + // expect(jniMessageNullable.echoString(null), null); + // final SomeNullableTypes? syncNullable = + // jniMessageNullable.sendSomeNullableTypes(SomeNullableTypes()); + // expect(syncNullable!.aString, null); + // expect(syncNullable.anInt, null); + // expect(syncNullable.aDouble, null); + // expect(syncNullable.aBool, null); + // final SomeNullableTypes? syncNull = + // jniMessageNullable.sendSomeNullableTypes(null); + // expect(syncNull, null); + //async + final JniMessageApiAsync? jniMessageAsync = + JniMessageApiAsync.getInstance(); + + final SomeTypes nonSync = await jniMessageAsync!.sendSomeTypes(SomeTypes( + aString: 'hi', + anInt: 5, + aDouble: 5.0, + aBool: false, + )); + expect(nonSync.aString, 'hi'); + expect(nonSync.anInt, 5); + expect(nonSync.aDouble, 5.0); + expect(nonSync.aBool, false); + //nullable async + // final JniMessageApiNullableAsync? jniMessageNullableAsync = + // JniMessageApiNullableAsync.getInstance(); + // expect(jniMessageNullableAsync, isNotNull); + // expect(await jniMessageNullableAsync!.echoString('hello'), 'hello'); + // expect(await jniMessageNullableAsync.echoString(null), null); + // final SomeNullableTypes? syncNullableAsync = await jniMessageNullableAsync + // .sendSomeNullableTypes(SomeNullableTypes()); + // expect(syncNullableAsync!.aString, null); + // expect(syncNullableAsync.anInt, null); + // expect(syncNullableAsync.aDouble, null); + // expect(syncNullableAsync.aBool, null); + // final SomeNullableTypes? syncNullAsync = + // await jniMessageNullableAsync.sendSomeNullableTypes(null); + // expect(syncNull, null); + //named + final JniMessageApi? jniMessageNamed = + JniMessageApi.getInstance(channelName: 'name'); + final JniMessageApiAsync? jniMessageAsyncNamed = + JniMessageApiAsync.getInstance(channelName: 'name'); + expect(jniMessageNamed, isNotNull); + expect(jniMessageNamed!.echoString('hello'), 'hello1'); + expect(await jniMessageAsync.echoInt(5), 5); + expect(await jniMessageAsyncNamed!.echoInt(5), 6); + }); + group('Host sync API tests', () { testWidgets('basic void->void call works', (WidgetTester _) async { final HostIntegrationCoreApi api = HostIntegrationCoreApi(); diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart new file mode 100644 index 000000000000..9a51e2c02fbf --- /dev/null +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart @@ -0,0 +1,384 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Autogenerated from Pigeon, do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers + +import 'dart:async'; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; + +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; +import 'package:flutter/services.dart'; +import 'package:jni/jni.dart'; +import './jni_tests.gen.jni.dart' as bridge; + +Object? convertObject(JObject? object) { + if (object == null) { + return null; + } + if (object.isA(JLong.type)) { + return (object.as(JLong.type)).intValue(); + } + if (object.isA(JDouble.type)) { + return (object.as(JDouble.type)).doubleValue(); + } + if (object.isA(JString.type)) { + return (object.as(JString.type)).toDartString(); + } + if (object.isA(JBoolean.type)) { + return (object.as(JBoolean.type)).booleanValue(); + } + if (object.isA>(JList.type(JObject.type))) { + final JList list = (object.as(JList.type(JObject.type))); + final List res = []; + for (int i = 0; i < list.length; i++) { + res.add(convertObject(list[i])); + } + return res; + } + if (object.isA>( + JMap.type(JObject.type, JObject.type))) { + final JMap map = + (object.as(JMap.type(JObject.type, JObject.type))); + final Map res = {}; + for (final MapEntry entry in map.entries) { + res[convertObject(entry.key)] = convertObject(entry.value); + } + return res; + } + return object; +} + +class SomeTypes { + SomeTypes({ + required this.aString, + required this.anInt, + required this.aDouble, + required this.aBool, + }); + + String aString; + + int anInt; + + double aDouble; + + bool aBool; + + List _toList() { + return [ + aString, + anInt, + aDouble, + aBool, + ]; + } + + bridge.SomeTypes toJni() { + return bridge.SomeTypes( + JString.fromString(aString), + anInt, + aDouble, + aBool, + ); + } + + Object encode() { + return _toList(); + } + + static SomeTypes? fromJni(bridge.SomeTypes? jniClass) { + return jniClass == null + ? null + : SomeTypes( + aString: jniClass.getAString().toDartString(releaseOriginal: true), + anInt: jniClass.getAnInt(), + aDouble: jniClass.getADouble(), + aBool: jniClass.getABool(), + ); + } + + static SomeTypes decode(Object result) { + result as List; + return SomeTypes( + aString: result[0]! as String, + anInt: result[1]! as int, + aDouble: result[2]! as double, + aBool: result[3]! as bool, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! SomeTypes || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return aString == other.aString && + anInt == other.anInt && + aDouble == other.aDouble && + aBool == other.aBool; + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()); +} + +class SomeNullableTypes { + SomeNullableTypes({ + this.aString, + this.anInt, + this.aDouble, + this.aBool, + }); + + String? aString; + + int? anInt; + + double? aDouble; + + bool? aBool; + + List _toList() { + return [ + aString, + anInt, + aDouble, + aBool, + ]; + } + + bridge.SomeNullableTypes toJni() { + return bridge.SomeNullableTypes( + aString != null ? JString.fromString(aString!) : null, + anInt != null ? JLong(anInt!) : null, + aDouble != null ? JDouble(aDouble!) : null, + aBool != null ? JBoolean(aBool!) : null, + ); + } + + Object encode() { + return _toList(); + } + + static SomeNullableTypes? fromJni(bridge.SomeNullableTypes? jniClass) { + return jniClass == null + ? null + : SomeNullableTypes( + aString: jniClass.getAString()?.toDartString(releaseOriginal: true), + anInt: jniClass.getAnInt()?.intValue(releaseOriginal: true), + aDouble: jniClass.getADouble()?.doubleValue(releaseOriginal: true), + aBool: jniClass.getABool()?.booleanValue(releaseOriginal: true), + ); + } + + static SomeNullableTypes decode(Object result) { + result as List; + return SomeNullableTypes( + aString: result[0] as String?, + anInt: result[1] as int?, + aDouble: result[2] as double?, + aBool: result[3] as bool?, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! SomeNullableTypes || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return aString == other.aString && + anInt == other.anInt && + aDouble == other.aDouble && + aBool == other.aBool; + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()); +} + +const String defaultInstanceName = + 'PigeonDefaultClassName32uh4ui3lh445uh4h3l2l455g4y34u'; + +class JniMessageApi { + JniMessageApi._withRegistrar(bridge.JniMessageApiRegistrar api) : _api = api; + + /// Returns instance of JniMessageApi with specified [channelName] if one has been registered. + static JniMessageApi? getInstance( + {String channelName = defaultInstanceName}) { + final bridge.JniMessageApiRegistrar? link = bridge.JniMessageApiRegistrar() + .getInstance(JString.fromString(channelName)); + if (link == null) { + String nameString = 'named $channelName'; + if (channelName == defaultInstanceName) { + nameString = 'with no name'; + } + final String error = 'No instance $nameString has been registered.'; + throw ArgumentError(error); + } + final JniMessageApi res = JniMessageApi._withRegistrar(link); + return res; + } + + late final bridge.JniMessageApiRegistrar _api; + + void doNothing() { + return _api.doNothing(); + } + + String echoString(String request) { + final JString res = _api.echoString(JString.fromString(request)); + final String dartTypeRes = res.toDartString(releaseOriginal: true); + return dartTypeRes; + } + + int echoInt(int request) { + return _api.echoInt(request); + } + + double echoDouble(double request) { + return _api.echoDouble(request); + } + + bool echoBool(bool request) { + return _api.echoBool(request); + } + + SomeTypes sendSomeTypes(SomeTypes someTypes) { + final bridge.SomeTypes res = _api.sendSomeTypes(someTypes.toJni()); + final SomeTypes dartTypeRes = SomeTypes.fromJni(res)!; + return dartTypeRes; + } +} + +class JniMessageApiNullable { + JniMessageApiNullable._withRegistrar( + bridge.JniMessageApiNullableRegistrar api) + : _api = api; + + /// Returns instance of JniMessageApiNullable with specified [channelName] if one has been registered. + static JniMessageApiNullable? getInstance( + {String channelName = defaultInstanceName}) { + final bridge.JniMessageApiNullableRegistrar? link = + bridge.JniMessageApiNullableRegistrar() + .getInstance(JString.fromString(channelName)); + if (link == null) { + String nameString = 'named $channelName'; + if (channelName == defaultInstanceName) { + nameString = 'with no name'; + } + final String error = 'No instance $nameString has been registered.'; + throw ArgumentError(error); + } + final JniMessageApiNullable res = + JniMessageApiNullable._withRegistrar(link); + return res; + } + + late final bridge.JniMessageApiNullableRegistrar _api; + + String? echoString(String? request) { + final JString? res = + _api.echoString(request != null ? JString.fromString(request) : null); + final String? dartTypeRes = res?.toDartString(releaseOriginal: true); + return dartTypeRes; + } + + int? echoInt(int? request) { + final JLong? res = _api.echoInt(request != null ? JLong(request) : null); + final int? dartTypeRes = res?.intValue(releaseOriginal: true); + return dartTypeRes; + } + + double? echoDouble(double? request) { + final JDouble? res = + _api.echoDouble(request != null ? JDouble(request) : null); + final double? dartTypeRes = res?.doubleValue(releaseOriginal: true); + return dartTypeRes; + } + + bool? echoBool(bool? request) { + final JBoolean? res = + _api.echoBool(request != null ? JBoolean(request) : null); + final bool? dartTypeRes = res?.booleanValue(releaseOriginal: true); + return dartTypeRes; + } + + SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes) { + final bridge.SomeNullableTypes? res = + _api.sendSomeNullableTypes(someTypes?.toJni()); + final SomeNullableTypes? dartTypeRes = SomeNullableTypes.fromJni(res); + return dartTypeRes; + } +} + +class JniMessageApiAsync { + JniMessageApiAsync._withRegistrar(bridge.JniMessageApiAsyncRegistrar api) + : _api = api; + + /// Returns instance of JniMessageApiAsync with specified [channelName] if one has been registered. + static JniMessageApiAsync? getInstance( + {String channelName = defaultInstanceName}) { + final bridge.JniMessageApiAsyncRegistrar? link = + bridge.JniMessageApiAsyncRegistrar() + .getInstance(JString.fromString(channelName)); + if (link == null) { + String nameString = 'named $channelName'; + if (channelName == defaultInstanceName) { + nameString = 'with no name'; + } + final String error = 'No instance $nameString has been registered.'; + throw ArgumentError(error); + } + final JniMessageApiAsync res = JniMessageApiAsync._withRegistrar(link); + return res; + } + + late final bridge.JniMessageApiAsyncRegistrar _api; + + Future doNothing() async { + await _api.doNothing(); + } + + Future echoString(String request) async { + final JString res = await _api.echoString(JString.fromString(request)); + final String dartTypeRes = res.toDartString(releaseOriginal: true); + return dartTypeRes; + } + + Future echoInt(int request) async { + final JLong res = await _api.echoInt(request); + final int dartTypeRes = res.intValue(releaseOriginal: true); + return dartTypeRes; + } + + Future echoDouble(double request) async { + final JDouble res = await _api.echoDouble(request); + final double dartTypeRes = res.doubleValue(releaseOriginal: true); + return dartTypeRes; + } + + Future echoBool(bool request) async { + final JBoolean res = await _api.echoBool(request); + final bool dartTypeRes = res.booleanValue(releaseOriginal: true); + return dartTypeRes; + } + + Future sendSomeTypes(SomeTypes someTypes) async { + final bridge.SomeTypes res = await _api.sendSomeTypes(someTypes.toJni()); + final SomeTypes dartTypeRes = SomeTypes.fromJni(res)!; + return dartTypeRes; + } +} diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart new file mode 100644 index 000000000000..a7b1a8ceac63 --- /dev/null +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart @@ -0,0 +1,3510 @@ +// Autogenerated by jnigen. DO NOT EDIT! + +// ignore_for_file: annotate_overrides +// ignore_for_file: argument_type_not_assignable +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: doc_directive_unknown +// ignore_for_file: file_names +// ignore_for_file: inference_failure_on_untyped_parameter +// ignore_for_file: invalid_internal_annotation +// ignore_for_file: invalid_use_of_internal_member +// ignore_for_file: library_prefixes +// ignore_for_file: lines_longer_than_80_chars +// ignore_for_file: no_leading_underscores_for_library_prefixes +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: only_throw_errors +// ignore_for_file: overridden_fields +// ignore_for_file: prefer_double_quotes +// ignore_for_file: unintended_html_in_doc_comment +// ignore_for_file: unnecessary_cast +// ignore_for_file: unnecessary_non_null_assertion +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_local_variable +// ignore_for_file: unused_shown_name +// ignore_for_file: use_super_parameters + +import 'dart:core' show Object, String, bool, double, int; +import 'dart:core' as core$_; + +import 'package:jni/_internal.dart' as jni$_; +import 'package:jni/jni.dart' as jni$_; + +/// from: `JniMessageApi` +class JniMessageApi extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + JniMessageApi.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'JniMessageApi'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $JniMessageApi$NullableType(); + static const type = $JniMessageApi$Type(); + static final _id_doNothing = _class.instanceMethodId( + r'doNothing', + r'()V', + ); + + static final _doNothing = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract void doNothing()` + void doNothing() { + _doNothing(reference.pointer, _id_doNothing as jni$_.JMethodIDPtr).check(); + } + + static final _id_echoString = _class.instanceMethodId( + r'echoString', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _echoString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.String echoString(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString echoString( + jni$_.JString string, + ) { + final _$string = string.reference; + return _echoString(reference.pointer, _id_echoString as jni$_.JMethodIDPtr, + _$string.pointer) + .object(const jni$_.JStringType()); + } + + static final _id_echoInt = _class.instanceMethodId( + r'echoInt', + r'(J)J', + ); + + static final _echoInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int64,)>)>>('globalEnv_CallLongMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public abstract long echoInt(long j)` + int echoInt( + int j, + ) { + return _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, j) + .long; + } + + static final _id_echoDouble = _class.instanceMethodId( + r'echoDouble', + r'(D)D', + ); + + static final _echoDouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Double,)>)>>('globalEnv_CallDoubleMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, double)>(); + + /// from: `public abstract double echoDouble(double d)` + double echoDouble( + double d, + ) { + return _echoDouble( + reference.pointer, _id_echoDouble as jni$_.JMethodIDPtr, d) + .doubleFloat; + } + + static final _id_echoBool = _class.instanceMethodId( + r'echoBool', + r'(Z)Z', + ); + + static final _echoBool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public abstract boolean echoBool(boolean z)` + bool echoBool( + bool z, + ) { + return _echoBool( + reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, z ? 1 : 0) + .boolean; + } + + static final _id_sendSomeTypes = _class.instanceMethodId( + r'sendSomeTypes', + r'(LSomeTypes;)LSomeTypes;', + ); + + static final _sendSomeTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract SomeTypes sendSomeTypes(SomeTypes someTypes)` + /// The returned object must be released after use, by calling the [release] method. + SomeTypes sendSomeTypes( + SomeTypes someTypes, + ) { + final _$someTypes = someTypes.reference; + return _sendSomeTypes(reference.pointer, + _id_sendSomeTypes as jni$_.JMethodIDPtr, _$someTypes.pointer) + .object(const $SomeTypes$Type()); + } +} + +final class $JniMessageApi$NullableType extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApi$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApi;'; + + @jni$_.internal + @core$_.override + JniMessageApi? fromReference(jni$_.JReference reference) => reference.isNull + ? null + : JniMessageApi.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($JniMessageApi$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApi$NullableType) && + other is $JniMessageApi$NullableType; + } +} + +final class $JniMessageApi$Type extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApi$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApi;'; + + @jni$_.internal + @core$_.override + JniMessageApi fromReference(jni$_.JReference reference) => + JniMessageApi.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $JniMessageApi$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($JniMessageApi$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApi$Type) && + other is $JniMessageApi$Type; + } +} + +/// from: `JniMessageApiRegistrar` +class JniMessageApiRegistrar extends JniMessageApi { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + JniMessageApiRegistrar.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'JniMessageApiRegistrar'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $JniMessageApiRegistrar$NullableType(); + static const type = $JniMessageApiRegistrar$Type(); + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory JniMessageApiRegistrar() { + return JniMessageApiRegistrar.fromReference( + _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) + .reference); + } + + static final _id_getApi = _class.instanceMethodId( + r'getApi', + r'()LJniMessageApi;', + ); + + static final _getApi = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final JniMessageApi getApi()` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApi? getApi() { + return _getApi(reference.pointer, _id_getApi as jni$_.JMethodIDPtr) + .object(const $JniMessageApi$NullableType()); + } + + static final _id_setApi = _class.instanceMethodId( + r'setApi', + r'(LJniMessageApi;)V', + ); + + static final _setApi = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final void setApi(JniMessageApi jniMessageApi)` + void setApi( + JniMessageApi? jniMessageApi, + ) { + final _$jniMessageApi = jniMessageApi?.reference ?? jni$_.jNullReference; + _setApi(reference.pointer, _id_setApi as jni$_.JMethodIDPtr, + _$jniMessageApi.pointer) + .check(); + } + + static final _id_register = _class.instanceMethodId( + r'register', + r'(LJniMessageApi;Ljava/lang/String;)LJniMessageApiRegistrar;', + ); + + static final _register = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public final JniMessageApiRegistrar register(JniMessageApi jniMessageApi, java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiRegistrar register( + JniMessageApi jniMessageApi, + jni$_.JString string, + ) { + final _$jniMessageApi = jniMessageApi.reference; + final _$string = string.reference; + return _register(reference.pointer, _id_register as jni$_.JMethodIDPtr, + _$jniMessageApi.pointer, _$string.pointer) + .object(const $JniMessageApiRegistrar$Type()); + } + + static final _id_getInstance = _class.instanceMethodId( + r'getInstance', + r'(Ljava/lang/String;)LJniMessageApiRegistrar;', + ); + + static final _getInstance = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final JniMessageApiRegistrar getInstance(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiRegistrar? getInstance( + jni$_.JString string, + ) { + final _$string = string.reference; + return _getInstance(reference.pointer, + _id_getInstance as jni$_.JMethodIDPtr, _$string.pointer) + .object( + const $JniMessageApiRegistrar$NullableType()); + } + + static final _id_doNothing = _class.instanceMethodId( + r'doNothing', + r'()V', + ); + + static final _doNothing = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void doNothing()` + void doNothing() { + _doNothing(reference.pointer, _id_doNothing as jni$_.JMethodIDPtr).check(); + } + + static final _id_echoString = _class.instanceMethodId( + r'echoString', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _echoString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.String echoString(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString echoString( + jni$_.JString string, + ) { + final _$string = string.reference; + return _echoString(reference.pointer, _id_echoString as jni$_.JMethodIDPtr, + _$string.pointer) + .object(const jni$_.JStringType()); + } + + static final _id_echoInt = _class.instanceMethodId( + r'echoInt', + r'(J)J', + ); + + static final _echoInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int64,)>)>>('globalEnv_CallLongMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public long echoInt(long j)` + int echoInt( + int j, + ) { + return _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, j) + .long; + } + + static final _id_echoDouble = _class.instanceMethodId( + r'echoDouble', + r'(D)D', + ); + + static final _echoDouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Double,)>)>>('globalEnv_CallDoubleMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, double)>(); + + /// from: `public double echoDouble(double d)` + double echoDouble( + double d, + ) { + return _echoDouble( + reference.pointer, _id_echoDouble as jni$_.JMethodIDPtr, d) + .doubleFloat; + } + + static final _id_echoBool = _class.instanceMethodId( + r'echoBool', + r'(Z)Z', + ); + + static final _echoBool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public boolean echoBool(boolean z)` + bool echoBool( + bool z, + ) { + return _echoBool( + reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, z ? 1 : 0) + .boolean; + } + + static final _id_sendSomeTypes = _class.instanceMethodId( + r'sendSomeTypes', + r'(LSomeTypes;)LSomeTypes;', + ); + + static final _sendSomeTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public SomeTypes sendSomeTypes(SomeTypes someTypes)` + /// The returned object must be released after use, by calling the [release] method. + SomeTypes sendSomeTypes( + SomeTypes someTypes, + ) { + final _$someTypes = someTypes.reference; + return _sendSomeTypes(reference.pointer, + _id_sendSomeTypes as jni$_.JMethodIDPtr, _$someTypes.pointer) + .object(const $SomeTypes$Type()); + } +} + +final class $JniMessageApiRegistrar$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiRegistrar;'; + + @jni$_.internal + @core$_.override + JniMessageApiRegistrar? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : JniMessageApiRegistrar.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const $JniMessageApi$Type(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 2; + + @core$_.override + int get hashCode => ($JniMessageApiRegistrar$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiRegistrar$NullableType) && + other is $JniMessageApiRegistrar$NullableType; + } +} + +final class $JniMessageApiRegistrar$Type + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiRegistrar$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiRegistrar;'; + + @jni$_.internal + @core$_.override + JniMessageApiRegistrar fromReference(jni$_.JReference reference) => + JniMessageApiRegistrar.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const $JniMessageApi$Type(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $JniMessageApiRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 2; + + @core$_.override + int get hashCode => ($JniMessageApiRegistrar$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiRegistrar$Type) && + other is $JniMessageApiRegistrar$Type; + } +} + +/// from: `JniMessageApiNullable` +class JniMessageApiNullable extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + JniMessageApiNullable.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'JniMessageApiNullable'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $JniMessageApiNullable$NullableType(); + static const type = $JniMessageApiNullable$Type(); + static final _id_echoString = _class.instanceMethodId( + r'echoString', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _echoString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.String echoString(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? echoString( + jni$_.JString? string, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _echoString(reference.pointer, _id_echoString as jni$_.JMethodIDPtr, + _$string.pointer) + .object(const jni$_.JStringNullableType()); + } + + static final _id_echoInt = _class.instanceMethodId( + r'echoInt', + r'(Ljava/lang/Long;)Ljava/lang/Long;', + ); + + static final _echoInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Long echoInt(java.lang.Long long)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JLong? echoInt( + jni$_.JLong? long, + ) { + final _$long = long?.reference ?? jni$_.jNullReference; + return _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, + _$long.pointer) + .object(const jni$_.JLongNullableType()); + } + + static final _id_echoDouble = _class.instanceMethodId( + r'echoDouble', + r'(Ljava/lang/Double;)Ljava/lang/Double;', + ); + + static final _echoDouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Double echoDouble(java.lang.Double double)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JDouble? echoDouble( + jni$_.JDouble? double, + ) { + final _$double = double?.reference ?? jni$_.jNullReference; + return _echoDouble(reference.pointer, _id_echoDouble as jni$_.JMethodIDPtr, + _$double.pointer) + .object(const jni$_.JDoubleNullableType()); + } + + static final _id_echoBool = _class.instanceMethodId( + r'echoBool', + r'(Ljava/lang/Boolean;)Ljava/lang/Boolean;', + ); + + static final _echoBool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Boolean echoBool(java.lang.Boolean boolean)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JBoolean? echoBool( + jni$_.JBoolean? boolean, + ) { + final _$boolean = boolean?.reference ?? jni$_.jNullReference; + return _echoBool(reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, + _$boolean.pointer) + .object(const jni$_.JBooleanNullableType()); + } + + static final _id_sendSomeNullableTypes = _class.instanceMethodId( + r'sendSomeNullableTypes', + r'(LSomeNullableTypes;)LSomeNullableTypes;', + ); + + static final _sendSomeNullableTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract SomeNullableTypes sendSomeNullableTypes(SomeNullableTypes someNullableTypes)` + /// The returned object must be released after use, by calling the [release] method. + SomeNullableTypes? sendSomeNullableTypes( + SomeNullableTypes? someNullableTypes, + ) { + final _$someNullableTypes = + someNullableTypes?.reference ?? jni$_.jNullReference; + return _sendSomeNullableTypes( + reference.pointer, + _id_sendSomeNullableTypes as jni$_.JMethodIDPtr, + _$someNullableTypes.pointer) + .object(const $SomeNullableTypes$NullableType()); + } +} + +final class $JniMessageApiNullable$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullable$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullable;'; + + @jni$_.internal + @core$_.override + JniMessageApiNullable? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : JniMessageApiNullable.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($JniMessageApiNullable$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiNullable$NullableType) && + other is $JniMessageApiNullable$NullableType; + } +} + +final class $JniMessageApiNullable$Type + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullable$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullable;'; + + @jni$_.internal + @core$_.override + JniMessageApiNullable fromReference(jni$_.JReference reference) => + JniMessageApiNullable.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $JniMessageApiNullable$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($JniMessageApiNullable$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiNullable$Type) && + other is $JniMessageApiNullable$Type; + } +} + +/// from: `JniMessageApiNullableRegistrar` +class JniMessageApiNullableRegistrar extends JniMessageApiNullable { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + JniMessageApiNullableRegistrar.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'JniMessageApiNullableRegistrar'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $JniMessageApiNullableRegistrar$NullableType(); + static const type = $JniMessageApiNullableRegistrar$Type(); + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory JniMessageApiNullableRegistrar() { + return JniMessageApiNullableRegistrar.fromReference( + _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) + .reference); + } + + static final _id_getApi = _class.instanceMethodId( + r'getApi', + r'()LJniMessageApiNullable;', + ); + + static final _getApi = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final JniMessageApiNullable getApi()` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiNullable? getApi() { + return _getApi(reference.pointer, _id_getApi as jni$_.JMethodIDPtr) + .object( + const $JniMessageApiNullable$NullableType()); + } + + static final _id_setApi = _class.instanceMethodId( + r'setApi', + r'(LJniMessageApiNullable;)V', + ); + + static final _setApi = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final void setApi(JniMessageApiNullable jniMessageApiNullable)` + void setApi( + JniMessageApiNullable? jniMessageApiNullable, + ) { + final _$jniMessageApiNullable = + jniMessageApiNullable?.reference ?? jni$_.jNullReference; + _setApi(reference.pointer, _id_setApi as jni$_.JMethodIDPtr, + _$jniMessageApiNullable.pointer) + .check(); + } + + static final _id_register = _class.instanceMethodId( + r'register', + r'(LJniMessageApiNullable;Ljava/lang/String;)LJniMessageApiNullableRegistrar;', + ); + + static final _register = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public final JniMessageApiNullableRegistrar register(JniMessageApiNullable jniMessageApiNullable, java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiNullableRegistrar register( + JniMessageApiNullable jniMessageApiNullable, + jni$_.JString string, + ) { + final _$jniMessageApiNullable = jniMessageApiNullable.reference; + final _$string = string.reference; + return _register(reference.pointer, _id_register as jni$_.JMethodIDPtr, + _$jniMessageApiNullable.pointer, _$string.pointer) + .object( + const $JniMessageApiNullableRegistrar$Type()); + } + + static final _id_getInstance = _class.instanceMethodId( + r'getInstance', + r'(Ljava/lang/String;)LJniMessageApiNullableRegistrar;', + ); + + static final _getInstance = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final JniMessageApiNullableRegistrar getInstance(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiNullableRegistrar? getInstance( + jni$_.JString string, + ) { + final _$string = string.reference; + return _getInstance(reference.pointer, + _id_getInstance as jni$_.JMethodIDPtr, _$string.pointer) + .object( + const $JniMessageApiNullableRegistrar$NullableType()); + } + + static final _id_echoString = _class.instanceMethodId( + r'echoString', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _echoString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.String echoString(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? echoString( + jni$_.JString? string, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _echoString(reference.pointer, _id_echoString as jni$_.JMethodIDPtr, + _$string.pointer) + .object(const jni$_.JStringNullableType()); + } + + static final _id_echoInt = _class.instanceMethodId( + r'echoInt', + r'(Ljava/lang/Long;)Ljava/lang/Long;', + ); + + static final _echoInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.Long echoInt(java.lang.Long long)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JLong? echoInt( + jni$_.JLong? long, + ) { + final _$long = long?.reference ?? jni$_.jNullReference; + return _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, + _$long.pointer) + .object(const jni$_.JLongNullableType()); + } + + static final _id_echoDouble = _class.instanceMethodId( + r'echoDouble', + r'(Ljava/lang/Double;)Ljava/lang/Double;', + ); + + static final _echoDouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.Double echoDouble(java.lang.Double double)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JDouble? echoDouble( + jni$_.JDouble? double, + ) { + final _$double = double?.reference ?? jni$_.jNullReference; + return _echoDouble(reference.pointer, _id_echoDouble as jni$_.JMethodIDPtr, + _$double.pointer) + .object(const jni$_.JDoubleNullableType()); + } + + static final _id_echoBool = _class.instanceMethodId( + r'echoBool', + r'(Ljava/lang/Boolean;)Ljava/lang/Boolean;', + ); + + static final _echoBool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.Boolean echoBool(java.lang.Boolean boolean)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JBoolean? echoBool( + jni$_.JBoolean? boolean, + ) { + final _$boolean = boolean?.reference ?? jni$_.jNullReference; + return _echoBool(reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, + _$boolean.pointer) + .object(const jni$_.JBooleanNullableType()); + } + + static final _id_sendSomeNullableTypes = _class.instanceMethodId( + r'sendSomeNullableTypes', + r'(LSomeNullableTypes;)LSomeNullableTypes;', + ); + + static final _sendSomeNullableTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public SomeNullableTypes sendSomeNullableTypes(SomeNullableTypes someNullableTypes)` + /// The returned object must be released after use, by calling the [release] method. + SomeNullableTypes? sendSomeNullableTypes( + SomeNullableTypes? someNullableTypes, + ) { + final _$someNullableTypes = + someNullableTypes?.reference ?? jni$_.jNullReference; + return _sendSomeNullableTypes( + reference.pointer, + _id_sendSomeNullableTypes as jni$_.JMethodIDPtr, + _$someNullableTypes.pointer) + .object(const $SomeNullableTypes$NullableType()); + } +} + +final class $JniMessageApiNullableRegistrar$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullableRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullableRegistrar;'; + + @jni$_.internal + @core$_.override + JniMessageApiNullableRegistrar? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : JniMessageApiNullableRegistrar.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const $JniMessageApiNullable$Type(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 2; + + @core$_.override + int get hashCode => ($JniMessageApiNullableRegistrar$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == + ($JniMessageApiNullableRegistrar$NullableType) && + other is $JniMessageApiNullableRegistrar$NullableType; + } +} + +final class $JniMessageApiNullableRegistrar$Type + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullableRegistrar$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullableRegistrar;'; + + @jni$_.internal + @core$_.override + JniMessageApiNullableRegistrar fromReference(jni$_.JReference reference) => + JniMessageApiNullableRegistrar.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const $JniMessageApiNullable$Type(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $JniMessageApiNullableRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 2; + + @core$_.override + int get hashCode => ($JniMessageApiNullableRegistrar$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiNullableRegistrar$Type) && + other is $JniMessageApiNullableRegistrar$Type; + } +} + +/// from: `JniMessageApiAsync` +class JniMessageApiAsync extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + JniMessageApiAsync.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'JniMessageApiAsync'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $JniMessageApiAsync$NullableType(); + static const type = $JniMessageApiAsync$Type(); + static final _id_doNothing = _class.instanceMethodId( + r'doNothing', + r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _doNothing = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object doNothing(kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future doNothing() async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _doNothing(reference.pointer, + _id_doNothing as jni$_.JMethodIDPtr, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JObjectType(), releaseOriginal: true); + } + + static final _id_echoString = _class.instanceMethodId( + r'echoString', + r'(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoString( + jni$_.JString string, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$string = string.reference; + final $r = _echoString( + reference.pointer, + _id_echoString as jni$_.JMethodIDPtr, + _$string.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JStringType(), releaseOriginal: true); + } + + static final _id_echoInt = _class.instanceMethodId( + r'echoInt', + r'(JLkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int64, jni$_.Pointer)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoInt(long j, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoInt( + int j, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, j, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JLongType(), releaseOriginal: true); + } + + static final _id_echoDouble = _class.instanceMethodId( + r'echoDouble', + r'(DLkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoDouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Double, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, double, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoDouble(double d, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoDouble( + double d, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _echoDouble(reference.pointer, + _id_echoDouble as jni$_.JMethodIDPtr, d, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JDoubleType(), releaseOriginal: true); + } + + static final _id_echoBool = _class.instanceMethodId( + r'echoBool', + r'(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoBool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32, jni$_.Pointer)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoBool(boolean z, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoBool( + bool z, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _echoBool(reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, + z ? 1 : 0, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JBooleanType(), releaseOriginal: true); + } + + static final _id_sendSomeTypes = _class.instanceMethodId( + r'sendSomeTypes', + r'(LSomeTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _sendSomeTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object sendSomeTypes(SomeTypes someTypes, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeTypes( + SomeTypes someTypes, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someTypes = someTypes.reference; + final $r = _sendSomeTypes( + reference.pointer, + _id_sendSomeTypes as jni$_.JMethodIDPtr, + _$someTypes.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const $SomeTypes$Type(), releaseOriginal: true); + } +} + +final class $JniMessageApiAsync$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiAsync$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiAsync;'; + + @jni$_.internal + @core$_.override + JniMessageApiAsync? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : JniMessageApiAsync.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($JniMessageApiAsync$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiAsync$NullableType) && + other is $JniMessageApiAsync$NullableType; + } +} + +final class $JniMessageApiAsync$Type + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiAsync$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiAsync;'; + + @jni$_.internal + @core$_.override + JniMessageApiAsync fromReference(jni$_.JReference reference) => + JniMessageApiAsync.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $JniMessageApiAsync$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($JniMessageApiAsync$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiAsync$Type) && + other is $JniMessageApiAsync$Type; + } +} + +/// from: `JniMessageApiAsyncRegistrar` +class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + JniMessageApiAsyncRegistrar.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'JniMessageApiAsyncRegistrar'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $JniMessageApiAsyncRegistrar$NullableType(); + static const type = $JniMessageApiAsyncRegistrar$Type(); + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory JniMessageApiAsyncRegistrar() { + return JniMessageApiAsyncRegistrar.fromReference( + _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) + .reference); + } + + static final _id_getApi = _class.instanceMethodId( + r'getApi', + r'()LJniMessageApiAsync;', + ); + + static final _getApi = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final JniMessageApiAsync getApi()` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiAsync? getApi() { + return _getApi(reference.pointer, _id_getApi as jni$_.JMethodIDPtr) + .object(const $JniMessageApiAsync$NullableType()); + } + + static final _id_setApi = _class.instanceMethodId( + r'setApi', + r'(LJniMessageApiAsync;)V', + ); + + static final _setApi = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final void setApi(JniMessageApiAsync jniMessageApiAsync)` + void setApi( + JniMessageApiAsync? jniMessageApiAsync, + ) { + final _$jniMessageApiAsync = + jniMessageApiAsync?.reference ?? jni$_.jNullReference; + _setApi(reference.pointer, _id_setApi as jni$_.JMethodIDPtr, + _$jniMessageApiAsync.pointer) + .check(); + } + + static final _id_register = _class.instanceMethodId( + r'register', + r'(LJniMessageApiAsync;Ljava/lang/String;)LJniMessageApiAsyncRegistrar;', + ); + + static final _register = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public final JniMessageApiAsyncRegistrar register(JniMessageApiAsync jniMessageApiAsync, java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiAsyncRegistrar register( + JniMessageApiAsync jniMessageApiAsync, + jni$_.JString string, + ) { + final _$jniMessageApiAsync = jniMessageApiAsync.reference; + final _$string = string.reference; + return _register(reference.pointer, _id_register as jni$_.JMethodIDPtr, + _$jniMessageApiAsync.pointer, _$string.pointer) + .object( + const $JniMessageApiAsyncRegistrar$Type()); + } + + static final _id_getInstance = _class.instanceMethodId( + r'getInstance', + r'(Ljava/lang/String;)LJniMessageApiAsyncRegistrar;', + ); + + static final _getInstance = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final JniMessageApiAsyncRegistrar getInstance(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiAsyncRegistrar? getInstance( + jni$_.JString string, + ) { + final _$string = string.reference; + return _getInstance(reference.pointer, + _id_getInstance as jni$_.JMethodIDPtr, _$string.pointer) + .object( + const $JniMessageApiAsyncRegistrar$NullableType()); + } + + static final _id_doNothing = _class.instanceMethodId( + r'doNothing', + r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _doNothing = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.Object doNothing(kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future doNothing() async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _doNothing(reference.pointer, + _id_doNothing as jni$_.JMethodIDPtr, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JObjectType(), releaseOriginal: true); + } + + static final _id_echoString = _class.instanceMethodId( + r'echoString', + r'(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoString( + jni$_.JString string, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$string = string.reference; + final $r = _echoString( + reference.pointer, + _id_echoString as jni$_.JMethodIDPtr, + _$string.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JStringType(), releaseOriginal: true); + } + + static final _id_echoInt = _class.instanceMethodId( + r'echoInt', + r'(JLkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int64, jni$_.Pointer)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoInt(long j, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoInt( + int j, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, j, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JLongType(), releaseOriginal: true); + } + + static final _id_echoDouble = _class.instanceMethodId( + r'echoDouble', + r'(DLkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoDouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Double, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, double, jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoDouble(double d, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoDouble( + double d, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _echoDouble(reference.pointer, + _id_echoDouble as jni$_.JMethodIDPtr, d, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JDoubleType(), releaseOriginal: true); + } + + static final _id_echoBool = _class.instanceMethodId( + r'echoBool', + r'(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoBool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32, jni$_.Pointer)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoBool(boolean z, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoBool( + bool z, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _echoBool(reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, + z ? 1 : 0, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JBooleanType(), releaseOriginal: true); + } + + static final _id_sendSomeTypes = _class.instanceMethodId( + r'sendSomeTypes', + r'(LSomeTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _sendSomeTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object sendSomeTypes(SomeTypes someTypes, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeTypes( + SomeTypes someTypes, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someTypes = someTypes.reference; + final $r = _sendSomeTypes( + reference.pointer, + _id_sendSomeTypes as jni$_.JMethodIDPtr, + _$someTypes.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const $SomeTypes$Type(), releaseOriginal: true); + } +} + +final class $JniMessageApiAsyncRegistrar$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiAsyncRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiAsyncRegistrar;'; + + @jni$_.internal + @core$_.override + JniMessageApiAsyncRegistrar? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : JniMessageApiAsyncRegistrar.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const $JniMessageApiAsync$Type(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 2; + + @core$_.override + int get hashCode => ($JniMessageApiAsyncRegistrar$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiAsyncRegistrar$NullableType) && + other is $JniMessageApiAsyncRegistrar$NullableType; + } +} + +final class $JniMessageApiAsyncRegistrar$Type + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiAsyncRegistrar$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiAsyncRegistrar;'; + + @jni$_.internal + @core$_.override + JniMessageApiAsyncRegistrar fromReference(jni$_.JReference reference) => + JniMessageApiAsyncRegistrar.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const $JniMessageApiAsync$Type(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $JniMessageApiAsyncRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 2; + + @core$_.override + int get hashCode => ($JniMessageApiAsyncRegistrar$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiAsyncRegistrar$Type) && + other is $JniMessageApiAsyncRegistrar$Type; + } +} + +/// from: `SomeTypes$Companion` +class SomeTypes$Companion extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + SomeTypes$Companion.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'SomeTypes$Companion'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $SomeTypes$Companion$NullableType(); + static const type = $SomeTypes$Companion$Type(); + static final _id_fromList = _class.instanceMethodId( + r'fromList', + r'(Ljava/util/List;)LSomeTypes;', + ); + + static final _fromList = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final SomeTypes fromList(java.util.List list)` + /// The returned object must be released after use, by calling the [release] method. + SomeTypes fromList( + jni$_.JList list, + ) { + final _$list = list.reference; + return _fromList(reference.pointer, _id_fromList as jni$_.JMethodIDPtr, + _$list.pointer) + .object(const $SomeTypes$Type()); + } + + static final _id_new$ = _class.constructorId( + r'(Lkotlin/jvm/internal/DefaultConstructorMarker;)V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `synthetic public void (kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker)` + /// The returned object must be released after use, by calling the [release] method. + factory SomeTypes$Companion( + jni$_.JObject? defaultConstructorMarker, + ) { + final _$defaultConstructorMarker = + defaultConstructorMarker?.reference ?? jni$_.jNullReference; + return SomeTypes$Companion.fromReference(_new$(_class.reference.pointer, + _id_new$ as jni$_.JMethodIDPtr, _$defaultConstructorMarker.pointer) + .reference); + } +} + +final class $SomeTypes$Companion$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $SomeTypes$Companion$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeTypes$Companion;'; + + @jni$_.internal + @core$_.override + SomeTypes$Companion? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : SomeTypes$Companion.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeTypes$Companion$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeTypes$Companion$NullableType) && + other is $SomeTypes$Companion$NullableType; + } +} + +final class $SomeTypes$Companion$Type + extends jni$_.JObjType { + @jni$_.internal + const $SomeTypes$Companion$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeTypes$Companion;'; + + @jni$_.internal + @core$_.override + SomeTypes$Companion fromReference(jni$_.JReference reference) => + SomeTypes$Companion.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $SomeTypes$Companion$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeTypes$Companion$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeTypes$Companion$Type) && + other is $SomeTypes$Companion$Type; + } +} + +/// from: `SomeTypes` +class SomeTypes extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + SomeTypes.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'SomeTypes'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $SomeTypes$NullableType(); + static const type = $SomeTypes$Type(); + static final _id_Companion = _class.staticFieldId( + r'Companion', + r'LSomeTypes$Companion;', + ); + + /// from: `static public final SomeTypes$Companion Companion` + /// The returned object must be released after use, by calling the [release] method. + static SomeTypes$Companion get Companion => + _id_Companion.get(_class, const $SomeTypes$Companion$Type()); + + static final _id_new$ = _class.constructorId( + r'(Ljava/lang/String;JDZ)V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int64, + jni$_.Double, + jni$_.Int32 + )>)>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + double, + int)>(); + + /// from: `public void (java.lang.String string, long j, double d, boolean z)` + /// The returned object must be released after use, by calling the [release] method. + factory SomeTypes( + jni$_.JString string, + int j, + double d, + bool z, + ) { + final _$string = string.reference; + return SomeTypes.fromReference(_new$(_class.reference.pointer, + _id_new$ as jni$_.JMethodIDPtr, _$string.pointer, j, d, z ? 1 : 0) + .reference); + } + + static final _id_getAString = _class.instanceMethodId( + r'getAString', + r'()Ljava/lang/String;', + ); + + static final _getAString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.String getAString()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString getAString() { + return _getAString(reference.pointer, _id_getAString as jni$_.JMethodIDPtr) + .object(const jni$_.JStringType()); + } + + static final _id_getAnInt = _class.instanceMethodId( + r'getAnInt', + r'()J', + ); + + static final _getAnInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallLongMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final long getAnInt()` + int getAnInt() { + return _getAnInt(reference.pointer, _id_getAnInt as jni$_.JMethodIDPtr) + .long; + } + + static final _id_getADouble = _class.instanceMethodId( + r'getADouble', + r'()D', + ); + + static final _getADouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallDoubleMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final double getADouble()` + double getADouble() { + return _getADouble(reference.pointer, _id_getADouble as jni$_.JMethodIDPtr) + .doubleFloat; + } + + static final _id_getABool = _class.instanceMethodId( + r'getABool', + r'()Z', + ); + + static final _getABool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final boolean getABool()` + bool getABool() { + return _getABool(reference.pointer, _id_getABool as jni$_.JMethodIDPtr) + .boolean; + } + + static final _id_toList = _class.instanceMethodId( + r'toList', + r'()Ljava/util/List;', + ); + + static final _toList = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.util.List toList()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JList toList() { + return _toList(reference.pointer, _id_toList as jni$_.JMethodIDPtr) + .object>( + const jni$_.JListType(jni$_.JObjectNullableType())); + } + + static final _id_equals = _class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean equals(java.lang.Object object)` + bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals as jni$_.JMethodIDPtr, + _$object.pointer) + .boolean; + } + + static final _id_hashCode$1 = _class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1 as jni$_.JMethodIDPtr) + .integer; + } + + static final _id_component1 = _class.instanceMethodId( + r'component1', + r'()Ljava/lang/String;', + ); + + static final _component1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.String component1()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString component1() { + return _component1(reference.pointer, _id_component1 as jni$_.JMethodIDPtr) + .object(const jni$_.JStringType()); + } + + static final _id_component2 = _class.instanceMethodId( + r'component2', + r'()J', + ); + + static final _component2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallLongMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final long component2()` + int component2() { + return _component2(reference.pointer, _id_component2 as jni$_.JMethodIDPtr) + .long; + } + + static final _id_component3 = _class.instanceMethodId( + r'component3', + r'()D', + ); + + static final _component3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallDoubleMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final double component3()` + double component3() { + return _component3(reference.pointer, _id_component3 as jni$_.JMethodIDPtr) + .doubleFloat; + } + + static final _id_component4 = _class.instanceMethodId( + r'component4', + r'()Z', + ); + + static final _component4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final boolean component4()` + bool component4() { + return _component4(reference.pointer, _id_component4 as jni$_.JMethodIDPtr) + .boolean; + } + + static final _id_copy = _class.instanceMethodId( + r'copy', + r'(Ljava/lang/String;JDZ)LSomeTypes;', + ); + + static final _copy = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int64, + jni$_.Double, + jni$_.Int32 + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + double, + int)>(); + + /// from: `public final SomeTypes copy(java.lang.String string, long j, double d, boolean z)` + /// The returned object must be released after use, by calling the [release] method. + SomeTypes copy( + jni$_.JString string, + int j, + double d, + bool z, + ) { + final _$string = string.reference; + return _copy(reference.pointer, _id_copy as jni$_.JMethodIDPtr, + _$string.pointer, j, d, z ? 1 : 0) + .object(const $SomeTypes$Type()); + } + + static final _id_toString$1 = _class.instanceMethodId( + r'toString', + r'()Ljava/lang/String;', + ); + + static final _toString$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.lang.String toString()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString toString$1() { + return _toString$1(reference.pointer, _id_toString$1 as jni$_.JMethodIDPtr) + .object(const jni$_.JStringType()); + } +} + +final class $SomeTypes$NullableType extends jni$_.JObjType { + @jni$_.internal + const $SomeTypes$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeTypes;'; + + @jni$_.internal + @core$_.override + SomeTypes? fromReference(jni$_.JReference reference) => reference.isNull + ? null + : SomeTypes.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeTypes$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeTypes$NullableType) && + other is $SomeTypes$NullableType; + } +} + +final class $SomeTypes$Type extends jni$_.JObjType { + @jni$_.internal + const $SomeTypes$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeTypes;'; + + @jni$_.internal + @core$_.override + SomeTypes fromReference(jni$_.JReference reference) => + SomeTypes.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $SomeTypes$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeTypes$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeTypes$Type) && other is $SomeTypes$Type; + } +} + +/// from: `SomeNullableTypes$Companion` +class SomeNullableTypes$Companion extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + SomeNullableTypes$Companion.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'SomeNullableTypes$Companion'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $SomeNullableTypes$Companion$NullableType(); + static const type = $SomeNullableTypes$Companion$Type(); + static final _id_fromList = _class.instanceMethodId( + r'fromList', + r'(Ljava/util/List;)LSomeNullableTypes;', + ); + + static final _fromList = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final SomeNullableTypes fromList(java.util.List list)` + /// The returned object must be released after use, by calling the [release] method. + SomeNullableTypes fromList( + jni$_.JList list, + ) { + final _$list = list.reference; + return _fromList(reference.pointer, _id_fromList as jni$_.JMethodIDPtr, + _$list.pointer) + .object(const $SomeNullableTypes$Type()); + } + + static final _id_new$ = _class.constructorId( + r'(Lkotlin/jvm/internal/DefaultConstructorMarker;)V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `synthetic public void (kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker)` + /// The returned object must be released after use, by calling the [release] method. + factory SomeNullableTypes$Companion( + jni$_.JObject? defaultConstructorMarker, + ) { + final _$defaultConstructorMarker = + defaultConstructorMarker?.reference ?? jni$_.jNullReference; + return SomeNullableTypes$Companion.fromReference(_new$( + _class.reference.pointer, + _id_new$ as jni$_.JMethodIDPtr, + _$defaultConstructorMarker.pointer) + .reference); + } +} + +final class $SomeNullableTypes$Companion$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $SomeNullableTypes$Companion$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeNullableTypes$Companion;'; + + @jni$_.internal + @core$_.override + SomeNullableTypes$Companion? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : SomeNullableTypes$Companion.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeNullableTypes$Companion$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeNullableTypes$Companion$NullableType) && + other is $SomeNullableTypes$Companion$NullableType; + } +} + +final class $SomeNullableTypes$Companion$Type + extends jni$_.JObjType { + @jni$_.internal + const $SomeNullableTypes$Companion$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeNullableTypes$Companion;'; + + @jni$_.internal + @core$_.override + SomeNullableTypes$Companion fromReference(jni$_.JReference reference) => + SomeNullableTypes$Companion.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $SomeNullableTypes$Companion$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeNullableTypes$Companion$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeNullableTypes$Companion$Type) && + other is $SomeNullableTypes$Companion$Type; + } +} + +/// from: `SomeNullableTypes` +class SomeNullableTypes extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + SomeNullableTypes.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'SomeNullableTypes'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $SomeNullableTypes$NullableType(); + static const type = $SomeNullableTypes$Type(); + static final _id_Companion = _class.staticFieldId( + r'Companion', + r'LSomeNullableTypes$Companion;', + ); + + /// from: `static public final SomeNullableTypes$Companion Companion` + /// The returned object must be released after use, by calling the [release] method. + static SomeNullableTypes$Companion get Companion => + _id_Companion.get(_class, const $SomeNullableTypes$Companion$Type()); + + static final _id_new$ = _class.constructorId( + r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;)V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public void (java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean)` + /// The returned object must be released after use, by calling the [release] method. + factory SomeNullableTypes( + jni$_.JString? string, + jni$_.JLong? long, + jni$_.JDouble? double, + jni$_.JBoolean? boolean, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + final _$long = long?.reference ?? jni$_.jNullReference; + final _$double = double?.reference ?? jni$_.jNullReference; + final _$boolean = boolean?.reference ?? jni$_.jNullReference; + return SomeNullableTypes.fromReference(_new$( + _class.reference.pointer, + _id_new$ as jni$_.JMethodIDPtr, + _$string.pointer, + _$long.pointer, + _$double.pointer, + _$boolean.pointer) + .reference); + } + + static final _id_new$1 = _class.constructorId( + r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V', + ); + + static final _new$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Int32, + jni$_.Pointer + )>)>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + int, + jni$_.Pointer)>(); + + /// from: `synthetic public void (java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean, int i, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker)` + /// The returned object must be released after use, by calling the [release] method. + factory SomeNullableTypes.new$1( + jni$_.JString? string, + jni$_.JLong? long, + jni$_.JDouble? double, + jni$_.JBoolean? boolean, + int i, + jni$_.JObject? defaultConstructorMarker, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + final _$long = long?.reference ?? jni$_.jNullReference; + final _$double = double?.reference ?? jni$_.jNullReference; + final _$boolean = boolean?.reference ?? jni$_.jNullReference; + final _$defaultConstructorMarker = + defaultConstructorMarker?.reference ?? jni$_.jNullReference; + return SomeNullableTypes.fromReference(_new$1( + _class.reference.pointer, + _id_new$1 as jni$_.JMethodIDPtr, + _$string.pointer, + _$long.pointer, + _$double.pointer, + _$boolean.pointer, + i, + _$defaultConstructorMarker.pointer) + .reference); + } + + static final _id_getAString = _class.instanceMethodId( + r'getAString', + r'()Ljava/lang/String;', + ); + + static final _getAString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.String getAString()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? getAString() { + return _getAString(reference.pointer, _id_getAString as jni$_.JMethodIDPtr) + .object(const jni$_.JStringNullableType()); + } + + static final _id_getAnInt = _class.instanceMethodId( + r'getAnInt', + r'()Ljava/lang/Long;', + ); + + static final _getAnInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Long getAnInt()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JLong? getAnInt() { + return _getAnInt(reference.pointer, _id_getAnInt as jni$_.JMethodIDPtr) + .object(const jni$_.JLongNullableType()); + } + + static final _id_getADouble = _class.instanceMethodId( + r'getADouble', + r'()Ljava/lang/Double;', + ); + + static final _getADouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Double getADouble()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JDouble? getADouble() { + return _getADouble(reference.pointer, _id_getADouble as jni$_.JMethodIDPtr) + .object(const jni$_.JDoubleNullableType()); + } + + static final _id_getABool = _class.instanceMethodId( + r'getABool', + r'()Ljava/lang/Boolean;', + ); + + static final _getABool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Boolean getABool()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JBoolean? getABool() { + return _getABool(reference.pointer, _id_getABool as jni$_.JMethodIDPtr) + .object(const jni$_.JBooleanNullableType()); + } + + static final _id_toList = _class.instanceMethodId( + r'toList', + r'()Ljava/util/List;', + ); + + static final _toList = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.util.List toList()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JList toList() { + return _toList(reference.pointer, _id_toList as jni$_.JMethodIDPtr) + .object>( + const jni$_.JListType(jni$_.JObjectNullableType())); + } + + static final _id_equals = _class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean equals(java.lang.Object object)` + bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals as jni$_.JMethodIDPtr, + _$object.pointer) + .boolean; + } + + static final _id_hashCode$1 = _class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1 as jni$_.JMethodIDPtr) + .integer; + } + + static final _id_component1 = _class.instanceMethodId( + r'component1', + r'()Ljava/lang/String;', + ); + + static final _component1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.String component1()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? component1() { + return _component1(reference.pointer, _id_component1 as jni$_.JMethodIDPtr) + .object(const jni$_.JStringNullableType()); + } + + static final _id_component2 = _class.instanceMethodId( + r'component2', + r'()Ljava/lang/Long;', + ); + + static final _component2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Long component2()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JLong? component2() { + return _component2(reference.pointer, _id_component2 as jni$_.JMethodIDPtr) + .object(const jni$_.JLongNullableType()); + } + + static final _id_component3 = _class.instanceMethodId( + r'component3', + r'()Ljava/lang/Double;', + ); + + static final _component3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Double component3()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JDouble? component3() { + return _component3(reference.pointer, _id_component3 as jni$_.JMethodIDPtr) + .object(const jni$_.JDoubleNullableType()); + } + + static final _id_component4 = _class.instanceMethodId( + r'component4', + r'()Ljava/lang/Boolean;', + ); + + static final _component4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Boolean component4()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JBoolean? component4() { + return _component4(reference.pointer, _id_component4 as jni$_.JMethodIDPtr) + .object(const jni$_.JBooleanNullableType()); + } + + static final _id_copy = _class.instanceMethodId( + r'copy', + r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;)LSomeNullableTypes;', + ); + + static final _copy = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public final SomeNullableTypes copy(java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean)` + /// The returned object must be released after use, by calling the [release] method. + SomeNullableTypes copy( + jni$_.JString? string, + jni$_.JLong? long, + jni$_.JDouble? double, + jni$_.JBoolean? boolean, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + final _$long = long?.reference ?? jni$_.jNullReference; + final _$double = double?.reference ?? jni$_.jNullReference; + final _$boolean = boolean?.reference ?? jni$_.jNullReference; + return _copy( + reference.pointer, + _id_copy as jni$_.JMethodIDPtr, + _$string.pointer, + _$long.pointer, + _$double.pointer, + _$boolean.pointer) + .object(const $SomeNullableTypes$Type()); + } + + static final _id_toString$1 = _class.instanceMethodId( + r'toString', + r'()Ljava/lang/String;', + ); + + static final _toString$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.lang.String toString()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString toString$1() { + return _toString$1(reference.pointer, _id_toString$1 as jni$_.JMethodIDPtr) + .object(const jni$_.JStringType()); + } + + static final _id_new$2 = _class.constructorId( + r'()V', + ); + + static final _new$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory SomeNullableTypes.new$2() { + return SomeNullableTypes.fromReference( + _new$2(_class.reference.pointer, _id_new$2 as jni$_.JMethodIDPtr) + .reference); + } +} + +final class $SomeNullableTypes$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $SomeNullableTypes$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeNullableTypes;'; + + @jni$_.internal + @core$_.override + SomeNullableTypes? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : SomeNullableTypes.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeNullableTypes$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeNullableTypes$NullableType) && + other is $SomeNullableTypes$NullableType; + } +} + +final class $SomeNullableTypes$Type extends jni$_.JObjType { + @jni$_.internal + const $SomeNullableTypes$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeNullableTypes;'; + + @jni$_.internal + @core$_.override + SomeNullableTypes fromReference(jni$_.JReference reference) => + SomeNullableTypes.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $SomeNullableTypes$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeNullableTypes$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeNullableTypes$Type) && + other is $SomeNullableTypes$Type; + } +} diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/pubspec.yaml b/packages/pigeon/platform_tests/shared_test_plugin_code/pubspec.yaml index a345c4c7d304..674eb6d4106d 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/pubspec.yaml +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/pubspec.yaml @@ -18,4 +18,5 @@ dependencies: sdk: flutter integration_test: sdk: flutter + jni: ^0.14.0 mockito: ^5.4.4 diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/.gitignore b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/.gitignore index bbe6aef544f5..debb3751da53 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/.gitignore +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/.gitignore @@ -5,9 +5,10 @@ !TestPlugin.kt !CoreTests.gen.kt # This contains the declaration of the test classes wrapped by the ProxyApi tests and the -# implemetations of their APIs. +# implementations of their APIs. !ProxyApiTestApiImpls.kt # Including these makes it easier to review code generation changes. !ProxyApiTests.gen.kt !EventChannelTests.gen.kt +!jniTests.gen.kt \ No newline at end of file diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt new file mode 100644 index 000000000000..ac03395b6ceb --- /dev/null +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt @@ -0,0 +1,400 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Autogenerated from Pigeon, do not edit directly. +// See also: https://pub.dev/packages/pigeon +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") + +import androidx.annotation.Keep + +/** + * Error class for passing custom error details to Flutter via a thrown PlatformException. + * + * @property code The error code. + * @property message The error message. + * @property details The error details. Must be a datatype supported by the api codec. + */ +class JniTestsError( + val code: String, + override val message: String? = null, + val details: Any? = null +) : Throwable() + +/** Generated class from Pigeon that represents data sent in messages. */ +data class SomeTypes( + val aString: String, + val anInt: Long, + val aDouble: Double, + val aBool: Boolean +) { + companion object { + fun fromList(pigeonVar_list: List): SomeTypes { + val aString = pigeonVar_list[0] as String + val anInt = pigeonVar_list[1] as Long + val aDouble = pigeonVar_list[2] as Double + val aBool = pigeonVar_list[3] as Boolean + return SomeTypes(aString, anInt, aDouble, aBool) + } + } + + fun toList(): List { + return listOf( + aString, + anInt, + aDouble, + aBool, + ) + } + + override fun equals(other: Any?): Boolean { + if (other !is SomeTypes) { + return false + } + if (this === other) { + return true + } + return aString == other.aString && + anInt == other.anInt && + aDouble == other.aDouble && + aBool == other.aBool + } + + override fun hashCode(): Int = toList().hashCode() +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class SomeNullableTypes( + val aString: String? = null, + val anInt: Long? = null, + val aDouble: Double? = null, + val aBool: Boolean? = null +) { + companion object { + fun fromList(pigeonVar_list: List): SomeNullableTypes { + val aString = pigeonVar_list[0] as String? + val anInt = pigeonVar_list[1] as Long? + val aDouble = pigeonVar_list[2] as Double? + val aBool = pigeonVar_list[3] as Boolean? + return SomeNullableTypes(aString, anInt, aDouble, aBool) + } + } + + fun toList(): List { + return listOf( + aString, + anInt, + aDouble, + aBool, + ) + } + + override fun equals(other: Any?): Boolean { + if (other !is SomeNullableTypes) { + return false + } + if (this === other) { + return true + } + return aString == other.aString && + anInt == other.anInt && + aDouble == other.aDouble && + aBool == other.aBool + } + + override fun hashCode(): Int = toList().hashCode() +} + +val JniMessageApiInstances: MutableMap = mutableMapOf() + +@Keep +abstract class JniMessageApi { + abstract fun doNothing() + + abstract fun echoString(request: String): String + + abstract fun echoInt(request: Long): Long + + abstract fun echoDouble(request: Double): Double + + abstract fun echoBool(request: Boolean): Boolean + + abstract fun sendSomeTypes(someTypes: SomeTypes): SomeTypes +} + +@Keep +class JniMessageApiRegistrar : JniMessageApi() { + var api: JniMessageApi? = null + + fun register( + api: JniMessageApi, + name: String = "PigeonDefaultClassName32uh4ui3lh445uh4h3l2l455g4y34u" + ): JniMessageApiRegistrar { + this.api = api + JniMessageApiInstances[name] = this + return this + } + + @Keep + fun getInstance(name: String): JniMessageApiRegistrar? { + return JniMessageApiInstances[name] + } + + override fun doNothing() { + api?.let { + try { + return api!!.doNothing() + } catch (e: Exception) { + throw e + } + } + error("JniMessageApi has not been set") + } + + override fun echoString(request: String): String { + api?.let { + try { + return api!!.echoString(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApi has not been set") + } + + override fun echoInt(request: Long): Long { + api?.let { + try { + return api!!.echoInt(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApi has not been set") + } + + override fun echoDouble(request: Double): Double { + api?.let { + try { + return api!!.echoDouble(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApi has not been set") + } + + override fun echoBool(request: Boolean): Boolean { + api?.let { + try { + return api!!.echoBool(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApi has not been set") + } + + override fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { + api?.let { + try { + return api!!.sendSomeTypes(someTypes) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApi has not been set") + } +} + +val JniMessageApiNullableInstances: MutableMap = + mutableMapOf() + +@Keep +abstract class JniMessageApiNullable { + abstract fun echoString(request: String?): String? + + abstract fun echoInt(request: Long?): Long? + + abstract fun echoDouble(request: Double?): Double? + + abstract fun echoBool(request: Boolean?): Boolean? + + abstract fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? +} + +@Keep +class JniMessageApiNullableRegistrar : JniMessageApiNullable() { + var api: JniMessageApiNullable? = null + + fun register( + api: JniMessageApiNullable, + name: String = "PigeonDefaultClassName32uh4ui3lh445uh4h3l2l455g4y34u" + ): JniMessageApiNullableRegistrar { + this.api = api + JniMessageApiNullableInstances[name] = this + return this + } + + @Keep + fun getInstance(name: String): JniMessageApiNullableRegistrar? { + return JniMessageApiNullableInstances[name] + } + + override fun echoString(request: String?): String? { + api?.let { + try { + return api!!.echoString(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullable has not been set") + } + + override fun echoInt(request: Long?): Long? { + api?.let { + try { + return api!!.echoInt(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullable has not been set") + } + + override fun echoDouble(request: Double?): Double? { + api?.let { + try { + return api!!.echoDouble(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullable has not been set") + } + + override fun echoBool(request: Boolean?): Boolean? { + api?.let { + try { + return api!!.echoBool(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullable has not been set") + } + + override fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? { + api?.let { + try { + return api!!.sendSomeNullableTypes(someTypes) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullable has not been set") + } +} + +val JniMessageApiAsyncInstances: MutableMap = mutableMapOf() + +@Keep +abstract class JniMessageApiAsync { + abstract suspend fun doNothing() + + abstract suspend fun echoString(request: String): String + + abstract suspend fun echoInt(request: Long): Long + + abstract suspend fun echoDouble(request: Double): Double + + abstract suspend fun echoBool(request: Boolean): Boolean + + abstract suspend fun sendSomeTypes(someTypes: SomeTypes): SomeTypes +} + +@Keep +class JniMessageApiAsyncRegistrar : JniMessageApiAsync() { + var api: JniMessageApiAsync? = null + + fun register( + api: JniMessageApiAsync, + name: String = "PigeonDefaultClassName32uh4ui3lh445uh4h3l2l455g4y34u" + ): JniMessageApiAsyncRegistrar { + this.api = api + JniMessageApiAsyncInstances[name] = this + return this + } + + @Keep + fun getInstance(name: String): JniMessageApiAsyncRegistrar? { + return JniMessageApiAsyncInstances[name] + } + + override suspend fun doNothing() { + api?.let { + try { + return api!!.doNothing() + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiAsync has not been set") + } + + override suspend fun echoString(request: String): String { + api?.let { + try { + return api!!.echoString(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiAsync has not been set") + } + + override suspend fun echoInt(request: Long): Long { + api?.let { + try { + return api!!.echoInt(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiAsync has not been set") + } + + override suspend fun echoDouble(request: Double): Double { + api?.let { + try { + return api!!.echoDouble(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiAsync has not been set") + } + + override suspend fun echoBool(request: Boolean): Boolean { + api?.let { + try { + return api!!.echoBool(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiAsync has not been set") + } + + override suspend fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { + api?.let { + try { + return api!!.sendSomeTypes(someTypes) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiAsync has not been set") + } +} 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 7c6707c25a41..2627b7622169 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 @@ -4,6 +4,11 @@ package com.example.test_plugin +import JniMessageApi +import JniMessageApiAsync +import JniMessageApiAsyncRegistrar +import JniMessageApiRegistrar +import SomeTypes import android.os.Handler import android.os.Looper import io.flutter.embedding.engine.plugins.FlutterPlugin @@ -15,6 +20,10 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { private var flutterSmallApiOne: FlutterSmallApi? = null private var flutterSmallApiTwo: FlutterSmallApi? = null private var proxyApiRegistrar: ProxyApiRegistrar? = null + private var jniMessageApi: JniMessageApiRegistrar? = null + private var jniMessageApiNamed: JniMessageApiRegistrar? = null + private var jniMessageApiAsync: JniMessageApiAsyncRegistrar? = null + private var jniMessageApiAsyncNamed: JniMessageApiAsyncRegistrar? = null override fun onAttachedToEngine(binding: FlutterPluginBinding) { HostIntegrationCoreApi.setUp(binding.binaryMessenger, this) @@ -22,6 +31,13 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { testSuffixApiOne.setUp(binding, "suffixOne") val testSuffixApiTwo = TestPluginWithSuffix() testSuffixApiTwo.setUp(binding, "suffixTwo") + + jniMessageApi = JniMessageApiRegistrar().register(JniMessageApiImpl()) + jniMessageApiNamed = JniMessageApiRegistrar().register(JniMessageApiImpl2(), "name") + jniMessageApiAsync = JniMessageApiAsyncRegistrar().register(JniMessageApiAsyncImpl()) + jniMessageApiAsyncNamed = + JniMessageApiAsyncRegistrar().register(JniMessageApiAsyncImpl2(), "name") + flutterApi = FlutterIntegrationCoreApi(binding.binaryMessenger) flutterSmallApiOne = FlutterSmallApi(binding.binaryMessenger, "suffixOne") flutterSmallApiTwo = FlutterSmallApi(binding.binaryMessenger, "suffixTwo") @@ -870,6 +886,133 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { } } +class JniMessageApiImpl : JniMessageApi() { + override fun doNothing() { + return + } + + override fun echoString(request: String): String { + return request + } + + override fun echoInt(request: Long): Long { + return request + } + + override fun echoDouble(request: Double): Double { + return request + } + + override fun echoBool(request: Boolean): Boolean { + return request + } + + // override fun echoObj(request: Any): Any { + // return request + // } + + override fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { + return someTypes + } +} + +class JniMessageApiImpl2 : JniMessageApi() { + override fun doNothing() { + return + } + + override fun echoString(request: String): String { + return request + "1" + } + + override fun echoInt(request: Long): Long { + return request + 1 + } + + override fun echoDouble(request: Double): Double { + return request + 1 + } + + override fun echoBool(request: Boolean): Boolean { + return !request + } + + // override fun echoObj(request: Any): Any { + // return request + // } + + override fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { + val newSomeTypes = someTypes.copy(anInt = someTypes.anInt + 1) + return newSomeTypes + } +} + +class JniMessageApiAsyncImpl : JniMessageApiAsync() { + override suspend fun doNothing() { + return + } + + override suspend fun echoString(request: String): String { + return request + } + + override suspend fun echoInt(request: Long): Long { + return request + } + + override suspend fun echoDouble(request: Double): Double { + return request + } + + override suspend fun echoBool(request: Boolean): Boolean { + return request + } + + // override fun echoObj(request: Any): Any { + // return request + // } + + override suspend fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { + return someTypes + } +} + +class JniMessageApiAsyncImpl2 : JniMessageApiAsync() { + override suspend fun doNothing() { + return + } + + override suspend fun echoString(request: String): String { + return request + "1" + } + + override suspend fun echoInt(request: Long): Long { + return request + 1 + } + + override suspend fun echoDouble(request: Double): Double { + return request + 1 + } + + override suspend fun echoBool(request: Boolean): Boolean { + return !request + } + + // override fun echoObj(request: Any): Any { + // return request + // } + + override suspend fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { + val newSomeTypes = someTypes.copy(anInt = someTypes.anInt + 1) + return newSomeTypes + } +} + +// override suspend fun thinkBeforeAnswering(): String { +// delay(10L) +// return "42" +// } + class TestPluginWithSuffix : HostSmallApi { fun setUp(binding: FlutterPluginBinding, suffix: String) { diff --git a/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml b/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml new file mode 100644 index 000000000000..b329cfcefbe6 --- /dev/null +++ b/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml @@ -0,0 +1,26 @@ +android_sdk_config: + add_gradle_deps: true + android_example: '/Users/tarrinneal/work/packages/packages/pigeon/platform_tests/test_plugin/example' + +# source_path: +# - 'android/src/main/java' + +summarizer: + backend: asm + +output: + dart: + path: /Users/tarrinneal/work/packages/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart + structure: single_file + +log_level: all + +classes: + - 'JniMessageApi' + - 'JniMessageApiRegistrar' + - 'JniMessageApiNullable' + - 'JniMessageApiNullableRegistrar' + - 'JniMessageApiAsync' + - 'JniMessageApiAsyncRegistrar' + - 'SomeTypes' + - 'SomeNullableTypes' diff --git a/packages/pigeon/platform_tests/test_plugin/example/pubspec.yaml b/packages/pigeon/platform_tests/test_plugin/example/pubspec.yaml index 9b5f46bcb780..cb263b0e9457 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/pubspec.yaml +++ b/packages/pigeon/platform_tests/test_plugin/example/pubspec.yaml @@ -8,6 +8,7 @@ environment: dependencies: flutter: sdk: flutter + jnigen: ^0.14.0 shared_test_plugin_code: path: ../../shared_test_plugin_code test_plugin: diff --git a/packages/pigeon/platform_tests/test_plugin/pubspec.yaml b/packages/pigeon/platform_tests/test_plugin/pubspec.yaml index 0547092ec50f..c9afc10baffa 100644 --- a/packages/pigeon/platform_tests/test_plugin/pubspec.yaml +++ b/packages/pigeon/platform_tests/test_plugin/pubspec.yaml @@ -25,6 +25,7 @@ flutter: dependencies: flutter: sdk: flutter + jni: ^0.14.0 dev_dependencies: flutter_test: diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index 3459232c9843..28a9f4d92c79 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: collection: ^1.15.0 dart_style: ^3.0.0 graphs: ^2.3.1 + jni: ^0.14.0 meta: ^1.9.0 path: ^1.8.0 pub_semver: ^2.1.4 @@ -21,6 +22,7 @@ dependencies: dev_dependencies: test: ^1.11.1 + jnigen: ^0.14.0 topics: - codegen diff --git a/packages/pigeon/tool/shared/generation.dart b/packages/pigeon/tool/shared/generation.dart index ec52d0b25c93..b2b9726b5ebd 100644 --- a/packages/pigeon/tool/shared/generation.dart +++ b/packages/pigeon/tool/shared/generation.dart @@ -43,6 +43,13 @@ const Map> _unsupportedFiles = GeneratorLanguage.java, GeneratorLanguage.objc, }, + 'jni_tests': { + GeneratorLanguage.cpp, + GeneratorLanguage.gobject, + GeneratorLanguage.java, + GeneratorLanguage.objc, + GeneratorLanguage.swift, + }, }; String _snakeToPascalCase(String snake) { @@ -99,6 +106,7 @@ Future generateTestPigeons( 'nullable_returns', 'primitive', 'proxy_api_tests', + 'jni_tests' }; final String outputBase = p.join(baseDir, 'platform_tests', 'test_plugin'); @@ -140,6 +148,8 @@ Future generateTestPigeons( : '$outputBase/android/src/main/kotlin/com/example/test_plugin/$pascalCaseName.gen.kt', kotlinPackage: 'com.example.test_plugin', kotlinErrorClassName: kotlinErrorName, + kotlinUseJni: input == 'jni_tests', + kotlinExampleAppDirectory: '$outputBase/example', kotlinIncludeErrorClass: input != 'primitive', // iOS swiftOut: skipLanguages.contains(GeneratorLanguage.swift) @@ -252,7 +262,9 @@ Future runPigeon({ String? kotlinOut, String? kotlinPackage, String? kotlinErrorClassName, + bool kotlinUseJni = false, bool kotlinIncludeErrorClass = true, + String kotlinExampleAppDirectory = '', bool swiftIncludeErrorClass = true, String? swiftOut, String? swiftErrorClassName, @@ -310,7 +322,7 @@ Future runPigeon({ copyrightHeader: copyrightHeader, dartOut: dartOut, dartTestOut: dartTestOut, - dartOptions: const DartOptions(), + dartOptions: DartOptions(useJni: kotlinUseJni), cppHeaderOut: cppHeaderOut, cppSourceOut: cppSourceOut, cppOptions: CppOptions(namespace: cppNamespace), @@ -325,6 +337,8 @@ Future runPigeon({ package: kotlinPackage, errorClassName: kotlinErrorClassName, includeErrorClass: kotlinIncludeErrorClass, + useJni: kotlinUseJni, + exampleAppDirectory: kotlinExampleAppDirectory, ), objcHeaderOut: objcHeaderOut, objcSourceOut: objcSourceOut, From 9fa695dd821903db460e25184a08f64857046453 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 14 Apr 2025 17:05:08 -0700 Subject: [PATCH 2/4] broken nullable async methods --- packages/pigeon/pigeons/jni_tests.dart | 26 +- .../lib/src/generated/jni_tests.gen.dart | 63 ++ .../lib/src/generated/jni_tests.gen.jni.dart | 868 ++++++++++++++++++ .../com/example/test_plugin/JniTests.gen.kt | 90 ++ .../test_plugin/example/jnigen.yaml | 2 + 5 files changed, 1036 insertions(+), 13 deletions(-) diff --git a/packages/pigeon/pigeons/jni_tests.dart b/packages/pigeon/pigeons/jni_tests.dart index 34ad4455213e..e6452f0a6b8d 100644 --- a/packages/pigeon/pigeons/jni_tests.dart +++ b/packages/pigeon/pigeons/jni_tests.dart @@ -60,16 +60,16 @@ abstract class JniMessageApiAsync { SomeTypes sendSomeTypes(SomeTypes someTypes); } -// @HostApi() -// abstract class JniMessageApiNullableAsync { -// @async -// String? echoString(String? request); -// @async -// int? echoInt(int? request); -// @async -// double? echoDouble(double? request); -// @async -// bool? echoBool(bool? request); -// @async -// SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes); -// } +@HostApi() +abstract class JniMessageApiNullableAsync { + @async + String? echoString(String? request); + @async + int? echoInt(int? request); + @async + double? echoDouble(double? request); + @async + bool? echoBool(bool? request); + @async + SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes); +} diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart index 9a51e2c02fbf..64aa5ab47c77 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart @@ -382,3 +382,66 @@ class JniMessageApiAsync { return dartTypeRes; } } + +class JniMessageApiNullableAsync { + JniMessageApiNullableAsync._withRegistrar( + bridge.JniMessageApiNullableAsyncRegistrar api) + : _api = api; + + /// Returns instance of JniMessageApiNullableAsync with specified [channelName] if one has been registered. + static JniMessageApiNullableAsync? getInstance( + {String channelName = defaultInstanceName}) { + final bridge.JniMessageApiNullableAsyncRegistrar? link = + bridge.JniMessageApiNullableAsyncRegistrar() + .getInstance(JString.fromString(channelName)); + if (link == null) { + String nameString = 'named $channelName'; + if (channelName == defaultInstanceName) { + nameString = 'with no name'; + } + final String error = 'No instance $nameString has been registered.'; + throw ArgumentError(error); + } + final JniMessageApiNullableAsync res = + JniMessageApiNullableAsync._withRegistrar(link); + return res; + } + + late final bridge.JniMessageApiNullableAsyncRegistrar _api; + + Future echoString(String? request) async { + final JString? res = await _api + .echoString(request != null ? JString.fromString(request) : null); + final String? dartTypeRes = res?.toDartString(releaseOriginal: true); + return dartTypeRes; + } + + Future echoInt(int? request) async { + final JLong? res = + await _api.echoInt(request != null ? JLong(request) : null); + final int? dartTypeRes = res?.intValue(releaseOriginal: true); + return dartTypeRes; + } + + Future echoDouble(double? request) async { + final JDouble? res = + await _api.echoDouble(request != null ? JDouble(request) : null); + final double? dartTypeRes = res?.doubleValue(releaseOriginal: true); + return dartTypeRes; + } + + Future echoBool(bool? request) async { + final JBoolean? res = + await _api.echoBool(request != null ? JBoolean(request) : null); + final bool? dartTypeRes = res?.booleanValue(releaseOriginal: true); + return dartTypeRes; + } + + Future sendSomeNullableTypes( + SomeNullableTypes? someTypes) async { + final bridge.SomeNullableTypes? res = + await _api.sendSomeNullableTypes(someTypes?.toJni()); + final SomeNullableTypes? dartTypeRes = SomeNullableTypes.fromJni(res); + return dartTypeRes; + } +} diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart index a7b1a8ceac63..76a24571145f 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart @@ -2175,6 +2175,874 @@ final class $JniMessageApiAsyncRegistrar$Type } } +/// from: `JniMessageApiNullableAsync` +class JniMessageApiNullableAsync extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + JniMessageApiNullableAsync.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'JniMessageApiNullableAsync'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $JniMessageApiNullableAsync$NullableType(); + static const type = $JniMessageApiNullableAsync$Type(); + static final _id_echoString = _class.instanceMethodId( + r'echoString', + r'(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoString( + jni$_.JString? string, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$string = string?.reference ?? jni$_.jNullReference; + final $r = _echoString( + reference.pointer, + _id_echoString as jni$_.JMethodIDPtr, + _$string.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JStringNullableType(), releaseOriginal: true); + } + + static final _id_echoInt = _class.instanceMethodId( + r'echoInt', + r'(Ljava/lang/Long;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoInt(java.lang.Long long, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoInt( + jni$_.JLong? long, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$long = long?.reference ?? jni$_.jNullReference; + final $r = _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, + _$long.pointer, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JLongNullableType(), releaseOriginal: true); + } + + static final _id_echoDouble = _class.instanceMethodId( + r'echoDouble', + r'(Ljava/lang/Double;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoDouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoDouble(java.lang.Double double, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoDouble( + jni$_.JDouble? double, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$double = double?.reference ?? jni$_.jNullReference; + final $r = _echoDouble( + reference.pointer, + _id_echoDouble as jni$_.JMethodIDPtr, + _$double.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JDoubleNullableType(), releaseOriginal: true); + } + + static final _id_echoBool = _class.instanceMethodId( + r'echoBool', + r'(Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoBool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoBool(java.lang.Boolean boolean, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoBool( + jni$_.JBoolean? boolean, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$boolean = boolean?.reference ?? jni$_.jNullReference; + final $r = _echoBool(reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, + _$boolean.pointer, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JBooleanNullableType(), releaseOriginal: true); + } + + static final _id_sendSomeNullableTypes = _class.instanceMethodId( + r'sendSomeNullableTypes', + r'(LSomeNullableTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _sendSomeNullableTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object sendSomeNullableTypes(SomeNullableTypes someNullableTypes, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeNullableTypes( + SomeNullableTypes? someNullableTypes, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someNullableTypes = + someNullableTypes?.reference ?? jni$_.jNullReference; + final $r = _sendSomeNullableTypes( + reference.pointer, + _id_sendSomeNullableTypes as jni$_.JMethodIDPtr, + _$someNullableTypes.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const $SomeNullableTypes$NullableType(), + releaseOriginal: true); + } +} + +final class $JniMessageApiNullableAsync$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullableAsync$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullableAsync;'; + + @jni$_.internal + @core$_.override + JniMessageApiNullableAsync? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : JniMessageApiNullableAsync.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($JniMessageApiNullableAsync$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiNullableAsync$NullableType) && + other is $JniMessageApiNullableAsync$NullableType; + } +} + +final class $JniMessageApiNullableAsync$Type + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullableAsync$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullableAsync;'; + + @jni$_.internal + @core$_.override + JniMessageApiNullableAsync fromReference(jni$_.JReference reference) => + JniMessageApiNullableAsync.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $JniMessageApiNullableAsync$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($JniMessageApiNullableAsync$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiNullableAsync$Type) && + other is $JniMessageApiNullableAsync$Type; + } +} + +/// from: `JniMessageApiNullableAsyncRegistrar` +class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + JniMessageApiNullableAsyncRegistrar.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = + jni$_.JClass.forName(r'JniMessageApiNullableAsyncRegistrar'); + + /// The type which includes information such as the signature of this class. + static const nullableType = + $JniMessageApiNullableAsyncRegistrar$NullableType(); + static const type = $JniMessageApiNullableAsyncRegistrar$Type(); + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory JniMessageApiNullableAsyncRegistrar() { + return JniMessageApiNullableAsyncRegistrar.fromReference( + _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) + .reference); + } + + static final _id_getApi = _class.instanceMethodId( + r'getApi', + r'()LJniMessageApiNullableAsync;', + ); + + static final _getApi = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final JniMessageApiNullableAsync getApi()` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiNullableAsync? getApi() { + return _getApi(reference.pointer, _id_getApi as jni$_.JMethodIDPtr) + .object( + const $JniMessageApiNullableAsync$NullableType()); + } + + static final _id_setApi = _class.instanceMethodId( + r'setApi', + r'(LJniMessageApiNullableAsync;)V', + ); + + static final _setApi = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final void setApi(JniMessageApiNullableAsync jniMessageApiNullableAsync)` + void setApi( + JniMessageApiNullableAsync? jniMessageApiNullableAsync, + ) { + final _$jniMessageApiNullableAsync = + jniMessageApiNullableAsync?.reference ?? jni$_.jNullReference; + _setApi(reference.pointer, _id_setApi as jni$_.JMethodIDPtr, + _$jniMessageApiNullableAsync.pointer) + .check(); + } + + static final _id_register = _class.instanceMethodId( + r'register', + r'(LJniMessageApiNullableAsync;Ljava/lang/String;)LJniMessageApiNullableAsyncRegistrar;', + ); + + static final _register = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public final JniMessageApiNullableAsyncRegistrar register(JniMessageApiNullableAsync jniMessageApiNullableAsync, java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiNullableAsyncRegistrar register( + JniMessageApiNullableAsync jniMessageApiNullableAsync, + jni$_.JString string, + ) { + final _$jniMessageApiNullableAsync = jniMessageApiNullableAsync.reference; + final _$string = string.reference; + return _register(reference.pointer, _id_register as jni$_.JMethodIDPtr, + _$jniMessageApiNullableAsync.pointer, _$string.pointer) + .object( + const $JniMessageApiNullableAsyncRegistrar$Type()); + } + + static final _id_getInstance = _class.instanceMethodId( + r'getInstance', + r'(Ljava/lang/String;)LJniMessageApiNullableAsyncRegistrar;', + ); + + static final _getInstance = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public final JniMessageApiNullableAsyncRegistrar getInstance(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + JniMessageApiNullableAsyncRegistrar? getInstance( + jni$_.JString string, + ) { + final _$string = string.reference; + return _getInstance(reference.pointer, + _id_getInstance as jni$_.JMethodIDPtr, _$string.pointer) + .object( + const $JniMessageApiNullableAsyncRegistrar$NullableType()); + } + + static final _id_echoString = _class.instanceMethodId( + r'echoString', + r'(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoString = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoString( + jni$_.JString? string, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$string = string?.reference ?? jni$_.jNullReference; + final $r = _echoString( + reference.pointer, + _id_echoString as jni$_.JMethodIDPtr, + _$string.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JStringNullableType(), releaseOriginal: true); + } + + static final _id_echoInt = _class.instanceMethodId( + r'echoInt', + r'(Ljava/lang/Long;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoInt(java.lang.Long long, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoInt( + jni$_.JLong? long, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$long = long?.reference ?? jni$_.jNullReference; + final $r = _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, + _$long.pointer, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JLongNullableType(), releaseOriginal: true); + } + + static final _id_echoDouble = _class.instanceMethodId( + r'echoDouble', + r'(Ljava/lang/Double;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoDouble = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoDouble(java.lang.Double double, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoDouble( + jni$_.JDouble? double, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$double = double?.reference ?? jni$_.jNullReference; + final $r = _echoDouble( + reference.pointer, + _id_echoDouble as jni$_.JMethodIDPtr, + _$double.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JDoubleNullableType(), releaseOriginal: true); + } + + static final _id_echoBool = _class.instanceMethodId( + r'echoBool', + r'(Ljava/lang/Boolean;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoBool = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoBool(java.lang.Boolean boolean, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoBool( + jni$_.JBoolean? boolean, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$boolean = boolean?.reference ?? jni$_.jNullReference; + final $r = _echoBool(reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, + _$boolean.pointer, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const jni$_.JBooleanNullableType(), releaseOriginal: true); + } + + static final _id_sendSomeNullableTypes = _class.instanceMethodId( + r'sendSomeNullableTypes', + r'(LSomeNullableTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _sendSomeNullableTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object sendSomeNullableTypes(SomeNullableTypes someNullableTypes, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeNullableTypes( + SomeNullableTypes? someNullableTypes, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someNullableTypes = + someNullableTypes?.reference ?? jni$_.jNullReference; + final $r = _sendSomeNullableTypes( + reference.pointer, + _id_sendSomeNullableTypes as jni$_.JMethodIDPtr, + _$someNullableTypes.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as(const $SomeNullableTypes$NullableType(), + releaseOriginal: true); + } +} + +final class $JniMessageApiNullableAsyncRegistrar$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullableAsyncRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullableAsyncRegistrar;'; + + @jni$_.internal + @core$_.override + JniMessageApiNullableAsyncRegistrar? fromReference( + jni$_.JReference reference) => + reference.isNull + ? null + : JniMessageApiNullableAsyncRegistrar.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const $JniMessageApiNullableAsync$Type(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 2; + + @core$_.override + int get hashCode => + ($JniMessageApiNullableAsyncRegistrar$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == + ($JniMessageApiNullableAsyncRegistrar$NullableType) && + other is $JniMessageApiNullableAsyncRegistrar$NullableType; + } +} + +final class $JniMessageApiNullableAsyncRegistrar$Type + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullableAsyncRegistrar$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullableAsyncRegistrar;'; + + @jni$_.internal + @core$_.override + JniMessageApiNullableAsyncRegistrar fromReference( + jni$_.JReference reference) => + JniMessageApiNullableAsyncRegistrar.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const $JniMessageApiNullableAsync$Type(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $JniMessageApiNullableAsyncRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 2; + + @core$_.override + int get hashCode => ($JniMessageApiNullableAsyncRegistrar$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($JniMessageApiNullableAsyncRegistrar$Type) && + other is $JniMessageApiNullableAsyncRegistrar$Type; + } +} + /// from: `SomeTypes$Companion` class SomeTypes$Companion extends jni$_.JObject { @jni$_.internal diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt index ac03395b6ceb..7a2c9b844d4f 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt @@ -398,3 +398,93 @@ class JniMessageApiAsyncRegistrar : JniMessageApiAsync() { error("JniMessageApiAsync has not been set") } } + +val JniMessageApiNullableAsyncInstances: MutableMap = + mutableMapOf() + +@Keep +abstract class JniMessageApiNullableAsync { + abstract suspend fun echoString(request: String?): String? + + abstract suspend fun echoInt(request: Long?): Long? + + abstract suspend fun echoDouble(request: Double?): Double? + + abstract suspend fun echoBool(request: Boolean?): Boolean? + + abstract suspend fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? +} + +@Keep +class JniMessageApiNullableAsyncRegistrar : JniMessageApiNullableAsync() { + var api: JniMessageApiNullableAsync? = null + + fun register( + api: JniMessageApiNullableAsync, + name: String = "PigeonDefaultClassName32uh4ui3lh445uh4h3l2l455g4y34u" + ): JniMessageApiNullableAsyncRegistrar { + this.api = api + JniMessageApiNullableAsyncInstances[name] = this + return this + } + + @Keep + fun getInstance(name: String): JniMessageApiNullableAsyncRegistrar? { + return JniMessageApiNullableAsyncInstances[name] + } + + override suspend fun echoString(request: String?): String? { + api?.let { + try { + return api!!.echoString(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullableAsync has not been set") + } + + override suspend fun echoInt(request: Long?): Long? { + api?.let { + try { + return api!!.echoInt(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullableAsync has not been set") + } + + override suspend fun echoDouble(request: Double?): Double? { + api?.let { + try { + return api!!.echoDouble(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullableAsync has not been set") + } + + override suspend fun echoBool(request: Boolean?): Boolean? { + api?.let { + try { + return api!!.echoBool(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullableAsync has not been set") + } + + override suspend fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? { + api?.let { + try { + return api!!.sendSomeNullableTypes(someTypes) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullableAsync has not been set") + } +} diff --git a/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml b/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml index b329cfcefbe6..783c3f0e1845 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml +++ b/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml @@ -22,5 +22,7 @@ classes: - 'JniMessageApiNullableRegistrar' - 'JniMessageApiAsync' - 'JniMessageApiAsyncRegistrar' + - 'JniMessageApiNullableAsync' + - 'JniMessageApiNullableAsyncRegistrar' - 'SomeTypes' - 'SomeNullableTypes' From 0aff0fdff1132ff3e9ca6790ec6349c5883cbdbb Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Wed, 16 Apr 2025 19:13:25 -0700 Subject: [PATCH 3/4] refactor type logic, add codec --- packages/pigeon/lib/src/ast.dart | 15 + .../pigeon/lib/src/dart/dart_generator.dart | 424 ++++++++++++------ packages/pigeon/pigeons/jni_tests.dart | 11 +- .../lib/integration_tests.dart | 56 +-- .../lib/src/generated/jni_tests.gen.dart | 141 ++++-- .../lib/src/generated/jni_tests.gen.jni.dart | 353 ++++++++++----- .../shared_test_plugin_code/pubspec.yaml | 6 +- .../com/example/test_plugin/TestPlugin.kt | 65 ++- .../test_plugin/example/pubspec.yaml | 6 +- .../platform_tests/test_plugin/pubspec.yaml | 6 +- packages/pigeon/pubspec.yaml | 12 +- 11 files changed, 746 insertions(+), 349 deletions(-) diff --git a/packages/pigeon/lib/src/ast.dart b/packages/pigeon/lib/src/ast.dart index 116654458e52..123149921358 100644 --- a/packages/pigeon/lib/src/ast.dart +++ b/packages/pigeon/lib/src/ast.dart @@ -143,6 +143,7 @@ class AstProxyApi extends Api { super.documentationComments = const [], required this.constructors, required this.fields, + this.associatedType, this.superClass, this.interfaces = const {}, this.swiftOptions, @@ -155,6 +156,9 @@ class AstProxyApi extends Api { /// List of fields inside the API. List fields; + /// The TypeDeclaration associated with this ProxyApi. + TypeDeclaration? associatedType; + /// Name of the class this class considers the super class. TypeDeclaration? superClass; @@ -541,6 +545,7 @@ class TypeDeclaration { /// Returns duplicated `TypeDeclaration` with attached `associatedEnum` value. TypeDeclaration copyWithEnum(Enum enumDefinition) { + enumDefinition.associatedType = this; return TypeDeclaration( baseName: baseName, isNullable: isNullable, @@ -551,6 +556,7 @@ class TypeDeclaration { /// Returns duplicated `TypeDeclaration` with attached `associatedClass` value. TypeDeclaration copyWithClass(Class classDefinition) { + classDefinition.associatedType = this; return TypeDeclaration( baseName: baseName, isNullable: isNullable, @@ -561,6 +567,7 @@ class TypeDeclaration { /// Returns duplicated `TypeDeclaration` with attached `associatedProxyApi` value. TypeDeclaration copyWithProxyApi(AstProxyApi proxyApiDefinition) { + proxyApiDefinition.associatedType = this; return TypeDeclaration( baseName: baseName, isNullable: isNullable, @@ -707,6 +714,7 @@ class Class extends Node { required this.fields, this.superClassName, this.superClass, + this.associatedType, this.isSealed = false, this.isReferenced = true, this.isSwiftClass = false, @@ -725,6 +733,9 @@ class Class extends Node { /// The definition of the parent class. Class? superClass; + /// The TypeDeclaration associated with this class. + TypeDeclaration? associatedType; + /// List of class definitions of children. /// /// This is only meant to be used by sealed classes used in event channel methods. @@ -761,6 +772,7 @@ class Enum extends Node { Enum({ required this.name, required this.members, + this.associatedType, this.documentationComments = const [], }); @@ -770,6 +782,9 @@ class Enum extends Node { /// All of the members of the enum. List members; + /// The TypeDeclaration associated with this enum. + TypeDeclaration? associatedType; + /// List of documentation comments, separated by line. /// /// Lines should not include the comment marker itself, but should include any diff --git a/packages/pigeon/lib/src/dart/dart_generator.dart b/packages/pigeon/lib/src/dart/dart_generator.dart index 44a8d3266101..50a9d384b4f3 100644 --- a/packages/pigeon/lib/src/dart/dart_generator.dart +++ b/packages/pigeon/lib/src/dart/dart_generator.dart @@ -99,30 +99,55 @@ class DartOptions { } class _JniType { - const _JniType( - this.typeName, - this.jniName, - this.getterName, - this.conversionToDart, - this.conversionToJni, - this.conversionToNullableDart, - this.conversionToNullableJni, - this.isBuiltIn, { + _JniType({ + required this.typeName, + required this.jniName, + required this.getToDartCall, + required this.getToJniCall, + required this.isBuiltIn, this.nonNullableNeedsUnwrapping = false, }); - static _JniType fromTypeDeclaration(TypeDeclaration type) { + static _JniType fromTypeDeclaration(TypeDeclaration? type) { + if (type == null) { + // throw + return _JniType( + typeName: '', + jniName: '', + getToDartCall: ( + TypeDeclaration type, { + String? varName, + bool forceConversion = false, + }) => + '', + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + '', + isBuiltIn: false, + ); + } _JniType? jniType = _jniTypeForDartType[type.baseName]; jniType = jniType ?? _JniType( - type.baseName, - 'bridge.${type.baseName}', - 'get', - '${type.baseName}.fromJni', - '.toJni()', - '', - '', - false, + typeName: type.baseName, + jniName: 'bridge.${type.baseName}', + getToDartCall: ( + TypeDeclaration type, { + String? varName, + bool forceConversion = false, + }) => + '${type.baseName}.fromJni($varName)${_getForceNonNullSymbol(!type.isNullable)}', + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + _wrapInNullCheckIfNullable( + field.type, field.name, '${field.name}.toJni()'), + isBuiltIn: false, nonNullableNeedsUnwrapping: true, ); return jniType; @@ -130,118 +155,185 @@ class _JniType { final String typeName; final String jniName; - final String getterName; - final String conversionToDart; - final String conversionToJni; - final String conversionToNullableDart; - final String conversionToNullableJni; final bool isBuiltIn; final bool nonNullableNeedsUnwrapping; - - String getToDartCall( + final String Function( TypeDeclaration type, { - String? varName, - bool forceConversion = false, - }) { - varName = varName ?? ''; - if (isBuiltIn) { - return !type.isNullable && !nonNullableNeedsUnwrapping && !forceConversion - ? '' - : type.isNullable - ? '$varName$conversionToNullableDart' - : '$varName$conversionToDart'; - } - return '$conversionToDart($varName)${type.isNullable ? '' : '!'}'; - } - - String getToJniCall( - NamedType field, { - bool forceNonNull = false, - }) { - if (isBuiltIn) { - final String forceNonNullSymbol = forceNonNull ? '!' : ''; - return field.type.isNullable - ? '${field.name} != null ? $jniName$conversionToJni(${field.name}$forceNonNullSymbol) : null' - : nonNullableNeedsUnwrapping - ? '$jniName$conversionToJni(${field.name})' - : field.name; - } - return '${field.name}${field.type.isNullable ? '?' : ''}$conversionToJni'; - } + String varName, + bool forceConversion, + }) getToDartCall; + String Function( + NamedType field, + _JniType jniType, { + bool forceNonNull, + }) getToJniCall; + + // String getToDartCall( + // TypeDeclaration type, { + // String? varName, + // bool forceConversion = false, + // }) { + // varName = varName ?? ''; + // if (isBuiltIn) { + // return !type.isNullable && !nonNullableNeedsUnwrapping && !forceConversion + // ? '' + // : type.isNullable + // ? '$varName$conversionToNullableDart' + // : '$varName$conversionToDart'; + // } + // return '$conversionToDart($varName)${type.isNullable ? '' : '!'}'; + // } String getJniGetterMethodName(String field) { - return '$getterName${toUpperCamelCase(field)}()'; + return 'get${toUpperCamelCase(field)}()'; } String getApiCallReturnType(Method method) { - final String nullable = method.returnType.isNullable ? '?' : ''; if (method.isAsynchronous || method.returnType.isNullable || nonNullableNeedsUnwrapping) { - return '$jniName$nullable'; + return '$jniName${_getNullableSymbol(method.returnType)}'; } return typeName; } } -const Map _jniTypeForDartType = { +String _standardToJniCall( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, +}) { + return field.type.isNullable + ? '${field.name} == null ? null : ${jniType.jniName}(${field.name}${_getForceNonNullSymbol(forceNonNull)})' + : field.name; + // return '${field.name}${field.type.isNullable ? '?' : ''}$conversionToJni'; +} + +String _getNullableSymbol(TypeDeclaration type) => type.isNullable ? '?' : ''; + +String _getForceNonNullSymbol(bool force) => force ? '!' : ''; + +String _wrapInNullCheckIfNullable( + TypeDeclaration type, String varName, String code) => + type.isNullable ? '$varName == null ? null : $code' : code; + +final Map _jniTypeForDartType = { 'String': _JniType( - 'String', - 'JString', - 'get', - '.toDartString(releaseOriginal: true)', - '.fromString', - '?.toDartString(releaseOriginal: true)', - '?.fromString', - true, + typeName: 'String', + jniName: 'JString', + getToDartCall: ( + TypeDeclaration type, { + String varName = '', + bool forceConversion = false, + }) => + '$varName${_getNullableSymbol(type)}.toDartString(releaseOriginal: true)', + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + _wrapInNullCheckIfNullable(field.type, field.name, + 'JString.fromString(${field.name}${_getForceNonNullSymbol(field.type.isNullable && forceNonNull)})'), + isBuiltIn: true, nonNullableNeedsUnwrapping: true, ), 'void': _JniType( - 'void', - 'JVoid', - '', - '', - '', - '', - '', - true, + typeName: 'void', + jniName: 'JVoid', + getToDartCall: ( + TypeDeclaration type, { + String varName = '', + bool forceConversion = false, + }) => + '', + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + '', + isBuiltIn: true, ), 'bool': _JniType( - 'bool', - 'JBoolean', - 'get', - '.booleanValue(releaseOriginal: true)', - '', - '?.booleanValue(releaseOriginal: true)', - '', - true, + typeName: 'bool', + jniName: 'JBoolean', + getToDartCall: ( + TypeDeclaration type, { + String varName = '', + bool forceConversion = false, + }) => + type.isNullable || forceConversion + ? '$varName${_getNullableSymbol(type)}.booleanValue(releaseOriginal: true)' + : varName, + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + _standardToJniCall(field, jniType, forceNonNull: forceNonNull), + isBuiltIn: true, ), 'int': _JniType( - 'int', - 'JLong', - 'get', - '.intValue(releaseOriginal: true)', - '', - '?.intValue(releaseOriginal: true)', - '', - true, + typeName: 'int', + jniName: 'JLong', + getToDartCall: ( + TypeDeclaration type, { + String varName = '', + bool forceConversion = false, + }) => + type.isNullable || forceConversion + ? '$varName${_getNullableSymbol(type)}.intValue(releaseOriginal: true)' + : varName, + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + _standardToJniCall(field, jniType, forceNonNull: forceNonNull), + isBuiltIn: true, ), 'double': _JniType( - 'double', - 'JDouble', - 'get', - '.doubleValue(releaseOriginal: true)', - '', - '?.doubleValue(releaseOriginal: true)', - '', - true, + typeName: 'double', + jniName: 'JDouble', + getToDartCall: ( + TypeDeclaration type, { + String varName = '', + bool forceConversion = false, + }) => + type.isNullable || forceConversion + ? '$varName${_getNullableSymbol(type)}.doubleValue(releaseOriginal: true)' + : varName, + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + _standardToJniCall(field, jniType, forceNonNull: forceNonNull), + isBuiltIn: true, ), // 'Uint8List': 'ByteArray', // 'Int32List': 'IntArray', // 'Int64List': 'LongArray', // 'Float32List': 'FloatArray', // 'Float64List': 'DoubleArray', - // 'Object': _JniType('Object', 'JObject', 'get', '', '', '', '',), + 'Object': _JniType( + typeName: 'Object', + jniName: 'JObject', + getToDartCall: ( + TypeDeclaration type, { + String varName = '', + bool forceConversion = false, + }) => + '_PigeonJniCodec.readValue($varName)', + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + '_PigeonJniCodec.writeValue(${field.name})', + isBuiltIn: true, + nonNullableNeedsUnwrapping: true, + ), }; /// Options that control how Dart code will be generated. @@ -464,7 +556,8 @@ class DartGenerator extends StructuredGenerator { for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) { final _JniType jniType = _JniType.fromTypeDeclaration(field.type); - indent.writeln('${jniType.getToJniCall(field, forceNonNull: true)},'); + indent.writeln( + '${jniType.getToJniCall(field, jniType, forceNonNull: true)},'); } }); }); @@ -828,9 +921,8 @@ class DartGenerator extends StructuredGenerator { method.isAsynchronous || returnType.nonNullableNeedsUnwrapping) && returnType.typeName != 'void') { - final String nullable = method.returnType.isNullable ? '?' : ''; indent.writeln( - 'final ${returnType.typeName}$nullable dartTypeRes = ${returnType.getToDartCall(method.returnType, varName: 'res', forceConversion: method.isAsynchronous)};'); + 'final ${returnType.typeName}${_getNullableSymbol(method.returnType)} dartTypeRes = ${returnType.getToDartCall(method.returnType, varName: 'res', forceConversion: method.isAsynchronous)};'); indent.writeln('return dartTypeRes;'); } }); @@ -840,11 +932,10 @@ class DartGenerator extends StructuredGenerator { } String _getJniMethodCallArguments(Iterable parameters) { - return parameters - .map((Parameter parameter) => - _JniType.fromTypeDeclaration(parameter.type) - .getToJniCall(parameter)) - .join(', '); + return parameters.map((Parameter parameter) { + final _JniType jniType = _JniType.fromTypeDeclaration(parameter.type); + return jniType.getToJniCall(parameter, jniType); + }).join(', '); } /// Writes the code for host [Api], [api]. @@ -1387,48 +1478,103 @@ final BinaryMessenger? ${varNamePrefix}binaryMessenger; _writeDeepEquals(indent); } if (generatorOptions.useJni) { - _writeConvertObject(indent); + _writeJniCodec(indent, root); } } - void _writeConvertObject(Indent indent) { + void _writeJniCodec(Indent indent, Root root) { indent.newln(); indent.format(''' -Object? convertObject(JObject? object) { - if (object == null) { - return null; - } - if (object.isA(JLong.type)) { - return (object.as(JLong.type)).intValue(); - } - if (object.isA(JDouble.type)) { - return (object.as(JDouble.type)).doubleValue(); - } - if (object.isA(JString.type)) { - return (object.as(JString.type)).toDartString(); - } - if (object.isA(JBoolean.type)) { - return (object.as(JBoolean.type)).booleanValue(); - } - if (object.isA>(JList.type(JObject.type))) { - final JList list = (object.as(JList.type(JObject.type))); - final List res = []; - for (int i = 0; i < list.length; i++) { - res.add(convertObject(list[i])); +class _PigeonJniCodec { + Object? readValue(JObject? value) { + if (value == null) { + return null; + } else if (value.isA(JLong.type)) { + return (value.as(JLong.type)).intValue(); + } else if (value.isA(JDouble.type)) { + return (value.as(JDouble.type)).doubleValue(); + } else if (value.isA(JString.type)) { + return (value.as(JString.type)).toDartString(); + } else if (value.isA(JBoolean.type)) { + return (value.as(JBoolean.type)).booleanValue(); + } else if (value.isA>(JList.type(JObject.type))) { + final JList list = (value.as(JList.type(JObject.type))); + final List res = []; + for (int i = 0; i < list.length; i++) { + res.add(readValue(list[i])); + } + return res; + } else if (value.isA>( + JMap.type(JObject.type, JObject.type))) { + final JMap map = + (value.as(JMap.type(JObject.type, JObject.type))); + final Map res = {}; + for (final MapEntry entry in map.entries) { + res[readValue(entry.key)] = readValue(entry.value); + } + return res; + ${root.classes.map((Class dataClass) { + final _JniType jniType = + _JniType.fromTypeDeclaration(dataClass.associatedType); + return ''' + } else if (value.isA<${jniType.jniName}>( + ${jniType.jniName}.type)) { + return ${jniType.typeName}.fromJni(value.as(${jniType.jniName}.type)); + '''; + }).join()} + } else { + throw ArgumentError.value(value); } - return res; } - if (object.isA>( - JMap.type(JObject.type, JObject.type))) { - final JMap map = - (object.as(JMap.type(JObject.type, JObject.type))); - final Map res = {}; - for (final MapEntry entry in map.entries) { - res[convertObject(entry.key)] = convertObject(entry.value); + + JObject? writeValue(Object? value) { + if (value == null) { + return null; + } else if (value is bool) { + return JBoolean(value); + } else if (value is double) { + return JDouble(value); + } else if (value is int) { + return JLong(value); + } else if (value is String) { + return JString.fromString(value); + } else if (value is Uint8List) { + //TODO + return null; + } else if (value is Int32List) { + //TODO + return null; + } else if (value is Int64List) { + //TODO + return null; + } else if (value is Float64List) { + //TODO + return null; + } else if (value is List) { + final JList res = JList.array(JObject.type); + for (int i = 0; i < value.length; i++) { + res.add(writeValue(value[i])); + } + return res; + } else if (value is Map) { + final JMap res = + JMap.hash(JObject.type, JObject.type); + for (final MapEntry entry in value.entries) { + res[writeValue(entry.key)] = writeValue(entry.value); + } + return res; + ${root.classes.map((Class dataClass) { + final _JniType jniType = + _JniType.fromTypeDeclaration(dataClass.associatedType); + return ''' + } else if (value is ${jniType.typeName}) { + return value.toJni(); + '''; + }).join()} + } else { + throw ArgumentError.value(value); } - return res; } - return object; } '''); } diff --git a/packages/pigeon/pigeons/jni_tests.dart b/packages/pigeon/pigeons/jni_tests.dart index e6452f0a6b8d..df8b10aaef4e 100644 --- a/packages/pigeon/pigeons/jni_tests.dart +++ b/packages/pigeon/pigeons/jni_tests.dart @@ -9,12 +9,18 @@ import 'package:pigeon/pigeon.dart'; kotlinOptions: KotlinOptions(useJni: true), )) class SomeTypes { - const SomeTypes(this.aString, this.anInt, this.aDouble, this.aBool); + const SomeTypes( + this.aString, + this.anInt, + this.aDouble, + this.aBool, + // this.anObject, + ); final String aString; final int anInt; final double aDouble; final bool aBool; - // Object anObject; + // final Object anObject; } class SomeNullableTypes { @@ -32,6 +38,7 @@ abstract class JniMessageApi { int echoInt(int request); double echoDouble(double request); bool echoBool(bool request); + // Object echoObj(Object request); SomeTypes sendSomeTypes(SomeTypes someTypes); } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart index d0aa41d8b827..52f0d652846f 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart @@ -61,20 +61,20 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { expect(sync.aDouble, 5.0); expect(sync.aBool, false); //nullable - // final JniMessageApiNullable? jniMessageNullable = - // JniMessageApiNullable.getInstance(); - // expect(jniMessageNullable, isNotNull); - // expect(jniMessageNullable!.echoString('hello'), 'hello'); - // expect(jniMessageNullable.echoString(null), null); - // final SomeNullableTypes? syncNullable = - // jniMessageNullable.sendSomeNullableTypes(SomeNullableTypes()); - // expect(syncNullable!.aString, null); - // expect(syncNullable.anInt, null); - // expect(syncNullable.aDouble, null); - // expect(syncNullable.aBool, null); - // final SomeNullableTypes? syncNull = - // jniMessageNullable.sendSomeNullableTypes(null); - // expect(syncNull, null); + final JniMessageApiNullable? jniMessageNullable = + JniMessageApiNullable.getInstance(); + expect(jniMessageNullable, isNotNull); + expect(jniMessageNullable!.echoString('hello'), 'hello'); + expect(jniMessageNullable.echoString(null), null); + final SomeNullableTypes? syncNullable = + jniMessageNullable.sendSomeNullableTypes(SomeNullableTypes()); + expect(syncNullable!.aString, null); + expect(syncNullable.anInt, null); + expect(syncNullable.aDouble, null); + expect(syncNullable.aBool, null); + final SomeNullableTypes? syncNull = + jniMessageNullable.sendSomeNullableTypes(null); + expect(syncNull, null); //async final JniMessageApiAsync? jniMessageAsync = JniMessageApiAsync.getInstance(); @@ -90,20 +90,20 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { expect(nonSync.aDouble, 5.0); expect(nonSync.aBool, false); //nullable async - // final JniMessageApiNullableAsync? jniMessageNullableAsync = - // JniMessageApiNullableAsync.getInstance(); - // expect(jniMessageNullableAsync, isNotNull); - // expect(await jniMessageNullableAsync!.echoString('hello'), 'hello'); - // expect(await jniMessageNullableAsync.echoString(null), null); - // final SomeNullableTypes? syncNullableAsync = await jniMessageNullableAsync - // .sendSomeNullableTypes(SomeNullableTypes()); - // expect(syncNullableAsync!.aString, null); - // expect(syncNullableAsync.anInt, null); - // expect(syncNullableAsync.aDouble, null); - // expect(syncNullableAsync.aBool, null); - // final SomeNullableTypes? syncNullAsync = - // await jniMessageNullableAsync.sendSomeNullableTypes(null); - // expect(syncNull, null); + final JniMessageApiNullableAsync? jniMessageNullableAsync = + JniMessageApiNullableAsync.getInstance(); + expect(jniMessageNullableAsync, isNotNull); + expect(await jniMessageNullableAsync!.echoString('hello'), 'hello'); + expect(await jniMessageNullableAsync.echoString(null), null); + final SomeNullableTypes? syncNullableAsync = await jniMessageNullableAsync + .sendSomeNullableTypes(SomeNullableTypes()); + expect(syncNullableAsync!.aString, null); + expect(syncNullableAsync.anInt, null); + expect(syncNullableAsync.aDouble, null); + expect(syncNullableAsync.aBool, null); + final SomeNullableTypes? syncNullAsync = + await jniMessageNullableAsync.sendSomeNullableTypes(null); + expect(syncNull, null); //named final JniMessageApi? jniMessageNamed = JniMessageApi.getInstance(channelName: 'name'); diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart index 64aa5ab47c77..a797a841e7b1 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart @@ -14,41 +14,88 @@ import 'package:flutter/services.dart'; import 'package:jni/jni.dart'; import './jni_tests.gen.jni.dart' as bridge; -Object? convertObject(JObject? object) { - if (object == null) { - return null; - } - if (object.isA(JLong.type)) { - return (object.as(JLong.type)).intValue(); - } - if (object.isA(JDouble.type)) { - return (object.as(JDouble.type)).doubleValue(); - } - if (object.isA(JString.type)) { - return (object.as(JString.type)).toDartString(); - } - if (object.isA(JBoolean.type)) { - return (object.as(JBoolean.type)).booleanValue(); - } - if (object.isA>(JList.type(JObject.type))) { - final JList list = (object.as(JList.type(JObject.type))); - final List res = []; - for (int i = 0; i < list.length; i++) { - res.add(convertObject(list[i])); +class _PigeonJniCodec { + Object? readValue(JObject? value) { + if (value == null) { + return null; + } else if (value.isA(JLong.type)) { + return (value.as(JLong.type)).intValue(); + } else if (value.isA(JDouble.type)) { + return (value.as(JDouble.type)).doubleValue(); + } else if (value.isA(JString.type)) { + return (value.as(JString.type)).toDartString(); + } else if (value.isA(JBoolean.type)) { + return (value.as(JBoolean.type)).booleanValue(); + } else if (value.isA>(JList.type(JObject.type))) { + final JList list = (value.as(JList.type(JObject.type))); + final List res = []; + for (int i = 0; i < list.length; i++) { + res.add(readValue(list[i])); + } + return res; + } else if (value.isA>( + JMap.type(JObject.type, JObject.type))) { + final JMap map = + (value.as(JMap.type(JObject.type, JObject.type))); + final Map res = {}; + for (final MapEntry entry in map.entries) { + res[readValue(entry.key)] = readValue(entry.value); + } + return res; + } else if (value.isA(bridge.SomeTypes.type)) { + return SomeTypes.fromJni(value.as(bridge.SomeTypes.type)); + } else if (value + .isA(bridge.SomeNullableTypes.type)) { + return SomeNullableTypes.fromJni(value.as(bridge.SomeNullableTypes.type)); + } else { + throw ArgumentError.value(value); } - return res; } - if (object.isA>( - JMap.type(JObject.type, JObject.type))) { - final JMap map = - (object.as(JMap.type(JObject.type, JObject.type))); - final Map res = {}; - for (final MapEntry entry in map.entries) { - res[convertObject(entry.key)] = convertObject(entry.value); + + JObject? writeValue(Object? value) { + if (value == null) { + return null; + } else if (value is bool) { + return JBoolean(value); + } else if (value is double) { + return JDouble(value); + } else if (value is int) { + return JLong(value); + } else if (value is String) { + return JString.fromString(value); + } else if (value is Uint8List) { + //TODO + return null; + } else if (value is Int32List) { + //TODO + return null; + } else if (value is Int64List) { + //TODO + return null; + } else if (value is Float64List) { + //TODO + return null; + } else if (value is List) { + final JList res = JList.array(JObject.type); + for (int i = 0; i < value.length; i++) { + res.add(writeValue(value[i])); + } + return res; + } else if (value is Map) { + final JMap res = + JMap.hash(JObject.type, JObject.type); + for (final MapEntry entry in value.entries) { + res[writeValue(entry.key)] = writeValue(entry.value); + } + return res; + } else if (value is SomeTypes) { + return value.toJni(); + } else if (value is SomeNullableTypes) { + return value.toJni(); + } else { + throw ArgumentError.value(value); } - return res; } - return object; } class SomeTypes { @@ -157,10 +204,10 @@ class SomeNullableTypes { bridge.SomeNullableTypes toJni() { return bridge.SomeNullableTypes( - aString != null ? JString.fromString(aString!) : null, - anInt != null ? JLong(anInt!) : null, - aDouble != null ? JDouble(aDouble!) : null, - aBool != null ? JBoolean(aBool!) : null, + aString == null ? null : JString.fromString(aString!), + anInt == null ? null : JLong(anInt!), + aDouble == null ? null : JDouble(aDouble!), + aBool == null ? null : JBoolean(aBool!), ); } @@ -291,34 +338,34 @@ class JniMessageApiNullable { String? echoString(String? request) { final JString? res = - _api.echoString(request != null ? JString.fromString(request) : null); + _api.echoString(request == null ? null : JString.fromString(request)); final String? dartTypeRes = res?.toDartString(releaseOriginal: true); return dartTypeRes; } int? echoInt(int? request) { - final JLong? res = _api.echoInt(request != null ? JLong(request) : null); + final JLong? res = _api.echoInt(request == null ? null : JLong(request)); final int? dartTypeRes = res?.intValue(releaseOriginal: true); return dartTypeRes; } double? echoDouble(double? request) { final JDouble? res = - _api.echoDouble(request != null ? JDouble(request) : null); + _api.echoDouble(request == null ? null : JDouble(request)); final double? dartTypeRes = res?.doubleValue(releaseOriginal: true); return dartTypeRes; } bool? echoBool(bool? request) { final JBoolean? res = - _api.echoBool(request != null ? JBoolean(request) : null); + _api.echoBool(request == null ? null : JBoolean(request)); final bool? dartTypeRes = res?.booleanValue(releaseOriginal: true); return dartTypeRes; } SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes) { - final bridge.SomeNullableTypes? res = - _api.sendSomeNullableTypes(someTypes?.toJni()); + final bridge.SomeNullableTypes? res = _api + .sendSomeNullableTypes(someTypes == null ? null : someTypes.toJni()); final SomeNullableTypes? dartTypeRes = SomeNullableTypes.fromJni(res); return dartTypeRes; } @@ -411,36 +458,36 @@ class JniMessageApiNullableAsync { Future echoString(String? request) async { final JString? res = await _api - .echoString(request != null ? JString.fromString(request) : null); + .echoString(request == null ? null : JString.fromString(request)); final String? dartTypeRes = res?.toDartString(releaseOriginal: true); return dartTypeRes; } Future echoInt(int? request) async { final JLong? res = - await _api.echoInt(request != null ? JLong(request) : null); + await _api.echoInt(request == null ? null : JLong(request)); final int? dartTypeRes = res?.intValue(releaseOriginal: true); return dartTypeRes; } Future echoDouble(double? request) async { final JDouble? res = - await _api.echoDouble(request != null ? JDouble(request) : null); + await _api.echoDouble(request == null ? null : JDouble(request)); final double? dartTypeRes = res?.doubleValue(releaseOriginal: true); return dartTypeRes; } Future echoBool(bool? request) async { final JBoolean? res = - await _api.echoBool(request != null ? JBoolean(request) : null); + await _api.echoBool(request == null ? null : JBoolean(request)); final bool? dartTypeRes = res?.booleanValue(releaseOriginal: true); return dartTypeRes; } Future sendSomeNullableTypes( SomeNullableTypes? someTypes) async { - final bridge.SomeNullableTypes? res = - await _api.sendSomeNullableTypes(someTypes?.toJni()); + final bridge.SomeNullableTypes? res = await _api + .sendSomeNullableTypes(someTypes == null ? null : someTypes.toJni()); final SomeNullableTypes? dartTypeRes = SomeNullableTypes.fromJni(res); return dartTypeRes; } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart index 76a24571145f..1fdc288ec07b 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart @@ -1,10 +1,11 @@ -// Autogenerated by jnigen. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT! // ignore_for_file: annotate_overrides // ignore_for_file: argument_type_not_assignable // ignore_for_file: camel_case_extensions // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names +// ignore_for_file: comment_references // ignore_for_file: doc_directive_unknown // ignore_for_file: file_names // ignore_for_file: inference_failure_on_untyped_parameter @@ -1297,7 +1298,7 @@ class JniMessageApiAsync extends jni$_.JObject { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object doNothing(kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object doNothing(kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future doNothing() async { final $p = jni$_.ReceivePort(); @@ -1310,8 +1311,9 @@ class JniMessageApiAsync extends jni$_.JObject { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1321,7 +1323,10 @@ class JniMessageApiAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JObjectType(), releaseOriginal: true); + return $o.as( + const jni$_.JObjectType(), + releaseOriginal: true, + ); } static final _id_echoString = _class.instanceMethodId( @@ -1346,7 +1351,7 @@ class JniMessageApiAsync extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoString( jni$_.JString string, @@ -1364,8 +1369,9 @@ class JniMessageApiAsync extends jni$_.JObject { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1375,7 +1381,10 @@ class JniMessageApiAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JStringType(), releaseOriginal: true); + return $o.as( + const jni$_.JStringType(), + releaseOriginal: true, + ); } static final _id_echoInt = _class.instanceMethodId( @@ -1395,7 +1404,7 @@ class JniMessageApiAsync extends jni$_.JObject { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object echoInt(long j, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object echoInt(long j, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoInt( int j, @@ -1410,8 +1419,9 @@ class JniMessageApiAsync extends jni$_.JObject { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1421,7 +1431,10 @@ class JniMessageApiAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JLongType(), releaseOriginal: true); + return $o.as( + const jni$_.JLongType(), + releaseOriginal: true, + ); } static final _id_echoDouble = _class.instanceMethodId( @@ -1443,7 +1456,7 @@ class JniMessageApiAsync extends jni$_.JObject { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, double, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object echoDouble(double d, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object echoDouble(double d, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoDouble( double d, @@ -1458,8 +1471,9 @@ class JniMessageApiAsync extends jni$_.JObject { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1469,7 +1483,10 @@ class JniMessageApiAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JDoubleType(), releaseOriginal: true); + return $o.as( + const jni$_.JDoubleType(), + releaseOriginal: true, + ); } static final _id_echoBool = _class.instanceMethodId( @@ -1489,7 +1506,7 @@ class JniMessageApiAsync extends jni$_.JObject { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object echoBool(boolean z, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object echoBool(boolean z, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoBool( bool z, @@ -1504,8 +1521,9 @@ class JniMessageApiAsync extends jni$_.JObject { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1515,7 +1533,10 @@ class JniMessageApiAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JBooleanType(), releaseOriginal: true); + return $o.as( + const jni$_.JBooleanType(), + releaseOriginal: true, + ); } static final _id_sendSomeTypes = _class.instanceMethodId( @@ -1540,7 +1561,7 @@ class JniMessageApiAsync extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object sendSomeTypes(SomeTypes someTypes, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object sendSomeTypes(SomeTypes someTypes, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future sendSomeTypes( SomeTypes someTypes, @@ -1558,8 +1579,9 @@ class JniMessageApiAsync extends jni$_.JObject { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1569,7 +1591,10 @@ class JniMessageApiAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const $SomeTypes$Type(), releaseOriginal: true); + return $o.as( + const $SomeTypes$Type(), + releaseOriginal: true, + ); } } @@ -1822,7 +1847,7 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public java.lang.Object doNothing(kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object doNothing(kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future doNothing() async { final $p = jni$_.ReceivePort(); @@ -1835,8 +1860,9 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1846,7 +1872,10 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { } else { $o = $r; } - return $o.as(const jni$_.JObjectType(), releaseOriginal: true); + return $o.as( + const jni$_.JObjectType(), + releaseOriginal: true, + ); } static final _id_echoString = _class.instanceMethodId( @@ -1871,7 +1900,7 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoString( jni$_.JString string, @@ -1889,8 +1918,9 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1900,7 +1930,10 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { } else { $o = $r; } - return $o.as(const jni$_.JStringType(), releaseOriginal: true); + return $o.as( + const jni$_.JStringType(), + releaseOriginal: true, + ); } static final _id_echoInt = _class.instanceMethodId( @@ -1920,7 +1953,7 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); - /// from: `public java.lang.Object echoInt(long j, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoInt(long j, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoInt( int j, @@ -1935,8 +1968,9 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1946,7 +1980,10 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { } else { $o = $r; } - return $o.as(const jni$_.JLongType(), releaseOriginal: true); + return $o.as( + const jni$_.JLongType(), + releaseOriginal: true, + ); } static final _id_echoDouble = _class.instanceMethodId( @@ -1968,7 +2005,7 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, double, jni$_.Pointer)>(); - /// from: `public java.lang.Object echoDouble(double d, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoDouble(double d, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoDouble( double d, @@ -1983,8 +2020,9 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -1994,7 +2032,10 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { } else { $o = $r; } - return $o.as(const jni$_.JDoubleType(), releaseOriginal: true); + return $o.as( + const jni$_.JDoubleType(), + releaseOriginal: true, + ); } static final _id_echoBool = _class.instanceMethodId( @@ -2014,7 +2055,7 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); - /// from: `public java.lang.Object echoBool(boolean z, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoBool(boolean z, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoBool( bool z, @@ -2029,8 +2070,9 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -2040,7 +2082,10 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { } else { $o = $r; } - return $o.as(const jni$_.JBooleanType(), releaseOriginal: true); + return $o.as( + const jni$_.JBooleanType(), + releaseOriginal: true, + ); } static final _id_sendSomeTypes = _class.instanceMethodId( @@ -2065,7 +2110,7 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public java.lang.Object sendSomeTypes(SomeTypes someTypes, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object sendSomeTypes(SomeTypes someTypes, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future sendSomeTypes( SomeTypes someTypes, @@ -2083,8 +2128,9 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { final jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); + final $a = await $p.first; $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); if ($o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); @@ -2094,7 +2140,10 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { } else { $o = $r; } - return $o.as(const $SomeTypes$Type(), releaseOriginal: true); + return $o.as( + const $SomeTypes$Type(), + releaseOriginal: true, + ); } } @@ -2214,7 +2263,7 @@ class JniMessageApiNullableAsync extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoString( jni$_.JString? string, @@ -2227,14 +2276,17 @@ class JniMessageApiNullableAsync extends jni$_.JObject { _id_echoString as jni$_.JMethodIDPtr, _$string.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2243,7 +2295,10 @@ class JniMessageApiNullableAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JStringNullableType(), releaseOriginal: true); + return $o?.as( + const jni$_.JStringNullableType(), + releaseOriginal: true, + ); } static final _id_echoInt = _class.instanceMethodId( @@ -2268,7 +2323,7 @@ class JniMessageApiNullableAsync extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object echoInt(java.lang.Long long, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object echoInt(java.lang.Long long, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoInt( jni$_.JLong? long, @@ -2278,14 +2333,17 @@ class JniMessageApiNullableAsync extends jni$_.JObject { final _$long = long?.reference ?? jni$_.jNullReference; final $r = _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, _$long.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2294,7 +2352,10 @@ class JniMessageApiNullableAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JLongNullableType(), releaseOriginal: true); + return $o?.as( + const jni$_.JLongNullableType(), + releaseOriginal: true, + ); } static final _id_echoDouble = _class.instanceMethodId( @@ -2319,7 +2380,7 @@ class JniMessageApiNullableAsync extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object echoDouble(java.lang.Double double, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object echoDouble(java.lang.Double double, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoDouble( jni$_.JDouble? double, @@ -2332,14 +2393,17 @@ class JniMessageApiNullableAsync extends jni$_.JObject { _id_echoDouble as jni$_.JMethodIDPtr, _$double.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2348,7 +2412,10 @@ class JniMessageApiNullableAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JDoubleNullableType(), releaseOriginal: true); + return $o?.as( + const jni$_.JDoubleNullableType(), + releaseOriginal: true, + ); } static final _id_echoBool = _class.instanceMethodId( @@ -2373,7 +2440,7 @@ class JniMessageApiNullableAsync extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object echoBool(java.lang.Boolean boolean, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object echoBool(java.lang.Boolean boolean, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoBool( jni$_.JBoolean? boolean, @@ -2383,14 +2450,17 @@ class JniMessageApiNullableAsync extends jni$_.JObject { final _$boolean = boolean?.reference ?? jni$_.jNullReference; final $r = _echoBool(reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, _$boolean.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2399,7 +2469,10 @@ class JniMessageApiNullableAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const jni$_.JBooleanNullableType(), releaseOriginal: true); + return $o?.as( + const jni$_.JBooleanNullableType(), + releaseOriginal: true, + ); } static final _id_sendSomeNullableTypes = _class.instanceMethodId( @@ -2424,7 +2497,7 @@ class JniMessageApiNullableAsync extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public abstract java.lang.Object sendSomeNullableTypes(SomeNullableTypes someNullableTypes, kotlin.coroutines.Continuation continuation)` + /// from: `public abstract java.lang.Object sendSomeNullableTypes(SomeNullableTypes someNullableTypes, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future sendSomeNullableTypes( SomeNullableTypes? someNullableTypes, @@ -2438,14 +2511,17 @@ class JniMessageApiNullableAsync extends jni$_.JObject { _id_sendSomeNullableTypes as jni$_.JMethodIDPtr, _$someNullableTypes.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2454,8 +2530,10 @@ class JniMessageApiNullableAsync extends jni$_.JObject { } else { $o = $r; } - return $o.as(const $SomeNullableTypes$NullableType(), - releaseOriginal: true); + return $o?.as( + const $SomeNullableTypes$NullableType(), + releaseOriginal: true, + ); } } @@ -2717,7 +2795,7 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoString(java.lang.String string, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoString( jni$_.JString? string, @@ -2730,14 +2808,17 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { _id_echoString as jni$_.JMethodIDPtr, _$string.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2746,7 +2827,10 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { } else { $o = $r; } - return $o.as(const jni$_.JStringNullableType(), releaseOriginal: true); + return $o?.as( + const jni$_.JStringNullableType(), + releaseOriginal: true, + ); } static final _id_echoInt = _class.instanceMethodId( @@ -2771,7 +2855,7 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public java.lang.Object echoInt(java.lang.Long long, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoInt(java.lang.Long long, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoInt( jni$_.JLong? long, @@ -2781,14 +2865,17 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { final _$long = long?.reference ?? jni$_.jNullReference; final $r = _echoInt(reference.pointer, _id_echoInt as jni$_.JMethodIDPtr, _$long.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2797,7 +2884,10 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { } else { $o = $r; } - return $o.as(const jni$_.JLongNullableType(), releaseOriginal: true); + return $o?.as( + const jni$_.JLongNullableType(), + releaseOriginal: true, + ); } static final _id_echoDouble = _class.instanceMethodId( @@ -2822,7 +2912,7 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public java.lang.Object echoDouble(java.lang.Double double, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoDouble(java.lang.Double double, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoDouble( jni$_.JDouble? double, @@ -2835,14 +2925,17 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { _id_echoDouble as jni$_.JMethodIDPtr, _$double.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2851,7 +2944,10 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { } else { $o = $r; } - return $o.as(const jni$_.JDoubleNullableType(), releaseOriginal: true); + return $o?.as( + const jni$_.JDoubleNullableType(), + releaseOriginal: true, + ); } static final _id_echoBool = _class.instanceMethodId( @@ -2876,7 +2972,7 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public java.lang.Object echoBool(java.lang.Boolean boolean, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoBool(java.lang.Boolean boolean, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future echoBool( jni$_.JBoolean? boolean, @@ -2886,14 +2982,17 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { final _$boolean = boolean?.reference ?? jni$_.jNullReference; final $r = _echoBool(reference.pointer, _id_echoBool as jni$_.JMethodIDPtr, _$boolean.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2902,7 +3001,10 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { } else { $o = $r; } - return $o.as(const jni$_.JBooleanNullableType(), releaseOriginal: true); + return $o?.as( + const jni$_.JBooleanNullableType(), + releaseOriginal: true, + ); } static final _id_sendSomeNullableTypes = _class.instanceMethodId( @@ -2927,7 +3029,7 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public java.lang.Object sendSomeNullableTypes(SomeNullableTypes someNullableTypes, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object sendSomeNullableTypes(SomeNullableTypes someNullableTypes, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. core$_.Future sendSomeNullableTypes( SomeNullableTypes? someNullableTypes, @@ -2941,14 +3043,17 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { _id_sendSomeNullableTypes as jni$_.JMethodIDPtr, _$someNullableTypes.pointer, _$continuation.pointer) - .object(const jni$_.JObjectType()); + .object(const jni$_.JObjectNullableType()); _$continuation.release(); - final jni$_.JObject $o; - if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { $r.release(); - $o = jni$_.JObject.fromReference( - jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress(await $p.first))); - if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { final $e = jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); $o.release(); @@ -2957,8 +3062,10 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { } else { $o = $r; } - return $o.as(const $SomeNullableTypes$NullableType(), - releaseOriginal: true); + return $o?.as( + const $SomeNullableTypes$NullableType(), + releaseOriginal: true, + ); } } @@ -3076,7 +3183,7 @@ class SomeTypes$Companion extends jni$_.JObject { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public final SomeTypes fromList(java.util.List list)` + /// from: `public final SomeTypes fromList(java.util.List list)` /// The returned object must be released after use, by calling the [release] method. SomeTypes fromList( jni$_.JList list, @@ -3368,7 +3475,7 @@ class SomeTypes extends jni$_.JObject { jni$_.JMethodIDPtr, )>(); - /// from: `public final java.util.List toList()` + /// from: `public final java.util.List toList()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList toList() { return _toList(reference.pointer, _id_toList as jni$_.JMethodIDPtr) @@ -3689,7 +3796,7 @@ class SomeNullableTypes$Companion extends jni$_.JObject { jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public final SomeNullableTypes fromList(java.util.List list)` + /// from: `public final SomeNullableTypes fromList(java.util.List list)` /// The returned object must be released after use, by calling the [release] method. SomeNullableTypes fromList( jni$_.JList list, @@ -4051,7 +4158,7 @@ class SomeNullableTypes extends jni$_.JObject { jni$_.JMethodIDPtr, )>(); - /// from: `public final java.util.List toList()` + /// from: `public final java.util.List toList()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList toList() { return _toList(reference.pointer, _id_toList as jni$_.JMethodIDPtr) diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/pubspec.yaml b/packages/pigeon/platform_tests/shared_test_plugin_code/pubspec.yaml index 674eb6d4106d..63845dfd15f9 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/pubspec.yaml +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/pubspec.yaml @@ -18,5 +18,9 @@ dependencies: sdk: flutter integration_test: sdk: flutter - jni: ^0.14.0 + jni: + git: + url: https://github.com/dart-lang/native/ + path: pkgs/jni + ref: 735250a19b1a429869bfacccba833ecc93db34b6 mockito: ^5.4.4 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 2627b7622169..4c47ed6e254f 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 @@ -7,7 +7,12 @@ package com.example.test_plugin import JniMessageApi import JniMessageApiAsync import JniMessageApiAsyncRegistrar +import JniMessageApiNullable +import JniMessageApiNullableAsync +import JniMessageApiNullableAsyncRegistrar +import JniMessageApiNullableRegistrar import JniMessageApiRegistrar +import SomeNullableTypes import SomeTypes import android.os.Handler import android.os.Looper @@ -22,8 +27,10 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { private var proxyApiRegistrar: ProxyApiRegistrar? = null private var jniMessageApi: JniMessageApiRegistrar? = null private var jniMessageApiNamed: JniMessageApiRegistrar? = null + private var jniMessageApiNullable: JniMessageApiNullableRegistrar? = null private var jniMessageApiAsync: JniMessageApiAsyncRegistrar? = null private var jniMessageApiAsyncNamed: JniMessageApiAsyncRegistrar? = null + private var jniMessageApiNullableAsync: JniMessageApiNullableAsyncRegistrar? = null override fun onAttachedToEngine(binding: FlutterPluginBinding) { HostIntegrationCoreApi.setUp(binding.binaryMessenger, this) @@ -34,9 +41,12 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { jniMessageApi = JniMessageApiRegistrar().register(JniMessageApiImpl()) jniMessageApiNamed = JniMessageApiRegistrar().register(JniMessageApiImpl2(), "name") + jniMessageApiNullable = JniMessageApiNullableRegistrar().register(JniMessageApiNullableImpl()) jniMessageApiAsync = JniMessageApiAsyncRegistrar().register(JniMessageApiAsyncImpl()) jniMessageApiAsyncNamed = JniMessageApiAsyncRegistrar().register(JniMessageApiAsyncImpl2(), "name") + jniMessageApiNullableAsync = + JniMessageApiNullableAsyncRegistrar().register(JniMessageApiNullableAsyncImpl()) flutterApi = FlutterIntegrationCoreApi(binding.binaryMessenger) flutterSmallApiOne = FlutterSmallApi(binding.binaryMessenger, "suffixOne") @@ -53,7 +63,7 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { binding.binaryMessenger, SendConsistentNumbers(2), "2") } - override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { + override fun onDetachedFromEngine(binding: FlutterPluginBinding) { proxyApiRegistrar?.tearDown() } @@ -543,11 +553,11 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { } override fun defaultIsMainThread(): Boolean { - return Thread.currentThread() == Looper.getMainLooper().getThread() + return Thread.currentThread() == Looper.getMainLooper().thread } override fun taskQueueIsBackgroundThread(): Boolean { - return Thread.currentThread() != Looper.getMainLooper().getThread() + return Thread.currentThread() != Looper.getMainLooper().thread } override fun callFlutterNoop(callback: (Result) -> Unit) { @@ -947,6 +957,28 @@ class JniMessageApiImpl2 : JniMessageApi() { } } +class JniMessageApiNullableImpl : JniMessageApiNullable() { + override fun echoString(request: String?): String? { + return request + } + + override fun echoInt(request: Long?): Long? { + return request + } + + override fun echoDouble(request: Double?): Double? { + return request + } + + override fun echoBool(request: Boolean?): Boolean? { + return request + } + + override fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? { + return someTypes + } +} + class JniMessageApiAsyncImpl : JniMessageApiAsync() { override suspend fun doNothing() { return @@ -1008,6 +1040,29 @@ class JniMessageApiAsyncImpl2 : JniMessageApiAsync() { } } +class JniMessageApiNullableAsyncImpl : JniMessageApiNullableAsync() { + + override suspend fun echoString(request: String?): String? { + return request + } + + override suspend fun echoInt(request: Long?): Long? { + return request + } + + override suspend fun echoDouble(request: Double?): Double? { + return request + } + + override suspend fun echoBool(request: Boolean?): Boolean? { + return request + } + + override suspend fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? { + return someTypes + } +} + // override suspend fun thinkBeforeAnswering(): String { // delay(10L) // return "42" @@ -1064,7 +1119,7 @@ object SendClass : StreamEventsStreamHandler() { ClassEvent(EventAllNullableTypes(aNullableInt = 0))) override fun onListen(p0: Any?, sink: PigeonEventSink) { - var count: Int = 0 + var count = 0 val r: Runnable = object : Runnable { override fun run() { @@ -1088,7 +1143,7 @@ class SendConsistentNumbers(private val numberToSend: Long) : private val handler = Handler(Looper.getMainLooper()) override fun onListen(p0: Any?, sink: PigeonEventSink) { - var count: Int = 0 + var count = 0 val r: Runnable = object : Runnable { override fun run() { diff --git a/packages/pigeon/platform_tests/test_plugin/example/pubspec.yaml b/packages/pigeon/platform_tests/test_plugin/example/pubspec.yaml index cb263b0e9457..62962765633e 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/pubspec.yaml +++ b/packages/pigeon/platform_tests/test_plugin/example/pubspec.yaml @@ -8,7 +8,11 @@ environment: dependencies: flutter: sdk: flutter - jnigen: ^0.14.0 + jnigen: + git: + url: https://github.com/dart-lang/native/ + path: pkgs/jnigen + ref: 735250a19b1a429869bfacccba833ecc93db34b6 shared_test_plugin_code: path: ../../shared_test_plugin_code test_plugin: diff --git a/packages/pigeon/platform_tests/test_plugin/pubspec.yaml b/packages/pigeon/platform_tests/test_plugin/pubspec.yaml index c9afc10baffa..601219c7bca7 100644 --- a/packages/pigeon/platform_tests/test_plugin/pubspec.yaml +++ b/packages/pigeon/platform_tests/test_plugin/pubspec.yaml @@ -25,7 +25,11 @@ flutter: dependencies: flutter: sdk: flutter - jni: ^0.14.0 + jni: + git: + url: https://github.com/dart-lang/native/ + path: pkgs/jni + ref: 735250a19b1a429869bfacccba833ecc93db34b6 dev_dependencies: flutter_test: diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index 28a9f4d92c79..ca8d9ed0be32 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -14,7 +14,11 @@ dependencies: collection: ^1.15.0 dart_style: ^3.0.0 graphs: ^2.3.1 - jni: ^0.14.0 + jni: + git: + url: https://github.com/dart-lang/native/ + path: pkgs/jni + ref: 735250a19b1a429869bfacccba833ecc93db34b6 meta: ^1.9.0 path: ^1.8.0 pub_semver: ^2.1.4 @@ -22,7 +26,11 @@ dependencies: dev_dependencies: test: ^1.11.1 - jnigen: ^0.14.0 + jnigen: + git: + url: https://github.com/dart-lang/native/ + path: pkgs/jnigen + ref: 735250a19b1a429869bfacccba833ecc93db34b6 topics: - codegen From 1ed8a8b36dfa1c0a769a13a2efd5816e24cbd9cf Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 21 Apr 2025 18:55:09 -0700 Subject: [PATCH 4/4] objects and enums --- .../example/app/lib/src/messages.g.dart | 2 +- packages/pigeon/lib/src/ast.dart | 15 +- .../pigeon/lib/src/dart/dart_generator.dart | 109 +- .../lib/src/kotlin/jnigen_yaml_generator.dart | 3 + packages/pigeon/pigeons/jni_tests.dart | 28 +- .../lib/example_app.dart | 13 + .../lib/integration_tests.dart | 72 +- .../lib/src/generated/core_tests.gen.dart | 4 +- .../lib/src/generated/enum.gen.dart | 2 +- .../generated/event_channel_tests.gen.dart | 4 +- .../lib/src/generated/jni_tests.gen.dart | 106 +- .../lib/src/generated/jni_tests.gen.jni.dart | 1402 ++++++++++++++++- .../lib/src/generated/message.gen.dart | 2 +- .../src/generated/non_null_fields.gen.dart | 2 +- .../lib/src/generated/null_fields.gen.dart | 2 +- .../src/generated/proxy_api_tests.gen.dart | 2 +- .../com/example/test_plugin/JniTests.gen.kt | 144 +- .../com/example/test_plugin/TestPlugin.kt | 57 +- .../test_plugin/example/jnigen.yaml | 1 + 19 files changed, 1833 insertions(+), 137 deletions(-) diff --git a/packages/pigeon/example/app/lib/src/messages.g.dart b/packages/pigeon/example/app/lib/src/messages.g.dart index fe3f5abab66d..bd0911c6933b 100644 --- a/packages/pigeon/example/app/lib/src/messages.g.dart +++ b/packages/pigeon/example/app/lib/src/messages.g.dart @@ -47,7 +47,7 @@ bool _deepEquals(Object? a, Object? b) { enum Code { one, - two, + two; } class MessageData { diff --git a/packages/pigeon/lib/src/ast.dart b/packages/pigeon/lib/src/ast.dart index 123149921358..d4fff9bae63d 100644 --- a/packages/pigeon/lib/src/ast.dart +++ b/packages/pigeon/lib/src/ast.dart @@ -545,35 +545,38 @@ class TypeDeclaration { /// Returns duplicated `TypeDeclaration` with attached `associatedEnum` value. TypeDeclaration copyWithEnum(Enum enumDefinition) { - enumDefinition.associatedType = this; - return TypeDeclaration( + final TypeDeclaration newType = TypeDeclaration( baseName: baseName, isNullable: isNullable, associatedEnum: enumDefinition, typeArguments: typeArguments, ); + enumDefinition.associatedType = newType; + return newType; } /// Returns duplicated `TypeDeclaration` with attached `associatedClass` value. TypeDeclaration copyWithClass(Class classDefinition) { - classDefinition.associatedType = this; - return TypeDeclaration( + final TypeDeclaration newType = TypeDeclaration( baseName: baseName, isNullable: isNullable, associatedClass: classDefinition, typeArguments: typeArguments, ); + classDefinition.associatedType = newType; + return newType; } /// Returns duplicated `TypeDeclaration` with attached `associatedProxyApi` value. TypeDeclaration copyWithProxyApi(AstProxyApi proxyApiDefinition) { - proxyApiDefinition.associatedType = this; - return TypeDeclaration( + final TypeDeclaration newType = TypeDeclaration( baseName: baseName, isNullable: isNullable, associatedProxyApi: proxyApiDefinition, typeArguments: typeArguments, ); + proxyApiDefinition.associatedType = newType; + return newType; } /// Returns duplicated `TypeDeclaration` with attached `associatedProxyApi` value. diff --git a/packages/pigeon/lib/src/dart/dart_generator.dart b/packages/pigeon/lib/src/dart/dart_generator.dart index 50a9d384b4f3..831e3a408477 100644 --- a/packages/pigeon/lib/src/dart/dart_generator.dart +++ b/packages/pigeon/lib/src/dart/dart_generator.dart @@ -130,27 +130,62 @@ class _JniType { ); } _JniType? jniType = _jniTypeForDartType[type.baseName]; - jniType = jniType ?? + if (type.isClass) { + jniType = jniType ?? + _JniType( + typeName: type.baseName, + jniName: 'bridge.${type.baseName}', + getToDartCall: ( + TypeDeclaration type, { + String? varName, + bool forceConversion = false, + }) => + '${type.baseName}.fromJni($varName)${_getForceNonNullSymbol(!type.isNullable)}', + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + _wrapInNullCheckIfNullable( + field.type, field.name, '${field.name}.toJni()'), + isBuiltIn: false, + nonNullableNeedsUnwrapping: true, + ); + } else if (type.isEnum) { + jniType = jniType ?? + _JniType( + typeName: type.baseName, + jniName: 'bridge.${type.baseName}', + getToDartCall: ( + TypeDeclaration type, { + String? varName, + bool forceConversion = false, + }) => + '${type.baseName}.fromJni($varName)${_getForceNonNullSymbol(!type.isNullable)}', + getToJniCall: ( + NamedType field, + _JniType jniType, { + bool forceNonNull = false, + }) => + _wrapInNullCheckIfNullable(field.type, field.name, + '${field.name}${_getForceNonNullSymbol(type.isNullable && forceNonNull)}.toJni()'), + isBuiltIn: false, + nonNullableNeedsUnwrapping: true, + ); + } + return jniType ?? _JniType( - typeName: type.baseName, - jniName: 'bridge.${type.baseName}', - getToDartCall: ( - TypeDeclaration type, { - String? varName, - bool forceConversion = false, - }) => - '${type.baseName}.fromJni($varName)${_getForceNonNullSymbol(!type.isNullable)}', - getToJniCall: ( - NamedType field, - _JniType jniType, { - bool forceNonNull = false, - }) => - _wrapInNullCheckIfNullable( - field.type, field.name, '${field.name}.toJni()'), - isBuiltIn: false, - nonNullableNeedsUnwrapping: true, - ); - return jniType; + typeName: '', + jniName: '', + isBuiltIn: false, + getToDartCall: + (_, {bool forceConversion = true, String varName = ''}) => '', + getToJniCall: ( + _, + __, { + bool forceNonNull = true, + }) => + ''); } final String typeName; @@ -324,13 +359,13 @@ final Map _jniTypeForDartType = { String varName = '', bool forceConversion = false, }) => - '_PigeonJniCodec.readValue($varName)', + '_PigeonJniCodec.readValue($varName)${_getForceNonNullSymbol(!type.isNullable)}', getToJniCall: ( NamedType field, _JniType jniType, { bool forceNonNull = false, }) => - '_PigeonJniCodec.writeValue(${field.name})', + '_PigeonJniCodec.writeValue(${field.name})${_getForceNonNullSymbol(!field.type.isNullable)}', isBuiltIn: true, nonNullableNeedsUnwrapping: true, ), @@ -433,12 +468,30 @@ class DartGenerator extends StructuredGenerator { indent.newln(); addDocumentationComments( indent, anEnum.documentationComments, _docCommentSpec); - indent.write('enum ${anEnum.name} '); - indent.addScoped('{', '}', () { + indent.addScoped('enum ${anEnum.name} {', '}', () { for (final EnumMember member in anEnum.members) { + final String separatorSymbol = + member == anEnum.members.last ? ';' : ','; addDocumentationComments( indent, member.documentationComments, _docCommentSpec); - indent.writeln('${member.name},'); + indent.writeln('${member.name}$separatorSymbol'); + } + + if (generatorOptions.useJni) { + final _JniType jniType = + _JniType.fromTypeDeclaration(anEnum.associatedType); + indent.newln(); + indent.writeScoped('${jniType.jniName} toJni() {', '}', () { + indent.writeln('return ${jniType.jniName}.Companion.ofRaw(index)!;'); + }); + + indent.newln(); + indent.writeScoped( + 'static ${anEnum.name}? fromJni(${jniType.jniName}? jniEnum) {', + '}', () { + indent.writeln( + 'return jniEnum == null ? null : ${anEnum.name}.values[jniEnum.getRaw()];'); + }); } }); } @@ -574,7 +627,7 @@ class DartGenerator extends StructuredGenerator { in getFieldsInSerializationOrder(classDefinition)) { final _JniType jniType = _JniType.fromTypeDeclaration(field.type); indent.writeln( - '${field.name}: jniClass.${jniType.getJniGetterMethodName(field.name)}${jniType.getToDartCall(field.type)},'); + '${field.name}: ${jniType.getToDartCall(field.type, varName: 'jniClass.${jniType.getJniGetterMethodName(field.name)}')},'); } }); }); @@ -1486,7 +1539,7 @@ final BinaryMessenger? ${varNamePrefix}binaryMessenger; indent.newln(); indent.format(''' class _PigeonJniCodec { - Object? readValue(JObject? value) { + static Object? readValue(JObject? value) { if (value == null) { return null; } else if (value.isA(JLong.type)) { @@ -1527,7 +1580,7 @@ class _PigeonJniCodec { } } - JObject? writeValue(Object? value) { + static JObject? writeValue(Object? value) { if (value == null) { return null; } else if (value is bool) { diff --git a/packages/pigeon/lib/src/kotlin/jnigen_yaml_generator.dart b/packages/pigeon/lib/src/kotlin/jnigen_yaml_generator.dart index acd6f8c422c8..242468ba5932 100644 --- a/packages/pigeon/lib/src/kotlin/jnigen_yaml_generator.dart +++ b/packages/pigeon/lib/src/kotlin/jnigen_yaml_generator.dart @@ -73,6 +73,9 @@ class JnigenYamlGenerator extends Generator { for (final Class dataClass in root.classes) { indent.writeln("- '${dataClass.name}'"); } + for (final Enum enumType in root.enums) { + indent.writeln("- '${enumType.name}'"); + } }); } } diff --git a/packages/pigeon/pigeons/jni_tests.dart b/packages/pigeon/pigeons/jni_tests.dart index df8b10aaef4e..291eb950ba8e 100644 --- a/packages/pigeon/pigeons/jni_tests.dart +++ b/packages/pigeon/pigeons/jni_tests.dart @@ -8,19 +8,27 @@ import 'package:pigeon/pigeon.dart'; dartOptions: DartOptions(useJni: true), kotlinOptions: KotlinOptions(useJni: true), )) +enum SomeEnum { + value1, + value2, + value3, +} + class SomeTypes { const SomeTypes( this.aString, this.anInt, this.aDouble, this.aBool, - // this.anObject, + this.anObject, + this.anEnum, ); final String aString; final int anInt; final double aDouble; final bool aBool; - // final Object anObject; + final Object anObject; + final SomeEnum anEnum; } class SomeNullableTypes { @@ -28,7 +36,8 @@ class SomeNullableTypes { int? anInt; double? aDouble; bool? aBool; - // Object? anObject; + Object? anObject; + SomeEnum? anEnum; } @HostApi() @@ -38,8 +47,9 @@ abstract class JniMessageApi { int echoInt(int request); double echoDouble(double request); bool echoBool(bool request); - // Object echoObj(Object request); + Object echoObj(Object request); SomeTypes sendSomeTypes(SomeTypes someTypes); + SomeEnum sendSomeEnum(SomeEnum anEnum); } @HostApi() @@ -48,7 +58,9 @@ abstract class JniMessageApiNullable { int? echoInt(int? request); double? echoDouble(double? request); bool? echoBool(bool? request); + Object? echoObj(Object? request); SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes); + SomeEnum? sendSomeEnum(SomeEnum? anEnum); } @HostApi() @@ -64,7 +76,11 @@ abstract class JniMessageApiAsync { @async bool echoBool(bool request); @async + Object echoObj(Object request); + @async SomeTypes sendSomeTypes(SomeTypes someTypes); + @async + SomeEnum sendSomeEnum(SomeEnum anEnum); } @HostApi() @@ -78,5 +94,9 @@ abstract class JniMessageApiNullableAsync { @async bool? echoBool(bool? request); @async + Object? echoObj(Object? request); + @async SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes); + @async + SomeEnum? sendSomeEnum(SomeEnum? anEnum); } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/example_app.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/example_app.dart index 31075ae532f6..5af09eec9a7d 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/example_app.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/example_app.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'generated.dart'; +import 'src/generated/jni_tests.gen.dart'; void main() { runApp(const ExampleApp()); @@ -39,6 +40,18 @@ class _ExampleAppState extends State { // Make a single trivial call just to validate that everything is wired // up. await api.noop(); + final JniMessageApi? jniMessage = JniMessageApi.getInstance(); + print('before sendSomeTypes'); + final SomeTypes toSend = SomeTypes( + aString: 'hi', + anInt: 5, + aDouble: 5.0, + aBool: false, + anObject: 'obj', + anEnum: SomeEnum.value2, + ); + final SomeTypes sync = jniMessage!.sendSomeTypes(toSend); + print(sync); } catch (e) { setState(() { status = 'Failed: $e'; diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart index 52f0d652846f..37282590cf88 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart @@ -50,16 +50,24 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { final JniMessageApi? jniMessage = JniMessageApi.getInstance(); expect(jniMessage, isNotNull); expect(jniMessage!.echoString('hello'), 'hello'); - final SomeTypes sync = jniMessage.sendSomeTypes(SomeTypes( + final SomeTypes toSend = SomeTypes( aString: 'hi', anInt: 5, aDouble: 5.0, aBool: false, - )); - expect(sync.aString, 'hi'); - expect(sync.anInt, 5); - expect(sync.aDouble, 5.0); - expect(sync.aBool, false); + anObject: 'obj', + anEnum: SomeEnum.value2, + ); + final SomeTypes sync = jniMessage.sendSomeTypes(toSend); + expect(sync, toSend); + expect(jniMessage.echoBool(true), true); + expect(jniMessage.echoBool(false), false); + expect(jniMessage.echoDouble(2.0), 2.0); + expect(jniMessage.echoInt(2), 2); + expect(jniMessage.echoString('hello'), 'hello'); + expect(jniMessage.echoObj('hello'), 'hello'); + expect(jniMessage.echoObj(sync), sync); + expect(jniMessage.sendSomeEnum(SomeEnum.value2), SomeEnum.value2); //nullable final JniMessageApiNullable? jniMessageNullable = JniMessageApiNullable.getInstance(); @@ -72,23 +80,38 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { expect(syncNullable.anInt, null); expect(syncNullable.aDouble, null); expect(syncNullable.aBool, null); + expect(syncNullable.anObject, null); final SomeNullableTypes? syncNull = jniMessageNullable.sendSomeNullableTypes(null); expect(syncNull, null); + expect(jniMessageNullable.echoBool(true), true); + expect(jniMessageNullable.echoBool(false), false); + expect(jniMessageNullable.echoDouble(2.0), 2.0); + expect(jniMessageNullable.echoInt(2), 2); + expect(jniMessageNullable.echoString('hello'), 'hello'); + expect(jniMessageNullable.echoObj('hello'), 'hello'); + expect(jniMessageNullable.echoObj(syncNullable), syncNullable); + expect(jniMessageNullable.sendSomeEnum(SomeEnum.value3), SomeEnum.value3); + expect(jniMessageNullable.echoBool(null), null); + expect(jniMessageNullable.echoDouble(null), null); + expect(jniMessageNullable.echoInt(null), null); + expect(jniMessageNullable.echoString(null), null); + expect(jniMessageNullable.echoObj(null), null); //async final JniMessageApiAsync? jniMessageAsync = JniMessageApiAsync.getInstance(); - final SomeTypes nonSync = await jniMessageAsync!.sendSomeTypes(SomeTypes( - aString: 'hi', - anInt: 5, - aDouble: 5.0, - aBool: false, - )); - expect(nonSync.aString, 'hi'); - expect(nonSync.anInt, 5); - expect(nonSync.aDouble, 5.0); - expect(nonSync.aBool, false); + final SomeTypes nonSync = await jniMessageAsync!.sendSomeTypes(toSend); + expect(nonSync, toSend); + expect(await jniMessageAsync.echoBool(true), true); + expect(await jniMessageAsync.echoBool(false), false); + expect(await jniMessageAsync.echoDouble(2.0), 2.0); + expect(await jniMessageAsync.echoInt(2), 2); + expect(await jniMessageAsync.echoString('hello'), 'hello'); + expect(await jniMessageAsync.echoObj('hello'), 'hello'); + expect(await jniMessageAsync.echoObj(sync), sync); + expect( + await jniMessageAsync.sendSomeEnum(SomeEnum.value3), SomeEnum.value3); //nullable async final JniMessageApiNullableAsync? jniMessageNullableAsync = JniMessageApiNullableAsync.getInstance(); @@ -101,9 +124,24 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { expect(syncNullableAsync.anInt, null); expect(syncNullableAsync.aDouble, null); expect(syncNullableAsync.aBool, null); + expect(syncNullableAsync.anObject, null); final SomeNullableTypes? syncNullAsync = await jniMessageNullableAsync.sendSomeNullableTypes(null); expect(syncNull, null); + expect(await jniMessageNullableAsync.echoBool(true), true); + expect(await jniMessageNullableAsync.echoBool(false), false); + expect(await jniMessageNullableAsync.echoDouble(2.0), 2.0); + expect(await jniMessageNullableAsync.echoInt(2), 2); + expect(await jniMessageNullableAsync.echoString('hello'), 'hello'); + expect(await jniMessageNullableAsync.echoObj('hello'), 'hello'); + expect(await jniMessageNullableAsync.echoObj(syncNullable), syncNullable); + expect(await jniMessageNullableAsync.sendSomeEnum(SomeEnum.value3), + SomeEnum.value3); + expect(await jniMessageNullableAsync.echoBool(null), null); + expect(await jniMessageNullableAsync.echoDouble(null), null); + expect(await jniMessageNullableAsync.echoInt(null), null); + expect(await jniMessageNullableAsync.echoString(null), null); + expect(await jniMessageNullableAsync.echoObj(null), null); //named final JniMessageApi? jniMessageNamed = JniMessageApi.getInstance(channelName: 'name'); @@ -113,7 +151,7 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { expect(jniMessageNamed!.echoString('hello'), 'hello1'); expect(await jniMessageAsync.echoInt(5), 5); expect(await jniMessageAsyncNamed!.echoInt(5), 6); - }); + }, skip: targetGenerator != TargetGenerator.kotlin); group('Host sync API tests', () { testWidgets('basic void->void call works', (WidgetTester _) async { diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart index 46be9723deb1..5ffccdbb8708 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart @@ -51,11 +51,11 @@ enum AnEnum { two, three, fortyTwo, - fourHundredTwentyTwo, + fourHundredTwentyTwo; } enum AnotherEnum { - justInCase, + justInCase; } class UnusedClass { diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/enum.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/enum.gen.dart index 290a812f7570..9d1d11656dca 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/enum.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/enum.gen.dart @@ -42,7 +42,7 @@ enum EnumState { Error, /// This comment is to test enum member (SnakeCase) documentation comments. - SnakeCase, + SnakeCase; } /// This comment is to test class documentation comments. diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/event_channel_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/event_channel_tests.gen.dart index 51e63738aae9..99aaa0115919 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/event_channel_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/event_channel_tests.gen.dart @@ -33,11 +33,11 @@ enum EventEnum { two, three, fortyTwo, - fourHundredTwentyTwo, + fourHundredTwentyTwo; } enum AnotherEventEnum { - justInCase, + justInCase; } /// A class containing all supported nullable types. diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart index a797a841e7b1..537f0fddc9bd 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.dart @@ -15,7 +15,7 @@ import 'package:jni/jni.dart'; import './jni_tests.gen.jni.dart' as bridge; class _PigeonJniCodec { - Object? readValue(JObject? value) { + static Object? readValue(JObject? value) { if (value == null) { return null; } else if (value.isA(JLong.type)) { @@ -52,7 +52,7 @@ class _PigeonJniCodec { } } - JObject? writeValue(Object? value) { + static JObject? writeValue(Object? value) { if (value == null) { return null; } else if (value is bool) { @@ -98,12 +98,28 @@ class _PigeonJniCodec { } } +enum SomeEnum { + value1, + value2, + value3; + + bridge.SomeEnum toJni() { + return bridge.SomeEnum.Companion.ofRaw(index)!; + } + + static SomeEnum? fromJni(bridge.SomeEnum? jniEnum) { + return jniEnum == null ? null : SomeEnum.values[jniEnum.getRaw()]; + } +} + class SomeTypes { SomeTypes({ required this.aString, required this.anInt, required this.aDouble, required this.aBool, + required this.anObject, + required this.anEnum, }); String aString; @@ -114,12 +130,18 @@ class SomeTypes { bool aBool; + Object anObject; + + SomeEnum anEnum; + List _toList() { return [ aString, anInt, aDouble, aBool, + anObject, + anEnum, ]; } @@ -129,6 +151,8 @@ class SomeTypes { anInt, aDouble, aBool, + _PigeonJniCodec.writeValue(anObject)!, + anEnum.toJni(), ); } @@ -144,6 +168,8 @@ class SomeTypes { anInt: jniClass.getAnInt(), aDouble: jniClass.getADouble(), aBool: jniClass.getABool(), + anObject: _PigeonJniCodec.readValue(jniClass.getAnObject())!, + anEnum: SomeEnum.fromJni(jniClass.getAnEnum())!, ); } @@ -154,6 +180,8 @@ class SomeTypes { anInt: result[1]! as int, aDouble: result[2]! as double, aBool: result[3]! as bool, + anObject: result[4]!, + anEnum: result[5]! as SomeEnum, ); } @@ -169,7 +197,9 @@ class SomeTypes { return aString == other.aString && anInt == other.anInt && aDouble == other.aDouble && - aBool == other.aBool; + aBool == other.aBool && + anObject == other.anObject && + anEnum == other.anEnum; } @override @@ -183,6 +213,8 @@ class SomeNullableTypes { this.anInt, this.aDouble, this.aBool, + this.anObject, + this.anEnum, }); String? aString; @@ -193,12 +225,18 @@ class SomeNullableTypes { bool? aBool; + Object? anObject; + + SomeEnum? anEnum; + List _toList() { return [ aString, anInt, aDouble, aBool, + anObject, + anEnum, ]; } @@ -208,6 +246,8 @@ class SomeNullableTypes { anInt == null ? null : JLong(anInt!), aDouble == null ? null : JDouble(aDouble!), aBool == null ? null : JBoolean(aBool!), + _PigeonJniCodec.writeValue(anObject), + anEnum == null ? null : anEnum!.toJni(), ); } @@ -223,6 +263,8 @@ class SomeNullableTypes { anInt: jniClass.getAnInt()?.intValue(releaseOriginal: true), aDouble: jniClass.getADouble()?.doubleValue(releaseOriginal: true), aBool: jniClass.getABool()?.booleanValue(releaseOriginal: true), + anObject: _PigeonJniCodec.readValue(jniClass.getAnObject()), + anEnum: SomeEnum.fromJni(jniClass.getAnEnum()), ); } @@ -233,6 +275,8 @@ class SomeNullableTypes { anInt: result[1] as int?, aDouble: result[2] as double?, aBool: result[3] as bool?, + anObject: result[4], + anEnum: result[5] as SomeEnum?, ); } @@ -248,7 +292,9 @@ class SomeNullableTypes { return aString == other.aString && anInt == other.anInt && aDouble == other.aDouble && - aBool == other.aBool; + aBool == other.aBool && + anObject == other.anObject && + anEnum == other.anEnum; } @override @@ -303,11 +349,23 @@ class JniMessageApi { return _api.echoBool(request); } + Object echoObj(Object request) { + final JObject res = _api.echoObj(_PigeonJniCodec.writeValue(request)!); + final Object dartTypeRes = _PigeonJniCodec.readValue(res)!; + return dartTypeRes; + } + SomeTypes sendSomeTypes(SomeTypes someTypes) { final bridge.SomeTypes res = _api.sendSomeTypes(someTypes.toJni()); final SomeTypes dartTypeRes = SomeTypes.fromJni(res)!; return dartTypeRes; } + + SomeEnum sendSomeEnum(SomeEnum anEnum) { + final bridge.SomeEnum res = _api.sendSomeEnum(anEnum.toJni()); + final SomeEnum dartTypeRes = SomeEnum.fromJni(res)!; + return dartTypeRes; + } } class JniMessageApiNullable { @@ -363,12 +421,25 @@ class JniMessageApiNullable { return dartTypeRes; } + Object? echoObj(Object? request) { + final JObject? res = _api.echoObj(_PigeonJniCodec.writeValue(request)); + final Object? dartTypeRes = _PigeonJniCodec.readValue(res); + return dartTypeRes; + } + SomeNullableTypes? sendSomeNullableTypes(SomeNullableTypes? someTypes) { final bridge.SomeNullableTypes? res = _api .sendSomeNullableTypes(someTypes == null ? null : someTypes.toJni()); final SomeNullableTypes? dartTypeRes = SomeNullableTypes.fromJni(res); return dartTypeRes; } + + SomeEnum? sendSomeEnum(SomeEnum? anEnum) { + final bridge.SomeEnum? res = + _api.sendSomeEnum(anEnum == null ? null : anEnum.toJni()); + final SomeEnum? dartTypeRes = SomeEnum.fromJni(res); + return dartTypeRes; + } } class JniMessageApiAsync { @@ -423,11 +494,24 @@ class JniMessageApiAsync { return dartTypeRes; } + Future echoObj(Object request) async { + final JObject res = + await _api.echoObj(_PigeonJniCodec.writeValue(request)!); + final Object dartTypeRes = _PigeonJniCodec.readValue(res)!; + return dartTypeRes; + } + Future sendSomeTypes(SomeTypes someTypes) async { final bridge.SomeTypes res = await _api.sendSomeTypes(someTypes.toJni()); final SomeTypes dartTypeRes = SomeTypes.fromJni(res)!; return dartTypeRes; } + + Future sendSomeEnum(SomeEnum anEnum) async { + final bridge.SomeEnum res = await _api.sendSomeEnum(anEnum.toJni()); + final SomeEnum dartTypeRes = SomeEnum.fromJni(res)!; + return dartTypeRes; + } } class JniMessageApiNullableAsync { @@ -484,6 +568,13 @@ class JniMessageApiNullableAsync { return dartTypeRes; } + Future echoObj(Object? request) async { + final JObject? res = + await _api.echoObj(_PigeonJniCodec.writeValue(request)); + final Object? dartTypeRes = _PigeonJniCodec.readValue(res); + return dartTypeRes; + } + Future sendSomeNullableTypes( SomeNullableTypes? someTypes) async { final bridge.SomeNullableTypes? res = await _api @@ -491,4 +582,11 @@ class JniMessageApiNullableAsync { final SomeNullableTypes? dartTypeRes = SomeNullableTypes.fromJni(res); return dartTypeRes; } + + Future sendSomeEnum(SomeEnum? anEnum) async { + final bridge.SomeEnum? res = + await _api.sendSomeEnum(anEnum == null ? null : anEnum.toJni()); + final SomeEnum? dartTypeRes = SomeEnum.fromJni(res); + return dartTypeRes; + } } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart index 1fdc288ec07b..3050f9a212d4 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/jni_tests.gen.jni.dart @@ -175,6 +175,33 @@ class JniMessageApi extends jni$_.JObject { .boolean; } + static final _id_echoObj = _class.instanceMethodId( + r'echoObj', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _echoObj = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoObj(java.lang.Object object)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject echoObj( + jni$_.JObject object, + ) { + final _$object = object.reference; + return _echoObj(reference.pointer, _id_echoObj as jni$_.JMethodIDPtr, + _$object.pointer) + .object(const jni$_.JObjectType()); + } + static final _id_sendSomeTypes = _class.instanceMethodId( r'sendSomeTypes', r'(LSomeTypes;)LSomeTypes;', @@ -201,6 +228,33 @@ class JniMessageApi extends jni$_.JObject { _id_sendSomeTypes as jni$_.JMethodIDPtr, _$someTypes.pointer) .object(const $SomeTypes$Type()); } + + static final _id_sendSomeEnum = _class.instanceMethodId( + r'sendSomeEnum', + r'(LSomeEnum;)LSomeEnum;', + ); + + static final _sendSomeEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract SomeEnum sendSomeEnum(SomeEnum someEnum)` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum sendSomeEnum( + SomeEnum someEnum, + ) { + final _$someEnum = someEnum.reference; + return _sendSomeEnum(reference.pointer, + _id_sendSomeEnum as jni$_.JMethodIDPtr, _$someEnum.pointer) + .object(const $SomeEnum$Type()); + } } final class $JniMessageApi$NullableType extends jni$_.JObjType { @@ -553,6 +607,33 @@ class JniMessageApiRegistrar extends JniMessageApi { .boolean; } + static final _id_echoObj = _class.instanceMethodId( + r'echoObj', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _echoObj = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoObj(java.lang.Object object)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject echoObj( + jni$_.JObject object, + ) { + final _$object = object.reference; + return _echoObj(reference.pointer, _id_echoObj as jni$_.JMethodIDPtr, + _$object.pointer) + .object(const jni$_.JObjectType()); + } + static final _id_sendSomeTypes = _class.instanceMethodId( r'sendSomeTypes', r'(LSomeTypes;)LSomeTypes;', @@ -579,6 +660,33 @@ class JniMessageApiRegistrar extends JniMessageApi { _id_sendSomeTypes as jni$_.JMethodIDPtr, _$someTypes.pointer) .object(const $SomeTypes$Type()); } + + static final _id_sendSomeEnum = _class.instanceMethodId( + r'sendSomeEnum', + r'(LSomeEnum;)LSomeEnum;', + ); + + static final _sendSomeEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public SomeEnum sendSomeEnum(SomeEnum someEnum)` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum sendSomeEnum( + SomeEnum someEnum, + ) { + final _$someEnum = someEnum.reference; + return _sendSomeEnum(reference.pointer, + _id_sendSomeEnum as jni$_.JMethodIDPtr, _$someEnum.pointer) + .object(const $SomeEnum$Type()); + } } final class $JniMessageApiRegistrar$NullableType @@ -783,6 +891,33 @@ class JniMessageApiNullable extends jni$_.JObject { .object(const jni$_.JBooleanNullableType()); } + static final _id_echoObj = _class.instanceMethodId( + r'echoObj', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _echoObj = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoObj(java.lang.Object object)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? echoObj( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _echoObj(reference.pointer, _id_echoObj as jni$_.JMethodIDPtr, + _$object.pointer) + .object(const jni$_.JObjectNullableType()); + } + static final _id_sendSomeNullableTypes = _class.instanceMethodId( r'sendSomeNullableTypes', r'(LSomeNullableTypes;)LSomeNullableTypes;', @@ -812,6 +947,33 @@ class JniMessageApiNullable extends jni$_.JObject { _$someNullableTypes.pointer) .object(const $SomeNullableTypes$NullableType()); } + + static final _id_sendSomeEnum = _class.instanceMethodId( + r'sendSomeEnum', + r'(LSomeEnum;)LSomeEnum;', + ); + + static final _sendSomeEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract SomeEnum sendSomeEnum(SomeEnum someEnum)` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum? sendSomeEnum( + SomeEnum? someEnum, + ) { + final _$someEnum = someEnum?.reference ?? jni$_.jNullReference; + return _sendSomeEnum(reference.pointer, + _id_sendSomeEnum as jni$_.JMethodIDPtr, _$someEnum.pointer) + .object(const $SomeEnum$NullableType()); + } } final class $JniMessageApiNullable$NullableType @@ -1156,6 +1318,33 @@ class JniMessageApiNullableRegistrar extends JniMessageApiNullable { .object(const jni$_.JBooleanNullableType()); } + static final _id_echoObj = _class.instanceMethodId( + r'echoObj', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _echoObj = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoObj(java.lang.Object object)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? echoObj( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _echoObj(reference.pointer, _id_echoObj as jni$_.JMethodIDPtr, + _$object.pointer) + .object(const jni$_.JObjectNullableType()); + } + static final _id_sendSomeNullableTypes = _class.instanceMethodId( r'sendSomeNullableTypes', r'(LSomeNullableTypes;)LSomeNullableTypes;', @@ -1185,6 +1374,33 @@ class JniMessageApiNullableRegistrar extends JniMessageApiNullable { _$someNullableTypes.pointer) .object(const $SomeNullableTypes$NullableType()); } + + static final _id_sendSomeEnum = _class.instanceMethodId( + r'sendSomeEnum', + r'(LSomeEnum;)LSomeEnum;', + ); + + static final _sendSomeEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public SomeEnum sendSomeEnum(SomeEnum someEnum)` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum? sendSomeEnum( + SomeEnum? someEnum, + ) { + final _$someEnum = someEnum?.reference ?? jni$_.jNullReference; + return _sendSomeEnum(reference.pointer, + _id_sendSomeEnum as jni$_.JMethodIDPtr, _$someEnum.pointer) + .object(const $SomeEnum$NullableType()); + } } final class $JniMessageApiNullableRegistrar$NullableType @@ -1539,6 +1755,61 @@ class JniMessageApiAsync extends jni$_.JObject { ); } + static final _id_echoObj = _class.instanceMethodId( + r'echoObj', + r'(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoObj = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoObj(java.lang.Object object, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoObj( + jni$_.JObject object, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$object = object.reference; + final $r = _echoObj(reference.pointer, _id_echoObj as jni$_.JMethodIDPtr, + _$object.pointer, _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as( + const jni$_.JObjectType(), + releaseOriginal: true, + ); + } + static final _id_sendSomeTypes = _class.instanceMethodId( r'sendSomeTypes', r'(LSomeTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', @@ -1596,6 +1867,64 @@ class JniMessageApiAsync extends jni$_.JObject { releaseOriginal: true, ); } + + static final _id_sendSomeEnum = _class.instanceMethodId( + r'sendSomeEnum', + r'(LSomeEnum;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _sendSomeEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object sendSomeEnum(SomeEnum someEnum, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeEnum( + SomeEnum someEnum, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someEnum = someEnum.reference; + final $r = _sendSomeEnum( + reference.pointer, + _id_sendSomeEnum as jni$_.JMethodIDPtr, + _$someEnum.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as( + const $SomeEnum$Type(), + releaseOriginal: true, + ); + } } final class $JniMessageApiAsync$NullableType @@ -2088,12 +2417,12 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { ); } - static final _id_sendSomeTypes = _class.instanceMethodId( - r'sendSomeTypes', - r'(LSomeTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + static final _id_echoObj = _class.instanceMethodId( + r'echoObj', + r'(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); - static final _sendSomeTypes = jni$_.ProtectedJniExtensions.lookup< + static final _echoObj = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, @@ -2110,19 +2439,16 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public java.lang.Object sendSomeTypes(SomeTypes someTypes, kotlin.coroutines.Continuation continuation)` + /// from: `public java.lang.Object echoObj(java.lang.Object object, kotlin.coroutines.Continuation continuation)` /// The returned object must be released after use, by calling the [release] method. - core$_.Future sendSomeTypes( - SomeTypes someTypes, + core$_.Future echoObj( + jni$_.JObject object, ) async { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final _$someTypes = someTypes.reference; - final $r = _sendSomeTypes( - reference.pointer, - _id_sendSomeTypes as jni$_.JMethodIDPtr, - _$someTypes.pointer, - _$continuation.pointer) + final _$object = object.reference; + final $r = _echoObj(reference.pointer, _id_echoObj as jni$_.JMethodIDPtr, + _$object.pointer, _$continuation.pointer) .object(const jni$_.JObjectType()); _$continuation.release(); final jni$_.JObject $o; @@ -2140,17 +2466,133 @@ class JniMessageApiAsyncRegistrar extends JniMessageApiAsync { } else { $o = $r; } - return $o.as( - const $SomeTypes$Type(), + return $o.as( + const jni$_.JObjectType(), releaseOriginal: true, ); } -} -final class $JniMessageApiAsyncRegistrar$NullableType - extends jni$_.JObjType { - @jni$_.internal - const $JniMessageApiAsyncRegistrar$NullableType(); + static final _id_sendSomeTypes = _class.instanceMethodId( + r'sendSomeTypes', + r'(LSomeTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _sendSomeTypes = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object sendSomeTypes(SomeTypes someTypes, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeTypes( + SomeTypes someTypes, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someTypes = someTypes.reference; + final $r = _sendSomeTypes( + reference.pointer, + _id_sendSomeTypes as jni$_.JMethodIDPtr, + _$someTypes.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as( + const $SomeTypes$Type(), + releaseOriginal: true, + ); + } + + static final _id_sendSomeEnum = _class.instanceMethodId( + r'sendSomeEnum', + r'(LSomeEnum;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _sendSomeEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object sendSomeEnum(SomeEnum someEnum, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeEnum( + SomeEnum someEnum, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someEnum = someEnum.reference; + final $r = _sendSomeEnum( + reference.pointer, + _id_sendSomeEnum as jni$_.JMethodIDPtr, + _$someEnum.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectType()); + _$continuation.release(); + final jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o.as( + const $SomeEnum$Type(), + releaseOriginal: true, + ); + } +} + +final class $JniMessageApiAsyncRegistrar$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiAsyncRegistrar$NullableType(); @jni$_.internal @core$_.override @@ -2475,6 +2917,63 @@ class JniMessageApiNullableAsync extends jni$_.JObject { ); } + static final _id_echoObj = _class.instanceMethodId( + r'echoObj', + r'(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoObj = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object echoObj(java.lang.Object object, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoObj( + jni$_.JObject? object, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$object = object?.reference ?? jni$_.jNullReference; + final $r = _echoObj(reference.pointer, _id_echoObj as jni$_.JMethodIDPtr, + _$object.pointer, _$continuation.pointer) + .object(const jni$_.JObjectNullableType()); + _$continuation.release(); + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o?.as( + const jni$_.JObjectNullableType(), + releaseOriginal: true, + ); + } + static final _id_sendSomeNullableTypes = _class.instanceMethodId( r'sendSomeNullableTypes', r'(LSomeNullableTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', @@ -2535,6 +3034,66 @@ class JniMessageApiNullableAsync extends jni$_.JObject { releaseOriginal: true, ); } + + static final _id_sendSomeEnum = _class.instanceMethodId( + r'sendSomeEnum', + r'(LSomeEnum;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _sendSomeEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract java.lang.Object sendSomeEnum(SomeEnum someEnum, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeEnum( + SomeEnum? someEnum, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someEnum = someEnum?.reference ?? jni$_.jNullReference; + final $r = _sendSomeEnum( + reference.pointer, + _id_sendSomeEnum as jni$_.JMethodIDPtr, + _$someEnum.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectNullableType()); + _$continuation.release(); + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o?.as( + const $SomeEnum$NullableType(), + releaseOriginal: true, + ); + } } final class $JniMessageApiNullableAsync$NullableType @@ -3007,6 +3566,63 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { ); } + static final _id_echoObj = _class.instanceMethodId( + r'echoObj', + r'(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _echoObj = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object echoObj(java.lang.Object object, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future echoObj( + jni$_.JObject? object, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$object = object?.reference ?? jni$_.jNullReference; + final $r = _echoObj(reference.pointer, _id_echoObj as jni$_.JMethodIDPtr, + _$object.pointer, _$continuation.pointer) + .object(const jni$_.JObjectNullableType()); + _$continuation.release(); + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o?.as( + const jni$_.JObjectNullableType(), + releaseOriginal: true, + ); + } + static final _id_sendSomeNullableTypes = _class.instanceMethodId( r'sendSomeNullableTypes', r'(LSomeNullableTypes;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', @@ -3067,18 +3683,78 @@ class JniMessageApiNullableAsyncRegistrar extends JniMessageApiNullableAsync { releaseOriginal: true, ); } -} - -final class $JniMessageApiNullableAsyncRegistrar$NullableType - extends jni$_.JObjType { - @jni$_.internal - const $JniMessageApiNullableAsyncRegistrar$NullableType(); - @jni$_.internal - @core$_.override - String get signature => r'LJniMessageApiNullableAsyncRegistrar;'; + static final _id_sendSomeEnum = _class.instanceMethodId( + r'sendSomeEnum', + r'(LSomeEnum;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); - @jni$_.internal + static final _sendSomeEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public java.lang.Object sendSomeEnum(SomeEnum someEnum, kotlin.coroutines.Continuation continuation)` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future sendSomeEnum( + SomeEnum? someEnum, + ) async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + final _$someEnum = someEnum?.reference ?? jni$_.jNullReference; + final $r = _sendSomeEnum( + reference.pointer, + _id_sendSomeEnum as jni$_.JMethodIDPtr, + _$someEnum.pointer, + _$continuation.pointer) + .object(const jni$_.JObjectNullableType()); + _$continuation.release(); + final jni$_.JObject? $o; + if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = $a == 0 + ? null + : jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o != null && $o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.JObjectType()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return $o?.as( + const $SomeEnum$NullableType(), + releaseOriginal: true, + ); + } +} + +final class $JniMessageApiNullableAsyncRegistrar$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $JniMessageApiNullableAsyncRegistrar$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LJniMessageApiNullableAsyncRegistrar;'; + + @jni$_.internal @core$_.override JniMessageApiNullableAsyncRegistrar? fromReference( jni$_.JReference reference) => @@ -3327,7 +4003,7 @@ class SomeTypes extends jni$_.JObject { _id_Companion.get(_class, const $SomeTypes$Companion$Type()); static final _id_new$ = _class.constructorId( - r'(Ljava/lang/String;JDZ)V', + r'(Ljava/lang/String;JDZLjava/lang/Object;LSomeEnum;)V', ); static final _new$ = jni$_.ProtectedJniExtensions.lookup< @@ -3340,7 +4016,9 @@ class SomeTypes extends jni$_.JObject { jni$_.Pointer, jni$_.Int64, jni$_.Double, - jni$_.Int32 + jni$_.Int32, + jni$_.Pointer, + jni$_.Pointer )>)>>('globalEnv_NewObject') .asFunction< jni$_.JniResult Function( @@ -3349,19 +4027,32 @@ class SomeTypes extends jni$_.JObject { jni$_.Pointer, int, double, - int)>(); + int, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public void (java.lang.String string, long j, double d, boolean z)` + /// from: `public void (java.lang.String string, long j, double d, boolean z, java.lang.Object object, SomeEnum someEnum)` /// The returned object must be released after use, by calling the [release] method. factory SomeTypes( jni$_.JString string, int j, double d, bool z, + jni$_.JObject object, + SomeEnum someEnum, ) { final _$string = string.reference; - return SomeTypes.fromReference(_new$(_class.reference.pointer, - _id_new$ as jni$_.JMethodIDPtr, _$string.pointer, j, d, z ? 1 : 0) + final _$object = object.reference; + final _$someEnum = someEnum.reference; + return SomeTypes.fromReference(_new$( + _class.reference.pointer, + _id_new$ as jni$_.JMethodIDPtr, + _$string.pointer, + j, + d, + z ? 1 : 0, + _$object.pointer, + _$someEnum.pointer) .reference); } @@ -3458,6 +4149,55 @@ class SomeTypes extends jni$_.JObject { .boolean; } + static final _id_getAnObject = _class.instanceMethodId( + r'getAnObject', + r'()Ljava/lang/Object;', + ); + + static final _getAnObject = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Object getAnObject()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject getAnObject() { + return _getAnObject( + reference.pointer, _id_getAnObject as jni$_.JMethodIDPtr) + .object(const jni$_.JObjectType()); + } + + static final _id_getAnEnum = _class.instanceMethodId( + r'getAnEnum', + r'()LSomeEnum;', + ); + + static final _getAnEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final SomeEnum getAnEnum()` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum getAnEnum() { + return _getAnEnum(reference.pointer, _id_getAnEnum as jni$_.JMethodIDPtr) + .object(const $SomeEnum$Type()); + } + static final _id_toList = _class.instanceMethodId( r'toList', r'()Ljava/util/List;', @@ -3625,9 +4365,57 @@ class SomeTypes extends jni$_.JObject { .boolean; } + static final _id_component5 = _class.instanceMethodId( + r'component5', + r'()Ljava/lang/Object;', + ); + + static final _component5 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Object component5()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject component5() { + return _component5(reference.pointer, _id_component5 as jni$_.JMethodIDPtr) + .object(const jni$_.JObjectType()); + } + + static final _id_component6 = _class.instanceMethodId( + r'component6', + r'()LSomeEnum;', + ); + + static final _component6 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final SomeEnum component6()` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum component6() { + return _component6(reference.pointer, _id_component6 as jni$_.JMethodIDPtr) + .object(const $SomeEnum$Type()); + } + static final _id_copy = _class.instanceMethodId( r'copy', - r'(Ljava/lang/String;JDZ)LSomeTypes;', + r'(Ljava/lang/String;JDZLjava/lang/Object;LSomeEnum;)LSomeTypes;', ); static final _copy = jni$_.ProtectedJniExtensions.lookup< @@ -3640,7 +4428,9 @@ class SomeTypes extends jni$_.JObject { jni$_.Pointer, jni$_.Int64, jni$_.Double, - jni$_.Int32 + jni$_.Int32, + jni$_.Pointer, + jni$_.Pointer )>)>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( @@ -3649,19 +4439,32 @@ class SomeTypes extends jni$_.JObject { jni$_.Pointer, int, double, - int)>(); + int, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public final SomeTypes copy(java.lang.String string, long j, double d, boolean z)` + /// from: `public final SomeTypes copy(java.lang.String string, long j, double d, boolean z, java.lang.Object object, SomeEnum someEnum)` /// The returned object must be released after use, by calling the [release] method. SomeTypes copy( jni$_.JString string, int j, double d, bool z, + jni$_.JObject object, + SomeEnum someEnum, ) { final _$string = string.reference; - return _copy(reference.pointer, _id_copy as jni$_.JMethodIDPtr, - _$string.pointer, j, d, z ? 1 : 0) + final _$object = object.reference; + final _$someEnum = someEnum.reference; + return _copy( + reference.pointer, + _id_copy as jni$_.JMethodIDPtr, + _$string.pointer, + j, + d, + z ? 1 : 0, + _$object.pointer, + _$someEnum.pointer) .object(const $SomeTypes$Type()); } @@ -3942,7 +4745,7 @@ class SomeNullableTypes extends jni$_.JObject { _id_Companion.get(_class, const $SomeNullableTypes$Companion$Type()); static final _id_new$ = _class.constructorId( - r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;)V', + r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;Ljava/lang/Object;LSomeEnum;)V', ); static final _new$ = jni$_.ProtectedJniExtensions.lookup< @@ -3952,6 +4755,8 @@ class SomeNullableTypes extends jni$_.JObject { jni$_.JMethodIDPtr, jni$_.VarArgs< ( + jni$_.Pointer, + jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, @@ -3964,32 +4769,40 @@ class SomeNullableTypes extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public void (java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean)` + /// from: `public void (java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean, java.lang.Object object, SomeEnum someEnum)` /// The returned object must be released after use, by calling the [release] method. factory SomeNullableTypes( jni$_.JString? string, jni$_.JLong? long, jni$_.JDouble? double, jni$_.JBoolean? boolean, + jni$_.JObject? object, + SomeEnum? someEnum, ) { final _$string = string?.reference ?? jni$_.jNullReference; final _$long = long?.reference ?? jni$_.jNullReference; final _$double = double?.reference ?? jni$_.jNullReference; final _$boolean = boolean?.reference ?? jni$_.jNullReference; + final _$object = object?.reference ?? jni$_.jNullReference; + final _$someEnum = someEnum?.reference ?? jni$_.jNullReference; return SomeNullableTypes.fromReference(_new$( _class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, _$string.pointer, _$long.pointer, _$double.pointer, - _$boolean.pointer) + _$boolean.pointer, + _$object.pointer, + _$someEnum.pointer) .reference); } static final _id_new$1 = _class.constructorId( - r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)V', + r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;Ljava/lang/Object;LSomeEnum;ILkotlin/jvm/internal/DefaultConstructorMarker;)V', ); static final _new$1 = jni$_.ProtectedJniExtensions.lookup< @@ -4003,6 +4816,8 @@ class SomeNullableTypes extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, jni$_.Int32, jni$_.Pointer )>)>>('globalEnv_NewObject') @@ -4014,16 +4829,20 @@ class SomeNullableTypes extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, int, jni$_.Pointer)>(); - /// from: `synthetic public void (java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean, int i, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker)` + /// from: `synthetic public void (java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean, java.lang.Object object, SomeEnum someEnum, int i, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker)` /// The returned object must be released after use, by calling the [release] method. factory SomeNullableTypes.new$1( jni$_.JString? string, jni$_.JLong? long, jni$_.JDouble? double, jni$_.JBoolean? boolean, + jni$_.JObject? object, + SomeEnum? someEnum, int i, jni$_.JObject? defaultConstructorMarker, ) { @@ -4031,6 +4850,8 @@ class SomeNullableTypes extends jni$_.JObject { final _$long = long?.reference ?? jni$_.jNullReference; final _$double = double?.reference ?? jni$_.jNullReference; final _$boolean = boolean?.reference ?? jni$_.jNullReference; + final _$object = object?.reference ?? jni$_.jNullReference; + final _$someEnum = someEnum?.reference ?? jni$_.jNullReference; final _$defaultConstructorMarker = defaultConstructorMarker?.reference ?? jni$_.jNullReference; return SomeNullableTypes.fromReference(_new$1( @@ -4040,6 +4861,8 @@ class SomeNullableTypes extends jni$_.JObject { _$long.pointer, _$double.pointer, _$boolean.pointer, + _$object.pointer, + _$someEnum.pointer, i, _$defaultConstructorMarker.pointer) .reference); @@ -4141,6 +4964,55 @@ class SomeNullableTypes extends jni$_.JObject { .object(const jni$_.JBooleanNullableType()); } + static final _id_getAnObject = _class.instanceMethodId( + r'getAnObject', + r'()Ljava/lang/Object;', + ); + + static final _getAnObject = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Object getAnObject()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? getAnObject() { + return _getAnObject( + reference.pointer, _id_getAnObject as jni$_.JMethodIDPtr) + .object(const jni$_.JObjectNullableType()); + } + + static final _id_getAnEnum = _class.instanceMethodId( + r'getAnEnum', + r'()LSomeEnum;', + ); + + static final _getAnEnum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final SomeEnum getAnEnum()` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum? getAnEnum() { + return _getAnEnum(reference.pointer, _id_getAnEnum as jni$_.JMethodIDPtr) + .object(const $SomeEnum$NullableType()); + } + static final _id_toList = _class.instanceMethodId( r'toList', r'()Ljava/util/List;', @@ -4311,9 +5183,57 @@ class SomeNullableTypes extends jni$_.JObject { .object(const jni$_.JBooleanNullableType()); } + static final _id_component5 = _class.instanceMethodId( + r'component5', + r'()Ljava/lang/Object;', + ); + + static final _component5 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final java.lang.Object component5()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? component5() { + return _component5(reference.pointer, _id_component5 as jni$_.JMethodIDPtr) + .object(const jni$_.JObjectNullableType()); + } + + static final _id_component6 = _class.instanceMethodId( + r'component6', + r'()LSomeEnum;', + ); + + static final _component6 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final SomeEnum component6()` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum? component6() { + return _component6(reference.pointer, _id_component6 as jni$_.JMethodIDPtr) + .object(const $SomeEnum$NullableType()); + } + static final _id_copy = _class.instanceMethodId( r'copy', - r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;)LSomeNullableTypes;', + r'(Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Double;Ljava/lang/Boolean;Ljava/lang/Object;LSomeEnum;)LSomeNullableTypes;', ); static final _copy = jni$_.ProtectedJniExtensions.lookup< @@ -4323,6 +5243,8 @@ class SomeNullableTypes extends jni$_.JObject { jni$_.JMethodIDPtr, jni$_.VarArgs< ( + jni$_.Pointer, + jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, @@ -4335,27 +5257,35 @@ class SomeNullableTypes extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public final SomeNullableTypes copy(java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean)` + /// from: `public final SomeNullableTypes copy(java.lang.String string, java.lang.Long long, java.lang.Double double, java.lang.Boolean boolean, java.lang.Object object, SomeEnum someEnum)` /// The returned object must be released after use, by calling the [release] method. SomeNullableTypes copy( jni$_.JString? string, jni$_.JLong? long, jni$_.JDouble? double, jni$_.JBoolean? boolean, + jni$_.JObject? object, + SomeEnum? someEnum, ) { final _$string = string?.reference ?? jni$_.jNullReference; final _$long = long?.reference ?? jni$_.jNullReference; final _$double = double?.reference ?? jni$_.jNullReference; final _$boolean = boolean?.reference ?? jni$_.jNullReference; + final _$object = object?.reference ?? jni$_.jNullReference; + final _$someEnum = someEnum?.reference ?? jni$_.jNullReference; return _copy( reference.pointer, _id_copy as jni$_.JMethodIDPtr, _$string.pointer, _$long.pointer, _$double.pointer, - _$boolean.pointer) + _$boolean.pointer, + _$object.pointer, + _$someEnum.pointer) .object(const $SomeNullableTypes$Type()); } @@ -4483,3 +5413,375 @@ final class $SomeNullableTypes$Type extends jni$_.JObjType { other is $SomeNullableTypes$Type; } } + +/// from: `SomeEnum$Companion` +class SomeEnum$Companion extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + SomeEnum$Companion.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'SomeEnum$Companion'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $SomeEnum$Companion$NullableType(); + static const type = $SomeEnum$Companion$Type(); + static final _id_ofRaw = _class.instanceMethodId( + r'ofRaw', + r'(I)LSomeEnum;', + ); + + static final _ofRaw = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public final SomeEnum ofRaw(int i)` + /// The returned object must be released after use, by calling the [release] method. + SomeEnum? ofRaw( + int i, + ) { + return _ofRaw(reference.pointer, _id_ofRaw as jni$_.JMethodIDPtr, i) + .object(const $SomeEnum$NullableType()); + } + + static final _id_new$ = _class.constructorId( + r'(Lkotlin/jvm/internal/DefaultConstructorMarker;)V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `synthetic public void (kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker)` + /// The returned object must be released after use, by calling the [release] method. + factory SomeEnum$Companion( + jni$_.JObject? defaultConstructorMarker, + ) { + final _$defaultConstructorMarker = + defaultConstructorMarker?.reference ?? jni$_.jNullReference; + return SomeEnum$Companion.fromReference(_new$(_class.reference.pointer, + _id_new$ as jni$_.JMethodIDPtr, _$defaultConstructorMarker.pointer) + .reference); + } +} + +final class $SomeEnum$Companion$NullableType + extends jni$_.JObjType { + @jni$_.internal + const $SomeEnum$Companion$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeEnum$Companion;'; + + @jni$_.internal + @core$_.override + SomeEnum$Companion? fromReference(jni$_.JReference reference) => + reference.isNull + ? null + : SomeEnum$Companion.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeEnum$Companion$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeEnum$Companion$NullableType) && + other is $SomeEnum$Companion$NullableType; + } +} + +final class $SomeEnum$Companion$Type + extends jni$_.JObjType { + @jni$_.internal + const $SomeEnum$Companion$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeEnum$Companion;'; + + @jni$_.internal + @core$_.override + SomeEnum$Companion fromReference(jni$_.JReference reference) => + SomeEnum$Companion.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => + const $SomeEnum$Companion$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeEnum$Companion$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeEnum$Companion$Type) && + other is $SomeEnum$Companion$Type; + } +} + +/// from: `SomeEnum` +class SomeEnum extends jni$_.JObject { + @jni$_.internal + @core$_.override + final jni$_.JObjType $type; + + @jni$_.internal + SomeEnum.fromReference( + jni$_.JReference reference, + ) : $type = type, + super.fromReference(reference); + + static final _class = jni$_.JClass.forName(r'SomeEnum'); + + /// The type which includes information such as the signature of this class. + static const nullableType = $SomeEnum$NullableType(); + static const type = $SomeEnum$Type(); + static final _id_Companion = _class.staticFieldId( + r'Companion', + r'LSomeEnum$Companion;', + ); + + /// from: `static public final SomeEnum$Companion Companion` + /// The returned object must be released after use, by calling the [release] method. + static SomeEnum$Companion get Companion => + _id_Companion.get(_class, const $SomeEnum$Companion$Type()); + + static final _id_VALUE1 = _class.staticFieldId( + r'VALUE1', + r'LSomeEnum;', + ); + + /// from: `static public final SomeEnum VALUE1` + /// The returned object must be released after use, by calling the [release] method. + static SomeEnum get VALUE1 => _id_VALUE1.get(_class, const $SomeEnum$Type()); + + static final _id_VALUE2 = _class.staticFieldId( + r'VALUE2', + r'LSomeEnum;', + ); + + /// from: `static public final SomeEnum VALUE2` + /// The returned object must be released after use, by calling the [release] method. + static SomeEnum get VALUE2 => _id_VALUE2.get(_class, const $SomeEnum$Type()); + + static final _id_VALUE3 = _class.staticFieldId( + r'VALUE3', + r'LSomeEnum;', + ); + + /// from: `static public final SomeEnum VALUE3` + /// The returned object must be released after use, by calling the [release] method. + static SomeEnum get VALUE3 => _id_VALUE3.get(_class, const $SomeEnum$Type()); + + static final _id_getRaw = _class.instanceMethodId( + r'getRaw', + r'()I', + ); + + static final _getRaw = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public final int getRaw()` + int getRaw() { + return _getRaw(reference.pointer, _id_getRaw as jni$_.JMethodIDPtr).integer; + } + + static final _id_values = _class.staticMethodId( + r'values', + r'()[LSomeEnum;', + ); + + static final _values = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public SomeEnum[] values()` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JArray? values() { + return _values(_class.reference.pointer, _id_values as jni$_.JMethodIDPtr) + .object?>( + const jni$_.JArrayNullableType( + $SomeEnum$NullableType())); + } + + static final _id_valueOf = _class.staticMethodId( + r'valueOf', + r'(Ljava/lang/String;)LSomeEnum;', + ); + + static final _valueOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public SomeEnum valueOf(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + static SomeEnum? valueOf( + jni$_.JString? string, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _valueOf(_class.reference.pointer, _id_valueOf as jni$_.JMethodIDPtr, + _$string.pointer) + .object(const $SomeEnum$NullableType()); + } + + static final _id_getEntries = _class.staticMethodId( + r'getEntries', + r'()Lkotlin/enums/EnumEntries;', + ); + + static final _getEntries = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public kotlin.enums.EnumEntries getEntries()` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JObject getEntries() { + return _getEntries( + _class.reference.pointer, _id_getEntries as jni$_.JMethodIDPtr) + .object(const jni$_.JObjectType()); + } +} + +final class $SomeEnum$NullableType extends jni$_.JObjType { + @jni$_.internal + const $SomeEnum$NullableType(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeEnum;'; + + @jni$_.internal + @core$_.override + SomeEnum? fromReference(jni$_.JReference reference) => reference.isNull + ? null + : SomeEnum.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => this; + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeEnum$NullableType).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeEnum$NullableType) && + other is $SomeEnum$NullableType; + } +} + +final class $SomeEnum$Type extends jni$_.JObjType { + @jni$_.internal + const $SomeEnum$Type(); + + @jni$_.internal + @core$_.override + String get signature => r'LSomeEnum;'; + + @jni$_.internal + @core$_.override + SomeEnum fromReference(jni$_.JReference reference) => SomeEnum.fromReference( + reference, + ); + @jni$_.internal + @core$_.override + jni$_.JObjType get superType => const jni$_.JObjectType(); + + @jni$_.internal + @core$_.override + jni$_.JObjType get nullableType => const $SomeEnum$NullableType(); + + @jni$_.internal + @core$_.override + final superCount = 1; + + @core$_.override + int get hashCode => ($SomeEnum$Type).hashCode; + + @core$_.override + bool operator ==(Object other) { + return other.runtimeType == ($SomeEnum$Type) && other is $SomeEnum$Type; + } +} diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart index d25c97ce3756..88b8f3aa973c 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart @@ -40,7 +40,7 @@ List wrapResponse( enum MessageRequestState { pending, success, - failure, + failure; } /// This comment is to test class documentation comments. diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/non_null_fields.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/non_null_fields.gen.dart index 3ebff9c56bd7..da8ab23b7bdd 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/non_null_fields.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/non_null_fields.gen.dart @@ -48,7 +48,7 @@ bool _deepEquals(Object? a, Object? b) { enum ReplyType { success, - error, + error; } class NonNullFieldSearchRequest { diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart index b281a87d9c3a..3d7b53dc327b 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart @@ -48,7 +48,7 @@ bool _deepEquals(Object? a, Object? b) { enum NullFieldsSearchReplyType { success, - failure, + failure; } class NullFieldsSearchRequest { diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/proxy_api_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/proxy_api_tests.gen.dart index 227b6792179c..44f00344c030 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/proxy_api_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/proxy_api_tests.gen.dart @@ -413,7 +413,7 @@ class _PigeonInternalProxyApiBaseCodec extends _PigeonCodec { enum ProxyApiTestEnum { one, two, - three, + three; } class _PigeonCodec extends StandardMessageCodec { diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt index 7a2c9b844d4f..c977a46dd23b 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/JniTests.gen.kt @@ -21,12 +21,26 @@ class JniTestsError( val details: Any? = null ) : Throwable() +enum class SomeEnum(val raw: Int) { + VALUE1(0), + VALUE2(1), + VALUE3(2); + + companion object { + fun ofRaw(raw: Int): SomeEnum? { + return values().firstOrNull { it.raw == raw } + } + } +} + /** Generated class from Pigeon that represents data sent in messages. */ data class SomeTypes( val aString: String, val anInt: Long, val aDouble: Double, - val aBool: Boolean + val aBool: Boolean, + val anObject: Any, + val anEnum: SomeEnum ) { companion object { fun fromList(pigeonVar_list: List): SomeTypes { @@ -34,7 +48,9 @@ data class SomeTypes( val anInt = pigeonVar_list[1] as Long val aDouble = pigeonVar_list[2] as Double val aBool = pigeonVar_list[3] as Boolean - return SomeTypes(aString, anInt, aDouble, aBool) + val anObject = pigeonVar_list[4] as Any + val anEnum = pigeonVar_list[5] as SomeEnum + return SomeTypes(aString, anInt, aDouble, aBool, anObject, anEnum) } } @@ -44,6 +60,8 @@ data class SomeTypes( anInt, aDouble, aBool, + anObject, + anEnum, ) } @@ -57,7 +75,9 @@ data class SomeTypes( return aString == other.aString && anInt == other.anInt && aDouble == other.aDouble && - aBool == other.aBool + aBool == other.aBool && + anObject == other.anObject && + anEnum == other.anEnum } override fun hashCode(): Int = toList().hashCode() @@ -68,7 +88,9 @@ data class SomeNullableTypes( val aString: String? = null, val anInt: Long? = null, val aDouble: Double? = null, - val aBool: Boolean? = null + val aBool: Boolean? = null, + val anObject: Any? = null, + val anEnum: SomeEnum? = null ) { companion object { fun fromList(pigeonVar_list: List): SomeNullableTypes { @@ -76,7 +98,9 @@ data class SomeNullableTypes( val anInt = pigeonVar_list[1] as Long? val aDouble = pigeonVar_list[2] as Double? val aBool = pigeonVar_list[3] as Boolean? - return SomeNullableTypes(aString, anInt, aDouble, aBool) + val anObject = pigeonVar_list[4] + val anEnum = pigeonVar_list[5] as SomeEnum? + return SomeNullableTypes(aString, anInt, aDouble, aBool, anObject, anEnum) } } @@ -86,6 +110,8 @@ data class SomeNullableTypes( anInt, aDouble, aBool, + anObject, + anEnum, ) } @@ -99,7 +125,9 @@ data class SomeNullableTypes( return aString == other.aString && anInt == other.anInt && aDouble == other.aDouble && - aBool == other.aBool + aBool == other.aBool && + anObject == other.anObject && + anEnum == other.anEnum } override fun hashCode(): Int = toList().hashCode() @@ -119,7 +147,11 @@ abstract class JniMessageApi { abstract fun echoBool(request: Boolean): Boolean + abstract fun echoObj(request: Any): Any + abstract fun sendSomeTypes(someTypes: SomeTypes): SomeTypes + + abstract fun sendSomeEnum(anEnum: SomeEnum): SomeEnum } @Keep @@ -195,6 +227,17 @@ class JniMessageApiRegistrar : JniMessageApi() { error("JniMessageApi has not been set") } + override fun echoObj(request: Any): Any { + api?.let { + try { + return api!!.echoObj(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApi has not been set") + } + override fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { api?.let { try { @@ -205,6 +248,17 @@ class JniMessageApiRegistrar : JniMessageApi() { } error("JniMessageApi has not been set") } + + override fun sendSomeEnum(anEnum: SomeEnum): SomeEnum { + api?.let { + try { + return api!!.sendSomeEnum(anEnum) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApi has not been set") + } } val JniMessageApiNullableInstances: MutableMap = @@ -220,7 +274,11 @@ abstract class JniMessageApiNullable { abstract fun echoBool(request: Boolean?): Boolean? + abstract fun echoObj(request: Any?): Any? + abstract fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? + + abstract fun sendSomeEnum(anEnum: SomeEnum?): SomeEnum? } @Keep @@ -285,6 +343,17 @@ class JniMessageApiNullableRegistrar : JniMessageApiNullable() { error("JniMessageApiNullable has not been set") } + override fun echoObj(request: Any?): Any? { + api?.let { + try { + return api!!.echoObj(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullable has not been set") + } + override fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? { api?.let { try { @@ -295,6 +364,17 @@ class JniMessageApiNullableRegistrar : JniMessageApiNullable() { } error("JniMessageApiNullable has not been set") } + + override fun sendSomeEnum(anEnum: SomeEnum?): SomeEnum? { + api?.let { + try { + return api!!.sendSomeEnum(anEnum) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullable has not been set") + } } val JniMessageApiAsyncInstances: MutableMap = mutableMapOf() @@ -311,7 +391,11 @@ abstract class JniMessageApiAsync { abstract suspend fun echoBool(request: Boolean): Boolean + abstract suspend fun echoObj(request: Any): Any + abstract suspend fun sendSomeTypes(someTypes: SomeTypes): SomeTypes + + abstract suspend fun sendSomeEnum(anEnum: SomeEnum): SomeEnum } @Keep @@ -387,6 +471,17 @@ class JniMessageApiAsyncRegistrar : JniMessageApiAsync() { error("JniMessageApiAsync has not been set") } + override suspend fun echoObj(request: Any): Any { + api?.let { + try { + return api!!.echoObj(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiAsync has not been set") + } + override suspend fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { api?.let { try { @@ -397,6 +492,17 @@ class JniMessageApiAsyncRegistrar : JniMessageApiAsync() { } error("JniMessageApiAsync has not been set") } + + override suspend fun sendSomeEnum(anEnum: SomeEnum): SomeEnum { + api?.let { + try { + return api!!.sendSomeEnum(anEnum) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiAsync has not been set") + } } val JniMessageApiNullableAsyncInstances: MutableMap = @@ -412,7 +518,11 @@ abstract class JniMessageApiNullableAsync { abstract suspend fun echoBool(request: Boolean?): Boolean? + abstract suspend fun echoObj(request: Any?): Any? + abstract suspend fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? + + abstract suspend fun sendSomeEnum(anEnum: SomeEnum?): SomeEnum? } @Keep @@ -477,6 +587,17 @@ class JniMessageApiNullableAsyncRegistrar : JniMessageApiNullableAsync() { error("JniMessageApiNullableAsync has not been set") } + override suspend fun echoObj(request: Any?): Any? { + api?.let { + try { + return api!!.echoObj(request) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullableAsync has not been set") + } + override suspend fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? { api?.let { try { @@ -487,4 +608,15 @@ class JniMessageApiNullableAsyncRegistrar : JniMessageApiNullableAsync() { } error("JniMessageApiNullableAsync has not been set") } + + override suspend fun sendSomeEnum(anEnum: SomeEnum?): SomeEnum? { + api?.let { + try { + return api!!.sendSomeEnum(anEnum) + } catch (e: Exception) { + throw e + } + } + error("JniMessageApiNullableAsync has not been set") + } } 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 4c47ed6e254f..84285ec78958 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 @@ -12,6 +12,7 @@ import JniMessageApiNullableAsync import JniMessageApiNullableAsyncRegistrar import JniMessageApiNullableRegistrar import JniMessageApiRegistrar +import SomeEnum import SomeNullableTypes import SomeTypes import android.os.Handler @@ -917,13 +918,17 @@ class JniMessageApiImpl : JniMessageApi() { return request } - // override fun echoObj(request: Any): Any { - // return request - // } + override fun echoObj(request: Any): Any { + return request + } override fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { return someTypes } + + override fun sendSomeEnum(anEnum: SomeEnum): SomeEnum { + return anEnum + } } class JniMessageApiImpl2 : JniMessageApi() { @@ -947,14 +952,18 @@ class JniMessageApiImpl2 : JniMessageApi() { return !request } - // override fun echoObj(request: Any): Any { - // return request - // } + override fun echoObj(request: Any): Any { + return request + } override fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { val newSomeTypes = someTypes.copy(anInt = someTypes.anInt + 1) return newSomeTypes } + + override fun sendSomeEnum(anEnum: SomeEnum): SomeEnum { + return anEnum + } } class JniMessageApiNullableImpl : JniMessageApiNullable() { @@ -974,9 +983,17 @@ class JniMessageApiNullableImpl : JniMessageApiNullable() { return request } + override fun echoObj(request: Any?): Any? { + return request + } + override fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? { return someTypes } + + override fun sendSomeEnum(anEnum: SomeEnum?): SomeEnum? { + return anEnum + } } class JniMessageApiAsyncImpl : JniMessageApiAsync() { @@ -1000,13 +1017,17 @@ class JniMessageApiAsyncImpl : JniMessageApiAsync() { return request } - // override fun echoObj(request: Any): Any { - // return request - // } + override suspend fun echoObj(request: Any): Any { + return request + } override suspend fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { return someTypes } + + override suspend fun sendSomeEnum(anEnum: SomeEnum): SomeEnum { + return anEnum + } } class JniMessageApiAsyncImpl2 : JniMessageApiAsync() { @@ -1030,14 +1051,18 @@ class JniMessageApiAsyncImpl2 : JniMessageApiAsync() { return !request } - // override fun echoObj(request: Any): Any { - // return request - // } + override suspend fun echoObj(request: Any): Any { + return request + } override suspend fun sendSomeTypes(someTypes: SomeTypes): SomeTypes { val newSomeTypes = someTypes.copy(anInt = someTypes.anInt + 1) return newSomeTypes } + + override suspend fun sendSomeEnum(anEnum: SomeEnum): SomeEnum { + return anEnum + } } class JniMessageApiNullableAsyncImpl : JniMessageApiNullableAsync() { @@ -1058,9 +1083,17 @@ class JniMessageApiNullableAsyncImpl : JniMessageApiNullableAsync() { return request } + override suspend fun echoObj(request: Any?): Any? { + return request + } + override suspend fun sendSomeNullableTypes(someTypes: SomeNullableTypes?): SomeNullableTypes? { return someTypes } + + override suspend fun sendSomeEnum(anEnum: SomeEnum?): SomeEnum? { + return anEnum + } } // override suspend fun thinkBeforeAnswering(): String { diff --git a/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml b/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml index 783c3f0e1845..fffedbca1c26 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml +++ b/packages/pigeon/platform_tests/test_plugin/example/jnigen.yaml @@ -26,3 +26,4 @@ classes: - 'JniMessageApiNullableAsyncRegistrar' - 'SomeTypes' - 'SomeNullableTypes' + - 'SomeEnum'