WIP: removed debug output, resolved a consistency issue between QtGui and QtCore - QtGui was injecting an enum into QtGui.

This commit is contained in:
Matthias Koefferlein 2018-05-30 23:17:35 +02:00
parent 80d00378d3
commit 07b655d3bc
2 changed files with 23 additions and 48 deletions

View File

@ -30,6 +30,12 @@
#include <QColor>
#include <QSize>
// NOTE: this is required because HitTestAccuracy is defined here, but goes into Qt
// namespace which is in QtCore ... this introduces a dependency of QtCore GSI lib on QtGui.
#include <QTextDocument>
class Qt_Namespace { };
namespace gsi_qt
{
@ -175,4 +181,21 @@ gsi::Class<QPair<double, QVariant> > decl_double_QVariant_QPair ("Qt", "QPair_do
"@qt\\n@brief Represents a QPair<double, QVariant>"
);
// ---------------------------------------------------------------------------
// Add declaration for HitTestAccuracy which would be in QtGui, but is in Qt namespace
// (hence QtCore)
static gsi::Enum<Qt::HitTestAccuracy> decl_Qt_HitTestAccuracy_Enum ("QtCore", "Qt_HitTestAccuracy",
gsi::enum_const ("ExactHit", Qt::ExactHit, "@brief Enum constant Qt::ExactHit") +
gsi::enum_const ("FuzzyHit", Qt::FuzzyHit, "@brief Enum constant Qt::FuzzyHit"),
"@qt\n@brief This class represents the Qt::HitTestAccuracy enum");
static gsi::QFlagsClass<Qt::HitTestAccuracy > decl_Qt_HitTestAccuracy_Enums ("QtCore", "Qt_QFlags_HitTestAccuracy",
"@qt\n@brief This class represents the QFlags<Qt::HitTestAccuracy> flag set");
// Inject the declarations into the parent
static gsi::ClassExt<Qt_Namespace> inject_Qt_HitTestAccuracy_Enum_in_parent (decl_Qt_HitTestAccuracy_Enum.defs ());
static gsi::ClassExt<Qt_Namespace> decl_Qt_HitTestAccuracy_Enum_as_child (decl_Qt_HitTestAccuracy_Enum, "QtCore", "HitTestAccuracy");
static gsi::ClassExt<Qt_Namespace> decl_Qt_HitTestAccuracy_Enums_as_child (decl_Qt_HitTestAccuracy_Enums, "QtCore", "QFlags_HitTestAccuracy");
}

View File

