-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.cpp
67 lines (52 loc) · 1.72 KB
/
render.cpp
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
#include "render.hpp"
ClassRender::ClassRender(const ClassData &data, const std::string &template_name) : e(), t(e.parse_template(template_name)), arg_limit(1) {
d["constructors"] = inja::json::array();
d["methods"] = inja::json::array();
for (auto c : data.constr_vec()) {
inja::json args = inja::json::array();
for (CXType a : c) {
CXString s = clang_getTypeSpelling(a);
dispose_queue.push_back(s);
args.push_back({
{"name", clang_getCString(s)},
{"is_pointer", a.kind == CXType_Pointer},
});
}
if (args.size() > arg_limit)
arg_limit = args.size();
d["constructors"].push_back({
{"args", args},
});
}
for (auto m : data.method_vec()) {
inja::json args = inja::json::array();
for (CXType a : m.args) {
CXString s = clang_getTypeSpelling(a);
dispose_queue.push_back(s);
args.push_back({
{"name", clang_getCString(s)},
{"is_pointer", a.kind == CXType_Pointer},
});
}
if (args.size() > arg_limit)
arg_limit = args.size();
CXString s = clang_getCursorSpelling(m.name);
d["methods"].push_back({
{"name", clang_getCString(s)},
{"args", args}
});
dispose_queue.push_back(s);
}
d["arg_limit"] = arg_limit;
}
ClassRender &ClassRender::set(const char *key, const char *value) {
d[key] = value;
return *this;
}
void ClassRender::render_to(std::ostream &out) {
e.render_to(out, t, d);
}
ClassRender::~ClassRender() {
for (auto s : dispose_queue)
clang_disposeString(s);
}