52 Q_CONSTINIT
static QBasicAtomicInt initialized = Q_BASIC_ATOMIC_INITIALIZER(
false);
56 if (!initialized.loadRelaxed()) {
66#ifndef QDBUS_NO_SPECIALTYPES
68 qDBusRegisterMetaType<
QDate>();
69 qDBusRegisterMetaType<
QTime>();
70 qDBusRegisterMetaType<QDateTime>();
71 qDBusRegisterMetaType<QRect>();
72 qDBusRegisterMetaType<QRectF>();
73 qDBusRegisterMetaType<
QSize>();
74 qDBusRegisterMetaType<QSizeF>();
75 qDBusRegisterMetaType<
QPoint>();
76 qDBusRegisterMetaType<
QPointF>();
77 qDBusRegisterMetaType<QLine>();
78 qDBusRegisterMetaType<QLineF>();
79 qDBusRegisterMetaType<QVariantList>();
80 qDBusRegisterMetaType<QVariantMap>();
81 qDBusRegisterMetaType<QVariantHash>();
83 qDBusRegisterMetaType<
QList<
bool> >();
84 qDBusRegisterMetaType<
QList<
short> >();
85 qDBusRegisterMetaType<QList<ushort> >();
86 qDBusRegisterMetaType<
QList<
int> >();
87 qDBusRegisterMetaType<QList<uint> >();
88 qDBusRegisterMetaType<QList<qlonglong> >();
89 qDBusRegisterMetaType<QList<qulonglong> >();
90 qDBusRegisterMetaType<
QList<
double> >();
91 qDBusRegisterMetaType<QMap<QString, QVariantMap>>();
94 qDBusRegisterMetaType<QList<QDBusVariant> >();
95 qDBusRegisterMetaType<QList<QDBusObjectPath> >();
96 qDBusRegisterMetaType<QList<QDBusSignature> >();
97 qDBusRegisterMetaType<
QList<QDBusUnixFileDescriptor> >();
100 initialized.storeRelaxed(
true);
210bool QDBusMetaType::marshall(QDBusArgument &arg, QMetaType metaType,
const void *data)
212 auto *ct = customTypes();
216 int id = metaType.id();
217 QDBusMetaTypeId::init();
221 QReadLocker locker(&ct->lock);
223 auto it = ct->hash.constFind(id);
224 if (it == ct->hash.cend())
227 const QDBusCustomTypeInfo &info = *it;
228 if (!info.marshall) {
245bool QDBusMetaType::demarshall(
const QDBusArgument &arg, QMetaType metaType,
void *data)
247 auto *ct = customTypes();
251 int id = metaType.id();
252 QDBusMetaTypeId::init();
254 DemarshallFunction df;
256 QReadLocker locker(&ct->lock);
258 auto it = ct->hash.constFind(id);
259 if (it == ct->hash.cend())
262 const QDBusCustomTypeInfo &info = *it;
263 if (!info.demarshall) {
267 df = info.demarshall;
269#ifndef QT_BOOTSTRAPPED
270 QDBusArgument copy = arg;
292QMetaType QDBusMetaType::signatureToMetaType(
const char *signature)
295 return QMetaType(QMetaType::UnknownType);
297 QDBusMetaTypeId::init();
298 switch (signature[0])
301 return QMetaType(QMetaType::Bool);
304 return QMetaType(QMetaType::UChar);
307 return QMetaType(QMetaType::Short);
310 return QMetaType(QMetaType::UShort);
313 return QMetaType(QMetaType::Int);
316 return QMetaType(QMetaType::UInt);
319 return QMetaType(QMetaType::LongLong);
322 return QMetaType(QMetaType::ULongLong);
325 return QMetaType(QMetaType::Double);
328 return QMetaType(QMetaType::QString);
331 return QDBusMetaTypeId::objectpath();
334 return QDBusMetaTypeId::signature();
337 return QDBusMetaTypeId::unixfd();
340 return QDBusMetaTypeId::variant();
343 switch (signature[1]) {
345 return QMetaType(QMetaType::QByteArray);
348 return QMetaType(QMetaType::QStringList);
351 return QMetaType(QMetaType::QVariantList);
354 return QMetaType::fromType<QList<QDBusObjectPath> >();
357 return QMetaType::fromType<QList<QDBusSignature> >();
362 return QMetaType(QMetaType::UnknownType);
374void QDBusMetaType::registerCustomType(QMetaType type,
const QByteArray &signature)
376 auto *ct = customTypes();
380 QWriteLocker locker(&ct->lock);
381 auto &info = ct->hash[type.id()];
382 info.signature = signature;
397const char *QDBusMetaType::typeToSignature(QMetaType type)
402 case QMetaType::UChar:
405 case QMetaType::Bool:
408 case QMetaType::Short:
411 case QMetaType::UShort:
417 case QMetaType::UInt:
420 case QMetaType::LongLong:
423 case QMetaType::ULongLong:
426 case QMetaType::Double:
429 case QMetaType::QString:
432 case QMetaType::QStringList:
436 case QMetaType::QByteArray:
441 QDBusMetaTypeId::init();
442 if (type == QDBusMetaTypeId::variant())
444 else if (type == QDBusMetaTypeId::objectpath())
446 else if (type == QDBusMetaTypeId::signature())
448 else if (type == QDBusMetaTypeId::unixfd())
452 auto *ct = customTypes();
457 QReadLocker locker(&ct->lock);
458 auto it = ct->hash.constFind(type.id());
459 if (it == ct->hash.end())
462 const QDBusCustomTypeInfo &info = *it;
464 if (!info.signature.isNull())
465 return info.signature;
472 QDBusCustomTypeInfo *info;
476 QByteArray signature = QDBusArgumentPrivate::createSignature(type);
479 QWriteLocker locker(&ct->lock);
480 info = &ct->hash[type.id()];
481 info->signature = signature;
483 return info->signature;