diff options
author | Vladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com> | 2020-09-21 23:37:01 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-21 09:37:01 -0700 |
commit | eb686a86f39c818f922105d6a994cedc512de60e (patch) | |
tree | b03d95c7b834a3e2c677351942b9cb263f30de34 /tests/optional_scalars | |
parent | 750281630b097dc311b3a18578c82e98ba2438db (diff) | |
download | flatbuffers-eb686a86f39c818f922105d6a994cedc512de60e.tar.gz flatbuffers-eb686a86f39c818f922105d6a994cedc512de60e.tar.bz2 flatbuffers-eb686a86f39c818f922105d6a994cedc512de60e.zip |
Add missed file generated by optional_scalar.fbs (#6125)
Diffstat (limited to 'tests/optional_scalars')
-rw-r--r-- | tests/optional_scalars/OptionalByte.kt | 14 | ||||
-rw-r--r-- | tests/optional_scalars/ScalarStuff.kt | 23 |
2 files changed, 34 insertions, 3 deletions
diff --git a/tests/optional_scalars/OptionalByte.kt b/tests/optional_scalars/OptionalByte.kt new file mode 100644 index 00000000..dc8e74a3 --- /dev/null +++ b/tests/optional_scalars/OptionalByte.kt @@ -0,0 +1,14 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +package optional_scalars + +@Suppress("unused") +@ExperimentalUnsignedTypes +class OptionalByte private constructor() { + companion object { + const val None: Byte = 0 + const val One: Byte = 1 + val names : Array<String> = arrayOf("None", "One") + fun name(e: Int) : String = names[e] + } +} diff --git a/tests/optional_scalars/ScalarStuff.kt b/tests/optional_scalars/ScalarStuff.kt index 1d71b232..0538775b 100644 --- a/tests/optional_scalars/ScalarStuff.kt +++ b/tests/optional_scalars/ScalarStuff.kt @@ -182,6 +182,16 @@ class ScalarStuff : Table() { val o = __offset(68) return if(o != 0) 0.toByte() != bb.get(o + bb_pos) else true } + val justEnum : Byte + get() { + val o = __offset(70) + return if(o != 0) bb.get(o + bb_pos) else 0 + } + val defaultEnum : Byte + get() { + val o = __offset(72) + return if(o != 0) bb.get(o + bb_pos) else 1 + } companion object { fun validateVersion() = Constants.FLATBUFFERS_1_12_0() fun getRootAsScalarStuff(_bb: ByteBuffer): ScalarStuff = getRootAsScalarStuff(_bb, ScalarStuff()) @@ -189,8 +199,9 @@ class ScalarStuff : Table() { _bb.order(ByteOrder.LITTLE_ENDIAN) return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)) } - fun createScalarStuff(builder: FlatBufferBuilder, justI8: Byte, maybeI8: Byte?, defaultI8: Byte, justU8: UByte, maybeU8: UByte?, defaultU8: UByte, justI16: Short, maybeI16: Short?, defaultI16: Short, justU16: UShort, maybeU16: UShort?, defaultU16: UShort, justI32: Int, maybeI32: Int?, defaultI32: Int, justU32: UInt, maybeU32: UInt?, defaultU32: UInt, justI64: Long, maybeI64: Long?, defaultI64: Long, justU64: ULong, maybeU64: ULong?, defaultU64: ULong, justF32: Float, maybeF32: Float?, defaultF32: Float, justF64: Double, maybeF64: Double?, defaultF64: Double, justBool: Boolean, maybeBool: Boolean?, defaultBool: Boolean) : Int { - builder.startTable(33) + fun ScalarStuffBufferHasIdentifier(_bb: ByteBuffer) : Boolean = __has_identifier(_bb, "NULL") + fun createScalarStuff(builder: FlatBufferBuilder, justI8: Byte, maybeI8: Byte?, defaultI8: Byte, justU8: UByte, maybeU8: UByte?, defaultU8: UByte, justI16: Short, maybeI16: Short?, defaultI16: Short, justU16: UShort, maybeU16: UShort?, defaultU16: UShort, justI32: Int, maybeI32: Int?, defaultI32: Int, justU32: UInt, maybeU32: UInt?, defaultU32: UInt, justI64: Long, maybeI64: Long?, defaultI64: Long, justU64: ULong, maybeU64: ULong?, defaultU64: ULong, justF32: Float, maybeF32: Float?, defaultF32: Float, justF64: Double, maybeF64: Double?, defaultF64: Double, justBool: Boolean, maybeBool: Boolean?, defaultBool: Boolean, justEnum: Byte, defaultEnum: Byte) : Int { + builder.startTable(35) addDefaultF64(builder, defaultF64) maybeF64?.run { addMaybeF64(builder, maybeF64) } addJustF64(builder, justF64) @@ -215,6 +226,8 @@ class ScalarStuff : Table() { addDefaultI16(builder, defaultI16) maybeI16?.run { addMaybeI16(builder, maybeI16) } addJustI16(builder, justI16) + addDefaultEnum(builder, defaultEnum) + addJustEnum(builder, justEnum) addDefaultBool(builder, defaultBool) maybeBool?.run { addMaybeBool(builder, maybeBool) } addJustBool(builder, justBool) @@ -226,7 +239,7 @@ class ScalarStuff : Table() { addJustI8(builder, justI8) return endScalarStuff(builder) } - fun startScalarStuff(builder: FlatBufferBuilder) = builder.startTable(33) + fun startScalarStuff(builder: FlatBufferBuilder) = builder.startTable(35) fun addJustI8(builder: FlatBufferBuilder, justI8: Byte) = builder.addByte(0, justI8, 0) fun addMaybeI8(builder: FlatBufferBuilder, maybeI8: Byte) = builder.addByte(1, maybeI8, 0) fun addDefaultI8(builder: FlatBufferBuilder, defaultI8: Byte) = builder.addByte(2, defaultI8, 42) @@ -260,9 +273,13 @@ class ScalarStuff : Table() { fun addJustBool(builder: FlatBufferBuilder, justBool: Boolean) = builder.addBoolean(30, justBool, false) fun addMaybeBool(builder: FlatBufferBuilder, maybeBool: Boolean) = builder.addBoolean(31, maybeBool, false) fun addDefaultBool(builder: FlatBufferBuilder, defaultBool: Boolean) = builder.addBoolean(32, defaultBool, true) + fun addJustEnum(builder: FlatBufferBuilder, justEnum: Byte) = builder.addByte(33, justEnum, 0) + fun addDefaultEnum(builder: FlatBufferBuilder, defaultEnum: Byte) = builder.addByte(34, defaultEnum, 1) fun endScalarStuff(builder: FlatBufferBuilder) : Int { val o = builder.endTable() return o } + fun finishScalarStuffBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finish(offset, "NULL") + fun finishSizePrefixedScalarStuffBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finishSizePrefixed(offset, "NULL") } } |