fixed bfbs gen to pass extra options (#7949)

This commit is contained in:
Derek Bailey
2023-05-09 22:42:31 -07:00
committed by GitHub
parent 10b79d87c1
commit 3e6cd51b63
26 changed files with 572 additions and 305 deletions

View File

@@ -28,6 +28,7 @@
#include "bfbs_namer.h"
// The intermediate representation schema.
#include "flatbuffers/code_generator.h"
#include "flatbuffers/reflection.h"
#include "flatbuffers/reflection_generated.h"
@@ -78,7 +79,10 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
flatc_version_(flatc_version),
namer_(LuaDefaultConfig(), LuaKeywords()) {}
Status GenerateFromSchema(const r::Schema *schema) FLATBUFFERS_OVERRIDE {
Status GenerateFromSchema(const r::Schema *schema,
const CodeGenOptions &options)
FLATBUFFERS_OVERRIDE {
options_ = options;
if (!GenerateEnums(schema->enums())) { return ERROR; }
if (!GenerateObjects(schema->objects(), schema->root_table())) {
return ERROR;
@@ -89,7 +93,7 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
using BaseBfbsGenerator::GenerateCode;
Status GenerateCode(const Parser &, const std::string &,
const std::string &) FLATBUFFERS_OVERRIDE {
const std::string &) override {
return Status::NOT_IMPLEMENTED;
}
@@ -652,12 +656,14 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
// TODO(derekbailey): figure out a save file without depending on util.h
EnsureDirExists(path);
const std::string file_name = path + "/" + namer_.File(name);
const std::string file_name = options_.output_path + path + "/" + namer_.File(name);
SaveFile(file_name.c_str(), code, false);
}
std::unordered_set<std::string> keywords_;
std::map<std::string, std::string> requires_;
CodeGenOptions options_;
const r::Object *current_obj_;
const r::Enum *current_enum_;
const std::string flatc_version_;