diff options
author | Klaus Kämpf <kkaempf@suse.de> | 2010-11-08 16:46:53 +0100 |
---|---|---|
committer | Klaus Kämpf <kkaempf@suse.de> | 2010-11-08 16:46:53 +0100 |
commit | 92a496183baf76262091f40724236d712ca397c6 (patch) | |
tree | addf024348de7bcb6e5b5a0f630672b9a51e94e3 | |
parent | 68e8aef38a7de70403a31a0a54bd52c846ca43af (diff) | |
download | libzypp-bindings-92a496183baf76262091f40724236d712ca397c6.tar.gz libzypp-bindings-92a496183baf76262091f40724236d712ca397c6.tar.bz2 libzypp-bindings-92a496183baf76262091f40724236d712ca397c6.zip |
Expose builtin architectures at class level
-rw-r--r-- | swig/Arch.i | 34 | ||||
-rw-r--r-- | swig/python/tests/arch.py | 11 | ||||
-rw-r--r-- | swig/ruby/tests/arch.rb | 20 |
3 files changed, 64 insertions, 1 deletions
diff --git a/swig/Arch.i b/swig/Arch.i index 0675ad9..0651b17 100644 --- a/swig/Arch.i +++ b/swig/Arch.i @@ -3,6 +3,24 @@ * * Architecture definitions * + * Document-class: Arch + * Instances of Arch represent architecture and compatibility. + * The system has an architecture (i.e. x86_64) and so does every + * Resolvable. + * + * Arch#compatible_with is used to detect compatible architectures. + * 'noarch' is compatible with any system architecture. + * + * There is no limit to architecture specifiers, any string can be + * passed to the Arch constructor. + * However, there is a set of architectures built into libzypp. + * Arch#builtin? returns true for an architecture from the builtin set. + * + * == Usage + * arch = Arch.new("i686") + * + * arch.builtin? -> true + * */ %nodefault zypp::Arch; @@ -19,9 +37,24 @@ class Arch { ~Arch() { delete $self; } + + # all the standard architectures + static Arch noarch() { return zypp::Arch_noarch; } + static Arch i386() { return zypp::Arch_i386; } + static Arch i486() { return zypp::Arch_i486; } + static Arch i586() { return zypp::Arch_i586; } + static Arch i686() { return zypp::Arch_i686; } + static Arch x86_64() { return zypp::Arch_x86_64; } + static Arch ia64() { return zypp::Arch_ia64; } + static Arch ppc() { return zypp::Arch_ppc; } + static Arch ppc64() { return zypp::Arch_ppc64; } + static Arch s390() { return zypp::Arch_s390; } + static Arch s390x() { return zypp::Arch_s390x; } + #if defined(SWIGRUBY) %typemap(out) int is_builtin "$result = $1 ? Qtrue : Qfalse;"; +%rename("builtin?") builtin; #endif /* * Whether this is a builtin (or known) architecture. @@ -33,6 +66,7 @@ class Arch { #if defined(SWIGRUBY) %typemap(out) int compatible_with "$result = $1 ? Qtrue : Qfalse;"; +%rename("compatible_with?") compatible_with; #endif /* * Check if this architecture is compatible with another one diff --git a/swig/python/tests/arch.py b/swig/python/tests/arch.py index 01751b0..4451da8 100644 --- a/swig/python/tests/arch.py +++ b/swig/python/tests/arch.py @@ -28,5 +28,16 @@ class TestSequenceFunctions(unittest.TestCase): assert "xyzzy" == z.__str__() assert not z.is_builtin() + assert Arch("noarch") == Arch.noarch() + assert a, Arch.i386() + assert b, Arch.i486() + assert Arch("i586") == Arch.i586() + assert Arch("i686") == Arch.i686() + assert Arch("x86_64") == Arch.x86_64() + assert Arch("ia64") == Arch.ia64() + assert Arch("ppc") == Arch.ppc() + assert Arch("ppc64") == Arch.ppc64() + assert Arch("s390") == Arch.s390() + assert Arch("s390x") == Arch.s390x() if __name__ == '__main__': unittest.main() diff --git a/swig/ruby/tests/arch.rb b/swig/ruby/tests/arch.rb index 95d3cef..e9a8155 100644 --- a/swig/ruby/tests/arch.rb +++ b/swig/ruby/tests/arch.rb @@ -14,22 +14,40 @@ end class ArchTest < Test::Unit::TestCase include Zypp def test_arch + # define i386, a builtin + a = Arch.new("i386") assert a assert_equal "i386", a.to_s assert a.is_builtin + # i486 is 'bigger' than i386 + b = Arch.new("i486") assert b assert_equal "i486", b.to_s assert b.is_builtin assert_equal a, b.base_arch assert a < b - assert a.compatible_with(b) + assert a.compatible_with?(b) + # A new, adventurous architecture z = Arch.new("xyzzy") assert z assert_equal "xyzzy", z.to_s assert !z.is_builtin + + # predefined archs + assert_equal Arch.new("noarch"), Arch.noarch + assert_equal a, Arch.i386 + assert_equal b, Arch.i486 + assert_equal Arch.new("i586"), Arch.i586 + assert_equal Arch.new("i686"), Arch.i686 + assert_equal Arch.new("x86_64"), Arch.x86_64 + assert_equal Arch.new("ia64"), Arch.ia64 + assert_equal Arch.new("ppc"), Arch.ppc + assert_equal Arch.new("ppc64"), Arch.ppc64 + assert_equal Arch.new("s390"), Arch.s390 + assert_equal Arch.new("s390x"), Arch.s390x end end |