1 /* 2 * Copyright (c) 2021 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_JAVA_CLIENT_PROXY_CODE_EMITTER_H 10 #define OHOS_HDI_JAVA_CLIENT_PROXY_CODE_EMITTER_H 11 12 #include "java_code_emitter.h" 13 #include "util/file.h" 14 15 namespace OHOS { 16 namespace HDI { 17 class JavaClientProxyCodeEmitter : public JavaCodeEmitter { 18 public: JavaClientProxyCodeEmitter()19 JavaClientProxyCodeEmitter() : JavaCodeEmitter() {} 20 21 virtual ~JavaClientProxyCodeEmitter() = default; 22 23 private: 24 bool ResolveDirectory(const std::string &targetDirectory) override; 25 26 void EmitCode() override; 27 28 void EmitProxyFile(); 29 30 void EmitProxyImports(StringBuilder &sb); 31 32 void EmitProxyCorelibImports(StringBuilder &sb); 33 34 void EmitProxySelfDefinedTypeImports(StringBuilder &sb); 35 36 void EmitProxyDBinderImports(StringBuilder &sb); 37 38 void EmitProxyImpl(StringBuilder &sb); 39 40 void EmitProxyConstants(StringBuilder &sb, const std::string &prefix); 41 42 void EmitProxyConstructor(StringBuilder &sb, const std::string &prefix); 43 44 void EmitProxyMethodImpls(StringBuilder &sb, const std::string &prefix); 45 46 void EmitProxyMethodImpl(const AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix); 47 48 void EmitInterfaceMethodParameter(const AutoPtr<ASTParameter> ¶m, StringBuilder &sb, const std::string &prefix); 49 50 void EmitProxyMethodBody(const AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix); 51 52 void EmitReadMethodParameter(const AutoPtr<ASTParameter> ¶m, const std::string &parcelName, StringBuilder &sb, 53 const std::string &prefix); 54 55 void EmitReadVariable(const std::string &parcelName, const std::string &name, const AutoPtr<ASTType> &type, 56 ParamAttr attribute, StringBuilder &sb, const std::string &prefix); 57 58 void EmitReadArrayVariable(const std::string &parcelName, const std::string &name, 59 const AutoPtr<ASTArrayType> &arrayType, ParamAttr attribute, StringBuilder &sb, const std::string &prefix); 60 61 void EmitReadOutArrayVariable(const std::string &parcelName, const std::string &name, 62 const AutoPtr<ASTArrayType> &arrayType, StringBuilder &sb, const std::string &prefix); 63 64 void EmitReadOutVariable(const std::string &parcelName, const std::string &name, const AutoPtr<ASTType> &type, 65 StringBuilder &sb, const std::string &prefix); 66 67 void EmitLocalVariable(const AutoPtr<ASTParameter> ¶m, StringBuilder &sb, const std::string &prefix); 68 }; 69 } // namespace HDI 70 } // namespace OHOS 71 72 #endif // OHOS_HDI_JAVA_CLIENT_PROXY_CODE_EMITTER_H