Commit 8526e12d authored by Paulo Pinheiro's avatar Paulo Pinheiro Committed by Wouter van Oortmerssen

[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
(e365c502).

This changes updates kotlin code generation to match Java's changes.
parent 3c7b660d
...@@ -975,9 +975,6 @@ class KotlinGenerator : public BaseGenerator { ...@@ -975,9 +975,6 @@ class KotlinGenerator : public BaseGenerator {
params = "obj: " + field_type + ", j: Int"; params = "obj: " + field_type + ", j: Int";
} }
writer.SetValue("toType", "YYYYY");
auto ret_type = return_type + nullable; auto ret_type = return_type + nullable;
GenerateFun(writer, field_name, params, ret_type, [&](){ GenerateFun(writer, field_name, params, ret_type, [&](){
auto inline_size = NumToString(InlineSize(vectortype)); auto inline_size = NumToString(InlineSize(vectortype));
...@@ -1008,7 +1005,7 @@ class KotlinGenerator : public BaseGenerator { ...@@ -1008,7 +1005,7 @@ class KotlinGenerator : public BaseGenerator {
GenerateFun(writer, field_name, "obj: " + field_type, GenerateFun(writer, field_name, "obj: " + field_type,
return_type + "?", [&](){ return_type + "?", [&](){
writer += OffsetWrapperOneLine(offset_val, writer += OffsetWrapperOneLine(offset_val,
bbgetter + "(obj, o)", bbgetter + "(obj, o + bb_pos)",
"null"); "null");
}); });
break; break;
......
...@@ -116,7 +116,7 @@ class Monster : Table() { ...@@ -116,7 +116,7 @@ class Monster : Table() {
} }
} }
fun test(obj: Table) : 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(j: Int) : MyGame.Example.Test? = test4(MyGame.Example.Test(), j)
fun test4(obj: MyGame.Example.Test, j: Int) : MyGame.Example.Test? { fun test4(obj: MyGame.Example.Test, j: Int) : MyGame.Example.Test? {
...@@ -717,7 +717,7 @@ class Monster : Table() { ...@@ -717,7 +717,7 @@ class Monster : Table() {
} }
} }
fun anyUnique(obj: Table) : 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 val anyAmbiguousType : UByte
get() { get() {
...@@ -734,7 +734,7 @@ class Monster : Table() { ...@@ -734,7 +734,7 @@ class Monster : Table() {
} }
} }
fun anyAmbiguous(obj: Table) : 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 { fun vectorOfEnums(j: Int) : UByte {
val o = __offset(98) val o = __offset(98)
......
...@@ -30,7 +30,7 @@ class Movie : Table() { ...@@ -30,7 +30,7 @@ class Movie : Table() {
} }
} }
fun mainCharacter(obj: Table) : 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 { fun charactersType(j: Int) : UByte {
val o = __offset(8) val o = __offset(8)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment