summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2013-06-04 17:55:34 +0200
committerMichael Schroeder <mls@suse.de>2013-06-04 17:55:34 +0200
commit35fe9fc7beea9290200e2c3301bb5e89f359189d (patch)
treea5774b19c8fc28d38d46a688dcc0536e4e4da637
parent9f6921196d3f4c38d636505326370b8950b6ca2a (diff)
downloadlibsolv-35fe9fc7beea9290200e2c3301bb5e89f359189d.tar.gz
libsolv-35fe9fc7beea9290200e2c3301bb5e89f359189d.tar.bz2
libsolv-35fe9fc7beea9290200e2c3301bb5e89f359189d.zip
Make 'dep' attribute in Ruleinfo return an object, add fromstr/tostr attributes to TransactionClass and remove old fromdep()/todep() methods
-rw-r--r--bindings/solv.i42
-rw-r--r--doc/libsolv-bindings.txt37
-rwxr-xr-xexamples/p5solv6
-rwxr-xr-xexamples/pysolv4
-rwxr-xr-xexamples/rbsolv6
5 files changed, 51 insertions, 44 deletions
diff --git a/bindings/solv.i b/bindings/solv.i
index 8277768..bfdee86 100644
--- a/bindings/solv.i
+++ b/bindings/solv.i
@@ -4,15 +4,6 @@
# on the generated c code
#
-#
-##if defined(SWIGRUBY)
-# %rename("to_s") string();
-##endif
-##if defined(SWIGPYTHON)
-# %rename("__str__") string();
-##endif
-#
-
%module solv
#ifdef SWIGRUBY
@@ -532,7 +523,7 @@ typedef struct {
Id type;
Id source;
Id target;
- Id dep;
+ Id dep_id;
} Ruleinfo;
typedef struct {
@@ -599,7 +590,7 @@ typedef struct {
typedef struct {
Solver* const solv;
Id const type;
- Id const dep;
+ Id const dep_id;
} Ruleinfo;
typedef struct {
@@ -2808,14 +2799,16 @@ rb_eval_string(
transaction_classify_pkgs($self->transaction, $self->mode, $self->type, $self->fromid, $self->toid, &q);
return q;
}
- %newobject fromdep;
- Dep *fromdep() {
- return new_Dep($self->transaction->pool, $self->fromid);
- }
- %newobject todep;
- Dep *todep() {
- return new_Dep($self->transaction->pool, $self->toid);
- }
+ const char * const fromstr;
+ const char * const tostr;
+ %{
+ SWIGINTERN const char *TransactionClass_fromstr_get(TransactionClass *cl) {
+ return pool_id2str(cl->transaction->pool, cl->fromid);
+ }
+ SWIGINTERN const char *TransactionClass_tostr_get(TransactionClass *cl) {
+ return pool_id2str(cl->transaction->pool, cl->toid);
+ }
+ %}
}
%extend XRule {
@@ -2863,20 +2856,22 @@ rb_eval_string(
}
%extend Ruleinfo {
- Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep) {
+ Ruleinfo(XRule *r, Id type, Id source, Id target, Id dep_id) {
Ruleinfo *ri = solv_calloc(1, sizeof(*ri));
ri->solv = r->solv;
ri->rid = r->id;
ri->type = type;
ri->source = source;
ri->target = target;
- ri->dep = dep;
+ ri->dep_id = dep_id;
return ri;
}
%newobject solvable;
XSolvable * const solvable;
%newobject othersolvable;
XSolvable * const othersolvable;
+ %newobject dep;
+ Dep * const dep;
%{
SWIGINTERN XSolvable *Ruleinfo_solvable_get(Ruleinfo *ri) {
return new_XSolvable(ri->solv->pool, ri->source);
@@ -2884,9 +2879,12 @@ rb_eval_string(
SWIGINTERN XSolvable *Ruleinfo_othersolvable_get(Ruleinfo *ri) {
return new_XSolvable(ri->solv->pool, ri->target);
}
+ SWIGINTERN Dep *Ruleinfo_dep_get(Ruleinfo *ri) {
+ return new_Dep(ri->solv->pool, ri->dep_id);
+ }
%}
const char *problemstr() {
- return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep);
+ return solver_problemruleinfo2str($self->solv, $self->type, $self->source, $self->target, $self->dep_id);
}
}
diff --git a/doc/libsolv-bindings.txt b/doc/libsolv-bindings.txt
index 70f3b8d..0310ce9 100644
--- a/doc/libsolv-bindings.txt
+++ b/doc/libsolv-bindings.txt
@@ -2159,12 +2159,19 @@ Back pointer to solver object.
The type of the ruleinfo. See the constant section of the solver class for the
rule type list and the special type list.
- Id dep; /* read only */
+ Dep *dep; /* read only */
$ruleinfo->{'dep'}
ruleinfo.dep
ruleinfo.dep
-The id of the dependency leading to the creation of the rule, or zero.
+The dependency leading to the creation of the rule.
+
+ Dep *dep_id; /* read only */
+ $ruleinfo->{'dep_id'}
+ ruleinfo.dep_id
+ ruleinfo.dep_id
+
+The Id of the dependency leading to the creation of the rule, or zero.
Solvable *solvable; /* read only */
$ruleinfo->{'solvable'}
@@ -2619,6 +2626,20 @@ The type of the transaction elements in the class.
The number of elements in the class.
+ const char *fromstr;
+ $class->{'fromstr'}
+ class.fromstr
+ class.fromstr
+
+The old vendor or architecture.
+
+ const char *tostr;
+ $class->{'tostr'}
+ class.tostr
+ class.tostr
+
+The new vendor or architecture.
+
Id fromid;
$class->{'fromid'}
class.fromid
@@ -2642,18 +2663,6 @@ The id of the new vendor or architecture.
Return the solvables for all transaction elements in the class.
- Dep *fromdep();
- my $from = $class->fromdep();
- from = class.fromdep();
- from = class.fromdep();
-
- Dep *todep();
- my $from = $class->todep();
- from = class.todep();
- from = class.todep();
-
-The id of the vendor or architecture in Dep object form.
-
CHECKSUMS
---------
Checksums (also called hashes) are used to make sure that downloaded data is
diff --git a/examples/p5solv b/examples/p5solv
index 5c25954..2e3e3ed 100755
--- a/examples/p5solv
+++ b/examples/p5solv
@@ -681,9 +681,9 @@ for my $c ($trans->classify($solv::Transaction::SOLVER_TRANSACTION_SHOW_OBSOLETE
} elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_UPGRADED) {
print "$c->{'count'} upgraded packages:\n";
} elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_VENDORCHANGE) {
- printf "$c->{'count'} vendor changes from '%s' to '%s':\n", $c->fromdep()->str(), $c->todep()->str();
+ printf "$c->{'count'} vendor changes from '%s' to '%s':\n", $c->{'fromstr'}, $c->{'tostr'};
} elsif ($c->{'type'} == $solv::Transaction::SOLVER_TRANSACTION_ARCHCHANGE) {
- printf "$c->{'count'} arch changes from '%s' to '%s':\n", $c->fromdep()->str(), $c->todep()->str();
+ printf "$c->{'count'} arch changes from '%s' to '%s':\n", $c->{'fromstr'}->str(), $c->{'tostr'};
} else {
next;
}
@@ -729,7 +729,7 @@ if (@newpkgs) {
}
print "Committing transaction:\n\n";
-$trans->order(0);
+$trans->order();
for my $p ($trans->steps()) {
my $steptype = $trans->steptype($p, $solv::Transaction::SOLVER_TRANSACTION_RPM_ONLY);
if ($steptype == $solv::Transaction::SOLVER_TRANSACTION_ERASE) {
diff --git a/examples/pysolv b/examples/pysolv
index f300d08..98dfec1 100755
--- a/examples/pysolv
+++ b/examples/pysolv
@@ -814,9 +814,9 @@ for cl in trans.classify(solv.Transaction.SOLVER_TRANSACTION_SHOW_OBSOLETES | so
elif cl.type == solv.Transaction.SOLVER_TRANSACTION_UPGRADED:
print "%d upgraded packages:" % cl.count
elif cl.type == solv.Transaction.SOLVER_TRANSACTION_VENDORCHANGE:
- print "%d vendor changes from '%s' to '%s':" % (cl.count, cl.fromdep(), cl.todep())
+ print "%d vendor changes from '%s' to '%s':" % (cl.count, cl.fromstr, cl.tostr)
elif cl.type == solv.Transaction.SOLVER_TRANSACTION_ARCHCHANGE:
- print "%d arch changes from '%s' to '%s':" % (cl.count, cl.fromdep(), cl.todep())
+ print "%d arch changes from '%s' to '%s':" % (cl.count, cl.fromstr, cl.tostr)
else:
continue
for p in cl.solvables():
diff --git a/examples/rbsolv b/examples/rbsolv
index e011010..e10e0fd 100755
--- a/examples/rbsolv
+++ b/examples/rbsolv
@@ -695,9 +695,9 @@ for cl in trans.classify(Solv::Transaction::SOLVER_TRANSACTION_SHOW_OBSOLETES |
elsif cl.type == Solv::Transaction::SOLVER_TRANSACTION_UPGRADED
puts "#{cl.count} upgraded packages:"
elsif cl.type == Solv::Transaction::SOLVER_TRANSACTION_VENDORCHANGE
- puts "#{cl.count} vendor changes from '#{cl.fromdep}' to '#{cl.todep}':"
+ puts "#{cl.count} vendor changes from '#{cl.fromstr}' to '#{cl.tostr}':"
elsif cl.type == Solv::Transaction::SOLVER_TRANSACTION_ARCHCHANGE
- puts "#{cl.count} arch changes from '#{cl.fromdep}' to '#{cl.todep}':"
+ puts "#{cl.count} arch changes from '#{cl.fromstr}' to '#{cl.tostr}':"
else
next
end
@@ -745,7 +745,7 @@ end
puts "Committing transaction:"
puts
-trans.order(0)
+trans.order()
for p in trans.steps
steptype = trans.steptype(p, Solv::Transaction::SOLVER_TRANSACTION_RPM_ONLY)
if steptype == Solv::Transaction::SOLVER_TRANSACTION_ERASE