--- /dev/null
+#!/usr/bin/python
+
+from zypp import ByteCount
+
+print ByteCount(ByteCount.G)
+print ByteCount(ByteCount.GB)
+
+x = ByteCount(ByteCount.K)
+print int(x)
+
--- /dev/null
+#!/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
+
--- /dev/null
+#!/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
+
--- /dev/null
+#!/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}"
+
%ignore Arch::compare(const Arch &, const Arch &);
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Arch::asString "__str__";
-#endif
-
class Arch
{
public:
+
#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 <zypp/ByteCount.h>
+
+
+#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
+
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.
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Capability::asString "__str__";
-#endif
-
class Capability
{
public:
-#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 <zypp/Date.h>
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Dep::asString "__str__";
-#endif
-
struct Dep
{
/** \name Dependency types
-#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 <zypp/Edition.h>
+
+#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
/** 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 )
{}
/** */
std::string name;
/** */
- Edition edition;
+ zypp::Edition edition;
public:
/** Comparison mostly for std::container */
return res;
return lhs.edition.compare( rhs.edition );
}
- };
\ No newline at end of file
+ };
/** 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 )
return res;
return lhs.arch.compare( rhs.arch );
}
- };
\ No newline at end of file
+ };
/** 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 )
/** Ctor */
explicit
NVRAD( Resolvable::constPtr res_r );
- };
\ No newline at end of file
+ };
/** */
Text postun() const;
/** */
- ByteCount sourcesize() const;
+ zypp::ByteCount sourcesize() const;
/** */
std::list<std::string> authors() const;
/** */
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename Pathname::asString "__str__";
-#endif
-
class Pathname
{
public:
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename PublicKey::asString "__str__";
-#endif
-
class PublicKey
{
#ifdef SWIGPERL5
#else
- %template(UrlSet) std::set<Url>;
+ %template(UrlSet) std::set<Url>;
#endif
class RepoInfo
*
* 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
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
-%rename RepoType::asString "__str__";
-#endif
-
struct RepoType
{
static const RepoType RPMMD;
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;
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;
-#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 <zypp/Url.h>
-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
+
+%rename *::asString "__str__";
+
+
+namespace zypp
+{
+ // Just to avoid warnings.
+ %ignore operator<<;
+}
+
+
%define iter( cls )
%extend cls {
%pythoncode %{
+%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.