< prev index next >
src/jdk.jextract/share/classes/com/sun/tools/jextract/parser/Parser.java
Print this page
*** 31,41 ****
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
- import java.util.function.Predicate;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import jdk.internal.clang.Cursor;
import jdk.internal.clang.CursorKind;
import jdk.internal.clang.Diagnostic;
--- 31,40 ----
*** 68,78 ****
public Parser(boolean supportMacros) {
this(new PrintWriter(System.out, true),
new PrintWriter(System.err, true), supportMacros);
}
! public List<HeaderTree> parse(Collection<Path> paths, Collection<String> args, Predicate<Cursor> include) {
final List<HeaderTree> headers = new ArrayList<>();
final Index index = LibClang.createIndex();
for (Path path : paths) {
logger.info(() -> {
StringBuilder sb = new StringBuilder(
--- 67,77 ----
public Parser(boolean supportMacros) {
this(new PrintWriter(System.out, true),
new PrintWriter(System.err, true), supportMacros);
}
! public List<HeaderTree> parse(Collection<Path> paths, Collection<String> args) {
final List<HeaderTree> headers = new ArrayList<>();
final Index index = LibClang.createIndex();
for (Path path : paths) {
logger.info(() -> {
StringBuilder sb = new StringBuilder(
*** 98,108 ****
supportMacros, args.toArray(new String[0]));
MacroParser macroParser = new MacroParser();
List<Tree> decls = new ArrayList<>();
tuCursor.children().
- filter(c -> include.test(c)).
peek(c -> logger.finest(
() -> "Cursor: " + c.spelling() + "@" + c.USR() + "?" + c.isDeclaration())).
forEach(c -> {
SourceLocation loc = c.getSourceLocation();
if (loc == null) {
--- 97,106 ----
*** 184,194 ****
Parser p = new Parser(true);
List<Path> paths = Arrays.stream(args).map(Paths::get).collect(Collectors.toList());
Path builtinInc = Paths.get(System.getProperty("java.home"), "conf", "jextract");
List<String> clangArgs = List.of("-I" + builtinInc);
! List<HeaderTree> headers = p.parse(paths, clangArgs, c->true);
TreePrinter printer = new TreePrinter();
for (HeaderTree ht : headers) {
ht.accept(printer, null);
}
}
--- 182,192 ----
Parser p = new Parser(true);
List<Path> paths = Arrays.stream(args).map(Paths::get).collect(Collectors.toList());
Path builtinInc = Paths.get(System.getProperty("java.home"), "conf", "jextract");
List<String> clangArgs = List.of("-I" + builtinInc);
! List<HeaderTree> headers = p.parse(paths, clangArgs);
TreePrinter printer = new TreePrinter();
for (HeaderTree ht : headers) {
ht.accept(printer, null);
}
}
< prev index next >