Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/jni/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use `Jni.androidApplicationContext(engineId)` to access the application
context and use `Jni.androidActivity(engineId)` to acccess the activity.
- Update to the latest lints.
- **Breaking Change**: `JArray`'s unnamed constructor is now
`JArray.withLength`.

## 0.14.2

Expand Down
59 changes: 18 additions & 41 deletions pkgs/jni/lib/_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,31 @@ export 'dart:isolate' show RawReceivePort, ReceivePort;
export 'package:meta/meta.dart' show internal;

export 'src/accessors.dart';
export 'src/jarray.dart'
show
$JArray$NullableType$,
$JArray$Type$,
$JBooleanArray$NullableType$,
$JBooleanArray$Type$,
$JByteArray$NullableType$,
$JByteArray$Type$,
$JCharArray$NullableType$,
$JCharArray$Type$,
$JDoubleArray$NullableType$,
$JDoubleArray$Type$,
$JFloatArray$NullableType$,
$JFloatArray$Type$,
$JIntArray$NullableType$,
$JIntArray$Type$,
$JLongArray$NullableType$,
$JLongArray$Type$,
$JShortArray$NullableType$,
$JShortArray$Type$;
export 'src/jni.dart' show ProtectedJniExtensions;
export 'src/jobject.dart' show $JObject$NullableType$, $JObject$Type$;
export 'src/jobject.dart' show $JObject$Type$;
export 'src/jreference.dart';
export 'src/kotlin.dart'
show coroutineSingletonsClass, failureExceptionField, result$FailureClass;
export 'src/lang/jboolean.dart' show $JBoolean$NullableType$, $JBoolean$Type$;
export 'src/lang/jbyte.dart' show $JByte$NullableType$, $JByte$Type$;
export 'src/lang/jcharacter.dart'
show $JCharacter$NullableType$, $JCharacter$Type$;
export 'src/lang/jdouble.dart' show $JDouble$NullableType$, $JDouble$Type$;
export 'src/lang/jfloat.dart' show $JFloat$NullableType$, $JFloat$Type$;
export 'src/lang/jinteger.dart' show $JInteger$NullableType$, $JInteger$Type$;
export 'src/lang/jlong.dart' show $JLong$NullableType$, $JLong$Type$;
export 'src/lang/jnumber.dart' show $JNumber$NullableType$, $JNumber$Type$;
export 'src/lang/jshort.dart' show $JShort$NullableType$, $JShort$Type$;
export 'src/lang/jstring.dart' show $JString$NullableType$, $JString$Type$;
export 'src/lang/jboolean.dart';
export 'src/lang/jbyte.dart';
export 'src/lang/jcharacter.dart';
export 'src/lang/jdouble.dart';
export 'src/lang/jfloat.dart';
export 'src/lang/jinteger.dart';
export 'src/lang/jlong.dart';
export 'src/lang/jnumber.dart';
export 'src/lang/jshort.dart';
export 'src/lang/jstring.dart';
export 'src/method_invocation.dart';
export 'src/nio/jbuffer.dart' show $JBuffer$NullableType$, $JBuffer$Type$;
export 'src/nio/jbyte_buffer.dart'
show $JByteBuffer$NullableType$, $JByteBuffer$Type$;
export 'src/nio/jbuffer.dart';
export 'src/nio/jbyte_buffer.dart';
export 'src/third_party/generated_bindings.dart'
show JFieldIDPtr, JMethodIDPtr, JObjectPtr, JThrowablePtr, JniResult;
export 'src/types.dart' show JTypeBase, lowestCommonSuperType, referenceType;
export 'src/util/jiterator.dart'
show $JIterator$NullableType$, $JIterator$Type$;
export 'src/util/jlist.dart' show $JList$NullableType$, $JList$Type$;
export 'src/util/jmap.dart' show $JMap$NullableType$, $JMap$Type$;
export 'src/util/jset.dart' show $JSet$NullableType$, $JSet$Type$;
export 'src/types.dart' show JTypeBase, referenceType;
export 'src/util/jiterator.dart';
export 'src/util/jlist.dart';
export 'src/util/jmap.dart';
export 'src/util/jset.dart';

/// Temporary fix for the macOS arm64 varargs problem.
///
Expand Down
299 changes: 299 additions & 0 deletions pkgs/jni/lib/core_bindings/java/util/Iterator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
// AUTO GENERATED BY JNIGEN 0.15.0. 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
// 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: `java.util.Iterator`
extension type Iterator<$E extends jni$_.JObject?>._(jni$_.JObject _$this)
implements jni$_.JObject {
static final _class = jni$_.JClass.forName(r'java/util/Iterator');

/// The type which includes information such as the signature of this class.
static const jni$_.JType<Iterator> type = $Iterator$Type$();
static final _id_hasNext = _class.instanceMethodId(
r'hasNext',
r'()Z',
);

static final _hasNext = jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)>>('globalEnv_CallBooleanMethod')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)>();

/// from: `public abstract boolean hasNext()`
bool hasNext() {
return _hasNext(reference.pointer, _id_hasNext as jni$_.JMethodIDPtr)
.boolean;
}

static final _id_next = _class.instanceMethodId(
r'next',
r'()Ljava/lang/Object;',
);

static final _next = jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)>>('globalEnv_CallObjectMethod')
.asFunction<
jni$_.JniResult Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)>();

/// from: `public abstract E next()`
/// The returned object must be released after use, by calling the [release] method.
$E? next() {
return _next(reference.pointer, _id_next as jni$_.JMethodIDPtr)
.object<$E?>();
}

static final _id_remove = _class.instanceMethodId(
r'remove',
r'()V',
);

