Skip to content

Commit dcc06df

Browse files
committed
* Have Parser wrap the erase() methods of basic containers with iterators to allow removing from maps
* Let `Parser` output the content of `Info.javaText` in the case of basic containers as well
1 parent 10ea4fd commit dcc06df

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
* Have `Parser` wrap the `erase()` methods of basic containers with iterators to allow removing from maps
3+
* Let `Parser` output the content of `Info.javaText` in the case of basic containers as well
24
* Fix `Parser` failure on arguments containing multiple array accesses ending with `]]`
35
* Fix `Parser` incorrectly considering some array definitions with expressions as multidimensional
46
* Log loading errors of optional `jnijavacpp` as debug messages instead of warnings ([issue tensorflow/java#189](https://github.com/tensorflow/java/issues/189))

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2013-2020 Samuel Audet
2+
* Copyright (C) 2013-2021 Samuel Audet
33
*
44
* Licensed either under the Apache License, Version 2.0, or (at your option)
55
* under the terms of the GNU General Public License as published by
@@ -140,6 +140,11 @@ void containers(Context context, DeclarationList declList) throws ParserExceptio
140140
for (Info info : infoSet) {
141141
Declaration decl = new Declaration();
142142
if (info == null || info.skip || !info.define) {
143+
if (info != null && info.javaText != null) {
144+
decl.type = new Type(info.pointerTypes[0]);
145+
decl.text = info.javaText;
146+
declList.add(decl);
147+
}
143148
continue;
144149
}
145150
int dim = containerName.toLowerCase().endsWith("optional")
@@ -167,6 +172,7 @@ void containers(Context context, DeclarationList declList) throws ParserExceptio
167172
String iteratorType = "iterator";
168173
String keyVariable = "first";
169174
String valueVariable = "second";
175+
boolean dict = false;
170176
boolean list = resizable; // also vector, etc
171177
if (valueType.javaName == null || valueType.javaName.length() == 0
172178
|| containerName.toLowerCase().endsWith("bitset")) {
@@ -178,6 +184,7 @@ void containers(Context context, DeclarationList declList) throws ParserExceptio
178184
iteratorType = "Iterator";
179185
keyVariable = "key()";
180186
valueVariable = "value()";
187+
dict = true;
181188
} else if (containerName.toLowerCase().endsWith("list")
182189
|| containerName.toLowerCase().endsWith("optional")
183190
|| containerName.toLowerCase().endsWith("variant")
@@ -352,8 +359,10 @@ void containers(Context context, DeclarationList declList) throws ParserExceptio
352359
} else if (indexType == null) {
353360
decl.text += " public native void insert(" + valueType.annotations + valueType.javaName + " value);\n"
354361
+ " public native void erase(" + valueType.annotations + valueType.javaName + " value);\n";
362+
} else if (!dict) {
363+
// XXX: need to figure out something for insert() on maps
364+
decl.text += " public native void erase(@ByVal Iterator pos);\n";
355365
}
356-
// XXX: else need to figure out something for maps
357366
}
358367
if (indexType != null && !indexType.annotations.contains("@Const") && !indexType.annotations.contains("@Cast") && !indexType.value) {
359368
indexType.annotations += "@Const ";
@@ -488,6 +497,11 @@ void containers(Context context, DeclarationList declList) throws ParserExceptio
488497
first = false;
489498
}
490499
}
500+
if (info != null && info.javaText != null) {
501+
declList.spacing = "\n ";
502+
decl.text += declList.rescan(info.javaText) + "\n";
503+
declList.spacing = null;
504+
}
491505
decl.text += "}\n";
492506
declList.add(decl);
493507
}

0 commit comments

Comments
 (0)