forked from BigfootDev/flatbuffers
[Kotlin] Control the generation of reflection with --reflect-names (#7775)
* [Kotlin] Control the generation of reflection with --reflect-names. Tested: ``` $ cmake -G "Unix Makefiles" && make && ./tests/flatc/main.py ... KotlinTests.EnumValAttributes [PASSED] KotlinTests.EnumValAttributes_ReflectNames [PASSED] KotlinTests: 2 of 2 passsed ... 35 of 35 tests passed ``` * [Kotlin] Fix SampleBinary by converting Byte to UByte for ubyte fields. * [Kotlin] Annotate all generated classes with kotlin.ExperimentalUnsignedTypes.
This commit is contained in:
@@ -24,6 +24,7 @@ import MyGame.Sample.Weapon
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder
|
||||
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class SampleBinary {
|
||||
|
||||
companion object {
|
||||
@@ -45,7 +46,7 @@ class SampleBinary {
|
||||
|
||||
// Serialize the FlatBuffer data.
|
||||
val name = builder.createString("Orc")
|
||||
val treasure = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
val treasure = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).asUByteArray()
|
||||
val inv = Monster.createInventoryVector(builder, treasure)
|
||||
val weapons = Monster.createWeaponsVector(builder, weaps)
|
||||
val pos = Vec3.createVec3(builder, 1.0f, 2.0f, 3.0f)
|
||||
@@ -85,7 +86,7 @@ class SampleBinary {
|
||||
|
||||
// Get and test the `inventory` FlatBuffer `vector`.
|
||||
for (i in 0 until monster.inventoryLength) {
|
||||
assert(monster.inventory(i) == i.toByte().toInt())
|
||||
assert(monster.inventory(i) == i.toUByte())
|
||||
}
|
||||
|
||||
// Get and test the `weapons` FlatBuffer `vector` of `table`s.
|
||||
|
||||
Reference in New Issue
Block a user