Fixed .proto translation making scalars into required fields.

Change-Id: If414d156b4e9bc7fead5f131823b2c419cdc4e2c
Tested: on Linux.
parent 811a5c33
...@@ -23,7 +23,7 @@ inline const char **EnumNamesColor() { ...@@ -23,7 +23,7 @@ inline const char **EnumNamesColor() {
return names; return names;
} }
inline const char *EnumNameColor(Color e) { return EnumNamesColor()[e]; } inline const char *EnumNameColor(Color e) { return EnumNamesColor()[static_cast<int>(e)]; }
enum Any { enum Any {
Any_NONE = 0, Any_NONE = 0,
...@@ -35,7 +35,7 @@ inline const char **EnumNamesAny() { ...@@ -35,7 +35,7 @@ inline const char **EnumNamesAny() {
return names; return names;
} }
inline const char *EnumNameAny(Any e) { return EnumNamesAny()[e]; } inline const char *EnumNameAny(Any e) { return EnumNamesAny()[static_cast<int>(e)]; }
inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, Any type); inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, Any type);
......
...@@ -1080,7 +1080,7 @@ void Parser::ParseProtoDecl() { ...@@ -1080,7 +1080,7 @@ void Parser::ParseProtoDecl() {
Expect(kTokenIntegerConstant); Expect(kTokenIntegerConstant);
auto &field = AddField(struct_def, name, type); auto &field = AddField(struct_def, name, type);
field.doc_comment = field_comment; field.doc_comment = field_comment;
field.required = required; if (!IsScalar(type.base_type)) field.required = required;
// See if there's a default specified. // See if there's a default specified.
if (IsNext('[')) { if (IsNext('[')) {
if (attribute_ != "default") Error("\'default\' expected"); if (attribute_ != "default") Error("\'default\' expected");
......
...@@ -31,7 +31,7 @@ inline const char **EnumNamesColor() { ...@@ -31,7 +31,7 @@ inline const char **EnumNamesColor() {
return names; return names;
} }
inline const char *EnumNameColor(Color e) { return EnumNamesColor()[e - Color_Red]; } inline const char *EnumNameColor(Color e) { return EnumNamesColor()[static_cast<int>(e) - static_cast<int>(Color_Red)]; }
enum Any { enum Any {
Any_NONE = 0, Any_NONE = 0,
...@@ -44,7 +44,7 @@ inline const char **EnumNamesAny() { ...@@ -44,7 +44,7 @@ inline const char **EnumNamesAny() {
return names; return names;
} }
inline const char *EnumNameAny(Any e) { return EnumNamesAny()[e]; } inline const char *EnumNameAny(Any e) { return EnumNamesAny()[static_cast<int>(e)]; }
inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, Any type); inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, Any type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment