Implement a config based name manager and use it in Rust codegen (#7144)

* Refactor out a  class from Rust Codegen

* Convert GenerateRustModuleRootFile

* git-clang-format

* unused variable

* parenthesis

* update BUILD file

* buildifier

* Delete bfbs_gen_rust.h

* Delete bfbs_gen_rust.cpp

* Addressed some comments

* Namer::EnumVariant

* Remove do not submit; Add Namespace vector overload

* Unshadow variable

* removed redundant variables

* Warn if converting from kKeep case.

Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
Casper
2022-03-05 20:43:57 -05:00
committed by GitHub
parent 8db2fef3f7
commit 65a10b6e32
6 changed files with 602 additions and 445 deletions

View File

@@ -416,6 +416,7 @@ static std::string ToDasher(const std::string &input) {
std::string ConvertCase(const std::string &input, Case output_case,
Case input_case) {
if (output_case == Case::kKeep) return input;
// The output cases expect snake_case inputs, so if we don't have that input
// format, try to convert to snake_case.
switch (input_case) {
@@ -423,6 +424,7 @@ std::string ConvertCase(const std::string &input, Case output_case,
case Case::kUpperCamel:
return ConvertCase(CamelToSnake(input), output_case);
case Case::kDasher: return ConvertCase(DasherToSnake(input), output_case);
case Case::kKeep: printf("WARNING: Converting from kKeep case.\n");
default:
case Case::kSnake:
case Case::kScreamingSnake: