Skip to content

Commit

Permalink
fix typemap to return undef if the return is null... this solves two …
Browse files Browse the repository at this point in the history
…failing tests... only three left
  • Loading branch information
ruoso committed Jan 19, 2010
1 parent 0169548 commit 7f651c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Core/objects/PixelFormat.xs
Expand Up @@ -33,7 +33,7 @@ pixelformat_palette( pixelformat )
PREINIT:
char* CLASS = "SDL::Palette";
CODE:
RETVAL = pixelformat->palette;
RETVAL = pixelformat->palette;
OUTPUT:
RETVAL

Expand Down
2 changes: 1 addition & 1 deletion t/core_palette.t
Expand Up @@ -27,7 +27,7 @@ my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE );

isa_ok($display->format, 'SDL::PixelFormat', 'Are we a SDL::PixelFormat?');

is( !defined $display->format->palette , 1, 'Palette is not defined as BitPerPixels is greater then 8');
ok( ! defined $display->format->palette , 'Palette is not defined as BitPerPixels is greater then 8');


my $disp = SDL::Video::set_video_mode(640,480,8, SDL_SWSURFACE );
Expand Down
13 changes: 8 additions & 5 deletions typemap
Expand Up @@ -102,11 +102,14 @@ OUTPUT
# The Perl object is blessed into 'CLASS', which should be a
# char* having the name of the package for the blessing.
O_OBJECT
void** pointers = malloc(2 * sizeof(void*));
pointers[0] = (void*)$var;
pointers[1] = (void*)my_perl;
sv_setref_pv( $arg, CLASS, (void*)pointers );

if ($var) {
void** pointers = malloc(2 * sizeof(void*));
pointers[0] = (void*)$var;
pointers[1] = (void*)my_perl;
sv_setref_pv( $arg, CLASS, (void*)pointers );
} else {
XSRETURN_UNDEF;
}

INPUT

Expand Down

0 comments on commit 7f651c7

Please sign in to comment.