changeset 58906:fa2e9c39d939 foreign+vector

Automatic merge with foreign
author mcimadamore
date Wed, 10 Apr 2019 16:39:22 +0200
parents 35218d8b9881 f09783d2b640
children 619a2c6f3d02
files
diffstat 7 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jextract/share/classes/com/sun/tools/jextract/AsmCodeFactory.java	Wed Apr 10 14:59:50 2019 +0200
+++ b/src/jdk.jextract/share/classes/com/sun/tools/jextract/AsmCodeFactory.java	Wed Apr 10 16:39:22 2019 +0200
@@ -483,7 +483,7 @@
         MacroParser.Macro macro = macroTree.macro().get();
         log.print(Level.FINE, () -> "Adding macro " + name);
 
-        addConstant(global_cw, macroTree.location(), name, macro.type(), macro.value());
+        addConstant(global_cw, macroTree.location(), Utils.toMacroName(name), macro.type(), macro.value());
 
         return true;
     }
--- a/src/jdk.jextract/share/classes/com/sun/tools/jextract/AsmCodeFactoryExt.java	Wed Apr 10 14:59:50 2019 +0200
+++ b/src/jdk.jextract/share/classes/com/sun/tools/jextract/AsmCodeFactoryExt.java	Wed Apr 10 16:39:22 2019 +0200
@@ -200,7 +200,7 @@
             String name = macroTree.name();
             MacroParser.Macro macro = macroTree.macro().get();
             log.print(Level.FINE, () -> "Adding macro " + name);
-            addConstant(name, macro.type(), macro.value());
+            addConstant(Utils.toMacroName(name), macro.type(), macro.value());
             return true;
         } else {
             return false;
--- a/src/jdk.jextract/share/classes/com/sun/tools/jextract/JavaSourceFactory.java	Wed Apr 10 14:59:50 2019 +0200
+++ b/src/jdk.jextract/share/classes/com/sun/tools/jextract/JavaSourceFactory.java	Wed Apr 10 16:39:22 2019 +0200
@@ -382,7 +382,7 @@
         MacroParser.Macro macro = macroTree.macro().get();
         log.print(Level.FINE, () -> "Adding macro " + name);
 
-        addConstant(global_jsb, macroTree.location(), name, macro.type(), macro.value());
+        addConstant(global_jsb, macroTree.location(), Utils.toMacroName(name), macro.type(), macro.value());
 
         return true;
     }
--- a/src/jdk.jextract/share/classes/com/sun/tools/jextract/JavaSourceFactoryExt.java	Wed Apr 10 14:59:50 2019 +0200
+++ b/src/jdk.jextract/share/classes/com/sun/tools/jextract/JavaSourceFactoryExt.java	Wed Apr 10 16:39:22 2019 +0200
@@ -130,7 +130,7 @@
             String name = macroTree.name();
             MacroParser.Macro macro = macroTree.macro().get();
             log.print(Level.FINE, () -> "Adding macro " + name);
-            addConstant(header_jsb, name, macro.type(), macro.value());
+            addConstant(header_jsb, Utils.toMacroName(name), macro.type(), macro.value());
             return true;
         } else {
             return false;
--- a/src/jdk.jextract/share/classes/com/sun/tools/jextract/Utils.java	Wed Apr 10 14:59:50 2019 +0200
+++ b/src/jdk.jextract/share/classes/com/sun/tools/jextract/Utils.java	Wed Apr 10 16:39:22 2019 +0200
@@ -99,16 +99,24 @@
         return sb.toString();
     }
 
-    public static String toClassName(String cname) {
-        StringBuilder sb = new StringBuilder(cname.length());
-        cname = toJavaIdentifier(cname);
-        sb.append(cname);
-        if (SourceVersion.isKeyword(cname)) {
+    private static String toSafeName(String name) {
+        StringBuilder sb = new StringBuilder(name.length());
+        name = toJavaIdentifier(name);
+        sb.append(name);
+        if (SourceVersion.isKeyword(name)) {
             sb.append("$");
         }
         return sb.toString();
     }
 
+    public static String toClassName(String cname) {
+        return toSafeName(cname);
+    }
+
+    public static String toMacroName(String mname) {
+        return toSafeName(mname);
+    }
+
     public static String toInternalName(String pkg, String name, String... nested) {
         if ((pkg == null || pkg.isEmpty()) && nested == null) {
             return name;
--- a/test/jdk/com/sun/tools/jextract/test8221154/SrcGenTest.java	Wed Apr 10 14:59:50 2019 +0200
+++ b/test/jdk/com/sun/tools/jextract/test8221154/SrcGenTest.java	Wed Apr 10 16:39:22 2019 +0200
@@ -43,7 +43,7 @@
 
 /*
  * @test
- * @bug 8221154 8221228 8221336 8221419 8221443
+ * @bug 8221154 8221228 8221336 8221419 8221443 8222274
  * @summary jextract should generate java source files
  * @library ..
  * @run testng SrcGenTest
@@ -106,6 +106,7 @@
         ArrayList<String> javacOpts = new ArrayList<>();
         javacOpts.add("-d");
         javacOpts.add(outputDir.toString());
+        javacOpts.add(outputDir.resolve("clang_support").resolve("stdbool_h.java").toString());
         javacOpts.add(pkgDir.resolve(srcgentestIfaceName + ".java").toString());
         javacOpts.add(pkgDir.resolve(srcgentestForwarderName + ".java").toString());
         javacOpts.add(pkgDir.resolve("sub").resolve(dupnameIfaceName + ".java").toString());
@@ -116,6 +117,7 @@
         }
 
         // sanity checks for .class file existence
+        assertTrue(Files.isRegularFile(outputDir.resolve("clang_support").resolve("stdbool_h.class")));
         assertTrue(Files.isRegularFile(pkgDir.resolve(srcgentestIfaceName + ".class")));
         assertTrue(Files.isRegularFile(pkgDir.resolve(srcgentestPointName + ".class")));
         assertTrue(Files.isRegularFile(pkgDir.resolve(srcgentestColorName + ".class")));
--- a/test/jdk/com/sun/tools/jextract/test8221154/srcgentest.h	Wed Apr 10 14:59:50 2019 +0200
+++ b/test/jdk/com/sun/tools/jextract/test8221154/srcgentest.h	Wed Apr 10 16:39:22 2019 +0200
@@ -33,6 +33,11 @@
 #define EXPORT
 #endif
 
+// make sure that 'true', 'false' macros do not
+// generate non-compilable source!
+
+#include <stdbool.h>
+
 enum {
     R, G, B
 };