Author: dmacvicar
Date: Thu Jun 21 17:17:15 2007
New Revision: 5823
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5823&view=rev
Log:
some updates
Added:
branches/REFACTORING-10_3/libzypp-bindings/examples/ruby/play_with_repos.rb
branches/REFACTORING-10_3/libzypp-bindings/swig/RepoInfo.i
branches/REFACTORING-10_3/libzypp-bindings/swig/RepoManager.i
branches/REFACTORING-10_3/libzypp-bindings/swig/RepoStatus.i
branches/REFACTORING-10_3/libzypp-bindings/swig/RepoType.i
branches/REFACTORING-10_3/libzypp-bindings/swig/Repository.i
branches/REFACTORING-10_3/libzypp-bindings/swig/std_list.i
branches/REFACTORING-10_3/libzypp-bindings/swig/std_set.i
Removed:
branches/REFACTORING-10_3/libzypp-bindings/swig/Source.i
branches/REFACTORING-10_3/libzypp-bindings/swig/SourceFactory.i
Modified:
branches/REFACTORING-10_3/libzypp-bindings/CMakeLists.txt
branches/REFACTORING-10_3/libzypp-bindings/swig/Capability.i
branches/REFACTORING-10_3/libzypp-bindings/swig/ResObject.i
branches/REFACTORING-10_3/libzypp-bindings/swig/Url.i
branches/REFACTORING-10_3/libzypp-bindings/swig/ruby.i
branches/REFACTORING-10_3/libzypp-bindings/swig/zypp.i
Modified: branches/REFACTORING-10_3/libzypp-bindings/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/CMakeLists.txt?rev=5823&r1=5822&r2=5823&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/CMakeLists.txt (original)
+++ branches/REFACTORING-10_3/libzypp-bindings/CMakeLists.txt Thu Jun 21 17:17:15 2007
@@ -32,7 +32,7 @@
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
Added: branches/REFACTORING-10_3/libzypp-bindings/examples/ruby/play_with_repos.rb
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/examples/ruby/play_with_repos.rb?rev=5823&view=auto
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/examples/ruby/play_with_repos.rb (added)
+++ branches/REFACTORING-10_3/libzypp-bindings/examples/ruby/play_with_repos.rb Thu Jun 21 17:17:15 2007
@@ -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
+
Modified: branches/REFACTORING-10_3/libzypp-bindings/swig/Capability.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/Capability.i?rev=5823&r1=5822&r2=5823&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/Capability.i (original)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/Capability.i Thu Jun 21 17:17:15 2007
@@ -44,11 +44,7 @@
/** 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 ;
Added: branches/REFACTORING-10_3/libzypp-bindings/swig/RepoInfo.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/RepoInfo.i?rev=5823&view=auto
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/RepoInfo.i (added)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/RepoInfo.i Thu Jun 21 17:17:15 2007
@@ -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>;
+
Added: branches/REFACTORING-10_3/libzypp-bindings/swig/RepoManager.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/RepoManager.i?rev=5823&view=auto
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/RepoManager.i (added)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/RepoManager.i Thu Jun 21 17:17:15 2007
@@ -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() );
+
+ };
Added: branches/REFACTORING-10_3/libzypp-bindings/swig/RepoStatus.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/RepoStatus.i?rev=5823&view=auto
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/RepoStatus.i (added)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/RepoStatus.i Thu Jun 21 17:17:15 2007
@@ -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 ×tamp );
+
+ /** 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
Added: branches/REFACTORING-10_3/libzypp-bindings/swig/RepoType.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/RepoType.i?rev=5823&view=auto
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/RepoType.i (added)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/RepoType.i Thu Jun 21 17:17:15 2007
@@ -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
Added: branches/REFACTORING-10_3/libzypp-bindings/swig/Repository.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/Repository.i?rev=5823&view=auto
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/Repository.i (added)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/Repository.i Thu Jun 21 17:17:15 2007
@@ -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::listpackagedelta::PatchRpm & patchRpms() const;
+ const std::listpackagedelta::DeltaRpm & deltaRpms() const;
+ };
+
Modified: branches/REFACTORING-10_3/libzypp-bindings/swig/ResObject.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/ResObject.i?rev=5823&r1=5822&r2=5823&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/ResObject.i (original)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/ResObject.i Thu Jun 21 17:17:15 2007
@@ -19,8 +19,8 @@
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;
Modified: branches/REFACTORING-10_3/libzypp-bindings/swig/Url.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/Url.i?rev=5823&r1=5822&r2=5823&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/Url.i (original)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/Url.i Thu Jun 21 17:17:15 2007
@@ -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
Modified: branches/REFACTORING-10_3/libzypp-bindings/swig/ruby.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/ruby.i?rev=5823&r1=5822&r2=5823&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/ruby.i (original)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/ruby.i Thu Jun 21 17:17:15 2007
@@ -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"; \
@@ -25,6 +32,19 @@
} \
}
+#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 )
{
Added: branches/REFACTORING-10_3/libzypp-bindings/swig/std_list.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/std_list.i?rev=5823&view=auto
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/std_list.i (added)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/std_list.i Thu Jun 21 17:17:15 2007
@@ -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::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; iptr[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; iptr[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 && isize());
+ if (i<0) i+= size;
+ if (i>=0 && ibegin();
+ 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 "Enumerable";
+ template<class T> class list {
+ %typemap(in) list {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1 = std::list(size);
+ for (unsigned int i=0; iptr[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& (std::list temp),
+ const list* (std::list temp) {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ temp = std::list(size);
+ $1 = &temp;
+ for (unsigned int i=0; iptr[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 {
+ $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 {
+ /* 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* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $&1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) const list&,
+ const list* {
+ /* 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* 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 &);
+
+ %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 && isize());
+ if (i<0) i+= size;
+ if (i>=0 && ibegin();
+ 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; iptr[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; iptr[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 && isize());
+ if (i<0) i+= size;
+ if (i>=0 && ibegin();
+ 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);
+
+}
+
Added: branches/REFACTORING-10_3/libzypp-bindings/swig/std_set.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/std_set.i?rev=5823&view=auto
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/std_set.i (added)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/std_set.i Thu Jun 21 17:17:15 2007
@@ -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::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; iptr[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; iptr[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 && isize());
+ if (i<0) i+= size;
+ if (i>=0 && ibegin();
+ 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 "Enumerable";
+ template<class T> class set {
+ %typemap(in) set {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1 = std::set(size);
+ for (unsigned int i=0; iptr[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& (std::set temp),
+ const set* (std::set temp) {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ temp = std::set(size);
+ $1 = &temp;
+ for (unsigned int i=0; iptr[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 {
+ $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 {
+ /* 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* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $&1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) const set&,
+ const set* {
+ /* 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* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ public:
+ set();
+ set(const set &);
+
+ %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 && isize());
+ if (i<0) i+= size;
+ if (i>=0 && ibegin();
+ 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; iptr[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; iptr[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 && isize());
+ if (i<0) i+= size;
+ if (i>=0 && ibegin();
+ 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);
+
+}
+
Modified: branches/REFACTORING-10_3/libzypp-bindings/swig/zypp.i
URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp-bindings/swig/zypp.i?rev=5823&r1=5822&r2=5823&view=diff
==============================================================================
--- branches/REFACTORING-10_3/libzypp-bindings/swig/zypp.i (original)
+++ branches/REFACTORING-10_3/libzypp-bindings/swig/zypp.i Thu Jun 21 17:17:15 2007
@@ -1,5 +1,4 @@
%module rzypp
-%include std_string.i
%{
/* Includes the header in the wrapper code */
@@ -12,8 +11,6 @@
#include
#include
#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"
@@ -21,19 +18,20 @@
#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 @@
};
%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 @@
%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 @@
%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
{
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org