Fixed incorrect verifier code for nested tables.

It was outputting the type instead of the field name, and didn't deal
with NULL fields. Added test case.

Also fixed token enums having the wrong value, resulting in
unreadable error messages.

Change-Id: Icd9b4d22f417bfad5824c0f58e067ce3f2e2dc6f
Tested: on Windows and Linux.
This commit is contained in:
Wouter van Oortmerssen
2014-07-09 11:44:26 -07:00
parent b3ee52c0a7
commit 75349ae8c3
8 changed files with 25 additions and 11 deletions

View File

@@ -155,8 +155,8 @@ static void GenComment(const std::string &dc,
if (!ev.value) {
code_post += ": return true;\n"; // "NONE" enum value.
} else {
code_post += ": return reinterpret_cast<const " + ev.struct_def->name;
code_post += " *>(union_obj)->Verify(verifier);\n";
code_post += ": return verifier.VerifyTable(reinterpret_cast<const ";
code_post += ev.struct_def->name + " *>(union_obj));\n";
}
}
code_post += " default: return false;\n }\n}\n\n";
@@ -213,8 +213,8 @@ static void GenTable(StructDef &struct_def, std::string *code_ptr) {
break;
case BASE_TYPE_STRUCT:
if (!field.value.type.struct_def->fixed) {
code += prefix + field.value.type.struct_def->name;
code += "()->Verify()";
code += prefix + "verifier.VerifyTable(" + field.name;
code += "())";
}
break;
case BASE_TYPE_STRING: