Moved Rect and Color to Core/objects
[sdlgit/SDL_perl.git] / src / Core / objects / Rect.xs
diff --git a/src/Core/objects/Rect.xs b/src/Core/objects/Rect.xs
new file mode 100644 (file)
index 0000000..e4b40dc
--- /dev/null
@@ -0,0 +1,81 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.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(self)
+       SDL_Rect *self
+       CODE:
+               safefree( (char *)self );