summaryrefslogtreecommitdiff
path: root/swig
diff options
context:
space:
mode:
Diffstat (limited to 'swig')
-rw-r--r--swig/Callbacks.i18
-rw-r--r--swig/PackageProvider.i26
-rw-r--r--swig/ResPool.i22
-rw-r--r--swig/Target.i4
-rw-r--r--swig/python/tests/repoinfo.py2
-rw-r--r--swig/ruby/ruby.i5
-rw-r--r--swig/ruby/tests/target.rb26
-rw-r--r--swig/zypp.i6
8 files changed, 87 insertions, 22 deletions
diff --git a/swig/Callbacks.i b/swig/Callbacks.i
index 9a91ddb..1c5e83c 100644
--- a/swig/Callbacks.i
+++ b/swig/Callbacks.i
@@ -34,6 +34,8 @@ static Target_Type action_abort()
if (value == Qnil)
value = ID2SYM(rb_intern("abort"));
return value;
+#else
+ return Target_String("abort");
#endif
return 0; // fallback
}
@@ -45,6 +47,8 @@ static Target_Type action_retry()
if (value == Qnil)
value = ID2SYM(rb_intern("retry"));
return value;
+#else
+ return Target_String("retry");
#endif
return 0; // fallback
}
@@ -56,6 +60,8 @@ static Target_Type action_ignore()
if (value == Qnil)
value = ID2SYM(rb_intern("ignore"));
return value;
+#else
+ return Target_String("ignore");
#endif
return 0; // fallback
}
@@ -73,8 +79,7 @@ static Target_Type error_no_error()
if (value == Qnil)
value = ID2SYM(rb_intern("no_error"));
return value;
-#endif
-#if defined(SWIGPYTHON)
+#else
return Target_String("no_error");
#endif
return 0; // fallback
@@ -87,8 +92,7 @@ static Target_Type error_not_found()
if (value == Qnil)
value = ID2SYM(rb_intern("not_found"));
return value;
-#endif
-#if defined(SWIGPYTHON)
+#else
return Target_String("not_found");
#endif
return 0; // fallback
@@ -101,8 +105,7 @@ static Target_Type error_io()
if (value == Qnil)
value = ID2SYM(rb_intern("io"));
return value;
-#endif
-#if defined(SWIGPYTHON)
+#else
return Target_String("io");
#endif
return 0; // fallback
@@ -115,8 +118,7 @@ static Target_Type error_invalid()
if (value == Qnil)
value = ID2SYM(rb_intern("invalid"));
return value;
-#endif
-#if defined(SWIGPYTHON)
+#else
return Target_String("invalid");
#endif
return 0; // fallback
diff --git a/swig/PackageProvider.i b/swig/PackageProvider.i
new file mode 100644
index 0000000..b844a65
--- /dev/null
+++ b/swig/PackageProvider.i
@@ -0,0 +1,26 @@
+%inline
+{
+ namespace zypp
+ {
+ class WrappedManagedFile
+ {
+ public:
+ WrappedManagedFile(ManagedFile managed_file){ mf = managed_file; }
+ const std::string & asString(){ return mf->asString();}
+ private:
+ ManagedFile mf;
+ };
+ }
+}
+%include "zypp/repo/PackageProvider.h"
+%extend zypp::repo::PackageProvider {
+ static zypp::WrappedManagedFile* provide( zypp::repo::RepoMediaAccess & rm, const zypp::Package_constPtr pkg )
+ {
+ zypp::Package::constPtr pkg_type(pkg);
+ zypp::repo::DeltaCandidates dc;
+ zypp::repo::PackageProvider pp(rm,pkg_type,dc);
+ zypp::ManagedFile mf = pp.providePackage();
+ zypp::WrappedManagedFile* res = new zypp::WrappedManagedFile(mf);
+ return res;
+ }
+}
diff --git a/swig/ResPool.i b/swig/ResPool.i
index c57f57c..34f3eb5 100644
--- a/swig/ResPool.i
+++ b/swig/ResPool.i
@@ -25,25 +25,25 @@ iter2(ResPool, PoolItem);
#ifdef SWIGRUBY
-iter3(ResPool, PoolItem*);
+iter3(ResPool, zypp::PoolItem*);
// %extend ResPool {
// void each()
// {
// ResPool::const_iterator i = self->begin();
// while ( i != self->end() ) {
-// rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_PoolItem, 0));
+// rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
// ++i;
// }
// }
// }
%extend ResPool {
- void each_by_kind( const ResObject::Kind & kind_r )
+ void each_by_kind( const ResKind & kind_r )
{
ResPool::byKind_iterator i = self->byKindBegin( kind_r );
while ( i != self->byKindEnd( kind_r ) ) {
- rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_PoolItem, 0));
+ rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
++i;
}
}
@@ -54,7 +54,7 @@ iter3(ResPool, PoolItem*);
{
ResPool::byName_iterator i = self->byNameBegin( name );
while ( i != self->byNameEnd( name ) ) {
- rb_yield( SWIG_NewPointerObj( (void *) &*i, $descriptor(PoolItem), 0));
+ rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
++i;
}
}
@@ -65,17 +65,29 @@ iter3(ResPool, PoolItem*);
#ifdef SWIGPYTHON
%newobject ResPool::const_iterator(PyObject **PYTHON_SELF);
%extend ResPool {
+#if SWIG_VERSION > 0x010336
swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF)
+#else
+ swig::PySwigIterator* iterator(PyObject **PYTHON_SELF)
+#endif
{
return swig::make_output_iterator(self->begin(), self->begin(),
self->end(), *PYTHON_SELF);
}
+#if SWIG_VERSION > 0x010336
swig::SwigPyIterator* kinditerator(PyObject **PYTHON_SELF, const ResObject::Kind & kind_r)
+#else
+ swig::PySwigIterator* kinditerator(PyObject **PYTHON_SELF, const ResObject::Kind & kind_r)
+#endif
{
return swig::make_output_iterator(self->byKindBegin( kind_r ), self->byKindBegin( kind_r ),
self->byKindEnd( kind_r ), *PYTHON_SELF);
}
+#if SWIG_VERSION > 0x010336
swig::SwigPyIterator* nameiterator(PyObject **PYTHON_SELF, const std::string &name)
+#else
+ swig::PySwigIterator* nameiterator(PyObject **PYTHON_SELF, const std::string &name)
+#endif
{
return swig::make_output_iterator(self->byNameBegin( name ), self->byNameBegin( name ),
self->byNameEnd( name ), *PYTHON_SELF);
diff --git a/swig/Target.i b/swig/Target.i
index 0c81a33..b8c2e3c 100644
--- a/swig/Target.i
+++ b/swig/Target.i
@@ -1,18 +1,15 @@
%ignore zypp::Target::reset;
-#if ZYPP_VERSION > 631
namespace zypp
{
// Redefine nested class in global scope for SWIG
struct DistributionLabel {};
}
-#endif
%include <zypp/Target.h>
namespace zypp
{
typedef intrusive_ptr<Target> Target_Ptr;
%template(Target_Ptr) intrusive_ptr<Target>;
}
-#if ZYPP_VERSION > 631
%{
namespace zypp
{
@@ -20,4 +17,3 @@ typedef intrusive_ptr<Target> Target_Ptr;
typedef Target::DistributionLabel DistributionLabel;
}
%}
-#endif \ No newline at end of file
diff --git a/swig/python/tests/repoinfo.py b/swig/python/tests/repoinfo.py
index 9934f09..8fdc3b0 100644
--- a/swig/python/tests/repoinfo.py
+++ b/swig/python/tests/repoinfo.py
@@ -56,7 +56,7 @@ class RepoInfoTestCase(unittest.TestCase):
def testDump(self):
out = self.info.dump()
- assert len(out) == 396, 'Invalid output length %d' % len(out)
+ assert len(out) > 300, 'Invalid output length %d' % len(out)
def testDumpIni(self):
out = self.info.dumpAsIni()
diff --git a/swig/ruby/ruby.i b/swig/ruby/ruby.i
index d2d3025..9d5ad5d 100644
--- a/swig/ruby/ruby.i
+++ b/swig/ruby/ruby.i
@@ -111,13 +111,16 @@ namespace zypp
} \
}
+%wrapper {
+ static VALUE zyppexception = rb_define_class("ZYppException", rb_eStandardError);
+}
+
%exception
{
try {
$action
}
catch (const Exception& e) {
- static VALUE zyppexception = rb_define_class("ZYppException", rb_eStandardError);
std::string tmp = e.historyAsString() + e.asUserString();
rb_raise(zyppexception, tmp.c_str());
}
diff --git a/swig/ruby/tests/target.rb b/swig/ruby/tests/target.rb
index cfecfff..40c9305 100644
--- a/swig/ruby/tests/target.rb
+++ b/swig/ruby/tests/target.rb
@@ -33,10 +33,30 @@ class LoadTest < Test::Unit::TestCase
p.each do | pi |
i = i + 1
break if i > 10
- puts pi
# PoolItems have status and a resolvable
-# r = pi.resolvable
-# puts "#{r.name}-#{r.edition}"
+ r = pi.resolvable
+ assert pi.is_a? PoolItem
+ end
+ #try iterate with kind
+ i = 0
+ p.each_by_kind(ResKind.package) do |pi|
+
+ i = i + 1
+ break if i > 10
+ assert pi.is_a? PoolItem
+ r = pi.resolvable
+ assert isKindPackage(pi)
+ end
+
+ i = 0
+ puts "search for libzypp ..."
+ p.each_by_name("libzypp") do |pi|
+ i = i + 1
+ break if i > 10
+ assert pi.is_a? PoolItem
+ r = pi.resolvable
+ assert_equal "libzypp",r.name
+ #try to download it
end
assert true
diff --git a/swig/zypp.i b/swig/zypp.i
index 08d573b..a84ca38 100644
--- a/swig/zypp.i
+++ b/swig/zypp.i
@@ -127,6 +127,7 @@ SWIGINTERNINLINE SV *SWIG_From_double SWIG_PERL_DECL_ARGS_1(double value);
#include "zypp/ServiceInfo.h"
#include "zypp/RepoManager.h"
#include "zypp/repo/RepoType.h"
+#include "zypp/repo/PackageProvider.h"
#include "zypp/TmpPath.h"
#include "zypp/Resolver.h"
#include "zypp/pool/GetResolvablesToInsDel.h"
@@ -230,6 +231,7 @@ namespace zypp {
%include "ResStatus.i"
%include "ResObject.i"
%include "Package.i"
+%include "PackageProvider.i"
%include "Patch.i"
%include "Pattern.i"
%include "Product.i"
@@ -249,6 +251,10 @@ namespace zypp {
%include "Resolver.i"
%include "ZConfig.i"
+//just simple files, where we need default ctor
+%include <zypp/repo/RepoProvideFile.h>
+%include <zypp/repo/DeltaCandidates.h>
+
%ignore zypp::ZYpp::setTextLocale;
%ignore zypp::ZYpp::getTextLocale;
%ignore zypp::ZYpp::setRequestedLocales;