From f92baf4078cb115390479ef6a91fdd68799c6923 Mon Sep 17 00:00:00 2001 From: j30052480 Date: Mon, 26 Feb 2024 20:01:51 +0800 Subject: [PATCH] idl support function with same name and nested enum Signed-off-by: j30052480 --- framework/tools/hdi-gen/ast/ast_method.cpp | 9 +++-- framework/tools/hdi-gen/ast/ast_method.h | 13 +++++- .../tools/hdi-gen/codegen/code_emitter.cpp | 5 ++- .../codegen/cpp_interface_code_emitter.cpp | 2 +- .../codegen/cpp_service_stub_code_emitter.cpp | 28 ++++++------- framework/tools/hdi-gen/parser/parser.cpp | 1 + .../target/foo/v1_0/foo_proxy.cpp.txt | 2 +- .../target/foo/v1_0/foo_stub.cpp.txt | 32 +++++++-------- .../target/foo/v1_0/ifoo.h.txt | 8 ++-- .../foo/v1_0/foo_callback_proxy.cpp.txt | 2 +- .../target/foo/v1_0/foo_callback_stub.cpp.txt | 16 ++++---- .../target/foo/v1_0/ifoo_callback.h.txt | 4 +- .../target/foo/v1_1/foo_proxy.cpp.txt | 2 +- .../target/foo/v1_1/foo_stub.cpp.txt | 40 +++++++++---------- .../target/foo/v1_1/ifoo.h.txt | 4 +- .../target/foo/v1_1/foo_stub.cpp.txt | 28 ++++++------- .../tools/hdi-gen/test/unittest/unit_test.py | 2 +- 17 files changed, 106 insertions(+), 92 deletions(-) diff --git a/framework/tools/hdi-gen/ast/ast_method.cpp b/framework/tools/hdi-gen/ast/ast_method.cpp index 6b0e94f7a..ac3b77090 100644 --- a/framework/tools/hdi-gen/ast/ast_method.cpp +++ b/framework/tools/hdi-gen/ast/ast_method.cpp @@ -13,21 +13,22 @@ namespace OHOS { namespace HDI { -bool ASTMethod::IsOverload(AutoPtr interface) +void ASTMethod::CheckOverload(AutoPtr interface) { if (interface == nullptr) { - return false; + return; } interface = interface->GetExtendsInterface(); while (interface != nullptr) { for (const auto &method : interface->GetMethodsBySystem(Options::GetInstance().GetSystemLevel())) { if (name_ == method->GetName()) { - return true; + isOverload_ = true; + return; } } interface = interface->GetExtendsInterface(); } - return false; + isOverload_ = false; } void ASTMethod::AddParameter(const AutoPtr ¶meter) diff --git a/framework/tools/hdi-gen/ast/ast_method.h b/framework/tools/hdi-gen/ast/ast_method.h index d7e4ab674..79be5afaa 100644 --- a/framework/tools/hdi-gen/ast/ast_method.h +++ b/framework/tools/hdi-gen/ast/ast_method.h @@ -61,7 +61,12 @@ public: return attr_->HasValue(ASTAttr::MINI); } - bool IsOverload(AutoPtr interface); + inline bool IsOverload() const + { + return isOverload_; + } + + void CheckOverload(AutoPtr interface); void AddParameter(const AutoPtr ¶meter); @@ -82,12 +87,18 @@ public: return cmdId_; } + inline std::string GetMethodIdentifier() + { + return isOverload_ ? "_" + std::to_string(cmdId_) : ""; + } + std::string Dump(const std::string &prefix) override; private: std::string name_; AutoPtr attr_ = new ASTAttr(); std::vector> parameters_; + bool isOverload_ = false; // used to identify if method is overload size_t cmdId_; // used to identify same name method }; } // namespace HDI diff --git a/framework/tools/hdi-gen/codegen/code_emitter.cpp b/framework/tools/hdi-gen/codegen/code_emitter.cpp index 289806139..e85a445f7 100644 --- a/framework/tools/hdi-gen/codegen/code_emitter.cpp +++ b/framework/tools/hdi-gen/codegen/code_emitter.cpp @@ -153,8 +153,9 @@ std::string CodeEmitter::InterfaceToFilePath(const std::string &interfaceName) c std::string CodeEmitter::EmitMethodCmdID(const AutoPtr &method) { - return StringHelper::Format("CMD_%s_%s_%d", - ConstantName(baseName_).c_str(), ConstantName(method->GetName()).c_str(), method->GetCmdId()); + return StringHelper::Format("CMD_%s_%s%s", + ConstantName(baseName_).c_str(), ConstantName(method->GetName()).c_str(), + method->GetMethodIdentifier().c_str()); } void CodeEmitter::EmitInterfaceMethodCommands(StringBuilder &sb, const std::string &prefix) diff --git a/framework/tools/hdi-gen/codegen/cpp_interface_code_emitter.cpp b/framework/tools/hdi-gen/codegen/cpp_interface_code_emitter.cpp index 16224d009..8ffe54daf 100644 --- a/framework/tools/hdi-gen/codegen/cpp_interface_code_emitter.cpp +++ b/framework/tools/hdi-gen/codegen/cpp_interface_code_emitter.cpp @@ -196,7 +196,7 @@ void CppInterfaceCodeEmitter::EmitInterfaceMethodsDecl(StringBuilder &sb, const void CppInterfaceCodeEmitter::EmitInterfaceMethodDecl( const AutoPtr &method, StringBuilder &sb, const std::string &prefix) const { - if (interface_->GetExtendsInterface() != nullptr && method->IsOverload(interface_)) { + if (interface_->GetExtendsInterface() != nullptr && method->IsOverload()) { sb.Append(prefix).AppendFormat("using %s::%s;\n", EmitDefinitionByInterface(interface_->GetExtendsInterface(), interfaceName_).c_str(), method->GetName().c_str()); diff --git a/framework/tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp b/framework/tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp index 2bba7d98d..257a4335f 100644 --- a/framework/tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp +++ b/framework/tools/hdi-gen/codegen/cpp_service_stub_code_emitter.cpp @@ -150,8 +150,8 @@ void CppServiceStubCodeEmitter::EmitStubMethodDecls(StringBuilder &sb, const std void CppServiceStubCodeEmitter::EmitStubMethodDecl( const AutoPtr &method, StringBuilder &sb, const std::string &prefix) const { - sb.Append(prefix).AppendFormat("int32_t %s%s_%d(MessageParcel& %s, MessageParcel& %s, MessageOption& %s);\n", - stubName_.c_str(), method->GetName().c_str(), method->GetCmdId(), + sb.Append(prefix).AppendFormat("int32_t %s%s%s(MessageParcel& %s, MessageParcel& %s, MessageOption& %s);\n", + stubName_.c_str(), method->GetName().c_str(), method->GetMethodIdentifier().c_str(), dataParcelName_.c_str(), replyParcelName_.c_str(), optionName_.c_str()); } @@ -159,8 +159,8 @@ void CppServiceStubCodeEmitter::EmitStubStaticMethodDecl( const AutoPtr &method, StringBuilder &sb, const std::string &prefix) const { sb.Append(prefix).AppendFormat( - "static int32_t %s%s_%d_(MessageParcel& %s, MessageParcel& %s, MessageOption& %s, sptr<%s> impl);\n", - stubName_.c_str(), method->GetName().c_str(), method->GetCmdId(), + "static int32_t %s%s%s_(MessageParcel& %s, MessageParcel& %s, MessageOption& %s, sptr<%s> impl);\n", + stubName_.c_str(), method->GetName().c_str(), method->GetMethodIdentifier().c_str(), dataParcelName_.c_str(), replyParcelName_.c_str(), optionName_.c_str(), EmitDefinitionByInterface(interface_, interfaceName_).c_str()); } @@ -345,15 +345,15 @@ void CppServiceStubCodeEmitter::EmitStubOnRequestMethodImpl(StringBuilder &sb, c AutoPtr getVerMethod = interface_->GetVersionMethod(); sb.Append(prefix + TAB + TAB).AppendFormat("case %s:\n", EmitMethodCmdID(getVerMethod).c_str()); sb.Append(prefix + TAB + TAB + TAB) - .AppendFormat("return %sStub%s_%d(data, reply, option);\n", - baseName_.c_str(), getVerMethod->GetName().c_str(), getVerMethod->GetCmdId()); + .AppendFormat("return %sStub%s%s(data, reply, option);\n", + baseName_.c_str(), getVerMethod->GetName().c_str(), getVerMethod->GetMethodIdentifier().c_str()); AutoPtr interface = interface_; while (interface != nullptr) { for (const auto &method : interface->GetMethodsBySystem(Options::GetInstance().GetSystemLevel())) { sb.Append(prefix + TAB + TAB).AppendFormat("case %s:\n", EmitMethodCmdID(method).c_str()); sb.Append(prefix + TAB + TAB + TAB) - .AppendFormat("return %sStub%s_%d(data, reply, option);\n", - baseName_.c_str(), method->GetName().c_str(), method->GetCmdId()); + .AppendFormat("return %sStub%s%s(data, reply, option);\n", + baseName_.c_str(), method->GetName().c_str(), method->GetMethodIdentifier().c_str()); } interface = interface->GetExtendsInterface(); } @@ -396,14 +396,14 @@ void CppServiceStubCodeEmitter::EmitStubMethodImpls(StringBuilder &sb, const std void CppServiceStubCodeEmitter::EmitStubMethodImpl(AutoPtr interface, const AutoPtr &method, StringBuilder &sb, const std::string &prefix) const { - sb.Append(prefix).AppendFormat("int32_t %s::%s%s_%d(MessageParcel& %s, MessageParcel& %s, MessageOption& %s)\n", + sb.Append(prefix).AppendFormat("int32_t %s::%s%s%s(MessageParcel& %s, MessageParcel& %s, MessageOption& %s)\n", EmitDefinitionByInterface(interface_, stubName_).c_str(), - stubName_.c_str(), method->GetName().c_str(), method->GetCmdId(), + stubName_.c_str(), method->GetName().c_str(), method->GetMethodIdentifier().c_str(), dataParcelName_.c_str(), replyParcelName_.c_str(), optionName_.c_str()); sb.Append(prefix).Append("{\n"); - sb.Append(prefix + TAB).AppendFormat("return %s::%s%s_%d_(%s, %s, %s, impl_);\n", + sb.Append(prefix + TAB).AppendFormat("return %s::%s%s%s_(%s, %s, %s, impl_);\n", EmitDefinitionByInterface(interface, stubName_).c_str(), - stubName_.c_str(), method->GetName().c_str(), method->GetCmdId(), + stubName_.c_str(), method->GetName().c_str(), method->GetMethodIdentifier().c_str(), dataParcelName_.c_str(), replyParcelName_.c_str(), optionName_.c_str()); sb.Append("}\n"); @@ -413,9 +413,9 @@ void CppServiceStubCodeEmitter::EmitStubStaticMethodImpl( const AutoPtr &method, StringBuilder &sb, const std::string &prefix) const { sb.Append(prefix).AppendFormat( - "int32_t %s::%s%s_%d_(MessageParcel& %s, MessageParcel& %s, MessageOption& %s, sptr<%s> impl)\n", + "int32_t %s::%s%s%s_(MessageParcel& %s, MessageParcel& %s, MessageOption& %s, sptr<%s> impl)\n", EmitDefinitionByInterface(interface_, stubName_).c_str(), - stubName_.c_str(), method->GetName().c_str(), method->GetCmdId(), + stubName_.c_str(), method->GetName().c_str(), method->GetMethodIdentifier().c_str(), dataParcelName_.c_str(), replyParcelName_.c_str(), optionName_.c_str(), EmitDefinitionByInterface(interface_, interfaceName_).c_str()); sb.Append(prefix).Append("{\n"); diff --git a/framework/tools/hdi-gen/parser/parser.cpp b/framework/tools/hdi-gen/parser/parser.cpp index 063065244..a03d2d0b5 100644 --- a/framework/tools/hdi-gen/parser/parser.cpp +++ b/framework/tools/hdi-gen/parser/parser.cpp @@ -554,6 +554,7 @@ AutoPtr Parser::ParseMethod(const AutoPtr &interfac extInterface = extInterface->GetExtendsInterface(); } method->SetCmdId(methodsCount); + method->CheckOverload(interface); return method; } diff --git a/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/foo_proxy.cpp.txt b/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/foo_proxy.cpp.txt index 9c69b0d39..ce35eb762 100644 --- a/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/foo_proxy.cpp.txt +++ b/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/foo_proxy.cpp.txt @@ -96,7 +96,7 @@ int32_t OHOS::HDI::Foo::V1_0::FooProxy::Ping_(const std::string& sendMsg, std::s return HDF_ERR_INVALID_OBJECT; } - int32_t fooRet = remote->SendRequest(CMD_FOO_PING_1, fooData, fooReply, fooOption); + int32_t fooRet = remote->SendRequest(CMD_FOO_PING, fooData, fooReply, fooOption); if (fooRet != HDF_SUCCESS) { HDF_LOGE("%{public}s failed, error code is %{public}d", __func__, fooRet); return fooRet; diff --git a/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/foo_stub.cpp.txt b/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/foo_stub.cpp.txt index f5a240ff2..789ee3807 100644 --- a/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/foo_stub.cpp.txt +++ b/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/foo_stub.cpp.txt @@ -29,14 +29,14 @@ sptr OHOS::HDI::Foo::V1_0::IFoo::Get(const std::stri int32_t OHOS::HDI::Foo::V1_0::FooStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { switch (code) { - case CMD_FOO_GET_VERSION_0: - return FooStubGetVersion_0(data, reply, option); - case CMD_FOO_PING_1: - return FooStubPing_1(data, reply, option); - case CMD_FOO_GET_DATA_2: - return FooStubGetData_2(data, reply, option); - case CMD_FOO_INFO_TEST_3: - return FooStubInfoTest_3(data, reply, option); + case CMD_FOO_GET_VERSION: + return FooStubGetVersion(data, reply, option); + case CMD_FOO_PING: + return FooStubPing(data, reply, option); + case CMD_FOO_GET_DATA: + return FooStubGetData(data, reply, option); + case CMD_FOO_INFO_TEST: + return FooStubInfoTest(data, reply, option); default: { HDF_LOGE("%{public}s: cmd %{public}d is not supported", __func__, code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -44,15 +44,15 @@ int32_t OHOS::HDI::Foo::V1_0::FooStub::OnRemoteRequest(uint32_t code, MessagePar } } -int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubPing_1(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubPing(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubGetData_2(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubGetData(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubInfoTest_3(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubInfoTest(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubGetVersion_0(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubGetVersion(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubPing_1_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) +int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubPing_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) { if (fooData.ReadInterfaceToken() != OHOS::HDI::Foo::V1_0::IFoo::GetDescriptor()) { HDF_LOGE("%{public}s: interface token check failed!", __func__); @@ -101,8 +101,8 @@ int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubPing_1_(MessageParcel& fooData, Me return fooRet; } -int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubGetData_2_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) +int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubGetData_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) -int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubInfoTest_3_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) +int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubInfoTest_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) -int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubGetVersion_0_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) \ No newline at end of file +int32_t OHOS::HDI::Foo::V1_0::FooStub::FooStubGetVersion_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) \ No newline at end of file diff --git a/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/ifoo.h.txt b/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/ifoo.h.txt index b72a58638..3d09ddd1c 100644 --- a/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/ifoo.h.txt +++ b/framework/tools/hdi-gen/test/unittest/02_standard_interface_idl/target/foo/v1_0/ifoo.h.txt @@ -27,10 +27,10 @@ using namespace OHOS; using namespace OHOS::HDI; enum { - CMD_FOO_GET_VERSION_0 = 0, - CMD_FOO_PING_1 = 1, - CMD_FOO_GET_DATA_2 = 2, - CMD_FOO_INFO_TEST_3 = 3, + CMD_FOO_GET_VERSION = 0, + CMD_FOO_PING = 1, + CMD_FOO_GET_DATA = 2, + CMD_FOO_INFO_TEST = 3, }; class IFoo : public HdiBase { diff --git a/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/foo_callback_proxy.cpp.txt b/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/foo_callback_proxy.cpp.txt index 3219dbf47..5604be422 100644 --- a/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/foo_callback_proxy.cpp.txt +++ b/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/foo_callback_proxy.cpp.txt @@ -33,7 +33,7 @@ int32_t OHOS::HDI::Foo::V1_0::FooCallbackProxy::PushData_(const std::string& mes return HDF_ERR_INVALID_OBJECT; } - int32_t fooCallbackRet = remote->SendRequest(CMD_FOO_CALLBACK_PUSH_DATA_1, fooCallbackData, fooCallbackReply, fooCallbackOption); + int32_t fooCallbackRet = remote->SendRequest(CMD_FOO_CALLBACK_PUSH_DATA, fooCallbackData, fooCallbackReply, fooCallbackOption); if (fooCallbackRet != HDF_SUCCESS) { HDF_LOGE("%{public}s failed, error code is %{public}d", __func__, fooCallbackRet); return fooCallbackRet; diff --git a/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/foo_callback_stub.cpp.txt b/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/foo_callback_stub.cpp.txt index d5444c6df..3dc7df1d6 100644 --- a/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/foo_callback_stub.cpp.txt +++ b/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/foo_callback_stub.cpp.txt @@ -7,10 +7,10 @@ int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { switch (code) { - case CMD_FOO_CALLBACK_GET_VERSION_0: - return FooCallbackStubGetVersion_0(data, reply, option); - case CMD_FOO_CALLBACK_PUSH_DATA_1: - return FooCallbackStubPushData_1(data, reply, option); + case CMD_FOO_CALLBACK_GET_VERSION: + return FooCallbackStubGetVersion(data, reply, option); + case CMD_FOO_CALLBACK_PUSH_DATA: + return FooCallbackStubPushData(data, reply, option); default: { HDF_LOGE("%{public}s: cmd %{public}d is not supported", __func__, code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -18,11 +18,11 @@ int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::OnRemoteRequest(uint32_t code, Me } } -int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubPushData_1(MessageParcel& fooCallbackData, MessageParcel& fooCallbackReply, MessageOption& fooCallbackOption) +int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubPushData(MessageParcel& fooCallbackData, MessageParcel& fooCallbackReply, MessageOption& fooCallbackOption) -int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubGetVersion_0(MessageParcel& fooCallbackData, MessageParcel& fooCallbackReply, MessageOption& fooCallbackOption) +int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubGetVersion(MessageParcel& fooCallbackData, MessageParcel& fooCallbackReply, MessageOption& fooCallbackOption) -int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubPushData_1_(MessageParcel& fooCallbackData, MessageParcel& fooCallbackReply, MessageOption& fooCallbackOption, sptr impl) +int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubPushData_(MessageParcel& fooCallbackData, MessageParcel& fooCallbackReply, MessageOption& fooCallbackOption, sptr impl) { if (fooCallbackData.ReadInterfaceToken() != OHOS::HDI::Foo::V1_0::IFooCallback::GetDescriptor()) { HDF_LOGE("%{public}s: interface token check failed!", __func__); @@ -50,4 +50,4 @@ int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubPushData_1_(Messag return fooCallbackRet; } -int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubGetVersion_0_(MessageParcel& fooCallbackData, MessageParcel& fooCallbackReply, MessageOption& fooCallbackOption, sptr impl) \ No newline at end of file +int32_t OHOS::HDI::Foo::V1_0::FooCallbackStub::FooCallbackStubGetVersion_(MessageParcel& fooCallbackData, MessageParcel& fooCallbackReply, MessageOption& fooCallbackOption, sptr impl) \ No newline at end of file diff --git a/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/ifoo_callback.h.txt b/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/ifoo_callback.h.txt index aabfea55f..2ffcd16d6 100644 --- a/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/ifoo_callback.h.txt +++ b/framework/tools/hdi-gen/test/unittest/03_standard_callback_idl/target/foo/v1_0/ifoo_callback.h.txt @@ -2,8 +2,8 @@ using namespace OHOS; using namespace OHOS::HDI; enum { - CMD_FOO_CALLBACK_GET_VERSION_0 = 0, - CMD_FOO_CALLBACK_PUSH_DATA_1 = 1, + CMD_FOO_CALLBACK_GET_VERSION = 0, + CMD_FOO_CALLBACK_PUSH_DATA = 1, }; class IFooCallback : public HdiBase { diff --git a/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/foo_proxy.cpp.txt b/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/foo_proxy.cpp.txt index 6e3dabf56..9691d1f3d 100644 --- a/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/foo_proxy.cpp.txt +++ b/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/foo_proxy.cpp.txt @@ -143,7 +143,7 @@ int32_t OHOS::HDI::Foo::V1_1::FooProxy::TestPingV1_1_(const std::string& sendMsg return HDF_ERR_INVALID_OBJECT; } - int32_t fooRet = remote->SendRequest(CMD_FOO_TEST_PING_V1_1_4, fooData, fooReply, fooOption); + int32_t fooRet = remote->SendRequest(CMD_FOO_TEST_PING_V1_1, fooData, fooReply, fooOption); if (fooRet != HDF_SUCCESS) { HDF_LOGE("%{public}s failed, error code is %{public}d", __func__, fooRet); return fooRet; diff --git a/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/foo_stub.cpp.txt b/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/foo_stub.cpp.txt index af7aebf1d..30ba2b36d 100644 --- a/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/foo_stub.cpp.txt +++ b/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/foo_stub.cpp.txt @@ -29,18 +29,18 @@ sptr OHOS::HDI::Foo::V1_1::IFoo::Get(const std::stri int32_t OHOS::HDI::Foo::V1_1::FooStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { switch (code) { - case CMD_FOO_GET_VERSION_0: - return FooStubGetVersion_0(data, reply, option); - case CMD_FOO_TEST_PING_V1_1_4: - return FooStubTestPingV1_1_4(data, reply, option); - case CMD_FOO_TEST_GET_DATA_5: - return FooStubTestGetData_5(data, reply, option); - case CMD_FOO_PING_1: - return FooStubPing_1(data, reply, option); - case CMD_FOO_GET_DATA_2: - return FooStubGetData_2(data, reply, option); - case CMD_FOO_INFO_TEST_3: - return FooStubInfoTest_3(data, reply, option); + case CMD_FOO_GET_VERSION: + return FooStubGetVersion(data, reply, option); + case CMD_FOO_TEST_PING_V1_1: + return FooStubTestPingV1_1(data, reply, option); + case CMD_FOO_TEST_GET_DATA: + return FooStubTestGetData(data, reply, option); + case CMD_FOO_PING: + return FooStubPing(data, reply, option); + case CMD_FOO_GET_DATA: + return FooStubGetData(data, reply, option); + case CMD_FOO_INFO_TEST: + return FooStubInfoTest(data, reply, option); default: { HDF_LOGE("%{public}s: cmd %{public}d is not supported", __func__, code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -48,19 +48,19 @@ int32_t OHOS::HDI::Foo::V1_1::FooStub::OnRemoteRequest(uint32_t code, MessagePar } } -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestPingV1_1_4(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestPingV1_1(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestGetData_5(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestGetData(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubPing_1(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubPing(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetData_2(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetData(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubInfoTest_3(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubInfoTest(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetVersion_0(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetVersion(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestPingV1_1_4_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestPingV1_1_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) { if (fooData.ReadInterfaceToken() != OHOS::HDI::Foo::V1_1::IFoo::GetDescriptor()) { HDF_LOGE("%{public}s: interface token check failed!", __func__); @@ -109,4 +109,4 @@ int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestPingV1_1_4_(MessageParcel& foo return fooRet; } -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestGetData_5_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) \ No newline at end of file +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubTestGetData_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) \ No newline at end of file diff --git a/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/ifoo.h.txt b/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/ifoo.h.txt index 989d4d478..083af8e8b 100644 --- a/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/ifoo.h.txt +++ b/framework/tools/hdi-gen/test/unittest/04_extended_interface_idl/target/foo/v1_1/ifoo.h.txt @@ -12,8 +12,8 @@ using namespace OHOS::HDI; using namespace OHOS::HDI::Foo::V1_0; enum { - CMD_FOO_TEST_PING_V1_1_4 = 4, - CMD_FOO_TEST_GET_DATA_5 = 5, + CMD_FOO_TEST_PING_V1_1 = 4, + CMD_FOO_TEST_GET_DATA = 5, }; class IFoo : public OHOS::HDI::Foo::V1_0::IFoo { diff --git a/framework/tools/hdi-gen/test/unittest/08_overload_method_idl/target/foo/v1_1/foo_stub.cpp.txt b/framework/tools/hdi-gen/test/unittest/08_overload_method_idl/target/foo/v1_1/foo_stub.cpp.txt index 8d8989fb6..354eaa4d2 100644 --- a/framework/tools/hdi-gen/test/unittest/08_overload_method_idl/target/foo/v1_1/foo_stub.cpp.txt +++ b/framework/tools/hdi-gen/test/unittest/08_overload_method_idl/target/foo/v1_1/foo_stub.cpp.txt @@ -10,18 +10,18 @@ int32_t OHOS::HDI::Foo::V1_1::FooStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { switch (code) { - case CMD_FOO_GET_VERSION_0: - return FooStubGetVersion_0(data, reply, option); - case CMD_FOO_PING_4: + case CMD_FOO_GET_VERSION: + return FooStubGetVersion(data, reply, option); + case CMD_FOO_PING: return FooStubPing_4(data, reply, option); - case CMD_FOO_GET_DATA_5: + case CMD_FOO_GET_DATA: return FooStubGetData_5(data, reply, option); - case CMD_FOO_PING_1: - return FooStubPing_1(data, reply, option); - case CMD_FOO_GET_DATA_2: - return FooStubGetData_2(data, reply, option); - case CMD_FOO_INFO_TEST_3: - return FooStubInfoTest_3(data, reply, option); + case CMD_FOO_PING: + return FooStubPing(data, reply, option); + case CMD_FOO_GET_DATA: + return FooStubGetData(data, reply, option); + case CMD_FOO_INFO_TEST: + return FooStubInfoTest(data, reply, option); default: { HDF_LOGE("%{public}s: cmd %{public}d is not supported", __func__, code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -33,13 +33,13 @@ int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubPing_4(MessageParcel& fooData, Mes int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetData_5(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubPing_1(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubPing(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetData_2(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetData(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubInfoTest_3(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubInfoTest(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) -int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetVersion_0(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) +int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubGetVersion(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption) int32_t OHOS::HDI::Foo::V1_1::FooStub::FooStubPing_4_(MessageParcel& fooData, MessageParcel& fooReply, MessageOption& fooOption, sptr impl) { diff --git a/framework/tools/hdi-gen/test/unittest/unit_test.py b/framework/tools/hdi-gen/test/unittest/unit_test.py index c72c251ac..12d2dab4c 100644 --- a/framework/tools/hdi-gen/test/unittest/unit_test.py +++ b/framework/tools/hdi-gen/test/unittest/unit_test.py @@ -29,7 +29,7 @@ def is_subsequence(first_file, second_file): second_info = second_file.readline() while second_info: if first_info.find(second_info) == -1: - print("line\n", second_info, "is not in output file", first_file_path) + print("line\n", second_info, "is not in output file") return False second_info = second_file.readline() return True -- Gitee