@@ -5,6 +5,7 @@ use vars qw(@ISA @EXPORT @EXPORT_OK);
5
5
require Exporter;
6
6
require DynaLoader;
7
7
use Carp ();
8
+ use Scalar::Util ();
8
9
use SDL;
9
10
use SDL::Rect;
10
11
use SDL::Video;
@@ -219,9 +220,9 @@ sub flip {
219
220
sub update {
220
221
my ( $surface , $rects ) = @_ ;
221
222
222
- if ( !defined ($rects ) || ( ref ( $rects ) eq ' ARRAY' && !ref ( $rects -> [0] ) ) ) {
223
- my @rect ;
224
- @rect = @{$rects } if $rects ;
223
+ if ( !defined ($rects ) || ( Scalar::Util::reftype $rects eq ' ARRAY' && !ref ( $rects -> [0] ) ) ) {
224
+ my @rect ;
225
+ @rect = @{$rects } if $rects ;
225
226
$rect [0] ||= 0;
226
227
$rect [1] ||= 0;
227
228
$rect [2] ||= $surface -> w;
@@ -239,9 +240,10 @@ sub draw_line {
239
240
my ( $self , $start , $end , $color , $antialias ) = @_ ;
240
241
241
242
Carp::confess " Error start needs an array ref [x,y]"
242
- unless ref ($start ) eq ' ARRAY' ;
243
+ unless Scalar::Util::reftype $start eq ' ARRAY' ;
244
+
243
245
Carp::confess " Error end needs an array ref [x,y]"
244
- unless ref ( $end ) eq ' ARRAY' ;
246
+ unless Scalar::Util::reftype $end eq ' ARRAY' ;
245
247
246
248
unless ( SDL::Config-> has(' SDL_gfx_primitives' ) ) {
247
249
Carp::cluck(" SDL_gfx_primitives support has not been compiled" );
@@ -270,7 +272,9 @@ sub draw_circle {
270
272
return ;
271
273
}
272
274
273
- Carp::cluck " Center needs to be an array of format [x,y]" unless ( ref $center eq ' ARRAY' && scalar @$center == 2 );
275
+ Carp::cluck " Center needs to be an array of format [x,y]"
276
+ unless Scalar::Util::reftype $center eq ' ARRAY' && scalar @$center == 2;
277
+
274
278
$color = SDLx::Validate::num_rgba($color );
275
279
276
280
unless ( $antialias )
@@ -292,7 +296,9 @@ sub draw_circle_filled {
292
296
return ;
293
297
}
294
298
295
- Carp::cluck " Center needs to be an array of format [x,y]" unless ( ref $center eq ' ARRAY' && scalar @$center == 2 );
299
+ Carp::cluck " Center needs to be an array of format [x,y]"
300
+ unless Scalar::Util::reftype $center eq ' ARRAY' && scalar @$center == 2;
301
+
296
302
$color = SDLx::Validate::num_rgba($color );
297
303
298
304
SDL::GFX::Primitives::filled_circle_color( $self , @{$center }, $radius , $color );
@@ -341,7 +347,9 @@ sub draw_polygon_filled {
341
347
sub draw_arc {
342
348
my ( $self , $center , $radius , $start , $end , $color ) = @_ ;
343
349
344
- Carp::cluck " Center needs to be an array of format [x,y]" unless ( ref $center eq ' ARRAY' && scalar @$center == 2 );
350
+ Carp::cluck " Center needs to be an array of format [x,y]"
351
+ unless Scalar::Util::reftype $center eq ' ARRAY' && scalar @$center == 2;
352
+
345
353
$color = SDLx::Validate::num_rgba($color );
346
354
347
355
SDL::GFX::Primitives::arc_color( $self , @$center , $radius , $start , $end , $color );
@@ -352,7 +360,9 @@ sub draw_arc {
352
360
sub draw_ellipse {
353
361
my ( $self , $center , $rx , $ry , $color , $antialias ) = @_ ;
354
362
355
- Carp::cluck " Center needs to be an array of format [x,y]" unless ( ref $center eq ' ARRAY' && scalar @$center == 2 );
363
+ Carp::cluck " Center needs to be an array of format [x,y]"
364
+ unless Scalar::Util::reftype $center eq ' ARRAY' && scalar @$center == 2;
365
+
356
366
$color = SDLx::Validate::num_rgba($color );
357
367
358
368
if ($antialias )
@@ -370,7 +380,9 @@ sub draw_ellipse {
370
380
sub draw_ellipse_filled {
371
381
my ( $self , $center , $rx , $ry , $color ) = @_ ;
372
382
373
- Carp::cluck " Center needs to be an array of format [x,y]" unless ( ref $center eq ' ARRAY' && scalar @$center == 2 );
383
+ Carp::cluck " Center needs to be an array of format [x,y]"
384
+ iunless Scalar::Util::reftype $center eq ' ARRAY' && scalar @$center == 2;
385
+
374
386
$color = SDLx::Validate::num_rgba($color );
375
387
376
388
SDL::GFX::Primitives::filled_ellipse_color( $self , @$center , $rx , $ry , $color );
0 commit comments