Fix union escaping order. (#4722)

* Fix union escaping order.

Fixes #4712

* style
This commit is contained in:
iceboy 2018-05-03 11:59:30 -07:00 committed by Wouter van Oortmerssen
parent cc354ea368
commit 85faa46fb3
1 changed files with 6 additions and 3 deletions

View File

@ -1638,7 +1638,9 @@ class CppGenerator : public BaseGenerator {
auto full_struct_name = GetUnionElement(ev, true, true);
// @TODO: Mby make this decisions more universal? How?
code_.SetValue("U_GET_TYPE", Name(field) + UnionTypeFieldSuffix());
code_.SetValue(
"U_GET_TYPE",
EscapeKeyword(field.name + UnionTypeFieldSuffix()));
code_.SetValue(
"U_ELEMENT_TYPE",
WrapInNameSpace(u->defined_namespace, GetEnumValUse(*u, ev)));
@ -1994,8 +1996,9 @@ class CppGenerator : public BaseGenerator {
std::string GenUnionUnpackVal(const FieldDef &afield,
const char *vec_elem_access,
const char *vec_type_access) {
return afield.value.type.enum_def->name + "Union::UnPack(" + "_e" +
vec_elem_access + ", " + Name(afield) + UnionTypeFieldSuffix() +
return afield.value.type.enum_def->name +
"Union::UnPack(" + "_e" + vec_elem_access + ", " +
EscapeKeyword(afield.name + UnionTypeFieldSuffix()) +
"()" + vec_type_access + ", _resolver)";
}