@ -25,7 +25,6 @@ import gc
# Set this to True to disable some tests involving exceptions
leak_check = "TEST_LEAK_CHECK" in os.environ
print("@@@1")
# see test_21
class AEXT(pya.A):
def __init__(self):
@ -135,23 +134,16 @@ class BasicTest(unittest.TestCase):
def test_00(self):
print("@@@00")
# all references of PA are released now:
ac0 = pya.A.a0()
print("@@@00-1")
a = pya.A.new_a(100)
self.assertEqual( pya.A.a0(), ac0 + 1 )
print("@@@00-2")
a = pya.A()
print("@@@00-31")
self.assertEqual(a.a1(), 17)
print("@@@00-32")
a.assign(pya.A(110))
print("@@@00-33")
self.assertEqual(a.a1(), 110)
print("@@@00-3")
a = None
self.assertEqual( pya.A.a0(), ac0 )
@ -392,7 +384,6 @@ class BasicTest(unittest.TestCase):
def test_12(self):
print("@@@12")
a1 = pya.A()
a1.a5( -15 )
a2 = a1
@ -593,7 +584,6 @@ class BasicTest(unittest.TestCase):
def test_13(self):
print("@@@13")
b = pya.B()
if not leak_check:
@ -820,7 +810,6 @@ class BasicTest(unittest.TestCase):
def test_13b(self):
print("@@@13b")
b = pya.B()
bb = pya.B()
@ -924,7 +913,6 @@ class BasicTest(unittest.TestCase):
def test_14(self):
print("@@@14")
a = pya.A()
a.a5( 22 )
@ -938,7 +926,6 @@ class BasicTest(unittest.TestCase):
def test_15(self):
print("@@@15")
a = pya.A_NC()
self.assertEqual( True, isinstance(a, pya.A) )
a.a5( 22 )
@ -953,7 +940,6 @@ class BasicTest(unittest.TestCase):
def test_16(self):
print("@@@16")
if leak_check:
return
@ -980,7 +966,6 @@ class BasicTest(unittest.TestCase):
def test_17(self):
print("@@@17")
# test copies of objects being returned
b = pya.B()
@ -1006,7 +991,6 @@ class BasicTest(unittest.TestCase):
def test_18(self):
print("@@@18")
# Test references to objects (returned by b.b7)
b = pya.B()
@ -1033,7 +1017,6 @@ class BasicTest(unittest.TestCase):
def test_19(self):
print("@@@19")
c0 = pya.C()
self.assertEqual( c0.g("x"), 1977 );
@ -1079,7 +1062,6 @@ class BasicTest(unittest.TestCase):
def test_20(self):
print("@@@20")
b = pya.B()
a1 = b.b14a( True )
@ -1099,7 +1081,6 @@ class BasicTest(unittest.TestCase):
def test_21(self):
print("@@@21")
# Python does not allow extending built-in types - the following test
# is taken from the Ruby binding. I don't know how to implement it for
# Python however.
@ -1131,7 +1112,6 @@ class BasicTest(unittest.TestCase):
def test_22(self):
print("@@@22")
# test client data binding to C++ objects
b = pya.B()
@ -1250,7 +1230,6 @@ class BasicTest(unittest.TestCase):
def test_23(self):
print("@@@23")
b = pya.B()
a = pya.A()
@ -1298,7 +1277,6 @@ class BasicTest(unittest.TestCase):
def test_24(self):
print("@@@24")
n = [ 0, 0 , "" ]
# Events
@ -1384,7 +1362,6 @@ class BasicTest(unittest.TestCase):
def test_25(self):
print("@@@25")
# destruction of an instance via c++
pya.A.a20(None)
ac0 = pya.A.a0()
@ -1437,7 +1414,6 @@ class BasicTest(unittest.TestCase):
def test_26(self):
print("@@@26")
# cyclic references - event bound to itself
base_count = EEXT.inst_count()
@ -1481,7 +1457,6 @@ class BasicTest(unittest.TestCase):
def test_27(self):
print("@@@27")
# destruction of an instance via c++
pya.A.a20(None)
ac0 = pya.A.a0()
@ -1518,7 +1493,6 @@ class BasicTest(unittest.TestCase):
def test_28(self):
print("@@@28")
self.assertEqual(pya.B.inst() == None, True)
self.assertEqual(pya.B.has_inst(), False)
@ -1554,7 +1528,6 @@ class BasicTest(unittest.TestCase):
def test_30(self):
print("@@@30")
# some basic tests for the *Value boxing classes
val = pya.Value()
@ -1731,7 +1704,6 @@ class BasicTest(unittest.TestCase):
def test_31(self):
print("@@@31")
# some basic tests with derived and base classes
pya.X.init()
@ -1788,7 +1760,6 @@ class BasicTest(unittest.TestCase):
def test_32(self):
print("@@@32")
# run test only if we have Qt bindings
if not "QStringPair" in pya.__dict__:
return
@ -1817,7 +1788,6 @@ class BasicTest(unittest.TestCase):
def test_33(self):
print("@@@33")
def str_from_bytearray(ba):
if (sys.version_info > (3, 0)):
return ba
@ -1852,7 +1822,6 @@ class BasicTest(unittest.TestCase):
def test_34(self):
print("@@@34")
# run test only if we have Qt bindings
if not "QDialog" in pya.__dict__:
return
@ -1871,7 +1840,6 @@ class BasicTest(unittest.TestCase):
def test_35(self):
print("@@@35")
# vectors of pointers
pya.X.init()
@ -1972,14 +1940,12 @@ class BasicTest(unittest.TestCase):
def test_36(self):
print("@@@36")
x = XEdge()
self.assertEqual("XEdge", type(x).__name__)
self.assertEqual("(1,2;3,4)", str(x))
def test_37(self):
print("@@@37")
# This test is taken from the Ruby binding, but
# Python does not have protected methods:
return
@ -1999,7 +1965,6 @@ class BasicTest(unittest.TestCase):
def test_38(self):
print("@@@38")
# mixed const / non-const reference and events
ec = pya.E.ic()
self.assertEqual(ec.is_const_object(), True)
@ -2031,7 +1996,6 @@ class BasicTest(unittest.TestCase):
def test_39(self):
print("@@@39")
# mixed const / non-const reference and events
fc = pya.F.ic()
self.assertEqual(fc.is_const_object(), True)
@ -2062,7 +2026,6 @@ class BasicTest(unittest.TestCase):
def test_40(self):
print("@@@40")
# optional arguments
g = pya.G()
@ -2146,7 +2109,6 @@ class BasicTest(unittest.TestCase):
def test_41(self):
print("@@@41")
# maps
b = pya.B()
@ -2208,7 +2170,6 @@ class BasicTest(unittest.TestCase):
def test_42(self):
print("@@@42")
# virtual functions and sub-classes
z = pya.Z()
self.assertEqual(z.f(None), "(nil)")
@ -2237,7 +2198,6 @@ class BasicTest(unittest.TestCase):
def test_50(self):
print("@@@50")
# advanced containers and out parameters
b = pya.B()
@ -2412,7 +2372,6 @@ class BasicTest(unittest.TestCase):
self.assertEqual(b.qhash_is(), {})
def test_51(self):
print("@@@51")
# new subclass and child class declarations
y2 = pya.Y2()
@ -2430,7 +2389,6 @@ class BasicTest(unittest.TestCase):
self.assertEqual(isinstance(y4, pya.X), False)
def test_60(self):
print("@@@60")
class SignalCollector(object):
@ -2524,7 +2482,6 @@ class BasicTest(unittest.TestCase):
self.assertEqual(sc.got_s2_2, None)
def test_61(self):
print("@@@61")
class SignalCollector(object):
@ -2608,7 +2565,6 @@ class BasicTest(unittest.TestCase):
self.assertEqual(sc.got_s0b, 0)
def test_70(self):
print("@@@70")
class SignalCollector(object):
@ -2657,7 +2613,6 @@ class BasicTest(unittest.TestCase):
self.assertEqual(sc.got_s2_2.tag, 111)
def test_71(self):
print("@@@71")
class SignalCollector(object):
@ -2742,7 +2697,6 @@ class BasicTest(unittest.TestCase):
# Custom factory implemented in Python
def test_80(self):
print("@@@80")
gc = pya.GObject.g_inst_count()
gf = PyGFactory()
go = pya.GFactory.create_f(gf, 17)
@ -2752,7 +2706,6 @@ class BasicTest(unittest.TestCase):
go = None
self.assertEqual(pya.GObject.g_inst_count(), gc)
print("@@@2")
# run unit tests
if __name__ == '__main__':
suite = unittest.TestSuite()
@ -2762,5 +2715,4 @@ if __name__ == '__main__':
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)
print("@@@3")