From 929105432c0ef7eb469ce4bf979c79b51a9af73d Mon Sep 17 00:00:00 2001 From: Jeremie St-Amand Date: Sun, 14 Jun 2015 12:56:48 -0400 Subject: [PATCH] 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. --- src/idl_gen_general.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/idl_gen_general.cpp b/src/idl_gen_general.cpp index 9e34a2e37..a212bf932 100644 --- a/src/idl_gen_general.cpp +++ b/src/idl_gen_general.cpp @@ -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); }