< prev index next >
src/jdk.jextract/share/classes/com/sun/tools/jextract/Context.java
Print this page
*** 50,61 ****
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import com.sun.tools.jextract.parser.Parser;
! import com.sun.tools.jextract.tree.Tree;
import com.sun.tools.jextract.tree.HeaderTree;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
import static java.nio.file.StandardOpenOption.WRITE;
--- 50,62 ----
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import com.sun.tools.jextract.parser.Parser;
! import com.sun.tools.jextract.tree.FunctionTree;
import com.sun.tools.jextract.tree.HeaderTree;
+ import com.sun.tools.jextract.tree.Tree;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
import static java.nio.file.StandardOpenOption.WRITE;
*** 339,377 ****
public void parse() {
parse(header -> new AsmCodeFactory(this, header));
}
! private boolean filterCursor(Cursor c) {
! if (c.isDeclaration()) {
! Type type = c.type();
! if (type.kind() == TypeKind.FunctionProto ||
! type.kind() == TypeKind.FunctionNoProto) {
! String name = c.spelling();
!
if (isSymbolExcluded(name)) {
return false;
}
! if (!isSymbolFound(name)) {
err.println(Main.format("warn.symbol.not.found", name));
}
! }
! }
return true;
}
public void parse(Function<HeaderFile, AsmCodeFactory> fn) {
initSymChecker();
initSymFilter();
! List<HeaderTree> headers = parser.parse(sources, clangArgs, this::filterCursor);
processHeaders(headers, fn);
}
private void processHeaders(List<HeaderTree> headers, Function<HeaderFile, AsmCodeFactory> fn) {
! headers.forEach(header -> {
HeaderFile hf = headerMap.computeIfAbsent(header.path(), p -> getHeaderFile(p, null));
hf.useLibraries(libraryNames, libraryPaths);
hf.useCodeFactory(fn.apply(hf));
logger.info(() -> "Processing header file " + header.path());
--- 340,377 ----
public void parse() {
parse(header -> new AsmCodeFactory(this, header));
}
! private boolean symbolFilter(Tree tree) {
! String name = tree.name();
if (isSymbolExcluded(name)) {
return false;
}
! // check for function symbols in libraries & warn missing symbols
! if (tree instanceof FunctionTree && !isSymbolFound(name)) {
err.println(Main.format("warn.symbol.not.found", name));
}
!
return true;
}
public void parse(Function<HeaderFile, AsmCodeFactory> fn) {
initSymChecker();
initSymFilter();
! List<HeaderTree> headers = parser.parse(sources, clangArgs);
processHeaders(headers, fn);
}
private void processHeaders(List<HeaderTree> headers, Function<HeaderFile, AsmCodeFactory> fn) {
! headers.stream().
! map((new TreeFilter(this::symbolFilter))::transform).
! map((new TypedefHandler())::transform).
! map((new EmptyNameHandler())::transform).
! forEach(header -> {
HeaderFile hf = headerMap.computeIfAbsent(header.path(), p -> getHeaderFile(p, null));
hf.useLibraries(libraryNames, libraryPaths);
hf.useCodeFactory(fn.apply(hf));
logger.info(() -> "Processing header file " + header.path());
< prev index next >