1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.core.metaobject; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.bytearray; 19 import qt.core.list; 20 import qt.core.namespace; 21 import qt.core.object; 22 import qt.core.objectdefs; 23 import qt.core.typeinfo; 24 import qt.core.variant; 25 import qt.helpers; 26 27 /+ template <typename T> class QList; 28 29 #define Q_METAMETHOD_INVOKE_MAX_ARGS 10 +/ 30 31 @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_CORE_EXPORT +/ QMetaMethod 32 { 33 public: 34 @disable this(); 35 /+pragma(inline, true) this() 36 { 37 this.mobj = null; 38 this.handle = 0; 39 }+/ 40 41 QByteArray methodSignature() const; 42 QByteArray name() const; 43 const(char)* typeName() const; 44 int returnType() const; 45 int parameterCount() const; 46 int parameterType(int index) const; 47 void getParameterTypes(int* types) const; 48 QList!(QByteArray) parameterTypes() const; 49 QList!(QByteArray) parameterNames() const; 50 const(char)* tag() const; 51 enum Access { Private, Protected, Public } 52 Access access() const; 53 enum MethodType { Method, Signal, Slot, Constructor } 54 MethodType methodType() const; 55 enum Attributes { Compatibility = 0x1, Cloned = 0x2, Scriptable = 0x4 } 56 int attributes() const; 57 int methodIndex() const; 58 int revision() const; 59 60 pragma(inline, true) const(QMetaObject)* enclosingMetaObject() const { return mobj; } 61 62 bool invoke(QObject object, 63 /+ Qt:: +/qt.core.namespace.ConnectionType connectionType, 64 QGenericReturnArgument returnValue, 65 QGenericArgument val0 = QGenericArgument(null), 66 QGenericArgument val1 = QGenericArgument(), 67 QGenericArgument val2 = QGenericArgument(), 68 QGenericArgument val3 = QGenericArgument(), 69 QGenericArgument val4 = QGenericArgument(), 70 QGenericArgument val5 = QGenericArgument(), 71 QGenericArgument val6 = QGenericArgument(), 72 QGenericArgument val7 = QGenericArgument(), 73 QGenericArgument val8 = QGenericArgument(), 74 QGenericArgument val9 = QGenericArgument()) const; 75 pragma(inline, true) bool invoke(QObject object, 76 QGenericReturnArgument returnValue, 77 QGenericArgument val0 = QGenericArgument(null), 78 QGenericArgument val1 = QGenericArgument(), 79 QGenericArgument val2 = QGenericArgument(), 80 QGenericArgument val3 = QGenericArgument(), 81 QGenericArgument val4 = QGenericArgument(), 82 QGenericArgument val5 = QGenericArgument(), 83 QGenericArgument val6 = QGenericArgument(), 84 QGenericArgument val7 = QGenericArgument(), 85 QGenericArgument val8 = QGenericArgument(), 86 QGenericArgument val9 = QGenericArgument()) const 87 { 88 return invoke(object, /+ Qt:: +/qt.core.namespace.ConnectionType.AutoConnection, returnValue, 89 val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); 90 } 91 pragma(inline, true) bool invoke(QObject object, 92 /+ Qt:: +/qt.core.namespace.ConnectionType connectionType, 93 QGenericArgument val0 = QGenericArgument(null), 94 QGenericArgument val1 = QGenericArgument(), 95 QGenericArgument val2 = QGenericArgument(), 96 QGenericArgument val3 = QGenericArgument(), 97 QGenericArgument val4 = QGenericArgument(), 98 QGenericArgument val5 = QGenericArgument(), 99 QGenericArgument val6 = QGenericArgument(), 100 QGenericArgument val7 = QGenericArgument(), 101 QGenericArgument val8 = QGenericArgument(), 102 QGenericArgument val9 = QGenericArgument()) const 103 { 104 return invoke(object, connectionType, QGenericReturnArgument(), 105 val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); 106 } 107 pragma(inline, true) bool invoke(QObject object, 108 QGenericArgument val0 = QGenericArgument(null), 109 QGenericArgument val1 = QGenericArgument(), 110 QGenericArgument val2 = QGenericArgument(), 111 QGenericArgument val3 = QGenericArgument(), 112 QGenericArgument val4 = QGenericArgument(), 113 QGenericArgument val5 = QGenericArgument(), 114 QGenericArgument val6 = QGenericArgument(), 115 QGenericArgument val7 = QGenericArgument(), 116 QGenericArgument val8 = QGenericArgument(), 117 QGenericArgument val9 = QGenericArgument()) const 118 { 119 return invoke(object, /+ Qt:: +/qt.core.namespace.ConnectionType.AutoConnection, QGenericReturnArgument(), 120 val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); 121 } 122 bool invokeOnGadget(void* gadget, 123 QGenericReturnArgument returnValue, 124 QGenericArgument val0 = QGenericArgument(null), 125 QGenericArgument val1 = QGenericArgument(), 126 QGenericArgument val2 = QGenericArgument(), 127 QGenericArgument val3 = QGenericArgument(), 128 QGenericArgument val4 = QGenericArgument(), 129 QGenericArgument val5 = QGenericArgument(), 130 QGenericArgument val6 = QGenericArgument(), 131 QGenericArgument val7 = QGenericArgument(), 132 QGenericArgument val8 = QGenericArgument(), 133 QGenericArgument val9 = QGenericArgument()) const; 134 pragma(inline, true) bool invokeOnGadget(void* gadget, 135 QGenericArgument val0 = QGenericArgument(null), 136 QGenericArgument val1 = QGenericArgument(), 137 QGenericArgument val2 = QGenericArgument(), 138 QGenericArgument val3 = QGenericArgument(), 139 QGenericArgument val4 = QGenericArgument(), 140 QGenericArgument val5 = QGenericArgument(), 141 QGenericArgument val6 = QGenericArgument(), 142 QGenericArgument val7 = QGenericArgument(), 143 QGenericArgument val8 = QGenericArgument(), 144 QGenericArgument val9 = QGenericArgument()) const 145 { 146 return invokeOnGadget(gadget, QGenericReturnArgument(), 147 val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); 148 } 149 150 pragma(inline, true) bool isValid() const { return mobj !is null; } 151 152 /+ template <typename PointerToMemberFunction> +/ 153 /+ static inline QMetaMethod fromSignal(PointerToMemberFunction signal) 154 { 155 typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SignalType; 156 Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, 157 "No Q_OBJECT in the class with the signal"); 158 return fromSignalImpl(&SignalType::Object::staticMetaObject, 159 reinterpret_cast<void **>(&signal)); 160 } +/ 161 162 private: 163 /+ #if QT_DEPRECATED_SINCE(5,0) 164 // signature() has been renamed to methodSignature() in Qt 5. 165 // Warning, that function returns a QByteArray; check the life time if 166 // you convert to char*. 167 char *signature(struct renamedInQt5_warning_checkTheLifeTime * = nullptr) = delete; 168 #endif +/ 169 static QMetaMethod fromSignalImpl(const(QMetaObject)* , void** ); 170 171 const(QMetaObject)* mobj = null; 172 uint handle = 0; 173 /+ friend class QMetaMethodPrivate; +/ 174 /+ friend struct QMetaObject; +/ 175 /+ friend struct QMetaObjectPrivate; +/ 176 /+ friend class QObject; +/ 177 /+ friend bool operator==(const QMetaMethod &m1, const QMetaMethod &m2); +/ 178 /+ friend bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2); +/ 179 } 180 /+ Q_DECLARE_TYPEINFO(QMetaMethod, Q_MOVABLE_TYPE); +/ 181 182 /+pragma(inline, true) bool operator ==(ref const(QMetaMethod) m1, ref const(QMetaMethod) m2) 183 { return m1.mobj == m2.mobj && m1.handle == m2.handle; }+/ 184 /+pragma(inline, true) bool operator !=(ref const(QMetaMethod) m1, ref const(QMetaMethod) m2) 185 { return !(m1 == m2); }+/ 186 187 @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_CORE_EXPORT +/ QMetaEnum 188 { 189 public: 190 @disable this(); 191 /+pragma(inline, true) this() 192 { 193 this.mobj = null; 194 this.handle = 0; 195 }+/ 196 197 const(char)* name() const; 198 const(char)* enumName() const; 199 bool isFlag() const; 200 bool isScoped() const; 201 202 int keyCount() const; 203 const(char)* key(int index) const; 204 int value(int index) const; 205 206 const(char)* scope_() const; 207 208 int keyToValue(const(char)* key, bool* ok = null) const; 209 const(char)* valueToKey(int value) const; 210 int keysToValue(const(char)* keys, bool* ok = null) const; 211 QByteArray valueToKeys(int value) const; 212 213 pragma(inline, true) const(QMetaObject)* enclosingMetaObject() const { return mobj; } 214 215 pragma(inline, true) bool isValid() const { return name() !is null; } 216 217 /+ template<typename T> +/ /+ static QMetaEnum fromType() { 218 Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper<T>::Value, 219 "QMetaEnum::fromType only works with enums declared as " 220 "Q_ENUM, Q_ENUM_NS, Q_FLAG or Q_FLAG_NS"); 221 const QMetaObject *metaObject = qt_getEnumMetaObject(T()); 222 const char *name = qt_getEnumName(T()); 223 return metaObject->enumerator(metaObject->indexOfEnumerator(name)); 224 } +/ 225 226 private: 227 const(QMetaObject)* mobj = null; 228 uint handle = 0; 229 /+ friend struct QMetaObject; +/ 230 } 231 /+ Q_DECLARE_TYPEINFO(QMetaEnum, Q_MOVABLE_TYPE); +/ 232 233 extern(C++, class) struct /+ Q_CORE_EXPORT +/ QMetaProperty 234 { 235 public: 236 @disable this(); 237 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 238 ref typeof(this) rawConstructor(); 239 static typeof(this) create() 240 { 241 typeof(this) r = typeof(this).init; 242 r.rawConstructor(); 243 return r; 244 } 245 246 247 const(char)* name() const; 248 const(char)* typeName() const; 249 QVariant.Type type() const; 250 int userType() const; 251 int propertyIndex() const; 252 int relativePropertyIndex() const; 253 254 bool isReadable() const; 255 bool isWritable() const; 256 bool isResettable() const; 257 bool isDesignable(const(QObject) obj = null) const; 258 bool isScriptable(const(QObject) obj = null) const; 259 bool isStored(const(QObject) obj = null) const; 260 /+ #if QT_DEPRECATED_SINCE(5, 15) +/ 261 /+ QT_DEPRECATED_VERSION_5_15 +/ bool isEditable(const(QObject) obj = null) const; 262 /+ #endif +/ 263 bool isUser(const(QObject) obj = null) const; 264 bool isConstant() const; 265 bool isFinal() const; 266 bool isRequired() const; 267 268 bool isFlagType() const; 269 bool isEnumType() const; 270 QMetaEnum enumerator() const; 271 272 bool hasNotifySignal() const; 273 QMetaMethod notifySignal() const; 274 int notifySignalIndex() const; 275 276 int revision() const; 277 278 QVariant read(const(QObject) obj) const; 279 bool write(QObject obj, ref const(QVariant) value) const; 280 bool reset(QObject obj) const; 281 282 QVariant readOnGadget(const(void)* gadget) const; 283 bool writeOnGadget(void* gadget, ref const(QVariant) value) const; 284 bool resetOnGadget(void* gadget) const; 285 286 bool hasStdCppSet() const; 287 pragma(inline, true) bool isValid() const { return isReadable(); } 288 pragma(inline, true) const(QMetaObject)* enclosingMetaObject() const { return mobj; } 289 290 private: 291 int registerPropertyType() const; 292 293 const(QMetaObject)* mobj; 294 uint handle; 295 int idx; 296 QMetaEnum menum; 297 /+ friend struct QMetaObject; +/ 298 /+ friend struct QMetaObjectPrivate; +/ 299 } 300 301 @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_CORE_EXPORT +/ QMetaClassInfo 302 { 303 public: 304 @disable this(); 305 /+pragma(inline, true) this() 306 { 307 this.mobj = null; 308 this.handle = 0; 309 }+/ 310 const(char)* name() const; 311 const(char)* value() const; 312 pragma(inline, true) const(QMetaObject)* enclosingMetaObject() const { return mobj; } 313 private: 314 const(QMetaObject)* mobj = null; 315 uint handle = 0; 316 /+ friend struct QMetaObject; +/ 317 } 318 /+ Q_DECLARE_TYPEINFO(QMetaClassInfo, Q_MOVABLE_TYPE); +/ 319