mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 02:38:29 +00:00
[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
This commit is contained in:
36
tests/nested_union_test.fbs
Normal file
36
tests/nested_union_test.fbs
Normal file
@@ -0,0 +1,36 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user