File 0001-pyqt4_pyqt5_specific_data_structures.patch of Package python-sip.1536

# HG changeset patch
# User Phil Thompson <phil@riverbankcomputing.com>
# Date 1392731642 0
# Node ID b96a5e69adb6f2243f8079b5381b4a6a28f86468
# Parent  d45411f2a001d318a28f9c6925dc9e6c92206362
Bumped the internal API to v11.0.
The PyQt4 and PyQt5 specific data structures are now completely separate in
preparation for the signal changes needed by PyQt5.
Renamed the PyQt4Flags and PyQt4NoQMetaObject annotations so that they are not
PyQt4 specific.

diff -r d45411f2a001 -r b96a5e69adb6 sipgen/gencode.c
--- a/sipgen/gencode.c	Sun Feb 09 12:02:34 2014 +0000
+++ b/sipgen/gencode.c	Tue Feb 18 13:54:02 2014 +0000
@@ -6580,7 +6580,7 @@
     /* The meta methods if required. */
     if ((pluginPyQt4(pt) || pluginPyQt5(pt)) && isQObjectSubClass(cd))
     {
-        if (!noPyQt4QMetaObject(cd))
+        if (!noPyQtQMetaObject(cd))
         {
             prcode(fp,
 "\n"
@@ -8632,7 +8632,9 @@
     {
         const char *type_prefix;
 
-        if (pluginPyQt4(pt) || pluginPyQt5(pt))
+        if (pluginPyQt5(pt))
+            type_prefix = "pyqt5";
+        else if (pluginPyQt4(pt))
             type_prefix = "pyqt4";
         else if (pluginPyQt3(pt))
             type_prefix = "pyqt3";
@@ -8803,7 +8805,7 @@
 "    void *qt_metacast(const char *);\n"
             );
 
-        if (!noPyQt4QMetaObject(cd))
+        if (!noPyQtQMetaObject(cd))
             prcode(fp,
 "    const QMetaObject *metaObject() const;\n"
                 );
@@ -9635,6 +9637,8 @@
 
     if ((pluginPyQt4(pt) || pluginPyQt5(pt)) && isQObjectSubClass(cd))
     {
+        const char *pyqt_prefix = (pluginPyQt5(pt) ? "pyqt5" : "pyqt4");
+
         /* The signals must be grouped by name. */
         for (md = cd->members; md != NULL; md = md->next)
         {
@@ -9670,9 +9674,9 @@
                     prcode(fp,
 "\n"
 "\n"
-"/* Define this type's PyQt4 signals. */\n"
-"static const pyqt4QtSignal pyqt4_signals_%C[] = {\n"
-                        , classFQCName(cd));
+"/* Define this type's signals. */\n"
+"static const %sQtSignal signals_%C[] = {\n"
+                        , pyqt_prefix, classFQCName(cd));
                 }
 
                 /*
@@ -9700,10 +9704,16 @@
         }
 
         if (is_signals)
-            prcode(fp,
+            if (pluginPyQt5(pt))
+                prcode(fp,
+"    {0, 0, 0, 0}\n"
+"};\n"
+                    );
+            else
+                prcode(fp,
 "    {0, 0, 0}\n"
 "};\n"
-                );
+                    );
     }
 
     /* Generate the property and variable handlers. */
@@ -9829,7 +9839,12 @@
         has_docstring = TRUE;
     }
 
-    if (pluginPyQt4(pt) || pluginPyQt5(pt))
+    if (pluginPyQt5(pt))
+    {
+        type_prefix = "pyqt5";
+        embedded = TRUE;
+    }
+    else if (pluginPyQt4(pt))
     {
         type_prefix = "pyqt4";
         embedded = TRUE;
@@ -10286,7 +10301,7 @@
 
     if (pluginPyQt4(pt) || pluginPyQt5(pt))
     {
-        if (isQObjectSubClass(cd) && !noPyQt4QMetaObject(cd))
+        if (isQObjectSubClass(cd) && !noPyQtQMetaObject(cd))
             prcode(fp,
 "    &%U::staticMetaObject,\n"
                 , cd);
@@ -10297,25 +10312,39 @@
 
         prcode(fp,
 "    %u,\n"
-            , cd->pyqt4_flags);
-
-        if (is_signals)
-            prcode(fp,
-"    pyqt4_signals_%C,\n"
-                , classFQCName(cd));
-        else
-            prcode(fp,
+            , cd->pyqt_flags);
+
+        if (pluginPyQt5(pt))
+        {
+            if (is_signals)
+                prcode(fp,
+"    signals_%C,\n"
+                    , classFQCName(cd));
+            else
+                prcode(fp,
 "    0,\n"
-                );
-
-        if (cd->pyqt_interface != NULL)
-            prcode(fp,
+                    );
+
+            if (cd->pyqt_interface != NULL)
+                prcode(fp,
 "    \"%s\"\n"
-                , cd->pyqt_interface);
-        else
-            prcode(fp,
+                    , cd->pyqt_interface);
+            else
+                prcode(fp,
 "    0\n"
-                );
+                    );
+        }
+        else
+        {
+            if (is_signals)
+                prcode(fp,
+"    signals_%C,\n"
+                    , classFQCName(cd));
+            else
+                prcode(fp,
+"    0\n"
+                    );
+        }
     }
 
     prcode(fp,
@@ -10382,6 +10411,9 @@
     else
         prcode(fp, "0");
 
+    if (pluginPyQt5(pt))
+        prcode(fp, ", 0");
+
     prcode(fp,"},\n"
         );
 }
diff -r d45411f2a001 -r b96a5e69adb6 sipgen/metasrc/parser.y
--- a/sipgen/metasrc/parser.y	Sun Feb 09 12:02:34 2014 +0000
+++ b/sipgen/metasrc/parser.y	Tue Feb 18 13:54:02 2014 +0000
@@ -2769,9 +2769,9 @@
                     "Mixin",
                     "NoDefaultCtors",
                     "PyName",
-                    "PyQt4Flags",
-                    "PyQt4NoQMetaObject",
+                    "PyQtFlags",
                     "PyQtInterface",
+                    "PyQtNoQMetaObject",
                     "Supertype",
                     "VirtualErrorHandler",
                     NULL
@@ -2843,9 +2843,9 @@
                     "Mixin",
                     "NoDefaultCtors",
                     "PyName",
-                    "PyQt4Flags",
-                    "PyQt4NoQMetaObject",
+                    "PyQtFlags",
                     "PyQtInterface",
+                    "PyQtNoQMetaObject",
                     "Supertype",
                     "VirtualErrorHandler",
                     NULL
@@ -4912,11 +4912,11 @@
     if (getOptFlag(of, "Mixin", bool_flag) != NULL)
         setMixin(cd);
 
-    if ((flg = getOptFlag(of, "PyQt4Flags", integer_flag)) != NULL)
-        cd->pyqt4_flags = flg->fvalue.ival;
-
-    if (getOptFlag(of, "PyQt4NoQMetaObject", bool_flag) != NULL)
-        setPyQt4NoQMetaObject(cd);
+    if ((flg = getOptFlag(of, "PyQtFlags", integer_flag)) != NULL)
+        cd->pyqt_flags = flg->fvalue.ival;
+
+    if (getOptFlag(of, "PyQtNoQMetaObject", bool_flag) != NULL)
+        setPyQtNoQMetaObject(cd);
 
     if ((flg = getOptFlag(of, "PyQtInterface", string_flag)) != NULL)
         cd->pyqt_interface = flg->fvalue.sval;
diff -r d45411f2a001 -r b96a5e69adb6 sipgen/sip.h.in
--- a/sipgen/sip.h	Sun Feb 09 12:02:34 2014 +0000
+++ b/sipgen/sip.h	Tue Feb 18 13:54:02 2014 +0000
@@ -159,8 +159,8 @@
 #define setIsHoldGILDtor(cd) ((cd)->classflags |= CLASS_DTOR_HOLD_GIL)
 #define assignmentHelper(cd) ((cd)->classflags & CLASS_ASSIGN_HELPER)
 #define setAssignmentHelper(cd) ((cd)->classflags |= CLASS_ASSIGN_HELPER)
-#define noPyQt4QMetaObject(cd)  ((cd)->classflags & CLASS_NO_QMETAOBJECT)
-#define setPyQt4NoQMetaObject(cd)   ((cd)->classflags |= CLASS_NO_QMETAOBJECT)
+#define noPyQtQMetaObject(cd)   ((cd)->classflags & CLASS_NO_QMETAOBJECT)
+#define setPyQtNoQMetaObject(cd)    ((cd)->classflags |= CLASS_NO_QMETAOBJECT)
 #define isTemplateClass(cd) ((cd)->classflags & CLASS_IS_TEMPLATE)
 #define setIsTemplateClass(cd)  ((cd)->classflags |= CLASS_IS_TEMPLATE)
 #define resetIsTemplateClass(cd)    ((cd)->classflags &= ~CLASS_IS_TEMPLATE)
@@ -1118,7 +1118,7 @@
 typedef struct _classDef {
     unsigned classflags;                /* The class flags. */
     unsigned classflags2;               /* The class flags, part 2. */
-    int pyqt4_flags;                    /* The PyQt4 specific flags. */
+    int pyqt_flags;                     /* The PyQt specific flags. */
     const char *pyqt_interface;         /* The Qt interface name. */
     nameDef *pyname;                    /* The Python name. */
     ifaceFileDef *iff;                  /* The interface file. */
diff -r d45411f2a001 -r b96a5e69adb6 siplib/sip.h.in.in
--- a/siplib/sip.h.in	Sun Feb 09 12:02:34 2014 +0000
+++ b/siplib/sip.h.in	Tue Feb 18 13:54:02 2014 +0000
@@ -70,6 +70,9 @@
  *
  * 11.2 Added sip_api_get_reference() to the private API.
  *
+ * 11.0 Added the pyqt5QtSignal and pyqt5ClassTypeDef structures.
+ *      Removed qt_interface from pyqt4ClassTypeDef.
+ *
  * 10.1 Added ctd_final to sipClassTypeDef.
  *      Added ctd_init_mixin to sipClassTypeDef.
  *      Added sip_api_get_mixin_address() to the public API.
@@ -1666,12 +1669,12 @@
  * out to a plugin supplied by PyQt3.
  */
 
-typedef int (*pyqt3EmitFunc)(sipSimpleWrapper *, PyObject *);
-
 
 /*
  * Maps the name of a Qt signal to a wrapper function to emit it.
  */
+typedef int (*pyqt3EmitFunc)(sipSimpleWrapper *, PyObject *);
+
 typedef struct _pyqt3QtSignal {
     /* The signal name. */
     const char *st_name;
@@ -1697,12 +1700,12 @@
 
 
 /*
- * The following are PyQt-specific extensions.  In SIP v5 they will be pushed
- * out to a plugin supplied by PyQt.
+ * The following are PyQt4-specific extensions.  In SIP v5 they will be pushed
+ * out to a plugin supplied by PyQt4.
  */
 
 /*
- * The description of a Qt signal for PyQt.
+ * The description of a Qt signal for PyQt4.
  */
 typedef struct _pyqt4QtSignal {
     /* The C++ name and signature of the signal. */
@@ -1720,7 +1723,7 @@
 
 
 /*
- * This is the PyQt-specific extension to the generated class type structure.
+ * This is the PyQt4-specific extension to the generated class type structure.
  */
 typedef struct _pyqt4ClassTypeDef {
     /*
@@ -1730,23 +1733,84 @@
     sipClassTypeDef super;
 
     /* A pointer to the QObject sub-class's staticMetaObject class variable. */
-    const void *qt4_static_metaobject;
+    const void *static_metaobject;
 
     /*
      * A set of flags.  At the moment only bit 0 is used to say if the type is
      * derived from QFlags.
      */
-    unsigned qt4_flags;
+    unsigned flags;
 
     /*
      * The table of signals emitted by the type.  These are grouped by signal
      * name.
      */
-    const pyqt4QtSignal *qt4_signals;
+    const pyqt4QtSignal *qt_signals;
+} pyqt4ClassTypeDef;
+
+
+/*
+ * The following are PyQt5-specific extensions.  In SIP v5 they will be pushed
+ * out to a plugin supplied by PyQt5.
+ */
+
+/*
+ * The description of a Qt signal for PyQt5.
+ */
+typedef PyObject *(*pyqt5EmitFunc)(sipSimpleWrapper *, PyObject *);
+
+typedef struct _pyqt5QtSignal {
+    /*
+     * The normalised C++ name and signature of the signal that would be
+     * returned by SIGNAL().
+     */
+    const char *signature;
+
+    /* The optional docstring. */
+    const char *docstring;
+
+    /*
+     * If the signal is an overload of regular methods then this points to the
+     * code that implements those methods.
+     */
+    PyMethodDef *non_signals;
+
+    /*
+     * If the signal has optional arguments then this function will implement
+     * emit() for the signal.
+     */
+    pyqt5EmitFunc emitter;
+} pyqt5QtSignal;
+
+
+/*
+ * This is the PyQt5-specific extension to the generated class type structure.
+ */
+typedef struct _pyqt5ClassTypeDef {
+    /*
+     * The super-type structure.  This must be first in the structure so that
+     * it can be cast to sipClassTypeDef *.
+     */
+    sipClassTypeDef super;
+
+    /* A pointer to the QObject sub-class's staticMetaObject class variable. */
+    const void *static_metaobject;
+
+    /*
+     * A set of flags.  At the moment only bit 0 is used to say if the type is
+     * derived from QFlags.
+     */
+    unsigned flags;
+
+    /*
+     * The table of signals emitted by the type.  These are grouped by signal
+     * name.
+     */
+    const pyqt5QtSignal *qt_signals;
 
     /* The name of the interface that the class defines. */
     const char *qt_interface;
-} pyqt4ClassTypeDef;
+} pyqt5ClassTypeDef;
 
 
 #ifdef __cplusplus
diff -r d45411f2a001 -r b96a5e69adb6 siplib/siplib.c.in
--- a/siplib/siplib.c.in	Sun Feb 09 12:02:34 2014 +0000
+++ b/siplib/siplib.c.in	Tue Feb 18 13:54:02 2014 +0000
@@ -796,7 +796,7 @@
      * Remind ourselves to add support for capsule variables when we have
      * another reason to move to the next major version number.
      */
-#if SIP_API_MAJOR_NR > 10
+#if SIP_API_MAJOR_NR > 11
 #error "Add support for capsule variables"
 #endif
 
@@ -9664,10 +9664,7 @@
         return 0;
 
     /* Call any finalisation code. */
-#if SIP_API_MAJOR_NR != 10
-#error Remove test for v10.1
-#endif
-    if (td->td_module->em_api_minor >= 1 && (final_func = find_finalisation(ctd)) != NULL)
+    if ((final_func = find_finalisation(ctd)) != NULL)
     {
         PyObject *new_unused = NULL, **new_unused_p;
 

openSUSE Build Service is sponsored by