mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-29 21:12:00 +00:00
[Rust] Ensure unions are referenced with the correct path (#6422)
* Add codegen test for namespaced unions * [Rust] Handle cross-namespace union use * [Rust] Test namespace handling * [Rust] Drop trailing whitespace in codegen * [Rust] Set flags in generate_code.bat to match .sh * [C#] Add additional namespace test file
This commit is contained in:
@@ -40,9 +40,26 @@ class TableInFirstNS : Table() {
|
||||
false
|
||||
}
|
||||
}
|
||||
val fooUnionType : UByte
|
||||
get() {
|
||||
val o = __offset(8)
|
||||
return if(o != 0) bb.get(o + bb_pos).toUByte() else 0u
|
||||
}
|
||||
fun mutateFooUnionType(fooUnionType: UByte) : Boolean {
|
||||
val o = __offset(8)
|
||||
return if (o != 0) {
|
||||
bb.put(o + bb_pos, fooUnionType.toByte())
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
fun fooUnion(obj: Table) : Table? {
|
||||
val o = __offset(10); return if (o != 0) __union(obj, o + bb_pos) else null
|
||||
}
|
||||
val fooStruct : NamespaceA.NamespaceB.StructInNestedNS? get() = fooStruct(NamespaceA.NamespaceB.StructInNestedNS())
|
||||
fun fooStruct(obj: NamespaceA.NamespaceB.StructInNestedNS) : NamespaceA.NamespaceB.StructInNestedNS? {
|
||||
val o = __offset(8)
|
||||
val o = __offset(12)
|
||||
return if (o != 0) {
|
||||
obj.__assign(o + bb_pos, bb)
|
||||
} else {
|
||||
@@ -56,10 +73,12 @@ class TableInFirstNS : Table() {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
|
||||
}
|
||||
fun startTableInFirstNS(builder: FlatBufferBuilder) = builder.startTable(3)
|
||||
fun startTableInFirstNS(builder: FlatBufferBuilder) = builder.startTable(5)
|
||||
fun addFooTable(builder: FlatBufferBuilder, fooTable: Int) = builder.addOffset(0, fooTable, 0)
|
||||
fun addFooEnum(builder: FlatBufferBuilder, fooEnum: Byte) = builder.addByte(1, fooEnum, 0)
|
||||
fun addFooStruct(builder: FlatBufferBuilder, fooStruct: Int) = builder.addStruct(2, fooStruct, 0)
|
||||
fun addFooUnionType(builder: FlatBufferBuilder, fooUnionType: UByte) = builder.addByte(2, fooUnionType.toByte(), 0)
|
||||
fun addFooUnion(builder: FlatBufferBuilder, fooUnion: Int) = builder.addOffset(3, fooUnion, 0)
|
||||
fun addFooStruct(builder: FlatBufferBuilder, fooStruct: Int) = builder.addStruct(4, fooStruct, 0)
|
||||
fun endTableInFirstNS(builder: FlatBufferBuilder) : Int {
|
||||
val o = builder.endTable()
|
||||
return o
|
||||
|
||||
Reference in New Issue
Block a user