From: Kartik Thakore Date: Mon, 26 Oct 2009 14:47:52 +0000 (-0400) Subject: Added missing SDL_Palette XS bindings file. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=997e38e1c4ab87741fdcf9f741ed791cad1efe49;hp=473d3fa763da18283068457753d13c4701d0e197;p=sdlgit%2FSDL_perl.git Added missing SDL_Palette XS bindings file. --- diff --git a/src/Core/objects/Palette.xs b/src/Core/objects/Palette.xs new file mode 100644 index 0000000..3177b02 --- /dev/null +++ b/src/Core/objects/Palette.xs @@ -0,0 +1,60 @@ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#ifndef aTHX_ +#define aTHX_ +#endif + +#include + +MODULE = SDL::Palette PACKAGE = SDL::Palette PREFIX = palette_ + +=for documentation + +SDL_Palette -- Color palette for 8-bit pixel formats + + typedef struct{ + int ncolors; + SDL_Color *colors + } SDL_Palette; + +=cut + +int +palette_ncolors ( palette ) + SDL_Palette *palette + CODE: + RETVAL = palette->ncolors; + OUTPUT: + RETVAL + +AV * +palette_colors ( palette ) + SDL_Palette *palette + CODE: + RETVAL = newAV(); + int i; + for(i = 0; i < palette->ncolors; i++) + { + + av_push(RETVAL,newSViv( PTR2IV( palette->colors + i ) ) ); + + } + OUTPUT: + RETVAL + + +SDL_Color * +palette_colors_index ( palette, index ) + SDL_Palette *palette + int index + PREINIT: + char * CLASS = "SDL::Color"; + CODE: + RETVAL = (SDL_Color *)(palette->colors + index); + OUTPUT: + RETVAL + + +