Skip to content

Commit 693dd20

Browse files
authored
Merge pull request #298 from ignatenkobrain/bindings
bindings: Add best_solvables/whatmatchessolvable
2 parents 6ba90b5 + 8bb3b58 commit 693dd20

3 files changed

Lines changed: 84 additions & 13 deletions

File tree

bindings/solv.i

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ typedef struct {
381381

382382
%typemap(in) Queue Array2Queue(SWIG_AsVal_int, "integers")
383383
%typemap(in) Queue solvejobs ObjArray2Queue(Job *, queue_push2(&$1, obj->how, obj->what))
384+
%typemap(in) Queue solvables ObjArray2Queue(XSolvable *, queue_push(&$1, obj->id))
384385

385386

386387

@@ -662,6 +663,12 @@ SWIG_AsValDepId(void *obj, int *val) {
662663
%typemaps_asval(%checkcode(POINTER), SWIG_AsValSolvFpPtr, "SWIG_AsValSolvFpPtr", FILE*);
663664
%typemaps_asval(%checkcode(INT32), SWIG_AsValDepId, "SWIG_AsValDepId", DepId);
664665

666+
%define SamePool(pool1,pool2) %{ {
667+
if (pool1 != pool2)
668+
SWIG_exception_fail(SWIG_ArgError(EINVAL), "pool of argument $argnum must be same as pool in method's object");
669+
}
670+
%}
671+
%enddef
665672

666673
/**
667674
** the C declarations
@@ -1066,10 +1073,12 @@ typedef struct {
10661073
Id what;
10671074
} Job;
10681075

1076+
%typemap(check) XSolvable *pool_solvable SamePool($1->pool, arg1)
10691077
%nodefaultctor Pool;
10701078
%nodefaultdtor Pool;
10711079
typedef struct {
10721080
} Pool;
1081+
%typemap(check) XSolvable *pool_solvable;
10731082

10741083
%nodefaultctor Repo;
10751084
%nodefaultdtor Repo;
@@ -1945,6 +1954,14 @@ typedef struct {
19451954
queue_push(&q, p);
19461955
return q;
19471956
}
1957+
%typemap(out) Queue best_solvables Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
1958+
%newobject best_solvables;
1959+
Queue best_solvables(Queue solvables, int flags=0) {
1960+
Queue q;
1961+
queue_init_clone(&q, &solvables);
1962+
pool_best_solvables($self, &q, flags);
1963+
return q;
1964+
}
19481965

19491966
Id towhatprovides(Queue q) {
19501967
return pool_queuetowhatprovides($self, &q);
@@ -1969,6 +1986,15 @@ typedef struct {
19691986
return q;
19701987
}
19711988

1989+
%typemap(out) Queue whatmatchessolvable Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
1990+
%newobject whatmatchessolvable;
1991+
Queue whatmatchessolvable(Id keyname, XSolvable *pool_solvable, Id marker = -1) {
1992+
Queue q;
1993+
queue_init(&q);
1994+
pool_whatmatchessolvable($self, keyname, pool_solvable->id, &q, marker);
1995+
return q;
1996+
}
1997+
19721998
#ifdef SWIGRUBY
19731999
%rename("isknownarch?") isknownarch;
19742000
#endif

doc/gen/libsolv-bindings.3

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
.\" Title: Libsolv-Bindings
33
.\" Author: [see the "Author" section]
44
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5-
.\" Date: 12/06/2018
5+
.\" Date: 02/13/2019
66
.\" Manual: LIBSOLV
77
.\" Source: libsolv
88
.\" Language: English
99
.\"
10-
.TH "LIBSOLV\-BINDINGS" "3" "12/06/2018" "libsolv" "LIBSOLV"
10+
.TH "LIBSOLV\-BINDINGS" "3" "02/13/2019" "libsolv" "LIBSOLV"
1111
.\" -----------------------------------------------------------------
1212
.\" * Define some portability stuff
1313
.\" -----------------------------------------------------------------
@@ -851,6 +851,36 @@ Return all solvables that provide the specified dependency\&. You can use either
851851
.RS 4
852852
.\}
853853
.nf
854+
\fBSolvable *best_solvables(Solvable *\fR\fIsolvables\fR\fB, int\fR \fIflags\fR \fB= 0)\fR
855+
my \fI@solvables\fR \fB=\fR \fI$pool\fR\fB\->best_solvables(\fR\fI$solvables\fR\fB)\fR;
856+
\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.best_solvables(\fR\fIsolvables\fR\fB)\fR
857+
\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.best_solvables(\fR\fIsolvables\fR\fB)\fR
858+
.fi
859+
.if n \{\
860+
.RE
861+
.\}
862+
.sp
863+
Filter list of solvables by repo priority, architecture and version\&.
864+
.sp
865+
.if n \{\
866+
.RS 4
867+
.\}
868+
.nf
869+
\fBSolvable *whatmatchessolvable(Id\fR \fIkeyname\fR\fB, Solvable\fR \fIsolvable\fR\fB, Id\fR \fImarker\fR \fB= \-1)\fR
870+
my \fI@solvables\fR \fB=\fR \fI$pool\fR\fB\->whatmatchessolvable(\fR\fI$keyname\fR\fB,\fR \fI$solvable\fR\fB)\fR
871+
\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.whatmatchessolvable(\fR\fIkeyname\fR\fB,\fR \fIsolvable\fR\fB)\fR
872+
\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.whatmatchessolvable(\fR\fIkeyname\fR\fB,\fR \fIsolvable\fR\fB)\fR
873+
.fi
874+
.if n \{\
875+
.RE
876+
.\}
877+
.sp
878+
Return all solvables that match package dependencies in against solvable\(cqs provides\&.
879+
.sp
880+
.if n \{\
881+
.RS 4
882+
.\}
883+
.nf
854884
\fBId *matchprovidingids(const char *\fR\fImatch\fR\fB, int\fR \fIflags\fR\fB)\fR
855885
my \fI@ids\fR \fB=\fR \fI$pool\fR\fB\->matchprovidingids(\fR\fI$match\fR\fB,\fR \fI$flags\fR\fB)\fR;
856886
\fIids\fR \fB=\fR \fIpool\fR\fB\&.matchprovidingids(\fR\fImatch\fR\fB,\fR \fIflags\fR\fB)\fR

doc/libsolv-bindings.txt

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ natural constant subs), so don't forget the leading ``$'' when accessing a
5959
constant. Also do not forget to prepend the namespace of the constant:
6060

6161
$pool->set_flag($solv::Pool::POOL_FLAG_OBSOLETEUSESCOLORS, 1);
62-
62+
6363

6464
Python Specifics
6565
----------------
@@ -185,7 +185,7 @@ to a libsolv class are prefixed with the class name:
185185
186186
TCL $pool set_flag $solv::Pool_POOL_FLAG_OBSOLETEUSESCOLORS 1
187187
TCL puts [$solvable lookup_str $solv::SOLVABLE_SUMMARY]
188-
188+
189189
190190
The Solv Class
191191
--------------
@@ -248,7 +248,7 @@ Repositories, Dependencies, each indexed by Ids.
248248
pool = Solv::Pool.new()
249249
250250
Create a new pool instance. In most cases you just need one pool.
251-
Note that the returned object "owns" the pool, i.e. if the object is
251+
Note that the returned object "owns" the pool, i.e. if the object is
252252
freed, the pool is also freed. You can use the disown method to
253253
break this ownership relation.
254254
@@ -488,6 +488,21 @@ the call to addfileprovides().
488488
Return all solvables that provide the specified dependency. You can use either
489489
a Dep object or a simple Id as argument.
490490
491+
Solvable *best_solvables(Solvable *solvables, int flags = 0)
492+
my @solvables = $pool->best_solvables($solvables);
493+
solvables = pool.best_solvables(solvables)
494+
solvables = pool.best_solvables(solvables)
495+
496+
Filter list of solvables by repo priority, architecture and version.
497+
498+
Solvable *whatmatchessolvable(Id keyname, Solvable solvable, Id marker = -1)
499+
my @solvables = $pool->whatmatchessolvable($keyname, $solvable)
500+
solvables = pool.whatmatchessolvable(keyname, solvable)
501+
solvables = pool.whatmatchessolvable(keyname, solvable)
502+
503+
Return all solvables that match package dependencies in against solvable's
504+
provides.
505+
491506
Id *matchprovidingids(const char *match, int flags)
492507
my @ids = $pool->matchprovidingids($match, $flags);
493508
ids = pool.matchprovidingids(match, flags)
@@ -554,7 +569,7 @@ selections.
554569
my $sel = $pool->Selection_all();
555570
sel = pool.Selection_all()
556571
sel = pool.Selection_all()
557-
572+
558573
Create a selection containing all packages. Useful as starting point for
559574
intersecting other selections or for update/distupgrade jobs.
560575
@@ -860,7 +875,7 @@ The id of the repository.
860875
$repo->{name}
861876
repo.name
862877
repo.name
863-
878+
864879
The repositories name. To libsolv, the name is just a string with no specific
865880
meaning.
866881
@@ -1371,7 +1386,7 @@ a specific id and want to avoid the string compare overhead.
13711386
my @deps = $solvable->lookup_deparray($keyname);
13721387
deps = solvable.lookup_deparray(keyname)
13731388
deps = solvable.lookup_deparray(keyname)
1374-
1389+
13751390
Generic lookup methods. Retrieve data stored for the specific keyname.
13761391
The lookup_idarray() method will return an array of Ids, use
13771392
lookup_deparray if you want an array of Dependency objects instead.
@@ -1719,7 +1734,7 @@ the version, and the architecture of a package.
17191734
*SELECTION_DOTARCH*::
17201735
Allow an ".<architecture>" suffix when matching names or
17211736
provides.
1722-
1737+
17231738
*SELECTION_REL*::
17241739
Allow the specification of a relation when matching names
17251740
or dependencies, e.g. "name >= 1.2".
@@ -1945,7 +1960,7 @@ Update the matching installed packages to their best version. If none
19451960
of the specified packages are installed, try to update the installed
19461961
packages to the specified versions. See the section about targeted
19471962
updates about more information.
1948-
1963+
19491964
*SOLVER_WEAKENDEPS*::
19501965
Allow to break the dependencies of the matching packages. Handle with care.
19511966

@@ -3164,7 +3179,7 @@ in passive mode, but
31643179
update A-2-1 (other: A-1-1)
31653180
erase B
31663181
3167-
in active mode. If the mode contains SOLVER_TRANSACTION_SHOW_ALL, the
3182+
in active mode. If the mode contains SOLVER_TRANSACTION_SHOW_ALL, the
31683183
passive mode list will be unchanged but the active mode list will just
31693184
contain A-2-1.
31703185
@@ -3290,7 +3305,7 @@ Add a (binary) string to the checksum.
32903305
chksum.add_fp(file)
32913306
32923307
Add the contents of a file to the checksum.
3293-
3308+
32943309
void add_stat(const char *filename)
32953310
$chksum->add_stat($filename);
32963311
chksum.add_stat(filename)
@@ -3422,7 +3437,7 @@ The Repodata Class
34223437
The Repodata stores attributes for packages and the repository itself, each
34233438
repository can have multiple repodata areas. You normally only need to
34243439
directly access them if you implement lazy downloading of repository data.
3425-
Repodata areas are created by calling the repository's add_repodata() method
3440+
Repodata areas are created by calling the repository's add_repodata() method
34263441
or by using repo_add methods without the REPO_REUSE_REPODATA or REPO_USE_LOADING
34273442
flag.
34283443

0 commit comments

Comments
 (0)