stas        2004/02/21 18:29:40

  Modified:    lib/ModPerl WrapXS.pm
  Log:
  MethodLookup:
  - fix an inheritance check
  - add a fall-through code when none of the matches fits the first argument
  
  Revision  Changes    Path
  1.69      +11 -1     modperl-2.0/lib/ModPerl/WrapXS.pm
  
  Index: WrapXS.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/ModPerl/WrapXS.pm,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -u -r1.68 -r1.69
  --- WrapXS.pm 13 Feb 2004 22:33:01 -0000      1.68
  +++ WrapXS.pm 22 Feb 2004 02:29:40 -0000      1.69
  @@ -865,20 +865,30 @@
       if (@items == 1) {
           my $module = $items[0]->[MODULE];
           my $hint = "To use method '$method' add:\n" . "\tuse $module ();\n";
  +        # we should really check that the method matches the object if
  +        # any was passed, but it may not always work
           return ($hint, $module);
       }
       else {
           if (defined $object) {
               my $class = ref $object || $object;
               for my $item (@items) {
  +                # real class or inheritance
                   if ($class eq $item->[OBJECT] or
  -                    (ref($object) && $object->isa($class))) { # inheritance
  +                    (ref($object) && $object->isa($item->[OBJECT]))) {
                       my $module = $item->[MODULE];
                       my $hint = "To use method '$method' add:\n" .
                           "\tuse $module ();\n";
                       return ($hint, $module);
                   }
               }
  +            # fall-through
  +            local $" = ", ";
  +            my @modules = map $_->[MODULE], @items;
  +            my $hint = "Several modules (@modules) contain method '$method' " .
  +                "but none of them matches class '$class';\n";
  +            return ($hint);
  +
           }
           else {
               my %modules = map { $_->[MODULE] => 1 } @items;
  
  
  

Reply via email to