From c48d4734a89a30a541b75629419f827b3a1e30e8 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sat, 16 Mar 2019 12:10:21 +0100 Subject: [PATCH] bindings: Add matchsolvable() for Pool and Selection Signed-off-by: Igor Gnatenko --- bindings/solv.i | 16 ++++++++++++++-- doc/gen/libsolv-bindings.3 | 38 ++++++++++++++++++++++++++++++++++---- doc/libsolv-bindings.txt | 19 +++++++++++++++++-- 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index d1143c3b..8ab1c8b9 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -1379,7 +1379,7 @@ typedef struct { if ($self->pool == lsel->pool) selection_subtract($self->pool, &$self->q, &lsel->q); } - + void select(const char *name, int flags) { if ((flags & SELECTION_MODEBITS) == 0) flags |= SELECTION_FILTER | SELECTION_WITH_ALL; @@ -1395,6 +1395,11 @@ typedef struct { flags |= SELECTION_FILTER | SELECTION_WITH_ALL; $self->flags = selection_make_matchdepid($self->pool, &$self->q, dep, flags, keyname, marker); } + void matchsolvable(XSolvable *solvable, int flags, Id keyname, Id marker = -1) { + if ((flags & SELECTION_MODEBITS) == 0) + flags |= SELECTION_FILTER | SELECTION_WITH_ALL; + $self->flags = selection_make_matchsolvable($self->pool, &$self->q, solvable->id, flags, keyname, marker); + } %typemap(out) Queue jobs Queue2Array(Job *, 2, new_Job(arg1->pool, id, idp[1])); %newobject jobs; @@ -1708,7 +1713,7 @@ typedef struct { int result, ecode = 0, vresult = 0; Tcl_Obj *objvx[2]; objvx[0] = callback_var->obj; - objvx[1] = SWIG_NewInstanceObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, 0); + objvx[1] = SWIG_NewInstanceObj(SWIG_as_voidptr(xd), SWIGTYPE_p_XRepodata, 0); Tcl_IncrRefCount(objvx[1]); result = Tcl_EvalObjv(interp, sizeof(objvx)/sizeof(*objvx), objvx, TCL_EVAL_GLOBAL); Tcl_DecrRefCount(objvx[1]); @@ -2037,6 +2042,13 @@ typedef struct { return sel; } + %newobject matchsolvable; + Selection *matchsolvable(XSolvable *solvable, int flags, Id keyname, Id marker = -1) { + Selection *sel = new_Selection($self); + sel->flags = selection_make_matchsolvable($self, &sel->q, solvable->id, flags, keyname, marker); + return sel; + } + Queue get_considered_list() { Queue q; queue_init(&q); diff --git a/doc/gen/libsolv-bindings.3 b/doc/gen/libsolv-bindings.3 index 47bf7dd7..88ab97d3 100644 --- a/doc/gen/libsolv-bindings.3 +++ b/doc/gen/libsolv-bindings.3 @@ -2,12 +2,12 @@ .\" Title: Libsolv-Bindings .\" Author: [see the "Author" section] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 02/13/2019 +.\" Date: 03/16/2019 .\" Manual: LIBSOLV .\" Source: libsolv .\" Language: English .\" -.TH "LIBSOLV\-BINDINGS" "3" "02/13/2019" "libsolv" "LIBSOLV" +.TH "LIBSOLV\-BINDINGS" "3" "03/16/2019" "libsolv" "LIBSOLV" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -875,7 +875,7 @@ my \fI@solvables\fR \fB=\fR \fI$pool\fR\fB\->whatmatchessolvable(\fR\fI$keyname\ .RE .\} .sp -Return all solvables that match package dependencies in against solvable\(cqs provides\&. +Return all solvables that match package dependencies against solvable\(cqs provides\&. .sp .if n \{\ .RS 4 @@ -1047,7 +1047,7 @@ Create a selection by matching package dependencies against the specified string .\} .nf \fBSelection matchdepid(DepId\fR \fIdep\fR\fB, int\fR \fIflags\fR\fB, Id\fR \fIkeyname\fR\fB, Id\fR \fImarker\fR \fB= \-1)\fR -my \fI$sel\fR \fB=\fR \fI$pool\fR\fB\->matchdepid(\fR\fIdep\fR\fB,\fR \fI$flags\fR\fB,\fR \fI$keyname\fR\fB)\fR; +my \fI$sel\fR \fB=\fR \fI$pool\fR\fB\->matchdepid(\fR\fI$dep\fR\fB,\fR \fI$flags\fR\fB,\fR \fI$keyname\fR\fB)\fR; \fIsel\fR \fB=\fR \fIpool\fR\fB\&.matchdepid(\fR\fIdep\fR\fB,\fR \fIflags\fR\fB,\fR \fIkeyname\fR\fB)\fR \fIsel\fR \fB=\fR \fIpool\fR\fB\&.matchdepid(\fR\fIdep\fR\fB,\fR \fIflags\fR\fB,\fR \fIkeyname\fR\fB)\fR .fi @@ -1061,6 +1061,21 @@ Create a selection by matching package dependencies against the specified depend .RS 4 .\} .nf +\fBSelection matchsolvable(Solvable\fR \fIsolvable\fR\fB, int\fR \fIflags\fR\fB, Id\fR \fIkeyname\fR\fB, Id\fR \fImarker\fR \fB= \-1)\fR +my \fI$sel\fR \fB=\fR \fI$pool\fR\fB\->matchsolvable(\fR\fI$solvable\fR\fB,\fR \fI$flags\fR\fB,\fR \fI$keyname\fR\fB)\fR; +\fIsel\fR \fB=\fR \fIpool\fR\fB\&.matchsolvable(\fR\fIsolvable\fR\fB,\fR \fIflags\fR\fB,\fR \fIkeyname\fR\fB)\fR +\fIsel\fR \fB=\fR \fIpool\fR\fB\&.matchsolvable(\fR\fIsolvable\fR\fB,\fR \fIflags\fR\fB,\fR \fIkeyname\fR\fB)\fR +.fi +.if n \{\ +.RE +.\} +.sp +Create a selection by matching package dependencies against the specified solvable\(cqs provides\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf \fBvoid setpooljobs(Jobs *\fR\fIjobs\fR\fB)\fR \fI$pool\fR\fB\->setpooljobs(\e\fR\fI@jobs\fR\fB)\fR; \fIpool\fR\fB\&.setpooljobs(\fR\fIjobs\fR\fB)\fR @@ -3377,6 +3392,21 @@ Do a matchdepid operation and combine the result with the current selection\&. .RS 4 .\} .nf +\fBvoid matchsolvable(Solvable\fR \fIsolvable\fR\fB, int\fR \fIflags\fR\fB, Id\fR \fIkeyname\fR\fB, Id\fR \fImarker\fR \fB= \-1)\fR +\fI$sel\fR\fB\->matchsolvable(\fR\fI$solvable\fR\fB,\fR \fI$flags\fR\fB,\fR \fI$keyname\fR\fB)\fR; +\fIsel\fR\fB\&.matchsolvable(\fR\fIsolvable\fR\fB,\fR \fIflags\fR\fB,\fR \fIkeyname\fR\fB)\fR +\fIsel\fR\fB\&.matchsolvable(\fR\fIsolvable\fR\fB,\fR \fIflags\fR\fB,\fR \fIkeyname\fR\fB)\fR +.fi +.if n \{\ +.RE +.\} +.sp +Do a matchsolvable operation and combine the result with the current selection\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf \fB\fR my \fI$str\fR \fB=\fR \fI$sel\fR\fB\->str\fR; \fIstr\fR \fB= str(\fR\fIsel\fR\fB)\fR diff --git a/doc/libsolv-bindings.txt b/doc/libsolv-bindings.txt index f3020c54..7b4f5053 100644 --- a/doc/libsolv-bindings.txt +++ b/doc/libsolv-bindings.txt @@ -500,7 +500,7 @@ Filter list of solvables by repo priority, architecture and version. solvables = pool.whatmatchessolvable(keyname, solvable) solvables = pool.whatmatchessolvable(keyname, solvable) -Return all solvables that match package dependencies in against solvable's +Return all solvables that match package dependencies against solvable's provides. Id *matchprovidingids(const char *match, int flags) @@ -591,7 +591,7 @@ Create a selection by matching package dependencies against the specified string This can be used if you want to match other dependency types than ``provides''. Selection matchdepid(DepId dep, int flags, Id keyname, Id marker = -1) - my $sel = $pool->matchdepid(dep, $flags, $keyname); + my $sel = $pool->matchdepid($dep, $flags, $keyname); sel = pool.matchdepid(dep, flags, keyname) sel = pool.matchdepid(dep, flags, keyname) @@ -600,6 +600,14 @@ dependency. This may be faster than matchdeps and also works with complex dependencies. The downside is that you cannot use globs or case insensitive matching. + Selection matchsolvable(Solvable solvable, int flags, Id keyname, Id marker = -1) + my $sel = $pool->matchsolvable($solvable, $flags, $keyname); + sel = pool.matchsolvable(solvable, flags, keyname) + sel = pool.matchsolvable(solvable, flags, keyname) + +Create a selection by matching package dependencies against the specified +solvable's provides. + void setpooljobs(Jobs *jobs) $pool->setpooljobs(\@jobs); pool.setpooljobs(jobs) @@ -1901,6 +1909,13 @@ Do a matchdeps operation and combine the result with the current selection. Do a matchdepid operation and combine the result with the current selection. + void matchsolvable(Solvable solvable, int flags, Id keyname, Id marker = -1) + $sel->matchsolvable($solvable, $flags, $keyname); + sel.matchsolvable(solvable, flags, keyname) + sel.matchsolvable(solvable, flags, keyname) + +Do a matchsolvable operation and combine the result with the current selection. + my $str = $sel->str; str = str(sel) -- 2.47.2