• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_NATIVE_BUFFER_H
10 #define OHOS_HDI_NATIVE_BUFFER_H
11 
12 #include "ast/ast_type.h"
13 
14 namespace OHOS {
15 namespace HDI {
16 class ASTNativeBufferType : public ASTType {
17 public:
ASTNativeBufferType()18     ASTNativeBufferType() : ASTType(TypeKind::TYPE_NATIVE_BUFFER, false) {}
19 
20     bool IsNativeBufferType() override;
21 
22     std::string ToString() const override;
23 
24     TypeKind GetTypeKind() override;
25 
26     std::string EmitCType(TypeMode mode = TypeMode::NO_MODE) const override;
27 
28     std::string EmitCppType(TypeMode mode = TypeMode::NO_MODE) const override;
29 
30     void EmitCWriteVar(const std::string &parcelName, const std::string &name, const std::string &ecName,
31         const std::string &gotoLabel, StringBuilder &sb, const std::string &prefix) const override;
32 
33     void EmitCProxyReadVar(const std::string &parcelName, const std::string &name, bool isInnerType,
34         const std::string &ecName, const std::string &gotoLabel, StringBuilder &sb,
35         const std::string &prefix) const override;
36 
37     void EmitCStubReadVar(const std::string &parcelName, const std::string &name, const std::string &ecName,
38         const std::string &gotoLabel, StringBuilder &sb, const std::string &prefix) const override;
39 
40     void EmitCppWriteVar(const std::string &parcelName, const std::string &name, StringBuilder &sb,
41         const std::string &prefix, unsigned int innerLevel = 0) const override;
42 
43     void EmitCppReadVar(const std::string &parcelName, const std::string &name, StringBuilder &sb,
44         const std::string &prefix, bool initVariable, unsigned int innerLevel = 0) const override;
45 
46     void EmitCMarshalling(const std::string &name, StringBuilder &sb, const std::string &prefix) const override;
47 
48     void EmitCUnMarshalling(const std::string &name, const std::string &gotoLabel, StringBuilder &sb,
49         const std::string &prefix, std::vector<std::string> &freeObjStatements) const override;
50 
51     void EmitCppMarshalling(const std::string &parcelName, const std::string &name, StringBuilder &sb,
52         const std::string &prefix, unsigned int innerLevel = 0) const override;
53 
54     void EmitCppUnMarshalling(const std::string &parcelName, const std::string &name, StringBuilder &sb,
55         const std::string &prefix, bool emitType, unsigned int innerLevel = 0) const override;
56 
57     void EmitMemoryRecycle(const std::string &name,
58         bool isClient, bool ownership, StringBuilder &sb, const std::string &prefix) const override;
59 };
60 } // namespace HDI
61 } // namespace OHOS
62 
63 #endif // OHOS_HDI_NATIVE_BUFFER_H