Skip to content
Browse files

Made SDLx::Validate::_color_number() ... 1 failing test in t/sdlx_val…

…idate.t, and warnings
  • Loading branch information...
1 parent c776a2f commit e83adc0e1fedacad501bd8205a17008f171ca828 @kthakore kthakore committed
Showing with 19 additions and 22 deletions.
  1. +7 −0 Build.PL
  2. +12 −22 lib/SDLx/Validate.pm
View
7 Build.PL
@@ -174,6 +174,13 @@ my %subsystems = (
},
libraries => [qw( SDL )],
},
+ ValidateX => {
+ file => {
+ from => 'src/SDLx/Validate.xs',
+ to => 'lib/SDLx/Validate.xs',
+ },
+ libraries => [qw( SDL )],
+ },
InterfaceX => {
file => {
from => 'src/SDLx/Controller/Interface.xs',
View
34 lib/SDLx/Validate.pm
@@ -2,6 +2,12 @@
package SDLx::Validate;
use strict;
use warnings;
+use vars qw(@ISA @EXPORT @EXPORT_OK);
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+
+
use Carp;
use Scalar::Util ();
@@ -51,26 +57,6 @@ sub rect {
}
}
-sub _color_number {
- my ( $color, $alpha ) = @_;
- if ( !defined $color || $color < 0 ) {
- Carp::cluck("Color was a negative number") if defined $color && $color < 0;
- if ($alpha) {
- return 0x000000FF;
- } else {
- return 0x000000;
- }
- } else {
- if ( $alpha && $color > 0xFFFFFFFF ) {
- Carp::cluck("Color was number greater than maximum expected: 0xFFFFFFFF");
- return 0xFFFFFFFF;
- } elsif ( !$alpha && $color > 0xFFFFFF ) {
- Carp::cluck("Color was number greater than maximum expected: 0xFFFFFF");
- return 0xFFFFFF;
- }
- }
- return $color;
-}
sub _color_arrayref {
my ( $color, $alpha ) = @_;
@@ -115,7 +101,7 @@ sub num_rgb {
my ($color) = @_;
my $format = _color_format($color);
if ( $format eq 'number' ) {
- return _color_number($color);
+ return _color_number($color, 0);
} elsif ( $format eq 'arrayref' ) {
my $c = _color_arrayref($color);
return ( $c->[0] << 16 ) + ( $c->[1] << 8 ) + ( $c->[2] );
@@ -141,7 +127,7 @@ sub list_rgb {
my ($color) = @_;
my $format = _color_format($color);
if ( $format eq 'number' ) {
- my $n = _color_number($color);
+ my $n = _color_number($color, 0);
return [ $n >> 16 & 0xFF, $n >> 8 & 0xFF, $n & 0xFF ];
} elsif ( $format eq 'arrayref' ) {
return _color_arrayref($color);
@@ -182,4 +168,8 @@ sub map_rgba {
return SDL::Video::map_RGBA( $format, @{ list_rgba($color) } );
}
+
+bootstrap SDLx::Validate;
+
1;
+

0 comments on commit e83adc0

Please sign in to comment.
Something went wrong with that request. Please try again.