mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Added --filename-suffix and --filename-ext to flatc (#5778)
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case. * Added --filename-suffix and --filename-ext to flatc * Fixed typo and added example generation of suffix and extension for C++ * Removed extra ; * Removed clang-format block from a region that didn't need it. Fixed an auto format of another clang-format block * Added docs, fixed pointer alignment, removed suffix test file
This commit is contained in:
@@ -22,11 +22,6 @@
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
static std::string GeneratedFileName(const std::string &path,
|
||||
const std::string &file_name) {
|
||||
return path + file_name + ".schema.json";
|
||||
}
|
||||
|
||||
namespace jsons {
|
||||
|
||||
std::string GenNativeType(BaseType type) {
|
||||
@@ -116,11 +111,18 @@ class JsonSchemaGenerator : public BaseGenerator {
|
||||
public:
|
||||
JsonSchemaGenerator(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name)
|
||||
: BaseGenerator(parser, path, file_name, "", "") {}
|
||||
: BaseGenerator(parser, path, file_name, "", "", "json") {}
|
||||
|
||||
explicit JsonSchemaGenerator(const BaseGenerator &base_generator)
|
||||
: BaseGenerator(base_generator) {}
|
||||
|
||||
std::string GeneratedFileName(const std::string &path,
|
||||
const std::string &file_name,
|
||||
const IDLOptions &options /* unused */) const {
|
||||
(void)options;
|
||||
return path + file_name + ".schema.json";
|
||||
}
|
||||
|
||||
bool generate() {
|
||||
if (parser_.root_struct_def_ == nullptr) { return false; }
|
||||
code_.Clear();
|
||||
@@ -203,7 +205,8 @@ class JsonSchemaGenerator : public BaseGenerator {
|
||||
GenFullName(parser_.root_struct_def_) + "\"";
|
||||
|
||||
code_ += "}"; // close schema root
|
||||
const std::string file_path = GeneratedFileName(path_, file_name_);
|
||||
const std::string file_path =
|
||||
GeneratedFileName(path_, file_name_, parser_.opts);
|
||||
const std::string final_code = code_.ToString();
|
||||
return SaveFile(file_path.c_str(), final_code, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user