0744f30f33a77785eb7d86fa968b03ca1cc923b7
[sdlgit/SDL_perl.git] / src / Rect.xs
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4
5 #ifndef aTHX_
6 #define aTHX_
7 #endif
8
9 #include <SDL.h>
10
11
12
13 MODULE = SDL::Rect      PACKAGE = SDL::Rect    PREFIX = rect_
14
15 SDL_Rect *
16 rect_new (CLASS, x, y, w, h)
17         char* CLASS
18         Sint16 x
19         Sint16 y
20         Uint16 w
21         Uint16 h
22         CODE:
23                 RETVAL = (SDL_Rect *) safemalloc (sizeof(SDL_Rect));
24                 RETVAL->x = x;
25                 RETVAL->y = y;
26                 RETVAL->w = w;
27                 RETVAL->h = h;
28         OUTPUT:
29                 RETVAL
30
31 void
32 SetRect(rect, x, y, w, h)
33         SDL_Rect *rect
34         Sint16 x        
35         Sint16 y
36         Uint16 w
37         Uint16 h
38         CODE:
39                 rect->x = x;
40                 rect->y = y;
41                 rect->w = w;
42                 rect->h = h;
43                 
44
45 Sint16
46 RectX ( rect, ... )
47         SDL_Rect *rect
48         CODE:
49                 if (items > 1 ) rect->x = SvIV(ST(1)); 
50                 RETVAL = rect->x;
51         OUTPUT:
52                 RETVAL
53
54 Sint16
55 RectY ( rect, ... )
56         SDL_Rect *rect
57         CODE:
58                 if (items > 1 ) rect->y = SvIV(ST(1)); 
59                 RETVAL = rect->y;
60         OUTPUT:
61                 RETVAL
62
63 Uint16
64 RectW ( rect, ... )
65         SDL_Rect *rect
66         CODE:
67                 if (items > 1 ) rect->w = SvIV(ST(1)); 
68                 RETVAL = rect->w;
69         OUTPUT:
70                 RETVAL
71
72 Uint16
73 RectH ( rect, ... )
74         SDL_Rect *rect
75         CODE:
76                 if (items > 1 ) rect->h = SvIV(ST(1)); 
77                 RETVAL = rect->h;
78         OUTPUT:
79                 RETVAL
80
81
82 void
83 rect_DESTROY(self)
84         SDL_Rect *self
85         CODE:
86                 printf("RectPtr::DESTROY\n");
87                 safefree( (char *)self );
88
89