【问题标题】:Flatbuffers Schema: Vectors of unions not possible with --binaryFlatbuffers Schema:联合向量不能使用 --binary
【发布时间】:2019-11-09 22:18:15
【问题描述】:

在尝试使用联合向量并生成线格式二进制文件 (--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.

没有 --binary-switch flatc.exe 不会抱怨:

flatc.exe --cpp --java --js --csharp c.fbs

在生成线格式二进制文件时真的不能使用联合向量吗?我认为这是文本模式的二进制序列化,应该支持 .fbs 文件可能的所有内容。

我很好奇并更改了 idl_parser.cpp (| IDLOptions::kBinary) 中的 Parser::SupportsVectorOfUnions() 并且它似乎有效。

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;
}

这是c.fbs

table A {
}

table B {
}

union U {
    A,
    B
}

table C {
    v : [U];
}

root_type C;

【问题讨论】:

  • 是的,这看起来就像那个测试中的一个错误。请在 github 上提交问题,或者更好的是,提交请求请求。

标签: schema flatbuffers


【解决方案1】:

这已在 master 分支中修复。当前版本的idl_parser.cpp中的Parser::SupportsAdvancedUnionFeatures()支持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; }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    相关资源
    最近更新 更多