Fixed crash when joining new channels
[quassel.git] / src / contrib / qxt / qxtboundcfunction.h
1 /****************************************************************************
2 **
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
4 **
5 ** This file is part of the QxtCore module of the Qt eXTension library
6 **
7 ** This library is free software; you can redistribute it and/or modify it
8 ** under the terms of th Common Public License, version 1.0, as published by
9 ** IBM.
10 **
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
14 ** FITNESS FOR A PARTICULAR PURPOSE.
15 **
16 ** You should have received a copy of the CPL along with this file.
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
18 ** distribution for more information. If you did not receive a copy of the
19 ** license, contact the Qxt Foundation.
20 **
21 ** <http://libqxt.sourceforge.net>  <foundation@libqxt.org>
22 **
23 ****************************************************************************/
24
25 #ifndef QXTBOUNDCFUNCTION_H
26 #define QXTBOUNDCFUNCTION_H
27
28 #include <QObject>
29 #include <QMetaObject>
30 #include <QGenericArgument>
31 #include <qxtmetaobject.h>
32 #include <qxtboundfunctionbase.h>
33 #include <qxtnull.h>
34 #include <QThread>
35 /*
36 template <typename FUNCTION, int argc, typename RETURN = void>
37 class QxtBoundCFunction : public QxtBoundFunctionBase {
38 public:
39     FUNCTION funcPtr;
40
41     QxtBoundCFunction(QObject* parent, FUNCTION funcPointer, QGenericArgument* params[argc], QByteArray types[argc]) : QxtBoundFunctionBase(parent, params, types), funcPtr(funcPointer) {
42         // initializers only, thanks to template magic
43     }
44
45     virtual bool invokeImpl(Qt::ConnectionType type, QGenericReturnArgument returnValue, QXT_IMPL_10ARGS(QGenericArgument)) {
46         return qxt_invoke_cfunction_return<FUNCTION, argc, RETURN>(funcPtr, returnValue, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
47     }
48 };
49
50 template <typename FUNCTION, int argc>
51 class QxtBoundCFunction<FUNCTION, argc, void> : public QxtBoundFunctionBase {
52 public:
53     FUNCTION funcPtr;
54
55     QxtBoundCFunction(QObject* parent, FUNCTION funcPointer, QGenericArgument* params[argc], QByteArray types[argc]) : QxtBoundFunctionBase(parent, params, types), funcPtr(funcPointer) {
56         // initializers only, thanks to template magic
57     }
58
59     virtual bool invokeImpl(Qt::ConnectionType type, QGenericReturnArgument returnValue, QXT_IMPL_10ARGS(QGenericArgument)) {
60         return qxt_invoke_cfunction<FUNCTION, argc>(funcPtr, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
61     }
62 };
63
64 QGenericArgument* qbcfP[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
65 QByteArray types[10] = { "", "", "", "", "", "", "", "", "", "" };
66
67 void testFunction(int a) { a++; return; }
68 template < typename FP > QxtBoundFunction* testBind(FP fn) { return new QxtBoundCFunction<FP, 1>(0, fn, qbcfP, types); }
69 QxtBoundCFunction<void(*)(int), 1> qbcf(0, testFunction, qbcfP, types);
70 QxtBoundFunction* qbf = testBind(testFunction);
71 */
72 #endif