Mailinglist Archive: zypp-commit (301 mails)

< Previous Next >
[zypp-commit] r7655 - in /trunk/sat-solver/bindings: ruby/satsolver.rb satsolver.i
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Fri, 26 Oct 2007 13:57:19 -0000
  • Message-id: <20071026135720.1B76B17375@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Fri Oct 26 15:57:19 2007
New Revision: 7655

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7655&view=rev
Log:
- ok, basc stuff working

Modified:
trunk/sat-solver/bindings/ruby/satsolver.rb
trunk/sat-solver/bindings/satsolver.i

Modified: trunk/sat-solver/bindings/ruby/satsolver.rb
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/satsolver.rb?rev=7655&r1=7654&r2=7655&view=diff
==============================================================================
--- trunk/sat-solver/bindings/ruby/satsolver.rb (original)
+++ trunk/sat-solver/bindings/ruby/satsolver.rb Fri Oct 26 15:57:19 2007
@@ -1,5 +1,5 @@
require 'satsolverx'

module Satsolver
- include Satsolverx
+include Satsolverx
end
\ No newline at end of file

Modified: trunk/sat-solver/bindings/satsolver.i
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/satsolver.i?rev=7655&r1=7654&r2=7655&view=diff
==============================================================================
--- trunk/sat-solver/bindings/satsolver.i (original)
+++ trunk/sat-solver/bindings/satsolver.i Fri Oct 26 15:57:19 2007
@@ -49,16 +49,65 @@
%include "pool.h"
%extend _Pool {

+ _Pool()
+ { return pool_create(); }
+
+ ~_Pool()
+ { pool_free($self); }
+
+ void set_arch(const char *arch)
+ { pool_setarch($self, arch); }
+
int installable(Solvable *s)
{ return pool_installable($self,s); }

void prepare()
{ pool_prepare($self);}

- void each_source()
+ void each_source()
{
+ for (int i = 0; i < $self->nsources; ++i )
+ rb_yield(SWIG_NewPointerObj((void*) $self->sources[i],
SWIGTYPE_p__Source, 0));
}
-
+
+ Solvable *
+ select_solvable(Source *source, char *name)
+ {
+ Id id;
+ Queue plist;
+ int i, end;
+ Solvable *s;
+ Pool *pool;
+
+ pool = $self;
+ id = str2id(pool, name, 1);
+ queueinit( &plist);
+ i = source ? source->start : 1;
+ end = source ? source->start + source->nsolvables : pool->nsolvables;
+ for (; i < end; i++)
+ {
+ s = pool->solvables + i;
+ if (!pool_installable(pool, s))
+ continue;
+ if (s->name == id)
+ queuepush(&plist, i);
+ }
+
+ prune_best_version_arch(pool, &plist);
+
+ if (plist.count == 0)
+ {
+ printf("unknown package '%s'\n", name);
+ exit(1);
+ }
+
+ id = plist.elements[0];
+ queuefree(&plist);
+
+ return pool->solvables + id;
+ }
+
+
Source* add_empty_source()
{
return pool_addsource_empty($self);
@@ -73,7 +122,42 @@

%include "poolid.h"
%include "pooltypes.h"
+
%include "queue.h"
+
+%extend Queue {
+
+ Queue()
+ { Queue *q = new Queue(); queueinit(q); return q; }
+
+ ~Queue()
+ { queuefree($self); }
+
+ Queue* clone()
+ { Queue *t; clonequeue(t, $self); return t; }
+
+ Id shift()
+ { return queueshift($self); }
+
+ void push(Id id)
+ { /*printf("push id\n");*/ queuepush($self, id); }
+
+ void push( Solvable *s )
+ { /*printf("push solvable\n");*/ queuepush($self, (s -
s->source->pool->solvables)); }
+
+ void push_unique(Id id)
+ { queuepushunique($self, id); }
+
+ %rename("empty?") empty();
+ bool empty()
+ { return ($self->count == 0); }
+
+ void clear()
+ { QUEUEEMPTY($self); }
+};
+%newobject queueinit;
+%delobject queuefree;
+
%include "solvable.h"

%extend Solvable {
@@ -87,16 +171,36 @@
//}

//%rename(name_id) name();
+ %ignore name;
const char * name()
{ return id2str($self->source->pool, $self->name);}

}

%include "solver.h"
+
+%extend Solver {
+
+ Solver( Pool *pool, Source *system ) { return solver_create(pool, system); }
+ ~Solver() { solver_free($self); }
+
+ %rename("fix_system") fixsystem;
+ %rename("update_system") updatesystem;
+ %rename("allow_downgrade") allowdowngrade;
+ %rename("allow_uninstall") allowuninstall;
+ %rename("no_update_provide") noupdateprovide;
+
+ void solve(Queue *job) { solve($self, job); }
+ void print_decisions() { printdecisions($self); }
+};
+
%include "source.h"

+%nodefaultdtor Source;
%extend Source {

+ const char *name() { return source_name($self); }
+
void each_solvable()
{
int i, endof;

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages