Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HosseinYousefi committed Feb 29, 2024
1 parent f6b527a commit 1b9d189
Show file tree
Hide file tree
Showing 16 changed files with 9,468 additions and 9,010 deletions.
3,521 changes: 1,822 additions & 1,699 deletions pkgs/jnigen/example/in_app_java/lib/android_utils.dart

Large diffs are not rendered by default.

1,721 changes: 865 additions & 856 deletions pkgs/jnigen/example/in_app_java/src/android_utils/android_utils.c

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ public static void main(String[] args) throws FileNotFoundException {

switch (options.backend) {
case DOCLET:
JsonWriter.writeJSON(runDoclet(javaDoc, sourceFiles, options), output);
JsonWriter.writeJSON(runDoclet(javaDoc, sourceFiles, options).values(), output);
break;
case ASM:
JsonWriter.writeJSON(AsmSummarizer.run(classStreamProviders), output);
JsonWriter.writeJSON(AsmSummarizer.run(classStreamProviders).values(), output);
break;
case AUTO:
Map<String, ClassDecl> classes = new HashMap<>();
Map<String, ClassDecl> classes = new LinkedHashMap<>();
// Preferring DOCLET as the source of summary a class exists in
// both ASM and DOCLET.
if (!classStreamProviders.isEmpty()) {
Expand All @@ -131,7 +131,7 @@ public static void main(String[] args) throws FileNotFoundException {
if (!sourceFiles.isEmpty()) {
classes.putAll(runDoclet(javaDoc, sourceFiles, options));
}
JsonWriter.writeJSON(classes, output);
JsonWriter.writeJSON(classes.values(), output);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Map<String, ClassDecl> getVisited() {
return visited;
}

Map<String, ClassDecl> visited = new HashMap<>();
Map<String, ClassDecl> visited = new LinkedHashMap<>();
Stack<ClassDecl> visiting = new Stack<>();

/// Actual access for the inner classes as originally defined.
Expand Down Expand Up @@ -65,8 +65,8 @@ public void visitInnerClass(String name, String outerName, String innerName, int
actualAccess.put(binaryName, access);

if (visited.containsKey(binaryName)) {
// If the order of visit is outer first inner second.
// We still want to correct the modifiers.
// If the order of visit is outerClass-first, innerClass-second then only
// correct the modifiers.
visited.get(binaryName).modifiers = TypeUtils.access(access);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static class SummaryCollector {

public class SummarizingScanner extends ElementScanner9<Void, SummaryCollector> {
List<Package> packages = new ArrayList<>();
Map<String, ClassDecl> types = new HashMap<>();
Map<String, ClassDecl> types = new LinkedHashMap<>();
ElementBuilders builders = new ElementBuilders(utils);

// Each element in collector is a stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import com.github.dart_lang.jnigen.apisummarizer.elements.ClassDecl;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
import java.util.Collection;

public class JsonWriter {
public static void writeJSON(Map<String, ClassDecl> classes, OutputStream output) {
public static void writeJSON(Collection<ClassDecl> classes, OutputStream output) {
var mapper = new ObjectMapper();
Log.info("Writing JSON for %d classes", classes.size());
mapper.enable(SerializationFeature.INDENT_OUTPUT);
Expand Down
10 changes: 7 additions & 3 deletions pkgs/jnigen/lib/src/elements/elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ class Classes implements Element<Classes> {

final Map<String, ClassDecl> decls;

factory Classes.fromJson(Map<String, dynamic> json) {
return Classes(
json.map((key, value) => MapEntry(key, ClassDecl.fromJson(value))));
factory Classes.fromJson(List<dynamic> json) {
final decls = <String, ClassDecl>{};
for (final declJson in json) {
final classDecl = ClassDecl.fromJson(declJson);
decls[classDecl.binaryName] = classDecl;
}
return Classes(decls);
}

@override
Expand Down
Loading

0 comments on commit 1b9d189

Please sign in to comment.