From: Michael Schroeder Date: Tue, 26 Mar 2024 12:05:17 +0000 (+0100) Subject: Add stringification for the solutionelement class X-Git-Tag: 0.7.29~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff35f9ebee3ddf3a2e3e75d556e19822fd5e975e;p=thirdparty%2Flibsolv.git Add stringification for the solutionelement class Also globalize some renames. --- diff --git a/bindings/solv.i b/bindings/solv.i index 1cfea38e..78745b77 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -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, ""); @@ -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, ""); @@ -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__() { diff --git a/doc/gen/libsolv-bindings.3 b/doc/gen/libsolv-bindings.3 index db0ea11d..a5f67565 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: 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\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 diff --git a/doc/libsolv-bindings.txt b/doc/libsolv-bindings.txt index 361bec55..d41def80 100644 --- a/doc/libsolv-bindings.txt +++ b/doc/libsolv-bindings.txt @@ -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() + + my $str = $solutionelement->str; + str = str(solutionelement) + str = solutionelement.to_s A string describing the change the solution element consists of. diff --git a/examples/luasolv b/examples/luasolv index 0e1dc588..a2fe5ecc 100644 --- a/examples/luasolv +++ b/examples/luasolv @@ -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 diff --git a/examples/pysolv b/examples/pysolv index b69234ef..f1827c6c 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -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))):