aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/csharp/csharp_generator.cc
diff options
context:
space:
mode:
authorJan Tattermusch <jtattermusch@google.com>2015-09-23 15:12:17 -0700
committerJan Tattermusch <jtattermusch@google.com>2015-09-23 15:12:17 -0700
commitc31f11deb41b38dd162e5718dfbfa7e4eb1304ea (patch)
treea09a37af8215c1d21eed3160477bed7d827525e0 /src/google/protobuf/compiler/csharp/csharp_generator.cc
parent97a1c1e08d87ca8c669418a6c46d605d3d602497 (diff)
downloadprotobuf-c31f11deb41b38dd162e5718dfbfa7e4eb1304ea.tar.gz
protobuf-c31f11deb41b38dd162e5718dfbfa7e4eb1304ea.tar.bz2
protobuf-c31f11deb41b38dd162e5718dfbfa7e4eb1304ea.zip
expose GetOutputFile in csharp_names.h
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_generator.cc')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_generator.cc37
1 files changed, 1 insertions, 36 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc
index 95ff48ae..f5ff880f 100644
--- a/src/google/protobuf/compiler/csharp/csharp_generator.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc
@@ -50,41 +50,6 @@ namespace protobuf {
namespace compiler {
namespace csharp {
-std::string GetOutputFile(
- const google::protobuf::FileDescriptor* file,
- const std::string file_extension,
- const bool generate_directories,
- const std::string base_namespace,
- string* error) {
- string relative_filename = GetUmbrellaClassUnqualifiedName(file) + file_extension;
- if (!generate_directories) {
- return relative_filename;
- }
- string ns = GetFileNamespace(file);
- string namespace_suffix = ns;
- if (!base_namespace.empty()) {
- // Check that the base_namespace is either equal to or a leading part of
- // the file namespace. This isn't just a simple prefix; "Foo.B" shouldn't
- // be regarded as a prefix of "Foo.Bar". The simplest option is to add "."
- // to both.
- string extended_ns = ns + ".";
- if (extended_ns.find(base_namespace + ".") != 0) {
- *error = "Namespace " + ns + " is not a prefix namespace of base namespace " + base_namespace;
- return ""; // This will be ignored, because we've set an error.
- }
- namespace_suffix = ns.substr(base_namespace.length());
- if (namespace_suffix.find(".") == 0) {
- namespace_suffix = namespace_suffix.substr(1);
- }
- }
-
- string namespace_dir = StringReplace(namespace_suffix, ".", "/", true);
- if (!namespace_dir.empty()) {
- namespace_dir += "/";
- }
- return namespace_dir + relative_filename;
-}
-
void GenerateFile(const google::protobuf::FileDescriptor* file,
io::Printer* printer) {
UmbrellaClassGenerator umbrellaGenerator(file);
@@ -123,7 +88,7 @@ bool Generator::Generate(
string filename_error = "";
std::string filename = GetOutputFile(file, file_extension, generate_directories, base_namespace, &filename_error);
- if (!filename_error.empty()) {
+ if (filename.empty()) {
*error = filename_error;
return false;
}