mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 20:15:34 +00:00
removed extern code generation declarations preferring direct includes (#7948)
* removed extern code generation definitions, preferring direct includes * add static to functions * remove idl_gen_lua
This commit is contained in:
@@ -31,9 +31,46 @@
|
||||
#include "flatbuffers/util.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
namespace {
|
||||
|
||||
static std::string BinaryFileName(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name) {
|
||||
auto ext = parser.file_extension_.length() ? parser.file_extension_ : "bin";
|
||||
return path + file_name + "." + ext;
|
||||
}
|
||||
|
||||
static bool GenerateBinary(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name) {
|
||||
if (parser.opts.use_flexbuffers) {
|
||||
auto data_vec = parser.flex_builder_.GetBuffer();
|
||||
auto data_ptr = reinterpret_cast<char *>(data(data_vec));
|
||||
return !parser.flex_builder_.GetSize() ||
|
||||
flatbuffers::SaveFile(
|
||||
BinaryFileName(parser, path, file_name).c_str(), data_ptr,
|
||||
parser.flex_builder_.GetSize(), true);
|
||||
}
|
||||
return !parser.builder_.GetSize() ||
|
||||
flatbuffers::SaveFile(
|
||||
BinaryFileName(parser, path, file_name).c_str(),
|
||||
reinterpret_cast<char *>(parser.builder_.GetBufferPointer()),
|
||||
parser.builder_.GetSize(), true);
|
||||
}
|
||||
|
||||
static std::string BinaryMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name) {
|
||||
if (!parser.builder_.GetSize()) return "";
|
||||
std::string filebase =
|
||||
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
|
||||
std::string make_rule =
|
||||
BinaryFileName(parser, path, filebase) + ": " + file_name;
|
||||
auto included_files =
|
||||
parser.GetIncludedFilesRecursive(parser.root_struct_def_->file);
|
||||
for (auto it = included_files.begin(); it != included_files.end(); ++it) {
|
||||
make_rule += " " + *it;
|
||||
}
|
||||
return make_rule;
|
||||
}
|
||||
|
||||
class BinaryCodeGenerator : public CodeGenerator {
|
||||
public:
|
||||
Status GenerateCode(const Parser &parser, const std::string &path,
|
||||
|
||||
Reference in New Issue
Block a user