< prev index next >

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

Print this page




  95 
  96     private int serialNo() {
  97         return serialNo.incrementAndGet();
  98     }
  99 
 100     void processCursor(Cursor c, HeaderFile main, boolean isBuiltIn) {
 101         if (c.isDeclaration()) {
 102             Type t = c.type();
 103             if (t.kind() == TypeKind.FunctionProto ||
 104                 t.kind() == TypeKind.FunctionNoProto) {
 105                 String name = c.spelling();
 106 
 107                 if (ctx.isSymbolExcluded(name)) {
 108                     return;
 109                 }
 110 
 111                 if (!ctx.isSymbolFound(name)) {
 112                     ctx.err.println(Main.format("warn.symbol.not.found", name));
 113                 }
 114             }














 115             JType jt = dict.computeIfAbsent(t, type -> {
 116                 logger.fine(() -> "PH: Compute type for " + type.spelling());
 117                 return define(type);
 118             });
 119             assert (jt instanceof JType2);
 120             // Only main file can define interface
 121             if (cf != null && this.main == main) {
 122                 cf.addType(jt, c);
 123             }
 124         } else if (c.isPreprocessing()) {
 125             if (cf != null && c.kind() == CursorKind.MacroDefinition && !isBuiltIn && this.main == main) {
 126                 cf.addMacro(c);
 127             }
 128         }
 129     }
 130 
 131     JType globalLookup(Type type) {
 132         JType jt;
 133         try {
 134             jt = dict.lookup(type);




  95 
  96     private int serialNo() {
  97         return serialNo.incrementAndGet();
  98     }
  99 
 100     void processCursor(Cursor c, HeaderFile main, boolean isBuiltIn) {
 101         if (c.isDeclaration()) {
 102             Type t = c.type();
 103             if (t.kind() == TypeKind.FunctionProto ||
 104                 t.kind() == TypeKind.FunctionNoProto) {
 105                 String name = c.spelling();
 106 
 107                 if (ctx.isSymbolExcluded(name)) {
 108                     return;
 109                 }
 110 
 111                 if (!ctx.isSymbolFound(name)) {
 112                     ctx.err.println(Main.format("warn.symbol.not.found", name));
 113                 }
 114             }
 115 
 116             // C structs and unions can have nested structs, unions and enums.
 117             if (c.kind() == CursorKind.StructDecl ||
 118                 c.kind() == CursorKind.UnionDecl) {
 119                 c.children()
 120                     .filter(c1 -> c1.isDeclaration() &&
 121                         (c1.kind() == CursorKind.StructDecl ||
 122                         c1.kind() == CursorKind.UnionDecl ||
 123                         c1.kind() == CursorKind.EnumDecl))
 124                     .peek(c1 -> logger.finest(
 125                         () -> "Cursor: " + c1.spelling() + "@" + c1.USR() + "?" + c1.isDeclaration()))
 126                     .forEach(c1 -> processCursor(c1, main, isBuiltIn));
 127             }
 128 
 129             JType jt = dict.computeIfAbsent(t, type -> {
 130                 logger.fine(() -> "PH: Compute type for " + type.spelling());
 131                 return define(type);
 132             });
 133             assert (jt instanceof JType2);
 134             // Only main file can define interface
 135             if (cf != null && this.main == main) {
 136                 cf.addType(jt, c);
 137             }
 138         } else if (c.isPreprocessing()) {
 139             if (cf != null && c.kind() == CursorKind.MacroDefinition && !isBuiltIn && this.main == main) {
 140                 cf.addMacro(c);
 141             }
 142         }
 143     }
 144 
 145     JType globalLookup(Type type) {
 146         JType jt;
 147         try {
 148             jt = dict.lookup(type);


< prev index next >