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

@@ -1414,6 +1414,8 @@ void UtilConvertCase() {
"THE_QUICK_BROWN_FOX" },
{ "the_quick_brown_fox", flatbuffers::Case::kUnknown,
"the_quick_brown_fox" },
{ "the_quick_brown_fox", flatbuffers::Case::kKeep,
"the_quick_brown_fox" },
// Tests for some snake_cases where the _ is oddly placed or missing.
{ "single", flatbuffers::Case::kUpperCamel, "Single" },
@@ -1444,7 +1446,7 @@ void UtilConvertCase() {
std::get<1>(test_case)));
}
}
// Tests for the non snake_case inputs.
{
std::vector<std::tuple<flatbuffers::Case, std::string, flatbuffers::Case,
@@ -1464,6 +1466,8 @@ void UtilConvertCase() {
"single" },
{ flatbuffers::Case::kUpperCamel, "ABCtest",
flatbuffers::Case::kSnake, "abctest" },
{ flatbuffers::Case::kUpperCamel, "tHe_qUiCk_BrOwN_fOx",
flatbuffers::Case::kKeep, "tHe_qUiCk_BrOwN_fOx" },
};
for (auto &test_case : cases) {