]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Move pakfire_pool_count to pakfire_count_packages
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 18 Jan 2018 18:42:56 +0000 (19:42 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 18 Jan 2018 18:43:13 +0000 (19:43 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/_pakfire/pool.c
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/include/pakfire/pool.h
src/libpakfire/libpakfire.sym
src/libpakfire/pakfire.c
src/libpakfire/pool.c

index 2a9a52bc971d8e71b045540c9a175d70b80c9352..6fbde87de1b1262d71732b40a38e843d3160c5c0 100644 (file)
@@ -256,6 +256,10 @@ static int Pakfire_set_installonly(PakfireObject* self, PyObject* value) {
        return 0;
 }
 
+static Py_ssize_t Pakfire_len(PakfireObject* self) {
+       return pakfire_count_packages(self->pakfire);
+}
+
 static struct PyMethodDef Pakfire_methods[] = {
        {
                "generate_key",
@@ -335,6 +339,10 @@ static struct PyGetSetDef Pakfire_getsetters[] = {
     { NULL },
 };
 
+static PySequenceMethods Pakfire_sequence = {
+       sq_length:          (lenfunc)Pakfire_len,
+};
+
 PyTypeObject PakfireType = {
        PyVarObject_HEAD_INIT(NULL, 0)
        tp_name:            "_pakfire.Pakfire",
@@ -347,4 +355,5 @@ PyTypeObject PakfireType = {
        tp_methods:         Pakfire_methods,
        tp_getset:          Pakfire_getsetters,
        tp_repr:            (reprfunc)Pakfire_repr,
+       tp_as_sequence:     &Pakfire_sequence,
 };
index dcae7b6fbaef10a3eef7b40e8853ffc34c4b7505..e92539336c0411c8dec40cf58466addb8a41c04b 100644 (file)
@@ -63,12 +63,6 @@ static int Pool_init(PoolObject* self, PyObject* args, PyObject* kwds) {
        return 0;
 }
 
-static Py_ssize_t Pool_len(PoolObject* self) {
-       return pakfire_pool_count(self->pool);
-}
-
-
-
 static PyObject* Pool_get_cache_path(PoolObject* self) {
        const char* path = pakfire_pool_get_cache_path(self->pool);
        if (!path)
@@ -96,10 +90,6 @@ static struct PyGetSetDef Pool_getsetters[] = {
        { NULL }
 };
 
-static PySequenceMethods Pool_sequence = {
-       sq_length:          (lenfunc)Pool_len,
-};
-
 PyTypeObject PoolType = {
        PyVarObject_HEAD_INIT(NULL, 0)
        tp_name:            "_pakfire.Pool",
@@ -110,5 +100,4 @@ PyTypeObject PoolType = {
        tp_init:            (initproc)Pool_init,
        tp_doc:             "Pool object",
        tp_getset:          Pool_getsetters,
-       tp_as_sequence:     &Pool_sequence,
 };
index 5cf492dadd5687befee000a25fb69c5d2fba57fb..e7aea8cbf5f7d91c2af44cdbc2ab226f5dd7e23d 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef PAKFIRE_PAKFIRE_H
 #define PAKFIRE_PAKFIRE_H
 
+#include <stddef.h>
+
 #include <pakfire/types.h>
 
 int pakfire_init();
@@ -40,6 +42,8 @@ void pakfire_set_installonly(Pakfire pakfire, const char** installonly);
 
 int pakfire_version_compare(Pakfire pakfire, const char* evr1, const char* evr2);
 
+size_t pakfire_count_packages(Pakfire pakfire);
+
 PakfireRepo pakfire_get_installed_repo(Pakfire pakfire);
 void pakfire_set_installed_repo(Pakfire pakfire, PakfireRepo repo);
 
index 01a5df6532b4112b9cd6306b9c12d6d82c948418..3759442dd7cb1b9062457f3fe82d1d57c9e03d4d 100644 (file)
@@ -28,8 +28,6 @@ PakfirePool pakfire_pool_create(Pakfire pakfire);
 PakfirePool pakfire_pool_ref(PakfirePool pool);
 PakfirePool pakfire_pool_unref(PakfirePool pool);
 
-int pakfire_pool_count(PakfirePool pool);
-
 const char* pakfire_pool_get_cache_path(PakfirePool pool);
 void pakfire_pool_set_cache_path(PakfirePool pool, const char* path);
 PakfireCache pakfire_pool_get_cache(PakfirePool pool);
index 8bebf05b0defeb1b704630867aab14d017f1a258..997824a4a8547562c680f01e3eca5107c85f38e2 100644 (file)
@@ -22,6 +22,7 @@ LIBPAKFIRE_0 {
 global:
        # pakfire
        pakfire_init;
+       pakfire_count_packages;
        pakfire_create;
        pakfire_get_arch;
        pakfire_get_installed_repo;
@@ -202,7 +203,6 @@ global:
        pakfire_packagelist_unref;
 
        # pool
-       pakfire_pool_count;
        pakfire_pool_create;
        pakfire_pool_get_cache_path;
        pakfire_pool_ref;
index 78127f2eb9322e0e743362c9c5ae6a47c5e22152..d28abda7a048b99bce41995ccb6457ec9040146f 100644 (file)
@@ -18,6 +18,8 @@
 #                                                                             #
 #############################################################################*/
 
+#include <stddef.h>
+
 #include <solv/evr.h>
 #include <solv/pool.h>
 #include <solv/poolarch.h>
@@ -151,6 +153,18 @@ void pakfire_pool_has_changed(Pakfire pakfire) {
        pakfire->pool_ready = 0;
 }
 
+PAKFIRE_EXPORT size_t pakfire_count_packages(Pakfire pakfire) {
+       size_t cnt = 0;
+
+       for (int i = 2; i < pakfire->pool->nsolvables; i++) {
+               Solvable* s = pakfire->pool->solvables + i;
+               if (s->repo)
+                       cnt++;
+       }
+
+       return cnt;
+}
+
 void pakfire_pool_apply_changes(Pakfire pakfire) {
        if (!pakfire->pool_ready) {
                pool_addfileprovides(pakfire->pool);
index 8761214e345f6e71cf08239344a92e58305b7bb5..da91c706d993675cfa30098d24f9e01cfa82e13c 100644 (file)
@@ -83,19 +83,6 @@ Pool* pakfire_pool_get_solv_pool(PakfirePool pool) {
        return pakfire_get_solv_pool(pool->pakfire);
 }
 
-PAKFIRE_EXPORT int pakfire_pool_count(PakfirePool pool) {
-       Pool* p = pakfire_get_solv_pool(pool->pakfire);
-       int cnt = 0;
-
-       for (int i = 2; i < p->nsolvables; i++) {
-               Solvable* s = p->solvables + i;
-               if (s->repo)
-                       cnt++;
-       }
-
-       return cnt;
-}
-
 PAKFIRE_EXPORT const char* pakfire_pool_get_cache_path(PakfirePool pool) {
        if (!pool->cache)
                return NULL;