diff --git a/framework/tools/hdi-gen/ast/ast_method.cpp b/framework/tools/hdi-gen/ast/ast_method.cpp index 6b0e94f7ab4b15c6550375afc34a682aee4418ac..ac3b77090a1ec083cb0424a60b13f3276744fdba 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 d7e4ab67412214df7cd5d0e9530ca08246a9e5fa..79be5afaa0951f8cec285a9f9323268772f50da3 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 2898061396091d3998de7167a0bb4eb8f6a75c62..e85a445f704c2e3f2ee295e3d2c6811ef7816afa 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 16224d00908c8b2ced32d90d6efc5a3a135296eb..8ffe54dafe3fc3f5c968c6f89b48285d2abb53c6 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 2bba7d98d571576423c41b9b53b12609a83261e3..257a4335fc273b7245a905a92247e121edb9180e 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 063065244adca1c2e5176a094dd1e52b3d7ce238..a03d2d0b53ca22e94d6609f229b6e8937522ab9f 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 9c69b0d39e2ab2eb01d3289678d5fb478666edfa..ce35eb7626cac9cb100d796ded5f6d283df9907b 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 f5a240ff28616a1a52edb23002e699c15c068dd2..789ee38071c153b047a9d32e1c8d9fc6e7cbc85b 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 b72a58638372d2ebbc419e975132970b9a36bac9..3d09ddd1c4c4decb15d9bd7dc08d3e99a9fd1f0d 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 3219dbf47f5e349bfeb6aab3ea435595716ad356..5604be42220d29e146d51c41e440bbabaecbca57 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 d5444c6df763d43ffb505616063b9e63b3058a37..3dc7df1d6ffe9d5ca1a19ad5ce539897645ff60a 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 aabfea55fb08dc5fcb1a39c558bd22096383b3e7..2ffcd16d6b4e2302cccb9d3e4953495872e88dda 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 6e3dabf56ef478a884c4336f9c24a0bdf9a2c550..9691d1f3d3eb047b38f86bd7f16a88a077195dba 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 af7aebf1d81434ebebd2f2e239367d3d2377d825..30ba2b36da3b864e602690605b09514fde509e08 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 989d4d478768ced4b4a0ab93d55a84321a2d9721..083af8e8baef89a808dcb9a26d422231915fe47c 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 8d8989fb667bd8e8ae90a5c489f6d0df36ef7034..354eaa4d2e8cc267eb0c2bb17889b4ca2d315cd6 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 c72c251aca9431523675729ab3974bde36338b2a..12d2dab4c109459b6cb18fc234a60f2079ee4d4b 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