Skip to content

Commit

Permalink
Moved qualify method name to new class to make common for all hidl ge…
Browse files Browse the repository at this point in the history
…nerated services
  • Loading branch information
kenrowland committed Jul 1, 2024
1 parent 145f79e commit 2831bc0
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 35 deletions.
1 change: 1 addition & 0 deletions esp/bindings/SOAP/Platform/soapbind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "espbinding.hpp"
#include "http/platform/httpbinding.hpp"

#include <initializer_list>

class esp_http_decl CSoapComplexType : implements IRpcSerializable, public CInterface
{
Expand Down
50 changes: 50 additions & 0 deletions esp/bindings/SOAP/Platform/soaphidlbind.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
############################################################################## */

#pragma warning( disable : 4786 )

#include "soaphidlbind.hpp"

void CHttpSoapHidlBinding::registerMethodNames(std::initializer_list<const char *> names)
{
for (const char *name : names)
{
std::string methodNameKey(name);
std::transform(methodNameKey.cbegin(), methodNameKey.cend(), methodNameKey.begin(), tolower);
m_qualifiedMethodNames.emplace(methodNameKey.c_str(), name);
}
}

bool CHttpSoapHidlBinding::qualifyMethodName(IEspContext &context, const char *methname, StringBuffer *methQName)
{
if (!methname || !*methname)
{
if (methQName != nullptr)
methQName->clear();
return true;
}
std::string methodName(methname);
std::transform(methodName.cbegin(), methodName.cend(), methodName.begin(), tolower);
auto it = m_qualifiedMethodNames.find(methodName);
if (it != m_qualifiedMethodNames.end())
{
if (methQName != nullptr)
methQName->set(it->second.c_str());
return true;
}
return false;
}
37 changes: 37 additions & 0 deletions esp/bindings/SOAP/Platform/soaphidlbind.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
############################################################################## */

#ifndef _SOAPHIDLBIND_HPP__
#define _SOAPHIDLBIND_HPP__

#include "soapbind.hpp"

class esp_http_decl CHttpSoapHidlBinding : public CHttpSoapBinding
{
public:
CHttpSoapHidlBinding(IPropertyTree* cfg, const char *bindname=NULL, const char *procname=NULL, http_soap_log_level level=hsl_none) :
CHttpSoapBinding(cfg, bindname, procname, level) {}
virtual bool qualifyMethodName(IEspContext &context, const char *methname, StringBuffer *methQName);

protected:
virtual void registerMethodNames(std::initializer_list<const char *> names);

private:
std::map<std::string, std::string> m_qualifiedMethodNames;
};

#endif
1 change: 1 addition & 0 deletions esp/protocols/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ set(SRCS
../../bindings/http/platform/msgbuilder.cpp
../../bindings/SOAP/client/soapclient.cpp
../../bindings/SOAP/Platform/soapbind.cpp
../../bindings/SOAP/Platform/soaphidlbind.cpp
../../bindings/SOAP/Platform/soapmessage.cpp
../../bindings/SOAP/Platform/soapservice.cpp
../../bindings/SOAP/Platform/soapparam.cpp
Expand Down
53 changes: 18 additions & 35 deletions tools/hidl/hidlcomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3932,7 +3932,7 @@ void EspServInfo::write_esp_binding_ipp()
{
EspMethodInfo *mthi=NULL;

outf("\n\nclass C%sSoapBinding : public CHttpSoapBinding\n", name_);
outf("\n\nclass C%sSoapBinding : public CHttpSoapHidlBinding\n", name_);
outs("{\npublic:\n");

//dom
Expand Down Expand Up @@ -3960,9 +3960,6 @@ void EspServInfo::write_esp_binding_ipp()
//method ==> isValidServiceName
outs("\tbool isValidServiceName(IEspContext &context, const char *name);\n");

//method ==> qualifyMethodName
outs("\tbool qualifyMethodName(IEspContext &context, const char *methname, StringBuffer *methQName);\n");

//method ==> qualifyServiceName
outs("\tbool qualifyServiceName(IEspContext &context, const char *servname, const char *methname, StringBuffer &servQName, StringBuffer *methQName);\n");

Expand Down Expand Up @@ -4084,13 +4081,13 @@ void EspServInfo::write_esp_binding(const char *packagename)
StrBuffer servicefeatureurl;
getMetaStringValue(servicefeatureurl,FEATEACCESSATTRIBUTE);

outf("\nC%sSoapBinding::C%sSoapBinding(http_soap_log_level level):CHttpSoapBinding(NULL, NULL, NULL, level)\n", name_, name_);
outf("\nC%sSoapBinding::C%sSoapBinding(http_soap_log_level level):CHttpSoapHidlBinding(NULL, NULL, NULL, level)\n", name_, name_);
outf("{\n");
outf("\tinit_strings();\n");
outf("\tsetWsdlVersion(%s);\n", wsdlVer.str());
outf("}\n");

outf("\nC%sSoapBinding::C%sSoapBinding(IPropertyTree* cfg, const char *bindname, const char *procname, http_soap_log_level level):CHttpSoapBinding(cfg, bindname, procname, level)\n", name_, name_);
outf("\nC%sSoapBinding::C%sSoapBinding(IPropertyTree* cfg, const char *bindname, const char *procname, http_soap_log_level level):CHttpSoapHidlBinding(cfg, bindname, procname, level)\n", name_, name_);
outf("{\n");
outf("\tinit_strings();\n");
outf("\tinit_metrics();\n");
Expand Down Expand Up @@ -4168,13 +4165,23 @@ void EspServInfo::write_esp_binding(const char *packagename)
// init_maps implementation
outf("\nvoid C%sSoapBinding::init_maps()\n", name_);
outs("{\n");
outs("\tstd::initializer_list<const char *> names = {\n");
for (mthi=methods; mthi!= nullptr; mthi=mthi->next)
{
std::string methodNameKey(mthi->getName());
std::transform(methodNameKey.cbegin(), methodNameKey.cend(), methodNameKey.begin(), tolower);
outf("\tm_qualifiedMethodNames.emplace(\"%s\", \"%s\");\n", methodNameKey.c_str(), mthi->getName());
outf("\t\t\"%s\"", mthi->getName());
if (mthi->next != nullptr)
{
outs(",\n");
}
else
{
outs("\n");
}
}
outs("}\n");
outs("\t};\n");

outs("\tregisterMethodNames(names);\n");
outs("}");

outf("\nint C%sSoapBinding::processRequest(IRpcMessage* rpc_call, IRpcMessage* rpc_response)\n", name_);
outs("{\n");
Expand Down Expand Up @@ -4379,31 +4386,6 @@ void EspServInfo::write_esp_binding(const char *packagename)
outs(2, "return (hasSubService(context, name));\n");
outs("}\n");

//method ==> qualifyMethodName
outf("\nbool C%sSoapBinding::qualifyMethodName(IEspContext &context, const char *methname, StringBuffer *methQName)\n", name_);
outs("{\n");

outs("\tif (!methname || !*methname)\n");
outs("\t{\n");
outs("\t\tif (methQName!=NULL)\n");
outs("\t\t\tmethQName->clear();\n");
outs("\t\treturn true;\n");
outs("\t}\n");

outs("\tstd::string methodName(methname);\n");
outs("\tstd::transform(methodName.cbegin(), methodName.cend(), methodName.begin(), tolower);\n");
outs("\tauto it = m_qualifiedMethodNames.find(methodName);\n");
outs("\tif (it != m_qualifiedMethodNames.end())\n");
outs("\t{\n");
outs("\t\tif (methQName != nullptr)\n");
outs("\t\t\tmethQName->set(it->second.c_str());\n");
outs("\t\treturn true;\n");
outs("\t}\n");

outs("\treturn false;\n");
outs("}\n");


//method ==> qualifyServiceName
outf("\nbool C%sSoapBinding::qualifyServiceName(IEspContext &context, const char *servname, const char *methname, StringBuffer &servQName, StringBuffer *methQName)\n", name_);
outs("{\n");
Expand Down Expand Up @@ -5565,6 +5547,7 @@ void HIDLcompiler::write_esp_ex_ipp()
outs("#include \"SOAP/Platform/soapmacro.hpp\"\n");
outs("#include \"SOAP/Platform/soapservice.hpp\"\n");
outs("#include \"SOAP/Platform/soapparam.hpp\"\n");
outs("#include \"SOAP/Platform/soaphidlbind.hpp\"\n");
outs("#include \"SOAP/client/soapclient.hpp\"\n");
outs("\n\n");

Expand Down

0 comments on commit 2831bc0

Please sign in to comment.