-
Notifications
You must be signed in to change notification settings - Fork 1
/
MetaMethodRef.cpp
63 lines (53 loc) · 1.08 KB
/
MetaMethodRef.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
#include "MetaMethodRef.h"
#include "MetaMethodSignature.h"
#include <vector>
#include "clang/Basic/LangOptions.h"
#include "clang/Frontend/CompilerInstance.h"
MetaMethodRef::MetaMethodRef(std::string rawString, clang::CompilerInstance &instance) :
mRawString(rawString),
mType(MetaMethodType::Invalid)
{
if (rawString.length() < 1)
{
// XXX: How?
return;
}
// Skip the type part for now
std::string declaration(rawString.substr(1));
mSignature = MetaMethodSignature(declaration, instance);
if (!mSignature.isValid())
{
// Not a valid signature
return;
}
// Looks valid!
switch(rawString[0])
{
case '1':
mType = MetaMethodType::Slot;
break;
case '2':
mType = MetaMethodType::Signal;
break;
}
}
std::string MetaMethodRef::spelling() const
{
if (!isValid())
{
return "(invalid)";
}
return typeSpelling() + " " + signature().spelling();
}
std::string MetaMethodRef::typeSpelling() const
{
switch(type())
{
case MetaMethodType::Invalid:
return "(invalid)";
case MetaMethodType::Signal:
return "signal";
case MetaMethodType::Slot:
return "slot";
}
}