• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SERVICE_STUB_CODE_EMITTER_H
17 #define OHOS_IDL_SA_CPP_SERVICE_STUB_CODE_EMITTER_H
18 
19 #include "sa_cpp_code_emitter.h"
20 
21 namespace OHOS {
22 namespace Idl {
23 class SaCppServiceStubCodeEmitter : public SACppCodeEmitter {
24 public:
SaCppServiceStubCodeEmitter()25     SaCppServiceStubCodeEmitter() : SACppCodeEmitter() {}
26 
27     ~SaCppServiceStubCodeEmitter() override = default;
28 
29 private:
30     void EmitCode() override;
31 
32     // ISample.idl -> sample_service_stub.h
33     void EmitStubHeaderFile();
34 
35     void EmitInterfaceStubInHeaderFile(StringBuilder &sb);
36 
37     void EmitInterfaceStubMethodDecls(StringBuilder &sb, const std::string &prefix) const;
38 
39     void EmitStubSourceFile();
40 
41     void EmitInterfaceStubMethodImpls(StringBuilder &sb, const std::string &prefix) const;
42 
43     void EmitInterfaceStubUseHooks(StringBuilder &sb, const std::string &prefix) const;
44 
45     void EmitInterfaceParcelUseHooks(StringBuilder &sb, const std::string &prefix) const;
46 
47     void EmitInterfaceStubMethodImpl(AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix) const;
48 
49     void EmitInterfaceStubMethodService(AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix,
50         bool hasOutParameter) const;
51 
52     void EmitInterfaceStubFdClose(TypeKind kind, const std::string &name, StringBuilder &sb,
53         const std::string &prefix) const;
54 
55     void EmitInterfaceStubMethodCall(AutoPtr<ASTMethod> &method, StringBuilder &sb, const std::string &prefix) const;
56 
57     void EmitLocalVariable(const AutoPtr<ASTParameter> &param, StringBuilder &sb, const std::string &prefix) const;
58 
59     static void EmitSaReturnParameter(const std::string &name, TypeKind kind, StringBuilder &sb);
60 
61     void EmitInterfaceProxyIpcCapacityValues(StringBuilder &sb, const std::string &prefix);
62 
63     void EmitInterfaceSetIpcCapacity(AutoPtr <ASTMethod> &method, StringBuilder &sb, const std::string &prefix) const;
64 };
65 } // namespace Idl
66 } // namespace OHOS
67 
68 #endif // OHOS_IDL_SA_CPP_SERVICE_STUB_CODE_EMITTER_H