Author: aschnell Date: Thu Aug 23 17:07:25 2007 New Revision: 6844 URL: http://svn.opensuse.org/viewcvs/zypp?rev=6844&view=rev Log: - added to_a functions Modified: trunk/libzypp-bindings/package/libzypp-bindings.changes trunk/libzypp-bindings/swig/ruby/ruby.i Modified: trunk/libzypp-bindings/package/libzypp-bindings.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/package/libzypp-bindings.changes?rev=6844&r1=6843&r2=6844&view=diff ============================================================================== --- trunk/libzypp-bindings/package/libzypp-bindings.changes (original) +++ trunk/libzypp-bindings/package/libzypp-bindings.changes Thu Aug 23 17:07:25 2007 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Thu Aug 23 17:10:56 CEST 2007 - aschnell@suse.de + +- added to_a functions + +------------------------------------------------------------------- Thu Aug 23 12:49:01 CEST 2007 - aschnell@suse.de - added some comparison functions Modified: trunk/libzypp-bindings/swig/ruby/ruby.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/ruby/ruby.i?rev=6844&r1=6843&r2=6844&view=diff ============================================================================== --- trunk/libzypp-bindings/swig/ruby/ruby.i (original) +++ trunk/libzypp-bindings/swig/ruby/ruby.i Thu Aug 23 17:07:25 2007 @@ -1,19 +1,31 @@ /* - * Extend cls with an ruby-like each iterator. Yields objects of type storetype. - * Parameter storetype must be a pointer type. + * Extend cls with an ruby-like each iterator and a to_a method. Yields + * objects of type storetype. Parameter storetype must be a pointer type. */ #define iter2(cls, storetype) \ %mixin cls "Enumerable"; \ -%extend cls { \ +%extend cls \ +{ \ void each() { \ cls::const_iterator i = self->begin(); \ while (i != self->end()) { \ const storetype tmp = &**i; \ rb_yield(SWIG_NewPointerObj((void*) tmp, $descriptor(storetype), 0)); \ - ++i; \ + i++; \ + } \ + } \ +\ + VALUE to_a() { \ + VALUE ary = rb_ary_new(); \ + cls::const_iterator i = self->begin(); \ + while (i != self->end()) { \ + const storetype tmp = &**i; \ + rb_ary_push(ary, SWIG_NewPointerObj((void*) tmp, $descriptor(storetype), 0)); \ + i++; \ } \ + return ary; \ } \ } @@ -22,14 +34,26 @@ */ #define iter3(cls, storetype) \ %mixin cls "Enumerable"; \ -%extend cls { \ +%extend cls \ +{ \ void each() { \ cls::const_iterator i = self->begin(); \ while (i != self->end()) { \ const storetype tmp = &*i; \ rb_yield(SWIG_NewPointerObj((void*) tmp, $descriptor(storetype), 0)); \ - ++i; \ + i++; \ + } \ + } \ +\ + VALUE to_a() { \ + VALUE ary = rb_ary_new(); \ + cls::const_iterator i = self->begin(); \ + while (i != self->end()) { \ + const storetype tmp = &*i; \ + rb_ary_push(ary, SWIG_NewPointerObj((void*) tmp, $descriptor(storetype), 0)); \ + i++; \ } \ + return ary; \ } \ } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org