Skip to content

Commit

Permalink
* Fix issues in the Parser with access specifiers and casting of c…
Browse files Browse the repository at this point in the history
…onst values by reference
  • Loading branch information
saudet committed Jun 28, 2014
1 parent 14c8b1c commit dd14511
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

* Fix a few other minor issues in the `Parser`
* Fix a few other minor issues in the `Parser` with the `long double` type, floating-point numbers, macro redefinitions, access specifiers, casting of const values by reference
* Allow users to instruct the `Parser` to skip the expansion of specific macro invocations
* Let `Parser` concatenate tokens when expanding macros containing the `##` operator
* Add some documentation for `Info`, `InfoMap`, `InfoMapper`, and `Parser`
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,6 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole
}
cast += token;
}
if (dcl.indirections == 0 && dcl.reference) {
cast = cast.replace('&', '*');
}

ArrayList<Attribute> attributes = new ArrayList<Attribute>();
if (type.attributes != null) {
Expand Down Expand Up @@ -662,6 +659,14 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole
}
}
if (needCast) {
if (dcl.indirections == 0 && dcl.reference) {
// consider as pointer type
cast = cast.replace('&', '*');
}
if (valueType && type.constValue && dcl.reference) {
// consider as value type
cast = cast.substring(0, cast.length() - 1);
}
if (type.constValue) {
cast = "const " + cast;
}
Expand Down Expand Up @@ -1881,9 +1886,10 @@ boolean extern(Context context, DeclarationList declList) throws ParserException

void declarations(Context context, DeclarationList declList) throws ParserException {
for (Token token = tokens.get(); !token.match(Token.EOF, '}'); token = tokens.get()) {
if (token.match(Token.PRIVATE, Token.PROTECTED, Token.PUBLIC) && tokens.next().match(':')) {
while (token.match(Token.PRIVATE, Token.PROTECTED, Token.PUBLIC) && tokens.get(1).match(':')) {
context.inaccessible = !token.match(Token.PUBLIC);
tokens.next();
tokens.next();
}
Context ctx = context;
String comment = commentBefore();
Expand Down

0 comments on commit dd14511

Please sign in to comment.