mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 23:58:56 +00:00
fix(flatbuffers): use manual impl Default for struct object types (#8947)
* fix(flatbuffers): use manual impl Default for struct object types * fix: handle bool and float zero literals in struct object Default impl * fix: regenerate all test bindings with generate_code.py * fix: data type check on swift build * fix: test large array on struct and enum
This commit is contained in:
@@ -282,9 +282,16 @@ class SwiftGenerator : public BaseGenerator {
|
||||
NumToString(field.value.type.VectorType().fixed_length);
|
||||
code_.SetValue("FIXEDLENGTH", fixed_length);
|
||||
|
||||
const auto vector_base_type = IsStruct(field.value.type.VectorType())
|
||||
? (type + "()")
|
||||
: SwiftConstant(field);
|
||||
std::string vector_base_type;
|
||||
if (IsStruct(field.value.type.VectorType())) {
|
||||
vector_base_type = type + "()";
|
||||
} else if (IsBool(field.value.type.VectorType().base_type)) {
|
||||
vector_base_type = "false";
|
||||
} else if (IsFloat(field.value.type.VectorType().base_type)) {
|
||||
vector_base_type = "0.0";
|
||||
} else {
|
||||
vector_base_type = SwiftConstant(field);
|
||||
}
|
||||
code_ += "private var _{{FIELDVAR}}: InlineArray<{{FIXEDLENGTH}}, " +
|
||||
valueType + ">";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user