Fix Rust codegen escaping field in tables. (#7659)

* Fix Rust codegen escaping  field in tables.

* other gencode

* gencode

* removed a debug print

* regen code

Co-authored-by: Casper Neo <cneo@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
Casper
2022-12-15 01:04:57 -05:00
committed by GitHub
parent 9ed76559df
commit a078130c87
7 changed files with 469 additions and 6 deletions

View File

@@ -102,6 +102,10 @@ class IdlNamer : public Namer {
std::string LegacyRustFieldOffsetName(const FieldDef &field) const {
return "VT_" + ConvertCase(EscapeKeyword(field.name), Case::kAllUpper);
}
std::string LegacyRustUnionTypeOffsetName(const FieldDef &field) const {
return "VT_" + ConvertCase(EscapeKeyword(field.name + "_type"), Case::kAllUpper);
}
std::string LegacySwiftVariant(const EnumVal &ev) const {
auto name = ev.name;
@@ -140,6 +144,11 @@ class IdlNamer : public Namer {
return "mutate_" + d.name;
}
std::string LegacyRustUnionTypeMethod(const FieldDef &d) {
// assert d is a union
return Method(d.name + "_type");
}
private:
std::string NamespacedString(const struct Namespace *ns,
const std::string &str) const {