• 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 private:
22     bool ResolveDirectory(const String& targetDirectory) override;
23 
24     void EmitCode() override;
25 
26     void EmitCustomTypesHeaderFile();
27 
28     void EmitHeaderFileInclusions(StringBuilder& sb);
29 
30     void GetHeaderOtherLibInclusions(HeaderFile::HeaderFileSet& headerFiles);
31 
32     void EmitCustomTypeDecls(StringBuilder& sb);
33 
34     void EmitCustomTypeDecl(StringBuilder& sb, const AutoPtr<ASTType>& type);
35 
36     void EmitCustomTypeFuncDecl(StringBuilder& sb);
37 
38     void EmitCustomTypeMarshallingDecl(StringBuilder& sb, const AutoPtr<ASTStructType>& type);
39 
40     void EmitCustomTypeUnmarshallingDecl(StringBuilder& sb, const AutoPtr<ASTStructType>& type);
41 
42     void EmitCustomTypesSourceFile();
43 
44     void EmitSourceFileInclusions(StringBuilder& sb);
45 
46     void GetSourceOtherLibInclusions(HeaderFile::HeaderFileSet& headerFiles);
47 
48     void EmitCustomTypeDataProcess(StringBuilder& sb);
49 
50     void EmitCustomTypeMarshallingImpl(StringBuilder& sb, const AutoPtr<ASTStructType>& type);
51 
52     void EmitCustomTypeUnmarshallingImpl(StringBuilder& sb, const AutoPtr<ASTStructType>& type);
53 
54     void EmitBeginNamespace(StringBuilder& sb) override;
55 
56     void EmitEndNamespace(StringBuilder& sb) override;
57 };
58 } // namespace HDI
59 } // namespace OHOS
60 
61 #endif // OHOS_HDI_CPP_CUSTOM_TYPES_CODE_EMITTER_H