Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
applying dart format and analyze
Browse files Browse the repository at this point in the history
marshelino-maged committed Dec 6, 2024
1 parent 2218500 commit 0e8eed5
Showing 3 changed files with 31 additions and 30 deletions.
39 changes: 19 additions & 20 deletions pkgs/jnigen/lib/src/config/config_types.dart
Original file line number Diff line number Diff line change
@@ -266,25 +266,24 @@ void _validateClassName(String className) {

/// Configuration for jnigen binding generation.
class Config {
Config({
required this.outputConfig,
required this.classes,
this.experiments,
this.exclude,
this.sourcePath,
this.classPath,
this.preamble,
this.customClassBody,
this.androidSdkConfig,
this.mavenDownloads,
this.summarizerOptions,
this.nonNullAnnotations,
this.nullableAnnotations,
this.logLevel = Level.INFO,
this.dumpJsonTo,
this.imports,
this.visitors
}) {
Config(
{required this.outputConfig,
required this.classes,
this.experiments,
this.exclude,
this.sourcePath,
this.classPath,
this.preamble,
this.customClassBody,
this.androidSdkConfig,
this.mavenDownloads,
this.summarizerOptions,
this.nonNullAnnotations,
this.nullableAnnotations,
this.logLevel = Level.INFO,
this.dumpJsonTo,
this.imports,
this.visitors}) {
for (final className in classes) {
_validateClassName(className);
}
@@ -351,7 +350,7 @@ class Config {
/// Used for testing package:jnigen.
final Map<String, String>? customClassBody;

// User custom visitors to modify the generated bindings.
// User custom visitors.
List<j_ast.Visitor>? visitors;

Future<void> importClasses() async {
16 changes: 9 additions & 7 deletions pkgs/jnigen/lib/src/elements/j_elements.dart
Original file line number Diff line number Diff line change
@@ -25,17 +25,19 @@ class Classes implements Element {
classDecl.accept(visitor);
}
}

void let(void Function(dynamic userClasses) param0) {}
}

class ClassDecl implements Element {
ClassDecl(this._classDecl): binaryName = _classDecl.binaryName;
ClassDecl(this._classDecl) : binaryName = _classDecl.binaryName;
final ast.ClassDecl _classDecl;

// Ex: com.x.Foo.
final String binaryName;

bool get isExcluded => _classDecl.isExcluded;
set isExcluded(bool value) => _classDecl.isExcluded = value;
set isExcluded(bool value) => _classDecl.isExcluded = value;

@override
void accept(Visitor visitor) {
@@ -54,11 +56,11 @@ class Method implements Element {
Method(this._method);

final ast.Method _method;

String get name => _method.name;

bool get isExcluded => _method.isExcluded;
set isExcluded(bool value) => _method.isExcluded = value;
set isExcluded(bool value) => _method.isExcluded = value;

@override
void accept(Visitor visitor) {
@@ -68,14 +70,14 @@ class Method implements Element {

class Field implements Element {
Field(this._field);

final ast.Field _field;

String get name => _field.name;

bool get isExcluded => _field.isExcluded;
set isExcluded(bool value) => _field.isExcluded = value;
set isExcluded(bool value) => _field.isExcluded = value;

@override
void accept(Visitor visitor) {
visitor.visitField(this);
6 changes: 3 additions & 3 deletions pkgs/jnigen/lib/src/generate_bindings.dart
Original file line number Diff line number Diff line change
@@ -39,9 +39,9 @@ Future<void> generateJniBindings(Config config) async {
log.fatal(e.message);
}

config.visitors?.forEach((visitor){
j_ast.Classes(classes).accept(visitor);
});
final userClasses = j_ast.Classes(classes);
config.visitors?.forEach(userClasses.accept);

classes.accept(Excluder(config));
classes.accept(KotlinProcessor());
await classes.accept(Linker(config));

0 comments on commit 0e8eed5

Please sign in to comment.