Author: aschnell
Date: Tue Sep 25 14:40:49 2007
New Revision: 7364
URL: http://svn.opensuse.org/viewcvs/zypp?rev=7364&view=rev
Log:
- sometimes include original C header file
- global rename for asString
- added examples
Added:
trunk/libzypp-bindings/examples/python/bytecount.py (with props)
trunk/libzypp-bindings/examples/python/url.py (with props)
trunk/libzypp-bindings/examples/ruby/bytecount.rb (with props)
trunk/libzypp-bindings/examples/ruby/url.rb (with props)
Modified:
trunk/libzypp-bindings/swig/Arch.i
trunk/libzypp-bindings/swig/ByteCount.i
trunk/libzypp-bindings/swig/CapFactory.i
trunk/libzypp-bindings/swig/Capability.i
trunk/libzypp-bindings/swig/Date.i
trunk/libzypp-bindings/swig/Dep.i
trunk/libzypp-bindings/swig/Edition.i
trunk/libzypp-bindings/swig/NVR.i
trunk/libzypp-bindings/swig/NVRA.i
trunk/libzypp-bindings/swig/NVRAD.i
trunk/libzypp-bindings/swig/Package.i
trunk/libzypp-bindings/swig/Pathname.i
trunk/libzypp-bindings/swig/PublicKey.i
trunk/libzypp-bindings/swig/RepoInfo.i
trunk/libzypp-bindings/swig/RepoType.i
trunk/libzypp-bindings/swig/ResObject.i
trunk/libzypp-bindings/swig/Resolvable.i
trunk/libzypp-bindings/swig/Url.i
trunk/libzypp-bindings/swig/python/python.i
trunk/libzypp-bindings/swig/ruby/ruby.i
Added: trunk/libzypp-bindings/examples/python/bytecount.py
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/python/bytecount.py?rev=7364&view=auto
==============================================================================
--- trunk/libzypp-bindings/examples/python/bytecount.py (added)
+++ trunk/libzypp-bindings/examples/python/bytecount.py Tue Sep 25 14:40:49 2007
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+from zypp import ByteCount
+
+print ByteCount(ByteCount.G)
+print ByteCount(ByteCount.GB)
+
+x = ByteCount(ByteCount.K)
+print int(x)
+
Added: trunk/libzypp-bindings/examples/python/url.py
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/python/url.py?rev=7364&view=auto
==============================================================================
--- trunk/libzypp-bindings/examples/python/url.py (added)
+++ trunk/libzypp-bindings/examples/python/url.py Tue Sep 25 14:40:49 2007
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+from zypp import Url
+
+a = Url("http://www.suse.de/download")
+print "a = %s" % a
+print " %s %s %s" % (a.getScheme(), a.getHost(), a.getPathData())
+
+b = Url(a)
+b.setHost("download.novell.com")
+print "b = %s" % b
+
+c = a # oops
+c.setPathData("/repository")
+print "c = %s" % c
+
+print
+print "a = %s" % a # oops
+print "b = %s" % b
+print "c = %s" % c
+
Added: trunk/libzypp-bindings/examples/ruby/bytecount.rb
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/ruby/bytecount.rb?rev=7364&view=auto
==============================================================================
--- trunk/libzypp-bindings/examples/ruby/bytecount.rb (added)
+++ trunk/libzypp-bindings/examples/ruby/bytecount.rb Tue Sep 25 14:40:49 2007
@@ -0,0 +1,11 @@
+#!/usr/bin/ruby
+
+require 'zypp'
+include Zypp
+
+puts ByteCount.new(ByteCount.G)
+puts ByteCount.new(ByteCount.GB)
+
+x = ByteCount.new(ByteCount.K)
+puts x.to_i
+
Added: trunk/libzypp-bindings/examples/ruby/url.rb
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/ruby/url.rb?rev=7364&view=auto
==============================================================================
--- trunk/libzypp-bindings/examples/ruby/url.rb (added)
+++ trunk/libzypp-bindings/examples/ruby/url.rb Tue Sep 25 14:40:49 2007
@@ -0,0 +1,22 @@
+#!/usr/bin/ruby
+
+require 'zypp'
+include Zypp
+
+a = Url.new("http://www.suse.de/download")
+puts "a = #{a}"
+puts " #{a.get_scheme} #{a.get_host} #{a.get_path_data}"
+
+b = Url.new(a)
+b.set_host("download.novell.com")
+puts "b = #{b}"
+
+c = a # oops
+c.set_path_data("/repository")
+puts "c = #{c}"
+
+puts
+puts "a = #{a}" # oops
+puts "b = #{b}"
+puts "c = #{c}"
+
Modified: trunk/libzypp-bindings/swig/Arch.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Arch.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Arch.i (original)
+++ trunk/libzypp-bindings/swig/Arch.i Tue Sep 25 14:40:49 2007
@@ -3,10 +3,6 @@
%ignore Arch::compare(const Arch &, const Arch &);
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Arch::asString "__str__";
-#endif
-
class Arch
{
public:
Modified: trunk/libzypp-bindings/swig/ByteCount.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/ByteCount.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/ByteCount.i (original)
+++ trunk/libzypp-bindings/swig/ByteCount.i Tue Sep 25 14:40:49 2007
@@ -1,24 +1,49 @@
+
#ifdef SWIGRUBY
-%typemap(in) ByteCount {
- ByteCount::SizeType bytes = (Date::SizeType) NUM2LONG( rb_funcall( $input, rb_intern("to_i"), 0, 0) );
- $1 = ByteCount(bytes);
+namespace zypp
+{
+ // how to do that?
+ // %rename "ByteCount::operator SizeType()" to_i;
}
-%typemap(out) ByteCount {
- VALUE rbbytenum = INT2NUM( (ByteCount::SizeType) $1 );
- return rbbytenum;
+#endif
+
+
+// TODO: tell make about dependencies
+%include
+
+
+#ifdef SWIGRUBY
+
+namespace zypp
+{
+ %extend ByteCount
+ {
+ long long int to_i()
+ {
+ ByteCount::SizeType tmp = *self;
+ return tmp;
+ }
+ }
}
#endif
-#ifdef SWIGPERL5
+#ifdef SWIGPYTHON
-%typemap(out) ByteCount {
- $result = sv_newmortal();
- sv_setiv($result, (IV) (ByteCount::SizeType) $1 );
- argvi++;
+namespace zypp
+{
+ %extend ByteCount
+ {
+ long long int __int__()
+ {
+ ByteCount::SizeType tmp = *self;
+ return tmp;
+ }
+ }
}
#endif
+
Modified: trunk/libzypp-bindings/swig/CapFactory.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/CapFactory.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/CapFactory.i (original)
+++ trunk/libzypp-bindings/swig/CapFactory.i Tue Sep 25 14:40:49 2007
@@ -32,7 +32,7 @@
Capability parse( const Resolvable::Kind & refers_r,
const std::string & name_r,
Rel op_r,
- const Edition & edition_r ) const;
+ const zypp::Edition & edition_r ) const;
/** Special Capability, triggering evaluation of Hal
* capabilities when matched.
Modified: trunk/libzypp-bindings/swig/Capability.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Capability.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Capability.i (original)
+++ trunk/libzypp-bindings/swig/Capability.i Tue Sep 25 14:40:49 2007
@@ -1,8 +1,4 @@
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Capability::asString "__str__";
-#endif
-
class Capability
{
public:
Modified: trunk/libzypp-bindings/swig/Date.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Date.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Date.i (original)
+++ trunk/libzypp-bindings/swig/Date.i Tue Sep 25 14:40:49 2007
@@ -1,20 +1,4 @@
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Date::asString "__str__";
-#endif
-
-class Date
-{
-public:
-
- Date();
- Date(const std::string & seconds_r);
-
- static Date now();
-
- std::string form(const std::string & format_r) const;
- std::string asString() const;
- std::string asSeconds() const;
-
-};
+// TODO: tell make about dependencies
+%include
Modified: trunk/libzypp-bindings/swig/Dep.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Dep.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Dep.i (original)
+++ trunk/libzypp-bindings/swig/Dep.i Tue Sep 25 14:40:49 2007
@@ -1,8 +1,4 @@
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Dep::asString "__str__";
-#endif
-
struct Dep
{
/** \name Dependency types
Modified: trunk/libzypp-bindings/swig/Edition.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Edition.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Edition.i (original)
+++ trunk/libzypp-bindings/swig/Edition.i Tue Sep 25 14:40:49 2007
@@ -1,37 +1,52 @@
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Edition::asString "__str__";
-#endif
+// example for including the original header file
+
+#if 1
+
+namespace zypp
+{
+ %rename Edition::compare(const Edition& lhs, const Edition& rhs) compare2;
+ %rename Edition::match(const Edition& lhs, const Edition& rhs) match2;
+}
-class Edition
+// TODO: tell make about dependencies
+%include
+
+#else
+
+namespace zypp
{
- public:
- typedef unsigned epoch_t;
- static const epoch_t noepoch = 0;
- static const Edition noedition;
- public:
- Edition();
-
- Edition( const std::string & edition_r );
- Edition( const std::string & version_r,
- const std::string & release_r,
- epoch_t epoch_r = noepoch );
- Edition( const std::string & version_r,
- const std::string & release_r,
- const std::string & epoch_r );
- ~Edition();
- public:
- epoch_t epoch() const;
- const std::string & version() const;
- const std::string & release() const;
- std::string asString() const;
- public:
- static int compare( const Edition & lhs, const Edition & rhs );
- int compare( const Edition & rhs ) const;
- typedef Compare<Edition> Compare;
- typedef Range<Edition> CompareRange;
- public:
- static int match( const Edition & lhs, const Edition & rhs );
- int match( const Edition & rhs ) const;
-};
+ class Edition
+ {
+ public:
+ typedef unsigned epoch_t;
+ static const epoch_t noepoch = 0;
+ static const Edition noedition;
+ public:
+ Edition();
+ Edition( const std::string & edition_r );
+ Edition( const std::string & version_r,
+ const std::string & release_r,
+ epoch_t epoch_r = noepoch );
+ Edition( const std::string & version_r,
+ const std::string & release_r,
+ const std::string & epoch_r );
+ ~Edition();
+ public:
+ epoch_t epoch() const;
+ const std::string & version() const;
+ const std::string & release() const;
+ std::string asString() const;
+ public:
+ static int compare( const Edition & lhs, const Edition & rhs );
+ int compare( const Edition & rhs ) const;
+ typedef Compare<Edition> Compare;
+ typedef Range<Edition> CompareRange;
+ public:
+ static int match( const Edition & lhs, const Edition & rhs );
+ int match( const Edition & rhs ) const;
+ };
+}
+
+#endif
Modified: trunk/libzypp-bindings/swig/NVR.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/NVR.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/NVR.i (original)
+++ trunk/libzypp-bindings/swig/NVR.i Tue Sep 25 14:40:49 2007
@@ -7,7 +7,7 @@
/** Ctor */
explicit
NVR( const std::string & name_r,
- const Edition & edition_r = Edition() )
+ const zypp::Edition & edition_r = zypp::Edition() )
: name( name_r )
, edition( edition_r )
{}
@@ -19,7 +19,7 @@
/** */
std::string name;
/** */
- Edition edition;
+ zypp::Edition edition;
public:
/** Comparison mostly for std::container */
@@ -30,4 +30,4 @@
return res;
return lhs.edition.compare( rhs.edition );
}
- };
\ No newline at end of file
+ };
Modified: trunk/libzypp-bindings/swig/NVRA.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/NVRA.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/NVRA.i (original)
+++ trunk/libzypp-bindings/swig/NVRA.i Tue Sep 25 14:40:49 2007
@@ -7,7 +7,7 @@
/** Ctor */
explicit
NVRA( const std::string & name_r,
- const Edition & edition_r = Edition(),
+ const zypp::Edition & edition_r = Edition(),
const Arch & arch_r = Arch() )
: NVR( name_r, edition_r )
, arch( arch_r )
@@ -37,4 +37,4 @@
return res;
return lhs.arch.compare( rhs.arch );
}
- };
\ No newline at end of file
+ };
Modified: trunk/libzypp-bindings/swig/NVRAD.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/NVRAD.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/NVRAD.i (original)
+++ trunk/libzypp-bindings/swig/NVRAD.i Tue Sep 25 14:40:49 2007
@@ -8,7 +8,7 @@
/** Ctor */
explicit
NVRAD( const std::string & name_r,
- const Edition & edition_r = Edition(),
+ const zypp::Edition & edition_r = zypp::Edition(),
const Arch & arch_r = Arch(),
const Dependencies & deps_r = Dependencies() )
: NVRA( name_r, edition_r, arch_r )
@@ -35,4 +35,4 @@
/** Ctor */
explicit
NVRAD( Resolvable::constPtr res_r );
- };
\ No newline at end of file
+ };
Modified: trunk/libzypp-bindings/swig/Package.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Package.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Package.i (original)
+++ trunk/libzypp-bindings/swig/Package.i Tue Sep 25 14:40:49 2007
@@ -37,7 +37,7 @@
/** */
Text postun() const;
/** */
- ByteCount sourcesize() const;
+ zypp::ByteCount sourcesize() const;
/** */
std::liststd::string authors() const;
/** */
Modified: trunk/libzypp-bindings/swig/Pathname.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Pathname.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Pathname.i (original)
+++ trunk/libzypp-bindings/swig/Pathname.i Tue Sep 25 14:40:49 2007
@@ -1,8 +1,4 @@
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Pathname::asString "__str__";
-#endif
-
class Pathname
{
public:
Modified: trunk/libzypp-bindings/swig/PublicKey.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/PublicKey.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/PublicKey.i (original)
+++ trunk/libzypp-bindings/swig/PublicKey.i Tue Sep 25 14:40:49 2007
@@ -1,8 +1,4 @@
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename PublicKey::asString "__str__";
-#endif
-
class PublicKey
{
Modified: trunk/libzypp-bindings/swig/RepoInfo.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/RepoInfo.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/RepoInfo.i (original)
+++ trunk/libzypp-bindings/swig/RepoInfo.i Tue Sep 25 14:40:49 2007
@@ -1,6 +1,6 @@
#ifdef SWIGPERL5
#else
- %template(UrlSet) std::set<Url>;
+ %template(UrlSet) std::set<Url>;
#endif
class RepoInfo
@@ -79,13 +79,13 @@
*
* To edit or remove urls, create a new RepoInfo instead.
*/
- RepoInfo & addBaseUrl( const Url &url );
+ RepoInfo & addBaseUrl( const zypp::Url &url );
/**
* Set mirror list url. \see mirrorListUrl
* \param url The base url for the list
*/
- RepoInfo & setMirrorListUrl( const Url &url );
+ RepoInfo & setMirrorListUrl( const zypp::Url &url );
/**
* enable or disable the repository \see enabled
Modified: trunk/libzypp-bindings/swig/RepoType.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/RepoType.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/RepoType.i (original)
+++ trunk/libzypp-bindings/swig/RepoType.i Tue Sep 25 14:40:49 2007
@@ -1,8 +1,4 @@
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename RepoType::asString "__str__";
-#endif
-
struct RepoType
{
static const RepoType RPMMD;
Modified: trunk/libzypp-bindings/swig/ResObject.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/ResObject.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/ResObject.i (original)
+++ trunk/libzypp-bindings/swig/ResObject.i Tue Sep 25 14:40:49 2007
@@ -17,8 +17,8 @@
Text delnotify() const;
Text licenseToConfirm() const;
Vendor vendor() const;
- ByteCount size() const;
- ByteCount downloadSize() const;
+ zypp::ByteCount size() const;
+ zypp::ByteCount downloadSize() const;
Repository repository() const;
unsigned mediaNr() const;
bool installOnly() const;
Modified: trunk/libzypp-bindings/swig/Resolvable.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Resolvable.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Resolvable.i (original)
+++ trunk/libzypp-bindings/swig/Resolvable.i Tue Sep 25 14:40:49 2007
@@ -10,7 +10,7 @@
const Kind & kind() const;
const std::string & name() const;
- const Edition & edition() const;
+ const zypp::Edition & edition() const;
const Arch & arch() const;
const CapSet & dep( Dep which_r ) const;
Modified: trunk/libzypp-bindings/swig/Url.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Url.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/Url.i (original)
+++ trunk/libzypp-bindings/swig/Url.i Tue Sep 25 14:40:49 2007
@@ -1,20 +1,30 @@
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Url::asString "__str__";
-#endif
+// example for including the original header file
+
+#if 1
+
+// TODO: tell make about dependencies
+%include
-class Url
+#else
+
+namespace zypp
{
-public:
+ class Url
+ {
+ public:
- Url();
- ~Url();
+ Url();
+ ~Url();
- Url(const std::string& encodedUrl);
+ Url(const Url &url);
+ Url(const std::string &encodedUrl);
- bool isValid() const;
+ bool isValid() const;
- std::string asString() const;
+ std::string asString() const;
-};
+ };
+}
+#endif
Modified: trunk/libzypp-bindings/swig/python/python.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/python/python.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/python/python.i (original)
+++ trunk/libzypp-bindings/swig/python/python.i Tue Sep 25 14:40:49 2007
@@ -1,4 +1,15 @@
+
+%rename *::asString "__str__";
+
+
+namespace zypp
+{
+ // Just to avoid warnings.
+ %ignore operator<<;
+}
+
+
%define iter( cls )
%extend cls {
%pythoncode %{
Modified: trunk/libzypp-bindings/swig/ruby/ruby.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/ruby/ruby.i?rev=7364&r1=7363&r2=7364&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/ruby/ruby.i (original)
+++ trunk/libzypp-bindings/swig/ruby/ruby.i Tue Sep 25 14:40:49 2007
@@ -1,5 +1,21 @@
+%rename *::asString "__str__";
+
+
+namespace zypp
+{
+ // Not ignoring gives a very strange error in the "pokus" testsuite: SWIG
+ // defines a Ruby module-function "==" which (when included into the main
+ // namespace) is apparently used where is should not.
+ %ignore operator==;
+
+ // Just to avoid warnings.
+ %ignore operator!=;
+ %ignore operator<<;
+}
+
+
/*
* Extend cls with an ruby-like each iterator and a to_a method. Yields
* objects of type storetype. Parameter storetype must be a pointer type.
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org