Commits

illume  committed fd421ea

Thanks Christopher Stone, John Myers, John Poppleweel, and Marcus!
64bit fixes, movie.c fix, font fix.

Added -bigw switch for extra gcc warnings.

  • Participants
  • Parent commits b3f4b48

Comments (0)

Files changed (13)

 import os, sys
 path = os.path.split(os.path.abspath(sys.argv[0]))[0]
 os.chdir(path)
-
-
+#os.environ["CFLAGS"] = "-W -Wall -Wpointer-arith -Wcast-qual -Winline " + \
+#                       "-Wcast-align -Wconversion -Wstrict-prototypes " + \
+#                       "-Wmissing-prototypes -Wmissing-declarations " + \
+#                       "-Wnested-externs -Wshadow -Wredundant-decls"
+if "-bigw" in sys.argv:
+    os.environ["CFLAGS"] = "-W -Wimplicit-int " + \
+                       "-Wimplicit-function-declaration " + \
+                       "-Wimplicit -Wmain -Wreturn-type -Wunused -Wswitch " + \
+                       "-Wcomment -Wtrigraphs -Wformat -Wchar-subscripts " + \
+                       "-Wuninitialized -Wparentheses " +\
+                       "-Wpointer-arith -Wcast-qual -Winline -Wcast-align " + \
+                       "-Wconversion -Wstrict-prototypes " + \
+                       "-Wmissing-prototypes -Wmissing-declarations " + \
+                       "-Wnested-externs -Wshadow -Wredundant-decls"
 
 import os.path, glob
 import distutils.sysconfig
 	if(keywords)
 	{
 		PyObject *key, *value;
-		int pos  = 0;
+		Py_ssize_t pos  = 0;
 		while(PyDict_Next(keywords, &pos, &key, &value))
 			PyDict_SetItem(dict, key, value);
 	}
 	PyObject *surfobj, *string=NULL;
 	char *format, *data, *pixels;
 	SDL_Surface *surf, *temp=NULL;
-	int w, h, color, len, flipped=0;
+	int w, h, color, flipped=0;
+        Py_ssize_t len;
 	int Rmask, Gmask, Bmask, Amask, Rshift, Gshift, Bshift, Ashift, Rloss, Gloss, Bloss, Aloss;
 	int hascolorkey, colorkey;
 
 	PyObject *string;
 	char *format, *data;
 	SDL_Surface *surf = NULL;
-	int w, h, len, flipped=0;
+	int w, h, flipped=0;
+        Py_ssize_t len;
 	int loopw, looph;
 
 	if(!PyArg_ParseTuple(arg, "O!(ii)s|i", &PyString_Type, &string, &w, &h, &format, &flipped))
 	PyObject *buffer;
 	char *format, *data;
 	SDL_Surface *surf = NULL;
-	int w, h, len;
+	int w, h;
+        Py_ssize_t len;
         PyObject *surfobj;
 
 	if(!PyArg_ParseTuple(arg, "O(ii)s|i", &buffer, &w, &h, &format))
 	  return NULL; /*RAISE(PyExc_Error, "cannot create bitmask");*/
         
         /*create the new python object from mask*/        
-	maskobj = PyObject_NEW(PyMaskObject, &PyMask_Type);
+	maskobj = PyObject_New(PyMaskObject, &PyMask_Type);
         if(maskobj)
         	maskobj->mask = mask;
 	return (PyObject*)maskobj;

File src/mask.doc

 pygame object for representing 2d bitmasks
 pygame.Mask((width, height): return Mask
 
+Useful for fast pixel perfect collision detection.  A Mask uses 1bit per 
+pixel to store which parts collide.
 
-TODO: Documentation goes here!
+New in pygame 1.8.
 
 <SECTION>
 
 		if(posobj == NULL)
 		{
                         Py_BEGIN_ALLOW_THREADS
-			SMPEG_Info info;
 			SMPEG_getinfo(movie, &info);
 			SMPEG_scaleXY(movie, info.width, info.height);
                         Py_END_ALLOW_THREADS
 		else if(TwoIntsFromObj(posobj, &x, &y))
 		{
                         Py_BEGIN_ALLOW_THREADS
-			SMPEG_Info info;
 			SMPEG_getinfo(movie, &info);
 			SMPEG_scaleXY(movie, info.width, info.height);
                         Py_END_ALLOW_THREADS

File src/pygame.h

 #define Py_RETURN_NONE return Py_INCREF (Py_None), Py_None
 #endif
 
+/* Py_ssize_t availability. */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
+
 #define PyType_Init(x) (((x).ob_type) = &PyType_Type)
 #define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"
 

File src/pygamedocs.h

 
 #define DOC_FONTGETDESCENT "Font.get_descent(): return int\nget the descent of the font"
 
+#define DOC_FONTMETRICS \
+  "Font.metrics(text): return list\n" \
+  "Gets the metrics for each character in the pased string.\n" \
+  "\n" \
+  "The list contains tuples for each character, which contain the minimum\n" \
+  "X offset, the maximum X offset, the minimum Y offset, the maximum\n" \
+  "Y offset and the advance offset (bearing plus width) of the character.\n" \
+  "[(minx, maxx, miny, maxy, advance), (minx, maxx, miny, maxy, advance), ...]"
+ 
 #define DOC_PYGAMEIMAGE "pygame module for image transfer"
 
 #define DOC_PYGAMEIMAGELOAD "pygame.image.load(filename): return Surface\npygame.image.load(fileobj, namehint=""): return Surface\nload new image from a file"
 {
 	PyRectObject* self = (PyRectObject*)oself;
 	GAME_Rect *argrect, temp;
-	int loop=0;
+	Py_ssize_t loop=0;
 	PyObject* dict, *key, *val;
 	PyObject* ret = NULL;
 
 {
 	PyRectObject* self = (PyRectObject*)oself;
 	GAME_Rect *argrect, temp;
-	int loop=0;
+	Py_ssize_t loop=0;
 	PyObject* dict, *key, *val;
 	PyObject* ret = NULL;
 
 
 /* sequence functions */
 
-static int rect_length(PyRectObject *self)
+static Py_ssize_t rect_length(PyRectObject *self)
 {
 	return 4;
 }
 
-static PyObject* rect_item(PyRectObject *self, int i)
+static PyObject* rect_item(PyObject *_self, Py_ssize_t i)
 {
-	int* data = (int*)&self->r;
-	if(i<0 || i>3)
-		return RAISE(PyExc_IndexError, "Invalid rect Index");
+    PyRectObject *self = (PyRectObject *) _self;
+    int* data = (int*)&self->r;
+    if(i<0 || i>3)
+        return RAISE(PyExc_IndexError, "Invalid rect Index");
 
-	return PyInt_FromLong(data[i]);
+    return PyInt_FromLong(data[i]);
 }
 
-static int rect_ass_item(PyRectObject *self, int i, PyObject *v)
+static int rect_ass_item(PyObject *_self, Py_ssize_t i, PyObject *v)
 {
-	int val;
-	int* data = (int*)&self->r;
-	if(i<0 || i>3)
-	{
-		RAISE(PyExc_IndexError, "Invalid rect Index");
-		return -1;
-	}
-	if(!IntFromObj(v, &val))
-	{
-		RAISE(PyExc_TypeError, "Must assign numeric values");
-		return -1;
-	}
-	data[i] = val;
-	return 0;
+    PyRectObject *self = (PyRectObject *) _self;
+    int val;
+    int* data = (int*)&self->r;
+    if(i<0 || i>3)
+    {
+        RAISE(PyExc_IndexError, "Invalid rect Index");
+        return -1;
+    }
+    if(!IntFromObj(v, &val))
+    {
+        RAISE(PyExc_TypeError, "Must assign numeric values");
+        return -1;
+    }
+    data[i] = val;
+    return 0;
 }
 
-
-static PyObject* rect_slice(PyRectObject *self, int ilow, int ihigh)
+static PyObject* rect_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh)
 {
-	PyObject *list;
-	int* data = (int*)&self->r;
-	int numitems, loop, l = 4;
-
-	if (ihigh < 0) ihigh += l;
-	if (ilow  < 0) ilow  += l;
-	if (ilow < 0) ilow = 0;
-	else if (ilow > l) ilow = l;
-	if (ihigh < 0) ihigh = 0;
-	else if (ihigh > l) ihigh = l;
-	if (ihigh < ilow) ihigh = ilow;
-
-	numitems = ihigh - ilow;
-	list = PyList_New(numitems);
-	for(loop = 0; loop < numitems; ++loop)
-		PyList_SET_ITEM(list, loop, PyInt_FromLong(data[loop+ilow]));
-
-	return list;
+    PyRectObject *self = (PyRectObject *) _self;
+    PyObject *list;
+    int* data = (int*)&self->r;
+    int numitems, loop, l = 4;
+    
+    if (ihigh < 0) ihigh += l;
+    if (ilow  < 0) ilow  += l;
+    if (ilow < 0) ilow = 0;
+    else if (ilow > l) ilow = l;
+    if (ihigh < 0) ihigh = 0;
+    else if (ihigh > l) ihigh = l;
+    if (ihigh < ilow) ihigh = ilow;
+    
+    numitems = ihigh - ilow;
+    list = PyList_New(numitems);
+    for(loop = 0; loop < numitems; ++loop)
+        PyList_SET_ITEM(list, loop, PyInt_FromLong(data[loop+ilow]));
+    
+    return list;
 }
 
-
-
-static int rect_ass_slice(PyRectObject *self, int ilow, int ihigh, PyObject *v)
+static int rect_ass_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh, 
+                          PyObject *v)
 {
-	int* data = (int*)&self->r;
-	int numitems, loop, l = 4;
-	int val;
-
-	if(!PySequence_Check(v))
-	{
-		RAISE(PyExc_TypeError, "Assigned slice must be a sequence");
-		return -1;
-	}
-
-	if (ihigh < 0) ihigh += l;
-	if (ilow  < 0) ilow  += l;
-	if (ilow < 0) ilow = 0;
-	else if (ilow > l) ilow = l;
-	if (ihigh < 0) ihigh = 0;
-	else if (ihigh > l) ihigh = l;
-	if (ihigh < ilow) ihigh = ilow;
-
-	numitems = ihigh - ilow;
-	if(numitems != PySequence_Length(v))
-	{
-		RAISE(PyExc_ValueError, "Assigned slice must be same length");
-		return -1;
-	}
-
-	for(loop = 0; loop < numitems; ++loop)
-	{
-		if(!IntFromObjIndex(v, loop, &val)) return -1;
-		data[loop+ilow] = val;
-	}
-
-	return 0;
+    PyRectObject *self = (PyRectObject *) _self;
+    int* data = (int*)&self->r;
+    int numitems, loop, l = 4;
+    int val;
+    
+    if(!PySequence_Check(v))
+    {
+        RAISE(PyExc_TypeError, "Assigned slice must be a sequence");
+        return -1;
+    }
+    
+    if (ihigh < 0) ihigh += l;
+    if (ilow  < 0) ilow  += l;
+    if (ilow < 0) ilow = 0;
+    else if (ilow > l) ilow = l;
+    if (ihigh < 0) ihigh = 0;
+    else if (ihigh > l) ihigh = l;
+    if (ihigh < ilow) ihigh = ilow;
+    
+    numitems = ihigh - ilow;
+    if(numitems != PySequence_Length(v))
+    {
+        RAISE(PyExc_ValueError, "Assigned slice must be same length");
+        return -1;
+    }
+    
+    for(loop = 0; loop < numitems; ++loop)
+    {
+        if(!IntFromObjIndex(v, loop, &val)) return -1;
+        data[loop+ilow] = val;
+    }
+    
+    return 0;
 }
 
 static PySequenceMethods rect_as_sequence = {
-	(inquiry)rect_length,				/*length*/
-	(binaryfunc)NULL,					/*concat*/
-	(intargfunc)NULL,					/*repeat*/
-	(intargfunc)rect_item,				/*item*/
-	(intintargfunc)rect_slice,			/*slice*/
-	(intobjargproc)rect_ass_item,		/*ass_item*/
-	(intintobjargproc)rect_ass_slice,	/*ass_slice*/
+    rect_length,    /*length*/
+    NULL,           /*concat*/
+    NULL,           /*repeat*/
+    rect_item,      /*item*/
+    rect_slice,     /*slice*/
+    rect_ass_item,  /*ass_item*/
+    rect_ass_slice, /*ass_slice*/
 };
 
 

File src/rotozoom.c

  
 */
 
-void transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int smooth)
+void transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx,
+                                 int cy, int isin, int icos, int smooth)
 {
     int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
     tColorRGBA c00, c01, c10, c11;
 
 /* Local rotozoom-size function with trig result return */
 
-void rotozoomSurfaceSizeTrig(int width, int height, double angle, double zoom, int *dstwidth, int *dstheight,
-			     double *canglezoom, double *sanglezoom)
+void rotozoomSurfaceSizeTrig(int width, int height, double angle,
+                                    double zoom, int *dstwidth, int *dstheight,
+                                    double *canglezoom, double *sanglezoom)
 {
     double x, y, cx, cy, sx, sy;
     double radangle;
 
 /* Publically available rotozoom-size function */
 
-void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth, int *dstheight)
+void rotozoomSurfaceSize(int width, int height, double angle,
+                                double zoom, int *dstwidth, int *dstheight)
 {
     double dummy_sanglezoom, dummy_canglezoom;
 
 
 */
 
-void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight)
+void zoomSurfaceSize(int width, int height, double zoomx, double zoomy,
+                            int *dstwidth, int *dstheight)
 {
     /*
      * Sanity check zoom factors 
 
 /* Publically available rotozoom function */
 
-SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth)
+SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle,
+                                    double zoom, int smooth)
 {
     SDL_Surface *rz_src;
     SDL_Surface *rz_dst;

File src/scrap_x11.c

             if (count && list)
             {
                 int i = 0;
-                int offset = 0;
+                int ioffset = 0;
                 int length = 0;
                 char *tmp;
 
                         free (tmp);
                         return NULL;
                     }
-                    offset += length;
+                    ioffset += length;
 
                     memcpy (retval, list[i], length);
-                    memset (retval + offset, '\n', 1);
+                    memset (retval + ioffset, '\n', 1);
                 }
-                memset (retval + offset, 0, 1);
+                memset (retval + ioffset, 0, 1);
             }
         }
 

