Simplyify SDL::Rect to be just an XS wrapper, add a few methods to SDL::Game::Rect
[sdlgit/SDL_perl.git] / src / Rect.xs
index 61b8c4e..e4b40dc 100644 (file)
@@ -8,38 +8,37 @@
 
 #include <SDL.h>
 
+MODULE = SDL::Rect     PACKAGE = SDL::Rect    PREFIX = rect_
 
+=for documentation
 
-MODULE = SDL::Rect     PACKAGE = SDL::Rect
+SDL_Rect -- Defines a rectangular area
+
+  typedef struct{
+    Sint16 x, y;
+    Uint16 w, h;
+  } SDL_Rect;
+
+=cut
 
 SDL_Rect *
-new (CLASS)
+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 = 0;
-               RETVAL->y = 0;
-               RETVAL->w = 0;
-               RETVAL->h = 0;
+               RETVAL->x = x;
+               RETVAL->y = y;
+               RETVAL->w = w;
+               RETVAL->h = h;
        OUTPUT:
                RETVAL
 
-void
-SetRect(rect, x, y, w, h)
-       SDL_Rect *rect
-       Sint16 x        
-       Sint16 y
-       Uint16 w
-       Uint16 h
-       CODE:
-               rect->x = x;
-               rect->y = y;
-               rect->w = w;
-               rect->h = h;
-               
-
 Sint16
-RectX ( rect, ... )
+rect_x ( rect, ... )
        SDL_Rect *rect
        CODE:
                if (items > 1 ) rect->x = SvIV(ST(1)); 
@@ -48,7 +47,7 @@ RectX ( rect, ... )
                RETVAL
 
 Sint16
-RectY ( rect, ... )
+rect_y ( rect, ... )
        SDL_Rect *rect
        CODE:
                if (items > 1 ) rect->y = SvIV(ST(1)); 
@@ -57,7 +56,7 @@ RectY ( rect, ... )
                RETVAL
 
 Uint16
-RectW ( rect, ... )
+rect_w ( rect, ... )
        SDL_Rect *rect
        CODE:
                if (items > 1 ) rect->w = SvIV(ST(1)); 
@@ -66,7 +65,7 @@ RectW ( rect, ... )
                RETVAL
 
 Uint16
-RectH ( rect, ... )
+rect_h ( rect, ... )
        SDL_Rect *rect
        CODE:
                if (items > 1 ) rect->h = SvIV(ST(1)); 
@@ -76,10 +75,7 @@ RectH ( rect, ... )
 
 
 void
-DESTROY(self)
+rect_DESTROY(self)
        SDL_Rect *self
        CODE:
-               printf("RectPtr::DESTROY\n");
                safefree( (char *)self );
-
-