Added Rect.xs
[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
14
15 SDL_Rect *
16 new (CLASS)
17         char* CLASS
18         CODE:
19                 RETVAL = (SDL_Rect *) safemalloc (sizeof(SDL_Rect));
20                 RETVAL->x = 0;
21                 RETVAL->y = 0;
22                 RETVAL->w = 0;
23                 RETVAL->h = 0;
24         OUTPUT:
25                 RETVAL
26
27 void
28 SetRect(rect, x, y, w, h)
29         SDL_Rect *rect
30         Sint16 x        
31         Sint16 y
32         Uint16 w
33         Uint16 h
34         CODE:
35                 rect->x = x;
36                 rect->y = y;
37                 rect->w = w;
38                 rect->h = h;
39                 
40
41 Sint16
42 RectX ( rect, ... )
43         SDL_Rect *rect
44         CODE:
45                 if (items > 1 ) rect->x = SvIV(ST(1)); 
46                 RETVAL = rect->x;
47         OUTPUT:
48                 RETVAL
49
50 Sint16
51 RectY ( rect, ... )
52         SDL_Rect *rect
53         CODE:
54                 if (items > 1 ) rect->y = SvIV(ST(1)); 
55                 RETVAL = rect->y;
56         OUTPUT:
57                 RETVAL
58
59 Uint16
60 RectW ( rect, ... )
61         SDL_Rect *rect
62         CODE:
63                 if (items > 1 ) rect->w = SvIV(ST(1)); 
64                 RETVAL = rect->w;
65         OUTPUT:
66                 RETVAL
67
68 Uint16
69 RectH ( rect, ... )
70         SDL_Rect *rect
71         CODE:
72                 if (items > 1 ) rect->h = SvIV(ST(1)); 
73                 RETVAL = rect->h;
74         OUTPUT:
75                 RETVAL
76
77
78 void
79 DESTROY(self)
80         SDL_Rect *self
81         CODE:
82                 printf("RectPtr::DESTROY\n");
83                 safefree( (char *)self );
84
85