Skip Menu |

This queue is for tickets about the GD-Window CPAN distribution.

Report information
The Basics
Id: 69389
Status: new
Priority: 0/
Queue: GD-Window

People
Owner: efunneko [...] gmail.com
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: passThrough can() support
Date: Mon, 11 Jul 2011 09:04:42 +1000
To: bug-GD-Window [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
In passThrough mode it'd be good if can() on the GD::Window reflected the methods that are available from the underlying GD. For example foo.pl says can(png) no Call ->png ok, length 83 where I hoped can('png') might be true (coderef for GD::Window object), since a $window->png() call will work. In GD I believe the availability of the png() and jpeg() methods depends on whether it's built with the respective libpng and libjpeg, so it can make sense to check for them with can(). I think a custom can() is usual when making an AUTOLOAD for methods. When I've done it I've shared a "create-the-method" func for the two. The autoload creates and calls (or dies if no such method), the can() creates and returns the coderef (or return undef if no such underlying method, or no passThrough option).
#!/usr/bin/perl -w use strict; use GD; use GD::Window; my $im = GD::Image->new(5, 5); $im->colorAllocate(0,0,0); my $win = GD::Window->new($im, 0,0, 4,4, 0,0, 4,4, passThrough => 1); my $coderef = $win->can('png'); if ($coderef) { print "can(png) yes\n"; } else { print "can(png) no\n"; } print "Call ->png\n"; $win->png; my $str = $win->png; print " ok, length ",length($str),"\n";