Mailinglist Archive: zypp-commit (171 mails)

< Previous Next >
[zypp-commit] <sat-solver> master : Reuse Ruleinfo to explain solver decisions
  • From: Klaus Kämpf <kkaempf@xxxxxxx>
  • Date: Mon, 22 Jun 2009 17:34:18 +0200
  • Message-id: <E1MIlXK-0005Mn-JL@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 668228b80911b8263634d8c397e1807e7ab4f887
Author: Klaus Kämpf <kkaempf@xxxxxxx>
Date: Mon Jun 22 17:34:18 2009 +0200

Reuse Ruleinfo to explain solver decisions
---
bindings/decision.i | 13 +++----------
bindings/problem.i | 19 +------------------
bindings/ruleinfo.i | 17 +++++++++++++++++
bindings/solver.i | 37 -------------------------------------
4 files changed, 21 insertions(+), 65 deletions(-)

diff --git a/bindings/decision.i b/bindings/decision.i
index fd27990..8124aeb 100644
--- a/bindings/decision.i
+++ b/bindings/decision.i
@@ -84,10 +84,10 @@ typedef struct _Decision {} Decision;
/*
* Explain a decision
*
- * returns 4-element Array [<SOLVER_PROBLEM_xxx>, Relation, Solvable,
Solvable]
+ * returns Ruleinfo
*
* call-seq:
- * decision.explain -> [<SOLVER_PROBLEM_xxx>, Relation, Solvable, Solvable]
+ * decision.explain -> Ruleinfo
*
*/
__type explain()
@@ -96,14 +96,7 @@ typedef struct _Decision {} Decision;
Solver *solver = $self->solver;
Id rule = $self->rule - solver->rules;
if (rule > 0) {
- Id depp = 0, sourcep = 0, targetp = 0;
- SolverRuleinfo pi = solver_ruleinfo(solver, rule, &sourcep, &targetp,
&depp);
- result = Swig_Array();
-/* fprintf(stderr, "Rule %d: [pi %d, rel %d, source %d, target %d]\n",
rule, pi, depp, sourcep, targetp); */
- Swig_Append(result, Swig_Int(pi));
- Swig_Append(result, SWIG_NewPointerObj((void*)relation_new(solver->pool,
depp), SWIGTYPE_p__Relation, 0));
- Swig_Append(result,
SWIG_NewPointerObj((void*)xsolvable_new(solver->pool, sourcep),
SWIGTYPE_p__Solvable, 0));
- Swig_Append(result,
SWIG_NewPointerObj((void*)xsolvable_new(solver->pool, targetp),
SWIGTYPE_p__Solvable, 0));
+ result = SWIG_NewPointerObj((void*)ruleinfo_new(solver, rule),
SWIGTYPE_p__Ruleinfo, 0);
}
return result;
}
diff --git a/bindings/problem.i b/bindings/problem.i
index ddfca10..e79dc0d 100644
--- a/bindings/problem.i
+++ b/bindings/problem.i
@@ -51,24 +51,7 @@ typedef struct _Problem {} Problem;


