mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
Refactor FieldDef to model presense as an enum rather than 2 bools. (#6420)
* Define presence. * Migrate to IsRequired and IsOptional methods * moved stuff around * Removed optional and required bools from FieldDef * change assert to return error * Fix tests.cpp * MakeFieldPresence helper * fmt * old c++ compatibility stuff Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
@@ -649,7 +649,7 @@ class JavaGenerator : public BaseGenerator {
|
||||
std::string src_cast = SourceCast(field.value.type);
|
||||
std::string method_start =
|
||||
" public " +
|
||||
(field.required ? "" : GenNullableAnnotation(field.value.type)) +
|
||||
(field.IsRequired() ? "" : GenNullableAnnotation(field.value.type)) +
|
||||
GenPureAnnotation(field.value.type) + type_name_dest + optional +
|
||||
" " + MakeCamel(field.name, false);
|
||||
std::string obj = "obj";
|
||||
@@ -1095,7 +1095,7 @@ class JavaGenerator : public BaseGenerator {
|
||||
for (auto it = struct_def.fields.vec.begin();
|
||||
it != struct_def.fields.vec.end(); ++it) {
|
||||
auto &field = **it;
|
||||
if (!field.deprecated && field.required) {
|
||||
if (!field.deprecated && field.IsRequired()) {
|
||||
code += " builder.required(o, ";
|
||||
code += NumToString(field.value.offset);
|
||||
code += "); // " + field.name + "\n";
|
||||
|
||||
Reference in New Issue
Block a user