summaryrefslogtreecommitdiff
path: root/swig
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2020-03-06 02:26:13 +0900
committerbiao716.wang <biao716.wang@samsung.com>2020-03-06 22:06:03 +0900
commitf2f1a310c855e9a9d19b1e3d1e7737784dc6ce7b (patch)
tree4d1ddd6f943fc35fc80999064d440c8c87674bcb /swig
parent23ca0cab871cc21b827c6d7caaedd4fcbde06224 (diff)
downloadlibzypp-bindings-tizen_6.0_hotfix.tar.gz
libzypp-bindings-tizen_6.0_hotfix.tar.bz2
libzypp-bindings-tizen_6.0_hotfix.zip
Change-Id: I9f33b96eeef6ba2a2fb0d1a4784cb88f90c8de67 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
Diffstat (limited to 'swig')
-rw-r--r--swig/Arch.i16
-rw-r--r--swig/CMakeLists.txt47
-rw-r--r--swig/Capabilities.i18
-rw-r--r--swig/PoolItem.i1
-rw-r--r--swig/RepoInfo.i4
-rw-r--r--swig/RepoManager.i3
-rw-r--r--swig/ResPool.i37
-rw-r--r--swig/ResTraits.i1
-rw-r--r--swig/Resolvable.i2
-rw-r--r--swig/Resolver.i18
-rw-r--r--swig/ZYppFactory.i14
-rw-r--r--swig/ruby/tests/arch.rb31
-rw-r--r--swig/ruby/tests/bytecount.rb9
-rw-r--r--swig/ruby/tests/target.rb15
-rw-r--r--swig/zypp.i26
15 files changed, 164 insertions, 78 deletions
diff --git a/swig/Arch.i b/swig/Arch.i
index 1129197..09ada80 100644
--- a/swig/Arch.i
+++ b/swig/Arch.i
@@ -100,6 +100,22 @@ class Arch {
* builtin: armv7hl
*/
static Arch armv7hl() { return zypp::Arch_armv7hl; }
+ /*
+ * builtin: armv7tnhl
+ */
+ static Arch armv7tnhl() { return zypp::Arch_armv7tnhl; }
+ /*
+ * builtin: armv7thl
+ */
+ static Arch armv7thl() { return zypp::Arch_armv7thl; }
+ /*
+ * builtin: armv7nhl
+ */
+ static Arch armv7nhl() { return zypp::Arch_armv7nhl; }
+ /*
+ * builtin: armv7hl
+ */
+ static Arch armv7hl() { return zypp::Arch_armv7hl; }
/*
* builtin: armv7l
diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt
index ea807f6..acf23f6 100644
--- a/swig/CMakeLists.txt
+++ b/swig/CMakeLists.txt
@@ -8,22 +8,37 @@ ENABLE_TESTING()
SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/zypp.i" )
#
+# Allow to build only a subset of language bindings via options
+#
+
+OPTION(BUILD_RUBY_BINDINGS "Build Ruby bindings" ON)
+OPTION(BUILD_PYTHON2_BINDINGS "Build Python 2 bindings" ON)
+OPTION(BUILD_PERL5_BINDINGS "Build Perl 5 bindings" ON)
+
+#
# Let's see which target languages are available
#
-FIND_PACKAGE(Ruby)
-FIND_PACKAGE(PythonLibs)
-FIND_PACKAGE(Perl)
-
-
-IF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
- ADD_SUBDIRECTORY(ruby)
-ENDIF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
-
-IF (PYTHON_LIBRARY)
- ADD_SUBDIRECTORY(python)
-ENDIF(PYTHON_LIBRARY)
-
-#IF (PERL_EXECUTABLE)
-# ADD_SUBDIRECTORY(perl5)
-#ENDIF (PERL_EXECUTABLE)
+IF(BUILD_RUBY_BINDINGS)
+ FIND_PACKAGE(Ruby)
+ IF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
+ ADD_SUBDIRECTORY(ruby)
+ ENDIF()
+ENDIF()
+
+IF(BUILD_PYTHON2_BINDINGS)
+ # Enforce Python 2.7, libzypp-bindings does not yet work with Python3
+ set(PythonLibs_FIND_VERSION 2.7)
+ set(PythonLibs_FIND_VERSION_MAJOR 2)
+ FIND_PACKAGE(PythonLibs)
+ IF(PYTHON_LIBRARY)
+ ADD_SUBDIRECTORY(python)
+ ENDIF()
+ENDIF()
+
+#IF(BUILD_PERL5_BINDINGS)
+# FIND_PACKAGE(Perl)
+# IF(PERL_EXECUTABLE)
+# ADD_SUBDIRECTORY(perl5)
+# ENDIF()
+#ENDIF()
diff --git a/swig/Capabilities.i b/swig/Capabilities.i
index 88e5c30..624b921 100644
--- a/swig/Capabilities.i
+++ b/swig/Capabilities.i
@@ -8,3 +8,21 @@ by_value_iterator(zypp::Capabilities);
#ifdef SWIGPERL5
forwarditer(zypp::Capabilities, zypp::Capability);
#endif
+
+#ifdef SWIGPYTHON
+%include "std_vector.i"
+%include "std_string.i"
+
+%template(StringVector) std::vector<std::string>;
+
+%extend zypp::Capabilities {
+ std::vector<std::string> CapNames()
+ {
+ std::vector<std::string> caps;
+ for (zypp::Capabilities::const_iterator it = self->begin(); it != self->end(); ++it) {
+ caps.push_back((*it).asString());
+ }
+ return caps;
+ }
+}
+#endif
diff --git a/swig/PoolItem.i b/swig/PoolItem.i
index 34a2eeb..ca4147c 100644
--- a/swig/PoolItem.i
+++ b/swig/PoolItem.i
@@ -1,3 +1,4 @@
+%template(SolvableType_PoolItem) zypp::sat::SolvableType<zypp::PoolItem>;
%include <zypp/PoolItem.h>
#ifdef SWIGPERL5
diff --git a/swig/RepoInfo.i b/swig/RepoInfo.i
index 4f6c06c..80b2dd6 100644
--- a/swig/RepoInfo.i
+++ b/swig/RepoInfo.i
@@ -1,6 +1,6 @@
#ifdef SWIGPERL5
#else
-%template(UrlSet) std::set<zypp::Url>;
+%template(UrlSet) std::list<zypp::Url>;
#endif
namespace zypp
@@ -31,7 +31,7 @@ namespace zypp
typedef std::list<zypp::RepoInfo> RepoInfoList;
%template(RepoInfoList) std::list<zypp::RepoInfo>;
-%extend zypp::RepoInfo
+%extend zypp::RepoInfo
{
std::string dump(void) const
{
diff --git a/swig/RepoManager.i b/swig/RepoManager.i
index a150d32..4101be3 100644
--- a/swig/RepoManager.i
+++ b/swig/RepoManager.i
@@ -1,10 +1,9 @@
%include <zypp/RepoManager.h>
-
#ifdef SWIGPYTHON
%extend zypp::RepoManager{
std::string loadSolvFile(std::string _solv, std::string _alias)
{
- RepoInfo tmpRepo;
+ RepoInfo tmpRepo;
tmpRepo.setAlias(_alias);
try {
sat::Pool::instance().addRepoSolv(_solv, tmpRepo);
diff --git a/swig/ResPool.i b/swig/ResPool.i
index b9f24e9..48634fa 100644
--- a/swig/ResPool.i
+++ b/swig/ResPool.i
@@ -3,11 +3,9 @@
%ignore zypp::ResPool::byKindEnd;
%ignore zypp::ResPool::byNameBegin;
%ignore zypp::ResPool::byNameEnd;
-#if (BOOST_VERSION >= 106501)
-%ignore zypp::ResPool::byStatus;
-%ignore zypp::ResPool::byStatusBegin;
-%ignore zypp::ResPool::byStatusEnd;
-#endif
+%ignore zypp::ResPool::byStatus;
+%ignore zypp::ResPool::byStatusBegin;
+%ignore zypp::ResPool::byStatusEnd;
%apply unsigned { zypp::ResPool::size_type };
%include <zypp/ResPool.h>
@@ -22,6 +20,35 @@ namespace zypp
namespace zypp
{
+#ifdef SWIGPYTHON
+namespace sat
+{
+%extend Pool {
+ std::string loadSolvFile(std::string _solv, std::string _alias)
+ {
+ RepoInfo tmpRepo;
+ tmpRepo.setAlias(_alias);
+
+ try {
+ addRepoSolv(_solv, tmpRepo);
+ } catch ( const Exception & e ) {
+ return e.msg();
+ }
+
+ return std::string();
+ }
+}
+}
+#endif
+
+%extend ResPool {
+ pool::GetResolvablesToInsDel getTransaction()
+ {
+ return pool::GetResolvablesToInsDel( *self );
+ }
+}
+
+
#ifdef SWIGPERL5
iter2(ResPool, PoolItem);
diff --git a/swig/ResTraits.i b/swig/ResTraits.i
index 60613ec..cbcefad 100644
--- a/swig/ResTraits.i
+++ b/swig/ResTraits.i
@@ -90,3 +90,4 @@ namespace zypp
%STUFF(SrcPackage)
%STUFF(Pattern)
%STUFF(Product)
+%STUFF(Application)
diff --git a/swig/Resolvable.i b/swig/Resolvable.i
index 7055b9f..ea4e33a 100644
--- a/swig/Resolvable.i
+++ b/swig/Resolvable.i
@@ -1,4 +1,6 @@
%ignore zypp::make;
%import <zypp/sat/Solvable.h>
+%import <zypp/sat/SolvableType.h>
+%template(SolvableType_Resolvable) zypp::sat::SolvableType<zypp::Resolvable>;
%include <zypp/Resolvable.h>
diff --git a/swig/Resolver.i b/swig/Resolver.i
index d4245c7..d6842dd 100644
--- a/swig/Resolver.i
+++ b/swig/Resolver.i
@@ -2,13 +2,30 @@
%template(StringList) std::list<std::string>;
#endif
+/* don't wrap legacy ItemCapKind stuff */
+%ignore zypp::Resolver::isInstalledBy( const PoolItem & item );
+%ignore zypp::Resolver::installs( const PoolItem & item );
+%ignore zypp::Resolver::satifiedByInstalled (const PoolItem & item );
+%ignore zypp::Resolver::installedSatisfied( const PoolItem & item );
+
%include <zypp/ProblemTypes.h>
%include <zypp/ResolverProblem.h>
%include <zypp/ProblemSolution.h>
%include <zypp/Resolver.h>
+/* ResPoool provides leagacy GetResolvablesToInsDel */
+%ignore zypp::Resolver::getTransaction();
+
+
+typedef std::list<zypp::ProblemSolution_Ptr> ProblemSolutionList;
+%template(ProblemSolutionList) std::list<zypp::ProblemSolution_Ptr>;
+
+typedef boost::intrusive_ptr< zypp::ProblemSolution > ProblemSolution_Ptr;
+%template(ProblemSolution_Ptr) boost::intrusive_ptr< zypp::ProblemSolution >;
+
namespace zypp
{
+
typedef ::zypp::intrusive_ptr< Resolver > Resolver_Ptr;
%template(Resolver_Ptr) ::zypp::intrusive_ptr<Resolver>;
@@ -25,3 +42,4 @@ namespace zypp
#endif
}
+
diff --git a/swig/ZYppFactory.i b/swig/ZYppFactory.i
index 3ac0b5a..5617f7e 100644
--- a/swig/ZYppFactory.i
+++ b/swig/ZYppFactory.i
@@ -1,9 +1,11 @@
-
+%include <zypp/ZYpp.h>
%include <zypp/ZYppFactory.h>
-namespace zypp
-{
-typedef ::zypp::intrusive_ptr<ZYpp> ZYpp_Ptr;
-%template(ZYpp_Ptr) ::zypp::intrusive_ptr<ZYpp>;
-}
+typedef ::boost::detail::sp_member_access<::zypp::ZYpp> b_d_sp_member_access;
+%template(b_d_sp_member_access) boost::detail::sp_member_access<::zypp::ZYpp>;
+
+typedef ::boost::detail::sp_dereference<::zypp::ZYpp> b_d_sp_dereference;
+%template(b_d_sp_dereference) boost::detail::sp_dereference<::zypp::ZYpp>;
+typedef ::boost::shared_ptr<::zypp::ZYpp> ZYpp_Ptr;
+%template(ZYpp_Ptr) ::boost::shared_ptr<::zypp::ZYpp>;
diff --git a/swig/ruby/tests/arch.rb b/swig/ruby/tests/arch.rb
index 3e2f508..eafca1b 100644
--- a/swig/ruby/tests/arch.rb
+++ b/swig/ruby/tests/arch.rb
@@ -12,44 +12,43 @@ class Zypp::Arch
end
class ArchTest < Test::Unit::TestCase
- include Zypp
def test_arch
# define i386, a builtin
- a = Arch.new("i386")
+ a = Zypp::Arch.new("i386")
assert a
assert_equal "i386", a.to_s
assert_equal true, a.is_builtin
# i486 is 'bigger' than i386
- b = Arch.new("i486")
+ b = Zypp::Arch.new("i486")
assert b
assert_equal "i486", b.to_s
assert b.is_builtin
- if VERSION > 800
+ if Zypp::VERSION > 800
assert_equal a, b.base_arch
end
assert a < b
assert a.compatible_with?(b)
# A new, adventurous architecture
- z = Arch.new("xyzzy")
+ z = Zypp::Arch.new("xyzzy")
assert z
assert_equal "xyzzy", z.to_s
assert_equal false, 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
+ assert_equal Zypp::Arch.new("noarch"), Zypp::Arch.noarch
+ assert_equal a, Zypp::Arch.i386
+ assert_equal b, Zypp::Arch.i486
+ assert_equal Zypp::Arch.new("i586"), Zypp::Arch.i586
+ assert_equal Zypp::Arch.new("i686"), Zypp::Arch.i686
+ assert_equal Zypp::Arch.new("x86_64"), Zypp::Arch.x86_64
+ assert_equal Zypp::Arch.new("ia64"), Zypp::Arch.ia64
+ assert_equal Zypp::Arch.new("ppc"), Zypp::Arch.ppc
+ assert_equal Zypp::Arch.new("ppc64"), Zypp::Arch.ppc64
+ assert_equal Zypp::Arch.new("s390"), Zypp::Arch.s390
+ assert_equal Zypp::Arch.new("s390x"), Zypp::Arch.s390x
end
end
diff --git a/swig/ruby/tests/bytecount.rb b/swig/ruby/tests/bytecount.rb
index 5b46e14..bda6f0a 100644
--- a/swig/ruby/tests/bytecount.rb
+++ b/swig/ruby/tests/bytecount.rb
@@ -10,16 +10,15 @@ require 'test/unit'
class LoadTest < Test::Unit::TestCase
require 'zypp'
- include Zypp
def test_bytecount
- g = ByteCount.new(ByteCount.G)
+ g = Zypp::ByteCount.new(Zypp::ByteCount.G)
assert g
- gb = ByteCount.new(ByteCount.GB)
+ gb = Zypp::ByteCount.new(Zypp::ByteCount.GB)
assert gb
- k = ByteCount.new(ByteCount.K)
+ k = Zypp::ByteCount.new(Zypp::ByteCount.K)
assert k.to_i == 1024
- mb = ByteCount.new(ByteCount.MB)
+ mb = Zypp::ByteCount.new(Zypp::ByteCount.MB)
assert mb.to_i == 1000*1000
end
end
diff --git a/swig/ruby/tests/target.rb b/swig/ruby/tests/target.rb
index 7594c79..1b8e45b 100644
--- a/swig/ruby/tests/target.rb
+++ b/swig/ruby/tests/target.rb
@@ -7,12 +7,11 @@ $:.unshift "../../../build/swig/ruby"
# test loading of extension
require 'test/unit'
+require 'zypp'
class LoadTest < Test::Unit::TestCase
- require 'zypp'
- include Zypp
def test_target
- z = ZYppFactory::instance.getZYpp
+ z = Zypp::ZYppFactory::instance.getZYpp
assert z.homePath
assert z.tmpPath
@@ -35,17 +34,17 @@ class LoadTest < Test::Unit::TestCase
break if i > 10
# PoolItems have status and a resolvable
r = pi.resolvable
- assert pi.is_a? PoolItem
+ assert pi.is_a? Zypp::PoolItem
end
#try iterate with kind
i = 0
- p.each_by_kind(ResKind.package) do |pi|
+ p.each_by_kind(Zypp::ResKind.package) do |pi|
i = i + 1
break if i > 10
- assert pi.is_a? PoolItem
+ assert pi.is_a? Zypp::PoolItem
r = pi.resolvable
- assert isKindPackage(pi)
+ assert Zypp::isKindPackage(pi)
end
i = 0
@@ -53,7 +52,7 @@ class LoadTest < Test::Unit::TestCase
p.each_by_name("libzypp") do |pi|
i = i + 1
break if i > 10
- assert pi.is_a? PoolItem
+ assert pi.is_a? Zypp::PoolItem
r = pi.resolvable
# broken in current SWIG assert_equal "libzypp",r.name
#try to download it
diff --git a/swig/zypp.i b/swig/zypp.i
index 1cf9a4d..cd9327e 100644
--- a/swig/zypp.i
+++ b/swig/zypp.i
@@ -17,20 +17,14 @@
// stuff swig seems to be unable to parse
#define BOOST_NOEXCEPT
-#define BOOST_SP_NOEXCEPT
-#define BOOST_SP_NOEXCEPT_WITH_ASSERT
+#define BOOST_SP_NOEXCEPT
+#define BOOST_SP_NOEXCEPT_WITH_ASSERT
#define BOOST_NO_CXX11_NOEXCEPT
#define BOOST_NO_CXX11_RVALUE_REFERENCES
#define BOOST_NO_CXX11_SMART_PTR
-#if (BOOST_VERSION >= 106501)
-#define BOOST_CONSTEXPR_OR_CONST const
#define constexpr
#define BOOST_CONSTEXPR constexpr
-#else
-#define BOOST_CONSTEXPR
-#define BOOST_CONSTEXPR_OR_CONST const
-#define constexpr
-#endif
+
%{
/* Includes the header in the wrapper code */
#ifdef SWIGRUBY
@@ -216,10 +210,8 @@ namespace zypp {
%include "std_string.i"
%include "stl.i"
-#if (BOOST_VERSION >= 106501)
-%import <boost/config.hpp>
-%import <boost/pointer_cast.hpp>
-#endif
+%import <boost/config.hpp>
+%import <boost/pointer_cast.hpp>
#ifdef BOOST_SMARTPTR_INCLUDE_DIR
%import <boost/smart_ptr/scoped_ptr.hpp>
@@ -250,11 +242,11 @@ namespace zypp {
%include "Capabilities.i"
%include "CapMatch.i"
%include "OnMediaLocation.i"
-%include "Resolvable.i"
+%include "SolvAttr.i"
%include "RepoType.i"
-%include "TmpPath.i"
%include "RepoInfo.i"
%include "Repository.i"
+%include "Resolvable.i"
%include "ServiceInfo.i"
%include "ResTraits.i"
%include "ResStatus.i"
@@ -276,10 +268,10 @@ namespace zypp {
%include "ResPool.i"
%include "ZYppCommitPolicy.i"
%include "ZYppCommitResult.i"
+%include "TmpPath.i"
%include "Resolver.i"
%include "ZConfig.i"
%include "PoolQuery.i"
-%include "SolvAttr.i"
//just simple files, where we need default ctor
%include <zypp/repo/RepoProvideFile.h>
@@ -294,8 +286,6 @@ namespace zypp {
%ignore zypp::ZYpp::setArchitecture;
%ignore zypp::ZYpp::applyLocks;
-%include <zypp/ZYpp.h>
-
%include "ZYppFactory.i"
#endif