1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IDLC_C_GEN_C_BODY_GEN_BASE_H_
#define IDLC_C_GEN_C_BODY_GEN_BASE_H_
#include <memory>
#include <string>
#include <map>
#include "idlc/c_gen/c_gen_base.h"
namespace tidl {
class CBodyGeneratorBase : public CGeneratorBase {
public:
explicit CBodyGeneratorBase(std::shared_ptr<Document> doc);
virtual ~CBodyGeneratorBase() = default;
void GenStructures(std::ofstream& stream);
void GenIncludeHeader(std::ofstream& stream);
void GenLogTag(std::ofstream& stream, const std::string& log_tag);
void GenInterfaceEnumerations(std::ofstream& stream, const Interface& inf);
std::string GetParcelWriteFunctionString(const BaseType& type,
bool meta_type = false);
std::string GetParcelReadFunctionString(const BaseType& type,
bool meta_type = false);
std::string GetDestructorString(const BaseType& type,
const std::string& value,
bool container_value = false);
std::string GetConstructorString(const BaseType& type,
const std::string& value);
bool HasDelegate(const Interface& inf) const;
void GenLogDefinition(std::ofstream& stream);
private:
void GenInterfaceMethodEnumeration(std::ofstream& stream,
const Interface& inf);
void GenInterfaceDelegateEnumeration(std::ofstream& stream,
const Interface& inf);
private:
void GenStructure(std::ofstream& stream, const Structure& st);
void GenStructureDeclaration(std::ofstream& stream, const Structure& st);
void GenStructureParcelSerializer(std::ofstream& stream, const Structure& st);
void GenStructureParcelDeserializer(std::ofstream& stream,
const Structure& st);
void GenStructureConstructor(std::ofstream& stream, const Structure& st);
void GenStructureDestructor(std::ofstream& stream, const Structure& st);
void GenStructureSetter(std::ofstream& stream, const Structure& st);
void GenStructureGetter(std::ofstream& stream, const Structure& st);
void GenStructureIterator(std::ofstream& stream, const Structure& st);
void GenStructureCloner(std::ofstream& stream, const Structure& st);
private:
std::string GetParcelTypeString(const BaseType& type, bool meta_type);
std::string GetParcelWriteString(const std::string& id, const BaseType& type);
std::string GetParcelReadString(const std::string& id, const BaseType& type);
std::string GetFinalizeString(const std::string& id, const BaseType& type);
std::string GetSetterString(const std::string& id, const BaseType& type);
std::string GetGetterString(const std::string& id, const BaseType& type);
std::string GetIteratorString(const std::string& id, const BaseType& type);
std::string GetClonerString(const std::string& id, const BaseType& type,
const Structure& st);
std::string GetSetterString(const BaseType& type, const std::string& lvalue,
const std::string& rvalue);
std::string GetSetterString(const std::string& lvalue,
const std::string& rvalue);
private:
std::map<std::string, std::string> parcel_type_map_;
};
} // namespace tidl
#endif // IDLC_C_GEN_C_BODY_GEN_BASE_H_
|