1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_IDL_JAVA_CLIENT_PROXY_CODE_EMITTER_H 17 #define OHOS_IDL_JAVA_CLIENT_PROXY_CODE_EMITTER_H 18 19 #include "hdi_java_code_emitter.h" 20 #include "util/file.h" 21 22 namespace OHOS { 23 namespace Idl { 24 class JavaClientProxyCodeEmitter : public HDIJavaCodeEmitter { 25 public: JavaClientProxyCodeEmitter()26 JavaClientProxyCodeEmitter() : HDIJavaCodeEmitter() {} 27 28 ~JavaClientProxyCodeEmitter() override = default; 29 30 private: 31 bool ResolveDirectory(const std::string &targetDirectory) override; 32 33 void EmitCode() override; 34 35 void EmitProxyFile(); 36 37 void EmitProxyImports(StringBuilder &sb) const; 38 39 void EmitProxyCorelibImports(StringBuilder &sb) const; 40 41 void EmitProxySelfDefinedTypeImports(StringBuilder &sb) const; 42 43 void EmitProxyDBinderImports(StringBuilder &sb) const; 44 45 void EmitProxyImpl(StringBuilder &sb); 46 47 void EmitProxyConstants(StringBuilder &sb, const std::string &prefix); 48 49 void EmitProxyConstructor(StringBuilder &sb, const std::string &prefix) const; 50 51 void EmitProxyMethodImpls(StringBuilder &sb, const std::string &prefix) const; 52 53 void EmitProxyMethodImpl(const AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix) const; 54 55 void EmitProxyMethodBody(const AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix) const; 56 57 void EmitReadOutArrayVariable(const std::string &parcelName, const std::string &name, 58 const AutoPtr<ASTArrayType> &arrayType, StringBuilder &sb, const std::string &prefix); 59 60 void EmitReadOutVariable(const std::string &parcelName, const std::string &name, const AutoPtr<ASTType> &type, 61 StringBuilder &sb, const std::string &prefix); 62 63 void EmitLocalVariable(const AutoPtr<ASTParameter> ¶m, StringBuilder &sb, const std::string &prefix) const; 64 65 void EmitParamWriteVar(const AutoPtr<ASTParameter> ¶m, 66 const std::string &parcelName, StringBuilder &sb, const std::string &prefix) const; 67 }; 68 } // namespace Idl 69 } // namespace OHOS 70 71 #endif // OHOS_IDL_JAVA_CLIENT_PROXY_CODE_EMITTER_H