4358b5a
From 5ddb0ce955faacaaaee03b22407049e10a2317ea Mon Sep 17 00:00:00 2001
4358b5a
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
4358b5a
Date: Sat, 9 Feb 2019 18:30:29 +0100
4358b5a
Subject: [PATCH 1/2] bindings: Add pool.best_solvables()
4358b5a
4358b5a
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
4358b5a
---
4358b5a
 bindings/solv.i            |  9 +++++++++
4358b5a
 doc/gen/libsolv-bindings.3 | 19 +++++++++++++++++--
4358b5a
 doc/libsolv-bindings.txt   |  7 +++++++
4358b5a
 3 files changed, 33 insertions(+), 2 deletions(-)
4358b5a
4358b5a
diff --git a/bindings/solv.i b/bindings/solv.i
4358b5a
index adaf1a37..cbfddb73 100644
4358b5a
--- a/bindings/solv.i
4358b5a
+++ b/bindings/solv.i
4358b5a
@@ -381,6 +381,7 @@ typedef struct {
4358b5a
 
4358b5a
 %typemap(in) Queue Array2Queue(SWIG_AsVal_int, "integers")
4358b5a
 %typemap(in) Queue solvejobs ObjArray2Queue(Job *, queue_push2(&$1, obj->how, obj->what))
4358b5a
+%typemap(in) Queue solvables ObjArray2Queue(XSolvable *, queue_push(&$1, obj->id))
4358b5a
 
4358b5a
 
4358b5a
 
4358b5a
@@ -1945,6 +1946,14 @@ typedef struct {
4358b5a
       queue_push(&q, p);
4358b5a
     return q;
4358b5a
   }
4358b5a
+  %typemap(out) Queue best_solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
4358b5a
+  %newobject best_solvables;
4358b5a
+  Queue best_solvables(Queue solvables, int flags=0) {
4358b5a
+    Queue q;
4358b5a
+    queue_init_clone(&q, &solvables);
4358b5a
+    pool_best_solvables($self, &q, flags);
4358b5a
+    return q;
4358b5a
+  }
4358b5a
 
4358b5a
   Id towhatprovides(Queue q) {
4358b5a
     return pool_queuetowhatprovides($self, &q);
4358b5a
diff --git a/doc/gen/libsolv-bindings.3 b/doc/gen/libsolv-bindings.3
4358b5a
index 9f84c77e..a6cf3588 100644
4358b5a
--- a/doc/gen/libsolv-bindings.3
4358b5a
+++ b/doc/gen/libsolv-bindings.3
4358b5a
@@ -2,12 +2,12 @@
4358b5a
 .\"     Title: Libsolv-Bindings
4358b5a
 .\"    Author: [see the "Author" section]
4358b5a
 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
4358b5a
-.\"      Date: 12/06/2018
4358b5a
+.\"      Date: 02/13/2019
4358b5a
 .\"    Manual: LIBSOLV
4358b5a
 .\"    Source: libsolv
4358b5a
 .\"  Language: English
4358b5a
 .\"
4358b5a
-.TH "LIBSOLV\-BINDINGS" "3" "12/06/2018" "libsolv" "LIBSOLV"
4358b5a
+.TH "LIBSOLV\-BINDINGS" "3" "02/13/2019" "libsolv" "LIBSOLV"
4358b5a
 .\" -----------------------------------------------------------------
4358b5a
 .\" * Define some portability stuff
4358b5a
 .\" -----------------------------------------------------------------
4358b5a
@@ -851,6 +851,21 @@ Return all solvables that provide the specified dependency\&. You can use either
4358b5a
 .RS 4
4358b5a
 .\}
4358b5a
 .nf
4358b5a
+\fBSolvable *best_solvables(Solvable *\fR\fIsolvables\fR\fB, int\fR \fIflags\fR \fB= 0)\fR
4358b5a
+my \fI@solvables\fR \fB=\fR \fI$pool\fR\fB\->best_solvables(\fR\fI$solvables\fR\fB)\fR;
4358b5a
+\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.best_solvables(\fR\fIsolvables\fR\fB)\fR
4358b5a
+\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.best_solvables(\fR\fIsolvables\fR\fB)\fR
4358b5a
+.fi
4358b5a
+.if n \{\
4358b5a
+.RE
4358b5a
+.\}
4358b5a
+.sp
4358b5a
+Filter list of solvables by repo priority, architecture and version\&.
4358b5a
+.sp
4358b5a
+.if n \{\
4358b5a
+.RS 4
4358b5a
+.\}
4358b5a
+.nf
4358b5a
 \fBId *matchprovidingids(const char *\fR\fImatch\fR\fB, int\fR \fIflags\fR\fB)\fR
4358b5a
 my \fI@ids\fR \fB=\fR \fI$pool\fR\fB\->matchprovidingids(\fR\fI$match\fR\fB,\fR \fI$flags\fR\fB)\fR;
4358b5a
 \fIids\fR \fB=\fR \fIpool\fR\fB\&.matchprovidingids(\fR\fImatch\fR\fB,\fR \fIflags\fR\fB)\fR
4358b5a
diff --git a/doc/libsolv-bindings.txt b/doc/libsolv-bindings.txt
4358b5a
index 3839ed96..450ed41c 100644
4358b5a
--- a/doc/libsolv-bindings.txt
4358b5a
+++ b/doc/libsolv-bindings.txt
4358b5a
@@ -488,6 +488,13 @@ the call to addfileprovides().
4358b5a
 Return all solvables that provide the specified dependency. You can use either
4358b5a
 a Dep object or a simple Id as argument.
4358b5a
 
4358b5a
+	Solvable *best_solvables(Solvable *solvables, int flags = 0)
4358b5a
+	my @solvables = $pool->best_solvables($solvables);
4358b5a
+	solvables = pool.best_solvables(solvables)
4358b5a
+	solvables = pool.best_solvables(solvables)
4358b5a
+
4358b5a
+Filter list of solvables by repo priority, architecture and version.
4358b5a
+
4358b5a
 	Id *matchprovidingids(const char *match, int flags)
4358b5a
 	my @ids = $pool->matchprovidingids($match, $flags);
4358b5a
 	ids = pool.matchprovidingids(match, flags)
4358b5a
-- 
4358b5a
2.20.1
4358b5a