diff options
author | Shauren <shauren.trinity@gmail.com> | 2016-03-26 22:01:03 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2016-03-26 22:01:03 +0100 |
commit | 0d3a81b2bccf2a45f11a5765b3ed17bbcd3addff (patch) | |
tree | a5aaffc5489c131739a57b18f085fcdea4715c76 /contrib/protoc-bnet/BnetServiceGenerator.cpp | |
parent | 7de5842f08645f24f20e24baf2a57cc4291db37e (diff) |
Contrib: Updated protoc plugin to generate service classes suitable for dynamic linking
Diffstat (limited to 'contrib/protoc-bnet/BnetServiceGenerator.cpp')
-rw-r--r-- | contrib/protoc-bnet/BnetServiceGenerator.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/protoc-bnet/BnetServiceGenerator.cpp b/contrib/protoc-bnet/BnetServiceGenerator.cpp index 955eb00bd70..29afb07b23e 100644 --- a/contrib/protoc-bnet/BnetServiceGenerator.cpp +++ b/contrib/protoc-bnet/BnetServiceGenerator.cpp @@ -38,8 +38,8 @@ void BnetServiceGenerator::GenerateInterface(pb::io::Printer* printer) "{\n" " public:\n" "\n" - " template<typename HashSelector>\n" - " explicit $classname$(HashSelector) : service_hash_(HashSelector::Result::value) { }\n" + " explicit $classname$(bool use_original_hash);\n" + " virtual ~$classname$();\n" "\n" "$original_hash$" "$name_hash$"); @@ -139,6 +139,12 @@ void BnetServiceGenerator::GenerateDescriptorInitializer(pb::io::Printer* printe void BnetServiceGenerator::GenerateImplementation(pb::io::Printer* printer) { printer->Print(vars_, + "$classname$::$classname$(bool use_original_hash) : service_hash_(use_original_hash ? OriginalHash::value : NameHash::value) {\n" + "}\n" + "\n" + "$classname$::~$classname$() {\n" + "}\n" + "\n" "google::protobuf::ServiceDescriptor const* $classname$::descriptor() {\n" " protobuf_AssignDescriptorsOnce();\n" " return $classname$_descriptor_;\n" @@ -170,7 +176,7 @@ void BnetServiceGenerator::GenerateClientMethodImplementations(pb::io::Printer* if (method->output_type()->name() != "NO_RESPONSE") { printer->Print(sub_vars, - "void $classname$::$name$($input_type$ const* request, std::function<void($output_type$ const*)> responseCallback) { \n" + "void $classname$::$name$($input_type$ const* request, std::function<void($output_type$ const*)> responseCallback) {\n" " TC_LOG_DEBUG(\"service.protobuf\", \"%s Server called client method $full_name$($input_type_name${ %s })\",\n" " GetCallerInfo().c_str(), request->ShortDebugString().c_str());\n" " std::function<void(MessageBuffer)> callback = [responseCallback](MessageBuffer buffer) -> void {\n" |