From: Kartik Thakore <thakore.kartik@gmail.com>
Date: Tue, 8 Sep 2009 16:32:50 +0000 (-0400)
Subject: Added Rect.xs
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8bd94773eeb62f65b5e67a0eb7ec60a23cf96baf;p=sdlgit%2FSDL_perl.git

Added Rect.xs
---

diff --git a/src/Rect.xs b/src/Rect.xs
new file mode 100644
index 0000000..61b8c4e
--- /dev/null
+++ b/src/Rect.xs
@@ -0,0 +1,85 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+
+
+
+MODULE = SDL::Rect 	PACKAGE = SDL::Rect
+
+SDL_Rect *
+new (CLASS)
+	char* CLASS
+	CODE:
+		RETVAL = (SDL_Rect *) safemalloc (sizeof(SDL_Rect));
+		RETVAL->x = 0;
+		RETVAL->y = 0;
+		RETVAL->w = 0;
+		RETVAL->h = 0;
+	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, ... )
+	SDL_Rect *rect
+	CODE:
+		if (items > 1 ) rect->x = SvIV(ST(1)); 
+		RETVAL = rect->x;
+	OUTPUT:
+		RETVAL
+
+Sint16
+RectY ( rect, ... )
+	SDL_Rect *rect
+	CODE:
+		if (items > 1 ) rect->y = SvIV(ST(1)); 
+		RETVAL = rect->y;
+	OUTPUT:
+		RETVAL
+
+Uint16
+RectW ( rect, ... )
+	SDL_Rect *rect
+	CODE:
+		if (items > 1 ) rect->w = SvIV(ST(1)); 
+		RETVAL = rect->w;
+	OUTPUT:
+		RETVAL
+
+Uint16
+RectH ( rect, ... )
+	SDL_Rect *rect
+	CODE:
+		if (items > 1 ) rect->h = SvIV(ST(1)); 
+		RETVAL = rect->h;
+	OUTPUT:
+		RETVAL
+
+
+void
+DESTROY(self)
+	SDL_Rect *self
+	CODE:
+	 	printf("RectPtr::DESTROY\n");
+		safefree( (char *)self );
+
+