Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HosseinYousefi committed Aug 17, 2023
1 parent 0e29539 commit b8b19ec
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 36 deletions.
2 changes: 1 addition & 1 deletion jni/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -519,5 +519,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
dart: ">=3.1.0 <4.0.0"
flutter: ">=2.11.0"
2 changes: 1 addition & 1 deletion jni/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: '>=2.17.5 <4.0.0'
sdk: '>=3.1.0 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down
4 changes: 3 additions & 1 deletion jni/lib/src/jni.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ abstract class Jni {
_dylibDir = dylibDir;
}

/// Initializes DartApiDL used for Continuations and interface implementation.
static void initDLApi() {
// Initializing DartApiDL used for Continuations.
assert(NativeApi.majorVersion == 2);
assert(NativeApi.minorVersion >= 3);
final result = _bindings.InitDartApiDL(NativeApi.initializeApiDLData);
assert(result == 0);
}
Expand Down
2 changes: 1 addition & 1 deletion jni/lib/src/jobject.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ T _callOrGet<T>(int? callType, JniResult Function(int) function) {
: (T == JObject ? JObject.fromRef : JString.fromRef);
result = ctor(ref) as T;
break;
case Pointer<Void>: // JObjectPtr
case const (Pointer<Void>): // JObjectPtr
finalCallType = _getCallType(
callType, JniCallType.objectType, {JniCallType.objectType});
result = function(finalCallType).object as T;
Expand Down
4 changes: 2 additions & 2 deletions jni/lib/src/jvalues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ void _fillJValue(Pointer<JValue> pos, dynamic arg) {
case bool:
pos.ref.z = arg ? 1 : 0;
break;
case Pointer<Void>:
case Pointer<Never>: // for nullptr
case const (Pointer<Void>):
case const (Pointer<Never>): // for nullptr
pos.ref.l = arg;
break;
case double:
Expand Down
34 changes: 17 additions & 17 deletions jni/lib/src/third_party/jni_bindings_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ abstract class JniCallType {
///
/// If [exception] is null, it means the result is valid.
/// It's assumed that the caller knows the expected type in [result].
class JniResult extends ffi.Struct {
final class JniResult extends ffi.Struct {
external JValue value;

external JThrowablePtr exception;
}

class JValue extends ffi.Union {
final class JValue extends ffi.Union {
@JBooleanMarker()
external int z;

Expand Down Expand Up @@ -306,7 +306,7 @@ typedef JObjectPtr = ffi.Pointer<ffi.Void>;
typedef JThrowablePtr = JObjectPtr;

/// Similar to [JniResult] but for class lookups.
class JniClassLookupResult extends ffi.Struct {
final class JniClassLookupResult extends ffi.Struct {
external JClassPtr value;

external JThrowablePtr exception;
Expand All @@ -315,15 +315,15 @@ class JniClassLookupResult extends ffi.Struct {
typedef JClassPtr = JObjectPtr;

/// Similar to [JniResult] but for method/field ID lookups.
class JniPointerResult extends ffi.Struct {
final class JniPointerResult extends ffi.Struct {
external ffi.Pointer<ffi.Void> value;

external JThrowablePtr exception;
}

/// JniExceptionDetails holds 2 jstring objects, one is the result of
/// calling `toString` on exception object, other is stack trace;
class JniExceptionDetails extends ffi.Struct {
final class JniExceptionDetails extends ffi.Struct {
external JStringPtr message;

external JStringPtr stacktrace;
Expand All @@ -337,7 +337,7 @@ typedef JStringPtr = JObjectPtr;
/// Flutter embedding checks for pending JNI exceptions before an FFI transition, which requires us
/// to check for and clear the exception before returning to dart code, which requires these functions
/// to return result types.
class JniAccessorsStruct extends ffi.Struct {
final class JniAccessorsStruct extends ffi.Struct {
external ffi.Pointer<
ffi.NativeFunction<
JniClassLookupResult Function(
Expand Down Expand Up @@ -421,19 +421,19 @@ class JniAccessorsStruct extends ffi.Struct {

typedef JMethodIDPtr = ffi.Pointer<jmethodID_>;

class jmethodID_ extends ffi.Opaque {}
final class jmethodID_ extends ffi.Opaque {}

/// "cardinal indices and sizes"
typedef JSizeMarker = JIntMarker;
typedef JArrayPtr = JObjectPtr;
typedef JFieldIDPtr = ffi.Pointer<jfieldID_>;

class jfieldID_ extends ffi.Opaque {}
final class jfieldID_ extends ffi.Opaque {}

typedef JavaVM = ffi.Pointer<JNIInvokeInterface>;

/// JNI invocation interface.
class JNIInvokeInterface extends ffi.Struct {
final class JNIInvokeInterface extends ffi.Struct {
external ffi.Pointer<ffi.Void> reserved0;

external ffi.Pointer<ffi.Void> reserved1;
Expand Down Expand Up @@ -474,7 +474,7 @@ typedef JavaVM1 = ffi.Pointer<JNIInvokeInterface>;
typedef JniEnv = ffi.Pointer<JNINativeInterface>;

/// Table of interface function pointers.
class JNINativeInterface extends ffi.Struct {
final class JNINativeInterface extends ffi.Struct {
external ffi.Pointer<ffi.Void> reserved0;

external ffi.Pointer<ffi.Void> reserved1;
Expand Down Expand Up @@ -1933,7 +1933,7 @@ typedef JLongArrayPtr = JArrayPtr;
typedef JFloatArrayPtr = JArrayPtr;
typedef JDoubleArrayPtr = JArrayPtr;

class JNINativeMethod extends ffi.Struct {
final class JNINativeMethod extends ffi.Struct {
external ffi.Pointer<ffi.Char> name;

external ffi.Pointer<ffi.Char> signature;
Expand All @@ -1950,7 +1950,7 @@ abstract class JObjectRefType {
static const int JNIWeakGlobalRefType = 3;
}

class JavaVMInitArgs extends ffi.Struct {
final class JavaVMInitArgs extends ffi.Struct {
/// use JNI_VERSION_1_2 or later
@JIntMarker()
external int version;
Expand All @@ -1966,13 +1966,13 @@ class JavaVMInitArgs extends ffi.Struct {

/// JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no
/// longer supported.)
class JavaVMOption extends ffi.Struct {
final class JavaVMOption extends ffi.Struct {
external ffi.Pointer<ffi.Char> optionString;

external ffi.Pointer<ffi.Void> extraInfo;
}

class CallbackResult extends ffi.Struct {
final class CallbackResult extends ffi.Struct {
external MutexLock lock;

external ConditionVariable cond;
Expand All @@ -1987,7 +1987,7 @@ typedef MutexLock = pthread_mutex_t;
typedef pthread_mutex_t = __darwin_pthread_mutex_t;
typedef __darwin_pthread_mutex_t = _opaque_pthread_mutex_t;

class _opaque_pthread_mutex_t extends ffi.Struct {
final class _opaque_pthread_mutex_t extends ffi.Struct {
@ffi.Long()
external int __sig;

Expand All @@ -1999,15 +1999,15 @@ typedef ConditionVariable = pthread_cond_t;
typedef pthread_cond_t = __darwin_pthread_cond_t;
typedef __darwin_pthread_cond_t = _opaque_pthread_cond_t;

class _opaque_pthread_cond_t extends ffi.Struct {
final class _opaque_pthread_cond_t extends ffi.Struct {
@ffi.Long()
external int __sig;

@ffi.Array.multi([40])
external ffi.Array<ffi.Char> __opaque;
}

class GlobalJniEnvStruct extends ffi.Struct {
final class GlobalJniEnvStruct extends ffi.Struct {
external ffi.Pointer<ffi.Void> reserved0;

external ffi.Pointer<ffi.Void> reserved1;
Expand Down
6 changes: 3 additions & 3 deletions jni/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# BSD-style license that can be found in the LICENSE file.

name: jni
description: Library to access JNI from dart and flutter
description: Library to access JNI from Dart and Flutter.
version: 0.6.0-wip.2
repository: https://github.com/dart-lang/jnigen/tree/main/jni

environment:
sdk: '>=2.17.1 <4.0.0'
sdk: '>=3.1.0 <4.0.0'
flutter: '>=2.11.0'

dependencies:
Expand All @@ -21,7 +21,7 @@ dependencies:

dev_dependencies:
## Pin ffigen version because we are depending on internal APIs.
ffigen: 7.2.10
ffigen: 8.0.2
flutter_lints: ^2.0.0
test: ^1.21.1
logging: ^1.1.1
Expand Down
2 changes: 1 addition & 1 deletion jnigen/android_test_runner/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: '>=2.19.6 <3.0.0'
sdk: '>=3.1.0 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down
2 changes: 1 addition & 1 deletion jnigen/example/in_app_java/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.17.6 <4.0.0"
sdk: ">=3.1.0 <4.0.0"

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion jnigen/example/kotlin_plugin/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.19.0-444.3.beta <4.0.0"
sdk: ">=3.1.0 <4.0.0"

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion jnigen/example/kotlin_plugin/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version: 0.0.1
publish_to: none

environment:
sdk: '>=2.19.0-444.3.beta <4.0.0'
sdk: '>=3.1.0 <4.0.0'
flutter: ">=1.17.0"

dependencies:
Expand Down
2 changes: 1 addition & 1 deletion jnigen/example/notification_plugin/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: '>=2.17.6 <4.0.0'
sdk: '>=3.1.0 <4.0.0'

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion jnigen/example/notification_plugin/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publish_to: none
homepage: https://github.com/dart-lang/jnigen

environment:
sdk: '>=2.17.6 <4.0.0'
sdk: '>=3.1.0 <4.0.0'
flutter: ">=2.11.0"

dependencies:
Expand Down
2 changes: 1 addition & 1 deletion jnigen/example/pdfbox_plugin/dart_example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publish_to: none
# homepage: https://www.example.com

environment:
sdk: '>=2.17.6 <4.0.0'
sdk: '>=3.1.0 <4.0.0'

dependencies:
path: ^1.8.0
Expand Down
2 changes: 1 addition & 1 deletion jnigen/example/pdfbox_plugin/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.17.6 <4.0.0"
sdk: ">=3.1.0 <4.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down
2 changes: 1 addition & 1 deletion jnigen/example/pdfbox_plugin/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish_to: none
homepage: https://github.com/dart-lang/jnigen

environment:
sdk: ">=2.17.6 <4.0.0"
sdk: ">=3.1.0 <4.0.0"
#flutter: ">=2.11.0"

dependencies:
Expand Down
2 changes: 1 addition & 1 deletion jnigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Experimental generator for FFI+JNI bindings.
repository: https://github.com/dart-lang/jnigen/tree/main/jnigen

environment:
sdk: '>=2.17.0 <4.0.0'
sdk: '>=3.1.0 <4.0.0'

dependencies:
json_annotation: ^4.8.0
Expand Down

0 comments on commit b8b19ec

Please sign in to comment.