static final _remove = jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)>>('globalEnv_CallVoidMethod')
.asFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
)>();

/// from: `public void remove()`
void remove() {
_remove(reference.pointer, _id_remove as jni$_.JMethodIDPtr).check();
}

static final _id_forEachRemaining = _class.instanceMethodId(
r'forEachRemaining',
r'(Ljava/util/function/Consumer;)V',
);

static final _forEachRemaining = jni$_.ProtectedJniExtensions.lookup<
jni$_.NativeFunction<
jni$_.JThrowablePtr Function(
jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr,
jni$_.VarArgs<(jni$_.Pointer<jni$_.Void>,)>)>>(
'globalEnv_CallVoidMethod')
.asFunction<
jni$_.JThrowablePtr Function(jni$_.Pointer<jni$_.Void>,
jni$_.JMethodIDPtr, jni$_.Pointer<jni$_.Void>)>();

/// from: `public void forEachRemaining(java.util.function.Consumer<? super E> consumer)`
void forEachRemaining(
jni$_.JObject? consumer,
) {
final _$consumer = consumer?.reference ?? jni$_.jNullReference;
_forEachRemaining(reference.pointer,
_id_forEachRemaining as jni$_.JMethodIDPtr, _$consumer.pointer)
.check();
}

/// Maps a specific port to the implemented interface.
static final core$_.Map<int, $Iterator> _$impls = {};
static jni$_.JObjectPtr _$invoke(
int port,
jni$_.JObjectPtr descriptor,
jni$_.JObjectPtr args,
) {
return _$invokeMethod(
port,
jni$_.MethodInvocation.fromAddresses(
0,
descriptor.address,
args.address,
),
);
}

static final jni$_.Pointer<
jni$_.NativeFunction<
jni$_.JObjectPtr Function(
jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>>
_$invokePointer = jni$_.Pointer.fromFunction(_$invoke);

static jni$_.Pointer<jni$_.Void> _$invokeMethod(
int $p,
jni$_.MethodInvocation $i,
) {
try {
final $d = $i.methodDescriptor.toDartString(releaseOriginal: true);
final $a = $i.args;
if ($d == r'hasNext()Z') {
final $r = _$impls[$p]!.hasNext();
return jni$_.JBoolean($r).reference.toPointer();
}
if ($d == r'next()Ljava/lang/Object;') {
final $r = _$impls[$p]!.next();
return ($r as jni$_.JObject?)
?.as(const jni$_.$JObject$Type$())
.reference
.toPointer() ??
jni$_.nullptr;
}
if ($d == r'remove()V') {
_$impls[$p]!.remove();
return jni$_.nullptr;
}
if ($d == r'forEachRemaining(Ljava/util/function/Consumer;)V') {
_$impls[$p]!.forEachRemaining(
$a![0],
);
return jni$_.nullptr;
}
} catch (e) {
return jni$_.ProtectedJniExtensions.newDartException(e);
}
return jni$_.nullptr;
}

static void implementIn<$E extends jni$_.JObject?>(
jni$_.JImplementer implementer,
$Iterator<$E> $impl,
) {
late final jni$_.RawReceivePort $p;
$p = jni$_.RawReceivePort(($m) {
if ($m == null) {
_$impls.remove($p.sendPort.nativePort);
$p.close();
return;
}
final $i = jni$_.MethodInvocation.fromMessage($m);
final $r = _$invokeMethod($p.sendPort.nativePort, $i);
jni$_.ProtectedJniExtensions.returnResult($i.result, $r);
});
implementer.add(
r'java.util.Iterator',
$p,
_$invokePointer,
[
if ($impl.remove$async) r'remove()V',
if ($impl.forEachRemaining$async)
r'forEachRemaining(Ljava/util/function/Consumer;)V',
],
);
final $a = $p.sendPort.nativePort;
_$impls[$a] = $impl;
}

factory Iterator.implement(
$Iterator<$E> $impl,
) {
final $i = jni$_.JImplementer();
implementIn($i, $impl);
return $i.implement<Iterator<$E>>();
}
}

abstract base mixin class $Iterator<$E extends jni$_.JObject?> {
factory $Iterator({
required bool Function() hasNext,
required $E? Function() next,
required void Function() remove,
bool remove$async,
required void Function(jni$_.JObject? consumer) forEachRemaining,
bool forEachRemaining$async,
}) = _$Iterator<$E>;

bool hasNext();
$E? next();
void remove();
bool get remove$async => false;
void forEachRemaining(jni$_.JObject? consumer);
bool get forEachRemaining$async => false;
}

final class _$Iterator<$E extends jni$_.JObject?> with $Iterator<$E> {
_$Iterator({
required bool Function() hasNext,
required $E? Function() next,
required void Function() remove,
this.remove$async = false,
required void Function(jni$_.JObject? consumer) forEachRemaining,
this.forEachRemaining$async = false,
}) : _hasNext = hasNext,
_next = next,
_remove = remove,
_forEachRemaining = forEachRemaining;

final bool Function() _hasNext;
final $E? Function() _next;
final void Function() _remove;
final bool remove$async;
final void Function(jni$_.JObject? consumer) _forEachRemaining;
final bool forEachRemaining$async;

bool hasNext() {
return _hasNext();
}

$E? next() {
return _next();
}

void remove() {
return _remove();
}

void forEachRemaining(jni$_.JObject? consumer) {
return _forEachRemaining(consumer);
}
}

final class $Iterator$Type$ extends jni$_.JType<Iterator> {
@jni$_.internal
const $Iterator$Type$();

@jni$_.internal
@core$_.override
String get signature => r'Ljava/util/Iterator;';
}
Loading
Loading