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 test suite of Qt for Python.
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 SAMPLENAMESPACE_H
30 #define SAMPLENAMESPACE_H
31
32 #include <list>
33 #include "libsamplemacros.h"
34 #include "str.h"
35 #include "point.h"
36 #include "objecttype.h"
37
38 // Anonymous global enum
39 enum {
40 AnonymousGlobalEnum_Value0,
41 AnonymousGlobalEnum_Value1
42 };
43
44 namespace SampleNamespace
45 {
46
47 enum Option {
48 None_,
49 RandomNumber,
50 UnixTime
51 };
52
53 enum InValue {
54 ZeroIn,
55 OneIn,
56 TwoIn
57 };
58
59 enum OutValue {
60 ZeroOut,
61 OneOut,
62 TwoOut
63 };
64
65 // Anonymous non-global enum.
66 // This counts as a class enum, since C++ namespaces
67 // are represented as classes in Python.
68 enum {
69 AnonymousClassEnum_Value0,
70 AnonymousClassEnum_Value1
71 };
72
73 LIBSAMPLE_API OutValue enumInEnumOut(InValue in);
74
75 LIBSAMPLE_API Option enumArgumentWithDefaultValue(Option opt = UnixTime);
76
77 LIBSAMPLE_API int getNumber(Option opt);
78
powerOfTwo(double num)79 inline double powerOfTwo(double num) {
80 return num * num;
81 }
82
83 LIBSAMPLE_API void doSomethingWithArray(const unsigned char *data, unsigned int size, const char *format = nullptr);
84
85 LIBSAMPLE_API int enumItemAsDefaultValueToIntArgument(int value = ZeroIn);
86
87 class LIBSAMPLE_API SomeClass
88 {
89 public:
90 enum class PublicScopedEnum { v1, v2 };
91
92 class SomeInnerClass
93 {
94 public:
95 class OkThisIsRecursiveEnough
96 {
97 public:
~OkThisIsRecursiveEnough()98 virtual ~OkThisIsRecursiveEnough() {}
99 enum NiceEnum {
100 NiceValue1, NiceValue2
101 };
102
103 enum class NiceEnumClass {
104 NiceClassValue1, NiceClassValue2
105 };
106
someMethod(SomeInnerClass *)107 inline int someMethod(SomeInnerClass*) { return 0; }
someVirtualMethod(OkThisIsRecursiveEnough * arg)108 virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; }
109 };
110 protected:
111 enum ProtectedEnum {
112 ProtectedItem0,
113 ProtectedItem1
114 };
115 };
116 struct SomeOtherInnerClass {
117 std::list<SomeInnerClass> someInnerClasses;
118 };
119 protected:
120 enum ProtectedEnum {
121 ProtectedItem0,
122 ProtectedItem1
123 };
124
125 PublicScopedEnum protectedMethodReturningPublicScopedEnum() const;
126 };
127
enumAsInt(SomeClass::PublicScopedEnum value)128 LIBSAMPLE_API inline int enumAsInt(SomeClass::PublicScopedEnum value) { return static_cast<int>(value); }
129
130 class DerivedFromNamespace : public SomeClass::SomeInnerClass::OkThisIsRecursiveEnough
131 {
132 public:
133 // FIXME Uncomment this when the fix for MSVC is available
134 // only to cause namespace confusion
135 // enum SampleNamespace {
136 // };
someVirtualMethod(OkThisIsRecursiveEnough * arg)137 virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; }
methodReturningTypeFromParentScope()138 inline OkThisIsRecursiveEnough *methodReturningTypeFromParentScope() { return nullptr; }
139 };
140
141 // The combination of the following two overloaded methods could trigger a
142 // problematic behaviour on the overload decisor, if it isn't working properly.
143 LIBSAMPLE_API void forceDecisorSideA(ObjectType *object = nullptr);
144 LIBSAMPLE_API void forceDecisorSideA(const Point& pt, const Str& text, ObjectType* object = 0);
145
146 // The combination of the following two overloaded methods could trigger a
147 // problematic behaviour on the overload decisor, if it isn't working properly.
148 // This is a variation of forceDecisorSideB.
149 LIBSAMPLE_API void forceDecisorSideB(int a, ObjectType *object = nullptr);
150 LIBSAMPLE_API void forceDecisorSideB(int a, const Point &pt, const Str &text, ObjectType *object = nullptr);
151
152 // Add a new signature on type system with only a Point value as parameter.
153 LIBSAMPLE_API double passReferenceToValueType(const Point& point, double multiplier);
154 // Add a new signature on type system with only a ObjectType pointer as parameter.
155 LIBSAMPLE_API int passReferenceToObjectType(const ObjectType& obj, int multiplier);
156
157 extern LIBSAMPLE_API int variableInNamespace;
158
159 } // namespace SampleNamespace
160
161 #endif // SAMPLENAMESPACE_H
162
163