61 if (flags & (QDBusConnection::ExportScriptableProperties |
62 QDBusConnection::ExportNonScriptableProperties)) {
63 for (
int i = propOffset; i < mo->propertyCount(); ++i) {
65 QMetaProperty mp = mo->property(i);
67 if (!((mp.isScriptable() && (flags & QDBusConnection::ExportScriptableProperties)) ||
68 (!mp.isScriptable() && (flags & QDBusConnection::ExportNonScriptableProperties))))
71 QMetaType type = mp.metaType();
74 const char *signature = QDBusMetaType::typeToSignature(type);
78 retval +=
" <property name=\"%1\" type=\"%2\" access=\"%3\""_L1
79 .arg(QLatin1StringView(mp.name()),
80 QLatin1StringView(signature),
81 accessAsString(mp.isReadable(), mp.isWritable()));
83 if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
84 const char *typeName = type.name();
85 retval +=
">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n"_L1
86 .arg(typeNameToXml(typeName));
94 for (
int i = methodOffset; i < mo->methodCount(); ++i) {
95 QMetaMethod mm = mo->method(i);
97 bool isSignal =
false;
99 if (mm.methodType() == QMetaMethod::Signal)
102 else if (mm.access() == QMetaMethod::Public && mm.methodType() == QMetaMethod::Slot)
104 else if (mm.access() == QMetaMethod::Public && mm.methodType() == QMetaMethod::Method)
109 if (isSignal && !(flags & (QDBusConnection::ExportScriptableSignals |
110 QDBusConnection::ExportNonScriptableSignals)))
112 if (!isSignal && (!(flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) &&
113 !(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables))))
118 bool isScriptable = mm.attributes() & QMetaMethod::Scriptable;
119 if (!isScriptable && !(flags & (isSignal ? QDBusConnection::ExportNonScriptableSignals : QDBusConnection::ExportNonScriptableInvokables | QDBusConnection::ExportNonScriptableSlots)))
122 QString xml = QString::asprintf(
" <%s name=\"%s\">\n",
123 isSignal ?
"signal" :
"method", mm.name().constData());
126 QMetaType typeId = mm.returnMetaType();
127 if (typeId.isValid() && typeId.id() != QMetaType::Void) {
128 const char *typeName = QDBusMetaType::typeToSignature(typeId);
130 xml +=
" <arg type=\"%1\" direction=\"out\"/>\n"_L1
131 .arg(typeNameToXml(typeName));
134 if (!QDBusMetaType::signatureToMetaType(typeName).isValid())
135 xml +=
" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n"_L1
136 .arg(typeNameToXml(QMetaType(typeId).name()));
138 qWarning() <<
"Unsupported return type" << typeId.id() << typeId.name() <<
"in method" << mm.name();
142 else if (!typeId.isValid()) {
143 qWarning() <<
"Invalid return type in method" << mm.name();
147 QList<QByteArray> names = mm.parameterNames();
148 QList<QMetaType> types;
150 int inputCount = qDBusParametersForMethod(mm, types, errorMsg);
151 if (inputCount == -1) {
152 qWarning() <<
"Skipped method" << mm.name() <<
":" << qPrintable(errorMsg);
155 if (isSignal && inputCount + 1 != types.size())
157 if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message())
159 if (isSignal && mm.attributes() & QMetaMethod::Cloned)
163 for (j = 1; j < types.size(); ++j) {
165 if (types.at(j) == QDBusMetaTypeId::message()) {
171 if (!names.at(j - 1).isEmpty())
172 name =
"name=\"%1\" "_L1.arg(QLatin1StringView(names.at(j - 1)));
174 bool isOutput = isSignal || j > inputCount;
176 const char *signature = QDBusMetaType::typeToSignature(types.at(j));
177 xml += QString::asprintf(
" <arg %lstype=\"%s\" direction=\"%s\"/>\n",
178 qUtf16Printable(name), signature, isOutput ?
"out" :
"in");
181 if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
182 const char *typeName = QMetaType(types.at(j)).name();
183 xml += QString::fromLatin1(
" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
184 .arg(isOutput ?
"Out"_L1 :
"In"_L1)
185 .arg(isOutput && !isSignal ? j - inputCount : j - 1)
186 .arg(typeNameToXml(typeName));
192 wantedMask = isSignal ? QDBusConnection::ExportScriptableSignals
193 : isSlot ? QDBusConnection::ExportScriptableSlots
194 : QDBusConnection::ExportScriptableInvokables;
196 wantedMask = isSignal ? QDBusConnection::ExportNonScriptableSignals
197 : isSlot ? QDBusConnection::ExportNonScriptableSlots
198 : QDBusConnection::ExportNonScriptableInvokables;
199 if ((flags & wantedMask) != wantedMask)
202 if (qDBusCheckAsyncTag(mm.tag()))
207 retval +=
" </%1>\n"_L1.arg(isSignal ?
"signal"_L1 :
"method"_L1);