• 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_C_CODE_EMITTER_H
10 #define OHOS_HDI_C_CODE_EMITTER_H
11 
12 #include "ast/ast.h"
13 #include "codegen/code_emitter.h"
14 #include "util/autoptr.h"
15 #include "util/string.h"
16 #include "util/string_builder.h"
17 
18 namespace OHOS {
19 namespace HDI {
20 class CCodeEmitter : public CodeEmitter {
21 public:
22     virtual ~CCodeEmitter() = default;
23 protected:
24     void GetImportInclusions(HeaderFile::HeaderFileSet& headerFiles);
25 
26     void EmitInterfaceMethodParameter(const AutoPtr<ASTParameter>& parameter, StringBuilder& sb, const String& prefix);
27 
28     void EmitInitLoopVar(const AutoPtr<ASTMethod>& method, StringBuilder& sb, const String& prefix);
29 
30     void EmitErrorHandle(const AutoPtr<ASTMethod>& method, const String& gotoLabel, bool isClient, StringBuilder& sb,
31         const String& prefix);
32 
33     void EmitLicense(StringBuilder& sb);
34 
35     void EmitHeadMacro(StringBuilder& sb, const String& fullName);
36 
37     void EmitTailMacro(StringBuilder& sb, const String& fullName);
38 
39     void EmitHeadExternC(StringBuilder& sb);
40 
41     void EmitTailExternC(StringBuilder& sb);
42 
43     String EmitDescMacroName();
44 
45     String MacroName(const String& name);
46 
47     String ConstantName(const String& name);
48 
49     String SpecificationParam(StringBuilder& sb, const String& prefix);
50 
51     static constexpr const char *errorsLabelName_ = "ERRORS";
52     static constexpr const char *finishedLabelName_ = "FINISHED";
53 };
54 } // namespace HDI
55 } // namespace OHOS
56 
57 #endif // OHOS_HDI_C_CODE_EMITTER_H