Skip to content

Commit

Permalink
* Add default Info to map noexcept attribute from C++11 to `@NoE…
Browse files Browse the repository at this point in the history
…xception` annotation

 * Fix `Parser` failures on variadic function template arguments `...` and destructor attributes (pull bytedeco/javacpp-presets#622)
  • Loading branch information
saudet committed Oct 25, 2018
1 parent f89f1c3 commit c4759be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

* Add default `Info` to map `noexcept` attribute from C++11 to `@NoException` annotation
* Fix `Parser` failures on variadic function template arguments `...` and destructor attributes ([pull bytedeco/javacpp-presets#622](https://github.com/bytedeco/javacpp-presets/pull/622))
* Add `@Properties(global=...)` value to allow `Parser` to target Java packages ([pull #252](https://github.com/bytedeco/javacpp/pull/252))
* Fix `Generator` output for `@Const` parameters of function pointers

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/bytedeco/javacpp/tools/InfoMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class InfoMap extends HashMap<String,List<Info>> {
"std::priority_queue", "std::unordered_map", "std::unordered_set"))
.put(new Info("basic/types").cppTypes("signed", "unsigned", "char", "short", "int", "long", "bool", "float", "double",
"_Bool", "_Complex", "_Imaginary", "complex", "imaginary"))
.put(new Info("noexcept").annotations("@NoException"))

.put(new Info("__COUNTER__").cppText("#define __COUNTER__ 0"))
.put(new Info(" __attribute__", "__declspec", "static_assert").annotations().skip())
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ Parameters parameters(Context context, int infoNumber, boolean useDefaults) thro
tokens.next();
}
}
if (dcls.size() == 1 && (dcls.get(0) == null || dcls.get(0).type == null
if (context.templateMap == null && dcls.size() == 1 && (dcls.get(0) == null || dcls.get(0).type == null
|| dcls.get(0).type.cppName == null || dcls.get(0).type.cppName.length() == 0)) {
// this looks more like a variable initialization
tokens.index = backIndex;
Expand Down Expand Up @@ -1833,7 +1833,7 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
tokens.index = backIndex;
return false;
} else if (context.javaName == null && !type.operator && params != null) {
// this is a constructor definition or specialization, skip over
// this is a constructor/destructor definition or specialization, skip over
if (tokens.get().match(':')) {
for (Token token = tokens.next(); !token.match(Token.EOF); token = tokens.next()) {
if (token.match('{', ';')) {
Expand All @@ -1844,7 +1844,9 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
if (tokens.get().match('{')) {
body();
} else {
tokens.next();
while (!tokens.get().match(';', Token.EOF)) {
tokens.next();
}
}
decl.text = spacing;
decl.function = true;
Expand Down Expand Up @@ -2000,10 +2002,13 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
}
}

// check for const and pure virtual functions, ignoring the body if present
// check for const, other attributes, and pure virtual functions, ignoring the body if present
for (Token token = tokens.get(); !token.match(Token.EOF); token = tokens.get()) {
decl.constMember |= token.match(Token.CONST, Token.__CONST, Token.CONSTEXPR);
if (attribute() == null) {
Attribute attr = attribute();
if (attr != null && attr.annotation) {
dcl.type.annotations += attr.javaName;
} else if (attr == null) {
break;
}
}
Expand Down

0 comments on commit c4759be

Please sign in to comment.