merge REFACTORING-10_3 back to trunk
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 16 Jul 2007 10:40:42 +0000 (10:40 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 16 Jul 2007 10:40:42 +0000 (10:40 +0000)
16 files changed:
CMakeLists.txt
examples/ruby/play_with_repos.rb [new file with mode: 0644]
swig/Capability.i
swig/RepoInfo.i [new file with mode: 0644]
swig/RepoManager.i [new file with mode: 0644]
swig/RepoStatus.i [new file with mode: 0644]
swig/RepoType.i [new file with mode: 0644]
swig/Repository.i [new file with mode: 0644]
swig/ResObject.i
swig/Source.i [deleted file]
swig/SourceFactory.i [deleted file]
swig/Url.i
swig/ruby.i
swig/std_list.i [new file with mode: 0644]
swig/std_set.i [new file with mode: 0644]
swig/zypp.i

index 97ba8d9..0c476b5 100644 (file)
@@ -32,7 +32,7 @@ SET (CPACK_SOURCE_IGNORE_FILES
 INCLUDE(CPack)
 
 #FIND_PACKAGE(SWIG REQUIRED)
-
+MESSAGE(STATUS "Looking modules in ${CMAKE_MODULE_PATH}")
 FIND_PROGRAM(SWIG_EXECUTABLE
   NAMES swig-1.3 swig
   PATHS ${SWIG_DIR} ${SWIG_DIR}/.. ${SWIG_DIR}/../../bin /usr/bin /usr/local/bin ${CMAKE_INSTALL_PREFIX}/bin
diff --git a/examples/ruby/play_with_repos.rb b/examples/ruby/play_with_repos.rb
new file mode 100644 (file)
index 0000000..5babf55
--- /dev/null
@@ -0,0 +1,18 @@
+
+require 'rzypp'
+include Rzypp
+
+a = Arch.new("i386")
+puts a.to_s
+#exit
+
+z = ZYppFactory::instance.get_zypp
+
+manager = RepoManager.new
+
+manager.known_repositories.each do | repo |
+  repo.base_urls.each do | url |
+    puts url.to_s
+  end
+end
+
index 2c31daf..d4c5107 100644 (file)
@@ -44,11 +44,7 @@ class Capability
     /** accessors needed by solver/zmd  */
     /** Deprecated */
     std::string index() const;
-    /** Deprecated, defaults to Rel::NONE */
-    Rel op() const;
-    /** Deprecated, defaults to Edition::noedition */
-    Edition edition() const;
-
+   
   private:
     typedef capability::CapabilityImpl          Impl;
     typedef capability::CapabilityImpl_Ptr      Impl_Ptr ;
diff --git a/swig/RepoInfo.i b/swig/RepoInfo.i
new file mode 100644 (file)
index 0000000..fa8589a
--- /dev/null
@@ -0,0 +1,144 @@
+
+%template(UrlSet) std::set<Url>;
+class RepoInfo
+  {
+    friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
+    
+    public:
+    RepoInfo();
+    ~RepoInfo();
+    
+    /**
+     * unique identifier for this source. If not specified
+     * It should be generated from the base url.
+     *
+     * Normally, in a .repo file the section name is used
+     * ( [somerepo] )
+     */
+    std::string alias() const;
+    
+    /**
+     * A Url under which the metadata are located, or a set of mirrors.
+     *
+     * This can't be empty in order the repository to be valid
+     * unless the download of the mirror list succeeds and it
+     * contains a valid url.
+     */
+    std::set<Url> baseUrls() const;
+
+    /**
+     * Url of a file which contains a list of Urls
+     * If empty, the base url will be used.
+     */
+    Url mirrorListUrl() const;
+    
+    typedef std::set<Url>::const_iterator urls_const_iterator;
+    
+    /**
+     * iterator that points at begin of repository urls
+     */
+    urls_const_iterator baseUrlsBegin() const;
+    
+    /**
+     * iterator that points at end of repository urls
+     */
+    urls_const_iterator baseUrlsEnd() const;
+    
+    /**
+     * If enabled is false, then this repository must be ignored as if does
+     * not exists, except when checking for duplicate alias.
+     */
+    boost::tribool enabled() const;
+    
+    /**
+     * If true, the repostory must be refreshed before creating resolvables
+     * from it
+     */
+    boost::tribool autorefresh() const;
+    
+    /**
+     * Type of repository,
+     * 
+     */
+    repo::RepoType type() const;
+    
+    /**
+     * \short Repository short label
+     *
+     * Short label or description of the repository, to be used on
+     * the user interface.
+     * ie: "SUSE Linux 10.2 updates"
+     */
+    std::string name() const;
+
+    /**
+     * \short File where this repo was read from
+     *
+     * \note could be an empty pathname for repo
+     * infos created in memory.
+     */
+     Pathname filepath() const;
+    
+    /**
+     * Add a base url. \see baseUrls
+     * \param url The base url for the repository.
+     *
+     * To edit or remove urls, create a new RepoInfo instead.
+     */
+    RepoInfo & addBaseUrl( const Url &url );
+    
+    /**
+     * Set mirror list url. \see mirrorListUrl
+     * \param url The base url for the list
+     */
+    RepoInfo & setMirrorListUrl( const Url &url );
+    
+    /**
+     * enable or disable the repository \see enabled
+     * \param enabled
+     */
+    RepoInfo & setEnabled( boost::tribool enabled );
+    
+    /**
+     * enable or disable autorefresh \see autorefresh
+     * \param enabled
+     */
+    RepoInfo & setAutorefresh( boost::tribool autorefresh );
+    
+    /**
+     * set the repository alias \see alias
+     * \param alias
+     */
+    RepoInfo & setAlias( const std::string &alias );
+    
+    /**
+     * set the repository type \see type
+     * \param t
+     */
+    RepoInfo & setType( const repo::RepoType &t );
+    
+    /**
+     * set the repository name \see name
+     * \param name
+     */
+    RepoInfo & setName( const std::string &name );
+
+    /**
+     * \short set the repository filepath
+     * \param path File path
+     */
+    RepoInfo & setFilepath( const Pathname &filename );
+    
+    std::ostream & dumpOn( std::ostream & str ) const;
+    
+    std::ostream & dumpRepoOn( std::ostream & str ) const;
+
+    class Impl;
+  private:
+    /** Pointer to implementation */
+    RWCOW_pointer<Impl> _pimpl;
+  };
+  typedef std::list<RepoInfo> RepoInfoList;
+   %template(RepoInfoList) std::list<RepoInfo>;
+
diff --git a/swig/RepoManager.i b/swig/RepoManager.i
new file mode 100644 (file)
index 0000000..9738af2
--- /dev/null
@@ -0,0 +1,57 @@
+   
+  std::list<RepoInfo> readRepoFile(const Url & repo_file);
+
+  struct RepoManagerOptions
+  {
+    RepoManagerOptions();
+    
+    Pathname repoCachePath;
+    Pathname repoRawCachePath;
+    Pathname knownReposPath;
+  };
+
+  class RepoManager
+  {
+  public:
+   RepoManager( const RepoManagerOptions &options = RepoManagerOptions() );
+    ~RepoManager();
+    
+    enum RawMetadataRefreshPolicy
+    {
+      RefreshIfNeeded,
+      RefreshForced
+    };
+    
+    enum CacheBuildPolicy
+    {
+      BuildIfNeeded,
+      BuildForced
+    };
+    
+    enum RepoRemovePolicy
+    {
+      
+    };
+    
+   std::list<RepoInfo> knownRepositories() const;
+ void refreshMetadata( const RepoInfo &info,
+                         RawMetadataRefreshPolicy policy = RefreshIfNeeded,
+                         const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+   void cleanMetadata( const RepoInfo &info,
+                       const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+   void buildCache( const RepoInfo &info,
+                    CacheBuildPolicy policy = BuildIfNeeded,
+                    const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+   void cleanCache( const RepoInfo &info,
+                    const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+    bool isCached( const RepoInfo &info ) const;
+   Repository createFromCache( const RepoInfo &info,const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+   repo::RepoType probe( const Url &url );
+   void addRepository( const RepoInfo &info,
+                       const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+    void addRepositories( const Url &url,
+                         const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+    void removeRepository( const RepoInfo & info,
+                           const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+    
+  };
diff --git a/swig/RepoStatus.i b/swig/RepoStatus.i
new file mode 100644 (file)
index 0000000..7bec53c
--- /dev/null
@@ -0,0 +1,57 @@
+class RepoStatus
+  {
+    friend std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
+
+  public:
+    
+    /**
+     * Checksum of the repository.
+     * Usually the checksum of the index, but any
+     * checksum that changes when the repository changes
+     * in any way is sufficient.
+     */
+    std::string checksum() const;
+    
+    /**
+     * timestamp of the repository. If the repository
+     * changes, it has to be updated as well with the
+     * new timestamp.
+     */
+    Date timestamp() const;
+    
+    /**
+     * set the repository checksum \see checksum
+     * \param checksum
+     */
+    RepoStatus & setChecksum( const std::string &checksum );
+    
+    /**
+     * set the repository timestamp \see timestamp
+     * \param timestamp
+     */
+    RepoStatus & setTimestamp( const Date &timestamp );
+
+    /** Implementation  */
+    class Impl;
+
+  public:
+    /** Default ctor */
+    RepoStatus();
+    
+    /**
+     * \short Status from a single file
+     * As most repository state is represented
+     * by the status of the index file, you can
+     * construct the status from a file.
+     */
+    RepoStatus( const Pathname &file );
+    
+    /** Dtor */
+    ~RepoStatus();
+
+  public:
+
+  private:
+    /** Pointer to implementation */
+    RWCOW_pointer<Impl> _pimpl;
+  };
\ No newline at end of file
diff --git a/swig/RepoType.i b/swig/RepoType.i
new file mode 100644 (file)
index 0000000..e4cef08
--- /dev/null
@@ -0,0 +1,26 @@
+
+struct RepoType
+  {
+    static const RepoType RPMMD;
+    static const RepoType YAST2;
+    //static const RepoType NONE;
+    
+    enum Type
+    {
+      NONE_e,
+      RPMMD_e,
+      YAST2_e
+    };
+
+    RepoType(Type type) : _type(type) {}
+
+    explicit RepoType(const std::string & strval_r);
+
+    const Type toEnum() const { return _type; }
+    
+    RepoType::Type parse(const std::string & strval_r);
+
+    const std::string & asString() const;
+
+    Type _type;
+  };
\ No newline at end of file
diff --git a/swig/Repository.i b/swig/Repository.i
new file mode 100644 (file)
index 0000000..32e0a2c
--- /dev/null
@@ -0,0 +1,15 @@
+  
+  class Repository : private base::SafeBool<Repository>
+  {
+    public:
+    Repository();
+    static const Repository noRepository;
+  public:
+    typedef unsigned long NumericId;
+    NumericId numericId() const;
+    const zypp::ResStore & resolvables();
+    const RepoInfo info() const;
+    const std::list<packagedelta::PatchRpm> & patchRpms() const;
+    const std::list<packagedelta::DeltaRpm> & deltaRpms() const;
+  };
+
index 793c866..3ae771d 100644 (file)
@@ -19,8 +19,8 @@ class ResObject : public Resolvable
     Vendor vendor() const;
     ByteCount size() const;
     ByteCount archivesize() const;
-    Source_Ref source() const;
-    unsigned sourceMediaNr() const;
+    Repository repository() const;
+    unsigned mediaNr() const;
     bool installOnly() const;
     Date buildtime() const;
     Date installtime() const;
diff --git a/swig/Source.i b/swig/Source.i
deleted file mode 100644 (file)
index 2ccb547..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-
-class Source_Ref
-{
-    friend std::ostream & operator<<( std::ostream & str, const Source_Ref & obj );
-    friend bool operator==( const Source_Ref & lhs, const Source_Ref & rhs );
-    friend bool operator<( const Source_Ref & lhs, const Source_Ref & rhs );
-
-  public:
-    typedef source::SourceImpl     Impl;
-    typedef source::SourceImpl_Ptr Impl_Ptr;
-
-  public:
-    Source_Ref();
-    static const Source_Ref noSource;
-
-  public:
-    typedef unsigned long NumericId;
-    NumericId numericId() const;
-
-  public:
-    std::string checksum() const;
-    Date timestamp() const;
-    bool hasResolvablesOfKind( const zypp::Resolvable::Kind &kind ) const;
-    std::set<zypp::Resolvable::Kind> resolvableKinds() const;
-    bool resStoreInitialized() const;
-    const ResStore & resolvables() const;
-    const ResStore resolvables(zypp::Resolvable::Kind kind) const;
-    //const Pathname providePackage( Package::constPtr package );
-    const Pathname provideFile(const Pathname & file_r, const unsigned media_nr = 1);
-    const Pathname provideDirTree(const Pathname & dir_r, const unsigned media_nr = 1);
-    const void releaseFile(const Pathname & file_r, const unsigned media_nr = 1);
-    const void releaseDir(const Pathname & dir_r, const unsigned media_nr = 1, bool recursive = false);
-    bool enabled() const;
-    void enable();
-    void disable();
-    bool autorefresh() const;
-    void setAutorefresh( bool enable_r );
-    void refresh();
-    void storeMetadata(const Pathname & cache_dir_r);
-    std::string alias (void) const;
-    void setAlias (const std::string & alias_r);
-    std::string type (void) const;
-    unsigned numberOfMedia(void) const;
-    std::string vendor (void) const;
-    std::string unique_id (void) const;
-    std::string id (void) const;
-    void setId (const std::string id_r);
-    unsigned priority (void) const;
-    void setPriority (unsigned p);
-    unsigned priorityUnsubscribed (void) const;
-    void setPriorityUnsubscribed (unsigned p);
-    bool subscribed (void) const;
-    void setSubscribed (bool s);
-    const Pathname & cacheDir (void) const;
-    const std::list<Pathname> publicKeys();
-    Url url (void) const;
-    void setUrl( const Url & url );
-    bool remote() const;
-    const Pathname & path (void) const;
-    bool baseSource() const;
-  public:
-    void changeMedia(const media::MediaId & media_r, const Pathname & path_r);
-    void redirect(unsigned media_nr, const Url & new_url);
-    void release();
-    void reattach(const Pathname &attach_point);
-    media::MediaVerifierRef verifier(unsigned media_nr);
-  private:
-    friend class SourceFactory;
-    friend class source::SourceImpl;
-  explicit
-    Source_Ref( const Impl_Ptr & impl_r );
-  };
\ No newline at end of file
diff --git a/swig/SourceFactory.i b/swig/SourceFactory.i
deleted file mode 100644 (file)
index e876e24..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-
-class SourceFactory
-  {
-    friend std::ostream & operator<<( std::ostream & str, const SourceFactory & obj );
-
-  public:
-    /** Default ctor */
-    SourceFactory();
-    /** Dtor */
-    ~SourceFactory();
-
-  public:
-    /** Construct source.
-     * \throw EXCEPTION on fail
-     */
-    Source_Ref createFrom( const source::SourceInfo & context );
-    
-    /** Construct source from an implementation.
-     * Returns Source_Ref::noSource on NULL \a impl_r.
-    */
-    //Source_Ref createFrom( const Source_Ref::Impl_Ptr & impl_r );
-
-    /** Construct source.
-     * \throw EXCEPTION on fail
-    */
-    Source_Ref createFrom( const Url & url_r, const Pathname & path_r = "/", const std::string & alias_r = "", const Pathname & cache_dir_r = "", bool base_source = false );
-
-    /** Construct source of a given type.
-     * \throw EXCEPTION on fail
-    */
-    Source_Ref createFrom( const std::string & type,  const Url & url_r, const Pathname & path_r, const std::string & alias_r, const Pathname & cache_dir_r, bool base_source, tribool auto_refresh );
-
-    protected:
-    template<class _SourceImpl>
-        Source_Ref createSourceImplWorkflow( media::MediaId id, const source::SourceInfo &context );
-  private:
-    /** Implementation  */
-    class Impl;
-    /** Pointer to implementation */
-    RW_pointer<Impl> _pimpl;
-
-  public:
-   struct ProductEntry {
-      Pathname    _dir;
-      std::string _name;
-      ProductEntry( const Pathname & dir_r = "/", const std::string & name_r = std::string() ){
-        _dir  = dir_r;
-        _name = name_r;
-      }
-      bool operator<( const ProductEntry & rhs ) const {
-        return( _dir.asString() < rhs._dir.asString() );
-      }
-    };
-
-    typedef std::set<ProductEntry> ProductSet;
-
-    /** Check which products are available on the media
-     * \throw Exception or MediaException on fail
-     */
-    void listProducts( const Url & url_r, ProductSet & products_r );
-  private:
-//     bool probeSource( const std::string name, boost::function<bool()> prober, callback::SendReport<CreateSourceReport> &report );
-    void scanProductsFile( const Pathname & file_r, ProductSet & pset_r ) const;
-  };
\ No newline at end of file
index 438afe3..ba95bd4 100644 (file)
@@ -10,3 +10,8 @@
 %typemap(freearg) const Url & {
  delete $1;
 }
+
+%typemap(out) Url {
+  VALUE rburlstr = rb_str_new2($1.asString().c_str());
+  $result = rburlstr ;
+}
\ No newline at end of file
index 5ab280f..baeea8a 100644 (file)
@@ -1,5 +1,12 @@
 
-%rename("asString") foo(to_s);
+%rename("asString") to_s;
+
+#define auto_string( cl ) \
+%extend cl { \
+  std::string to_s() { \
+    return self->asString();\
+  } \
+}
 
 #define iter( cl, storetype ) \
 %mixin cl "Enumerable"; \
     } \
 }
 
+#define auto_iterator( cl, storetype ) \
+%mixin cl "Enumerable"; \
+%extend cl { \
+    void each() { \
+        cl::iterator i = self->begin(); \
+        while ( i != self->end() ) { \
+            rb_yield( SWIG_NewPointerObj( (void *) &*i, $descriptor(storetype), 0)); \
+            ++i; \
+        } \
+    } \
+}
+
+
 %extend Target {
     void each_by_kind( const ResObject::Kind & kind_r )
     {
diff --git a/swig/std_list.i b/swig/std_list.i
new file mode 100644 (file)
index 0000000..f6d36e6
--- /dev/null
@@ -0,0 +1,533 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * std_list.i
+ *
+ * SWIG typemaps for std::list
+ * ----------------------------------------------------------------------------- */
+
+%include <std_common.i>
+
+// ------------------------------------------------------------------------
+// std::list
+// 
+// The aim of all that follows would be to integrate std::list with 
+// Ruby as much as possible, namely, to allow the user to pass and 
+// be returned Ruby arrays
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+// 
+//   -- f(std::list<T>), f(const std::list<T>&), f(const std::list<T>*):
+//      the parameter being read-only, either a Ruby array or a
+//      previously wrapped std::list<T> can be passed.
+//   -- f(std::list<T>&), f(std::list<T>*):
+//      the parameter must be modified; therefore, only a wrapped std::list
+//      can be passed.
+//   -- std::list<T> f():
+//      the list is returned by copy; therefore, a Ruby array of T:s 
+//      is returned which is most easily used in other Ruby functions
+//   -- std::list<T>& f(), std::list<T>* f(), const std::list<T>& f(),
+//      const std::list<T>* f():
+//      the list is returned by reference; therefore, a wrapped std::list
+//      is returned
+// ------------------------------------------------------------------------
+
+%{
+#include <list>
+#include <algorithm>
+#include <stdexcept>
+%}
+
+// exported class
+
+namespace std {
+
+    %mixin list "Enumerable";
+
+    template<class T> class list {
+        %typemap(in) list<T> {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                $1;
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    T* x;
+                   SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+                    $1.push_back(*x);
+                }
+            } else {
+               void *ptr;
+                SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+                $1 = *(($&1_type) ptr);
+            }
+        }
+        %typemap(in) const list<T>& (std::list<T> temp),
+                     const list<T>* (std::list<T> temp) {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                $1 = &temp;
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    T* x;
+                    SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+                    temp.push_back(*x);
+                }
+            } else {
+                SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+            }
+        }
+        
+        void each() {
+                for ( std::list<T>::const_iterator it = self->begin();
+                      it != self->end();
+                      ++it )
+                {
+                  T* x = &(*it);
+                    rb_yield(SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+                }
+            }
+        
+        
+        %typemap(out) list<T> {
+            $result = rb_ary_new2($1.size());
+            unsigned int i = 0;
+            for ( std::list<T>::iterator it = $1.begin();
+                  it != $1.end();
+                  ++it )
+            {
+                T* x = new T((*it));
+                rb_ary_store($result,i,
+                             SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 1));
+                ++i;
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) list<T> {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    T* x;
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if ((SWIG_ConvertPtr(o,(void **) &x, 
+                                         $descriptor(T *),0)) != -1)
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped list? */
+                std::list<T >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $&1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) const list<T>&,
+                                          const list<T>* {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    T* x;
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if ((SWIG_ConvertPtr(o,(void **) &x, 
+                                         $descriptor(T *),0)) != -1)
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped list? */
+                std::list<T >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+      public:
+        list();
+        list(unsigned int size);
+        list(unsigned int size, const T& value);
+        list(const list<T> &);
+
+        %rename(__len__) size;
+        unsigned int size() const;
+        %rename("empty?") empty;
+        bool empty() const;
+        void clear();
+        %rename(push) push_back;
+        void push_back(const T& x);
+        %extend {
+            /*
+            T pop() throw (std::out_of_range) {
+                if (self->size() == 0)
+                    throw std::out_of_range("pop from empty list");
+                T x = self->back();
+                self->pop_back();
+                return x;
+            }
+            T& __getitem__(int i) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i += size;
+                if (i>=0 && i<size)
+                    return (*self)[i];
+                else
+                    throw std::out_of_range("list index out of range");
+            }
+            void __setitem__(int i, const T& x) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i+= size;
+                if (i>=0 && i<size)
+                    (*self)[i] = x;
+                else
+                    throw std::out_of_range("list index out of range");
+            }
+            */
+            void each() {
+                for ( std::list<T>::iterator it = self->begin();
+                      it != self->end();
+                      ++it )
+                {
+                  T* x = &(*it);
+                    rb_yield(SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+                }
+            }
+        }
+    };
+
+    // Partial specialization for lists of pointers.  [ beazley ]
+
+    %mixin list<T*> "Enumerable";
+    template<class T> class list<T*> {
+        %typemap(in) list<T*> {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                $1 = std::list<T* >(size);
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    T* x;
+                    SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+                    (($1_type &)$1)[i] = x;
+                }
+            } else {
+                void *ptr;
+                SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+                $1 = *(($&1_type) ptr);
+            }
+        }
+        %typemap(in) const list<T*>& (std::list<T*> temp),
+                     const list<T*>* (std::list<T*> temp) {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                temp = std::list<T* >(size);
+                $1 = &temp;
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    T* x;
+                    SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+                    temp[i] = x;
+                }
+            } else {
+                SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+            }
+        }
+        %typemap(out) list<T*> {
+            $result = rb_ary_new2($1.size());
+            for (unsigned int i=0; i<$1.size(); i++) {
+                T* x = (($1_type &)$1)[i];
+                rb_ary_store($result,i,
+                             SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) list<T*> {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    T* x;
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if ((SWIG_ConvertPtr(o,(void **) &x, 
+                                         $descriptor(T *),0)) != -1)
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped list? */
+                std::list<T* >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $&1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) const list<T*>&,
+                                          const list<T*>* {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    T* x;
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if ((SWIG_ConvertPtr(o,(void **) &x, 
+                                         $descriptor(T *),0)) != -1)
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped list? */
+                std::list<T* >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+      public:
+        list();
+        list(unsigned int size);
+        list(unsigned int size, T * &value);
+        list(const list<T*> &);
+
+        %rename(__len__) size;
+        unsigned int size() const;
+        %rename("empty?") empty;
+        bool empty() const;
+        void clear();
+        %rename(push) push_back;
+        void push_back(T* x);
+        %extend {
+            /*
+            T* pop() throw (std::out_of_range) {
+                if (self->size() == 0)
+                    throw std::out_of_range("pop from empty list");
+                T* x = self->back();
+                self->pop_back();
+                return x;
+            }
+            T* __getitem__(int i) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i += size;
+                if (i>=0 && i<size)
+                    return (*self)[i];
+                else
+                    throw std::out_of_range("list index out of range");
+            }
+            void __setitem__(int i, T* x) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i+= size;
+                if (i>=0 && i<size)
+                    (*self)[i] = x;
+                else
+                    throw std::out_of_range("list index out of range");
+            }
+            */
+            void each() {
+                for ( std::list<T>::iterator it = self->begin();
+                      it != self->end();
+                      ++it )
+                {
+                  T* x = &(*it);
+                    rb_yield(SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+                }
+            }
+        }
+    };
+        
+
+    // specializations for built-ins
+
+    %define specialize_std_list(T,CHECK,CONVERT_FROM,CONVERT_TO)
+    %mixin list<T> "Enumerable";
+    template<> class list<T> {
+        %typemap(in) list<T> {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                $1 = std::list<T >(size);
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    if (CHECK(o))
+                        (($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
+                    else
+                        rb_raise(rb_eTypeError,
+                                 "wrong argument type"
+                                 " (expected list<" #T ">)");
+                }
+            } else {
+               void *ptr;
+                SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+                $1 = *(($&1_type) ptr);
+            }
+        }
+        %typemap(in) const list<T>& (std::list<T> temp),
+                     const list<T>* (std::list<T> temp) {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                temp = std::list<T >(size);
+                $1 = &temp;
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    if (CHECK(o))
+                        temp[i] = (T)(CONVERT_FROM(o));
+                    else
+                        rb_raise(rb_eTypeError,
+                                 "wrong argument type"
+                                 " (expected list<" #T ">)");
+                }
+            } else {
+                SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+            }
+        }
+        %typemap(out) list<T> {
+            $result = rb_ary_new2($1.size());
+            for (unsigned int i=0; i<$1.size(); i++)
+                rb_ary_store($result,i,CONVERT_TO((($1_type &)$1)[i]));
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) list<T> {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if (CHECK(o))
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped list? */
+                std::list<T >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $&1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) const list<T>&,
+                                          const list<T>* {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if (CHECK(o))
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped list? */
+                std::list<T >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+      public:
+        list();
+        list(unsigned int size);
+        list(unsigned int size, const T& value);
+        list(const list<T> &);
+
+        %rename(__len__) size;
+        unsigned int size() const;
+        %rename("empty?") empty;
+        bool empty() const;
+        void clear();
+        %rename(push) push_back;
+        void push_back(T x);
+        %extend {
+            /*
+            T pop() throw (std::out_of_range) {
+                if (self->size() == 0)
+                    throw std::out_of_range("pop from empty list");
+                T x = self->back();
+                self->pop_back();
+                return x;
+            }
+            T __getitem__(int i) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i += size;
+                if (i>=0 && i<size)
+                    return (*self)[i];
+                else
+                    throw std::out_of_range("list index out of range");
+            }
+            void __setitem__(int i, T x) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i+= size;
+                if (i>=0 && i<size)
+                    (*self)[i] = x;
+                else
+                    throw std::out_of_range("list index out of range");
+            }
+            */
+            void each() {
+                for ( std::list<T>::iterator it = self->begin();
+                      it != self->end();
+                      ++it )
+                {
+                  T* x = &(*it);
+                    rb_yield(SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+                }
+            }
+        }
+    };
+    %enddef
+
+    specialize_std_list(bool,SWIG_BOOL_P,SWIG_RB2BOOL,SWIG_BOOL2RB);
+    specialize_std_list(char,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_list(int,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_list(short,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_list(long,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_list(unsigned char,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_list(unsigned int,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_list(unsigned short,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_list(unsigned long,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_list(double,SWIG_FLOAT_P,SWIG_NUM2DBL,rb_float_new);
+    specialize_std_list(float,SWIG_FLOAT_P,SWIG_NUM2DBL,rb_float_new);
+    specialize_std_list(std::string,SWIG_STRING_P,SWIG_RB2STR,SWIG_STR2RB);
+
+}
+
diff --git a/swig/std_set.i b/swig/std_set.i
new file mode 100644 (file)
index 0000000..af2a146
--- /dev/null
@@ -0,0 +1,527 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * std_set.i
+ *
+ * SWIG typemaps for std::set
+ * ----------------------------------------------------------------------------- */
+
+%include <std_common.i>
+
+// ------------------------------------------------------------------------
+// std::set
+// 
+// The aim of all that follows would be to integrate std::set with 
+// Ruby as much as possible, namely, to allow the user to pass and 
+// be returned Ruby arrays
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+// 
+//   -- f(std::set<T>), f(const std::set<T>&), f(const std::set<T>*):
+//      the parameter being read-only, either a Ruby array or a
+//      previously wrapped std::set<T> can be passed.
+//   -- f(std::set<T>&), f(std::set<T>*):
+//      the parameter must be modified; therefore, only a wrapped std::set
+//      can be passed.
+//   -- std::set<T> f():
+//      the set is returned by copy; therefore, a Ruby array of T:s 
+//      is returned which is most easily used in other Ruby functions
+//   -- std::set<T>& f(), std::set<T>* f(), const std::set<T>& f(),
+//      const std::set<T>* f():
+//      the set is returned by reference; therefore, a wrapped std::set
+//      is returned
+// ------------------------------------------------------------------------
+
+%{
+#include <set>
+#include <algorithm>
+#include <stdexcept>
+%}
+
+// exported class
+
+namespace std {
+
+    %mixin set "Enumerable";
+
+    template<class T> class set {
+        %typemap(in) set<T> {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                $1;
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    T* x;
+                   SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+                    $1.insert(*x);
+                }
+            } else {
+               void *ptr;
+                SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+                $1 = *(($&1_type) ptr);
+            }
+        }
+        %typemap(in) const set<T>& (std::set<T> temp),
+                     const set<T>* (std::set<T> temp) {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                $1 = &temp;
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    T* x;
+                    SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+                    temp.insert(*x);
+                }
+            } else {
+                SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+            }
+        }
+        
+        void each() {
+                for ( std::set<T>::iterator it = self->begin();
+                      it != self->end();
+                      ++it )
+                {
+                  T* x = (T *) &(*it);
+                    rb_yield(SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+                }
+            }
+        
+        
+        %typemap(out) set<T> {
+            $result = rb_ary_new2($1.size());
+            unsigned int i = 0;
+            for ( std::set<T>::iterator it = $1.begin();
+                  it != $1.end();
+                  ++it )
+            {
+                T* x = new T((*it));
+                rb_ary_store($result,i,
+                             SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 1));
+                ++i;
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) set<T> {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    T* x;
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if ((SWIG_ConvertPtr(o,(void **) &x, 
+                                         $descriptor(T *),0)) != -1)
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped set? */
+                std::set<T >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $&1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) const set<T>&,
+                                          const set<T>* {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    T* x;
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if ((SWIG_ConvertPtr(o,(void **) &x, 
+                                         $descriptor(T *),0)) != -1)
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped set? */
+                std::set<T >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+      public:
+        set();
+        set(const set<T> &);
+
+        %rename(__len__) size;
+        unsigned int size() const;
+        %rename("empty?") empty;
+        bool empty() const;
+        void clear();
+        %rename(push) insert;
+        void insert(const T& x);
+        %extend {
+            /*
+            T pop() throw (std::out_of_range) {
+                if (self->size() == 0)
+                    throw std::out_of_range("pop from empty set");
+                T x = self->back();
+                self->pop_back();
+                return x;
+            }
+            T& __getitem__(int i) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i += size;
+                if (i>=0 && i<size)
+                    return (*self)[i];
+                else
+                    throw std::out_of_range("set index out of range");
+            }
+            void __setitem__(int i, const T& x) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i+= size;
+                if (i>=0 && i<size)
+                    (*self)[i] = x;
+                else
+                    throw std::out_of_range("set index out of range");
+            }
+            */
+            void each() {
+                for ( std::set<T>::iterator it = self->begin();
+                      it != self->end();
+                      ++it )
+                {
+                  T* x = (T *)&(*it);
+                    rb_yield(SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+                }
+            }
+        }
+    };
+
+    // Partial specialization for sets of pointers.  [ beazley ]
+
+    %mixin set<T*> "Enumerable";
+    template<class T> class set<T*> {
+        %typemap(in) set<T*> {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                $1 = std::set<T* >(size);
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    T* x;
+                    SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+                    (($1_type &)$1)[i] = x;
+                }
+            } else {
+                void *ptr;
+                SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+                $1 = *(($&1_type) ptr);
+            }
+        }
+        %typemap(in) const set<T*>& (std::set<T*> temp),
+                     const set<T*>* (std::set<T*> temp) {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                temp = std::set<T* >(size);
+                $1 = &temp;
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    T* x;
+                    SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+                    temp[i] = x;
+                }
+            } else {
+                SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+            }
+        }
+        %typemap(out) set<T*> {
+            $result = rb_ary_new2($1.size());
+            for (unsigned int i=0; i<$1.size(); i++) {
+                T* x = (($1_type &)$1)[i];
+                rb_ary_store($result,i,
+                             SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) set<T*> {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    T* x;
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if ((SWIG_ConvertPtr(o,(void **) &x, 
+                                         $descriptor(T *),0)) != -1)
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped set? */
+                std::set<T* >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $&1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) const set<T*>&,
+                                          const set<T*>* {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    T* x;
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if ((SWIG_ConvertPtr(o,(void **) &x, 
+                                         $descriptor(T *),0)) != -1)
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped set? */
+                std::set<T* >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+      public:
+        set();
+        set(const set<T*> &);
+
+        %rename(__len__) size;
+        unsigned int size() const;
+        %rename("empty?") empty;
+        bool empty() const;
+        void clear();
+        %rename(push) insert;
+        void insert(T* x);
+        %extend {
+            /*
+            T* pop() throw (std::out_of_range) {
+                if (self->size() == 0)
+                    throw std::out_of_range("pop from empty set");
+                T* x = self->back();
+                self->pop_back();
+                return x;
+            }
+            T* __getitem__(int i) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i += size;
+                if (i>=0 && i<size)
+                    return (*self)[i];
+                else
+                    throw std::out_of_range("set index out of range");
+            }
+            void __setitem__(int i, T* x) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i+= size;
+                if (i>=0 && i<size)
+                    (*self)[i] = x;
+                else
+                    throw std::out_of_range("set index out of range");
+            }
+            */
+            void each() {
+                for ( std::set<T>::iterator it = self->begin();
+                      it != self->end();
+                      ++it )
+                {
+                  T* x = (T*) &(*it);
+                    rb_yield(SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+                }
+            }
+        }
+    };
+        
+
+    // specializations for built-ins
+
+    %define specialize_std_set(T,CHECK,CONVERT_FROM,CONVERT_TO)
+    %mixin set<T> "Enumerable";
+    template<> class set<T> {
+        %typemap(in) set<T> {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                $1 = std::set<T >(size);
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    if (CHECK(o))
+                        (($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
+                    else
+                        rb_raise(rb_eTypeError,
+                                 "wrong argument type"
+                                 " (expected set<" #T ">)");
+                }
+            } else {
+               void *ptr;
+                SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+                $1 = *(($&1_type) ptr);
+            }
+        }
+        %typemap(in) const set<T>& (std::set<T> temp),
+                     const set<T>* (std::set<T> temp) {
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                temp = std::set<T >(size);
+                $1 = &temp;
+                for (unsigned int i=0; i<size; i++) {
+                    VALUE o = RARRAY($input)->ptr[i];
+                    if (CHECK(o))
+                        temp[i] = (T)(CONVERT_FROM(o));
+                    else
+                        rb_raise(rb_eTypeError,
+                                 "wrong argument type"
+                                 " (expected set<" #T ">)");
+                }
+            } else {
+                SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+            }
+        }
+        %typemap(out) set<T> {
+            $result = rb_ary_new2($1.size());
+            for (unsigned int i=0; i<$1.size(); i++)
+                rb_ary_store($result,i,CONVERT_TO((($1_type &)$1)[i]));
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) set<T> {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if (CHECK(o))
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped set? */
+                std::set<T >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $&1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+        %typecheck(SWIG_TYPECHECK_VECTOR) const set<T>&,
+                                          const set<T>* {
+            /* native sequence? */
+            if (rb_obj_is_kind_of($input,rb_cArray)) {
+                unsigned int size = RARRAY($input)->len;
+                if (size == 0) {
+                    /* an empty sequence can be of any type */
+                    $1 = 1;
+                } else {
+                    /* check the first element only */
+                    VALUE o = RARRAY($input)->ptr[0];
+                    if (CHECK(o))
+                        $1 = 1;
+                    else
+                        $1 = 0;
+                }
+            } else {
+                /* wrapped set? */
+                std::set<T >* v;
+                if (SWIG_ConvertPtr($input,(void **) &v, 
+                                    $1_descriptor,0) != -1)
+                    $1 = 1;
+                else
+                    $1 = 0;
+            }
+        }
+      public:
+        set();
+        set(const set<T> &);
+
+        %rename(__len__) size;
+        unsigned int size() const;
+        %rename("empty?") empty;
+        bool empty() const;
+        void clear();
+        %rename(push) insert;
+        void insert(T x);
+        %extend {
+            /*
+            T pop() throw (std::out_of_range) {
+                if (self->size() == 0)
+                    throw std::out_of_range("pop from empty set");
+                T x = self->back();
+                self->pop_back();
+                return x;
+            }
+            T __getitem__(int i) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i += size;
+                if (i>=0 && i<size)
+                    return (*self)[i];
+                else
+                    throw std::out_of_range("set index out of range");
+            }
+            void __setitem__(int i, T x) throw (std::out_of_range) {
+                int size = int(self->size());
+                if (i<0) i+= size;
+                if (i>=0 && i<size)
+                    (*self)[i] = x;
+                else
+                    throw std::out_of_range("set index out of range");
+            }
+            */
+            void each() {
+                for ( std::set<T>::iterator it = self->begin();
+                      it != self->end();
+                      ++it )
+                {
+                  T* x = &(*it);
+                    rb_yield(SWIG_NewPointerObj((void *) x, 
+                                                $descriptor(T *), 0));
+                }
+            }
+        }
+    };
+    %enddef
+
+    specialize_std_set(bool,SWIG_BOOL_P,SWIG_RB2BOOL,SWIG_BOOL2RB);
+    specialize_std_set(char,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_set(int,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_set(short,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_set(long,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_set(unsigned char,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_set(unsigned int,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_set(unsigned short,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_set(unsigned long,FIXNUM_P,FIX2INT,INT2NUM);
+    specialize_std_set(double,SWIG_FLOAT_P,SWIG_NUM2DBL,rb_float_new);
+    specialize_std_set(float,SWIG_FLOAT_P,SWIG_NUM2DBL,rb_float_new);
+    specialize_std_set(std::string,SWIG_STRING_P,SWIG_RB2STR,SWIG_STR2RB);
+
+}
+
index a987a35..20f503d 100644 (file)
@@ -1,5 +1,4 @@
 %module rzypp
-%include std_string.i
  %{
  /* Includes the header in the wrapper code */
 
@@ -12,8 +11,6 @@
  #include <zypp/ZYpp.h>
  #include <zypp/Pathname.h>
  #include "zypp/base/ReferenceCounted.h"
- #include "zypp/SourceFactory.h"
- #include "zypp/Source.h"
  #include "zypp/ResObject.h"
  #include "zypp/Target.h"
  #include "zypp/target/TargetImpl.h"
  #include "zypp/CapFactory.h"
  #include "zypp/Package.h"
 #include "zypp/ResFilters.h"
-#include "zypp/source/OnMediaLocation.h"
+#include "zypp/OnMediaLocation.h"
+ #include "zypp/Repository.h"
+ #include "zypp/RepoManager.h"
+ #include "zypp/repo/RepoType.h"
 #include "zypp/MediaSetAccess.h"
   
  using namespace boost;
  using namespace zypp;
+ using namespace zypp::repo;
  using namespace zypp::resfilter;
 
+ typedef std::set<Url> UrlSet;
  %}
 
-#ifdef SWIGRUBY
-%include "ruby.i"
-#endif
-
 %rename("+") "operator+";
 %rename("<<") "operator<<";
 %rename("!=") "operator!=";
@@ -57,6 +55,13 @@ class intrusive_ptr {
 };
 
 %include "Pathname.i"
+%include "Url.i"
+    
+%include std_string.i
+%include "stl.i"
+%include "std_list.i"
+%include "std_set.i"
 %include "Arch.i"
 %include "ResStore.i"
 %include "Edition.i"
@@ -64,8 +69,11 @@ class intrusive_ptr {
 %include "Date.i"
 %include "Resolvable.i"
 %include "ByteCount.i"
-%include "Source.i"
-%include "SourceFactory.i"
+%include "RepoType.i"
+%include "Repository.i"
+%include "RepoInfo.i"
+%include "RepoManager.i"
+%include "RepoStatus.i"
 %include "ResObject.i"
 %include "TranslatedText.i"
 %include "CheckSum.i"
@@ -85,11 +93,18 @@ class intrusive_ptr {
 %include "ResPool.i"
 %include "ZYppCommitPolicy.i"
 %include "ZYppCommitResult.i"
-%include "Url.i"
 %include "MediaSetAccess.i"
 
+    
+#ifdef SWIGRUBY
+%include "ruby.i"
+#endif
+    
+
 /* define iterators using swig macros */
 iter2( ResStore, ResObject::Ptr )
+auto_iterator( std::list<RepoInfo>, RepoInfo )
+%alias Arch::asString "to_s";
     
 class ZYpp
 {