Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11663 - /trunk/sat-solver/bindings/pool.i
  • From: kkaempf@xxxxxxxxxxxxxxxx
  • Date: Wed, 12 Nov 2008 14:43:04 -0000
  • Message-id: <20081112144304.9490737295@xxxxxxxxxxxxxxxx>
Author: kkaempf
Date: Wed Nov 12 15:43:04 2008
New Revision: 11663

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11663&view=rev
Log:
document providers iterators better

Modified:
trunk/sat-solver/bindings/pool.i

Modified: trunk/sat-solver/bindings/pool.i
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/pool.i?rev=11663&r1=11662&r2=11663&view=diff
==============================================================================
--- trunk/sat-solver/bindings/pool.i (original)
+++ trunk/sat-solver/bindings/pool.i Wed Nov 12 15:43:04 2008
@@ -186,7 +186,16 @@
return NULL;
}

+ /*
+ * Ruby has real iterators and callbacks, which make iterating over
+ * providers (of name or relation) straightforward.
+ *
+ * Other languages have to revert to providers_count and
+ * providers_get and implement iterators themselves
+ */
+
#if defined(SWIGRUBY)
+
/*
* iterate over providers of relation
*/
@@ -197,12 +206,25 @@
if (!$self->whatprovides)
pool_createwhatprovides( $self );

- FOR_PROVIDES(p, pp, rel->id)
+ FOR_PROVIDES(p, pp, rel->id) {
generic_xsolvables_iterate_callback( xsolvable_new( $self, p ), NULL );
+ }
}
+
+ void each_provider( const char *name )
+ {
+ Id p, pp;
+ Pool *pool = $self;
+ if (!$self->whatprovides)
+ pool_createwhatprovides($self);
+
+ FOR_PROVIDES(p, pp, str2id( $self, name, 0) ) {
+ generic_xsolvables_iterate_callback( xsolvable_new( $self, p ), NULL );
+ }
+ }
+
#endif

-#if defined(SWIGPYTHON)

int providers_count( const char *name )
{ int i = 0;
@@ -228,6 +250,12 @@
vp = $self->whatprovidesdata + pool_whatprovides($self, rel->id);
return xsolvable_new( $self, *(vp + i));
}
+
+ /*
+ * providers iterator for Python
+ * using providers_count and providers_get
+ */
+#if defined(SWIGPYTHON)
%pythoncode %{
def providers(self,what):
if self.unprepared():
@@ -238,19 +266,6 @@
%}
#endif

- void each_provider( const char *name )
- {
-#if defined(SWIGRUBY)
- Id p, pp;
- Pool *pool = $self;
- if (!$self->whatprovides)
- pool_createwhatprovides($self);
-
- FOR_PROVIDES(p, pp, str2id( $self, name, 0) )
- generic_xsolvables_iterate_callback( xsolvable_new( $self, p ), NULL );
-#endif
- }
-
/*
* Solvable management
*/

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages