Rename Nullable scalars to Optional scalars (#6112)

Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
Casper
2020-09-10 16:04:36 -04:00
committed by GitHub
parent f5ab24bc41
commit 338944d3d9
6 changed files with 37 additions and 37 deletions

View File

@@ -110,13 +110,13 @@ class LobsterGenerator : public BaseGenerator {
offsets + ")";
} else {
auto defval = field.nullable ? "0" : field.value.constant;
auto defval = field.optional ? "0" : field.value.constant;
acc = "buf_.flatbuffers_field_" + GenTypeName(field.value.type) +
"(pos_, " + offsets + ", " + defval + ")";
}
if (field.value.type.enum_def)
acc = NormalizedName(*field.value.type.enum_def) + "(" + acc + ")";
if (field.nullable)
if (field.optional)
acc += ", buf_.flatbuffers_field_present(pos_, " + offsets + ")";
code += def + "():\n return " + acc + "\n";
return;
@@ -201,7 +201,7 @@ class LobsterGenerator : public BaseGenerator {
NormalizedName(field) + ":" + LobsterType(field.value.type) +
"):\n b_.Prepend" + GenMethod(field.value.type) + "Slot(" +
NumToString(offset) + ", " + NormalizedName(field);
if (IsScalar(field.value.type.base_type) && !field.nullable)
if (IsScalar(field.value.type.base_type) && !field.optional)
code += ", " + field.value.constant;
code += ")\n return this\n";
}