Transition 1 (with nice diffs) Go, Cpp and General code generators with class

This commit is contained in:
Lakedaemon
2016-04-13 23:21:18 +02:00
parent 9f2b05df1b
commit 8a64afabfd
5 changed files with 126 additions and 24 deletions

View File

@@ -21,6 +21,7 @@
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
#include "flatbuffers/code_generators.h"
#ifdef _WIN32
#include <direct.h>
@@ -660,11 +661,12 @@ static void GenStructBuilder(const StructDef &struct_def,
EndBuilderBody(code_ptr);
}
} // namespace go
bool GenerateGo(const Parser &parser,
const std::string &path,
const std::string & /*file_name*/) {
class GoGenerator : public BaseGenerator {
public:
GoGenerator(const Parser &parser_, const std::string &path_,
const std::string &file_name_)
: BaseGenerator(parser_, path_, file_name_){};
bool generate() {
for (auto it = parser.enums_.vec.begin();
it != parser.enums_.vec.end(); ++it) {
std::string enumcode;
@@ -682,6 +684,15 @@ bool GenerateGo(const Parser &parser,
}
return true;
}
};
} // namespace go
bool GenerateGo(const Parser &parser,
const std::string &path,
const std::string & file_name) {
go::GoGenerator *generator = new go::GoGenerator(parser, path, file_name);
return generator->generate();
}
} // namespace flatbuffers