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_SA_CPP_CUSTOM_TYPES_CODE_EMITTER_H 17 #define OHOS_IDL_SA_CPP_CUSTOM_TYPES_CODE_EMITTER_H 18 19 #include "sa_cpp_code_emitter.h" 20 21 namespace OHOS { 22 namespace Idl { 23 24 class SaCppCustomTypesCodeEmitter : public SACppCodeEmitter { 25 public: SaCppCustomTypesCodeEmitter()26 SaCppCustomTypesCodeEmitter() : SACppCodeEmitter() {} 27 28 ~SaCppCustomTypesCodeEmitter() override = default; 29 30 private: 31 void EmitCode() override; 32 33 void EmitCustomTypesHeaderFile(); 34 35 void EmitHeaderFileInclusions(StringBuilder &sb); 36 37 void EmitUsingNamespace(StringBuilder &sb); 38 39 void EmitDefineConstant(StringBuilder &sb) const; 40 41 void EmitCustomTypeDecls(StringBuilder &sb) const; 42 43 void EmitCustomTypeFuncDecl(StringBuilder &sb) const; 44 45 void EmitCustomTypeMarshallFuncDecl(StringBuilder &sb, const AutoPtr<ASTType> &type) const; 46 47 void EmitCustomTypesSourceFile(); 48 49 void EmitSourceFileInclusions(StringBuilder &sb); 50 51 void GetSourceOtherLibInclusions(HeaderFile::HeaderFileSet &headerFiles) const; 52 53 void EmitCustomTypeDataProcess(StringBuilder &sb) const; 54 55 void EmitCustomTypeMarshallingImpl(StringBuilder &sb, const AutoPtr<ASTStructType> &type) const; 56 57 void EmitCustomTypeUnmarshallingImpl(StringBuilder &sb, const AutoPtr<ASTStructType> &type) const; 58 59 void EmitCustomTypeUnmarshallingImplNoPod(StringBuilder &sb, const AutoPtr<ASTStructType> &type) const; 60 61 bool EmitCustomTypeNeedSecurec(const AutoPtr<ASTStructType> &type) const; 62 63 void EmitBeginNamespace(StringBuilder &sb); 64 65 void EmitEndNamespace(StringBuilder &sb); 66 }; 67 } // namespace Idl 68 } // namespace OHOS 69 70 #endif // OHOS_IDL_SA_CPP_CUSTOM_TYPES_CODE_EMITTER_H