Namespace now optional for general generator

If you have a schema with no namespace, the resulting C#/Java won't have
an erroneous empty namespace keyword.
This commit is contained in:
Jeremie St-Amand 2015-06-14 12:56:48 -04:00
parent 932b22f043
commit 929105432c
1 changed files with 5 additions and 3 deletions

View File

@ -875,11 +875,13 @@ static bool SaveClass(const LanguageParameters &lang, const Parser &parser,
EnsureDirExists(namespace_dir);
std::string code = "// automatically generated, do not modify\n\n";
code += lang.namespace_ident + namespace_general + lang.namespace_begin;
code += "\n\n";
if (!namespace_general.empty()) {
code += lang.namespace_ident + namespace_general + lang.namespace_begin;
code += "\n\n";
}
if (needs_includes) code += lang.includes;
code += classcode;
code += lang.namespace_end;
if (!namespace_general.empty()) code += lang.namespace_end;
auto filename = namespace_dir + def.name + lang.file_extension;
return SaveFile(filename.c_str(), code, false);
}