1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef OHOS_HDI_CPP_SERVICE_IMPL_CODE_EMITTER_H 10 #define OHOS_HDI_CPP_SERVICE_IMPL_CODE_EMITTER_H 11 12 #include "codegen/cpp_code_emitter.h" 13 14 namespace OHOS { 15 namespace HDI { 16 class CppServiceImplCodeEmitter : public CppCodeEmitter { 17 public: CppServiceImplCodeEmitter()18 CppServiceImplCodeEmitter() : CppCodeEmitter() {} 19 20 ~CppServiceImplCodeEmitter() override = default; 21 22 private: 23 bool ResolveDirectory(const std::string &targetDirectory) override; 24 25 void EmitCode() override; 26 27 void EmitImplHeaderFile(); 28 29 void EmitServiceImplInclusions(StringBuilder &sb); 30 31 void EmitServiceImplDecl(StringBuilder &sb); 32 33 void EmitServiceImplBody(StringBuilder &sb, const std::string &prefix); 34 35 void EmitServiceImplConstructor(StringBuilder &sb, const std::string &prefix) const; 36 37 void EmitServiceImplMethodDecls(StringBuilder &sb, const std::string &prefix) const; 38 39 void EmitServiceImplMethodDecl( 40 const AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix) const; 41 42 void EmitImplSourceFile(); 43 44 void EmitImplSourceInclusions(StringBuilder &sb); 45 46 void GetSourceOtherLibInclusions(HeaderFile::HeaderFileSet &headerFiles) const; 47 48 void EmitServiceImplMethodImpls(StringBuilder &sb, const std::string &prefix) const; 49 50 void EmitServiceImplMethodImpl( 51 const AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix) const; 52 53 void EmitExternalGetMethodImpl(StringBuilder &sb); 54 55 void EmitExternalReleaseMethodImpl(StringBuilder &sb); 56 57 void EmitServiceImplGetMethodImpl(StringBuilder &sb, const std::string &prefix) const; 58 }; 59 } // namespace HDI 60 } // namespace OHOS 61 62 #endif // OHOS_HDI_CPP_SERVICE_IMPL_CODE_EMITTER_H