[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#134020: Patch to build python-apt with g++-3.0



apt folk: does this look reasonable to you?  I had to get rid of those funky
array declarations by shuffling things around, make two minor namespace
tweaks, and use string::c_str() instead of string::begin().  Works for me.

This is necessary to get python-apt building on hppa, so I would like to
commit a fix soon.

-- 
 - mdz
? build
Index: python/cache.cc
===================================================================
RCS file: /cvs/deity/python-apt/python/cache.cc,v
retrieving revision 1.2
diff -u -r1.2 cache.cc
--- python/cache.cc	2002/01/08 06:53:04	1.2
+++ python/cache.cc	2002/02/24 05:19:22
@@ -533,39 +533,6 @@
    0,                                   // tp_hash
 };
    
-									/*}}}*/
-// Dependency Class							/*{{{*/
-// ---------------------------------------------------------------------
-static PyMethodDef DependencyMethods[];
-   
-static PyObject *DependencyAttr(PyObject *Self,char *Name)
-{
-   pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self);
-   PyObject *Owner = GetOwner<pkgCache::DepIterator>(Self);
-   
-   if (strcmp("TargetVer",Name) == 0)
-   {
-      if (Dep->Version == 0)
-	 return PyString_FromString("");
-      return PyString_FromString(Dep.TargetVer());
-   }   
-   else if (strcmp("TargetPkg",Name) == 0)
-      return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType,
-							 Dep.TargetPkg());
-   else if (strcmp("ParentVer",Name) == 0)
-      return CppOwnedPyObject_NEW<pkgCache::VerIterator>(Owner,&VersionType,
-							 Dep.ParentVer());
-   else if (strcmp("ParentPkg",Name) == 0)
-      return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType,							 Dep.ParentPkg());
-   else if (strcmp("CompType",Name) == 0)
-      return PyString_FromString(Dep.CompType());
-   else if (strcmp("DepType",Name) == 0)
-      return PyString_FromString(Dep.DepType());
-   else if (strcmp("ID",Name) == 0)
-      return Py_BuildValue("i",Dep->ID);
-   
-   return Py_FindMethod(DependencyMethods,Self,Name);
-}
 
 static PyObject *DependencyRepr(PyObject *Self)
 {
@@ -626,6 +593,38 @@
    {}
 };
 
+// Dependency Class							/*{{{*/
+// ---------------------------------------------------------------------
+   
+static PyObject *DependencyAttr(PyObject *Self,char *Name)
+{
+   pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self);
+   PyObject *Owner = GetOwner<pkgCache::DepIterator>(Self);
+   
+   if (strcmp("TargetVer",Name) == 0)
+   {
+      if (Dep->Version == 0)
+	 return PyString_FromString("");
+      return PyString_FromString(Dep.TargetVer());
+   }   
+   else if (strcmp("TargetPkg",Name) == 0)
+      return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType,
+							 Dep.TargetPkg());
+   else if (strcmp("ParentVer",Name) == 0)
+      return CppOwnedPyObject_NEW<pkgCache::VerIterator>(Owner,&VersionType,
+							 Dep.ParentVer());
+   else if (strcmp("ParentPkg",Name) == 0)
+      return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType,							 Dep.ParentPkg());
+   else if (strcmp("CompType",Name) == 0)
+      return PyString_FromString(Dep.CompType());
+   else if (strcmp("DepType",Name) == 0)
+      return PyString_FromString(Dep.DepType());
+   else if (strcmp("ID",Name) == 0)
+      return Py_BuildValue("i",Dep->ID);
+   
+   return Py_FindMethod(DependencyMethods,Self,Name);
+}
+
 PyTypeObject DependencyType =
 {
    PyObject_HEAD_INIT(&PyType_Type)
@@ -646,6 +645,7 @@
    0,                                   // tp_hash
 };
    
+									/*}}}*/
 									/*}}}*/
 // Reverse Dependency List Class					/*{{{*/
 // ---------------------------------------------------------------------
