~gabriel1984sibiu/minitube/qt5.6

« back to all changes in this revision

Viewing changes to tests/auto/tools/moc/parse-defines.h

  • Committer: Grevutiu Gabriel
  • Date: 2017-06-13 08:43:17 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20170613084317-ek0zqe0u9g3ocvi8
OriginalĀ upstreamĀ code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2016 The Qt Company Ltd.
 
4
** Contact: https://www.qt.io/licensing/
 
5
**
 
6
** This file is part of the tools applications of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and The Qt Company. For licensing terms
 
14
** and conditions see https://www.qt.io/terms-conditions. For further
 
15
** information use the contact form at https://www.qt.io/contact-us.
 
16
**
 
17
** GNU General Public License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU
 
19
** General Public License version 3 as published by the Free Software
 
20
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
 
21
** included in the packaging of this file. Please review the following
 
22
** information to ensure the GNU General Public License requirements will
 
23
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 
24
**
 
25
** $QT_END_LICENSE$
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef PARSE_DEFINES_H
 
30
#define PARSE_DEFINES_H
 
31
 
 
32
#include <qobject.h>
 
33
 
 
34
// this is intentionally ugly to test moc's preprocessing capabilities
 
35
#define PD_NAMESPACE PD
 
36
#define PD_BEGIN_NAMESPACE namespace PD_NAMESPACE {
 
37
#define PD_END_NAMESPACE }
 
38
#define PD_VOIDFUNCTION() voidFunction()
 
39
#define PD_CLASSNAME ParseDefine
 
40
 
 
41
#define PD_STRINGIFY(a) #a
 
42
#define PD_XSTRINGIFY(a) PD_STRINGIFY(a)
 
43
#define PD_SCOPED_STRING(a, b) PD_STRINGIFY(a) "::" PD_STRINGIFY(b)
 
44
#define PD_DEFINE1(a,b) a##b
 
45
#define PD_DEFINE2(a,b) a comb##b
 
46
#define PD_DEFINE3(a,b) a b##ined3()
 
47
#define PD_COMBINE(a,b) a b
 
48
#define PD_TEST_IDENTIFIER_ARG(if, while) if while
 
49
 
 
50
#define QString() error_type
 
51
 
 
52
#define PD_CLASSINFO Q_CLASSINFO
 
53
 
 
54
#if defined(Q_COMPILER_VARIADIC_MACROS) || defined (Q_MOC_RUN)
 
55
#define PD_VARARG(x, ...) x(__VA_ARGS__)
 
56
 
 
57
#if defined(Q_CC_GNU) || defined(Q_MOC_RUN)
 
58
//GCC extension for variadic macros
 
59
#define PD_VARARGEXT(x, y...) x(y)
 
60
#else
 
61
#define PD_VARARGEXT(x, ...) x(__VA_ARGS__)
 
62
#endif
 
63
 
 
64
#endif
 
65
 
 
66
#define PD_ADD_SUFFIX(x)  PD_DEFINE1(x,_SUFFIX)
 
67
#define PD_DEFINE_ITSELF PD_ADD_SUFFIX(PD_DEFINE_ITSELF)
 
68
 
 
69
#ifndef Q_MOC_RUN
 
70
// macro defined on the command line (in tst_moc.pro)
 
71
#define DEFINE_CMDLINE_EMPTY
 
72
#define DEFINE_CMDLINE_SIGNAL void cmdlineSignal(const QMap<int, int> &i)
 
73
#endif
 
74
 
 
75
#define HASH_SIGN #
 
76
 
 
77
PD_BEGIN_NAMESPACE
 
78
 
 
79
class DEFINE_CMDLINE_EMPTY PD_CLASSNAME DEFINE_CMDLINE_EMPTY
 
80
    : public DEFINE_CMDLINE_EMPTY QObject DEFINE_CMDLINE_EMPTY
 
81
{
 
82
    Q_OBJECT
 
83
    Q_CLASSINFO("TestString", PD_STRINGIFY(PD_CLASSNAME))
 
84
    Q_CLASSINFO("TestString2", PD_XSTRINGIFY(PD_CLASSNAME))
 
85
    PD_CLASSINFO("TestString3", "TestValue")
 
86
public:
 
87
    PD_CLASSNAME() {}
 
88
 
 
89
public slots:
 
90
    void PD_VOIDFUNCTION() {}
 
91
 
 
92
    QString stringMethod() { return QString::fromLatin1(""); }
 
93
 
 
94
    void PD_DEFINE1(comb, ined1()) {}
 
95
    PD_DEFINE2(void, ined2()) {}
 
96
    PD_DEFINE3(void, comb) {}
 
97
    PD_COMBINE(void combined4(int, int), {})
 
98
 
 
99
    PD_COMBINE(void combined5() {, })
 
100
 
 
101
    PD_TEST_IDENTIFIER_ARG(void, combined6()) {}
 
102
 
 
103
#if defined(Q_COMPILER_VARIADIC_MACROS) || defined (Q_MOC_RUN)
 
104
    PD_VARARG(void vararg1) {}
 
105
    PD_VARARG(void vararg2, int) {}
 
106
    PD_VARARG(void vararg3, int, int) {}
 
107
 
 
108
    PD_VARARGEXT(void vararg4) {}
 
109
    PD_VARARGEXT(void vararg5, int) {}
 
110
    PD_VARARGEXT(void vararg6, int, int) {}
 
111
#else
 
112
    void vararg1() {}
 
113
    void vararg2(int) {}
 
114
    void vararg3(int,int) {}
 
115
    void vararg4() {}
 
116
    void vararg5(int) {}
 
117
    void vararg6(int,int) {}
 
118
#endif
 
119
 
 
120
#define OUTERFUNCTION(x) x
 
121
#define INNERFUNCTION(x) OUTERFUNCTION(x)
 
122
#define INNER INNERFUNCTION
 
123
 
 
124
    void INNERFUNCTION(INNERFUNCTION)(int) {}
 
125
    void OUTERFUNCTION(INNERFUNCTION)(inner_expanded(int)) {}
 
126
    void expanded_method OUTERFUNCTION(INNER)((int)) {}
 
127
 
 
128
#undef INNERFUNCTION
 
129
 
 
130
#define cond1() 0x1
 
131
#define cond2() 0x2
 
132
 
 
133
#if !(cond1() & cond2())
 
134
    void conditionSlot() {}
 
135
#endif
 
136
 
 
137
    void PD_DEFINE_ITSELF(int) {}
 
138
 
 
139
signals:
 
140
    DEFINE_CMDLINE_SIGNAL;
 
141
 
 
142
};
 
143
 
 
144
#undef QString
 
145
 
 
146
PD_END_NAMESPACE
 
147
 
 
148
#endif