summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTibor Král <tibor.kral@pantheon.tech>2019-03-14 16:02:38 +0100
committerMichal Cmarada <mcmarada@cisco.com>2019-03-20 13:53:15 +0000
commitcb48eef7770e0782c686337b577064905e1edb8d (patch)
tree9315c3abc4febd271b1592d1cfe7741801dc550e /java
parente599b1319651e2e5a4415033913d615e3617effa (diff)
Fixes EnumSet translation
Change-Id: Ic78a2523b766456e888c3468452a4685b8798dbe Signed-off-by: Tibor Král <tibor.kral@pantheon.tech>
Diffstat (limited to 'java')
-rwxr-xr-xjava/jvpp/gen/jvppgen/enumsets_gen.py38
-rwxr-xr-xjava/jvpp/gen/jvppgen/jni_type_handlers_gen.py4
2 files changed, 34 insertions, 8 deletions
diff --git a/java/jvpp/gen/jvppgen/enumsets_gen.py b/java/jvpp/gen/jvppgen/enumsets_gen.py
index 029c4ec..e1f5c8d 100755
--- a/java/jvpp/gen/jvppgen/enumsets_gen.py
+++ b/java/jvpp/gen/jvppgen/enumsets_gen.py
@@ -53,7 +53,17 @@ $json_definition
*/
public final class $java_name {
- private final EnumSet<$java_enum_name> options = EnumSet.noneOf($java_enum_name.class);
+ private final EnumSet<$java_enum_name> options;
+
+ public $java_name() {
+ options = EnumSet.noneOf($java_enum_name.class);
+ setOptionsValue(0);
+ }
+
+ public $java_name($value_type value) {
+ options = EnumSet.noneOf($java_enum_name.class);
+ setOptionsValue(value);
+ }
@Override
public boolean equals(final Object obj) {
@@ -92,19 +102,35 @@ public final class $java_name {
}
public boolean add($java_enum_name option) {
+ if (option.value == 0) return false;
+
+ if (getOptionsValue() == 0) {
+ options.clear();
+ }
return options.add(option);
}
public boolean remove($java_enum_name option) {
- return options.remove(option);
+ if (option.value == 0) return false;
+
+ options.remove(option);
+ if (options.isEmpty()) {
+ clear();
+ }
+ return true;
}
- public boolean removeAll(EnumSet<$java_enum_name> options) {
- return options.removeAll(options);
+ public boolean removeAll(EnumSet<$java_enum_name> optionsToRemove) {
+ boolean retVal = options.removeAll(optionsToRemove);
+ if (options.isEmpty()) {
+ clear();
+ retVal = true;
+ }
+ return retVal;
}
public void clear() {
- options.clear();
+ setOptionsValue(0);
}
public boolean contains($java_enum_name option) {
@@ -135,7 +161,7 @@ $constants;
return enumeration;
}
}
- return null;
+ return $java_enum_name.values()[0];
}
}
}
diff --git a/java/jvpp/gen/jvppgen/jni_type_handlers_gen.py b/java/jvpp/gen/jvppgen/jni_type_handlers_gen.py
index 657972d..d0d123a 100755
--- a/java/jvpp/gen/jvppgen/jni_type_handlers_gen.py
+++ b/java/jvpp/gen/jvppgen/jni_type_handlers_gen.py
@@ -186,9 +186,9 @@ $json_definition
static inline jobject _net_to_host_${c_name}(JNIEnv * env, vl_api_${c_name}_t _net)
{
jclass enumClass = (*env)->FindClass(env, "${class_FQN}");
- jmethodID enumInit = (*env)->GetMethodID(env, enumClass, "setOptionsValue", "(I)V");
+ jmethodID constructor = (*env)->GetMethodID(env, enumClass, "<init>", "(I)V");
${jni_type} value = (${jni_type}) $type_swap
- return (*env)->NewObject(env, enumClass, enumInit, value);
+ return (*env)->NewObject(env, enumClass, constructor, value);
}""")