Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11667 - in /trunk/sat-solver/bindings: perl/tests/providers.pl pool.i
  • From: kkaempf@xxxxxxxxxxxxxxxx
  • Date: Wed, 12 Nov 2008 15:49:43 -0000
  • Message-id: <20081112154944.2072737362@xxxxxxxxxxxxxxxx>
Author: kkaempf
Date: Wed Nov 12 16:49:43 2008
New Revision: 11667

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11667&view=rev
Log:
add 'pool->providers()' for Perl, and testcase

Modified:
trunk/sat-solver/bindings/perl/tests/providers.pl
trunk/sat-solver/bindings/pool.i

Modified: trunk/sat-solver/bindings/perl/tests/providers.pl
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/perl/tests/providers.pl?rev=11667&r1=11666&r2=11667&view=diff
==============================================================================
--- trunk/sat-solver/bindings/perl/tests/providers.pl (original)
+++ trunk/sat-solver/bindings/perl/tests/providers.pl Wed Nov 12 16:49:43 2008
@@ -39,36 +39,28 @@
# Find Providers of Relation $rel
$solvname = $mysolvable->string();
print "\nFinding providers for relation $rel ...\n";
-$provcount = $pool->providers_count($rel);
-print "\nFound $provcount providers for relation $rel ...\n";
-$solvable = $pool->providers_get($rel, 0);
-$name = $solvable->name();
-print "\nFound $name as provider for relation $rel ...\n";
-#foreach my $solvable ($pool->providers($rel)) {
-# print "--\n";
-# next if not defined $solvable;
-#
-# my $name = $solvable->name();
-# next if not defined $name;
-# print " solvable name: $name\n";
-#
-# if ($solvable == $mysolvable) {
-# print " found in repo $reponame\n";
-# last;
-# }
-#}
+foreach my $solvable ($pool->providers($rel)) {
+ print "--\n";
+ next if not defined $solvable;
+
+ my $name = $solvable->name();
+ next if not defined $name;
+ print " solvable name: $name\n";
+
+ if ($solvable == $mysolvable) {
+ print " found in repo $reponame\n";
+ last;
+ }
+}

# Find Providers of Solvables identified by a name only
$solvname = "perl";
print "\nFinding providers for name $solvname\n";
-$provcount = $pool->providers_count($rel);
-print "\nFound $provcount providers for name $solvname\n";
-#foreach my $solvable ($pool->providers($solvname)) {
-# print "--\n";
-# next if not defined $solvable;
-#
-# my $name = $solvable->name();
-# next if not defined $name;
-# print " solvable name: $name\n";
-#
-#}
+foreach my $solvable ($pool->providers($solvname)) {
+ print "--\n";
+ next if not defined $solvable;
+
+ my $name = $solvable->name();
+ next if not defined $name;
+ print " solvable name: $name\n";
+}

Modified: trunk/sat-solver/bindings/pool.i
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/pool.i?rev=11667&r1=11666&r2=11667&view=diff
==============================================================================
--- trunk/sat-solver/bindings/pool.i (original)
+++ trunk/sat-solver/bindings/pool.i Wed Nov 12 16:49:43 2008
@@ -225,6 +225,21 @@

#endif

+#if defined(SWIGPERL)
+ %perlcode %{
+ sub providers {
+ my ($self, $rel) = @_;
+ my @prov = ();
+ my $count = $self->providers_count($rel);
+ for (my $i = 0; $i < $count; ++$i) {
+ my $solvable = $self->providers_get($rel, $i);
+ push @prov, $solvable;
+ }
+
+ return wantarray ? @prov : $prov[0];
+ }
+ %}
+#endif

int providers_count( const char *name )
{ int i = 0;
@@ -233,6 +248,7 @@
++i;
return i;
}
+
int providers_count( Relation *rel )
{ int i = 0;
Id v, *vp;
@@ -240,11 +256,13 @@
++i;
return i;
}
+
XSolvable *providers_get( const char *name, int i)
{ Id *vp;
vp = $self->whatprovidesdata + pool_whatprovides($self, str2id( $self,
name, 0));
return xsolvable_new( $self, *(vp + i));
}
+
XSolvable *providers_get( Relation *rel, int i)
{ Id *vp;
vp = $self->whatprovidesdata + pool_whatprovides($self, rel->id);

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

< Previous Next >
This Thread
  • No further messages