[PyQt] [PATCH v2 2/6] Use SIP_NULLPTR for null pointer constants

Stefan Brüns stefan.bruens at rwth-aachen.de
Mon Oct 1 02:58:45 BST 2018


Current versions of GCC and LLVM issue a warning "zero as null pointer
constant [-Wzero-as-null-pointer-constant]" if 0 is used.

Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
---
 sipgen/gencode.c | 212 +++++++++++++++++++++++------------------------
 1 file changed, 106 insertions(+), 106 deletions(-)

diff --git a/sipgen/gencode.c b/sipgen/gencode.c
index 98a84b5..2ce4b22 100644
--- a/sipgen/gencode.c
+++ b/sipgen/gencode.c
@@ -1203,8 +1203,8 @@ static void generateCompositeCpp(sipSpec *pt, const char *codeDir,
     prcode(fp,
 "#endif\n"
 "\n"
-"    if (sipModule == NULL)\n"
-"        SIP_MODULE_RETURN(NULL);\n"
+"    if (sipModule == SIP_NULLPTR)\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "\n"
 "    sipModuleDict = PyModule_GetDict(sipModule);\n"
 "\n"
@@ -1344,8 +1344,8 @@ static void generateConsolidatedCpp(sipSpec *pt, const char *codeDir,
 
     prcode(fp,
 "    static PyMethodDef sip_methods[] = {\n"
-"        {SIP_MLNAME_CAST(\"init\"), sip_init, METH_O, NULL},\n"
-"        {NULL, NULL, 0, NULL}\n"
+"        {SIP_MLNAME_CAST(\"init\"), sip_init, METH_O, SIP_NULLPTR},\n"
+"        {SIP_NULLPTR, SIP_NULLPTR, 0, SIP_NULLPTR}\n"
 "    };\n"
         );
 
@@ -1428,7 +1428,7 @@ static void generateComponentCpp(sipSpec *pt, const char *codeDir,
 "\n"
 "    /* Import the consolidated module. */\n"
 "    if ((sip_mod = PyImport_ImportModule(\"%s\")) == NULL)\n"
-"        SIP_MODULE_RETURN(NULL);\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "\n"
         , consModule);
 
@@ -1917,7 +1917,7 @@ static void generateCpp(sipSpec *pt, moduleDef *mod, const char *codeDir,
         if (ed->slots != NULL)
             prcode(fp, "slots_%C", ed->fqcname);
         else
-            prcode(fp, "NULL");
+            prcode(fp, "SIP_NULLPTR");
 
         prcode(fp, "},\n"
             );
@@ -2498,7 +2498,7 @@ static void generateCpp(sipSpec *pt, moduleDef *mod, const char *codeDir,
             generateGlobalFunctionTableEntries(pt, mod, cd->members, fp);
 
     prcode(fp,
-"        {0, 0, 0, 0}\n"
+"        {SIP_NULLPTR, SIP_NULLPTR, 0, SIP_NULLPTR}\n"
 "    };\n"
         );
 
@@ -2560,8 +2560,8 @@ static void generateCpp(sipSpec *pt, moduleDef *mod, const char *codeDir,
     prcode(fp,
 "#endif\n"
 "\n"
-"    if (sipModule == NULL)\n"
-"        SIP_MODULE_RETURN(NULL);\n"
+"    if (sipModule == SIP_NULLPTR)\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "\n"
 "    sipModuleDict = PyModule_GetDict(sipModule);\n"
 "\n"
@@ -2577,7 +2577,7 @@ static void generateCpp(sipSpec *pt, moduleDef *mod, const char *codeDir,
 "    if (sipExportModule(&sipModuleAPI_%s,SIP_API_MAJOR_NR,SIP_API_MINOR_NR,0) < 0)\n"
 "    {\n"
 "        SIP_MODULE_DISCARD(sipModule);\n"
-"        SIP_MODULE_RETURN(0);\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "    }\n"
         , mname);
 
@@ -2604,7 +2604,7 @@ static void generateCpp(sipSpec *pt, moduleDef *mod, const char *codeDir,
 "    if (sipInitModule(&sipModuleAPI_%s,sipModuleDict) < 0)\n"
 "    {\n"
 "        SIP_MODULE_DISCARD(sipModule);\n"
-"        SIP_MODULE_RETURN(0);\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "    }\n"
         , mname);
 
@@ -2642,7 +2642,7 @@ static void generateCpp(sipSpec *pt, moduleDef *mod, const char *codeDir,
         prcode(fp, ",NULL)) == NULL || PyDict_SetItemString(sipModuleDict, \"%s\", sipExportedExceptions_%s[%d]) < 0)\n"
 "    {\n"
 "        SIP_MODULE_DISCARD(sipModule);\n"
-"        SIP_MODULE_RETURN(0);\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "    }\n"
             , xd->pyname, xd->iff->module->name, xd->exceptionnr);
     }
@@ -2803,7 +2803,7 @@ static void generateSipImport(moduleDef *mod, const char *sipName, FILE *fp)
 "    if (sip_sipmod == NULL)\n"
 "    {\n"
 "        SIP_MODULE_DISCARD(sipModule);\n"
-"        SIP_MODULE_RETURN(NULL);\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "    }\n"
 "\n"
 "    sip_capiobj = PyDict_GetItemString(PyModule_GetDict(sip_sipmod), \"_C_API\");\n"
@@ -2816,7 +2816,7 @@ static void generateSipImport(moduleDef *mod, const char *sipName, FILE *fp)
 "#endif\n"
 "    {\n"
 "        SIP_MODULE_DISCARD(sipModule);\n"
-"        SIP_MODULE_RETURN(NULL);\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "    }\n"
 "\n"
         );
@@ -2846,7 +2846,7 @@ static void generateSipImport(moduleDef *mod, const char *sipName, FILE *fp)
 "    if (sipAPI_%s == NULL)\n"
 "    {\n"
 "        SIP_MODULE_DISCARD(sipModule);\n"
-"        SIP_MODULE_RETURN(NULL);\n"
+"        SIP_MODULE_RETURN(SIP_NULLPTR);\n"
 "    }\n"
 "#endif\n"
 "\n"
@@ -3149,7 +3149,7 @@ static void generateOrdinaryFunction(sipSpec *pt, moduleDef *mod,
             if (need_intro)
             {
                 prcode(fp,
-"    PyObject *sipParseErr = NULL;\n"
+"    PyObject *sipParseErr = SIP_NULLPTR;\n"
                     );
 
                 need_intro = FALSE;
@@ -3177,12 +3177,12 @@ static void generateOrdinaryFunction(sipSpec *pt, moduleDef *mod,
         }
         else
         {
-            prcode(fp, "NULL");
+            prcode(fp, "SIP_NULLPTR");
         }
 
         prcode(fp, ");\n"
 "\n"
-"    return NULL;\n"
+"    return SIP_NULLPTR;\n"
             );
     }
 
@@ -4504,7 +4504,7 @@ static void generateTypeDefLink(ifaceFileDef *iff, FILE *fp)
             prcode(fp, ".ctd_base");
     }
     else
-        prcode(fp, "0");
+        prcode(fp, "SIP_NULLPTR");
 }
 
 
@@ -4797,7 +4797,7 @@ static void prMethodTable(sipSpec *pt, sortedMethTab *mtable, int nr,
         if (hasMemberDocstring(pt, overs, md, iff))
             prcode(fp, "SIP_MLDOC_CAST(doc_%L_%s)", iff, md->pyname->text);
         else
-            prcode(fp, "NULL");
+            prcode(fp, "SIP_NULLPTR");
 
         prcode(fp, "}%s\n"
             , ((i + 1) < nr) ? "," : "");
@@ -4941,7 +4941,7 @@ static void generateVariableGetter(ifaceFileDef *scope, varDef *vd, FILE *fp)
     {
         if (isStaticVar(vd))
             prcode(fp,
-"    static PyObject *sipPy = NULL;\n"
+"    static PyObject *sipPy = SIP_NULLPTR;\n"
                 );
         else
             prcode(fp,
@@ -5498,7 +5498,7 @@ static void generateVariableSetter(ifaceFileDef *scope, varDef *vd, FILE *fp)
         {
             prcode(fp,
 "\n"
-"    static PyObject *sipKeep = 0;\n"
+"    static PyObject *sipKeep = SIP_NULLPTR;\n"
 "\n"
 "    Py_XDECREF(sipKeep);\n"
 "    sipKeep = sipPy;\n"
@@ -6085,7 +6085,7 @@ static void generateSlot(moduleDef *mod, classDef *cd, enumDef *ed,
 
         if (has_args)
             prcode(fp,
-"    PyObject *sipParseErr = NULL;\n"
+"    PyObject *sipParseErr = SIP_NULLPTR;\n"
                 );
 
         for (od = overs; od != NULL; od = od->next)
@@ -6134,7 +6134,7 @@ static void generateSlot(moduleDef *mod, classDef *cd, enumDef *ed,
 "    Py_XDECREF(sipParseErr);\n"
 "\n"
 "    if (sipParseErr == Py_None)\n"
-"        return NULL;\n"
+"        return SIP_NULLPTR;\n"
                         );
                 }
 
@@ -6150,7 +6150,7 @@ static void generateSlot(moduleDef *mod, classDef *cd, enumDef *ed,
                     else if (isNumberSlot(md))
                         prcode(fp,
 "\n"
-"    return sipPySlotExtend(&sipModuleAPI_%s, %s, NULL, sipArg0, sipArg1);\n"
+"    return sipPySlotExtend(&sipModuleAPI_%s, %s, SIP_NULLPTR, sipArg0, sipArg1);\n"
                             , mod->name, slotName(md->slot));
                     else
                         prcode(fp,
@@ -7049,7 +7049,7 @@ static void generateShadowCode(sipSpec *pt, moduleDef *mod, classDef *cd,
 
         generateProtectedCallArgs(mod, ct->cppsig, fp);
 
-        prcode(fp,"), sipPySelf(0)\n"
+        prcode(fp,"), sipPySelf(SIP_NULLPTR)\n"
 "{\n"
             );
 
@@ -7306,7 +7306,7 @@ static void generateVirtualCatcher(moduleDef *mod, classDef *cd, int virtNr,
     if (isAbstract(od))
         prcode(fp, "%N", cd->pyname);
     else
-        prcode(fp,"NULL");
+        prcode(fp,"SIP_NULLPTR");
 
     prcode(fp,",%N);\n"
 "\n"
@@ -7655,7 +7655,7 @@ static void generateDefaultInstanceReturn(argDef *res, const char *indent,
 
         prcode(fp,
 "%s{\n"
-"%s    static %B *sipCpp = 0;\n"
+"%s    static %B *sipCpp = SIP_NULLPTR;\n"
 "\n"
 "%s    if (!sipCpp)\n"
 "%s    {\n"
@@ -8143,7 +8143,7 @@ static void generateVirtualHandler(moduleDef *mod, virtHandlerDef *vhd,
 "    {\n"
 "        // Return any previous result to the heap.\n"
 "        sipFree(%s);\n"
-"        sipRes = 0;\n"
+"        sipRes = SIP_NULLPTR;\n"
 "    }\n"
 "\n"
                 , (isConstArg(res) ? "const_cast<wchar_t *>(sipRes)" : "sipRes"));
@@ -8212,7 +8212,7 @@ static void generateVirtualHandler(moduleDef *mod, virtHandlerDef *vhd,
 "    sipCallProcedureMethod(sipGILState, sipErrorHandler, sipPySelf, sipMethod, ");
     else
         prcode(fp,
-"    PyObject *sipResObj = sipCallMethod(0, sipMethod, ");
+"    PyObject *sipResObj = sipCallMethod(SIP_NULLPTR, sipMethod, ");
 
     saved = *vhd->pysig;
     fakeProtectedArgs(vhd->pysig);
@@ -10048,15 +10048,15 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
         if (pd->set != NULL)
             prcode(fp, "&methods_%L[%d], ", cd->iff, findMethod(cd, pd->set)->membernr);
         else
-            prcode(fp, "NULL, ");
+            prcode(fp, "SIP_NULLPTR, ");
 
         /* We don't support a deleter yet. */
-        prcode(fp, "NULL, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
         if (pd->docstring != NULL)
             prcode(fp, "doc_%L_%s", cd->iff, pd->name->text);
         else
-            prcode(fp, "NULL");
+            prcode(fp, "SIP_NULLPTR");
 
         prcode(fp, "},\n"
             );
@@ -10075,9 +10075,9 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
                 if (canSetVariable(vd))
                     prcode(fp, "(PyMethodDef *)varset_%C", vd->fqcname);
                 else
-                    prcode(fp, "NULL");
+                    prcode(fp, "SIP_NULLPTR");
 
-                prcode(fp, ", NULL, NULL},\n"
+                prcode(fp, ", 0, SIP_NULLPTR},\n"
                     );
             }
     }
@@ -10142,7 +10142,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
     generateTypeDefLink(cd->iff, fp);
 
     prcode(fp, ",\n"
-"        0,\n"
+"        SIP_NULLPTR,\n"
 "        ");
 
     sep = "";
@@ -10201,7 +10201,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
 
     prcode(fp,
 "        %n,\n"
-"        {0},\n"
+"        {SIP_NULLPTR},\n"
         , cd->iff->name);
 
     if (plugin)
@@ -10210,7 +10210,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , cd->iff);
     else
         prcode(fp,
-"        0\n"
+"        SIP_NULLPTR\n"
             );
 
     prcode(fp,
@@ -10241,7 +10241,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
 
     if (nr_methods == 0)
         prcode(fp,
-"        0, 0,\n"
+"        0, SIP_NULLPTR,\n"
             );
     else
         prcode(fp,
@@ -10250,7 +10250,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
 
     if (nr_enums == 0)
         prcode(fp,
-"        0, 0,\n"
+"        0, SIP_NULLPTR,\n"
             );
     else
         prcode(fp,
@@ -10259,7 +10259,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
 
     if (nr_vars == 0)
         prcode(fp,
-"        0, 0,\n"
+"        0, SIP_NULLPTR,\n"
             );
     else
         prcode(fp,
@@ -10272,52 +10272,52 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
     if (is_inst_class)
         prcode(fp, "typeInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (is_inst_voidp)
         prcode(fp, "voidPtrInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (is_inst_char)
         prcode(fp, "charInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (is_inst_string)
         prcode(fp, "stringInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (is_inst_int)
         prcode(fp, "intInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (is_inst_long)
         prcode(fp, "longInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (is_inst_ulong)
         prcode(fp, "unsignedLongInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (is_inst_longlong)
         prcode(fp, "longLongInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp,"0, ");
+        prcode(fp,"SIP_NULLPTR, ");
 
     if (is_inst_ulonglong)
         prcode(fp, "unsignedLongLongInstances_%C, ", classFQCName(cd));
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (is_inst_double)
         prcode(fp, "doubleInstances_%C", classFQCName(cd));
     else
-        prcode(fp, "0");
+        prcode(fp, "SIP_NULLPTR");
 
     prcode(fp,"},\n"
 "    },\n"
@@ -10329,7 +10329,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , cd->iff);
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->metatype != NULL)
@@ -10356,7 +10356,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (is_slots)
@@ -10365,7 +10365,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , cd->iff);
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (canCreate(cd))
@@ -10374,7 +10374,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , cd->iff);
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->travcode != NULL)
@@ -10383,7 +10383,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->clearcode != NULL)
@@ -10392,7 +10392,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     prcode(fp,
@@ -10405,7 +10405,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->releasebufcode != NULL)
@@ -10414,7 +10414,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     prcode(fp,
@@ -10427,7 +10427,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->writebufcode != NULL)
@@ -10436,7 +10436,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->segcountcode != NULL)
@@ -10445,7 +10445,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->charbufcode != NULL)
@@ -10454,7 +10454,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     prcode(fp,
@@ -10467,7 +10467,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , cd->iff);
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (generating_c || assignmentHelper(cd))
@@ -10480,14 +10480,14 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , cd->iff);
     else
         prcode(fp,
-"    0,\n"
-"    0,\n"
-"    0,\n"
+"    SIP_NULLPTR,\n"
+"    SIP_NULLPTR,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->iff->type == namespace_iface || generating_c)
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
     else
         prcode(fp,
@@ -10500,13 +10500,13 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , cd->iff);
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->iff->type == namespace_iface)
     {
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
     }
     else
@@ -10517,14 +10517,14 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
                 , cd->iff);
         else
             prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
                 );
     }
 
     if (cd->iff->type == namespace_iface)
     {
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
     }
     else
@@ -10535,12 +10535,12 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
                 , cd->iff);
         else
             prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
                 );
     }
 
     prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
         );
 
     if (cd->picklecode != NULL)
@@ -10549,7 +10549,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->finalcode != NULL)
@@ -10558,7 +10558,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (isMixin(cd))
@@ -10567,7 +10567,7 @@ static void generateTypeDefinition(sipSpec *pt, classDef *cd, int py_debug,
             , classFQCName(cd));
     else
         prcode(fp,
-"    0\n"
+"    SIP_NULLPTR\n"
             );
 
     prcode(fp,
@@ -10621,7 +10621,7 @@ static void generatePyQt5Emitters(classDef *cd, FILE *fp)
                 prcode(fp,
 "static int emit_%L_%s(void *sipCppV, PyObject *sipArgs)\n"
 "{\n"
-"    PyObject *sipParseErr = NULL;\n"
+"    PyObject *sipParseErr = SIP_NULLPTR;\n"
 "    %V *sipCpp = reinterpret_cast<%V *>(sipCppV);\n"
                     , cd->iff, od->cppname
                     , classFQCName(cd), classFQCName(cd));
@@ -10665,7 +10665,7 @@ static void generatePyQt5Emitters(classDef *cd, FILE *fp)
         {
             prcode(fp,
 "\n"
-"    sipNoMethod(sipParseErr, %N, %N, NULL);\n"
+"    sipNoMethod(sipParseErr, %N, %N, SIP_NULLPTR);\n"
 "\n"
 "    return -1;\n"
 "}\n"
@@ -10766,20 +10766,20 @@ static void generateSignalTableEntry(sipSpec *pt, classDef *cd, overDef *sig,
     }
     else
     {
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
     }
 
     if (membernr >= 0)
         prcode(fp, "&methods_%L[%d], ", cd->iff, membernr);
     else
-        prcode(fp, "0, ");
+        prcode(fp, "SIP_NULLPTR, ");
 
     if (pyqt5)
     {
         if (optional_args)
             prcode(fp, "emit_%L_%s", cd->iff, sig->cppname);
         else
-            prcode(fp, "0");
+            prcode(fp, "SIP_NULLPTR");
     }
     else
     {
@@ -11146,11 +11146,11 @@ static void generateTypeInit(classDef *cd, moduleDef *mod, FILE *fp)
 
     if (hasShadow(cd))
         prcode(fp,
-"    sip%C *sipCpp = 0;\n"
+"    sip%C *sipCpp = SIP_NULLPTR;\n"
             ,classFQCName(cd));
     else
         prcode(fp,
-"    %U *sipCpp = 0;\n"
+"    %U *sipCpp = SIP_NULLPTR;\n"
             ,cd);
 
     if (tracing)
@@ -11228,7 +11228,7 @@ static void generateTypeInit(classDef *cd, moduleDef *mod, FILE *fp)
 
     prcode(fp,
 "\n"
-"    return NULL;\n"
+"    return SIP_NULLPTR;\n"
 "}\n"
         );
 }
@@ -11313,7 +11313,7 @@ static void generateCatch(throwArgs *ta, signatureDef *sd, moduleDef *mod,
 
         prcode(fp,
 "                sipRaiseUnknownException();\n"
-"                return NULL;\n"
+"                return SIP_NULLPTR;\n"
 "            }\n"
             );
     }
@@ -11356,7 +11356,7 @@ static void generateCatchBlock(moduleDef *mod, exceptionDef *xd,
 
     prcode(fp,
 "\n"
-"                return NULL;\n"
+"                return SIP_NULLPTR;\n"
 "            }\n"
         );
 }
@@ -11526,7 +11526,7 @@ static void generateConstructorCall(classDef *cd, ctorDef *ct, int error_flag,
 "            if (PyErr_Occurred())\n"
 "            {\n"
 "                delete sipCpp;\n"
-"                return NULL;\n"
+"                return SIP_NULLPTR;\n"
 "            }\n"
 "\n"
                 );
@@ -11575,7 +11575,7 @@ static void generateConstructorCall(classDef *cd, ctorDef *ct, int error_flag,
 "            sipAddException(sipError, sipParseErr);\n"
 "\n"
 "            if (sipError == sipErrorFail)\n"
-"                return NULL;\n"
+"                return SIP_NULLPTR;\n"
             );
     }
     else
@@ -11591,7 +11591,7 @@ static void generateConstructorCall(classDef *cd, ctorDef *ct, int error_flag,
 "                }\n"
 "\n"
 "                sipAddException(sipErrorFail, sipParseErr);\n"
-"                return NULL;\n"
+"                return SIP_NULLPTR;\n"
 "            }\n"
 "\n"
                 );
@@ -11742,7 +11742,7 @@ static void generateFunction(sipSpec *pt, memberDef *md, overDef *overs,
         {
             if (need_args)
                 prcode(fp,
-"    PyObject *sipParseErr = NULL;\n"
+"    PyObject *sipParseErr = SIP_NULLPTR;\n"
                     );
 
             if (need_selfarg)
@@ -11807,16 +11807,16 @@ static void generateFunction(sipSpec *pt, memberDef *md, overDef *overs,
             prcode(fp,
 "\n"
 "    /* Raise an exception if the arguments couldn't be parsed. */\n"
-"    sipNoMethod(%s, %N, %N, ", (need_args ? "sipParseErr" : "NULL"), cd->pyname, md->pyname);
+"    sipNoMethod(%s, %N, %N, ", (need_args ? "sipParseErr" : "SIP_NULLPTR"), cd->pyname, md->pyname);
 
             if (has_auto_docstring)
                 prcode(fp, "doc_%L_%s", cd->iff, pname);
             else
-                prcode(fp, "NULL");
+                prcode(fp, "SIP_NULLPTR");
 
             prcode(fp, ");\n"
 "\n"
-"    return NULL;\n"
+"    return SIP_NULLPTR;\n"
                 );
         }
 
@@ -12016,7 +12016,7 @@ static void generateHandleResult(moduleDef *mod, overDef *od, int isNew,
                     prcode(fp,"sipRes");
 
                 prcode(fp, ",sipType_%C,%s);\n"
-                    , iff->fqcname, (need_xfer ? "NULL" : resultOwner(od)));
+                    , iff->fqcname, (need_xfer ? "SIP_NULLPTR" : resultOwner(od)));
 
                 /*
                  * Transferring the result of a static overload needs an
@@ -12145,7 +12145,7 @@ static void generateHandleResult(moduleDef *mod, overDef *od, int isNew,
             prcode(fp, ",sipType_%C,", iff->fqcname);
 
             if (needNew || !isTransferredBack(ad))
-                prcode(fp, "NULL);\n");
+                prcode(fp, "SIP_NULLPTR);\n");
             else
                 prcode(fp, "Py_None);\n");
         }
@@ -12428,7 +12428,7 @@ static const char *resultOwner(overDef *od)
     if (isResultTransferred(od))
         return "sipSelf";
 
-    return "NULL";
+    return "SIP_NULLPTR";
 }
 
 
@@ -13436,7 +13436,7 @@ static int generateArgParser(moduleDef *mod, signatureDef *sd,
 
     if (od != NULL && need_owner)
         prcode(fp,
-"        sipWrapper *sipOwner = 0;\n"
+"        sipWrapper *sipOwner = SIP_NULLPTR;\n"
             );
 
     if (handle_self)
@@ -13544,7 +13544,7 @@ static int generateArgParser(moduleDef *mod, signatureDef *sd,
         }
 
         prcode(fp,
-"        if (sipParseKwdArgs(%ssipParseErr, sipArgs, sipKwds, %s, %s, \"", (ct != NULL ? "" : "&"), (is_ka_list ? "sipKwdList" : "NULL"), (ct != NULL ? "sipUnused" : "NULL"));
+"        if (sipParseKwdArgs(%ssipParseErr, sipArgs, sipKwds, %s, %s, \"", (ct != NULL ? "" : "&"), (is_ka_list ? "sipKwdList" : "SIP_NULLPTR"), (ct != NULL ? "sipUnused" : "SIP_NULLPTR"));
     }
     else
     {
@@ -15595,7 +15595,7 @@ static int generatePluginSignalsTable(sipSpec *pt, classDef *cd,
 
         if (is_signals)
             prcode(fp,
-"    {0, 0, 0, 0}\n"
+"    {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR}\n"
 "};\n"
                 );
     }
@@ -15624,7 +15624,7 @@ static int generatePyQt5ClassPlugin(sipSpec *pt, classDef *cd, FILE *fp)
             , cd);
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     prcode(fp,
@@ -15637,7 +15637,7 @@ static int generatePyQt5ClassPlugin(sipSpec *pt, classDef *cd, FILE *fp)
             , classFQCName(cd));
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     if (cd->pyqt_interface != NULL)
@@ -15646,7 +15646,7 @@ static int generatePyQt5ClassPlugin(sipSpec *pt, classDef *cd, FILE *fp)
             , cd->pyqt_interface);
     else
         prcode(fp,
-"    0\n"
+"    SIP_NULLPTR\n"
             );
 
     prcode(fp,
@@ -15677,7 +15677,7 @@ static int generatePyQt4ClassPlugin(sipSpec *pt, classDef *cd, FILE *fp)
             , cd);
     else
         prcode(fp,
-"    0,\n"
+"    SIP_NULLPTR,\n"
             );
 
     prcode(fp,
@@ -15690,7 +15690,7 @@ static int generatePyQt4ClassPlugin(sipSpec *pt, classDef *cd, FILE *fp)
             , classFQCName(cd));
         else
         prcode(fp,
-"    0\n"
+"    SIP_NULLPTR\n"
             );
 
     prcode(fp,
@@ -15725,7 +15725,7 @@ static void generateGlobalFunctionTableEntries(sipSpec *pt, moduleDef *mod,
                 prcode(fp, ", SIP_MLDOC_CAST(doc_%s)},\n"
                     , md->pyname->text);
             else
-                prcode(fp, ", NULL},\n"
+                prcode(fp, ", SIP_NULLPTR},\n"
                     );
         }
     }
-- 
2.19.0



More information about the PyQt mailing list