summaryrefslogtreecommitdiff
path: root/python/depcache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'python/depcache.cc')
-rw-r--r--python/depcache.cc133
1 files changed, 85 insertions, 48 deletions
diff --git a/python/depcache.cc b/python/depcache.cc
index 0e83c956..1c9eeff7 100644
--- a/python/depcache.cc
+++ b/python/depcache.cc
@@ -560,50 +560,73 @@ static PyMethodDef PkgDepCacheMethods[] =
{}
};
-
-static PyObject *DepCacheAttr(PyObject *Self,char *Name)
-{
- pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self);
-
- // size querries
- if(strcmp("KeepCount",Name) == 0)
- return Py_BuildValue("l", depcache->KeepCount());
- else if(strcmp("InstCount",Name) == 0)
- return Py_BuildValue("l", depcache->InstCount());
- else if(strcmp("DelCount",Name) == 0)
- return Py_BuildValue("l", depcache->DelCount());
- else if(strcmp("BrokenCount",Name) == 0)
- return Py_BuildValue("l", depcache->BrokenCount());
- else if(strcmp("UsrSize",Name) == 0)
- return Py_BuildValue("d", depcache->UsrSize());
- else if(strcmp("DebSize",Name) == 0)
- return Py_BuildValue("d", depcache->DebSize());
-
-
- return Py_FindMethod(PkgDepCacheMethods,Self,Name);
+#define depcache (GetCpp<pkgDepCache *>(Self))
+static PyObject *PkgDepCacheGetKeepCount(PyObject *Self,void*) {
+ return Py_BuildValue("l", depcache->KeepCount());
}
+static PyObject *PkgDepCacheGetInstCount(PyObject *Self,void*) {
+ return Py_BuildValue("l", depcache->InstCount());
+}
+static PyObject *PkgDepCacheGetDelCount(PyObject *Self,void*) {
+ return Py_BuildValue("l", depcache->DelCount());
+}
+static PyObject *PkgDepCacheGetBrokenCount(PyObject *Self,void*) {
+ return Py_BuildValue("l", depcache->BrokenCount());
+}
+static PyObject *PkgDepCacheGetUsrSize(PyObject *Self,void*) {
+ return Py_BuildValue("d", depcache->UsrSize());
+}
+static PyObject *PkgDepCacheGetDebSize(PyObject *Self,void*) {
+ return Py_BuildValue("d", depcache->DebSize());
+}
+#undef depcache
-
-
+static PyGetSetDef PkgDepCacheGetSet[] = {
+ {"BrokenCount",PkgDepCacheGetBrokenCount},
+ {"DebSize",PkgDepCacheGetDebSize},
+ {"DelCount",PkgDepCacheGetDelCount},
+ {"InstCount",PkgDepCacheGetInstCount},
+ {"KeepCount",PkgDepCacheGetKeepCount},
+ {"UsrSize",PkgDepCacheGetUsrSize},
+ {}
+};
PyTypeObject PkgDepCacheType =
{
PyObject_HEAD_INIT(&PyType_Type)
- 0, // ob_size
- "pkgDepCache", // tp_name
+ #if PY_MAJOR_VERSION < 3
+ 0, // ob_size
+ #endif
+ "pkgDepCache", // tp_name
sizeof(CppOwnedPyObject<pkgDepCache *>), // tp_basicsize
0, // tp_itemsize
// Methods
- CppOwnedDealloc<pkgDepCache *>, // tp_dealloc
+ CppOwnedDealloc<pkgDepCache *>, // tp_dealloc
0, // tp_print
- DepCacheAttr, // tp_getattr
+ 0, // tp_getattr
0, // tp_setattr
0, // tp_compare
0, // tp_repr
0, // tp_as_number
0, // tp_as_sequence
- 0, // tp_as_mapping
+ 0, // tp_as_mapping
0, // tp_hash
+ 0, // tp_call
+ 0, // tp_str
+ 0, // tp_getattro
+ 0, // tp_setattro
+ 0, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "pkgDepCache Object", // tp_doc
+ 0, // tp_traverse
+ 0, // tp_clear
+ 0, // tp_richcompare
+ 0, // tp_weaklistoffset
+ 0, // tp_iter
+ 0, // tp_iternext
+ PkgDepCacheMethods, // tp_methods
+ 0, // tp_members
+ PkgDepCacheGetSet, // tp_getset
};
@@ -749,26 +772,19 @@ static PyMethodDef PkgProblemResolverMethods[] =
{}
};
-
-static PyObject *ProblemResolverAttr(PyObject *Self,char *Name)
-{
- pkgProblemResolver *fixer = GetCpp<pkgProblemResolver *>(Self);
-
- return Py_FindMethod(PkgProblemResolverMethods,Self,Name);
-}
-
-
PyTypeObject PkgProblemResolverType =
{
PyObject_HEAD_INIT(&PyType_Type)
+ #if PY_MAJOR_VERSION < 3
0, // ob_size
+ #endif
"pkgProblemResolver", // tp_name
sizeof(CppOwnedPyObject<pkgProblemResolver *>), // tp_basicsize
0, // tp_itemsize
// Methods
CppOwnedDealloc<pkgProblemResolver *>, // tp_dealloc
0, // tp_print
- ProblemResolverAttr, // tp_getattr
+ 0, // tp_getattr
0, // tp_setattr
0, // tp_compare
0, // tp_repr
@@ -776,6 +792,20 @@ PyTypeObject PkgProblemResolverType =
0, // tp_as_sequence
0, // tp_as_mapping
0, // tp_hash
+ 0, // tp_call
+ 0, // tp_str
+ 0, // tp_getattro
+ 0, // tp_setattro
+ 0, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "ProblemResolver Object", // tp_doc
+ 0, // tp_traverse
+ 0, // tp_clear
+ 0, // tp_richcompare
+ 0, // tp_weaklistoffset
+ 0, // tp_iter
+ 0, // tp_iternext
+ PkgProblemResolverMethods, // tp_methods
};
/*}}}*/
@@ -800,26 +830,19 @@ static PyMethodDef PkgActionGroupMethods[] =
{}
};
-
-static PyObject *ActionGroupAttr(PyObject *Self,char *Name)
-{
- pkgDepCache::ActionGroup *ag = GetCpp<pkgDepCache::ActionGroup*>(Self);
-
- return Py_FindMethod(PkgActionGroupMethods,Self,Name);
-}
-
-
PyTypeObject PkgActionGroupType =
{
PyObject_HEAD_INIT(&PyType_Type)
+ #if PY_MAJOR_VERSION < 3
0, // ob_size
+ #endif
"pkgActionGroup", // tp_name
sizeof(CppOwnedPyObject<pkgDepCache::ActionGroup*>), // tp_basicsize
0, // tp_itemsize
// Methods
CppOwnedDealloc<pkgDepCache::ActionGroup*>, // tp_dealloc
0, // tp_print
- ActionGroupAttr, // tp_getattr
+ 0, // tp_getattr
0, // tp_setattr
0, // tp_compare
0, // tp_repr
@@ -827,6 +850,20 @@ PyTypeObject PkgActionGroupType =
0, // tp_as_sequence
0, // tp_as_mapping
0, // tp_hash
+ 0, // tp_call
+ 0, // tp_str
+ 0, // tp_getattro
+ 0, // tp_setattro
+ 0, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT, // tp_flags
+ "ActionGroup Object", // tp_doc
+ 0, // tp_traverse
+ 0, // tp_clear
+ 0, // tp_richcompare
+ 0, // tp_weaklistoffset
+ 0, // tp_iter
+ 0, // tp_iternext
+ PkgActionGroupMethods, // tp_methods
};
PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args)