From 125543957d3386983ae4ea00a59073607248c235 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 4 Dec 2021 00:31:01 +0100 Subject: [PATCH] WIP: Fixed GSI to some extent, some tests --- scripts/mkqtdecl6/mkqtdecl.conf | 3 - scripts/mkqtdecl_common/c++.treetop | 2 +- src/db/db/dbBox.h | 10 +- src/db/db/dbEdge.h | 10 +- src/db/db/dbEdgePair.h | 10 +- src/db/db/dbPoint.h | 10 +- src/db/db/dbText.h | 4 +- src/db/db/dbTrans.h | 14 +-- src/db/db/dbVector.h | 10 +- src/db/db/gsiDeclDbBox.cc | 7 +- src/db/db/gsiDeclDbEdge.cc | 7 +- src/db/db/gsiDeclDbEdgePair.cc | 7 +- src/db/db/gsiDeclDbPoint.cc | 7 +- src/db/db/gsiDeclDbText.cc | 7 +- src/db/db/gsiDeclDbTrans.cc | 11 +- src/db/db/gsiDeclDbVector.cc | 5 +- src/gsi/gsi/gsiClass.h | 2 +- src/gsi/gsi_test/gsiTest.cc | 163 +++++++++++++++++++++++++- src/gsi/gsi_test/gsiTest.h | 78 +++++++++++- src/gsiqt/qt6/QtGui/gsiDeclQRgba64.cc | 40 +++++++ src/tl/tl/tlString.h | 4 +- testdata/ruby/basic_testcore.rb | 10 +- 22 files changed, 338 insertions(+), 83 deletions(-) diff --git a/scripts/mkqtdecl6/mkqtdecl.conf b/scripts/mkqtdecl6/mkqtdecl.conf index dd93a037e..396216df9 100644 --- a/scripts/mkqtdecl6/mkqtdecl.conf +++ b/scripts/mkqtdecl6/mkqtdecl.conf @@ -809,9 +809,6 @@ include "QWindow", [ "", "", include "QOffscreenSurface", [ "", "" ] include "QScreenOrientationChangeEvent", [ "", "" ] -drop_method "QRgba64", /QRgba64::QRgba64\(.*quint64/ # some problem with quint64 type ... @@@ TODO: debug later -drop_method "QRgba64", /QRgba64::operator=\(.*quint64/ # some problem with quint64 type ... @@@ TODO: debug later -drop_method "QRgba64", /QRgba64::quint64/ # some problem with quint64 type ... @@@ TODO: debug later drop_method "QWindow", /QWindow::handle/ # QPlatformWindow not available drop_method "QScreen", /QScreen::handle/ # QPlatformScreen not available drop_method "QSurface", /QSurface::surfaceHandle/ # QPlatformSurface not available diff --git a/scripts/mkqtdecl_common/c++.treetop b/scripts/mkqtdecl_common/c++.treetop index 26f1f3489..9dfb92bd5 100644 --- a/scripts/mkqtdecl_common/c++.treetop +++ b/scripts/mkqtdecl_common/c++.treetop @@ -97,7 +97,7 @@ grammar CPP rule id "operator" s "," / "operator" s ( bin_op / unary_op / "," ) / - "operator" sp [a-zA-Z\*\& \t\n\r]+ &( s "(" ) / + "operator" sp [a-zA-Z_0-9\*\& \t\n\r]+ &( s "(" ) / "~"? [a-zA-Z_] [a-zA-Z_0-9]* end diff --git a/src/db/db/dbBox.h b/src/db/db/dbBox.h index 31502f164..08177b319 100644 --- a/src/db/db/dbBox.h +++ b/src/db/db/dbBox.h @@ -612,21 +612,13 @@ struct DB_PUBLIC_TEMPLATE box */ double double_area () const; - /** - * @brief Default conversion to string - */ - std::string to_string () const - { - return to_string (0.0); - } - /** * @brief Conversion to string * * If dbu is set, it determines the factor by which the coordinates are multiplied to render * micron units. In addition, a micron format is chosen for output of these coordinates. */ - std::string to_string (double dbu) const + std::string to_string (double dbu = 0.0) const { if (empty ()) { return "()"; diff --git a/src/db/db/dbEdge.h b/src/db/db/dbEdge.h index da2e29cd7..7104fcdab 100644 --- a/src/db/db/dbEdge.h +++ b/src/db/db/dbEdge.h @@ -586,21 +586,13 @@ public: return dx_abs () + dy_abs (); } - /** - * @brief Default conversion to string - */ - std::string to_string () const - { - return to_string (0.0); - } - /** * @brief Conversion to a string. * * If dbu is set, it determines the factor by which the coordinates are multiplied to render * micron units. In addition, a micron format is chosen for output of these coordinates. */ - std::string to_string (double dbu) const + std::string to_string (double dbu = 0.0) const { return "(" + m_p1.to_string (dbu) + ";" + m_p2.to_string (dbu) + ")"; } diff --git a/src/db/db/dbEdgePair.h b/src/db/db/dbEdgePair.h index 6cebdf015..826bb0d1a 100644 --- a/src/db/db/dbEdgePair.h +++ b/src/db/db/dbEdgePair.h @@ -387,21 +387,13 @@ public: return m_first.is_ortho () && m_second.is_ortho (); } - /** - * @brief Default conversion to string - */ - std::string to_string () const - { - return to_string (0.0); - } - /** * @brief Conversion to a string. * * If dbu is set, it determines the factor by which the coordinates are multiplied to render * micron units. In addition, a micron format is chosen for output of these coordinates. */ - std::string to_string (double dbu) const + std::string to_string (double dbu = 0.0) const { return lesser ().to_string (dbu) + (m_symmetric ? "|" : "/") + greater ().to_string (dbu); } diff --git a/src/db/db/dbPoint.h b/src/db/db/dbPoint.h index 741c061d3..c8ab8d1a0 100644 --- a/src/db/db/dbPoint.h +++ b/src/db/db/dbPoint.h @@ -285,14 +285,6 @@ public: */ double sq_double_distance () const; - /** - * @brief Default conversion to string - */ - std::string to_string () const - { - return to_string (0.0); - } - /** * @brief String conversion * @@ -300,7 +292,7 @@ public: * micron units. In addition, a micron format is chosen for output of these coordinates. */ std::string - to_string (double dbu) const + to_string (double dbu = 0.0) const { if (dbu == 1.0) { return tl::db_to_string (m_x) + "," + tl::db_to_string (m_y); diff --git a/src/db/db/dbText.h b/src/db/db/dbText.h index 47fd1e64f..03361eba8 100644 --- a/src/db/db/dbText.h +++ b/src/db/db/dbText.h @@ -757,9 +757,9 @@ public: /** * @brief String conversion */ - std::string to_string () const + std::string to_string (double dbu = 0.0) const { - return std::string ("(") + tl::to_quoted_string (string ()) + "," + m_trans.to_string () + ")"; + return std::string ("(") + tl::to_quoted_string (string ()) + "," + m_trans.to_string (dbu) + ")"; } /** diff --git a/src/db/db/dbTrans.h b/src/db/db/dbTrans.h index c08915e74..115f6b920 100644 --- a/src/db/db/dbTrans.h +++ b/src/db/db/dbTrans.h @@ -1472,10 +1472,10 @@ public: /** * @brief String conversion */ - std::string to_string () const + std::string to_string (double dbu = 0.0) const { std::string s1 = fixpoint_trans::to_string (); - std::string s2 = m_u.to_string (); + std::string s2 = m_u.to_string (dbu); if (! s1.empty () && ! s2.empty ()) { return s1 + " " + s2; } else { @@ -2242,14 +2242,6 @@ public: return ! equal (t); } - /** - * @brief Default string conversion - */ - std::string to_string () const - { - return to_string (false); - } - /** * @brief String conversion * @@ -2257,7 +2249,7 @@ public: * When lazy is set to true, output that is not required (i.e. magnification when 1) * is dropped. If dbu is set, the coordinates are multiplied with this factor to render micron units. */ - std::string to_string (bool lazy, double dbu = 0.0) const + std::string to_string (bool lazy = false, double dbu = 0.0) const { std::string s; if (is_mirror ()) { diff --git a/src/db/db/dbVector.h b/src/db/db/dbVector.h index 34e079c1f..d2b7642ec 100644 --- a/src/db/db/dbVector.h +++ b/src/db/db/dbVector.h @@ -327,14 +327,6 @@ public: */ double sq_double_length () const; - /** - * @brief Default conversion to string - */ - std::string to_string () const - { - return to_string (0.0); - } - /** * @brief String conversion * @@ -342,7 +334,7 @@ public: * micron units. In addition, a micron format is chosen for output of these coordinates. */ std::string - to_string (double dbu) const + to_string (double dbu = 0.0) const { if (dbu == 1.0) { return tl::db_to_string (m_x) + "," + tl::db_to_string (m_y); diff --git a/src/db/db/gsiDeclDbBox.cc b/src/db/db/gsiDeclDbBox.cc index 28b1079ea..e4d2dda8a 100644 --- a/src/db/db/gsiDeclDbBox.cc +++ b/src/db/db/gsiDeclDbBox.cc @@ -441,10 +441,13 @@ struct box_defs "\n" "This method has been added in version 0.23.\n" ) + - method ("to_s", (std::string (C::*) () const) &C::to_string, + method ("to_s", &C::to_string, gsi::arg ("dbu", 0.0), "@brief Returns a string representing this box\n" "\n" - "This string can be turned into a box again by using \\from_s\n" + "This string can be turned into a box again by using \\from_s\n. " + "If a DBU is given, the output units will be micrometers.\n" + "\n" + "The DBU argument has been added in version 0.27.6.\n" ); } }; diff --git a/src/db/db/gsiDeclDbEdge.cc b/src/db/db/gsiDeclDbEdge.cc index cd4424477..12b3aacd2 100644 --- a/src/db/db/gsiDeclDbEdge.cc +++ b/src/db/db/gsiDeclDbEdge.cc @@ -439,8 +439,11 @@ struct edge_defs "\n" "This method has been added in version 0.23.\n" ) + - method ("to_s", (std::string (C::*) () const) &C::to_string, - "@brief Returns a string representing the edge\n" + method ("to_s", &C::to_string, gsi::arg ("dbu", 0.0), + "@brief Returns a string representing the edge\n " + "If a DBU is given, the output units will be micrometers.\n" + "\n" + "The DBU argument has been added in version 0.27.6.\n" ) + method ("is_parallel?", &C::parallel, gsi::arg ("e"), "@brief Test for being parallel\n" diff --git a/src/db/db/gsiDeclDbEdgePair.cc b/src/db/db/gsiDeclDbEdgePair.cc index fdcc00c66..b26862385 100644 --- a/src/db/db/gsiDeclDbEdgePair.cc +++ b/src/db/db/gsiDeclDbEdgePair.cc @@ -156,8 +156,11 @@ struct edge_pair_defs "\n" "This method has been added in version 0.23.\n" ) + - method ("to_s", (std::string (C::*) () const) &C::to_string, - "@brief Returns a string representing the edge pair\n" + method ("to_s", &C::to_string, gsi::arg ("dbu", 0.0), + "@brief Returns a string representing the edge pair\n " + "If a DBU is given, the output units will be micrometers.\n" + "\n" + "The DBU argument has been added in version 0.27.6.\n" ) + method ("bbox", &C::bbox, "@brief Gets the bounding box of the edge pair\n" diff --git a/src/db/db/gsiDeclDbPoint.cc b/src/db/db/gsiDeclDbPoint.cc index 48aff21a4..df876b2ba 100644 --- a/src/db/db/gsiDeclDbPoint.cc +++ b/src/db/db/gsiDeclDbPoint.cc @@ -234,8 +234,11 @@ struct point_defs "\n" "This method has been added in version 0.23.\n" ) + - method ("to_s", (std::string (C::*) () const) &C::to_string, - "@brief String conversion\n" + method ("to_s", &C::to_string, gsi::arg ("dbu", 0.0), + "@brief String conversion.\n" + "If a DBU is given, the output units will be micrometers.\n" + "\n" + "The DBU argument has been added in version 0.27.6.\n" ); } diff --git a/src/db/db/gsiDeclDbText.cc b/src/db/db/gsiDeclDbText.cc index 3f241b2fa..7da557d99 100644 --- a/src/db/db/gsiDeclDbText.cc +++ b/src/db/db/gsiDeclDbText.cc @@ -345,8 +345,11 @@ struct text_defs "\n" "This method has been added in version 0.23.\n" ) + - method ("to_s", (std::string (C::*) () const) &C::to_string, - "@brief Convert to a string\n" + method ("to_s", &C::to_string, gsi::arg ("dbu", 0.0), + "@brief Convert to a string.\n" + "If a DBU is given, the output units will be micrometers.\n" + "\n" + "The DBU argument has been added in version 0.27.6.\n" ); } }; diff --git a/src/db/db/gsiDeclDbTrans.cc b/src/db/db/gsiDeclDbTrans.cc index 397378c17..cd72a204c 100644 --- a/src/db/db/gsiDeclDbTrans.cc +++ b/src/db/db/gsiDeclDbTrans.cc @@ -333,8 +333,11 @@ struct trans_defs "\n" "This method has been added in version 0.23.\n" ) + - method ("to_s", (std::string (C::*) () const) &C::to_string, + method ("to_s", &C::to_string, gsi::arg ("dbu", 0.0), "@brief String conversion\n" + "If a DBU is given, the output units will be micrometers.\n" + "\n" + "The DBU argument has been added in version 0.27.6.\n" ) + method ("disp", (const vector_type &(C::*) () const) &C::disp, "@brief Gets to the displacement vector\n" @@ -853,8 +856,12 @@ struct cplx_trans_defs "\n" "This method has been added in version 0.23.\n" ) + - method ("to_s", (std::string (C::*) () const) &C::to_string, + method ("to_s", &C::to_string, gsi::arg ("lazy", false), gsi::arg ("dbu", 0.0), "@brief String conversion\n" + "If 'lazy' is true, some parts are omitted when not required.\n" + "If a DBU is given, the output units will be micrometers.\n" + "\n" + "The lazy and DBU arguments have been added in version 0.27.6.\n" ) + method ("disp", (displacement_type (C::*)() const) &C::disp, "@brief Gets the displacement\n" diff --git a/src/db/db/gsiDeclDbVector.cc b/src/db/db/gsiDeclDbVector.cc index 9ad16cd02..3f5619afa 100644 --- a/src/db/db/gsiDeclDbVector.cc +++ b/src/db/db/gsiDeclDbVector.cc @@ -264,8 +264,11 @@ struct vector_defs "@brief Creates an object from a string\n" "Creates the object from a string representation (as returned by \\to_s)\n" ) + - method ("to_s", (std::string (C::*) () const) &C::to_string, + method ("to_s", &C::to_string, gsi::arg ("dbu", 0.0), "@brief String conversion\n" + "If a DBU is given, the output units will be micrometers.\n" + "\n" + "The DBU argument has been added in version 0.27.6.\n" ); } diff --git a/src/gsi/gsi/gsiClass.h b/src/gsi/gsi/gsiClass.h index d6f2d9c81..48ec4e0ca 100644 --- a/src/gsi/gsi/gsiClass.h +++ b/src/gsi/gsi/gsiClass.h @@ -230,7 +230,7 @@ template struct _create { static void *call () { return new X template struct _clone; template struct _clone { static void *call (const void *) { throw tl::Exception (tl::to_string (tr ("Object cannot be copied here"))); } }; -template struct _clone { static void *call (const void *other) { new X (*(const X *)other); } }; +template struct _clone { static void *call (const void *other) { return new X (*(const X *)other); } }; template struct _assign; template struct _assign { static void call (void *, const void *) { throw tl::Exception (tl::to_string (tr ("Object cannot be copied here"))); } }; diff --git a/src/gsi/gsi_test/gsiTest.cc b/src/gsi/gsi_test/gsiTest.cc index ba53486cb..34d9180e1 100644 --- a/src/gsi/gsi_test/gsiTest.cc +++ b/src/gsi/gsi_test/gsiTest.cc @@ -112,6 +112,8 @@ tl::Variant A::new_a_by_variant () return tl::Variant (A ()); } +#if defined(HAVE_QT) + std::vector A::qba_cref_to_ia (const QByteArray &ba) { @@ -134,8 +136,8 @@ A::ia_cref_to_qba (const std::vector &ia) return ba; } -const QByteArray & -A::ia_cref_to_qba_cref (const std::vector &ia) +QByteArray & +A::ia_cref_to_qba_ref (const std::vector &ia) { static QByteArray ba; ba.clear (); @@ -145,6 +147,120 @@ A::ia_cref_to_qba_cref (const std::vector &ia) return ba; } +#if QT_VERSION >= 0x60000 + +std::vector +A::qbav_cref_to_ia (const QByteArrayView &ba) +{ + const char *cp = ba.constData (); + size_t n = ba.size (); + std::vector ia; + for (size_t i = 0; i < n; ++i) { + ia.push_back (int (*cp++)); + } + return ia; +} + +QByteArrayView +A::ia_cref_to_qbav (const std::vector &ia) +{ + static QByteArray ba; + ba.clear (); + for (std::vector::const_iterator i = ia.begin (); i != ia.end (); ++i) { + ba.push_back (char (*i)); + } + return ba; +} + +QByteArrayView & +A::ia_cref_to_qbav_ref (const std::vector &ia) +{ + static QByteArray ba; + ba.clear (); + for (std::vector::const_iterator i = ia.begin (); i != ia.end (); ++i) { + ba.push_back (char (*i)); + } + static QByteArrayView bav; + bav = ba; + return bav; +} + +#endif + +std::vector +A::qs_cref_to_ia (const QString &qs) +{ + const QChar *cp = qs.constData (); + size_t n = qs.size (); + std::vector ia; + for (size_t i = 0; i < n; ++i) { + ia.push_back ((*cp++).unicode ()); + } + return ia; +} + +QString +A::ia_cref_to_qs (const std::vector &ia) +{ + QString s; + for (std::vector::const_iterator i = ia.begin (); i != ia.end (); ++i) { + s.push_back (char (*i)); + } + return s; +} + +QString & +A::ia_cref_to_qs_ref (const std::vector &ia) +{ + static QString s; + s.clear (); + for (std::vector::const_iterator i = ia.begin (); i != ia.end (); ++i) { + s.push_back (char (*i)); + } + return s; +} + +#if QT_VERSION >= 0x60000 + +std::vector +A::qsv_cref_to_ia (const QStringView &qs) +{ + const QChar *cp = qs.constData (); + size_t n = qs.size (); + std::vector ia; + for (size_t i = 0; i < n; ++i) { + ia.push_back ((*cp++).unicode ()); + } + return ia; +} + +QStringView +A::ia_cref_to_qsv (const std::vector &ia) +{ + QString s; + for (std::vector::const_iterator i = ia.begin (); i != ia.end (); ++i) { + s.push_back (char (*i)); + } + return s; +} + +QStringView & +A::ia_cref_to_qsv_ref (const std::vector &ia) +{ + static QString s; + s.clear (); + for (std::vector::const_iterator i = ia.begin (); i != ia.end (); ++i) { + s.push_back (char (*i)); + } + static QStringView sv; + sv = s; + return sv; +} + +#endif + +#endif + std::vector A::ba_cref_to_ia (const std::vector &ba) { @@ -877,6 +993,7 @@ static gsi::Class decl_a ("", "A", gsi::method ("new_a_by_variant", &A::new_a_by_variant) + #if defined(HAVE_QT) + gsi::method ("qba_cref_to_ia", &A::qba_cref_to_ia) + gsi::method ("qba_ref_to_ia", &A::qba_ref_to_ia) + gsi::method ("qba_cptr_to_ia", &A::qba_cptr_to_ia) + @@ -884,7 +1001,49 @@ static gsi::Class decl_a ("", "A", gsi::method ("qba_to_ia", &A::qba_to_ia) + gsi::method ("ia_cref_to_qba", &A::ia_cref_to_qba) + gsi::method ("ia_cref_to_qba_cref", &A::ia_cref_to_qba_cref) + + gsi::method ("ia_cref_to_qba_ref", &A::ia_cref_to_qba_ref) + + gsi::method ("ia_cptr_to_qba_cptr", &A::ia_cref_to_qba_cptr) + + gsi::method ("ia_cptr_to_qba_ptr", &A::ia_cref_to_qba_ptr) + + + gsi::method ("qs_cref_to_ia", &A::qs_cref_to_ia) + + gsi::method ("qs_ref_to_ia", &A::qs_ref_to_ia) + + gsi::method ("qs_cptr_to_ia", &A::qs_cptr_to_ia) + + gsi::method ("qs_ptr_to_ia", &A::qs_ptr_to_ia) + + gsi::method ("qs_to_ia", &A::qs_to_ia) + + gsi::method ("ia_cref_to_qs", &A::ia_cref_to_qs) + + gsi::method ("ia_cref_to_qs_cref", &A::ia_cref_to_qs_cref) + + gsi::method ("ia_cref_to_qs_ref", &A::ia_cref_to_qs_ref) + + gsi::method ("ia_cptr_to_qs_cptr", &A::ia_cref_to_qs_cptr) + + gsi::method ("ia_cptr_to_qs_ptr", &A::ia_cref_to_qs_ptr) + + +#if QT_VERSION >= 0x60000 + + gsi::method ("qbav_cref_to_ia", &A::qbav_cref_to_ia) + + gsi::method ("qbav_ref_to_ia", &A::qbav_ref_to_ia) + + gsi::method ("qbav_cptr_to_ia", &A::qbav_cptr_to_ia) + + gsi::method ("qbav_ptr_to_ia", &A::qbav_ptr_to_ia) + + gsi::method ("qbav_to_ia", &A::qbav_to_ia) + + gsi::method ("ia_cref_to_qbav", &A::ia_cref_to_qbav) + + gsi::method ("ia_cref_to_qbav_cref", &A::ia_cref_to_qbav_cref) + + gsi::method ("ia_cref_to_qbav_ref", &A::ia_cref_to_qbav_ref) + + gsi::method ("ia_cptr_to_qbav_cptr", &A::ia_cref_to_qbav_cptr) + + gsi::method ("ia_cptr_to_qbav_ptr", &A::ia_cref_to_qbav_ptr) + + + gsi::method ("qsv_cref_to_ia", &A::qsv_cref_to_ia) + + gsi::method ("qsv_ref_to_ia", &A::qsv_ref_to_ia) + + gsi::method ("qsv_cptr_to_ia", &A::qsv_cptr_to_ia) + + gsi::method ("qsv_ptr_to_ia", &A::qsv_ptr_to_ia) + + gsi::method ("qsv_to_ia", &A::qsv_to_ia) + + gsi::method ("ia_cref_to_qsv", &A::ia_cref_to_qsv) + + gsi::method ("ia_cref_to_qsv_cref", &A::ia_cref_to_qsv_cref) + + gsi::method ("ia_cref_to_qsv_ref", &A::ia_cref_to_qsv_ref) + + gsi::method ("ia_cptr_to_qsv_cptr", &A::ia_cref_to_qsv_cptr) + + gsi::method ("ia_cptr_to_qsv_ptr", &A::ia_cref_to_qsv_ptr) + + #endif + +#endif + gsi::method ("ba_cref_to_ia", &A::ba_cref_to_ia) + gsi::method ("ba_ref_to_ia", &A::ba_ref_to_ia) + gsi::method ("ba_cptr_to_ia", &A::ba_cptr_to_ia) + diff --git a/src/gsi/gsi_test/gsiTest.h b/src/gsi/gsi_test/gsiTest.h index 57d6efb95..37777c3ca 100644 --- a/src/gsi/gsi_test/gsiTest.h +++ b/src/gsi/gsi_test/gsiTest.h @@ -99,6 +99,7 @@ struct A static tl::Variant new_a_by_variant (); #if defined(HAVE_QT) + /** * @brief Byte sequences: tests access to QByteArray */ @@ -108,11 +109,84 @@ struct A static std::vector qba_ptr_to_ia (QByteArray *ba) { return qba_cref_to_ia (*ba); } static std::vector qba_to_ia (QByteArray ba) { return qba_cref_to_ia (ba); } +#if QT_VERSION >= 0x60000 + + /** + * @brief Byte sequences: tests access to QByteArrayView + */ + static std::vector qbav_cref_to_ia (const QByteArrayView &ba); + static std::vector qbav_ref_to_ia (QByteArrayView &ba) { return qbav_cref_to_ia (ba); } + static std::vector qbav_cptr_to_ia (const QByteArrayView *ba) { return qbav_cref_to_ia (*ba); } + static std::vector qbav_ptr_to_ia (QByteArrayView *ba) { return qbav_cref_to_ia (*ba); } + static std::vector qbav_to_ia (QByteArrayView ba) { return qbav_cref_to_ia (ba); } + +#endif + + /** + * @brief Byte sequences: tests access to QString + */ + static std::vector qs_cref_to_ia (const QString &qs); + static std::vector qs_ref_to_ia (QString &qs) { return qs_cref_to_ia (qs); } + static std::vector qs_cptr_to_ia (const QString *qs) { return qs_cref_to_ia (*qs); } + static std::vector qs_ptr_to_ia (QString *qs) { return qs_cref_to_ia (*qs); } + static std::vector qs_to_ia (QString qs) { return qs_cref_to_ia (qs); } + +#if QT_VERSION >= 0x60000 + + /** + * @brief Byte sequences: tests access to QStringView + */ + static std::vector qsv_cref_to_ia (const QStringView &qs); + static std::vector qsv_ref_to_ia (QStringView &qs) { return qsv_cref_to_ia (qs); } + static std::vector qsv_cptr_to_ia (const QStringView *qs) { return qsv_cref_to_ia (*qs); } + static std::vector qsv_ptr_to_ia (QStringView *qs) { return qsv_cref_to_ia (*qs); } + static std::vector qsv_to_ia (QStringView qs) { return qsv_cref_to_ia (qs); } + +#endif + /** * @brief Byte sequences: tests return of QByteArray */ static QByteArray ia_cref_to_qba (const std::vector &ia); - static const QByteArray &ia_cref_to_qba_cref (const std::vector &ia); + static QByteArray &ia_cref_to_qba_ref (const std::vector &ia); + static const QByteArray &ia_cref_to_qba_cref (const std::vector &ia) { return ia_cref_to_qba_ref (ia); } + static const QByteArray *ia_cref_to_qba_cptr (const std::vector &ia) { return &ia_cref_to_qba_ref (ia); } + static QByteArray *ia_cref_to_qba_ptr (const std::vector &ia) { return &ia_cref_to_qba_ref (ia); } + +#if QT_VERSION >= 0x60000 + + /** + * @brief Byte sequences: tests return of QByteArrayView (uses a static buffer) + */ + static QByteArrayView ia_cref_to_qbav (const std::vector &ia); + static QByteArrayView &ia_cref_to_qbav_ref (const std::vector &ia); + static const QByteArrayView &ia_cref_to_qbav_cref (const std::vector &ia) { return ia_cref_to_qbav_ref (ia); } + static const QByteArrayView *ia_cref_to_qbav_cptr (const std::vector &ia) { return &ia_cref_to_qbav_ref (ia); } + static QByteArrayView *ia_cref_to_qbav_ptr (const std::vector &ia) { return &ia_cref_to_qbav_ref (ia); } + +#endif + + /** + * @brief Byte sequences: tests return of QString + */ + static QString ia_cref_to_qs (const std::vector &ia); + static QString &ia_cref_to_qs_ref (const std::vector &ia); + static const QString &ia_cref_to_qs_cref (const std::vector &ia) { return ia_cref_to_qs_ref (ia); } + static const QString *ia_cref_to_qs_cptr (const std::vector &ia) { return &ia_cref_to_qs_ref (ia); } + static QString *ia_cref_to_qs_ptr (const std::vector &ia) { return &ia_cref_to_qs_ref (ia); } + +#if QT_VERSION >= 0x60000 + + /** + * @brief Byte sequences: tests return of QStringView (uses a static buffer) + */ + static QStringView ia_cref_to_qsv (const std::vector &ia); + static QStringView &ia_cref_to_qsv_ref (const std::vector &ia); + static const QStringView &ia_cref_to_qsv_cref (const std::vector &ia) { return ia_cref_to_qsv_ref (ia); } + static const QStringView *ia_cref_to_qsv_cptr (const std::vector &ia) { return &ia_cref_to_qsv_ref (ia); } + static QStringView *ia_cref_to_qsv_ptr (const std::vector &ia) { return &ia_cref_to_qsv_ref (ia); } + +#endif #endif @@ -207,11 +281,13 @@ struct A std::string a10_d (double f) { return tl::to_string (f); } std::vector a10_d_ba (double f) { std::string s = tl::to_string (f); return std::vector (s.begin (), s.end ()); } + #if defined(HAVE_QT) QByteArray a10_d_qba (double f) { return tl::to_qstring (tl::to_string (f)).toUtf8 (); } QString a10_d_qstr (double f) { return tl::to_qstring (tl::to_string (f)); } QStringRef a10_d_qstrref (double f) { m_s = tl::to_qstring (tl::to_string (f)); return QStringRef (&m_s); } #endif + std::string a10_f (float f) { return tl::to_string(f); } std::string a10_s (short l) { return tl::to_string(int (l)); } std::string a10_us (unsigned short l) { return tl::to_string(int (l)); } diff --git a/src/gsiqt/qt6/QtGui/gsiDeclQRgba64.cc b/src/gsiqt/qt6/QtGui/gsiDeclQRgba64.cc index c30495964..77b80642a 100644 --- a/src/gsiqt/qt6/QtGui/gsiDeclQRgba64.cc +++ b/src/gsiqt/qt6/QtGui/gsiDeclQRgba64.cc @@ -170,6 +170,25 @@ static void _call_f_isTransparent_c0 (const qt_gsi::GenericMethod * /*decl*/, vo } +// QRgba64 &QRgba64::operator=(quint64 _rgba) + + +static void _init_f_operator_eq__1103 (qt_gsi::GenericMethod *decl) +{ + static gsi::ArgSpecBase argspec_0 ("_rgba"); + decl->add_arg (argspec_0); + decl->set_return (); +} + +static void _call_f_operator_eq__1103 (const qt_gsi::GenericMethod * /*decl*/, void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret) +{ + __SUPPRESS_UNUSED_WARNING(args); + tl::Heap heap; + quint64 arg1 = gsi::arg_reader() (args, heap); + ret.write ((QRgba64 &)((QRgba64 *)cls)->operator= (arg1)); +} + + // QRgba64 QRgba64::premultiplied() @@ -387,6 +406,25 @@ static void _call_f_fromRgba_3888 (const qt_gsi::GenericStaticMethod * /*decl*/, } +// static QRgba64 QRgba64::fromRgba64(quint64 c) + + +static void _init_f_fromRgba64_1103 (qt_gsi::GenericStaticMethod *decl) +{ + static gsi::ArgSpecBase argspec_0 ("c"); + decl->add_arg (argspec_0); + decl->set_return (); +} + +static void _call_f_fromRgba64_1103 (const qt_gsi::GenericStaticMethod * /*decl*/, gsi::SerialArgs &args, gsi::SerialArgs &ret) +{ + __SUPPRESS_UNUSED_WARNING(args); + tl::Heap heap; + quint64 arg1 = gsi::arg_reader() (args, heap); + ret.write ((QRgba64)QRgba64::fromRgba64 (arg1)); +} + + // static QRgba64 QRgba64::fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha) @@ -430,6 +468,7 @@ static gsi::Methods methods_QRgba64 () { methods += new qt_gsi::GenericMethod ("green8", "@brief Method quint8 QRgba64::green8()\n", true, &_init_f_green8_c0, &_call_f_green8_c0); methods += new qt_gsi::GenericMethod ("isOpaque?", "@brief Method bool QRgba64::isOpaque()\n", true, &_init_f_isOpaque_c0, &_call_f_isOpaque_c0); methods += new qt_gsi::GenericMethod ("isTransparent?", "@brief Method bool QRgba64::isTransparent()\n", true, &_init_f_isTransparent_c0, &_call_f_isTransparent_c0); + methods += new qt_gsi::GenericMethod ("assign", "@brief Method QRgba64 &QRgba64::operator=(quint64 _rgba)\n", false, &_init_f_operator_eq__1103, &_call_f_operator_eq__1103); methods += new qt_gsi::GenericMethod ("premultiplied", "@brief Method QRgba64 QRgba64::premultiplied()\n", true, &_init_f_premultiplied_c0, &_call_f_premultiplied_c0); methods += new qt_gsi::GenericMethod ("red", "@brief Method quint16 QRgba64::red()\n", true, &_init_f_red_c0, &_call_f_red_c0); methods += new qt_gsi::GenericMethod ("red8", "@brief Method quint8 QRgba64::red8()\n", true, &_init_f_red8_c0, &_call_f_red8_c0); @@ -442,6 +481,7 @@ static gsi::Methods methods_QRgba64 () { methods += new qt_gsi::GenericMethod ("unpremultiplied", "@brief Method QRgba64 QRgba64::unpremultiplied()\n", true, &_init_f_unpremultiplied_c0, &_call_f_unpremultiplied_c0); methods += new qt_gsi::GenericStaticMethod ("fromArgb32", "@brief Static method QRgba64 QRgba64::fromArgb32(unsigned int rgb)\nThis method is static and can be called without an instance.", &_init_f_fromArgb32_1772, &_call_f_fromArgb32_1772); methods += new qt_gsi::GenericStaticMethod ("fromRgba", "@brief Static method QRgba64 QRgba64::fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha)\nThis method is static and can be called without an instance.", &_init_f_fromRgba_3888, &_call_f_fromRgba_3888); + methods += new qt_gsi::GenericStaticMethod ("fromRgba64", "@brief Static method QRgba64 QRgba64::fromRgba64(quint64 c)\nThis method is static and can be called without an instance.", &_init_f_fromRgba64_1103, &_call_f_fromRgba64_1103); methods += new qt_gsi::GenericStaticMethod ("fromRgba64", "@brief Static method QRgba64 QRgba64::fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha)\nThis method is static and can be called without an instance.", &_init_f_fromRgba64_4076, &_call_f_fromRgba64_4076); return methods; } diff --git a/src/tl/tl/tlString.h b/src/tl/tl/tlString.h index bcefe9eeb..6266bbb04 100644 --- a/src/tl/tl/tlString.h +++ b/src/tl/tl/tlString.h @@ -45,7 +45,7 @@ namespace tl { * @brief An exception indicating that string extraction is not available for a certain type */ class TL_PUBLIC ExtractorNotImplementedException - : tl::Exception + : public tl::Exception { public: ExtractorNotImplementedException (); @@ -55,7 +55,7 @@ public: * @brief An exception indicating that string conversion is not available for a certain type */ class TL_PUBLIC StringConversionException - : tl::Exception + : public tl::Exception { public: StringConversionException (); diff --git a/testdata/ruby/basic_testcore.rb b/testdata/ruby/basic_testcore.rb index ab32c9156..a34755802 100644 --- a/testdata/ruby/basic_testcore.rb +++ b/testdata/ruby/basic_testcore.rb @@ -2807,16 +2807,22 @@ class Basic_TestClass < TestBase # binary strings - qba = RBA::A::ia_cref_to_qba([ 17, 42, 0, 8 ]) - assert_equal(qba.inspect, "\"\\x11*\\x00\\b\"") assert_equal(RBA::A::qba_to_ia(qba), [ 17, 42, 0, 8 ]) assert_equal(RBA::A::qba_cref_to_ia(qba), [ 17, 42, 0, 8 ]) assert_equal(RBA::A::qba_cptr_to_ia(qba), [ 17, 42, 0, 8 ]) assert_equal(RBA::A::qba_ref_to_ia(qba), [ 17, 42, 0, 8 ]) assert_equal(RBA::A::qba_ptr_to_ia(qba), [ 17, 42, 0, 8 ]) + qba = RBA::A::ia_cref_to_qba([ 16, 42, 0, 8 ]) + assert_equal(qba.inspect, "\"\\x10*\\x00\\b\"") qba = RBA::A::ia_cref_to_qba_cref([ 17, 42, 0, 8 ]) assert_equal(qba.inspect, "\"\\x11*\\x00\\b\"") + qba = RBA::A::ia_cref_to_qba_ref([ 18, 42, 0, 8 ]) + assert_equal(qba.inspect, "\"\\x12*\\x00\\b\"") + qba = RBA::A::ia_cref_to_qba_cptr([ 19, 42, 0, 8 ]) + assert_equal(qba.inspect, "\"\\x13*\\x00\\b\"") + qba = RBA::A::ia_cref_to_qba_ptr([ 20, 42, 0, 8 ]) + assert_equal(qba.inspect, "\"\\x14*\\x00\\b\"") assert_equal(RBA::A::qba_to_ia("\x00\x01\x02"), [ 0, 1, 2 ])