diff options
author | Klaus Kämpf <kkaempf@suse.de> | 2010-11-13 18:15:55 +0100 |
---|---|---|
committer | Klaus Kämpf <kkaempf@suse.de> | 2010-11-13 18:15:55 +0100 |
commit | 43f013895fe290659f05ba9ea47305ee09bc2e4c (patch) | |
tree | d46310fb8d3f8a6c11e91fc6dc1fcee7fa5e3277 /swig | |
parent | 5fb5bfe9a2e8247f21449d0112eeb2951b73dfc9 (diff) | |
download | libzypp-bindings-43f013895fe290659f05ba9ea47305ee09bc2e4c.tar.gz libzypp-bindings-43f013895fe290659f05ba9ea47305ee09bc2e4c.tar.bz2 libzypp-bindings-43f013895fe290659f05ba9ea47305ee09bc2e4c.zip |
Add Zypp::VERSION to dynamically adapt to API changes
Use this in Arch to flag if Arch::baseArch is available
Diffstat (limited to 'swig')
-rw-r--r-- | swig/Arch.i | 6 | ||||
-rw-r--r-- | swig/ruby/tests/arch.rb | 10 | ||||
-rw-r--r-- | swig/zypp.i | 52 |
3 files changed, 38 insertions, 30 deletions
diff --git a/swig/Arch.i b/swig/Arch.i index 1f33234..f0746e9 100644 --- a/swig/Arch.i +++ b/swig/Arch.i @@ -85,7 +85,7 @@ class Arch { */ static Arch s390x() { return zypp::Arch_s390x; } -#if defined(SWIGRUBY) +#if 0 /* defined(SWIGRUBY) */ %typemap(out) int is_builtin "$result = $1 ? Qtrue : Qfalse;"; %rename("builtin?") builtin; @@ -94,7 +94,7 @@ class Arch { * Whether this is a builtin (or known) architecture. * */ - int is_builtin() { + bool is_builtin() { return ($self->isBuiltIn() ? 1 : 0); } #if defined(SWIGRUBY) @@ -112,6 +112,7 @@ class Arch { return ($self->compatibleWith(arch) ? 1 : 0); } +#if ZYPP_VERSION > 800 /* * return the arch before noarch if it's not a multilib arch * (e.g. x86_64,sparc64v,sparc64,ppc64,s390x). @@ -121,6 +122,7 @@ class Arch { { return $self->baseArch(); } +#endif #if defined(SWIGRUBY) %alias compare "<=>"; diff --git a/swig/ruby/tests/arch.rb b/swig/ruby/tests/arch.rb index e9a8155..3e2f508 100644 --- a/swig/ruby/tests/arch.rb +++ b/swig/ruby/tests/arch.rb @@ -2,7 +2,7 @@ # Arch # -$:.unshift "../../../build/swig/ruby" +$:.unshift File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","build","swig","ruby")) require 'test/unit' require 'zypp' @@ -19,7 +19,7 @@ class ArchTest < Test::Unit::TestCase a = Arch.new("i386") assert a assert_equal "i386", a.to_s - assert a.is_builtin + assert_equal true, a.is_builtin # i486 is 'bigger' than i386 @@ -27,7 +27,9 @@ class ArchTest < Test::Unit::TestCase assert b assert_equal "i486", b.to_s assert b.is_builtin - assert_equal a, b.base_arch + if VERSION > 800 + assert_equal a, b.base_arch + end assert a < b assert a.compatible_with?(b) @@ -35,7 +37,7 @@ class ArchTest < Test::Unit::TestCase z = Arch.new("xyzzy") assert z assert_equal "xyzzy", z.to_s - assert !z.is_builtin + assert_equal false, z.is_builtin # predefined archs assert_equal Arch.new("noarch"), Arch.noarch diff --git a/swig/zypp.i b/swig/zypp.i index b09dfd9..856156a 100644 --- a/swig/zypp.i +++ b/swig/zypp.i @@ -1,5 +1,8 @@ %module zypp +/* set this to 0 (zero) to only create a subset of the bindings + * for testing + */ #define PRODUCTION 1 #ifdef SWIGPERL5 @@ -140,8 +143,7 @@ typedef std::list<std::string> StringList; %} -%nodefault ByKind; - +/* prevent swig from creating a type called 'Target_Type' */ #if defined(SWIGRUBY) #define Target_Type VALUE #endif @@ -152,22 +154,6 @@ typedef std::list<std::string> StringList; #define Target_Type SV * #endif -%rename("+") "operator+"; -%rename("<<") "operator<<"; -%rename("!=") "operator!="; -%rename("!") "operator!"; -%rename("==") "operator=="; - -namespace zypp { - namespace base { - // silence 'Nothing known about class..' warning - class ReferenceCounted {}; - } -} - -%include "std_string.i" -%include "stl.i" - #ifdef SWIGRUBY %include "ruby/std_list.i" %include "ruby/std_set.i" @@ -185,10 +171,33 @@ namespace zypp { %include "perl5/perl.i" #endif +#define VERSION ZYPP_VERSION + /* These include files are already cleaned up from C++ cruft */ %include "Arch.i" +%include "Resolvable.i" +%include "Callbacks.i" /* These include files are pending to be cleaned up from C++ cruft */ +#if PRODUCTION /* set 0 for testing, these files still carry the full C++ cruft */ + +%nodefault ByKind; + +%rename("+") "operator+"; +%rename("<<") "operator<<"; +%rename("!=") "operator!="; +%rename("!") "operator!"; +%rename("==") "operator=="; + +namespace zypp { + namespace base { + // silence 'Nothing known about class..' warning + class ReferenceCounted {}; + } +} + +%include "std_string.i" +%include "stl.i" #ifdef BOOST_SMARTPTR_INCLUDE_DIR %import <boost/smart_ptr/scoped_ptr.hpp> @@ -204,7 +213,6 @@ namespace zypp { %import <zypp/base/PtrTypes.h> %import <zypp/base/Flags.h> -#if PRODUCTION /* set 0 for testing, these files still carry the full C++ cruft */ %include "IdStringType.i" %include "Pathname.i" %include "ByteCount.i" @@ -223,7 +231,6 @@ namespace zypp { %include "ServiceInfo.i" %include "ResTraits.i" %include "ResStatus.i" -%include "Resolvable.i" %include "ResObject.i" %include "Package.i" %include "Patch.i" @@ -238,16 +245,12 @@ namespace zypp { %include "Target.i" %include "MediaSetAccess.i" %include "PoolItem.i" -#endif %include "ResPool.i" -#if PRODUCTION %include "ZYppCommitPolicy.i" %include "ZYppCommitResult.i" %include "TmpPath.i" %include "Resolver.i" %include "ZConfig.i" -%include "Callbacks.i" -#endif %ignore zypp::ZYpp::setTextLocale; %ignore zypp::ZYpp::getTextLocale; @@ -261,6 +264,7 @@ namespace zypp { %include <zypp/ZYpp.h> %include "ZYppFactory.i" +#endif // // helper |