KVIrc
4.9.2
DeveloperAPIs
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
modules
objects
object_macros.h
Go to the documentation of this file.
1
#ifndef _OBJECT_MACROS_H_
2
#define _OBJECT_MACROS_H_
3
//=============================================================================
4
//
5
// File : object_macros.h
6
// Creation date : Sat Jun 18 2005 15:32:01 by Szymon Stefanek
7
//
8
// This file is part of the KVIrc IRC client distribution
9
// Copyright (C) 2005-2010 Szymon Stefanek (pragma at kvirc dot net)
10
//
11
// This program is FREE software. You can redistribute it and/or
12
// modify it under the terms of the GNU General Public License
13
// as published by the Free Software Foundation; either version 2
14
// of the License, or (at your option) any later version.
15
//
16
// This program is distributed in the HOPE that it will be USEFUL,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
// See the GNU General Public License for more details.
20
//
21
// You should have received a copy of the GNU General Public License
22
// along with this program. If not, write to the Free Software Foundation,
23
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
//
25
//=============================================================================
26
27
#include "
KviKvsKernel.h
"
28
#include "
KviKvsObject.h
"
29
#include "
KviKvsObjectClass.h
"
30
#include "
KviKvsObjectController.h
"
31
#include "
KviKvsObjectFunctionCall.h
"
32
33
#define KVSO_DECLARE_OBJECT(__className) \
34
__className(KviKvsObjectClass * pClass, KviKvsObject * pParent, const QString & szName); \
35
~__className(); \
36
static void registerSelf(); \
37
static void unregisterSelf();
38
39
#define SET_OBJECT(__className) \
40
__className * obj = new __className(parentScriptWidget()); \
41
obj->setObjectName(getName()); \
42
setObject(obj, true);
43
44
#define KVSO_REGISTER_HANDLER(__className, __szName, __proc) \
45
g_pKvs##__className##Class->registerFunctionHandler(__szName, (KviKvsObjectFunctionHandlerProc)(KVI_PTR2MEMBER(__className::__proc)));
46
47
// TEST
48
#define KVSO_REGISTER_HANDLER_BY_NAME(__className, __szName) \
49
g_pKvs##__className##Class->registerFunctionHandler(#__szName, (KviKvsObjectFunctionHandlerProc)(KVI_PTR2MEMBER(__className::__szName)));
50
51
#define KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(__className, __szName) \
52
g_pKvs##__className##Class->registerStandardNothingReturnFunctionHandler(__szName);
53
54
#define KVSO_REGISTER_STANDARD_TRUERETURN_HANDLER(__className, __szName) \
55
g_pKvs##__className##Class->registerStandardTrueReturnFunctionHandler(__szName);
56
57
#define KVSO_REGISTER_STANDARD_FALSERETURN_HANDLER(__className, __szName) \
58
g_pKvs##__className##Class->registerStandardFalseReturnFunctionHandler(__szName);
59
60
#define KVSO_BEGIN_REGISTERCLASS(__className, __stringName, __baseClass) \
61
static KviKvsObjectClass * g_pKvs##__className##Class = 0; \
62
static KviKvsObject * kvs_##__className##_createInstance(KviKvsObjectClass * pClass, KviKvsObject * pParent, const QString & szName) \
63
{ \
64
return new __className(pClass, pParent, szName); \
65
} \
66
void __className::unregisterSelf() \
67
{ \
68
delete g_pKvs##__className##Class; \
69
g_pKvs##__className##Class = 0; \
70
} \
71
void __className::registerSelf() \
72
{ \
73
KviKvsObjectClass * base = KviKvsKernel::instance()->objectController()->lookupClass(__baseClass); \
74
g_pKvs##__className##Class = new KviKvsObjectClass(base, __stringName, kvs_##__className##_createInstance, true);
75
76
#define KVSO_END_REGISTERCLASS(__className) \
77
}
78
79
#define KVSO_BEGIN_CONSTRUCTOR(__className, __baseClass) \
80
__className::__className(KviKvsObjectClass * pClass, KviKvsObject * pParent, const QString & szName) \
81
: __baseClass(pClass, pParent, szName) \
82
{
83
84
#define KVSO_END_CONSTRUCTOR(__className) \
85
}
86
87
#define KVSO_BEGIN_DESTRUCTOR(__className) \
88
__className::~__className() \
89
{
90
91
#define KVSO_END_DESTRUCTOR(__className) \
92
}
93
94
#define KVSO_CLASS_FUNCTION(__className, __functionName) \
95
bool KvsObject_##__className::__functionName(KviKvsObjectFunctionCall * c)
96
97
#define CHECK_INTERNAL_POINTER(__pointer) \
98
if(!__pointer) \
99
{ \
100
c->error(__tr2qs_ctx("Internal error: no valid pointer for this object", "objects")); \
101
return false; \
102
}
103
#define CHECK_HOBJECT_IS_WIDGET(__pObject) \
104
if(!__pObject) \
105
{ \
106
c->warning(__tr2qs_ctx("Widget parameter is not an object", "objects")); \
107
return true; \
108
} \
109
if(!__pObject->object()) \
110
{ \
111
c->warning(__tr2qs_ctx("Widget parameter is not a valid object", "objects")); \
112
return true; \
113
} \
114
if(!__pObject->object()->isWidgetType()) \
115
{ \
116
c->warning(__tr2qs_ctx("Widget object required", "objects")); \
117
return true; \
118
}
119
#endif
KviKvsObject.h
KviKvsObjectFunctionCall.h
KviKvsKernel.h
KviKvsObjectClass.h
KviKvsObjectController.h
Generated on Mon May 16 2016 22:48:47 for KVIrc by
1.8.7