Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
IpcSchemaGenerator.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3#pragma once
4
5#include <PhosphorIpc/phosphoripc_export.h>
6
7#include <QJsonObject>
8#include <QString>
9#include <QtCore/qtmetamacros.h>
10
11QT_BEGIN_NAMESPACE
12class QObject;
13QT_END_NAMESPACE
14
15namespace PhosphorIpc {
16
17// QMetaObject → JSON Schema. Walks the target QObject's metaobject
18// and emits a per-target schema document:
19//
20// {
21// "target": "<name>",
22// "functions": [
23// {"name": "fn", "params": [{"name":"x","type":"integer"}], "returns": {"type":"string"}}
24// ],
25// "signals": [
26// {"name": "sigName", "params": [{"name":"y","type":"number"}]}
27// ]
28// }
29//
30// Type mapping (QMetaType ID → JSON Schema):
31// - Int / Long / LongLong / Short / UInt / etc. → {"type":"integer"}
32// - Double / Float → {"type":"number"}
33// - Bool → {"type":"boolean"}
34// - QString → {"type":"string"}
35// - QStringList → {"type":"array","items":{"type":"string"}}
36// - QVariantList → {"type":"array"}
37// - QVariantMap / QJsonObject → {"type":"object"}
38// - Void (return only) → "returns" omitted
39// - Unknown / custom → {"description":"custom QMetaType: <name>"}
40//
41// The CLI (phosphorctl) uses this schema for argument validation
42// before sending a call request. Server side, the schema lets
43// `phosphorctl schema <target>` describe the surface without
44// requiring documentation maintained out of band.
46
47[[nodiscard]] PHOSPHORIPC_EXPORT QJsonObject schemaFor(const QString& targetName, const QObject* object);
48
49} // namespace IpcSchemaGenerator
50
51} // namespace PhosphorIpc
Definition IpcSchemaGenerator.h:45
PHOSPHORIPC_EXPORT QJsonObject schemaFor(const QString &targetName, const QObject *object)
Definition IpcCallContext.h:10