-
Notifications
You must be signed in to change notification settings - Fork 77
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
qtypes: add support for Qt alias types that don't match #904
base: main
Are you sure you want to change the base?
Conversation
e8826f5
to
e409d32
Compare
e409d32
to
e5daff8
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #904 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 71 71
Lines 11949 11949
=========================================
Hits 11949 11949 ☔ View full report in Codecov by Sentry. |
debf9b7
to
79cc8fe
Compare
6a21207
to
c67af09
Compare
c67af09
to
709d25d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good.
Naming wise I would just copy Qts casing (so lowercase). These types are quiet "fundamental types", which even in Rust are lowercase (i64, isize, etc.).
A sort-off open question is still how many operations we want to support on these...
Do we basically just enable From/Into
and call it a day, or do we want to have support for using the type more directly, like support for +-*/
on qint64...
For now it's probably good enough if we just have them convertable to their inner type, but something to keep in mind.
On the same note: Maybe we don't want to support Deref on these types?
It may be weird if you call e.g. abs
on qint64, but get an i64 back...
And now it would be a breaking change for us to add our own abs
method that returns qint64...
So it seems like limiting the API to just From/To with some derives is maybe best?
crates/cxx-qt-lib/src/core/qtypes.rs
Outdated
|
||
/// Typedef for long long int. This type is guaranteed to be 64-bit on all platforms supported by Qt. | ||
#[repr(transparent)] | ||
#[derive(Default, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add Clone
and Copy
to this list as well...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
crates/cxx-qt-lib/src/core/qtypes.rs
Outdated
/// Typedef for long long int. This type is guaranteed to be 64-bit on all platforms supported by Qt. | ||
#[repr(transparent)] | ||
#[derive(Default, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct QInt64(i64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with qint64
here. No need to rename the type. It's still a sort off "fundamental type" like i64, which is also lowercase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
crates/cxx-qt-lib/src/core/qtypes.rs
Outdated
|
||
/// Integral type for representing pointers in a signed integer (useful for hashing, etc.). | ||
#[repr(transparent)] | ||
#[derive(Default, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, let's add Copy
and Clone
to that list :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
crates/cxx-qt-lib/src/core/qtypes.rs
Outdated
/// | ||
/// Note that configuring Qt with -qreal float is not supported | ||
#[repr(transparent)] | ||
#[derive(Default, Debug, PartialEq, PartialOrd)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy + Clone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
crates/cxx-qt-lib/src/core/qtypes.rs
Outdated
|
||
/// Typedef for unsigned long long int. This type is guaranteed to be 64-bit on all platforms supported by Qt. | ||
#[repr(transparent)] | ||
#[derive(Default, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy + Clone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
crates/cxx-qt-lib/src/core/qtypes.rs
Outdated
|
||
/// Integral type for representing pointers in an unsigned integer (useful for hashing, etc.). | ||
#[repr(transparent)] | ||
#[derive(Default, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy + Clone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
crates/cxx-qt-lib/src/core/qtypes.rs
Outdated
/// Integral type providing Posix' ssize_t for all platforms. | ||
/// | ||
/// This type is guaranteed to be the same size as a size_t on all platforms supported by Qt. | ||
#[derive(Default, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy + Clone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
709d25d
to
aec4f39
Compare
Some times don't match the Rust types so add these missing types. Closes KDAB#882
aec4f39
to
f2bf8e6
Compare
f2bf8e6
to
91759c2
Compare
@@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|||
## [Unreleased](https://github.com/KDAB/cxx-qt/compare/v0.7.0...HEAD) | |||
|
|||
### Added | |||
|
|||
- Support for further types: `qreal`, `qint64`, `qintptr`, `qsizetype`, `quint64`, `quintptr` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we also want qlonglong
, qulonglong
, or qptrdiff
?
See https://doc.qt.io/qt-6/qttypes.html#types for full types in Qt
Closes #882