Skip to content

Commit

Permalink
* Make sure default values placed in nullValue by the Parser hav…
Browse files Browse the repository at this point in the history
…e the right type (issue bytedeco/javacv#518)
  • Loading branch information
saudet committed Oct 8, 2016
1 parent 8344c59 commit cba7a59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Make sure default values placed in `nullValue` by the `Parser` have the right type ([issue bytedeco/javacv#518](https://github.com/bytedeco/javacv/issues/518))
* Accelerate call to `Pointer.physicalBytes()` on Linux ([issue #133](https://github.com/bytedeco/javacpp/issues/133))
* Fix `Parser` incorrectly skipping over some template function declarations
* Allow C++ types to be prefixed by `class`, `struct`, or `union` to work around name clashes ([pull bytedeco/javacpp-presets#266](https://github.com/bytedeco/javacpp-presets/pull/266))
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,11 @@ Parameters parameters(Context context, int infoNumber, boolean useDefaults) thro
n = s.indexOf("@ByRef ");
}
if (n >= 0) {
s = s.substring(0, n + 6) + "(nullValue = \""
+ defaultValue.replaceAll("\"", "\\\\\"").replaceAll("\n(\\s*)", "\"\n$1 + \"") + "\")" + s.substring(n + 6);
if (!defaultValue.startsWith(dcl.type.cppName)) {
defaultValue = dcl.type.cppName + "(" + defaultValue + ")";
}
defaultValue = defaultValue.replaceAll("\"", "\\\\\"").replaceAll("\n(\\s*)", "\"\n$1 + \"");
s = s.substring(0, n + 6) + "(nullValue = \"" + defaultValue + "\")" + s.substring(n + 6);
}
dcl.type.annotations = s;
}
Expand All @@ -1480,7 +1483,7 @@ Parameters parameters(Context context, int infoNumber, boolean useDefaults) thro
params.infoNumber = Math.max(params.infoNumber, dcl.infoNumber);
params.list += (count > 1 ? "," : "") + spacing + dcl.type.annotations + dcl.type.javaName + " " + dcl.javaName;
lastVarargs = params.list.indexOf("...", n);
if (hasDefault) {
if (hasDefault && !dcl.type.annotations.contains("(nullValue = ")) {
// output default argument as a comment
params.list += "/*" + defaultToken + defaultValue + "*/";
}
Expand Down

0 comments on commit cba7a59

Please sign in to comment.