Skip to content

Commit

Permalink
Update CHANGELOG.md and fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Dec 31, 2023
1 parent 95ff339 commit 7395919
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Improve `Parser` capabilities for `operator` and function templates ([pull #732](https://github.com/bytedeco/javacpp/pull/732))
* Fix `Parser` failing on nested initializer lists and on attributes found inside `enum` declarations
* Fix `Parser` for basic containers like `std::optional<std::pair<int,int> >` ([issue #718](https://github.com/bytedeco/javacpp/issues/718))
* Add support for `std::basic_string` basic container ([issue bytedeco/javacpp-presets#1311](https://github.com/bytedeco/javacpp-presets/issues/1311))
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/bytedeco/javacpp/tools/InfoMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class InfoMap extends HashMap<String,List<Info>> {
"std::function", "std::basic_string"))
.put(new Info("basic/types").cppTypes("signed", "unsigned", "char", "short", "int", "long", "bool", "float", "double",
"__int8", "__int16", "__int32", "__int64", "_Bool", "_Complex", "_Imaginary", "complex", "imaginary"))
.put(new Info("deprecated").annotations("@Deprecated"))
.put(new Info("noexcept").annotations("@NoException(true)"))

.put(new Info("__COUNTER__").cppText("#define __COUNTER__ 0"))
Expand Down Expand Up @@ -192,10 +191,13 @@ String normalize(String name, boolean unconst, boolean untemplate) {
String lastComp = comps.get(paramsIdx - 1);
comps.set(paramsIdx - 1, Templates.strip(lastComp));
name = comps.get(0);
for (int i = 1; i < paramsIdx; i++)
for (int i = 1; i < paramsIdx; i++) {
name += "::" + comps.get(i);
}
name += comps.get(paramsIdx);
if (name.isEmpty()) return name;
if (name.isEmpty()) {
return name;
}
}
boolean foundConst = false, simpleType = true;
String prefix = null;
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/org/bytedeco/javacpp/tools/TemplateMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ Type get(String key) {

@Override
public String toString() {
String res = "<";
for (Map.Entry<String, Type> e: entrySet()) {
if (res.length() > 1) res += ",";
String s = "<";
for (Map.Entry<String, Type> e : entrySet()) {
if (s.length() > 1) {
s += ",";
}
Type t = e.getValue();
if (t == null)
res += e.getKey();
else
res += t.cppName;
s += t != null ? t.cppName : e.getKey();
}
if (s.endsWith(">")) {
s += " ";
}
if (res.charAt(res.length()-1) == '>') res += " ";
return res + ">";
return s + ">";
}
}
14 changes: 10 additions & 4 deletions src/main/java/org/bytedeco/javacpp/tools/Templates.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static boolean notExists(String s) {
return strip(s).length() == s.length();
}

/** Returns {@code splitNamespace(s, false)}. */
static List<String> splitNamespace(String s) {
return splitNamespace(s, false);
}
Expand Down Expand Up @@ -75,10 +76,13 @@ static List<String> splitNamespace(String s, boolean returnParams) {
int count = 1;
for (pIndex--; pIndex >= 0; pIndex--) {
char c = sTemplatesMasked.charAt(pIndex);
if (c == ')') count++;
else if (c == '(') {
if (c == ')') {
count++;
} else if (c == '(') {
count--;
if (count == 0) break;
if (count == 0) {
break;
}
}
}
}
Expand All @@ -100,7 +104,9 @@ else if (c == '(') {
comps.add(s.substring(start));
params = "";
}
if (returnParams) comps.add(params);
if (returnParams) {
comps.add(params);
}
return comps;
}
}

0 comments on commit 7395919

Please sign in to comment.