| 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 QtScxml module 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 MOC_H |
| 30 | #define MOC_H |
| 31 | |
| 32 | #include <QtCore/qmap.h> |
| 33 | #include <QtCore/qpair.h> |
| 34 | #include <QtCore/qjsondocument.h> |
| 35 | #include <QtCore/qjsonarray.h> |
| 36 | #include <ctype.h> |
| 37 | |
| 38 | QT_BEGIN_NAMESPACE |
| 39 | |
| 40 | struct QMetaObject; |
| 41 | |
| 42 | struct Type |
| 43 | { |
| 44 | enum ReferenceType { NoReference, Reference, RValueReference, Pointer }; |
| 45 | |
| 46 | inline Type() : isVolatile(false), isScoped(false), /*firstToken(NOTOKEN), */referenceType(NoReference) {} |
| 47 | inline explicit Type(const QByteArray &_name) |
| 48 | : name(_name), rawName(name), isVolatile(false), isScoped(false), /*firstToken(NOTOKEN),*/ referenceType(NoReference) {} |
| 49 | QByteArray name; |
| 50 | //When used as a return type, the type name may be modified to remove the references. |
| 51 | // rawName is the type as found in the function signature |
| 52 | QByteArray rawName; |
| 53 | uint isVolatile : 1; |
| 54 | uint isScoped : 1; |
| 55 | // Token firstToken; |
| 56 | ReferenceType referenceType; |
| 57 | }; |
| 58 | |
| 59 | struct EnumDef |
| 60 | { |
| 61 | QByteArray name; |
| 62 | QList<QByteArray> values; |
| 63 | bool isEnumClass; // c++11 enum class |
| 64 | EnumDef() : isEnumClass(false) {} |
| 65 | }; |
| 66 | |
| 67 | struct ArgumentDef |
| 68 | { |
| 69 | ArgumentDef() : isDefault(false) {} |
| 70 | Type type; |
| 71 | QByteArray rightType, normalizedType, name; |
| 72 | QByteArray typeNameForCast; // type name to be used in cast from void * in metacall |
| 73 | bool isDefault; |
| 74 | }; |
| 75 | |
| 76 | struct FunctionDef |
| 77 | { |
| 78 | FunctionDef(): access(Private), isConst(false), isVirtual(false), isStatic(false), |
| 79 | inlineCode(false), wasCloned(false), isCompat(false), isInvokable(false), |
| 80 | isScriptable(false), isSlot(false), isSignal(false), isPrivateSignal(false), |
| 81 | isConstructor(false), isDestructor(false), isAbstract(false), revision(0), implementation(0) {} |
| 82 | Type type; |
| 83 | QByteArray normalizedType; |
| 84 | QByteArray tag; |
| 85 | QByteArray name; |
| 86 | QByteArray mangledName; |
| 87 | |
| 88 | QList<ArgumentDef> arguments; |
| 89 | |
| 90 | enum Access { Private, Protected, Public }; |
| 91 | Access access; |
| 92 | bool isConst; |
| 93 | bool isVirtual; |
| 94 | bool isStatic; |
| 95 | bool inlineCode; |
| 96 | bool wasCloned; |
| 97 | |
| 98 | QByteArray inPrivateClass; |
| 99 | bool isCompat; |
| 100 | bool isInvokable; |
| 101 | bool isScriptable; |
| 102 | bool isSlot; |
| 103 | bool isSignal; |
| 104 | bool isPrivateSignal; |
| 105 | bool isConstructor; |
| 106 | bool isDestructor; |
| 107 | bool isAbstract; |
| 108 | |
| 109 | int revision; |
| 110 | |
| 111 | const char *implementation; |
| 112 | }; |
| 113 | |
| 114 | struct PropertyDef |
| 115 | { |
| 116 | PropertyDef():notifyId(-1), constant(false), final(false), gspec(ValueSpec), revision(0){} |
| 117 | QByteArray name, mangledName, type, member, read, write, reset, designable, scriptable, |
| 118 | editable, stored, user, notify, inPrivateClass; |
| 119 | int notifyId; |
| 120 | bool constant; |
| 121 | bool final; |
| 122 | enum Specification { ValueSpec, ReferenceSpec, PointerSpec }; |
| 123 | Specification gspec; |
| 124 | bool stdCppSet() const { |
| 125 | QByteArray s("set" ); |
| 126 | s += toupper(c: name[0]); |
| 127 | s += name.mid(index: 1); |
| 128 | return (s == write); |
| 129 | } |
| 130 | int revision; |
| 131 | }; |
| 132 | |
| 133 | |
| 134 | struct ClassInfoDef |
| 135 | { |
| 136 | QByteArray name; |
| 137 | QByteArray value; |
| 138 | }; |
| 139 | |
| 140 | struct ClassDef { |
| 141 | ClassDef(): |
| 142 | hasQObject(false), hasQGadget(false), notifyableProperties(0) |
| 143 | , revisionedMethods(0), revisionedProperties(0), begin(0), end(0){} |
| 144 | QByteArray classname; |
| 145 | QByteArray qualified; |
| 146 | QList<QPair<QByteArray, FunctionDef::Access> > superclassList; |
| 147 | |
| 148 | struct Interface |
| 149 | { |
| 150 | inline explicit Interface(const QByteArray &_className) |
| 151 | : className(_className) {} |
| 152 | QByteArray className; |
| 153 | QByteArray interfaceId; |
| 154 | }; |
| 155 | QList<QList<Interface> >interfaceList; |
| 156 | |
| 157 | bool hasQObject; |
| 158 | bool hasQGadget; |
| 159 | |
| 160 | struct PluginData { |
| 161 | QByteArray iid; |
| 162 | QMap<QString, QJsonArray> metaArgs; |
| 163 | QJsonDocument metaData; |
| 164 | } pluginData; |
| 165 | |
| 166 | QList<FunctionDef> constructorList; |
| 167 | QList<FunctionDef> signalList, slotList, methodList, publicList; |
| 168 | int notifyableProperties; |
| 169 | QList<PropertyDef> propertyList; |
| 170 | QList<ClassInfoDef> classInfoList; |
| 171 | QMap<QByteArray, bool> enumDeclarations; |
| 172 | QList<EnumDef> enumList; |
| 173 | QMap<QByteArray, QByteArray> flagAliases; |
| 174 | int revisionedMethods; |
| 175 | int revisionedProperties; |
| 176 | |
| 177 | int begin; |
| 178 | int end; |
| 179 | }; |
| 180 | |
| 181 | struct NamespaceDef { |
| 182 | QByteArray name; |
| 183 | int begin; |
| 184 | int end; |
| 185 | }; |
| 186 | |
| 187 | inline QByteArray noRef(const QByteArray &type) |
| 188 | { |
| 189 | if (type.endsWith(c: '&')) { |
| 190 | if (type.endsWith(c: "&&" )) |
| 191 | return type.left(len: type.length()-2); |
| 192 | return type.left(len: type.length()-1); |
| 193 | } |
| 194 | return type; |
| 195 | } |
| 196 | |
| 197 | QT_END_NAMESPACE |
| 198 | |
| 199 | #endif // MOC_H |
| 200 | |