ref: refs/heads/master
commit ab8d658753be1679d8e1f6d8248a8551a6412217
Author: Klaus Kämpf
Date: Fri Mar 27 15:51:36 2009 +0100
add Solvable.location and fix documentation
This adds solvable_get_location() as Solvable.location(), returning a
2-element tuple of [path,media]
It also adds a dummy '__type' for functions returning target-language
specific data (not auto-converted by swig) so the parse_swig.rb
pattern matcher detects them and catches their documentation.
---
bindings/repokey.i | 20 ++++++++++----------
bindings/ruby/tests/solvable.rb | 12 +++++++++++-
bindings/satsolver.i | 2 ++
bindings/solvable.i | 33 +++++++++++++++++++++++++++++++++
bindings/solver.i | 4 ++--
5 files changed, 58 insertions(+), 13 deletions(-)
diff --git a/bindings/repokey.i b/bindings/repokey.i
index 3e22780..1ed3459 100644
--- a/bindings/repokey.i
+++ b/bindings/repokey.i
@@ -45,7 +45,7 @@ typedef struct _Repokey {} XRepokey; /* expose XRepokey as 'Repokey' */
/*
* type id of key
*
- * One of +Satsolver::REPOKEY_TYPE_*+
+ * One of +Satsolver+::+REPOKEY_TYPE_+*
*/
int type_id()
{
@@ -53,14 +53,6 @@ typedef struct _Repokey {} XRepokey; /* expose XRepokey as 'Repokey' */
return key->type;
}
- /*
- * Class of key
- *
- * Returns a _best_ _matching_ Class representation of the type
- *
- * i.e. +Satsolver::REPOKEY_TYPE_VOID+ is represented as a +Boolean+ since presence of the key means +true+ for this attribute.
- *
- */
#if defined(SWIGPYTHON)
PyTypeObject *
#endif
@@ -70,7 +62,15 @@ VALUE
#if defined(SWIGPERL)
SV *
#endif
- type()
+ /*
+ * Class of key
+ *
+ * Returns a _best_ _matching_ Class representation of the type
+ *
+ * i.e. +Satsolver+::+REPOKEY_TYPE_VOID+ is represented as a +Boolean+ since presence of the key means +true+ for this attribute.
+ *
+ */
+ __type type()
{
Repokey *key = xrepokey_repokey( $self );
Swig_Type_Type type = Swig_Type_Null;
diff --git a/bindings/ruby/tests/solvable.rb b/bindings/ruby/tests/solvable.rb
index f73addf..a82d0d7 100644
--- a/bindings/ruby/tests/solvable.rb
+++ b/bindings/ruby/tests/solvable.rb
@@ -34,7 +34,7 @@ class SolvableTest < Test::Unit::TestCase
i = 0
puts "test_deps"
@pool.each { |s|
- puts "Solvable >#{s}<"
+ puts "Solvable >#{s}< @ #{s.location.inspect}"
show_dep "Provides", s.provides
show_dep "Requires", s.requires
show_dep "Obsoletes", s.obsoletes
@@ -44,6 +44,16 @@ class SolvableTest < Test::Unit::TestCase
}
end
+ def test_attributes
+ @pool.each do |s|
+ assert s.name
+ assert s.arch
+ assert s.evr
+# assert s.vendor
+ assert s.location.size == 2
+ end
+ end
+
def test_iterate_pool
@pool.each do |s|
assert s.pool == @pool
diff --git a/bindings/satsolver.i b/bindings/satsolver.i
index 2b109c8..cc8e662 100644
--- a/bindings/satsolver.i
+++ b/bindings/satsolver.i
@@ -46,6 +46,8 @@
%include
#endif
+#define __type
+
%{
/*=============================================================*/
diff --git a/bindings/solvable.i b/bindings/solvable.i
index 8cbcb04..fa43415 100644
--- a/bindings/solvable.i
+++ b/bindings/solvable.i
@@ -92,6 +92,39 @@ typedef struct _Solvable {} XSolvable; /* expose XSolvable as 'Solvable' */
void set_vendor(const char *vendor)
{ xsolvable_solvable($self)->vendor = str2id( $self->pool, vendor, 1 ); }
+#if defined(SWIGRUBY)
+ VALUE
+#endif
+#if defined(SWIGPYTHON)
+ PyObject *
+#endif
+#if defined(SWIGPERL)
+ SV *
+#endif
+ /*
+ * Get location of corresponding package
+ *
+ * returns a 2-element tuple of [path (string), medianr (int)]
+ *
+ * +medianr+ is meaningful only for fixed-media repositories spread
+ * across multiple CDs or DVDs.
+ *
+ * +path+ is +nil+ for non-package solvables.
+ *
+ */
+ __type location()
+ {
+ Swig_Type result = Swig_Array();
+ unsigned int media;
+ const char *loc = solvable_get_location(xsolvable_solvable($self), &media);
+ if (loc == NULL)
+ Swig_Append(result, Swig_Null);
+ else
+ Swig_Append(result, Swig_String(loc));
+ Swig_Append(result, Swig_Int(media));
+ return result;
+ }
+
%newobject XSolvable::string;
#if defined(SWIGRUBY)
%rename("to_s") string();
diff --git a/bindings/solver.i b/bindings/solver.i
index 313c103..5d4f614 100644
--- a/bindings/solver.i
+++ b/bindings/solver.i
@@ -849,7 +849,7 @@ typedef struct solver {} Solver;
}
/*
- * Document-method; explain
+ * Document-method: explain
*
* Explain a decision
*
@@ -868,7 +868,7 @@ typedef struct solver {} Solver;
#if defined(SWIGPERL)
SV *
#endif
- explain(Transaction *t, Decision *decision)
+ __type explain(Transaction *t, Decision *decision)
{
Swig_Type result = Swig_Null;
Id rule = decision->rule - $self->rules;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org