ref: refs/heads/master
commit ff13681f6b91cb3d7af39be703ebe681f6cfa323
Author: Michael Schroeder
Date: Fri May 15 17:04:18 2009 +0200
- rename applayer's transaction to request to make it compile
(I would prefer job, but job is already taken.
Let Klaus decide.)
---
applayer/request.c | 127 ++++++++++++++++++++++++++
applayer/request.h | 41 +++++++++
applayer/transaction.c | 127 --------------------------
applayer/transaction.h | 41 ---------
bindings/request.i | 176 ++++++++++++++++++++++++++++++++++++
bindings/ruby/tests/request.rb | 42 +++++++++
bindings/ruby/tests/transaction.rb | 42 ---------
bindings/transaction.i | 176 ------------------------------------
8 files changed, 386 insertions(+), 386 deletions(-)
diff --git a/applayer/request.c b/applayer/request.c
new file mode 100644
index 0000000..a2bf6b0
--- /dev/null
+++ b/applayer/request.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/************************************************
+ * Transaction
+ *
+ * A set of Actions to be solved by the Solver
+ *
+ */
+
+#include
+
+#include "transaction.h"
+
+
+Transaction *
+transaction_new( Pool *pool )
+{
+ Transaction *t = (Transaction *)malloc( sizeof( Transaction ));
+ t->pool = pool;
+ queue_init( &(t->queue) );
+ return t;
+}
+
+void
+transaction_free( Transaction *t )
+{
+ queue_free( &(t->queue) );
+ free( t );
+}
+
+
+/*
+ * number of actions in transaction
+ * every two queue elements make one action
+ */
+
+int
+transaction_size( Transaction *t )
+{
+ return t->queue.count >> 1;
+}
+
+
+void
+transaction_install_xsolvable( Transaction *t, XSolvable *xs )
+{
+ queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE );
+ /* FIXME: check: s->repo->pool == $self->pool */
+ queue_push( &(t->queue), xs->id );
+}
+
+
+void
+transaction_remove_xsolvable( Transaction *t, XSolvable *xs )
+{
+ queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE );
+ /* FIXME: check: s->repo->pool == $self->pool */
+ queue_push( &(t->queue), xs->id );
+}
+
+
+void
+transaction_install_name( Transaction *t, const char *name )
+{
+ queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_NAME );
+ queue_push( &(t->queue), str2id( t->pool, name, 1 ));
+}
+
+
+void
+transaction_remove_name( Transaction *t, const char *name )
+{
+ queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_NAME );
+ queue_push( &(t->queue), str2id( t->pool, name, 1 ));
+}
+
+
+void
+transaction_install_relation( Transaction *t, const Relation *rel )
+{
+ queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_PROVIDES );
+ /* FIXME: check: rel->pool == $self->pool */
+ queue_push( &(t->queue), rel->id );
+}
+
+
+void
+transaction_remove_relation( Transaction *t, const Relation *rel )
+{
+ queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_PROVIDES );
+ /* FIXME: check: rel->pool == $self->pool */
+ queue_push( &(t->queue), rel->id );
+}
+
+
+Job *
+transaction_job_get( Transaction *t, int i )
+{
+ int size, cmd;
+ Id id;
+ i <<= 1;
+ size = t->queue.count;
+ if (i-1 >= size)
+ return NULL;
+ cmd = t->queue.elements[i];
+ id = t->queue.elements[i+1];
+ return job_new( t->pool, cmd, id );
+}
+
+
+void
+transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j))
+{
+ int i;
+ for (i = 0; i < t->queue.count-1; )
+ {
+ int cmd = t->queue.elements[i++];
+ Id id = t->queue.elements[i++];
+ if (callback( job_new( t->pool, cmd, id ) ) )
+ break;
+ }
+}
diff --git a/applayer/request.h b/applayer/request.h
new file mode 100644
index 0000000..0a30642
--- /dev/null
+++ b/applayer/request.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/************************************************
+ * Transaction
+ *
+ * A set of Actions to be solved by the Solver
+ *
+ */
+
+#ifndef SATSOLVER_TRANSACTION_H
+#define SATSOLVER_TRANSACTION_H
+
+#include "job.h"
+
+
+typedef struct _Transaction {
+ Pool *pool;
+ Queue queue;
+} Transaction;
+
+
+Transaction *transaction_new( Pool *pool );
+void transaction_free( Transaction *t );
+
+void transaction_install_xsolvable( Transaction *t, XSolvable *xs );
+void transaction_remove_xsolvable( Transaction *t, XSolvable *xs );
+void transaction_install_name( Transaction *t, const char *name );
+void transaction_remove_name( Transaction *t, const char *name );
+void transaction_install_relation( Transaction *t, const Relation *rel );
+void transaction_remove_relation( Transaction *t, const Relation *rel );
+int transaction_size( Transaction *t );
+Job *transaction_job_get( Transaction *t, int i );
+
+void transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j));
+
+#endif /* SATSOLVER_TRANSACTION_H */
diff --git a/applayer/transaction.c b/applayer/transaction.c
deleted file mode 100644
index a2bf6b0..0000000
--- a/applayer/transaction.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2007, Novell Inc.
- *
- * This program is licensed under the BSD license, read LICENSE.BSD
- * for further information
- */
-
-/************************************************
- * Transaction
- *
- * A set of Actions to be solved by the Solver
- *
- */
-
-#include
-
-#include "transaction.h"
-
-
-Transaction *
-transaction_new( Pool *pool )
-{
- Transaction *t = (Transaction *)malloc( sizeof( Transaction ));
- t->pool = pool;
- queue_init( &(t->queue) );
- return t;
-}
-
-void
-transaction_free( Transaction *t )
-{
- queue_free( &(t->queue) );
- free( t );
-}
-
-
-/*
- * number of actions in transaction
- * every two queue elements make one action
- */
-
-int
-transaction_size( Transaction *t )
-{
- return t->queue.count >> 1;
-}
-
-
-void
-transaction_install_xsolvable( Transaction *t, XSolvable *xs )
-{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE );
- /* FIXME: check: s->repo->pool == $self->pool */
- queue_push( &(t->queue), xs->id );
-}
-
-
-void
-transaction_remove_xsolvable( Transaction *t, XSolvable *xs )
-{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE );
- /* FIXME: check: s->repo->pool == $self->pool */
- queue_push( &(t->queue), xs->id );
-}
-
-
-void
-transaction_install_name( Transaction *t, const char *name )
-{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_NAME );
- queue_push( &(t->queue), str2id( t->pool, name, 1 ));
-}
-
-
-void
-transaction_remove_name( Transaction *t, const char *name )
-{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_NAME );
- queue_push( &(t->queue), str2id( t->pool, name, 1 ));
-}
-
-
-void
-transaction_install_relation( Transaction *t, const Relation *rel )
-{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_PROVIDES );
- /* FIXME: check: rel->pool == $self->pool */
- queue_push( &(t->queue), rel->id );
-}
-
-
-void
-transaction_remove_relation( Transaction *t, const Relation *rel )
-{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_PROVIDES );
- /* FIXME: check: rel->pool == $self->pool */
- queue_push( &(t->queue), rel->id );
-}
-
-
-Job *
-transaction_job_get( Transaction *t, int i )
-{
- int size, cmd;
- Id id;
- i <<= 1;
- size = t->queue.count;
- if (i-1 >= size)
- return NULL;
- cmd = t->queue.elements[i];
- id = t->queue.elements[i+1];
- return job_new( t->pool, cmd, id );
-}
-
-
-void
-transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j))
-{
- int i;
- for (i = 0; i < t->queue.count-1; )
- {
- int cmd = t->queue.elements[i++];
- Id id = t->queue.elements[i++];
- if (callback( job_new( t->pool, cmd, id ) ) )
- break;
- }
-}
diff --git a/applayer/transaction.h b/applayer/transaction.h
deleted file mode 100644
index 0a30642..0000000
--- a/applayer/transaction.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2007, Novell Inc.
- *
- * This program is licensed under the BSD license, read LICENSE.BSD
- * for further information
- */
-
-/************************************************
- * Transaction
- *
- * A set of Actions to be solved by the Solver
- *
- */
-
-#ifndef SATSOLVER_TRANSACTION_H
-#define SATSOLVER_TRANSACTION_H
-
-#include "job.h"
-
-
-typedef struct _Transaction {
- Pool *pool;
- Queue queue;
-} Transaction;
-
-
-Transaction *transaction_new( Pool *pool );
-void transaction_free( Transaction *t );
-
-void transaction_install_xsolvable( Transaction *t, XSolvable *xs );
-void transaction_remove_xsolvable( Transaction *t, XSolvable *xs );
-void transaction_install_name( Transaction *t, const char *name );
-void transaction_remove_name( Transaction *t, const char *name );
-void transaction_install_relation( Transaction *t, const Relation *rel );
-void transaction_remove_relation( Transaction *t, const Relation *rel );
-int transaction_size( Transaction *t );
-Job *transaction_job_get( Transaction *t, int i );
-
-void transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j));
-
-#endif /* SATSOLVER_TRANSACTION_H */
diff --git a/bindings/request.i b/bindings/request.i
new file mode 100644
index 0000000..1ef2d9a
--- /dev/null
+++ b/bindings/request.i
@@ -0,0 +1,176 @@
+/*
+ * Document-class: Transaction
+ * Transaction represents a Set of Jobs as input for the Solver.
+ *
+ */
+
+%{
+
+/*
+ * iterating over jobs of a transaction ('yield' in Ruby)
+ */
+
+static int
+transaction_jobs_iterate_callback( const Job *j )
+{
+#if defined(SWIGRUBY)
+ /* FIXME: how to pass 'break' back to the caller ? */
+ rb_yield(SWIG_NewPointerObj((void*) j, SWIGTYPE_p__Job, 0));
+#endif
+ return 0;
+}
+
+%}
+
+
+%nodefault _Transaction;
+%rename(Transaction) _Transaction;
+typedef struct _Transaction {} Transaction;
+
+#if defined(SWIGRUBY)
+%mixin Transaction "Enumerable";
+#endif
+
+%extend Transaction {
+ /*
+ * Create transaction based on Pool
+ *
+ * See also: Pool.create_transaction
+ */
+ Transaction( Pool *pool )
+ { return transaction_new( pool ); }
+
+ ~Transaction()
+ { transaction_free( $self ); }
+
+ /*
+ * Install request
+ *
+ * Ensure installation of a solvable by either
+ * * specifying it directly
+ * * specify it by name
+ * * specify a required relation
+ *
+ * Except when specified directly, the solver is free to choose any
+ * solvable matching the request (by name, by relation)
+ *
+ * call-seq:
+ * transaction.install(solvable) -> void
+ * transaction.install("kernel") -> void
+ * transaction.install(relation) -> void
+ *
+ */
+ void install( XSolvable *xs )
+ { transaction_install_xsolvable( $self, xs ); }
+
+ /*
+ * Remove request
+ *
+ * Ensure removal of a solvable by either
+ * * specifying it directly
+ * * specify it by name
+ * * specify a required relation
+ *
+ * Except when specified directly, the solver is free to choose any
+ * solvable matching the request (by name, by relation)
+ *
+ * call-seq:
+ * transaction.remove(solvable) -> void
+ * transaction.remove("kernel") -> void
+ * transaction.remove(relation) -> void
+ *
+ */
+ void remove( XSolvable *xs )
+ { transaction_remove_xsolvable( $self, xs ); }
+
+ /*
+ * Install solvable by name
+ */
+ void install( const char *name )
+ { transaction_install_name( $self, name ); }
+
+ /*
+ * Remove solvable by name
+ *
+ */
+ void remove( const char *name )
+ { transaction_remove_name( $self, name ); }
+
+ /*
+ * Install solvable by relation
+ *
+ */
+ void install( const Relation *rel )
+ { transaction_install_relation( $self, rel ); }
+
+ /*
+ * Remove solvable by relation
+ *
+ */
+ void remove( const Relation *rel )
+ { return transaction_remove_relation( $self, rel ); }
+
+#if defined(SWIGRUBY)
+ %rename("empty?") empty();
+ %typemap(out) int empty
+ "$result = $1 ? Qtrue : Qfalse;";
+#endif
+ /*
+ * Check if the transaction has any jobs attached.
+ *
+ * call-seq:
+ * transaction.empty? -> bool
+ *
+ */
+ int empty()
+ { return ( $self->queue.count == 0 ); }
+
+ /*
+ * Return number of jobs of this transaction
+ *
+ */
+ int size()
+ { return transaction_size( $self ); }
+
+#if defined(SWIGRUBY)
+ %rename("clear!") clear();
+#endif
+ /*
+ * Remove all jobs of this transaction
+ *
+ * call-seq:
+ * transaction.clear! -> void
+ *
+ */
+ void clear()
+ { queue_empty( &($self->queue) ); }
+
+#if defined(SWIGRUBY)
+ %alias get "[]";
+#endif
+ /*
+ * Get job by index
+ *
+ * The index is just a convenience access method and
+ * does NOT imply any preference/ordering of the Jobs.
+ *
+ * A Transaction is always considered a set of Jobs.
+ *
+ * call-seq:
+ * transaction.get(42) -> Job
+ *
+ */
+ Job *get( unsigned int i )
+ { return transaction_job_get( $self, i ); }
+
+ /*
+ * Iterate over each Job of the Transaction.
+ *
+ * call-seq:
+ * transaction.each { |job| ... }
+ *
+ */
+ void each()
+ { transaction_jobs_iterate( $self, transaction_jobs_iterate_callback ); }
+}
+
diff --git a/bindings/ruby/tests/request.rb b/bindings/ruby/tests/request.rb
new file mode 100644
index 0000000..454572f
--- /dev/null
+++ b/bindings/ruby/tests/request.rb
@@ -0,0 +1,42 @@
+$:.unshift "../../../build/bindings/ruby"
+require 'pathname'
+
+# test Transction
+
+require 'test/unit'
+require 'satsolver'
+
+class TransactionTest < Test::Unit::TestCase
+ def test_transaction
+ pool = Satsolver::Pool.new
+ assert pool
+ pool.arch = "i686"
+ solvpath = Pathname( File.dirname( __FILE__ ) ) + Pathname( "../../testdata" ) + "os11-biarch.solv"
+ repo = pool.add_solv( solvpath )
+ repo.name = "test1"
+
+ transaction = Satsolver::Transaction.new( pool )
+ assert transaction
+ transaction.install( "foo" )
+ transaction.install( repo.find "ruby" )
+ transaction.install( Satsolver::Relation.new( pool, "foo", Satsolver::REL_EQ, "42-7" ) )
+ transaction.remove( "bar" )
+ transaction.remove( repo.find "glibc" )
+ transaction.remove( Satsolver::Relation.new( pool, "bar", Satsolver::REL_EQ, "42-7" ) )
+ assert transaction.size == 6
+ transaction.each { |a|
+ cmd = case a.cmd
+ when Satsolver::INSTALL_SOLVABLE: "install #{a.solvable}"
+ when Satsolver::REMOVE_SOLVABLE: "remove #{a.solvable}"
+ when Satsolver::INSTALL_SOLVABLE_NAME: "install by name #{a.name}"
+ when Satsolver::REMOVE_SOLVABLE_NAME: "remove by name #{a.name}"
+ when Satsolver::INSTALL_SOLVABLE_PROVIDES: "install by relation #{a.relation}"
+ when Satsolver::REMOVE_SOLVABLE_PROVIDES: "remove by relation #{a.relation}"
+ else "<NONE>"
+ end
+ puts cmd
+ }
+ transaction.clear!
+ assert transaction.empty?
+ end
+end
diff --git a/bindings/ruby/tests/transaction.rb b/bindings/ruby/tests/transaction.rb
deleted file mode 100644
index 454572f..0000000
--- a/bindings/ruby/tests/transaction.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-$:.unshift "../../../build/bindings/ruby"
-require 'pathname'
-
-# test Transction
-
-require 'test/unit'
-require 'satsolver'
-
-class TransactionTest < Test::Unit::TestCase
- def test_transaction
- pool = Satsolver::Pool.new
- assert pool
- pool.arch = "i686"
- solvpath = Pathname( File.dirname( __FILE__ ) ) + Pathname( "../../testdata" ) + "os11-biarch.solv"
- repo = pool.add_solv( solvpath )
- repo.name = "test1"
-
- transaction = Satsolver::Transaction.new( pool )
- assert transaction
- transaction.install( "foo" )
- transaction.install( repo.find "ruby" )
- transaction.install( Satsolver::Relation.new( pool, "foo", Satsolver::REL_EQ, "42-7" ) )
- transaction.remove( "bar" )
- transaction.remove( repo.find "glibc" )
- transaction.remove( Satsolver::Relation.new( pool, "bar", Satsolver::REL_EQ, "42-7" ) )
- assert transaction.size == 6
- transaction.each { |a|
- cmd = case a.cmd
- when Satsolver::INSTALL_SOLVABLE: "install #{a.solvable}"
- when Satsolver::REMOVE_SOLVABLE: "remove #{a.solvable}"
- when Satsolver::INSTALL_SOLVABLE_NAME: "install by name #{a.name}"
- when Satsolver::REMOVE_SOLVABLE_NAME: "remove by name #{a.name}"
- when Satsolver::INSTALL_SOLVABLE_PROVIDES: "install by relation #{a.relation}"
- when Satsolver::REMOVE_SOLVABLE_PROVIDES: "remove by relation #{a.relation}"
- else "<NONE>"
- end
- puts cmd
- }
- transaction.clear!
- assert transaction.empty?
- end
-end
diff --git a/bindings/transaction.i b/bindings/transaction.i
deleted file mode 100644
index 1ef2d9a..0000000
--- a/bindings/transaction.i
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Document-class: Transaction
- * Transaction represents a Set of Jobs as input for the Solver.
- *
- */
-
-%{
-
-/*
- * iterating over jobs of a transaction ('yield' in Ruby)
- */
-
-static int
-transaction_jobs_iterate_callback( const Job *j )
-{
-#if defined(SWIGRUBY)
- /* FIXME: how to pass 'break' back to the caller ? */
- rb_yield(SWIG_NewPointerObj((void*) j, SWIGTYPE_p__Job, 0));
-#endif
- return 0;
-}
-
-%}
-
-
-%nodefault _Transaction;
-%rename(Transaction) _Transaction;
-typedef struct _Transaction {} Transaction;
-
-#if defined(SWIGRUBY)
-%mixin Transaction "Enumerable";
-#endif
-
-%extend Transaction {
- /*
- * Create transaction based on Pool
- *
- * See also: Pool.create_transaction
- */
- Transaction( Pool *pool )
- { return transaction_new( pool ); }
-
- ~Transaction()
- { transaction_free( $self ); }
-
- /*
- * Install request
- *
- * Ensure installation of a solvable by either
- * * specifying it directly
- * * specify it by name
- * * specify a required relation
- *
- * Except when specified directly, the solver is free to choose any
- * solvable matching the request (by name, by relation)
- *
- * call-seq:
- * transaction.install(solvable) -> void
- * transaction.install("kernel") -> void
- * transaction.install(relation) -> void
- *
- */
- void install( XSolvable *xs )
- { transaction_install_xsolvable( $self, xs ); }
-
- /*
- * Remove request
- *
- * Ensure removal of a solvable by either
- * * specifying it directly
- * * specify it by name
- * * specify a required relation
- *
- * Except when specified directly, the solver is free to choose any
- * solvable matching the request (by name, by relation)
- *
- * call-seq:
- * transaction.remove(solvable) -> void
- * transaction.remove("kernel") -> void
- * transaction.remove(relation) -> void
- *
- */
- void remove( XSolvable *xs )
- { transaction_remove_xsolvable( $self, xs ); }
-
- /*
- * Install solvable by name
- */
- void install( const char *name )
- { transaction_install_name( $self, name ); }
-
- /*
- * Remove solvable by name
- *
- */
- void remove( const char *name )
- { transaction_remove_name( $self, name ); }
-
- /*
- * Install solvable by relation
- *
- */
- void install( const Relation *rel )
- { transaction_install_relation( $self, rel ); }
-
- /*
- * Remove solvable by relation
- *
- */
- void remove( const Relation *rel )
- { return transaction_remove_relation( $self, rel ); }
-
-#if defined(SWIGRUBY)
- %rename("empty?") empty();
- %typemap(out) int empty
- "$result = $1 ? Qtrue : Qfalse;";
-#endif
- /*
- * Check if the transaction has any jobs attached.
- *
- * call-seq:
- * transaction.empty? -> bool
- *
- */
- int empty()
- { return ( $self->queue.count == 0 ); }
-
- /*
- * Return number of jobs of this transaction
- *
- */
- int size()
- { return transaction_size( $self ); }
-
-#if defined(SWIGRUBY)
- %rename("clear!") clear();
-#endif
- /*
- * Remove all jobs of this transaction
- *
- * call-seq:
- * transaction.clear! -> void
- *
- */
- void clear()
- { queue_empty( &($self->queue) ); }
-
-#if defined(SWIGRUBY)
- %alias get "[]";
-#endif
- /*
- * Get job by index
- *
- * The index is just a convenience access method and
- * does NOT imply any preference/ordering of the Jobs.
- *
- * A Transaction is always considered a set of Jobs.
- *
- * call-seq:
- * transaction.get(42) -> Job
- *
- */
- Job *get( unsigned int i )
- { return transaction_job_get( $self, i ); }
-
- /*
- * Iterate over each Job of the Transaction.
- *
- * call-seq:
- * transaction.each { |job| ... }
- *
- */
- void each()
- { transaction_jobs_iterate( $self, transaction_jobs_iterate_callback ); }
-}
-
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org