Index: python/configuration.cc
===================================================================
RCS file: /cvs/deity/python-apt/python/configuration.cc,v
retrieving revision 1.2
diff -u -r1.2 configuration.cc
--- python/configuration.cc	2002/01/08 06:53:04	1.2
+++ python/configuration.cc	2002/02/24 05:19:22
@@ -25,8 +25,6 @@
 
 #include <Python.h>
 									/*}}}*/
-static PyMethodDef CnfMethods[];
-
 /* If we create a sub tree then it is of this type, the Owner is used
    to manage reference counting. */
 struct SubConfiguration : public CppPyObject<Configuration>
@@ -34,13 +32,6 @@
    PyObject *Owner;
 };
 
-// CnfGetAttr - Get an attribute - variable/method			/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static PyObject *CnfGetAttr(PyObject *Self,char *Name)
-{
-   return Py_FindMethod(CnfMethods,Self,Name);
-}
 									/*}}}*/
 // CnfSubFree - Free a sub configuration				/*{{{*/
 // ---------------------------------------------------------------------
@@ -458,6 +449,14 @@
    {"get",CnfFind,METH_VARARGS,doc_Find},
    {}
 };
+
+// CnfGetAttr - Get an attribute - variable/method			/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static PyObject *CnfGetAttr(PyObject *Self,char *Name)
+{
+   return Py_FindMethod(CnfMethods,Self,Name);
+}
 
 // Type for a Normal Configuration object
 static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet};
Index: python/generic.h
===================================================================
RCS file: /cvs/deity/python-apt/python/generic.h,v
retrieving revision 1.2
diff -u -r1.2 generic.h
--- python/generic.h	2002/01/08 06:53:04	1.2
+++ python/generic.h	2002/02/24 05:19:22
@@ -110,9 +110,9 @@
    PyMem_DEL(Obj);
 }
 
-inline PyObject *CppPyString(string Str)
+inline PyObject *CppPyString(std::string Str)
 {
-   return PyString_FromStringAndSize(Str.begin(),Str.length());
+   return PyString_FromStringAndSize(Str.c_str(),Str.length());
 }
 
 inline PyObject *Safe_FromString(const char *Str)
Index: python/pkgrecords.cc
===================================================================
RCS file: /cvs/deity/python-apt/python/pkgrecords.cc,v
retrieving revision 1.2
diff -u -r1.2 pkgrecords.cc
--- python/pkgrecords.cc	2002/01/08 06:53:04	1.2
+++ python/pkgrecords.cc	2002/02/24 05:19:22
@@ -27,32 +27,7 @@
     
 // PkgRecords Class							/*{{{*/
 // ---------------------------------------------------------------------
-static PyMethodDef PkgRecordsMethods[];
 
-static PyObject *PkgRecordsAttr(PyObject *Self,char *Name)
-{
-   PkgRecordsStruct &Struct = GetCpp<PkgRecordsStruct>(Self);
-
-   if (Struct.Last != 0)
-   {
-      if (strcmp("FileName",Name) == 0)
-	 return CppPyString(Struct.Last->FileName());
-      else if (strcmp("MD5Hash",Name) == 0)
-	 return CppPyString(Struct.Last->MD5Hash());
-      else if (strcmp("SourcePkg",Name) == 0)
-	 return CppPyString(Struct.Last->SourcePkg());
-      else if (strcmp("Maintainer",Name) == 0)
-	 return CppPyString(Struct.Last->Maintainer());
-      else if (strcmp("ShortDesc",Name) == 0)
-	 return CppPyString(Struct.Last->ShortDesc());
-      else if (strcmp("LongDesc",Name) == 0)
-	 return CppPyString(Struct.Last->LongDesc());
-      else if (strcmp("Name",Name) == 0)
-	 return CppPyString(Struct.Last->Name());
-   }
-   
-   return Py_FindMethod(PkgRecordsMethods,Self,Name);
-}
 
 static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args)
 {   
@@ -85,6 +60,30 @@
    {}
 };
 
+static PyObject *PkgRecordsAttr(PyObject *Self,char *Name)
+{
+   PkgRecordsStruct &Struct = GetCpp<PkgRecordsStruct>(Self);
+
+   if (Struct.Last != 0)
+   {
+      if (strcmp("FileName",Name) == 0)
+	 return CppPyString(Struct.Last->FileName());
+      else if (strcmp("MD5Hash",Name) == 0)
+	 return CppPyString(Struct.Last->MD5Hash());
+      else if (strcmp("SourcePkg",Name) == 0)
+	 return CppPyString(Struct.Last->SourcePkg());
+      else if (strcmp("Maintainer",Name) == 0)
+	 return CppPyString(Struct.Last->Maintainer());
+      else if (strcmp("ShortDesc",Name) == 0)
+	 return CppPyString(Struct.Last->ShortDesc());
+      else if (strcmp("LongDesc",Name) == 0)
+	 return CppPyString(Struct.Last->LongDesc());
+      else if (strcmp("Name",Name) == 0)
+	 return CppPyString(Struct.Last->Name());
+   }
+   
+   return Py_FindMethod(PkgRecordsMethods,Self,Name);
+}
 PyTypeObject PkgRecordsType =
 {
    PyObject_HEAD_INIT(&PyType_Type)
Index: python/tag.cc
===================================================================
RCS file: /cvs/deity/python-apt/python/tag.cc,v
retrieving revision 1.2
diff -u -r1.2 tag.cc
--- python/tag.cc	2002/01/08 06:53:04	1.2
+++ python/tag.cc	2002/02/24 05:19:22
@@ -19,18 +19,20 @@
    ##################################################################### */
 									/*}}}*/
 // Include Files							/*{{{*/
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 #include "generic.h"
 #include "apt_pkgmodule.h"
 
 #include <apt-pkg/tagfile.h>
 
 #include <stdio.h>
+#include <iostream>
 #include <Python.h>
-									/*}}}*/
-static PyMethodDef TagSecMethods[];
-static PyMethodDef TagFileMethods[];
 
+using namespace std;
+									/*}}}*/
 /* We need to keep a private copy of the data.. */
 struct TagSecData : public CppPyObject<pkgTagSection>
 {
@@ -45,28 +47,6 @@
    FileFd Fd;
 };
 
-// TagSecGetAttr - Get an attribute - variable/method			/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static PyObject *TagSecGetAttr(PyObject *Self,char *Name)
-{
-   return Py_FindMethod(TagSecMethods,Self,Name);
-}
-									/*}}}*/
-// TagFileGetAttr - Get an attribute - variable/method			/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static PyObject *TagFileGetAttr(PyObject *Self,char *Name)
-{
-   if (strcmp("Section",Name) == 0)
-   {
-      PyObject *Obj = ((TagFileData *)Self)->Section;
-      Py_INCREF(Obj);
-      return Obj;
-   }   
-   
-   return Py_FindMethod(TagFileMethods,Self,Name);
-}
 									/*}}}*/
 // TagSecFree - Free a Tag Section					/*{{{*/
 // ---------------------------------------------------------------------
@@ -388,6 +368,14 @@
    {}
 };
 
+// TagSecGetAttr - Get an attribute - variable/method			/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static PyObject *TagSecGetAttr(PyObject *Self,char *Name)
+{
+   return Py_FindMethod(TagSecMethods,Self,Name);
+}
+									/*}}}*/
 // Type for a Tag Section
 PyMappingMethods TagSecMapMeth = {TagSecLength,TagSecMap,0};
 PyTypeObject TagSecType =
@@ -422,6 +410,21 @@
 	 
    {}
 };
+
+// TagFileGetAttr - Get an attribute - variable/method			/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static PyObject *TagFileGetAttr(PyObject *Self,char *Name)
+{
+   if (strcmp("Section",Name) == 0)
+   {
+      PyObject *Obj = ((TagFileData *)Self)->Section;
+      Py_INCREF(Obj);
+      return Obj;
+   }   
+   
+   return Py_FindMethod(TagFileMethods,Self,Name);
+}
 
 // Type for a Tag File
 PyTypeObject TagFileType =

Reply to: