Moved Rect and Color to Core/objects
[sdlgit/SDL_perl.git] / src / Core / objects / 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 MODULE = SDL::Rect      PACKAGE = SDL::Rect    PREFIX = rect_
12
13 =for documentation
14
15 SDL_Rect -- Defines a rectangular area
16
17   typedef struct{
18     Sint16 x, y;
19     Uint16 w, h;
20   } SDL_Rect;
21
22 =cut
23
24 SDL_Rect *
25 rect_new (CLASS, x, y, w, h)
26         char* CLASS
27         Sint16 x
28         Sint16 y
29         Uint16 w
30         Uint16 h
31         CODE:
32                 RETVAL = (SDL_Rect *) safemalloc (sizeof(SDL_Rect));
33                 RETVAL->x = x;
34                 RETVAL->y = y;
35                 RETVAL->w = w;
36                 RETVAL->h = h;
37         OUTPUT:
38                 RETVAL
39
40 Sint16
41 rect_x ( rect, ... )
42         SDL_Rect *rect
43         CODE:
44                 if (items > 1 ) rect->x = SvIV(ST(1)); 
45                 RETVAL = rect->x;
46         OUTPUT:
47                 RETVAL
48
49 Sint16
50 rect_y ( rect, ... )
51         SDL_Rect *rect
52         CODE:
53                 if (items > 1 ) rect->y = SvIV(ST(1)); 
54                 RETVAL = rect->y;
55         OUTPUT:
56                 RETVAL
57
58 Uint16
59 rect_w ( rect, ... )
60         SDL_Rect *rect
61         CODE:
62                 if (items > 1 ) rect->w = SvIV(ST(1)); 
63                 RETVAL = rect->w;
64         OUTPUT:
65                 RETVAL
66
67 Uint16
68 rect_h ( rect, ... )
69         SDL_Rect *rect
70         CODE:
71                 if (items > 1 ) rect->h = SvIV(ST(1)); 
72                 RETVAL = rect->h;
73         OUTPUT:
74                 RETVAL
75
76
77 void
78 rect_DESTROY(self)
79         SDL_Rect *self
80         CODE:
81                 safefree( (char *)self );