< prev index next >

src/jdk.jextract/share/classes/com/sun/tools/jextract/HeaderFile.java

Print this page




  27 import jdk.internal.clang.Type;
  28 import jdk.internal.clang.TypeKind;
  29 
  30 import java.nio.file.Path;
  31 import java.util.concurrent.atomic.AtomicInteger;
  32 import java.util.logging.Logger;
  33 import java.util.List;
  34 
  35 /**
  36  * This class represent a native code header file
  37  */
  38 public final class HeaderFile {
  39     final Path path;
  40     final String pkgName;
  41     final String clsName;
  42     final TypeDictionary dict;
  43     // The top header file cause this file to be parsed
  44     HeaderFile main;
  45     CodeFactory cf;
  46     List<String> libraries;

  47 
  48     private final AtomicInteger serialNo;
  49     final Logger logger = Logger.getLogger(getClass().getPackage().getName());
  50 
  51     HeaderFile(Path path, String pkgName, String clsName, HeaderFile main) {
  52         this.path = path;
  53         this.pkgName = pkgName;
  54         this.clsName = clsName;
  55         dict = TypeDictionary.of(pkgName);
  56         serialNo = new AtomicInteger();
  57         this.main = main == null ? this : main;
  58     }
  59 
  60     void useLibraries(List<String> libraries) {
  61         this.libraries = libraries;

  62     }
  63 
  64     /**
  65      * Call this function to enable code generation for this HeaderFile.
  66      * This function should only be called once to turn on code generation and before process any cursor.
  67      * @param cf The CodeFactory used to generate code
  68      */
  69     void useCodeFactory(CodeFactory cf) {
  70         if (null != this.cf) {
  71             logger.config(() -> "CodeFactory had been initialized for " + path);
  72             // Diagnosis code
  73             if (Main.DEBUG) {
  74                 new Throwable().printStackTrace(System.err);
  75             }
  76         } else {
  77             this.cf = cf;
  78         }
  79     }
  80 
  81     @Override




  27 import jdk.internal.clang.Type;
  28 import jdk.internal.clang.TypeKind;
  29 
  30 import java.nio.file.Path;
  31 import java.util.concurrent.atomic.AtomicInteger;
  32 import java.util.logging.Logger;
  33 import java.util.List;
  34 
  35 /**
  36  * This class represent a native code header file
  37  */
  38 public final class HeaderFile {
  39     final Path path;
  40     final String pkgName;
  41     final String clsName;
  42     final TypeDictionary dict;
  43     // The top header file cause this file to be parsed
  44     HeaderFile main;
  45     CodeFactory cf;
  46     List<String> libraries;
  47     List<String> libraryPaths;
  48 
  49     private final AtomicInteger serialNo;
  50     final Logger logger = Logger.getLogger(getClass().getPackage().getName());
  51 
  52     HeaderFile(Path path, String pkgName, String clsName, HeaderFile main) {
  53         this.path = path;
  54         this.pkgName = pkgName;
  55         this.clsName = clsName;
  56         dict = TypeDictionary.of(pkgName);
  57         serialNo = new AtomicInteger();
  58         this.main = main == null ? this : main;
  59     }
  60 
  61     void useLibraries(List<String> libraries, List<String> libraryPaths) {
  62         this.libraries = libraries;
  63         this.libraryPaths = libraryPaths;
  64     }
  65 
  66     /**
  67      * Call this function to enable code generation for this HeaderFile.
  68      * This function should only be called once to turn on code generation and before process any cursor.
  69      * @param cf The CodeFactory used to generate code
  70      */
  71     void useCodeFactory(CodeFactory cf) {
  72         if (null != this.cf) {
  73             logger.config(() -> "CodeFactory had been initialized for " + path);
  74             // Diagnosis code
  75             if (Main.DEBUG) {
  76                 new Throwable().printStackTrace(System.err);
  77             }
  78         } else {
  79             this.cf = cf;
  80         }
  81     }
  82 
  83     @Override


< prev index next >