File src/surface.c

     if(rect && kw)
     {
         PyObject *key, *value;
-        int pos=0;
+        Py_ssize_t pos=0;
         while(PyDict_Next(kw, &pos, &key, &value))
         {
             if((PyObject_SetAttr(rect, key, value) == -1))

File src/transform.c

 #include "pygamedocs.h"
 #include <math.h>
 
-
 void scale2x(SDL_Surface *src, SDL_Surface *dst);
 
-
-
 static SDL_Surface* newsurf_fromsurf(SDL_Surface* surf, int width, int height)
 {
 	SDL_Surface* newsurf;
 	}
 	else
 	{
+                SDL_LockSurface(surf);
 		switch(surf->format->BytesPerPixel)
 		{
 		case 1: bgcolor = *(Uint8*)surf->pixels; break;
 			bgcolor = (((Uint8*)surf->pixels)[2]) + (((Uint8*)surf->pixels)[1]<<8) + (((Uint8*)surf->pixels)[0]<<16);
 #endif
 		}
+                SDL_UnlockSurface(surf);
 		bgcolor &= ~surf->format->Amask;
 	}
 
 PYGAME_EXPORT
 void inittransform(void)
 {
-	PyObject *module;
-	module = Py_InitModule3("transform", transform_builtins, DOC_PYGAMETRANSFORM);
+    PyObject *module;
+    module = Py_InitModule3("transform", transform_builtins,
+                            DOC_PYGAMETRANSFORM);
 
-	/*imported needed apis*/
-	import_pygame_base();
-	import_pygame_rect();
-	import_pygame_surface();
+    /*imported needed apis*/
+    import_pygame_base();
+    import_pygame_rect();
+    import_pygame_surface();
 }
-
-