Reputation: 151
I get this error when trying to use vectors of unions and generating wire format binaries (--binary)
flatc.exe --cpp --java --js --csharp --binary c.fbs
error: D:\FlatbuffersVectorOfUnions\c.fbs(13, 9): error: Vectors of unions are not yet supported in all the specified programming languages.
Without the --binary-switch flatc.exe doesn't complain:
flatc.exe --cpp --java --js --csharp c.fbs
Is it really not possible to use vectors of unions when generating wire format binaries? I thought this is the binary serialisation of the textual schema and should support everything which is possible with the .fbs files.
I was curious and changed Parser::SupportsVectorOfUnions() in idl_parser.cpp (| IDLOptions::kBinary) and it seems to work.
bool Parser::SupportsVectorOfUnions() const {
return opts.lang_to_generate != 0 &&
(opts.lang_to_generate & ~(IDLOptions::kCpp | IDLOptions::kJs |
IDLOptions::kTs | IDLOptions::kPhp |
IDLOptions::kJava | IDLOptions::kCSharp | IDLOptions::kBinary)) == 0;
}
This is the c.fbs
table A {
}
table B {
}
union U {
A,
B
}
table C {
v : [U];
}
root_type C;
Upvotes: 0
Views: 429
Reputation: 21
This has already been fixed in the master branch. Parser::SupportsAdvancedUnionFeatures() in the current version of idl_parser.cpp supports kBinary:
bool Parser::SupportsAdvancedUnionFeatures() const { return opts.lang_to_generate != 0 &&
(opts.lang_to_generate &
~(IDLOptions::kCpp | IDLOptions::kJs | IDLOptions::kTs |
IDLOptions::kPhp | IDLOptions::kJava | IDLOptions::kCSharp |
IDLOptions::kKotlin | IDLOptions::kBinary)) == 0; }
Upvotes: 2