Skip to content

Commit

Permalink
Use infoMap instead
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed May 25, 2024
1 parent c52cc8a commit 9b5b017
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/bytedeco/javacpp/tools/InfoMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,23 @@ public class InfoMap extends HashMap<String,List<Info>> {
.put(new Info("std::vector").annotations("@StdVector"))

.put(new Info("abstract").javaNames("_abstract"))
.put(new Info("assert").javaNames("_assert"))
.put(new Info("boolean").javaNames("_boolean"))
.put(new Info("byte").javaNames("_byte"))
.put(new Info("extends").javaNames("_extends"))
.put(new Info("final").javaNames("_final"))
.put(new Info("finally").javaNames("_finally"))
.put(new Info("implements").javaNames("_implements"))
.put(new Info("import").javaNames("_import"))
.put(new Info("instanceof").javaNames("_instanceof"))
.put(new Info("interface").javaNames("_interface"))
.put(new Info("native").javaNames("_native"))
.put(new Info("null").javaNames("_null"))
.put(new Info("package").javaNames("_package"))
.put(new Info("strictfp").javaNames("_strictfp"))
.put(new Info("super").javaNames("_super"))
.put(new Info("synchronized").javaNames("_synchronized"))
.put(new Info("throws").javaNames("_throws"))
.put(new Info("transient").javaNames("_transient"))

.put(new Info("operator ->").javaNames("access"))
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,6 @@ public Parser(Logger logger, Properties properties, String encoding, String line
this.lineSeparator = p.lineSeparator;
}

/** Reserved keywords than cannot be used for Java identifier, but could be for C++ identifiers. */
static final HashSet<String> JAVA_KEYWORDS = new HashSet<>();
static {
JAVA_KEYWORDS.addAll(Arrays.asList(new String[] {
"abstract", "assert", "boolean", "byte", "extends", "final", "finally", "implements", "import",
"instanceof", "interface", "native", "package", "strictfp", "super", "synchronized", "throws", "transient"
}));
}

final Logger logger;
final Properties properties;
final String encoding;
Expand Down Expand Up @@ -1671,8 +1662,6 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole
dcl.javaName = info.javaNames[0];
}

if (JAVA_KEYWORDS.contains(dcl.javaName)) dcl.javaName += '_';

if (info != null && info.annotations != null) {
for (String s : info.annotations) {
if (!type.annotations.contains(s)) {
Expand Down Expand Up @@ -1835,8 +1824,8 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole
}
}

// annotate with @Name if the Java name doesn't match with the C++ name, and if we are not parsing a function parameter
if (dcl.cppName != null && defaultName == null) {
// annotate with @Name if the Java name doesn't match with the C++ name
if (dcl.cppName != null) {
String localName = dcl.cppName;
if (context.namespace != null && localName.startsWith(context.namespace + "::")) {
localName = dcl.cppName.substring(context.namespace.length() + 2);
Expand Down

0 comments on commit 9b5b017

Please sign in to comment.