#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#ifndef aTHX_
#define aTHX_
#endif
#include <SDL.h>
MODULE = SDL::Rect PACKAGE = SDL::Rect PREFIX = rect_
=for documentation
SDL_Rect -- Defines a rectangular area
typedef struct{
Sint16 x, y;
Uint16 w, h;
} SDL_Rect;
=cut
SDL_Rect *
rect_new (CLASS, x, y, w, h)
char* CLASS
Sint16 x
Sint16 y
Uint16 w
Uint16 h
CODE:
RETVAL = (SDL_Rect *) safemalloc (sizeof(SDL_Rect));
RETVAL->x = x;
RETVAL->y = y;
RETVAL->w = w;
RETVAL->h = h;
OUTPUT:
RETVAL
Sint16
rect_x ( rect, ... )
SDL_Rect *rect
CODE:
if (items > 1 ) rect->x = SvIV(ST(1));
RETVAL = rect->x;
OUTPUT:
RETVAL
Sint16
rect_y ( rect, ... )
SDL_Rect *rect
CODE:
if (items > 1 ) rect->y = SvIV(ST(1));
RETVAL = rect->y;
OUTPUT:
RETVAL
Uint16
rect_w ( rect, ... )
SDL_Rect *rect
CODE:
if (items > 1 ) rect->w = SvIV(ST(1));
RETVAL = rect->w;
OUTPUT:
RETVAL
Uint16
rect_h ( rect, ... )
SDL_Rect *rect
CODE:
if (items > 1 ) rect->h = SvIV(ST(1));
RETVAL = rect->h;
OUTPUT:
RETVAL
void
rect_DESTROY(bag)
SV *bag
CODE:
if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) ) {
void** pointers = (void**)(SvIV((SV*)SvRV( bag )));
SDL_Rect * rect = (SDL_Rect*)(pointers[0]);
if (PERL_GET_CONTEXT == pointers[1]) {
pointers[0] = NULL;
safefree(rect);
}
} else if (bag == 0) {
XSRETURN(0);
} else {
XSRETURN_UNDEF;
}