Files
flatbuffers-bigfoot/tests/nested_union_test.fbs
Joshua Smith 043a24f2e4 [Python] Fixed the issue with nested unions relying on InitFromBuf. (#7576)
* feat: Fixed the issue with nested unions relying on InitFromBuf.
Problem: Issue #7569
Nested Unions were broken with the introduction of parsing buffers with an initial encoding offset.

Fix:
Revert the InitFromBuf method to the previous version and introduction of InitFromPackedBuf that allows
users to read types from packed buffers applying the offset automatically.

Test:
Added in TestNestedUnionTables to test the encoding and decoding ability using a nested table with a
union field.

* fix: Uncommented generate code command
2022-10-26 14:56:52 -07:00

36 lines
630 B
Plaintext

namespace MyGame.Example.NestedUnion;
/// Composite components of Monster color.
enum Color:ubyte (bit_flags) {
Red = 0, // color Red = (1u << 0)
/// \brief color Green
/// Green is bit_flag with value (1u << 1)
Green,
/// \brief color Blue (1u << 3)
Blue = 3,
}
table TestSimpleTableWithEnum (csharp_partial, private) {
color: Color = Green;
}
struct Test { a:short; b:byte; }
table Vec3 {
x:double;
y:double;
z:double;
test1:double;
test2:Color;
test3:Test;
}
union Any { Vec3, TestSimpleTableWithEnum }
table NestedUnionTest {
name:string;
data:Any;
id:short;
}
root_type NestedUnionTest;