< prev index next >

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

Print this page




  68  */
  69 public final class Context {
  70     // package name to TypeDictionary
  71     private final Map<String, TypeDictionary> tdMap;
  72     // The folder path mapping to package name
  73     private final Map<Path, String> pkgMap;
  74     // The header file parsed
  75     private final Map<Path, HeaderFile> headerMap;
  76     // The args for parsing C
  77     private final List<String> clangArgs;
  78     // The set of source header files
  79     private final Set<Path>  sources;
  80     // The list of library names
  81     private final List<String> libraryNames;
  82     // The list of library paths
  83     private final List<String> libraryPaths;
  84     // The list of library paths for link checks
  85     private final List<String> linkCheckPaths;
  86     // Symbol patterns to be excluded
  87     private final List<Pattern> excludeSymbols;


  88 
  89     final PrintWriter out;
  90     final PrintWriter err;
  91 
  92     private Predicate<String> symChecker;
  93     private Predicate<String> symFilter;
  94 
  95     private final Parser parser;
  96 
  97     private final static String defaultPkg = "jextract.dump";
  98     final Logger logger = Logger.getLogger(getClass().getPackage().getName());
  99 
 100     public Context(PrintWriter out, PrintWriter err) {
 101         this.tdMap = new HashMap<>();
 102         this.pkgMap = new HashMap<>();
 103         this.headerMap = new HashMap<>();
 104         this.clangArgs = new ArrayList<>();
 105         this.sources = new TreeSet<>();
 106         this.libraryNames = new ArrayList<>();
 107         this.libraryPaths = new ArrayList<>();


 127     public void addSource(Path path) {
 128         sources.add(path);
 129     }
 130 
 131     void addLibraryName(String name) {
 132         libraryNames.add(name);
 133     }
 134 
 135     void addLibraryPath(String path) {
 136         libraryPaths.add(path);
 137     }
 138 
 139     void addLinkCheckPath(String path) {
 140         linkCheckPaths.add(path);
 141     }
 142 
 143     void addExcludeSymbols(String pattern) {
 144         excludeSymbols.add(Pattern.compile(pattern));
 145     }
 146 








 147     // return the absolute path of the library of given name by searching
 148     // in the given array of paths.
 149     private static Optional<Path> findLibraryPath(Path[] paths, String libName) {
 150          return Arrays.stream(paths).
 151               map(p -> p.resolve(System.mapLibraryName(libName))).
 152               filter(Files::isRegularFile).map(Path::toAbsolutePath).findFirst();
 153     }
 154 
 155     /*
 156      * Load the specified shared libraries from the specified paths.
 157      *
 158      * @param lookup Lookup object of the caller.
 159      * @param pathStrs array of paths to load the shared libraries from.
 160      * @param names array of shared library names.
 161      */
 162     // used by jextract tool to load libraries for symbol checks.
 163     public static Library[] loadLibraries(Lookup lookup, String[] pathStrs, String[] names) {
 164         if (pathStrs == null || pathStrs.length == 0) {
 165             return Arrays.stream(names).map(
 166                 name -> Libraries.loadLibrary(lookup, name)).toArray(Library[]::new);




  68  */
  69 public final class Context {
  70     // package name to TypeDictionary
  71     private final Map<String, TypeDictionary> tdMap;
  72     // The folder path mapping to package name
  73     private final Map<Path, String> pkgMap;
  74     // The header file parsed
  75     private final Map<Path, HeaderFile> headerMap;
  76     // The args for parsing C
  77     private final List<String> clangArgs;
  78     // The set of source header files
  79     private final Set<Path>  sources;
  80     // The list of library names
  81     private final List<String> libraryNames;
  82     // The list of library paths
  83     private final List<String> libraryPaths;
  84     // The list of library paths for link checks
  85     private final List<String> linkCheckPaths;
  86     // Symbol patterns to be excluded
  87     private final List<Pattern> excludeSymbols;
  88     // generate static forwarder class or not?
  89     private boolean genStaticForwarder;
  90 
  91     final PrintWriter out;
  92     final PrintWriter err;
  93 
  94     private Predicate<String> symChecker;
  95     private Predicate<String> symFilter;
  96 
  97     private final Parser parser;
  98 
  99     private final static String defaultPkg = "jextract.dump";
 100     final Logger logger = Logger.getLogger(getClass().getPackage().getName());
 101 
 102     public Context(PrintWriter out, PrintWriter err) {
 103         this.tdMap = new HashMap<>();
 104         this.pkgMap = new HashMap<>();
 105         this.headerMap = new HashMap<>();
 106         this.clangArgs = new ArrayList<>();
 107         this.sources = new TreeSet<>();
 108         this.libraryNames = new ArrayList<>();
 109         this.libraryPaths = new ArrayList<>();


 129     public void addSource(Path path) {
 130         sources.add(path);
 131     }
 132 
 133     void addLibraryName(String name) {
 134         libraryNames.add(name);
 135     }
 136 
 137     void addLibraryPath(String path) {
 138         libraryPaths.add(path);
 139     }
 140 
 141     void addLinkCheckPath(String path) {
 142         linkCheckPaths.add(path);
 143     }
 144 
 145     void addExcludeSymbols(String pattern) {
 146         excludeSymbols.add(Pattern.compile(pattern));
 147     }
 148 
 149     void setGenStaticForwarder(boolean flag) {
 150         this.genStaticForwarder = flag;
 151     }
 152 
 153     boolean getGenStaticForwarder() {
 154         return genStaticForwarder;
 155     }
 156 
 157     // return the absolute path of the library of given name by searching
 158     // in the given array of paths.
 159     private static Optional<Path> findLibraryPath(Path[] paths, String libName) {
 160          return Arrays.stream(paths).
 161               map(p -> p.resolve(System.mapLibraryName(libName))).
 162               filter(Files::isRegularFile).map(Path::toAbsolutePath).findFirst();
 163     }
 164 
 165     /*
 166      * Load the specified shared libraries from the specified paths.
 167      *
 168      * @param lookup Lookup object of the caller.
 169      * @param pathStrs array of paths to load the shared libraries from.
 170      * @param names array of shared library names.
 171      */
 172     // used by jextract tool to load libraries for symbol checks.
 173     public static Library[] loadLibraries(Lookup lookup, String[] pathStrs, String[] names) {
 174         if (pathStrs == null || pathStrs.length == 0) {
 175             return Arrays.stream(names).map(
 176                 name -> Libraries.loadLibrary(lookup, name)).toArray(Library[]::new);


< prev index next >