From: Breno G. de Oliveira Date: Sun, 30 Aug 2009 03:48:39 +0000 (-0300) Subject: implemented 'aliases' left, top, h and w X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=964934756806b76f79c163776fc350214c0bb489;p=sdlgit%2FSDL_perl.git implemented 'aliases' left, top, h and w --- diff --git a/lib/SDL/Rect.pm b/lib/SDL/Rect.pm index 25aa5a1..d557cdd 100644 --- a/lib/SDL/Rect.pm +++ b/lib/SDL/Rect.pm @@ -40,10 +40,10 @@ sub new { my $class = ref($proto) || $proto; my %options = @_; - verify (%options, qw/ -x -y -width -height -w -h / ) if $SDL::DEBUG; + verify (%options, qw/ -x -y -top -left -width -height -w -h / ) if $SDL::DEBUG; - my $x = $options{-x} || 0; - my $y = $options{-y} || 0; + my $x = $options{-x} || $options{-left} || 0; + my $y = $options{-y} || $options{-top} || 0; my $w = $options{-width} || $options{-w} || 0; my $h = $options{-height} || $options{-h} || 0; @@ -57,21 +57,47 @@ sub DESTROY { SDL::FreeRect(${$_[0]}); } +# TODO: mangle with the symbol table to create an alias +# to sub x. We could call x from inside the sub but that +# would be another call and rects are a time-critical object. +sub left { + my $self = shift; + SDL::RectX($$self,@_); +} + sub x { my $self = shift; SDL::RectX($$self,@_); } +### TODO: see 'left' above +sub top { + my $self = shift; + SDL::RectY($$self,@_); +} + sub y { my $self = shift; SDL::RectY($$self,@_); } +### TODO: see 'left' above +sub w { + my $self = shift; + SDL::RectW($$self,@_); +} + sub width { my $self = shift; SDL::RectW($$self,@_); } +### TODO: see 'left' above +sub h { + my $self = shift; + SDL::RectH($$self,@_); +} + sub height { my $self = shift; SDL::RectH($$self,@_);