• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CPP_CUSTOM_TYPES_CODE_EMITTER_H
10 #define OHOS_HDI_CPP_CUSTOM_TYPES_CODE_EMITTER_H
11 
12 #include "codegen/cpp_code_emitter.h"
13 
14 namespace OHOS {
15 namespace HDI {
16 class CppCustomTypesCodeEmitter : public CppCodeEmitter {
17 public:
CppCustomTypesCodeEmitter()18     CppCustomTypesCodeEmitter() : CppCodeEmitter() {}
19 
20     virtual ~CppCustomTypesCodeEmitter() = default;
21 
22 private:
23     bool ResolveDirectory(const std::string &targetDirectory) override;
24 
25     void EmitCode() override;
26 
27     void EmitPassthroughCustomTypesHeaderFile();
28 
29     void EmitPassthroughHeaderFileInclusions(StringBuilder& sb);
30 
31     void EmitCustomTypesHeaderFile();
32 
33     void EmitHeaderFileInclusions(StringBuilder &sb);
34 
35     void GetHeaderOtherLibInclusions(HeaderFile::HeaderFileSet &headerFiles);
36 
37     void EmitUsingNamespace(StringBuilder &sb) override;
38 
39     void EmitCustomTypeDecls(StringBuilder &sb);
40 
41     void EmitCustomTypeDecl(StringBuilder &sb, const AutoPtr<ASTType> &type);
42 
43     void EmitCustomTypeFuncDecl(StringBuilder &sb);
44 
45     void EmitCustomTypeMarshallingDecl(StringBuilder &sb, const AutoPtr<ASTStructType> &type);
46 
47     void EmitCustomTypeUnmarshallingDecl(StringBuilder &sb, const AutoPtr<ASTStructType> &type);
48 
49     void EmitCustomTypesSourceFile();
50 
51     void EmitSourceFileInclusions(StringBuilder &sb);
52 
53     void GetSourceOtherLibInclusions(HeaderFile::HeaderFileSet &headerFiles);
54 
55     void EmitCustomTypeDataProcess(StringBuilder &sb);
56 
57     void EmitCustomTypeMarshallingImpl(StringBuilder &sb, const AutoPtr<ASTStructType> &type);
58 
59     void EmitCustomTypeUnmarshallingImpl(StringBuilder &sb, const AutoPtr<ASTStructType> &type);
60 
61     void EmitBeginNamespace(StringBuilder &sb) override;
62 
63     void EmitEndNamespace(StringBuilder &sb) override;
64 
65     void GetUtilMethods(UtilMethodMap &methods) override;
66 };
67 } // namespace HDI
68 } // namespace OHOS
69 
70 #endif // OHOS_HDI_CPP_CUSTOM_TYPES_CODE_EMITTER_H