Skip to content

Commit 997201f

Browse files
committed
* Prevent Parser from overwriting target classes when nothing was parsed
1 parent c6760df commit 997201f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Prevent `Parser` from overwriting target classes when nothing was parsed
23
* Fix `Parser` error on member variables with initializers plus `Info.skip()` ([issue #179](https://github.com/bytedeco/javacpp/issues/179))
34
* Fix `Parser` incorrectly recognizing values as pointers when `const` is placed after type ([issue #173](https://github.com/bytedeco/javacpp/issues/173))
45
* Add `Parser` support for C++11 `using` declarations that act as `typedef` ([issue #169](https://github.com/bytedeco/javacpp/issues/169))

src/main/java/org/bytedeco/javacpp/tools/Parser.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole
908908
dimCast += "[" + dims[i] + "]";
909909
}
910910
}
911-
911+
912912
if (!dimCast.isEmpty()) {
913913
if (dims[0] != -1) {
914914
// Annotate with the first dimension's value
@@ -2998,17 +2998,17 @@ public File parse(String outputDirectory, String[] classPath, Class cls) throws
29982998
public File parse(File outputDirectory, String[] classPath, Class cls) throws IOException, ParserException {
29992999
ClassProperties allProperties = Loader.loadProperties(cls, properties, true);
30003000
ClassProperties clsProperties = Loader.loadProperties(cls, properties, false);
3001-
3001+
30023002
// Capture c-includes from "class" and "all" properties
30033003
List<String> cIncludes = new ArrayList<>();
30043004
cIncludes.addAll(clsProperties.get("platform.cinclude"));
30053005
cIncludes.addAll(allProperties.get("platform.cinclude"));
3006-
3006+
30073007
// Capture class includes
30083008
List<String> clsIncludes = new ArrayList<String>();
30093009
clsIncludes.addAll(clsProperties.get("platform.include"));
30103010
clsIncludes.addAll(clsProperties.get("platform.cinclude"));
3011-
3011+
30123012
// Capture all includes
30133013
List<String> allIncludes = new ArrayList<String>();
30143014
allIncludes.addAll(allProperties.get("platform.include"));
@@ -3104,6 +3104,11 @@ public File parse(File outputDirectory, String[] classPath, Class cls) throws IO
31043104
}
31053105
}
31063106

3107+
if (declList.size() == 0) {
3108+
logger.info("Nothing targeted for " + targetFile);
3109+
return null;
3110+
}
3111+
31073112
File targetDir = targetFile.getParentFile();
31083113
if (targetDir != null) {
31093114
targetDir.mkdirs();

0 commit comments

Comments
 (0)