-
Notifications
You must be signed in to change notification settings - Fork 93
cxx-qt-build: inject QML_FOREIGN types for qmllint/qmlls #1344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
LeonMatthesKDAB
merged 1 commit into
KDAB:main
from
ahayzen-kdab:975-add-declarative-numerics
Oct 15, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// clang-format off | ||
// SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
// clang-format on | ||
// SPDX-FileContributor: Andrew Hayzen <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
#include <QtQml/QQmlEngine> | ||
|
||
// This is similar to the builtins file in qtdeclarative | ||
// https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qml/qqmlbuiltins_p.h?h=v6.9.3 | ||
// | ||
// We need this to be able to alias namespaced std numerics to types that QML | ||
// understands. | ||
// | ||
// We do not need to build this file but the moc JSON output to give to | ||
// qmltyperegistrar so that qmllint and qmlls can understand the types. | ||
// | ||
// If Qt ever registered qualified versions of the numerics this could be | ||
// removed. | ||
// | ||
// qqmlbuiltins uses the following values for QML_USING so we should copy | ||
// i8, u8 -> qint8, quint8 | ||
// i16, u16 -> short, ushort | ||
// i32, u32 -> int, uint | ||
// i64, u64 -> qlonglong, qulonglong | ||
|
||
struct QQmlCxxQtStdInt8TForeign | ||
{ | ||
Q_GADGET | ||
QML_FOREIGN(::std::int8_t) | ||
QML_USING(qint8) | ||
}; | ||
static_assert(sizeof(::std::int8_t) == sizeof(qint8)); | ||
|
||
struct QQmlCxxQtStdUInt8TForeign | ||
{ | ||
Q_GADGET | ||
QML_FOREIGN(::std::uint8_t) | ||
QML_USING(quint8) | ||
}; | ||
static_assert(sizeof(::std::uint8_t) == sizeof(quint8)); | ||
|
||
struct QQmlCxxQtStdInt16TForeign | ||
{ | ||
Q_GADGET | ||
QML_FOREIGN(::std::int16_t) | ||
QML_USING(short) | ||
}; | ||
static_assert(sizeof(::std::int16_t) == sizeof(short)); | ||
|
||
struct QQmlCxxQtStdUInt16TForeign | ||
{ | ||
Q_GADGET | ||
QML_FOREIGN(::std::uint16_t) | ||
QML_USING(ushort) | ||
}; | ||
static_assert(sizeof(::std::uint16_t) == sizeof(ushort)); | ||
|
||
struct QQmlCxxQtStdInt32TForeign | ||
{ | ||
Q_GADGET | ||
QML_FOREIGN(::std::int32_t) | ||
QML_USING(int) | ||
}; | ||
static_assert(sizeof(::std::int32_t) == sizeof(int)); | ||
|
||
struct QQmlCxxQtStdUInt32TForeign | ||
{ | ||
Q_GADGET | ||
QML_FOREIGN(::std::uint32_t) | ||
QML_USING(uint) | ||
}; | ||
static_assert(sizeof(::std::uint32_t) == sizeof(uint)); | ||
|
||
struct QQmlCxxQtStdInt64TForeign | ||
{ | ||
Q_GADGET | ||
QML_FOREIGN(::std::int64_t) | ||
QML_USING(qlonglong) | ||
}; | ||
static_assert(sizeof(::std::int64_t) == sizeof(qlonglong)); | ||
|
||
struct QQmlCxxQtStdUInt64TForeign | ||
{ | ||
Q_GADGET | ||
QML_FOREIGN(::std::uint64_t) | ||
QML_USING(qulonglong) | ||
}; | ||
static_assert(sizeof(::std::uint64_t) == sizeof(qulonglong)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.