< prev index next >
src/jdk.jextract/share/classes/com/sun/tools/jextract/HeaderFile.java
Print this page
*** 26,71 ****
import jdk.internal.clang.CursorKind;
import jdk.internal.clang.Type;
import jdk.internal.clang.TypeKind;
import java.nio.file.Path;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import java.util.List;
/**
* This class represent a native code header file
*/
public final class HeaderFile {
final Path path;
final String pkgName;
final String clsName;
! final TypeDictionary dict;
// The top header file cause this file to be parsed
! HeaderFile main;
! CodeFactory cf;
! List<String> libraries;
! List<String> libraryPaths;
private final AtomicInteger serialNo;
private final Context.SymbolChecker symChecker;
! final Logger logger = Logger.getLogger(getClass().getPackage().getName());
! HeaderFile(Path path, String pkgName, String clsName, HeaderFile main, Context.SymbolChecker symChecker) {
this.path = path;
this.pkgName = pkgName;
this.clsName = clsName;
! dict = TypeDictionary.of(pkgName);
serialNo = new AtomicInteger();
this.main = main == null ? this : main;
this.symChecker = symChecker;
}
void useLibraries(List<String> libraries, List<String> libraryPaths) {
! this.libraries = libraries;
! this.libraryPaths = libraryPaths;
}
/**
* Call this function to enable code generation for this HeaderFile.
* This function should only be called once to turn on code generation and before process any cursor.
--- 26,78 ----
import jdk.internal.clang.CursorKind;
import jdk.internal.clang.Type;
import jdk.internal.clang.TypeKind;
import java.nio.file.Path;
+ import java.util.Collections;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import java.util.List;
/**
* This class represent a native code header file
*/
public final class HeaderFile {
+ private final Context ctx;
final Path path;
final String pkgName;
final String clsName;
! private final TypeDictionary dict;
// The top header file cause this file to be parsed
! private HeaderFile main;
! private CodeFactory cf;
! List<String> libraries; // immutable
! List<String> libraryPaths; // immutable
private final AtomicInteger serialNo;
private final Context.SymbolChecker symChecker;
! private final Logger logger = Logger.getLogger(getClass().getPackage().getName());
! HeaderFile(Context ctx, Path path, String pkgName, String clsName, HeaderFile main, Context.SymbolChecker symChecker) {
! this.ctx = ctx;
this.path = path;
this.pkgName = pkgName;
this.clsName = clsName;
! dict = ctx.typeDictionaryFor(pkgName);
serialNo = new AtomicInteger();
this.main = main == null ? this : main;
this.symChecker = symChecker;
}
void useLibraries(List<String> libraries, List<String> libraryPaths) {
! this.libraries = Collections.unmodifiableList(libraries);
! this.libraryPaths = Collections.unmodifiableList(libraryPaths);
! }
!
! CodeFactory getCodeFactory() {
! return cf;
}
/**
* Call this function to enable code generation for this HeaderFile.
* This function should only be called once to turn on code generation and before process any cursor.
*** 74,84 ****
void useCodeFactory(CodeFactory cf) {
if (null != this.cf) {
logger.config(() -> "CodeFactory had been initialized for " + path);
// Diagnosis code
if (Main.DEBUG) {
! new Throwable().printStackTrace(Context.getInstance().err);
}
} else {
this.cf = cf;
}
}
--- 81,91 ----
void useCodeFactory(CodeFactory cf) {
if (null != this.cf) {
logger.config(() -> "CodeFactory had been initialized for " + path);
// Diagnosis code
if (Main.DEBUG) {
! new Throwable().printStackTrace(ctx.err);
}
} else {
this.cf = cf;
}
}
*** 98,108 ****
if (symChecker != null) {
if (t.kind() == TypeKind.FunctionProto ||
t.kind() == TypeKind.FunctionNoProto) {
String name = c.spelling();
if (!symChecker.lookup(name)) {
! Context.getInstance().err.println(Main.format("warn.symbol.not.found", name));
}
}
}
JType jt = dict.computeIfAbsent(t, type -> {
logger.fine(() -> "PH: Compute type for " + type.spelling());
--- 105,115 ----
if (symChecker != null) {
if (t.kind() == TypeKind.FunctionProto ||
t.kind() == TypeKind.FunctionNoProto) {
String name = c.spelling();
if (!symChecker.lookup(name)) {
! ctx.err.println(Main.format("warn.symbol.not.found", name));
}
}
}
JType jt = dict.computeIfAbsent(t, type -> {
logger.fine(() -> "PH: Compute type for " + type.spelling());
< prev index next >