|
| 1 | +// clang-format off |
| 2 | +// SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> |
| 3 | +// clang-format on |
| 4 | +// SPDX-FileContributor: Andrew Hayzen <andrew.hayzen@kdab.com> |
| 5 | +// |
| 6 | +// SPDX-License-Identifier: MIT OR Apache-2.0 |
| 7 | + |
| 8 | +#pragma once |
| 9 | + |
| 10 | +#include <cstdint> |
| 11 | + |
| 12 | +#include <QtQml/QQmlEngine> |
| 13 | + |
| 14 | +// This is similar to the builtins file in qtdeclarative |
| 15 | +// https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qml/qqmlbuiltins_p.h?h=v6.9.3 |
| 16 | +// |
| 17 | +// We need this to be able to alias namespaced std numerics to types that QML |
| 18 | +// understands. |
| 19 | +// |
| 20 | +// We do not need to build this file but the moc JSON output to give to |
| 21 | +// qmltyperegistrar so that qmllint and qmlls can understand the types. |
| 22 | +// |
| 23 | +// If Qt ever registered qualified versions of the numerics this could be |
| 24 | +// removed. |
| 25 | +// |
| 26 | +// qqmlbuiltins uses the following values for QML_USING so we should copy |
| 27 | +// i8, u8 -> qint8, quint8 |
| 28 | +// i16, u16 -> short, ushort |
| 29 | +// i32, u32 -> int, uint |
| 30 | +// i64, u64 -> qlonglong, qulonglong |
| 31 | + |
| 32 | +struct QQmlCxxQtStdInt8TForeign |
| 33 | +{ |
| 34 | + Q_GADGET |
| 35 | + QML_FOREIGN(::std::int8_t) |
| 36 | + QML_USING(qint8) |
| 37 | +}; |
| 38 | +static_assert(sizeof(::std::int8_t) == sizeof(qint8)); |
| 39 | + |
| 40 | +struct QQmlCxxQtStdUInt8TForeign |
| 41 | +{ |
| 42 | + Q_GADGET |
| 43 | + QML_FOREIGN(::std::uint8_t) |
| 44 | + QML_USING(quint8) |
| 45 | +}; |
| 46 | +static_assert(sizeof(::std::uint8_t) == sizeof(quint8)); |
| 47 | + |
| 48 | +struct QQmlCxxQtStdInt16TForeign |
| 49 | +{ |
| 50 | + Q_GADGET |
| 51 | + QML_FOREIGN(::std::int16_t) |
| 52 | + QML_USING(short) |
| 53 | +}; |
| 54 | +static_assert(sizeof(::std::int16_t) == sizeof(short)); |
| 55 | + |
| 56 | +struct QQmlCxxQtStdUInt16TForeign |
| 57 | +{ |
| 58 | + Q_GADGET |
| 59 | + QML_FOREIGN(::std::uint16_t) |
| 60 | + QML_USING(ushort) |
| 61 | +}; |
| 62 | +static_assert(sizeof(::std::uint16_t) == sizeof(ushort)); |
| 63 | + |
| 64 | +struct QQmlCxxQtStdInt32TForeign |
| 65 | +{ |
| 66 | + Q_GADGET |
| 67 | + QML_FOREIGN(::std::int32_t) |
| 68 | + QML_USING(int) |
| 69 | +}; |
| 70 | +static_assert(sizeof(::std::int32_t) == sizeof(int)); |
| 71 | + |
| 72 | +struct QQmlCxxQtStdUInt32TForeign |
| 73 | +{ |
| 74 | + Q_GADGET |
| 75 | + QML_FOREIGN(::std::uint32_t) |
| 76 | + QML_USING(uint) |
| 77 | +}; |
| 78 | +static_assert(sizeof(::std::uint32_t) == sizeof(uint)); |
| 79 | + |
| 80 | +struct QQmlCxxQtStdInt64TForeign |
| 81 | +{ |
| 82 | + Q_GADGET |
| 83 | + QML_FOREIGN(::std::int64_t) |
| 84 | + QML_USING(qlonglong) |
| 85 | +}; |
| 86 | +static_assert(sizeof(::std::int64_t) == sizeof(qlonglong)); |
| 87 | + |
| 88 | +struct QQmlCxxQtStdUInt64TForeign |
| 89 | +{ |
| 90 | + Q_GADGET |
| 91 | + QML_FOREIGN(::std::uint64_t) |
| 92 | + QML_USING(qulonglong) |
| 93 | +}; |
| 94 | +static_assert(sizeof(::std::uint64_t) == sizeof(qulonglong)); |
0 commit comments