Repository navigation
Expand file tree
/
Copy pathCategory.cpp
More file actions
75 lines (59 loc) · 1.81 KB
/
Copy pathCategory.cpp
File metadata and controls
75 lines (59 loc) · 1.81 KB
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
#include "IR.h"
namespace metagen {
CategoryDecl::CategoryDecl(CXCursor cursor) {
this->cursor = cursor;
framework = getFrameworkName(cursor);
CXString cxname = clang_getCursorSpelling(cursor);
name = clang_getCString(cxname);
clang_disposeString(cxname);
clang_visitChildren(
cursor,
[](CXCursor cursor, CXCursor, CXClientData clientData) {
if (!isAvailable(cursor)) {
return CXChildVisit_Continue;
}
auto cls = (CategoryDecl *)clientData;
CXCursorKind kind = clang_getCursorKind(cursor);
switch (kind) {
case CXCursor_ObjCClassRef: {
CXString name = clang_getCursorSpelling(cursor);
std::string nameStr = clang_getCString(name);
cls->className = nameStr;
clang_disposeString(name);
break;
}
default:
break;
}
return CXChildVisit_Continue;
},
this);
}
void CategoryDecl::processMembers(
std::vector<std::string> *classTypeParameters) {
_classTypeParameters = classTypeParameters;
clang_visitChildren(
cursor,
[](CXCursor cursor, CXCursor, CXClientData clientData) {
if (!isAvailable(cursor)) {
return CXChildVisit_Continue;
}
auto cls = (CategoryDecl *)clientData;
CXCursorKind kind = clang_getCursorKind(cursor);
switch (kind) {
case CXCursor_ObjCPropertyDecl:
case CXCursor_ObjCClassMethodDecl:
case CXCursor_ObjCInstanceMethodDecl: {
auto member = MemberDecl(cursor, cls->_classTypeParameters);
member.parentClassName = cls->className;
cls->members.emplace_back(member);
break;
}
default:
break;
}
return CXChildVisit_Continue;
},
this);
}
} // namespace metagen