-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClassScope.h
65 lines (52 loc) · 1.21 KB
/
ClassScope.h
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
#ifndef CLASSSCOPE_H
#define CLASSSCOPE_H
#include "Scope.h"
// Qt includes
#include <QtCore/QSharedPointer>
// Local includes
#include "BindedFunction.h"
#include "ClassPrototype.h"
#include "Expression.h"
#include "NameMangling.h"
template<class T>
class ClassScope : public Scope
{
public:
ClassScope(ClassPrototype<T>* prototype)
: m_classInstance(0), m_prototype(prototype)
{
}
virtual ~ClassScope()
{
delete m_classInstance;
}
virtual QVariant asQVariant() const
{
return QVariant(*m_classInstance);
}
bool isValidFunction(const QString &functionName) const
{
return m_prototype->isValidFunction(functionName);
}
QMetaType::Type functionReturnType(const QString &functionName) const
{
return m_prototype->functionReturnType(functionName);
}
QVariant execute(const QString &functionName, const QList<Expression*> ¶meters)
{
QString mangledFunctionName = NameMangling::mangleFunctionName(functionName,parameters);
BindedFunction<T> *function = m_prototype->function(mangledFunctionName);
if(function)
{
return function->execute(m_classInstance, parameters);
}
else
{
return QVariant();
}
}
T* m_classInstance;
protected:
ClassPrototype<T>* m_prototype;
};
#endif