%extend Problem {
-
- %constant int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
- %constant int SOLVER_RULE_RPM_NOT_INSTALLABLE =
SOLVER_RULE_RPM_NOT_INSTALLABLE,
- %constant int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP =
SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP,
- %constant int SOLVER_RULE_RPM_PACKAGE_REQUIRES =
SOLVER_RULE_RPM_PACKAGE_REQUIRES,
- %constant int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT,
- %constant int SOLVER_RULE_RPM_PACKAGE_CONFLICT =
SOLVER_RULE_RPM_PACKAGE_CONFLICT,
- %constant int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME,
- %constant int SOLVER_RULE_RPM_PACKAGE_OBSOLETES =
SOLVER_RULE_RPM_PACKAGE_OBSOLETES,
- %constant int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES =
SOLVER_RULE_RPM_IMPLICIT_OBSOLETES,
- %constant int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE = 0x200,
- %constant int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE = 0x300,
- %constant int SOLVER_RULE_JOB = SOLVER_RULE_JOB = 0x400,
- %constant int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP =
SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
- %constant int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
- %constant int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
- %constant int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
-
+
~Problem()
{ problem_free ($self); }

diff --git a/bindings/ruleinfo.i b/bindings/ruleinfo.i
index 3b535c9..dbde610 100644
--- a/bindings/ruleinfo.i
+++ b/bindings/ruleinfo.i
@@ -16,6 +16,23 @@ typedef struct _Ruleinfo {} Ruleinfo;

%extend Ruleinfo {

+ %constant int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
+ %constant int SOLVER_RULE_RPM_NOT_INSTALLABLE =
SOLVER_RULE_RPM_NOT_INSTALLABLE,
+ %constant int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP =
SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP,
+ %constant int SOLVER_RULE_RPM_PACKAGE_REQUIRES =
SOLVER_RULE_RPM_PACKAGE_REQUIRES,
+ %constant int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT,
+ %constant int SOLVER_RULE_RPM_PACKAGE_CONFLICT =
SOLVER_RULE_RPM_PACKAGE_CONFLICT,
+ %constant int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME,
+ %constant int SOLVER_RULE_RPM_PACKAGE_OBSOLETES =
SOLVER_RULE_RPM_PACKAGE_OBSOLETES,
+ %constant int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES =
SOLVER_RULE_RPM_IMPLICIT_OBSOLETES,
+ %constant int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE = 0x200,
+ %constant int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE = 0x300,
+ %constant int SOLVER_RULE_JOB = SOLVER_RULE_JOB = 0x400,
+ %constant int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP =
SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
+ %constant int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
+ %constant int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
+ %constant int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
+
int command()
{ return $self->cmd; }

diff --git a/bindings/solver.i b/bindings/solver.i
index de991de..e25729f 100644
--- a/bindings/solver.i
+++ b/bindings/solver.i
@@ -742,43 +742,6 @@ typedef struct solver {} Solver;
}

#if defined(SWIGRUBY)
- VALUE
-#endif
-#if defined(SWIGPYTHON)
- PyObject *
-#endif
-#if defined(SWIGPERL)
- SV *
-#endif
- /*
- * Explain a decision
- *
- * returns 4-element Array [<SOLVER_PROBLEM_xxx>, Relation, Solvable,
Solvable]
- *
- * *OBSOLETE*: Use Decision.explain instead
- *
- * call-seq:
- * solver.explain(request, decision) -> [<SOLVER_PROBLEM_xxx>, Relation,
Solvable, Solvable]
- *
- */
- __type explain(Request *unused, Decision *decision)
- {
- Swig_Type result = Swig_Null;
- Id rule = decision->rule - $self->rules;
- if (rule > 0) {
- Id depp = 0, sourcep = 0, targetp = 0;
- SolverRuleinfo pi = solver_ruleinfo($self, rule, &sourcep, &targetp,
&depp);
- result = Swig_Array();
-/* fprintf(stderr, "Rule %d: [pi %d, rel %d, source %d, target %d]\n",
rule, pi, depp, sourcep, targetp); */
- Swig_Append(result, Swig_Int(pi));
- Swig_Append(result, SWIG_NewPointerObj((void*)relation_new($self->pool,
depp), SWIGTYPE_p__Relation, 0));
- Swig_Append(result, SWIG_NewPointerObj((void*)xsolvable_new($self->pool,
sourcep), SWIGTYPE_p__Solvable, 0));
- Swig_Append(result, SWIG_NewPointerObj((void*)xsolvable_new($self->pool,
targetp), SWIGTYPE_p__Solvable, 0));
- }
- return result;
- }
-
-#if defined(SWIGRUBY)
%rename("problems?") problems_found();
%typemap(out) int problems_found
"$result = ($1 != 0) ? Qtrue : Qfalse;";
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages