Skip to content

Commit

Permalink
Fixed jni issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches committed Jan 13, 2025
1 parent 4abff69 commit 58df689
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkgs/ffi/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ environment:

resolution: workspace
dev_dependencies:
dart_flutter_team_lints: ^2.0.0
dart_flutter_team_lints: ^3.2.0
test: ^1.21.2
2 changes: 1 addition & 1 deletion pkgs/ffigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
dev_dependencies:
async: ^2.11.0
coverage: ^1.11.0
dart_flutter_team_lints: ^2.0.0
dart_flutter_team_lints: ^3.2.0
json_schema: ^5.1.1
leak_tracker: ^10.0.7
objective_c: ^4.1.0
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jni/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies:
dev_dependencies:
dart_flutter_team_lints: ^3.2.0
## Pin ffigen version because we are depending on internal APIs.
ffigen: 8.0.2
ffigen: ^16.0.0
logging: ^1.2.0
test: ^1.25.8

Expand Down
7 changes: 4 additions & 3 deletions pkgs/jni/tool/generate_ffi_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'dart:io';

import 'package:args/args.dart';
import 'package:ffigen/ffigen.dart' as ffigen;
import 'package:ffigen/src/header_parser.dart' as ffigen;
import 'package:logging/logging.dart';

import 'wrapper_generators/generate_c_extensions.dart';
Expand Down Expand Up @@ -51,15 +52,15 @@ void main(List<String> args) {
});

logger.info('Generating C wrappers');
final minimalConfig = ffigen.Config.fromFile(File('ffigen_exts.yaml'));
final minimalConfig = ffigen.YamlConfig.fromFile(File('ffigen_exts.yaml'));
final minimalLibrary = ffigen.parse(minimalConfig);
generateCWrappers(minimalLibrary);

logger.info('Generating FFI bindings for package:jni');

final config = ffigen.Config.fromFile(File('ffigen.yaml'));
final config = ffigen.YamlConfig.fromFile(File('ffigen.yaml'));
final library = ffigen.parse(config);
final outputFile = File(config.output);
final outputFile = File(config.output.toFilePath());
library.generateFile(outputFile);

logger.info('Generating Dart extensions');
Expand Down
4 changes: 4 additions & 0 deletions pkgs/jni/tool/wrapper_generators/ffigen_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ final dummyWriter = Writer(
lookUpBindings: [],
ffiNativeBindings: [],
noLookUpBindings: [],
nativeEntryPoints: [],
className: 'unused',
silenceEnumWarning: true,
generateForPackageObjectiveC: false,
nativeAssetId: null,
);

/// Find compound having [name] in [library].
Expand Down
4 changes: 2 additions & 2 deletions pkgs/jni/tool/wrapper_generators/generate_c_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ String getWrapperFuncName(String name) {
}

// Returns declaration of function field in GlobalJniEnv struct
String getFunctionFieldDecl(Member field, {required bool isField}) {
String getFunctionFieldDecl(CompoundMember field, {required bool isField}) {
final fieldType = field.type;
if (fieldType is PointerType && fieldType.child is NativeFunc) {
final nativeFunc = fieldType.child as NativeFunc;
Expand Down Expand Up @@ -226,7 +226,7 @@ const _noCheckException = {
'ExceptionDescribe',
};

String? getWrapperFunc(Member field) {
String? getWrapperFunc(CompoundMember field) {
final fieldType = field.type;
if (fieldType is PointerType && fieldType.child is NativeFunc) {
final functionType = (fieldType.child as NativeFunc).type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ String getCheckedGetter(Type returnType) {
}

String? getGlobalEnvExtensionFunction(
Member field,
CompoundMember field,
Type? checkedReturnType, {
required bool isLeaf,
}) {
Expand Down Expand Up @@ -276,7 +276,7 @@ class GlobalJniEnv {
}

String? getFunctionPointerExtensionFunction(
Member field, {
CompoundMember field, {
bool indirect = false,
bool implicitThis = false,
required bool isLeaf,
Expand Down

0 comments on commit 58df689

Please sign in to comment.