[Kotlin] Fix union vector accessor after change in Java API (#5605)

Kolin uses java library as dependency, which changed the way it access union vector recently
(e365c502ff).

This changes updates kotlin code generation to match Java's changes.
This commit is contained in:
Paulo Pinheiro
2019-11-04 23:25:07 +01:00
committed by Wouter van Oortmerssen
parent 3c7b660d62
commit 8526e12d73
3 changed files with 5 additions and 8 deletions

View File

@@ -975,9 +975,6 @@ class KotlinGenerator : public BaseGenerator {
params = "obj: " + field_type + ", j: Int";
}
writer.SetValue("toType", "YYYYY");
auto ret_type = return_type + nullable;
GenerateFun(writer, field_name, params, ret_type, [&](){
auto inline_size = NumToString(InlineSize(vectortype));
@@ -1008,7 +1005,7 @@ class KotlinGenerator : public BaseGenerator {
GenerateFun(writer, field_name, "obj: " + field_type,
return_type + "?", [&](){
writer += OffsetWrapperOneLine(offset_val,
bbgetter + "(obj, o)",
bbgetter + "(obj, o + bb_pos)",
"null");
});
break;

View File

@@ -116,7 +116,7 @@ class Monster : Table() {
}
}
fun test(obj: Table) : Table? {
val o = __offset(20); return if (o != 0) __union(obj, o) else null
val o = __offset(20); return if (o != 0) __union(obj, o + bb_pos) else null
}
fun test4(j: Int) : MyGame.Example.Test? = test4(MyGame.Example.Test(), j)
fun test4(obj: MyGame.Example.Test, j: Int) : MyGame.Example.Test? {
@@ -717,7 +717,7 @@ class Monster : Table() {
}
}
fun anyUnique(obj: Table) : Table? {
val o = __offset(92); return if (o != 0) __union(obj, o) else null
val o = __offset(92); return if (o != 0) __union(obj, o + bb_pos) else null
}
val anyAmbiguousType : UByte
get() {
@@ -734,7 +734,7 @@ class Monster : Table() {
}
}
fun anyAmbiguous(obj: Table) : Table? {
val o = __offset(96); return if (o != 0) __union(obj, o) else null
val o = __offset(96); return if (o != 0) __union(obj, o + bb_pos) else null
}
fun vectorOfEnums(j: Int) : UByte {
val o = __offset(98)

View File

@@ -30,7 +30,7 @@ class Movie : Table() {
}
}
fun mainCharacter(obj: Table) : Table? {
val o = __offset(6); return if (o != 0) __union(obj, o) else null
val o = __offset(6); return if (o != 0) __union(obj, o + bb_pos) else null
}
fun charactersType(j: Int) : UByte {
val o = __offset(8)