1
0
mirror of https://github.com/openSUSE/libsolv.git synced 2026-02-05 12:45:46 +01:00

Add stringification for the solutionelement class

Also globalize some renames.
This commit is contained in:
Michael Schroeder
2024-03-26 13:05:17 +01:00
parent dd3babbcee
commit ff35f9ebee
5 changed files with 19 additions and 36 deletions

View File

@@ -903,6 +903,9 @@ SWIG_AsValDepId(void *obj, int *val) {
%rename("==") *::__eq__;
%rename("!=") *::__ne__;
#endif
#if defined(SWIGPERL) || defined(SWIGTCL) || defined(SWIGLUA)
%rename("repr") *::__repr__;
#endif
%typemap(in,numinputs=0,noblock=1) XRule **OUTPUT ($*1_ltype temp) {
$1 = &temp;
@@ -1669,9 +1672,6 @@ typedef struct {
const char *__str__() {
return pool_job2str($self->pool, $self->how, $self->what, 0);
}
#if defined(SWIGPERL) || defined(SWIGTCL)
%rename("repr") __repr__;
#endif
const char *__repr__() {
const char *str = pool_job2str($self->pool, $self->how, $self->what, ~0);
return pool_tmpjoin($self->pool, "<Job ", str, ">");
@@ -1802,9 +1802,6 @@ returnself(matchsolvable)
const char *__str__() {
return pool_selection2str($self->pool, &$self->q, 0);
}
#if defined(SWIGPERL) || defined(SWIGTCL)
%rename("repr") __repr__;
#endif
const char *__repr__() {
const char *str = pool_selection2str($self->pool, &$self->q, ~0);
return pool_tmpjoin($self->pool, "<Selection ", str, ">");
@@ -1928,9 +1925,6 @@ returnself(matchsolvable)
solv_free((void *)h);
return str;
}
#if defined(SWIGPERL) || defined(SWIGTCL)
%rename("repr") __repr__;
#endif
%newobject __repr__;
const char *__repr__() {
const char *h = Chksum___str__($self);
@@ -2851,9 +2845,6 @@ returnself(matchsolvable)
sprintf(buf, "Repo#%d", $self->repoid);
return solv_strdup(buf);
}
#if defined(SWIGPERL) || defined(SWIGTCL)
%rename("repr") __repr__;
#endif
%newobject __repr__;
const char *__repr__() {
char buf[20];
@@ -3379,9 +3370,6 @@ returnself(matchsolvable)
const char *__str__() {
return pool_dep2str($self->pool, $self->id);
}
#if defined(SWIGPERL) || defined(SWIGTCL)
%rename("repr") __repr__;
#endif
%newobject __repr__;
const char *__repr__() {
char buf[20];
@@ -3634,9 +3622,6 @@ returnself(matchsolvable)
const char *__str__() {
return pool_solvid2str($self->pool, $self->id);
}
#if defined(SWIGPERL) || defined(SWIGTCL)
%rename("repr") __repr__;
#endif
%newobject __repr__;
const char *__repr__() {
char buf[20];
@@ -3764,9 +3749,13 @@ returnself(matchsolvable)
e->rp = rp;
return e;
}
/* legacy */
const char *str() {
return solver_solutionelementtype2str($self->solv, $self->type, $self->p, $self->rp);
}
const char *__str__() {
return solver_solutionelementtype2str($self->solv, $self->type, $self->p, $self->rp);
}
%typemap(out) Queue replaceelements Queue2Array(Solutionelement *, 1, new_Solutionelement(arg1->solv, arg1->problemid, arg1->solutionid, id, arg1->p, arg1->rp));
%newobject replaceelements;
Queue replaceelements() {
@@ -4348,9 +4337,6 @@ rb_eval_string(
int __hash__() {
return $self->id;
}
#endif
#if defined(SWIGPERL) || defined(SWIGTCL)
%rename("repr") __repr__;
#endif
%newobject __repr__;
const char *__repr__() {
@@ -4514,9 +4500,6 @@ rb_eval_string(
int __hash__() {
return $self->id;
}
#endif
#if defined(SWIGPERL) || defined(SWIGTCL)
%rename("repr") __repr__;
#endif
%newobject __repr__;
const char *__repr__() {

View File

@@ -2,12 +2,12 @@
.\" Title: Libsolv-Bindings
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 03/25/2024
.\" Date: 03/26/2024
.\" Manual: LIBSOLV
.\" Source: libsolv
.\" Language: English
.\"
.TH "LIBSOLV\-BINDINGS" "3" "03/25/2024" "libsolv" "LIBSOLV"
.TH "LIBSOLV\-BINDINGS" "3" "03/26/2024" "libsolv" "LIBSOLV"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -5214,10 +5214,10 @@ Create a job that implements the solution element\&. Add this job to the array o
.RS 4
.\}
.nf
\fBconst char *str()\fR
my \fI$str\fR \fB=\fR \fI$solutionelement\fR\fB\->str()\fR;
\fIstr\fR \fB=\fR \fIsolutionelement\fR\fB\&.str()\fR
\fIstr\fR \fB=\fR \fIsolutionelement\fR\fB\&.str()\fR
\fB<stringification>\fR
my \fI$str\fR \fB=\fR \fI$solutionelement\fR\fB\->str\fR;
\fIstr\fR \fB= str(\fR\fIsolutionelement\fR\fB)\fR
\fIstr\fR \fB=\fR \fIsolutionelement\fR\fB\&.to_s\fR
.fi
.if n \{\
.RE

View File

@@ -3154,10 +3154,10 @@ of jobs for all elements of type different to SOLVER_SOLUTION_JOB and
SOLVER_SOLUTION_POOLJOB. For the latter two, a SOLVER_NOOB Job is created,
you should replace the old job with the new one.
const char *str()
my $str = $solutionelement->str();
str = solutionelement.str()
str = solutionelement.str()
<stringification>
my $str = $solutionelement->str;
str = str(solutionelement)
str = solutionelement.to_s
A string describing the change the solution element consists of.

View File

@@ -538,7 +538,7 @@ while true do
print((" Solution %d:"):format(solution.id))
local elements = solution:elements(true)
for _, element in ipairs(elements) do
print(" - ".. element:str())
print((" - %s"):format(element))
end
print('')
end

View File

@@ -781,7 +781,7 @@ while True:
print(" Solution %d:" % solution.id)
elements = solution.elements(True)
for element in elements:
print(" - %s" % element.str())
print(" - %s" % element)
print('')
sol = ''
while not (sol == 's' or sol == 'q' or (sol.isdigit() and int(sol) >= 1 and int(sol) <= len(solutions))):