Refactored the Java and C# code generators into one.

Also made the C# implementation support unsigned types, and
made it more like the Java version.

Bug: 17359988
Change-Id: If5305c08cd5c97f35426639516ce05e53bbec36c
Tested: on Linux and Windows.
This commit is contained in:
Wouter van Oortmerssen
2014-09-16 17:37:17 -07:00
parent d01b30cdd6
commit 557c88c039
23 changed files with 516 additions and 722 deletions

View File

@@ -26,7 +26,7 @@ namespace cpp {
// Return a C++ type from the table in idl.h
static std::string GenTypeBasic(const Type &type) {
static const char *ctypename[] = {
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE) #CTYPE,
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE) #CTYPE,
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
#undef FLATBUFFERS_TD
};
@@ -96,16 +96,6 @@ static std::string GenTypeGet(const Parser &parser, const Type &type,
: beforeptr + GenTypePointer(parser, type) + afterptr;
}
// Generate a documentation comment, if available.
static void GenComment(const std::string &dc,
std::string *code_ptr,
const char *prefix = "") {
std::string &code = *code_ptr;
if (dc.length()) {
code += std::string(prefix) + "///" + dc + "\n";
}
}
static std::string GenEnumVal(const EnumDef &enum_def, const EnumVal &enum_val,
const GeneratorOptions &opts) {
return opts.prefixed_enums ? enum_def.name + "_" + enum_val.name