]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add stringification for the solutionelement class
authorMichael Schroeder <mls@suse.de>
Tue, 26 Mar 2024 12:05:17 +0000 (13:05 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 27 Mar 2024 10:40:18 +0000 (11:40 +0100)
Also globalize some renames.

bindings/solv.i
doc/gen/libsolv-bindings.3
doc/libsolv-bindings.txt
examples/luasolv
examples/pysolv

index 1cfea38e75fbdd15a7d9fd48f4891c60000a2c94..78745b77f358c2c89449373642617547367b70cc 100644 (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__() {
index db0ea11d73e1c5eea6a2f1331206f87f3ad52dc1..a5f675650825c3fbcf04f22cd083d312ce8107a7 100644 (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
index 361bec55cfdaac6037b6c9227ba095e2745a66f6..d41def8091dda9b20f34fefa68c36f85a81d6d08 100644 (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.
 
index 0e1dc5888589e0bd31e273e5668a27a63c5f3fcc..a2fe5ecc58844613ed74ba46f28f055d409fd59f 100644 (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
index b69234efc5294d4b1c22200827059b2566dceeed..f1827c6cc55e09947072e5053a750e20a05501ca 100755 (executable)
@@ -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))):