-#
-# WARNING: for perl iterator/array support you need to run
-# sed -i -e 's/SvTYPE(tsv) == SVt_PVHV/SvTYPE(tsv) == SVt_PVHV || SvTYPE(tsv) == SVt_PVAV/'
-# on the generated c code
-#
+/*
+ * WARNING: for perl iterator/array support you need to run
+ * sed -i -e 's/SvTYPE(tsv) == SVt_PVHV/SvTYPE(tsv) == SVt_PVHV || SvTYPE(tsv) == SVt_PVAV/'
+ * on the generated c code
+ */
%module solv
%markfunc Pool "mark_Pool";
#endif
-#
-# binaryblob handling
-#
+/*
+ * binaryblob handling
+ */
%{
typedef struct {
queue_push(&$1, v);
}
}
-# AV *o = newAV();
-# av_push(o, SvREFCNT_inc(SWIG_From_int($1.elements[i])));
-# $result = newRV_noinc((SV*)o); argvi++;
-#
+/* AV *o = newAV();
+ * av_push(o, SvREFCNT_inc(SWIG_From_int($1.elements[i])));
+ * $result = newRV_noinc((SV*)o); argvi++;
+ */
%typemap(out) Queue {
int i;
if (argvi + $1.count + 1 >= items) {
#if defined(SWIGPERL)
-# work around a swig bug
+/* work around a swig bug */
%{
#undef SWIG_CALLXS
#ifdef PERL_OBJECT
#ifdef ENABLE_ARCHREPO
#include "repo_arch.h"
#endif
+#ifdef SUSE
+#include "repo_autopattern.h"
+#endif
#include "solv_xfopen.h"
/* for old ruby versions */
} Ruleinfo;
typedef struct {
+ Solver *solv;
+ Id type;
+ Id rid;
+ Id from_id;
+ Id dep_id;
+ Id chosen_id;
+ Queue choices;
+ int level;
+} Alternative;
+
+typedef struct {
Transaction *transaction;
int mode;
Id type;
%include "knownid.h"
-# from repodata.h
+/* from repodata.h */
%constant Id SOLVID_META;
%constant Id SOLVID_POS;
Id const id;
} Dep;
-# put before pool/repo so we can access the constructor
+/* put before pool/repo so we can access the constructor */
%nodefaultdtor Dataiterator;
typedef struct {} Dataiterator;
Id const type;
} Solutionelement;
+%nodefaultctor Alternative;
+typedef struct {
+ Solver *const solv;
+ Id const type;
+ Id const rid;
+ Id const from_id;
+ Id const dep_id;
+ Id const chosen_id;
+ int level;
+} Alternative;
+
%nodefaultctor Transaction;
%nodefaultdtor Transaction;
typedef struct {
return pool_queuetowhatprovides($self, &q);
}
+ %typemap(out) Queue whatmatchesdep Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id));
+ %newobject whatmatchesdep;
+ Queue whatmatchesdep(Id keyname, DepId dep, Id marker = -1) {
+ Queue q;
+ queue_init(&q);
+ pool_whatmatchesdep($self, keyname, dep, &q, marker);
+ return q;
+ }
+
#ifdef SWIGRUBY
%rename("isknownarch?") isknownarch;
#endif
return new_XSolvable($self->pool, repo_add_arch_pkg($self, name, flags));
}
#endif
+#ifdef SUSE
+ bool add_autopattern(int flags = 0) {
+ return repo_add_autopattern($self, flags) == 0;
+ }
+#endif
void internalize() {
repo_internalize($self);
}
bool write(FILE *fp) {
return repo_write($self, fp) == 0;
}
- # HACK, remove if no longer needed!
+ /* HACK, remove if no longer needed! */
bool write_first_repodata(FILE *fp) {
int oldnrepodata = $self->nrepodata;
int res;
#endif
const char *__str__() {
KeyValue kv = $self->kv;
- if (!repodata_stringify($self->pool, $self->data, $self->key, &kv, SEARCH_FILES | SEARCH_CHECKSUMS))
- return "";
- return kv.str;
+ const char *str = repodata_stringify($self->pool, $self->data, $self->key, &kv, SEARCH_FILES | SEARCH_CHECKSUMS);
+ return str ? str : "";
}
}
%extend Solver {
static const int SOLVER_RULE_UNKNOWN = SOLVER_RULE_UNKNOWN;
- static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
- static const int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
- static const int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
- static const int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
- static const int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
- static const int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
- static const int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
- static const int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
- static const int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
- static const int SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES = SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES;
+ static const int SOLVER_RULE_PKG = SOLVER_RULE_PKG;
+ static const int SOLVER_RULE_PKG_NOT_INSTALLABLE = SOLVER_RULE_PKG_NOT_INSTALLABLE;
+ static const int SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP = SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP;
+ static const int SOLVER_RULE_PKG_REQUIRES = SOLVER_RULE_PKG_REQUIRES;
+ static const int SOLVER_RULE_PKG_SELF_CONFLICT = SOLVER_RULE_PKG_SELF_CONFLICT;
+ static const int SOLVER_RULE_PKG_CONFLICTS = SOLVER_RULE_PKG_CONFLICTS;
+ static const int SOLVER_RULE_PKG_SAME_NAME = SOLVER_RULE_PKG_SAME_NAME;
+ static const int SOLVER_RULE_PKG_OBSOLETES = SOLVER_RULE_PKG_OBSOLETES;
+ static const int SOLVER_RULE_PKG_IMPLICIT_OBSOLETES = SOLVER_RULE_PKG_IMPLICIT_OBSOLETES;
+ static const int SOLVER_RULE_PKG_INSTALLED_OBSOLETES = SOLVER_RULE_PKG_INSTALLED_OBSOLETES;
static const int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
static const int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
static const int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
static const int SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE = SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE;
static const int SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE = SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE;
static const int SOLVER_FLAG_DUP_ALLOW_NAMECHANGE = SOLVER_FLAG_DUP_ALLOW_NAMECHANGE;
+ static const int SOLVER_FLAG_KEEP_ORPHANS = SOLVER_FLAG_KEEP_ORPHANS;
+ static const int SOLVER_FLAG_BREAK_ORPHANS = SOLVER_FLAG_BREAK_ORPHANS;
+ static const int SOLVER_FLAG_FOCUS_INSTALLED = SOLVER_FLAG_FOCUS_INSTALLED;
+ static const int SOLVER_FLAG_YUM_OBSOLETES = SOLVER_FLAG_YUM_OBSOLETES;
static const int SOLVER_REASON_UNRELATED = SOLVER_REASON_UNRELATED;
static const int SOLVER_REASON_UNIT_RULE = SOLVER_REASON_UNIT_RULE;
static const int SOLVER_REASON_RECOMMENDED = SOLVER_REASON_RECOMMENDED;
static const int SOLVER_REASON_SUPPLEMENTED = SOLVER_REASON_SUPPLEMENTED;
+ /* legacy */
+ static const int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
+
~Solver() {
solver_free($self);
}
*OUTPUT = new_XRule($self, ruleid);
return reason;
}
+
+ int alternatives_count() {
+ return solver_alternatives_count($self);
+ }
+
+ %newobject alternative;
+ Alternative *alternative(Id aid) {
+ Alternative *a = solv_calloc(1, sizeof(*a));
+ a->solv = $self;
+ queue_init(&a->choices);
+ a->type = solver_get_alternative($self, aid, &a->dep_id, &a->from_id, &a->chosen_id, &a->choices, &a->level);
+ if (!a->type) {
+ queue_free(&a->choices);
+ solv_free(a);
+ return 0;
+ }
+ if (a->type == SOLVER_ALTERNATIVE_TYPE_RULE) {
+ a->rid = a->dep_id;
+ a->dep_id = 0;
+ }
+ return a;
+ }
+
+ %typemap(out) Queue all_alternatives Queue2Array(Alternative *, 1, Solver_alternative(arg1, id));
+ %newobject all_alternatives;
+ Queue all_alternatives() {
+ Queue q;
+ int i, cnt;
+ queue_init(&q);
+ cnt = solver_alternatives_count($self);
+ for (i = 1; i <= cnt; i++)
+ queue_push(&q, i);
+ return q;
+ }
}
%extend Transaction {
return q;
}
- # deprecated, use newsolvables instead
+ /* deprecated, use newsolvables instead */
%typemap(out) Queue newpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
%newobject newpackages;
Queue newpackages() {
return q;
}
- # deprecated, use keptsolvables instead
+ /* deprecated, use keptsolvables instead */
%typemap(out) Queue keptpackages Queue2Array(XSolvable *, 1, new_XSolvable(arg1->pool, id));
%newobject keptpackages;
Queue keptpackages() {
#endif
}
#endif
+
+%extend Alternative {
+ static const int SOLVER_ALTERNATIVE_TYPE_RULE = SOLVER_ALTERNATIVE_TYPE_RULE;
+ static const int SOLVER_ALTERNATIVE_TYPE_RECOMMENDS = SOLVER_ALTERNATIVE_TYPE_RECOMMENDS;
+ static const int SOLVER_ALTERNATIVE_TYPE_SUGGESTS = SOLVER_ALTERNATIVE_TYPE_SUGGESTS;
+
+ ~Alternative() {
+ queue_free(&$self->choices);
+ solv_free($self);
+ }
+ %newobject chosen;
+ XSolvable * const chosen;
+ %newobject rule;
+ XRule * const rule;
+ %newobject depsolvable;
+ XSolvable * const depsolvable;
+ %newobject dep;
+ Dep * const dep;
+ %{
+ SWIGINTERN XSolvable *Alternative_chosen_get(Alternative *a) {
+ return new_XSolvable(a->solv->pool, a->chosen_id);
+ }
+ SWIGINTERN XRule *Alternative_rule_get(Alternative *a) {
+ return new_XRule(a->solv, a->rid);
+ }
+ SWIGINTERN XSolvable *Alternative_depsolvable_get(Alternative *a) {
+ return new_XSolvable(a->solv->pool, a->from_id);
+ }
+ SWIGINTERN Dep *Alternative_dep_get(Alternative *a) {
+ return new_Dep(a->solv->pool, a->dep_id);
+ }
+ %}
+
+ Queue choices_raw() {
+ Queue r;
+ queue_init_clone(&r, &$self->choices);
+ return r;
+ }
+
+ %typemap(out) Queue choices Queue2Array(XSolvable *, 1, new_XSolvable(arg1->solv->pool, id));
+ Queue choices() {
+ int i;
+ Queue r;
+ queue_init_clone(&r, &$self->choices);
+ for (i = 0; i < r.count; i++)
+ if (r.elements[i] < 0)
+ r.elements[i] = -r.elements[i];
+ return r;
+ }
+
+#if defined(SWIGPERL)
+ %rename("str") __str__;
+#endif
+ const char *__str__() {
+ return solver_alternative2str($self->solv, $self->type, $self->type == SOLVER_ALTERNATIVE_TYPE_RULE ? $self->rid : $self->dep_id, $self->from_id);
+ }
+}