]> git.ipfire.org Git - pakfire.git/commitdiff
solution: Change type from PakfireSolution to struct pakfire_solution
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 2 Jul 2021 15:57:44 +0000 (15:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 2 Jul 2021 15:57:44 +0000 (15:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/problem.c
src/_pakfire/solution.c
src/_pakfire/solution.h
src/libpakfire/include/pakfire/problem.h
src/libpakfire/include/pakfire/solution.h
src/libpakfire/include/pakfire/types.h
src/libpakfire/problem.c
src/libpakfire/solution.c

index 23f4430f850aa8fc28696dfa8ddd250354b09191..120569c1a9a8c6c735c5fced39df523daaf4fe42 100644 (file)
@@ -21,6 +21,7 @@
 #include <Python.h>
 
 #include <pakfire/problem.h>
+#include <pakfire/solution.h>
 
 #include "problem.h"
 #include "solution.h"
@@ -83,7 +84,7 @@ static PyObject* Problem_string(ProblemObject* self) {
 static PyObject* Problem_get_solutions(ProblemObject* self) {
        PyObject* list = PyList_New(0);
 
-       PakfireSolution solution = pakfire_problem_get_solutions(self->problem);
+       struct pakfire_solution* solution = pakfire_problem_get_solutions(self->problem);
        while (solution) {
                PyObject* s = new_solution(solution);
                PyList_Append(list, s);
index af7ed86aae27b5a0665e6a4a4e539aec808bcc4d..b0315cd7e80351cd9b227abf3c965f39a86d6c41 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "solution.h"
 
-static SolutionObject* Solution_new_core(PyTypeObject* type, PakfireSolution solution) {
+static SolutionObject* Solution_new_core(PyTypeObject* type, struct pakfire_solution* solution) {
        SolutionObject* self = (SolutionObject *)type->tp_alloc(type, 0);
        if (self) {
                self->solution = solution;
@@ -33,7 +33,7 @@ static SolutionObject* Solution_new_core(PyTypeObject* type, PakfireSolution sol
        return self;
 }
 
-PyObject* new_solution(PakfireSolution solution) {
+PyObject* new_solution(struct pakfire_solution* solution) {
        SolutionObject* s = Solution_new_core(&SolutionType, solution);
 
        return (PyObject*)s;
index 44d6fcda92927dcfdadba9252e368e5ad6691105..cd5bb3e05626e46cbadb365709e5d38b2f21fe12 100644 (file)
 
 typedef struct {
        PyObject_HEAD
-       PakfireSolution solution;
+       struct pakfire_solution* solution;
 } SolutionObject;
 
 extern PyTypeObject SolutionType;
 
-PyObject* new_solution(PakfireSolution solution);
+PyObject* new_solution(struct pakfire_solution* solution);
 
 #endif /* PYTHON_PAKFIRE_SOLUTION_H */
index f4ffd5ad1e1ae5c1b47f87a948faf535422a1ea3..c391918ee632906edb1ba449d56787345ddfd12b 100644 (file)
 #ifndef PAKFIRE_PROBLEM_H
 #define PAKFIRE_PROBLEM_H
 
-#include <pakfire/types.h>
-
 struct pakfire_problem;
 
+#include <pakfire/solution.h>
+#include <pakfire/types.h>
+
 struct pakfire_problem* pakfire_problem_ref(struct pakfire_problem* problem);
 struct pakfire_problem* pakfire_problem_unref(struct pakfire_problem* problem);
 
 const char* pakfire_problem_to_string(struct pakfire_problem* problem);
 
 struct pakfire_request* pakfire_problem_get_request(struct pakfire_problem* problem);
-PakfireSolution pakfire_problem_get_solutions(struct pakfire_problem* problem);
+struct pakfire_solution* pakfire_problem_get_solutions(struct pakfire_problem* problem);
 
 #ifdef PAKFIRE_PRIVATE
 
index 1c833a5138fc3208156606132ffb753e6818386b..4e36f73abb46a705637cc0635ee6eec8f19c03b2 100644 (file)
 
 #include <solv/pooltypes.h>
 
+struct pakfire_solution;
+
 #include <pakfire/problem.h>
 
-PakfireSolution pakfire_solution_create(struct pakfire_problem* problem, Id id);
-PakfireSolution pakfire_solution_ref(PakfireSolution solution);
-PakfireSolution pakfire_solution_unref(PakfireSolution solution);
+struct pakfire_solution* pakfire_solution_create(struct pakfire_problem* problem, Id id);
+struct pakfire_solution* pakfire_solution_ref(struct pakfire_solution* solution);
+struct pakfire_solution* pakfire_solution_unref(struct pakfire_solution* solution);
 
-PakfireSolution pakfire_solution_next(PakfireSolution solution);
-void pakfire_solution_append(PakfireSolution solution, PakfireSolution new_solution);
+struct pakfire_solution* pakfire_solution_next(struct pakfire_solution* solution);
+void pakfire_solution_append(struct pakfire_solution* solution, struct pakfire_solution* new_solution);
 
-char* pakfire_solution_to_string(PakfireSolution solution);
+char* pakfire_solution_to_string(struct pakfire_solution* solution);
 
 #endif /* PAKFIRE_SOLUTION_H */
index 28b07102e4594325cfa145f3c3e1d7bac898b6e4..a450143b9abe2ab83bb4577b48ebd504d5e12074 100644 (file)
@@ -26,6 +26,5 @@ typedef struct _PakfireArchive* PakfireArchive;
 typedef struct _PakfireArchiveSignature* PakfireArchiveSignature;
 typedef struct _PakfireFilelist* PakfireFilelist;
 typedef struct _PakfireKey* PakfireKey;
-typedef struct _PakfireSolution* PakfireSolution;
 
 #endif /* PAKFIRE_TYPES_H */
index 841408c61dd26c74658ad9f5315e936e2beb7eef..2e8ec982fdc852307bd491cf58e1e73a69ac2997 100644 (file)
@@ -262,13 +262,13 @@ PAKFIRE_EXPORT struct pakfire_request* pakfire_problem_get_request(struct pakfir
        return pakfire_request_ref(problem->request);
 }
 
-PAKFIRE_EXPORT PakfireSolution pakfire_problem_get_solutions(struct pakfire_problem* problem) {
-       PakfireSolution ret = NULL;
+PAKFIRE_EXPORT struct pakfire_solution* pakfire_problem_get_solutions(struct pakfire_problem* problem) {
+       struct pakfire_solution* ret = NULL;
        Solver* solver = pakfire_request_get_solver(problem->request);
 
        Id solution = 0;
        while ((solution = solver_next_solution(solver, problem->id, solution)) != 0) {
-               PakfireSolution s = pakfire_solution_create(problem, solution);
+               struct pakfire_solution* s = pakfire_solution_create(problem, solution);
 
                if (ret)
                        pakfire_solution_append(ret, s);
index 5eead890bd22a9b526751c2662eb5fd1a04532a3..2459b8287aaab8d606e00ea1d9e0eb5a1887f345 100644 (file)
 #include <pakfire/solution.h>
 #include <pakfire/util.h>
 
-struct _PakfireSolution {
+struct pakfire_solution {
        Pakfire pakfire;
+       int nrefs;
+
        struct pakfire_problem* problem;
        Id id;
        char** elements;
 
-       PakfireSolution next;
-       int nrefs;
+       struct pakfire_solution* next;
 };
 
-static void import_elements(PakfireSolution solution) {
+static void import_elements(struct pakfire_solution* solution) {
        struct pakfire_request* request = pakfire_problem_get_request(solution->problem);
 
        Solver* solver = pakfire_request_get_solver(request);
@@ -119,10 +120,10 @@ static void import_elements(PakfireSolution solution) {
        pakfire_request_unref(request);
 }
 
-PAKFIRE_EXPORT PakfireSolution pakfire_solution_create(struct pakfire_problem* problem, Id id) {
+PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_create(struct pakfire_problem* problem, Id id) {
        Pakfire pakfire = pakfire_problem_get_pakfire(problem);
 
-       PakfireSolution solution = calloc(1, sizeof(*solution));
+       struct pakfire_solution* solution = calloc(1, sizeof(*solution));
        if (solution) {
                DEBUG(pakfire, "Allocated Solution at %p\n", solution);
                solution->pakfire = pakfire_ref(pakfire);
@@ -140,13 +141,13 @@ PAKFIRE_EXPORT PakfireSolution pakfire_solution_create(struct pakfire_problem* p
        return solution;
 }
 
-PAKFIRE_EXPORT PakfireSolution pakfire_solution_ref(PakfireSolution solution) {
+PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_ref(struct pakfire_solution* solution) {
        solution->nrefs++;
 
        return solution;
 }
 
-static void pakfire_solution_free(PakfireSolution solution) {
+static void pakfire_solution_free(struct pakfire_solution* solution) {
        DEBUG(solution->pakfire, "Releasing Solution at %p\n", solution);
        pakfire_unref(solution->pakfire);
 
@@ -162,7 +163,7 @@ static void pakfire_solution_free(PakfireSolution solution) {
        free(solution);
 }
 
-PAKFIRE_EXPORT PakfireSolution pakfire_solution_unref(PakfireSolution solution) {
+PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_unref(struct pakfire_solution* solution) {
        if (!solution)
                return NULL;
 
@@ -173,12 +174,12 @@ PAKFIRE_EXPORT PakfireSolution pakfire_solution_unref(PakfireSolution solution)
        return NULL;
 }
 
-PAKFIRE_EXPORT PakfireSolution pakfire_solution_next(PakfireSolution solution) {
+PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_next(struct pakfire_solution* solution) {
        return solution->next;
 }
 
-PAKFIRE_EXPORT void pakfire_solution_append(PakfireSolution solution, PakfireSolution new_solution) {
-       PakfireSolution next;
+PAKFIRE_EXPORT void pakfire_solution_append(struct pakfire_solution* solution, struct pakfire_solution* new_solution) {
+       struct pakfire_solution* next;
 
        // Go to last problem in list
        while ((next = pakfire_solution_next(solution)) != NULL) {
@@ -188,7 +189,7 @@ PAKFIRE_EXPORT void pakfire_solution_append(PakfireSolution solution, PakfireSol
        solution->next = pakfire_solution_ref(new_solution);
 }
 
-static size_t count_elements_length(PakfireSolution solution) {
+static size_t count_elements_length(struct pakfire_solution* solution) {
        size_t length = 0;
 
        char** elements = solution->elements;
@@ -199,7 +200,7 @@ static size_t count_elements_length(PakfireSolution solution) {
        return length;
 }
 
-PAKFIRE_EXPORT char* pakfire_solution_to_string(PakfireSolution solution) {
+PAKFIRE_EXPORT char* pakfire_solution_to_string(struct pakfire_solution* solution) {
        // Determine length of output string
        size_t length = count_elements_length(solution);