Skip to content

Commit 22af7db

Browse files
ahayzen-kdabLeonMatthesKDAB
authored andcommitted
cxx-qt-build: use file stem for cxx bridges
As this is how cxx bridges normally function, ideally we want this for cxx-qt bridges too but the macro needs to know the file name too.
1 parent 3936872 commit 22af7db

39 files changed

+49
-44
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Internal `cxx-qt` headers have moved to the namespace `cxxqt1` and the folder `cxx-qt`
3232
- `cxx-qt-gen` now does not generate code requiring `cxx-qt-lib`, this allows for `cxx-qt-lib` to be optional
3333
- `cxx-qt-lib` headers must be given to `cxx-qt-build` with `.with_opts(cxx_qt_lib_headers::build_opts())`
34+
- File name is used for CXX bridges rather than module name to match upstream
3435

3536
### Fixed
3637

crates/cxx-qt-build/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ repository.workspace = true
1414

1515
[dependencies]
1616
cc.workspace = true
17-
convert_case.workspace = true
1817
cxx-gen.workspace = true
1918
cxx-qt.workspace = true
2019
cxx-qt-gen.workspace = true

crates/cxx-qt-build/src/lib.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ mod qml_modules;
1818
use qml_modules::OwningQmlModule;
1919
pub use qml_modules::QmlModule;
2020

21-
use convert_case::{Case, Casing};
2221
use quote::ToTokens;
2322
use std::{
2423
collections::HashSet,
@@ -65,11 +64,6 @@ impl GeneratedCpp {
6564
.map_err(to_diagnostic)?;
6665

6766
let mut cxx_qt = None;
68-
// TODO: later change how the resultant filename is chosen, can we match the input file like
69-
// CXX does?
70-
//
71-
// For CXX-Qt generating one header per QObject likely makes sense, but what happens with CXX data?
72-
// for now this uses the module ident
7367
let mut file_ident: String = "".to_owned();
7468
let mut tokens = proc_macro2::TokenStream::new();
7569

@@ -90,7 +84,18 @@ impl GeneratedCpp {
9084
rust_file_path.display());
9185
}
9286

93-
file_ident = m.ident.to_string().to_case(Case::Snake);
87+
// Match upstream where they use the file name as the ident
88+
//
89+
// TODO: what happens if there are folders?
90+
//
91+
// TODO: ideally CXX-Qt would also use the file name
92+
// https://github.com/KDAB/cxx-qt/pull/200/commits/4861c92e66c3a022d3f0dedd9f8fd20db064b42b
93+
file_ident = rust_file_path
94+
.file_stem()
95+
.unwrap()
96+
.to_str()
97+
.unwrap()
98+
.to_owned();
9499
tokens.extend(m.into_token_stream());
95100
}
96101
CxxQtItem::CxxQt(m) => {

tests/basic_cxx_only/cpp/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// SPDX-License-Identifier: MIT OR Apache-2.0
88
#include <QtTest/QTest>
99

10-
#include "cxx-qt-gen/ffi.cxx.h"
10+
#include "cxx-qt-gen/lib.cxx.h"
1111
#include "cxx_test.h"
1212

1313
class CxxTest : public QObject

tests/qt_types_standalone/cpp/qbytearray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QByteArray>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qbytearray_cxx.cxx.h"
12+
#include "cxx-qt-gen/qbytearray.cxx.h"
1313

1414
class QByteArrayTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qcolor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtGui/QColor>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qcolor_cxx.cxx.h"
12+
#include "cxx-qt-gen/qcolor.cxx.h"
1313

1414
class QColorTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qcoreapplication.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QCoreApplication>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qcoreapplication_cxx.cxx.h"
12+
#include "cxx-qt-gen/qcoreapplication.cxx.h"
1313

1414
class QCoreApplicationTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qdate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QDate>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qdate_cxx.cxx.h"
12+
#include "cxx-qt-gen/qdate.cxx.h"
1313

1414
class QDateTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qdatetime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QDateTime>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qdatetime_cxx.cxx.h"
12+
#include "cxx-qt-gen/qdatetime.cxx.h"
1313

1414
class QDateTimeTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qguiapplication.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtGui/QGuiApplication>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qguiapplication_cxx.cxx.h"
12+
#include "cxx-qt-gen/qguiapplication.cxx.h"
1313

1414
class QGuiApplicationTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qhash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <QtCore/QVariant>
1111
#include <QtTest/QTest>
1212

13-
#include "cxx-qt-gen/qhash_cxx.cxx.h"
13+
#include "cxx-qt-gen/qhash.cxx.h"
1414

1515
class QHashTest : public QObject
1616
{

tests/qt_types_standalone/cpp/qline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QLine>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qline_cxx.cxx.h"
12+
#include "cxx-qt-gen/qline.cxx.h"
1313

1414
class QLineTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qlinef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QLineF>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qlinef_cxx.cxx.h"
12+
#include "cxx-qt-gen/qlinef.cxx.h"
1313

1414
class QLineFTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QList>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qlist_cxx.cxx.h"
12+
#include "cxx-qt-gen/qlist.cxx.h"
1313

1414
class QListTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <QtCore/QVariant>
1111
#include <QtTest/QTest>
1212

13-
#include "cxx-qt-gen/qmap_cxx.cxx.h"
13+
#include "cxx-qt-gen/qmap.cxx.h"
1414

1515
class QMapTest : public QObject
1616
{

tests/qt_types_standalone/cpp/qmargins.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QMargins>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qmargins_cxx.cxx.h"
12+
#include "cxx-qt-gen/qmargins.cxx.h"
1313

1414
class QMarginsTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qmarginsf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QMarginsF>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qmarginsf_cxx.cxx.h"
12+
#include "cxx-qt-gen/qmarginsf.cxx.h"
1313

1414
class QMarginsFTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qmetaobjectconnection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <QtTest/QTest>
1212
#include <qobjectdefs.h>
1313

14-
#include "cxx-qt-gen/qmetaobjectconnection_cxx.cxx.h"
14+
#include "cxx-qt-gen/qmetaobjectconnection.cxx.h"
1515

1616
class MyObject : public QObject
1717
{

tests/qt_types_standalone/cpp/qmodelindex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <QtCore/QStringListModel>
1212
#include <QtTest/QTest>
1313

14-
#include "cxx-qt-gen/qmodelindex_cxx.cxx.h"
14+
#include "cxx-qt-gen/qmodelindex.cxx.h"
1515

1616
// We subclass from QAbstractListModel to have a valid model to use for
1717
// access to createIndex();

tests/qt_types_standalone/cpp/qpersistentmodelindex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <QtGui/QStandardItemModel>
1212
#include <QtTest/QTest>
1313

14-
#include "cxx-qt-gen/qpersistentmodelindex_cxx.cxx.h"
14+
#include "cxx-qt-gen/qpersistentmodelindex.cxx.h"
1515

1616
class QPersistentModelIndexTest : public QObject
1717
{

tests/qt_types_standalone/cpp/qpoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QPoint>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qpoint_cxx.cxx.h"
12+
#include "cxx-qt-gen/qpoint.cxx.h"
1313

1414
class QPointTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qpointf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QPointF>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qpointf_cxx.cxx.h"
12+
#include "cxx-qt-gen/qpointf.cxx.h"
1313

1414
class QPointFTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qqmlapplicationengine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <QtQml/QQmlApplicationEngine>
1111
#include <QtTest/QTest>
1212

13-
#include "cxx-qt-gen/qqmlapplicationengine_cxx.cxx.h"
13+
#include "cxx-qt-gen/qqmlapplicationengine.cxx.h"
1414

1515
class QQmlApplicationEngineTest : public QObject
1616
{

tests/qt_types_standalone/cpp/qqmlengine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <QtQml/QQmlEngine>
1111
#include <QtTest/QTest>
1212

13-
#include "cxx-qt-gen/qqmlengine_cxx.cxx.h"
13+
#include "cxx-qt-gen/qqmlengine.cxx.h"
1414

1515
class QQmlEngineTest : public QObject
1616
{

tests/qt_types_standalone/cpp/qrect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QRect>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qrect_cxx.cxx.h"
12+
#include "cxx-qt-gen/qrect.cxx.h"
1313

1414
class QRectTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qrectf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QRectF>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qrectf_cxx.cxx.h"
12+
#include "cxx-qt-gen/qrectf.cxx.h"
1313

1414
class QRectFTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QSet>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qset_cxx.cxx.h"
12+
#include "cxx-qt-gen/qset.cxx.h"
1313

1414
class QSetTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qsize.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QSize>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qsize_cxx.cxx.h"
12+
#include "cxx-qt-gen/qsize.cxx.h"
1313

1414
class QSizeTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qsizef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QSizeF>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qsizef_cxx.cxx.h"
12+
#include "cxx-qt-gen/qsizef.cxx.h"
1313

1414
class QSizeFTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qstring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QString>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qstring_cxx.cxx.h"
12+
#include "cxx-qt-gen/qstring.cxx.h"
1313

1414
class QStringTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qstringlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QStringList>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qstringlist_cxx.cxx.h"
12+
#include "cxx-qt-gen/qstringlist.cxx.h"
1313

1414
class QStringListTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qtime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QTime>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qtime_cxx.cxx.h"
12+
#include "cxx-qt-gen/qtime.cxx.h"
1313

1414
class QTimeTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qtimezone.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QTimeZone>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qtimezone_cxx.cxx.h"
12+
#include "cxx-qt-gen/qtimezone.cxx.h"
1313

1414
class QTimeZoneTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qurl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QUrl>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qurl_cxx.cxx.h"
12+
#include "cxx-qt-gen/qurl.cxx.h"
1313

1414
class QUrlTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qvariant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QVariant>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qvariant_cxx.cxx.h"
12+
#include "cxx-qt-gen/qvariant.cxx.h"
1313

1414
// We use VariantTest in data driven tests, so register to Qt metatype system
1515
Q_DECLARE_METATYPE(VariantTest)

tests/qt_types_standalone/cpp/qvector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtCore/QVector>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qvector_cxx.cxx.h"
12+
#include "cxx-qt-gen/qvector.cxx.h"
1313

1414
class QVectorTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qvector2d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtGui/QVector2D>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qvector_2_d_cxx.cxx.h"
12+
#include "cxx-qt-gen/qvector2d.cxx.h"
1313

1414
class QVector2DTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qvector3d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtGui/QVector4D>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qvector_3_d_cxx.cxx.h"
12+
#include "cxx-qt-gen/qvector3d.cxx.h"
1313

1414
class QVector3DTest : public QObject
1515
{

tests/qt_types_standalone/cpp/qvector4d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QtGui/QVector4D>
1010
#include <QtTest/QTest>
1111

12-
#include "cxx-qt-gen/qvector_4_d_cxx.cxx.h"
12+
#include "cxx-qt-gen/qvector4d.cxx.h"
1313

1414
class QVector4DTest : public QObject
1515
{

0 commit comments

Comments
 (0)