1. pygame
  2. Untitled project
  3. pygame

Commits

illume  committed 1633c43

Some code cleanups from Marcus von Appen. min->MIN, indentation, other.
A rewritten scrap module. Hasn't been tested on osx/windows.
Issues with pasting into the gimp. Pasting from the gimp works fine.

  • Participants
  • Parent commits 19d38ed
  • Branches default

Comments (0)

Files changed (33)

File Setup.in

View file
  • Ignore whitespace
 
 
 #--StartConfig
-SDL = -I/usr/include/SDL -D_REENTRANT -lSDL
+SDL = -I/usr/include/SDL -D_REENTRANT -lSDL -CW -CWall
 FONT = -lSDL_ttf
 IMAGE = -lSDL_image
 MIXER = -lSDL_mixer
 X11 = -lX11
 #--EndConfig
 
-
-
+DEBUG = -C-W -C-Wall
 
 #the following modules are optional. you will want to compile
 #everything you can, but you can ignore ones you don't have
 #dependencies for, just comment them out
 
-imageext src/imageext.c $(SDL) $(IMAGE) $(PNG) $(JPEG)
-font src/font.c $(SDL) $(FONT)
-mixer src/mixer.c $(SDL) $(MIXER)
-mixer_music src/music.c $(SDL) $(MIXER)
-surfarray src/surfarray.c $(SDL) $(NUMERIC)
-sndarray src/sndarray.c $(SDL) $(NUMERIC) $(MIXER)
-movie src/movie.c $(SDL) $(SMPEG)
-scrap src/scrap.c $(SDL) $(X11)
+imageext src/imageext.c $(SDL) $(IMAGE) $(PNG) $(JPEG) $(DEBUG)
+font src/font.c $(SDL) $(FONT) $(DEBUG)
+mixer src/mixer.c $(SDL) $(MIXER) $(DEBUG)
+mixer_music src/music.c $(SDL) $(MIXER) $(DEBUG)
+surfarray src/surfarray.c $(SDL) $(NUMERIC) $(DEBUG)
+sndarray src/sndarray.c $(SDL) $(NUMERIC) $(MIXER) $(DEBUG)
+movie src/movie.c $(SDL) $(SMPEG) $(DEBUG)
+scrap src/scrap.c $(SDL) $(X11) $(DEBUG)
 
 #experimental new movie movie. requires libavcodec and libavformat.
 #add any necessary compile flags to this line and uncomment.
 #these modules are required for pygame to run. they only require
 #SDL as a dependency. these should not be altered
 
-base src/base.c $(SDL)
-cdrom src/cdrom.c $(SDL)
-constants src/constants.c $(SDL)
-display src/display.c $(SDL)
-event src/event.c $(SDL)
-fastevent src/fastevent.c src/fastevents.c $(SDL)
-key src/key.c $(SDL)
-mouse src/mouse.c $(SDL)
-rect src/rect.c $(SDL)
-rwobject src/rwobject.c $(SDL)
-surface src/surface.c src/alphablit.c $(SDL)
-surflock src/surflock.c $(SDL)
-time src/time.c $(SDL)
-joystick src/joystick.c $(SDL)
-draw src/draw.c $(SDL)
-image src/image.c $(SDL)
-overlay src/overlay.c $(SDL)
-transform src/transform.c src/rotozoom.c src/scale2x.c $(SDL)
+base src/base.c $(SDL) $(DEBUG)
+cdrom src/cdrom.c $(SDL) $(DEBUG)
+constants src/constants.c $(SDL) $(DEBUG)
+display src/display.c $(SDL) $(DEBUG)
+event src/event.c $(SDL) $(DEBUG)
+fastevent src/fastevent.c src/fastevents.c $(SDL) $(DEBUG)
+key src/key.c $(SDL) $(DEBUG)
+mouse src/mouse.c $(SDL) $(DEBUG)
+rect src/rect.c $(SDL) $(DEBUG)
+rwobject src/rwobject.c $(SDL) $(DEBUG)
+surface src/surface.c src/alphablit.c $(SDL) $(DEBUG)
+surflock src/surflock.c $(SDL) $(DEBUG)
+time src/time.c $(SDL) $(DEBUG)
+joystick src/joystick.c $(SDL) $(DEBUG)
+draw src/draw.c $(SDL) $(DEBUG)
+image src/image.c $(SDL) $(DEBUG)
+overlay src/overlay.c $(SDL) $(DEBUG)
+transform src/transform.c src/rotozoom.c src/scale2x.c $(SDL) $(DEBUG)
 scrap src/scrap.c $(SDL)
 
 
 #auto-copy needed DLLs into the pygame installation folder.
 #you can simply ignore these lines under non-windows, no need to
 #comment out.
-COPYLIB_smpeg $(SDL) $(SMPEG)
+COPYLIB_smpeg $(SDL) $(SMPEG) $(DEBUG)

File WHATSNEW

View file
  • Ignore whitespace
 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
 
+Apr 26, 2007
+    Some code cleanups from Marcus von Appen.  min->MIN, indentation, other.
+    A rewritten scrap module.  Hasn't been tested on osx/windows.
+
 Dec 15, 2006
     Some config changes to make scrap compile correctly on freebsd and debian.
 

File config_unix.py

View file
  • Ignore whitespace
 localbase = os.environ.get('LOCALBASE', '')
 
 #these get prefixes with '/usr' and '/usr/local' or the $LOCALBASE
-origincdirs = ['/include', '/include/SDL', '/include/SDL11',
+origincdirs = ['/include', '/include/SDL', '/include/SDL',
                '/include/smpeg' ]
 origlibdirs = ['/lib','/lib64']
 
                     self.cflags += f + ' '
                 elif f[:3] == '-Wl':
                     self.cflags += '-Xlinker ' + f + ' '
+            if self.name == 'SDL':
+		inc = '-I' + '/usr/X11R6/include'
+		self.cflags = inc + ' ' + self.cflags
         except:
             print 'WARNING: "%s" failed!' % command    
             self.found = 0

File examples/readme.txt

View file
  • Ignore whitespace
 glcube.py - Using PyOpenGL and Pygame, this creates a spinning 3D
 	multicolored cube.
 
+scrap_clipboard.py - A simple demonstration exampl for the clipboard support.
 
 data/ - directory with the resources for the examples
 

File examples/scrap_clipboard.py

View file
  • Ignore whitespace
+#!/usr/bin/env python
+"""
+Demonstrates the clipboard capabilities of pygame.
+"""
 import pygame
 from pygame.locals import *
-pygame.init()
+import pygame.scrap as scrap
+import StringIO
 
-pygame.display.set_mode((200, 200))
 
-import pygame.scrap
-pygame.scrap.init()
-
-
-c = pygame.time.Clock()
-
+pygame.init ()
+screen = pygame.display.set_mode ((200, 200))
+c = pygame.time.Clock ()
 going = True
 
+# Initialize the scrap module and use the clipboard mode.
+scrap.init ()
+scrap.set_mode (SCRAP_CLIPBOARD)
 
 while going:
-    for e in pygame.event.get():
+    for e in pygame.event.get ():
         if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
             going = False
+
         if e.type == KEYDOWN and e.key == K_g:
+            # This means to look for data.
+            print "Getting the different clipboard data.."
+            for t in scrap.get_types ():
+                r = scrap.get (t)
+                if r and len (r) > 500:
+                    print "Type %s : (large buffer)" % t
+                else:
+                    print "Type %s : %s" % (t, r)
+                if "image" in t:
+                    namehint = t.split("/")[1]
+                    if namehint in ['bmp', 'png', 'jpg']:
+                        f = StringIO.StringIO(r)
+                        loaded_surf = pygame.image.load(f, "." + namehint)
+                        screen.blit(loaded_surf, (0,0))
 
-            # this number means to look for text data.
-            r = pygame.scrap.get(SCRAP_TEXT)
-            print type(r)
-            print ":%s:" % r
-
-            if type(r) == type(""):
-                print repr(r)
-                print len(r)
-                print "replaced :%s:" % r.replace("\r", "\n")
 
         if e.type == KEYDOWN and e.key == K_p:
+            # Place some text into the selection.
+            print "Placing clipboard text."
+            scrap.put (SCRAP_TEXT, "Hello. This is a message from scrap.")
 
-            # this number means to look for text data.
-            pygame.scrap.put(SCRAP_TEXT, "Hello.  This is a message from scrap.")
+        if e.type == KEYDOWN and e.key == K_a:
+            # Get all available types.
+            print "Getting the available types from the clipboard."
+            types = scrap.get_types ()
+            print types
+            if len (types) > 0:
+                print "Contains %s: %s" % (types[0], scrap.contains (types[0]))
+                print "Contains _INVALID_: ", scrap.contains ("_INVALID_")
 
-            #r = pygame.scrap.get(SCRAP_TEXT)
-            #print type(r)
-            #print ":%s:" % r
-
-
-
-        if e.type == KEYDOWN and e.key == K_b:
-            r = pygame.scrap.get(1)
-            print type(r)
-            print r
+        if e.type == KEYDOWN and e.key == K_i:
+            print "Putting image into the clipboard."
+            scrap.set_mode (SCRAP_CLIPBOARD)
+            fp = open ("data/liquid.bmp", "rb")
+            buf = fp.read ()
+            scrap.put ("image/bmp", buf)
+            print len (buf)
+            fp.close ()
 
     pygame.display.flip()
     c.tick(40)

File lib/mac_scrap.py

View file
  • Ignore whitespace
         content = board.stringForType_(NSStringPboardType)
         return content
     elif scrap_type == SCRAP_BMP:
-        # We could try loading directly but I don't trust pygame's TIFF loading.
-        # This is slow and stupid but it does happen to work.
+        # We could try loading directly but I don't trust pygame's TIFF
+        # loading.  This is slow and stupid but it does happen to work.
         if not NSImage.canInitWithPasteboard_(board):
             return None
         img = NSImage.alloc().initWithPasteboard_(board)

File src/base.c

View file
  • Ignore whitespace
 	}
 	PyList_Append(quitfunctions, quitfunc);
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
     //force crash
     *((int*)1) = 45;
     memcpy((char*)2, (char*)3, 10);
-    RETURN_NONE
+    Py_RETURN_NONE;
 }
 
 

File src/cdrom.c

View file
  • Ignore whitespace
 
 	cdrom_autoquit();
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(!istrue)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
                 if(!cdrom_drivedata[cd_id])
 			return RAISE(PyExc_SDLError, "Cannot initialize device");
 	}
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		SDL_CDClose(cdrom_drivedata[cd_id]);
 		cdrom_drivedata[cd_id] = NULL;
 	}
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(playforever)
 	    end = start;
 	else if(start == end && start != 0.0f)
-	    RETURN_NONE;
+	    Py_RETURN_NONE;;
 	
 	startframe = (int)(start * CD_FPS);
 	numframes = 0;
 	else
 		numframes = cdrom->track[track].length - startframe;
 	if(numframes < 0 || startframe > (int)(cdrom->track[track].length * CD_FPS))
-		RETURN_NONE;
+		Py_RETURN_NONE;;
 
 	result = SDL_CDPlayTracks(cdrom, track, startframe, 0, numframes);
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/constants.c

View file
  • Ignore whitespace
 #include "pygame.h"
 #include "scrap.h"
 
-
 /* macros used to create each constant */
 #define DEC_CONST(x)  PyModule_AddIntConstant(module, #x, (int) SDL_##x);
 #define DEC_CONSTK(x) PyModule_AddIntConstant(module, #x, (int) SDL##x);
 #define DEC_CONSTN(x) PyModule_AddIntConstant(module, #x, (int) x);
 #define DEC_CONSTS(x,y) PyModule_AddIntConstant(module, #x, (int) y);
 
+#define ADD_STRING_CONST(x) PyModule_AddStringConstant(module, #x, x);
 
 static PyMethodDef builtins[] =
 {
-	{NULL}
+    {NULL}
 };
 
-
-
 PYGAME_EXPORT
 void initconstants(void)
 {
-	PyObject* module;
-
-	module = Py_InitModule3("constants", builtins,
-	           "Constants defined by SDL and needed in Pygame.\n");
-
-	DEC_CONST(YV12_OVERLAY);
-	DEC_CONST(IYUV_OVERLAY);
-	DEC_CONST(YUY2_OVERLAY);
-	DEC_CONST(UYVY_OVERLAY);
-	DEC_CONST(YVYU_OVERLAY);
-
-	DEC_CONST(SWSURFACE);
-	DEC_CONST(HWSURFACE);
-	DEC_CONST(RESIZABLE);
-	DEC_CONST(ASYNCBLIT);
-	DEC_CONST(OPENGL);
-	DEC_CONST(OPENGLBLIT)
-	DEC_CONST(ANYFORMAT);
-	DEC_CONST(HWPALETTE);
-	DEC_CONST(DOUBLEBUF);
-	DEC_CONST(FULLSCREEN);
-	DEC_CONST(HWACCEL);
-	DEC_CONST(SRCCOLORKEY);
-	DEC_CONST(RLEACCELOK);
-	DEC_CONST(RLEACCEL);
-	DEC_CONST(SRCALPHA);
-	DEC_CONST(PREALLOC);
-	DEC_CONST(NOFRAME);
-
-	DEC_CONST(GL_RED_SIZE);
-	DEC_CONST(GL_GREEN_SIZE);
-	DEC_CONST(GL_BLUE_SIZE);
-	DEC_CONST(GL_ALPHA_SIZE);
-	DEC_CONST(GL_BUFFER_SIZE);
-	DEC_CONST(GL_DOUBLEBUFFER);
-	DEC_CONST(GL_DEPTH_SIZE);
-	DEC_CONST(GL_STENCIL_SIZE);
-	DEC_CONST(GL_ACCUM_RED_SIZE);
-	DEC_CONST(GL_ACCUM_GREEN_SIZE);
-	DEC_CONST(GL_ACCUM_BLUE_SIZE);
-	DEC_CONST(GL_ACCUM_ALPHA_SIZE);
+    PyObject* module;
+    
+    module = Py_InitModule3
+        ("constants", builtins,
+         "Constants defined by SDL and needed in Pygame.\n");
+    
+    DEC_CONST(YV12_OVERLAY);
+    DEC_CONST(IYUV_OVERLAY);
+    DEC_CONST(YUY2_OVERLAY);
+    DEC_CONST(UYVY_OVERLAY);
+    DEC_CONST(YVYU_OVERLAY);
+    
+    DEC_CONST(SWSURFACE);
+    DEC_CONST(HWSURFACE);
+    DEC_CONST(RESIZABLE);
+    DEC_CONST(ASYNCBLIT);
+    DEC_CONST(OPENGL);
+    DEC_CONST(OPENGLBLIT);
+    DEC_CONST(ANYFORMAT);
+    DEC_CONST(HWPALETTE);
+    DEC_CONST(DOUBLEBUF);
+    DEC_CONST(FULLSCREEN);
+    DEC_CONST(HWACCEL);
+    DEC_CONST(SRCCOLORKEY);
+    DEC_CONST(RLEACCELOK);
+    DEC_CONST(RLEACCEL);
+    DEC_CONST(SRCALPHA);
+    DEC_CONST(PREALLOC);
+    DEC_CONST(NOFRAME);
+    
+    DEC_CONST(GL_RED_SIZE);
+    DEC_CONST(GL_GREEN_SIZE);
+    DEC_CONST(GL_BLUE_SIZE);
+    DEC_CONST(GL_ALPHA_SIZE);
+    DEC_CONST(GL_BUFFER_SIZE);
+    DEC_CONST(GL_DOUBLEBUFFER);
+    DEC_CONST(GL_DEPTH_SIZE);
+    DEC_CONST(GL_STENCIL_SIZE);
+    DEC_CONST(GL_ACCUM_RED_SIZE);
+    DEC_CONST(GL_ACCUM_GREEN_SIZE);
+    DEC_CONST(GL_ACCUM_BLUE_SIZE);
+    DEC_CONST(GL_ACCUM_ALPHA_SIZE);
 #if SDL_VERSION_ATLEAST(1, 2, 5)
-	DEC_CONST(GL_STEREO);
+    DEC_CONST(GL_STEREO);
 #else
-	PyModule_AddIntConstant(module, "GL_STEREO", -1);
+    PyModule_AddIntConstant(module, "GL_STEREO", -1);
 #endif
 #if SDL_VERSION_ATLEAST(1, 2, 6)
-	DEC_CONST(GL_MULTISAMPLEBUFFERS);
-	DEC_CONST(GL_MULTISAMPLESAMPLES);
+    DEC_CONST(GL_MULTISAMPLEBUFFERS);
+    DEC_CONST(GL_MULTISAMPLESAMPLES);
 #else
-	PyModule_AddIntConstant(module, "GL_MULTISAMPLEBUFFERS", -1);
-	PyModule_AddIntConstant(module, "GL_MULTISAMPLESAMPLES", -1);
+    PyModule_AddIntConstant(module, "GL_MULTISAMPLEBUFFERS", -1);
+    PyModule_AddIntConstant(module, "GL_MULTISAMPLESAMPLES", -1);
 #endif
 
-	DEC_CONSTN(TIMER_RESOLUTION);
+    DEC_CONSTN(TIMER_RESOLUTION);
     
-	DEC_CONSTN(AUDIO_U8);
-	DEC_CONSTN(AUDIO_S8);
-	DEC_CONSTN(AUDIO_U16LSB);
-	DEC_CONSTN(AUDIO_S16LSB);
-	DEC_CONSTN(AUDIO_U16MSB);
-	DEC_CONSTN(AUDIO_S16MSB);
-	DEC_CONSTN(AUDIO_U16);
-	DEC_CONSTN(AUDIO_S16);
-	DEC_CONSTN(AUDIO_U16SYS);
-	DEC_CONSTN(AUDIO_S16SYS);
+    DEC_CONSTN(AUDIO_U8);
+    DEC_CONSTN(AUDIO_S8);
+    DEC_CONSTN(AUDIO_U16LSB);
+    DEC_CONSTN(AUDIO_S16LSB);
+    DEC_CONSTN(AUDIO_U16MSB);
+    DEC_CONSTN(AUDIO_S16MSB);
+    DEC_CONSTN(AUDIO_U16);
+    DEC_CONSTN(AUDIO_S16);
+    DEC_CONSTN(AUDIO_U16SYS);
+    DEC_CONSTN(AUDIO_S16SYS);
 
 #define SCRAP_TEXT PYGAME_SCRAP_TEXT
 #define SCRAP_BMP PYGAME_SCRAP_BMP
+#define SCRAP_PPM PYGAME_SCRAP_PPM
+#define SCRAP_PBM PYGAME_SCRAP_PBM
 
-	DEC_CONSTN(SCRAP_TEXT);
-	DEC_CONSTN(SCRAP_BMP);
+    ADD_STRING_CONST(SCRAP_TEXT);
+    ADD_STRING_CONST(SCRAP_BMP);
+    ADD_STRING_CONST(SCRAP_PPM);
+    ADD_STRING_CONST(SCRAP_PBM);
+    PyModule_AddIntConstant(module, "SCRAP_CLIPBOARD", 0);
+    PyModule_AddIntConstant(module, "SCRAP_SELECTION", 1);
 
 #define PYGAME_BLEND_ADD 0x1
 #define PYGAME_BLEND_ADD  0x1
 #define PYGAME_BLEND_MIN  0x4
 #define PYGAME_BLEND_MAX  0x5
 
-        DEC_CONSTS(BLEND_ADD,  PYGAME_BLEND_ADD);
-        DEC_CONSTS(BLEND_SUB,  PYGAME_BLEND_SUB);
-        DEC_CONSTS(BLEND_MULT, PYGAME_BLEND_MULT);
-        DEC_CONSTS(BLEND_MIN,  PYGAME_BLEND_MIN);
-        DEC_CONSTS(BLEND_MAX,  PYGAME_BLEND_MAX);
+    DEC_CONSTS(BLEND_ADD,  PYGAME_BLEND_ADD);
+    DEC_CONSTS(BLEND_SUB,  PYGAME_BLEND_SUB);
+    DEC_CONSTS(BLEND_MULT, PYGAME_BLEND_MULT);
+    DEC_CONSTS(BLEND_MIN,  PYGAME_BLEND_MIN);
+    DEC_CONSTS(BLEND_MAX,  PYGAME_BLEND_MAX);
 
-
-	DEC_CONST(NOEVENT);
-	DEC_CONST(ACTIVEEVENT);
-	DEC_CONST(KEYDOWN);
-	DEC_CONST(KEYUP);
-	DEC_CONST(MOUSEMOTION);
-	DEC_CONST(MOUSEBUTTONDOWN);
-	DEC_CONST(MOUSEBUTTONUP);
-	DEC_CONST(JOYAXISMOTION);
-	DEC_CONST(JOYBALLMOTION);
-	DEC_CONST(JOYHATMOTION);
-	DEC_CONST(JOYBUTTONDOWN);
-	DEC_CONST(JOYBUTTONUP);
-	DEC_CONST(VIDEORESIZE);
-	DEC_CONST(VIDEOEXPOSE);
-	DEC_CONST(QUIT);
-	DEC_CONST(SYSWMEVENT);
-	DEC_CONST(USEREVENT);
-	DEC_CONST(NUMEVENTS);
-
-	DEC_CONST(HAT_CENTERED);
-	DEC_CONST(HAT_UP);
-	DEC_CONST(HAT_RIGHTUP);
-	DEC_CONST(HAT_RIGHT);
-	DEC_CONST(HAT_RIGHTDOWN);
-	DEC_CONST(HAT_DOWN);
-	DEC_CONST(HAT_LEFTDOWN);
-	DEC_CONST(HAT_LEFT);
-	DEC_CONST(HAT_LEFTUP);
-
-
-	DEC_CONSTK(K_UNKNOWN);
-	DEC_CONSTK(K_FIRST);
-	DEC_CONSTK(K_BACKSPACE);
-	DEC_CONSTK(K_TAB);
-	DEC_CONSTK(K_CLEAR);
-	DEC_CONSTK(K_RETURN);
-	DEC_CONSTK(K_PAUSE);
-	DEC_CONSTK(K_ESCAPE);
-	DEC_CONSTK(K_SPACE);
-	DEC_CONSTK(K_EXCLAIM);
-	DEC_CONSTK(K_QUOTEDBL);
-	DEC_CONSTK(K_HASH);
-	DEC_CONSTK(K_DOLLAR);
-	DEC_CONSTK(K_AMPERSAND);
-	DEC_CONSTK(K_QUOTE);
-	DEC_CONSTK(K_LEFTPAREN);
-	DEC_CONSTK(K_RIGHTPAREN);
-	DEC_CONSTK(K_ASTERISK);
-	DEC_CONSTK(K_PLUS);
-	DEC_CONSTK(K_COMMA);
-	DEC_CONSTK(K_MINUS);
-	DEC_CONSTK(K_PERIOD);
-	DEC_CONSTK(K_SLASH);
-	DEC_CONSTK(K_0);
-	DEC_CONSTK(K_1);
-	DEC_CONSTK(K_2);
-	DEC_CONSTK(K_3);
-	DEC_CONSTK(K_4);
-	DEC_CONSTK(K_5);
-	DEC_CONSTK(K_6);
-	DEC_CONSTK(K_7);
-	DEC_CONSTK(K_8);
-	DEC_CONSTK(K_9);
-	DEC_CONSTK(K_COLON);
-	DEC_CONSTK(K_SEMICOLON);
-	DEC_CONSTK(K_LESS);
-	DEC_CONSTK(K_EQUALS);
-	DEC_CONSTK(K_GREATER);
-	DEC_CONSTK(K_QUESTION);
-	DEC_CONSTK(K_AT);
-	DEC_CONSTK(K_LEFTBRACKET);
-	DEC_CONSTK(K_BACKSLASH);
-	DEC_CONSTK(K_RIGHTBRACKET);
-	DEC_CONSTK(K_CARET);
-	DEC_CONSTK(K_UNDERSCORE);
-	DEC_CONSTK(K_BACKQUOTE);
-	DEC_CONSTK(K_a);
-	DEC_CONSTK(K_b);
-	DEC_CONSTK(K_c);
-	DEC_CONSTK(K_d);
-	DEC_CONSTK(K_e);
-	DEC_CONSTK(K_f);
-	DEC_CONSTK(K_g);
-	DEC_CONSTK(K_h);
-	DEC_CONSTK(K_i);
-	DEC_CONSTK(K_j);
-	DEC_CONSTK(K_k);
-	DEC_CONSTK(K_l);
-	DEC_CONSTK(K_m);
-	DEC_CONSTK(K_n);
-	DEC_CONSTK(K_o);
-	DEC_CONSTK(K_p);
-	DEC_CONSTK(K_q);
-	DEC_CONSTK(K_r);
-	DEC_CONSTK(K_s);
-	DEC_CONSTK(K_t);
-	DEC_CONSTK(K_u);
-	DEC_CONSTK(K_v);
-	DEC_CONSTK(K_w);
-	DEC_CONSTK(K_x);
-	DEC_CONSTK(K_y);
-	DEC_CONSTK(K_z);
-	DEC_CONSTK(K_DELETE);
-
-	DEC_CONSTK(K_KP0);
-	DEC_CONSTK(K_KP1);
-	DEC_CONSTK(K_KP2);
-	DEC_CONSTK(K_KP3);
-	DEC_CONSTK(K_KP4);
-	DEC_CONSTK(K_KP5);
-	DEC_CONSTK(K_KP6);
-	DEC_CONSTK(K_KP7);
-	DEC_CONSTK(K_KP8);
-	DEC_CONSTK(K_KP9);
-	DEC_CONSTK(K_KP_PERIOD);
-	DEC_CONSTK(K_KP_DIVIDE);
-	DEC_CONSTK(K_KP_MULTIPLY);
-	DEC_CONSTK(K_KP_MINUS);
-	DEC_CONSTK(K_KP_PLUS);
-	DEC_CONSTK(K_KP_ENTER);
-	DEC_CONSTK(K_KP_EQUALS);
-	DEC_CONSTK(K_UP);
-	DEC_CONSTK(K_DOWN);
-	DEC_CONSTK(K_RIGHT);
-	DEC_CONSTK(K_LEFT);
-	DEC_CONSTK(K_INSERT);
-	DEC_CONSTK(K_HOME);
-	DEC_CONSTK(K_END);
-	DEC_CONSTK(K_PAGEUP);
-	DEC_CONSTK(K_PAGEDOWN);
-	DEC_CONSTK(K_F1);
-	DEC_CONSTK(K_F2);
-	DEC_CONSTK(K_F3);
-	DEC_CONSTK(K_F4);
-	DEC_CONSTK(K_F5);
-	DEC_CONSTK(K_F6);
-	DEC_CONSTK(K_F7);
-	DEC_CONSTK(K_F8);
-	DEC_CONSTK(K_F9);
-	DEC_CONSTK(K_F10);
-	DEC_CONSTK(K_F11);
-	DEC_CONSTK(K_F12);
-	DEC_CONSTK(K_F13);
-	DEC_CONSTK(K_F14);
-	DEC_CONSTK(K_F15);
-
-	DEC_CONSTK(K_NUMLOCK);
-	DEC_CONSTK(K_CAPSLOCK);
-	DEC_CONSTK(K_SCROLLOCK);
-	DEC_CONSTK(K_RSHIFT);
-	DEC_CONSTK(K_LSHIFT);
-	DEC_CONSTK(K_RCTRL);
-	DEC_CONSTK(K_LCTRL);
-	DEC_CONSTK(K_RALT);
-	DEC_CONSTK(K_LALT);
-	DEC_CONSTK(K_RMETA);
-	DEC_CONSTK(K_LMETA);
-	DEC_CONSTK(K_LSUPER);
-	DEC_CONSTK(K_RSUPER);
-	DEC_CONSTK(K_MODE);
-
-	DEC_CONSTK(K_HELP);
-	DEC_CONSTK(K_PRINT);
-	DEC_CONSTK(K_SYSREQ);
-	DEC_CONSTK(K_BREAK);
-	DEC_CONSTK(K_MENU);
-	DEC_CONSTK(K_POWER);
-	DEC_CONSTK(K_EURO);
-	DEC_CONSTK(K_LAST);
-
-	DEC_CONSTN(KMOD_NONE);
-	DEC_CONSTN(KMOD_LSHIFT);
-	DEC_CONSTN(KMOD_RSHIFT);
-	DEC_CONSTN(KMOD_LCTRL);
-	DEC_CONSTN(KMOD_RCTRL);
-	DEC_CONSTN(KMOD_LALT);
-	DEC_CONSTN(KMOD_RALT);
-	DEC_CONSTN(KMOD_LMETA);
-	DEC_CONSTN(KMOD_RMETA);
-	DEC_CONSTN(KMOD_NUM);
-	DEC_CONSTN(KMOD_CAPS);
-	DEC_CONSTN(KMOD_MODE);
-
-	DEC_CONSTN(KMOD_CTRL);
-	DEC_CONSTN(KMOD_SHIFT);
-	DEC_CONSTN(KMOD_ALT);
-	DEC_CONSTN(KMOD_META);
+    DEC_CONST(NOEVENT);
+    DEC_CONST(ACTIVEEVENT);
+    DEC_CONST(KEYDOWN);
+    DEC_CONST(KEYUP);
+    DEC_CONST(MOUSEMOTION);
+    DEC_CONST(MOUSEBUTTONDOWN);
+    DEC_CONST(MOUSEBUTTONUP);
+    DEC_CONST(JOYAXISMOTION);
+    DEC_CONST(JOYBALLMOTION);
+    DEC_CONST(JOYHATMOTION);
+    DEC_CONST(JOYBUTTONDOWN);
+    DEC_CONST(JOYBUTTONUP);
+    DEC_CONST(VIDEORESIZE);
+    DEC_CONST(VIDEOEXPOSE);
+    DEC_CONST(QUIT);
+    DEC_CONST(SYSWMEVENT);
+    DEC_CONST(USEREVENT);
+    DEC_CONST(NUMEVENTS);
+    
+    DEC_CONST(HAT_CENTERED);
+    DEC_CONST(HAT_UP);
+    DEC_CONST(HAT_RIGHTUP);
+    DEC_CONST(HAT_RIGHT);
+    DEC_CONST(HAT_RIGHTDOWN);
+    DEC_CONST(HAT_DOWN);
+    DEC_CONST(HAT_LEFTDOWN);
+    DEC_CONST(HAT_LEFT);
+    DEC_CONST(HAT_LEFTUP);
+    
+    DEC_CONSTK(K_UNKNOWN);
+    DEC_CONSTK(K_FIRST);
+    DEC_CONSTK(K_BACKSPACE);
+    DEC_CONSTK(K_TAB);
+    DEC_CONSTK(K_CLEAR);
+    DEC_CONSTK(K_RETURN);
+    DEC_CONSTK(K_PAUSE);
+    DEC_CONSTK(K_ESCAPE);
+    DEC_CONSTK(K_SPACE);
+    DEC_CONSTK(K_EXCLAIM);
+    DEC_CONSTK(K_QUOTEDBL);
+    DEC_CONSTK(K_HASH);
+    DEC_CONSTK(K_DOLLAR);
+    DEC_CONSTK(K_AMPERSAND);
+    DEC_CONSTK(K_QUOTE);
+    DEC_CONSTK(K_LEFTPAREN);
+    DEC_CONSTK(K_RIGHTPAREN);
+    DEC_CONSTK(K_ASTERISK);
+    DEC_CONSTK(K_PLUS);
+    DEC_CONSTK(K_COMMA);
+    DEC_CONSTK(K_MINUS);
+    DEC_CONSTK(K_PERIOD);
+    DEC_CONSTK(K_SLASH);
+    DEC_CONSTK(K_0);
+    DEC_CONSTK(K_1);
+    DEC_CONSTK(K_2);
+    DEC_CONSTK(K_3);
+    DEC_CONSTK(K_4);
+    DEC_CONSTK(K_5);
+    DEC_CONSTK(K_6);
+    DEC_CONSTK(K_7);
+    DEC_CONSTK(K_8);
+    DEC_CONSTK(K_9);
+    DEC_CONSTK(K_COLON);
+    DEC_CONSTK(K_SEMICOLON);
+    DEC_CONSTK(K_LESS);
+    DEC_CONSTK(K_EQUALS);
+    DEC_CONSTK(K_GREATER);
+    DEC_CONSTK(K_QUESTION);
+    DEC_CONSTK(K_AT);
+    DEC_CONSTK(K_LEFTBRACKET);
+    DEC_CONSTK(K_BACKSLASH);
+    DEC_CONSTK(K_RIGHTBRACKET);
+    DEC_CONSTK(K_CARET);
+    DEC_CONSTK(K_UNDERSCORE);
+    DEC_CONSTK(K_BACKQUOTE);
+    DEC_CONSTK(K_a);
+    DEC_CONSTK(K_b);
+    DEC_CONSTK(K_c);
+    DEC_CONSTK(K_d);
+    DEC_CONSTK(K_e);
+    DEC_CONSTK(K_f);
+    DEC_CONSTK(K_g);
+    DEC_CONSTK(K_h);
+    DEC_CONSTK(K_i);
+    DEC_CONSTK(K_j);
+    DEC_CONSTK(K_k);
+    DEC_CONSTK(K_l);
+    DEC_CONSTK(K_m);
+    DEC_CONSTK(K_n);
+    DEC_CONSTK(K_o);
+    DEC_CONSTK(K_p);
+    DEC_CONSTK(K_q);
+    DEC_CONSTK(K_r);
+    DEC_CONSTK(K_s);
+    DEC_CONSTK(K_t);
+    DEC_CONSTK(K_u);
+    DEC_CONSTK(K_v);
+    DEC_CONSTK(K_w);
+    DEC_CONSTK(K_x);
+    DEC_CONSTK(K_y);
+    DEC_CONSTK(K_z);
+    DEC_CONSTK(K_DELETE);
+    
+    DEC_CONSTK(K_KP0);
+    DEC_CONSTK(K_KP1);
+    DEC_CONSTK(K_KP2);
+    DEC_CONSTK(K_KP3);
+    DEC_CONSTK(K_KP4);
+    DEC_CONSTK(K_KP5);
+    DEC_CONSTK(K_KP6);
+    DEC_CONSTK(K_KP7);
+    DEC_CONSTK(K_KP8);
+    DEC_CONSTK(K_KP9);
+    DEC_CONSTK(K_KP_PERIOD);
+    DEC_CONSTK(K_KP_DIVIDE);
+    DEC_CONSTK(K_KP_MULTIPLY);
+    DEC_CONSTK(K_KP_MINUS);
+    DEC_CONSTK(K_KP_PLUS);
+    DEC_CONSTK(K_KP_ENTER);
+    DEC_CONSTK(K_KP_EQUALS);
+    DEC_CONSTK(K_UP);
+    DEC_CONSTK(K_DOWN);
+    DEC_CONSTK(K_RIGHT);
+    DEC_CONSTK(K_LEFT);
+    DEC_CONSTK(K_INSERT);
+    DEC_CONSTK(K_HOME);
+    DEC_CONSTK(K_END);
+    DEC_CONSTK(K_PAGEUP);
+    DEC_CONSTK(K_PAGEDOWN);
+    DEC_CONSTK(K_F1);
+    DEC_CONSTK(K_F2);
+    DEC_CONSTK(K_F3);
+    DEC_CONSTK(K_F4);
+    DEC_CONSTK(K_F5);
+    DEC_CONSTK(K_F6);
+    DEC_CONSTK(K_F7);
+    DEC_CONSTK(K_F8);
+    DEC_CONSTK(K_F9);
+    DEC_CONSTK(K_F10);
+    DEC_CONSTK(K_F11);
+    DEC_CONSTK(K_F12);
+    DEC_CONSTK(K_F13);
+    DEC_CONSTK(K_F14);
+    DEC_CONSTK(K_F15);
+    
+    DEC_CONSTK(K_NUMLOCK);
+    DEC_CONSTK(K_CAPSLOCK);
+    DEC_CONSTK(K_SCROLLOCK);
+    DEC_CONSTK(K_RSHIFT);
+    DEC_CONSTK(K_LSHIFT);
+    DEC_CONSTK(K_RCTRL);
+    DEC_CONSTK(K_LCTRL);
+    DEC_CONSTK(K_RALT);
+    DEC_CONSTK(K_LALT);
+    DEC_CONSTK(K_RMETA);
+    DEC_CONSTK(K_LMETA);
+    DEC_CONSTK(K_LSUPER);
+    DEC_CONSTK(K_RSUPER);
+    DEC_CONSTK(K_MODE);
+    
+    DEC_CONSTK(K_HELP);
+    DEC_CONSTK(K_PRINT);
+    DEC_CONSTK(K_SYSREQ);
+    DEC_CONSTK(K_BREAK);
+    DEC_CONSTK(K_MENU);
+    DEC_CONSTK(K_POWER);
+    DEC_CONSTK(K_EURO);
+    DEC_CONSTK(K_LAST);
+    
+    DEC_CONSTN(KMOD_NONE);
+    DEC_CONSTN(KMOD_LSHIFT);
+    DEC_CONSTN(KMOD_RSHIFT);
+    DEC_CONSTN(KMOD_LCTRL);
+    DEC_CONSTN(KMOD_RCTRL);
+    DEC_CONSTN(KMOD_LALT);
+    DEC_CONSTN(KMOD_RALT);
+    DEC_CONSTN(KMOD_LMETA);
+    DEC_CONSTN(KMOD_RMETA);
+    DEC_CONSTN(KMOD_NUM);
+    DEC_CONSTN(KMOD_CAPS);
+    DEC_CONSTN(KMOD_MODE);
+    
+    DEC_CONSTN(KMOD_CTRL);
+    DEC_CONSTN(KMOD_SHIFT);
+    DEC_CONSTN(KMOD_ALT);
+    DEC_CONSTN(KMOD_META);
 }
-

File src/display.c

View file
  • Ignore whitespace
 	PyGame_Video_AutoQuit();
 	display_autoquit();
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(!display_autoinit(NULL, NULL))
 		return NULL;
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	/*override the default video driver*/
 	/*environment variable: SDL_VIDEODRIVER*/
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 #endif
 
 		return NULL;
 
 	if(!DisplaySurfaceObject)
-		RETURN_NONE
+		Py_RETURN_NONE;
 
 	Py_INCREF(DisplaySurfaceObject);
 	return DisplaySurfaceObject;
 	if(!PyArg_ParseTuple(arg, "ii", &flag, &value))
 		return NULL;
 	if(flag == -1) /*an undefined/unsupported val, ignore*/
-		RETURN_NONE
+		Py_RETURN_NONE;
 
 	result = SDL_GL_SetAttribute(flag, value);
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(status == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		return 0;
 	else
 	{
-		int right = min(r->x + r->w, w);
-		int bottom = min(r->y + r->h, h);
-		cur->x = (short)max(r->x, 0);
-		cur->y = (short)max(r->y, 0);
+		int right = MIN(r->x + r->w, w);
+		int bottom = MIN(r->y + r->h, h);
+		cur->x = (short)MAX(r->x, 0);
+		cur->y = (short)MAX(r->y, 0);
 		cur->w = (unsigned short)right - cur->x;
 		cur->h = (unsigned short)bottom - cur->y;
 	}
 	if(PyTuple_Size(arg) == 0)
 	{
 		SDL_UpdateRect(screen, 0, 0, 0, 0);
-		RETURN_NONE
+		Py_RETURN_NONE;
 	}
 	else
 	{
 			SDL_UpdateRects(screen, count, rects);
 		PyMem_Free((char*)rects);
 	}
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		colors = pal->colors;
 		len = pal->ncolors;
 		SDL_SetPalette(surf, SDL_PHYSPAL, colors, 0, len);
-		RETURN_NONE
+		Py_RETURN_NONE;
 	}
 
 
 	if(!PySequence_Check(list))
 		return RAISE(PyExc_ValueError, "Argument must be a sequence type");
 
-	len = min(pal->ncolors, PySequence_Length(list));
+	len = MIN(pal->ncolors, PySequence_Length(list));
 
 	colors = (SDL_Color*)malloc(len * sizeof(SDL_Color));
 	if(!colors)
 	SDL_SetPalette(surf, SDL_PHYSPAL, colors, 0, len);
 
 	free((char*)colors);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 
 	SDL_WM_SetCaption(title, icontitle);
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
         if(!PyGame_Video_AutoInit())
                return RAISE(PyExc_SDLError, SDL_GetError());
 	do_set_icon(surface);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/draw.c

View file
  • Ignore whitespace
 		starty = pts[3] = y;
 		if(clip_and_draw_aaline(surf, &surf->clip_rect, color, pts, blend))
 		{
-			left = min((int)min(pts[0], pts[2]), left);
-			top = min((int)min(pts[1], pts[3]), top);
-			right = max((int)max(pts[0], pts[2]), right);
-			bottom = max((int)max(pts[1], pts[3]), bottom);
+			left = MIN((int)MIN(pts[0], pts[2]), left);
+			top = MIN((int)MIN(pts[1], pts[3]), top);
+			right = MAX((int)MAX(pts[0], pts[2]), right);
+			bottom = MAX((int)MAX(pts[1], pts[3]), bottom);
 		}
 	}
 	if(closed && drawn > 2)
 		starty = pts[3] = y;
 		if(clip_and_draw_line_width(surf, &surf->clip_rect, color, width, pts))
 		{
-			left = min(min(pts[0], pts[2]), left);
-			top = min(min(pts[1], pts[3]), top);
-			right = max(max(pts[0], pts[2]), right);
-			bottom = max(max(pts[1], pts[3]), bottom);
+			left = MIN(MIN(pts[0], pts[2]), left);
+			top = MIN(MIN(pts[1], pts[3]), top);
+			right = MAX(MAX(pts[0], pts[2]), right);
+			bottom = MAX(MAX(pts[1], pts[3]), bottom);
 		}
 	}
 	if(closed && drawn > 2)
 
 	if(!PySurface_Lock(surfobj)) return NULL;
 
-	width = min(width, min(rect->w, rect->h) / 2);
+	width = MIN(width, MIN(rect->w, rect->h) / 2);
 	for(loop=0; loop<width; ++loop)
 	{
 		draw_arc(surf, rect->x+rect->w/2, rect->y+rect->h/2,
 
 	if(!PySurface_Unlock(surfobj)) return NULL;
 
-	l = max(rect->x, surf->clip_rect.x);
-	t = max(rect->y, surf->clip_rect.y);
-	r = min(rect->x + rect->w, surf->clip_rect.x + surf->clip_rect.w);
-	b = min(rect->y + rect->h, surf->clip_rect.y + surf->clip_rect.h);
-	return PyRect_New4(l, t, max(r-l, 0), max(b-t, 0));
+	l = MAX(rect->x, surf->clip_rect.x);
+	t = MAX(rect->y, surf->clip_rect.y);
+	r = MIN(rect->x + rect->w, surf->clip_rect.x + surf->clip_rect.w);
+	b = MIN(rect->y + rect->h, surf->clip_rect.y + surf->clip_rect.h);
+	return PyRect_New4(l, t, MAX(r-l, 0), MAX(b-t, 0));
 }
 
 
 					(Sint16)(rect->w/2), (Sint16)(rect->h/2), color);
 	else
 	{
-		width = min(width, min(rect->w, rect->h) / 2);
+		width = MIN(width, MIN(rect->w, rect->h) / 2);
 		for(loop=0; loop<width; ++loop)
 		{
 			draw_ellipse(surf, rect->x+rect->w/2, rect->y+rect->h/2,
 
 	if(!PySurface_Unlock(surfobj)) return NULL;
 
-	l = max(rect->x, surf->clip_rect.x);
-	t = max(rect->y, surf->clip_rect.y);
-	r = min(rect->x + rect->w, surf->clip_rect.x + surf->clip_rect.w);
-	b = min(rect->y + rect->h, surf->clip_rect.y + surf->clip_rect.h);
-	return PyRect_New4(l, t, max(r-l, 0), max(b-t, 0));
+	l = MAX(rect->x, surf->clip_rect.x);
+	t = MAX(rect->y, surf->clip_rect.y);
+	r = MIN(rect->x + rect->w, surf->clip_rect.x + surf->clip_rect.w);
+	b = MIN(rect->y + rect->h, surf->clip_rect.y + surf->clip_rect.h);
+	return PyRect_New4(l, t, MAX(r-l, 0), MAX(b-t, 0));
 }
 
 
 
 	if(!PySurface_Unlock(surfobj)) return NULL;
 
-	l = max(posx - radius, surf->clip_rect.x);
-	t = max(posy - radius, surf->clip_rect.y);
-	r = min(posx + radius, surf->clip_rect.x + surf->clip_rect.w);
-	b = min(posy + radius, surf->clip_rect.y + surf->clip_rect.h);
-	return PyRect_New4(l, t, max(r-l, 0), max(b-t, 0));
+	l = MAX(posx - radius, surf->clip_rect.x);
+	t = MAX(posy - radius, surf->clip_rect.y);
+	r = MIN(posx + radius, surf->clip_rect.x + surf->clip_rect.w);
+	b = MIN(posy + radius, surf->clip_rect.y + surf->clip_rect.h);
+	return PyRect_New4(l, t, MAX(r-l, 0), MAX(b-t, 0));
 }
 
 
 		xlist[numpoints] = x;
 		ylist[numpoints] = y;
 		++numpoints;
-		left = min(x, left);
-		top = min(y, top);
-		right = max(x, right);
-		bottom = max(y, bottom);
+		left = MIN(x, left);
+		top = MIN(y, top);
+		right = MAX(x, right);
+		bottom = MAX(y, bottom);
 	}
 
 	if(!PySurface_Lock(surfobj))
 	if(!PySurface_Unlock(surfobj))
 		return NULL;
 
-	left = max(left, surf->clip_rect.x);
-	top = max(top, surf->clip_rect.y);
-	right = min(right, surf->clip_rect.x + surf->clip_rect.w);
-	bottom = min(bottom, surf->clip_rect.y + surf->clip_rect.h);
+	left = MAX(left, surf->clip_rect.x);
+	top = MAX(top, surf->clip_rect.y);
+	right = MIN(right, surf->clip_rect.x + surf->clip_rect.w);
+	bottom = MIN(bottom, surf->clip_rect.y + surf->clip_rect.h);
 	return PyRect_New4(left, top, right-left+1, bottom-top+1);
 }
 
 		if(clip_and_draw_line(surf, rect, color, newpts))
 		{
 			anydrawn = 1;
-			range[0] = min(newpts[0], range[0]);
-			range[1] = min(newpts[1], range[1]);
-			range[2] = max(newpts[2], range[2]);
-			range[3] = max(newpts[3], range[3]);
+			range[0] = MIN(newpts[0], range[0]);
+			range[1] = MIN(newpts[1], range[1]);
+			range[2] = MAX(newpts[2], range[2]);
+			range[3] = MAX(newpts[3], range[3]);
 		}
 		if(loop+1<width)
 		{
 			if(clip_and_draw_line(surf, rect, color, newpts))
 			{
 				anydrawn = 1;
-				range[0] = min(newpts[0], range[0]);
-				range[1] = min(newpts[1], range[1]);
-				range[2] = max(newpts[2], range[2]);
-				range[3] = max(newpts[3], range[3]);
+				range[0] = MIN(newpts[0], range[0]);
+				range[1] = MIN(newpts[1], range[1]);
+				range[2] = MAX(newpts[2], range[2]);
+				range[3] = MAX(newpts[3], range[3]);
 			}
 		}
 	}
                 x1 = x2; x2 = temp;
 	}
 
-	x1 = max(x1, surf->clip_rect.x);
-	x2 = min(x2, surf->clip_rect.x + surf->clip_rect.w-1);
+	x1 = MAX(x1, surf->clip_rect.x);
+	x2 = MIN(x2, surf->clip_rect.x + surf->clip_rect.w-1);
 
         if(x2 < surf->clip_rect.x || x1 >= surf->clip_rect.x + surf->clip_rect.w)
                 return;
 		int temp = y1;
 		y1 = y2; y2 = temp;
 	}
-	y1 = max(y1, surf->clip_rect.y);
-	y2 = min(y2, surf->clip_rect.y + surf->clip_rect.h-1);
+	y1 = MAX(y1, surf->clip_rect.y);
+	y2 = MIN(y2, surf->clip_rect.y + surf->clip_rect.h-1);
 	if(y2 - y1 < 1)
 		set_at( surf, x1, y1, color);
 	else
 	maxy = vy[0];
 	for (i=1; (i < n); i++)
 	{
-		miny = min(miny, vy[i]);
-		maxy = max(maxy, vy[i]);
+		miny = MIN(miny, vy[i]);
+		maxy = MAX(maxy, vy[i]);
 	}
 
 	/* Draw, scanning y */

File src/event.c

View file
  • Ignore whitespace
 	else
 		SDL_WM_GrabInput(SDL_GRAB_OFF);
 
-	RETURN_NONE;
+	Py_RETURN_NONE;;
 }
 
 
 
 	SDL_PumpEvents();
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, mask) == 1)
 	{}
 
-	RETURN_NONE;
+	Py_RETURN_NONE;;
 }
 
 
 	if(SDL_PushEvent(&event) == -1)
 		return RAISE(PyExc_SDLError, "Event queue full");
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	else
 		return RAISE(PyExc_TypeError, "type must be numeric or a sequence");
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	else
 		return RAISE(PyExc_TypeError, "type must be numeric or a sequence");
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/fastevent.c

View file
  • Ignore whitespace
 		FE_WasInit = 1;
 	}
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 #endif /* WITH_THREAD */
 }
 
 
 	FE_PumpEvents();
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if (status != 1)
 		return RAISE(PyExc_SDLError, "Unexpected error in FE_PushEvent");
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/font.c

View file
  • Ignore whitespace
 
 	font_autoquit();
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(!istrue)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		style &= ~TTF_STYLE_BOLD;
 	TTF_SetFontStyle(font, style);
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		style &= ~TTF_STYLE_ITALIC;
 	TTF_SetFontStyle(font, style);
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		style &= ~TTF_STYLE_UNDERLINE;
 	TTF_SetFontStyle(font, style);
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/image.c

View file
  • Ignore whitespace
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/imageext.c

View file
  • Ignore whitespace
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-
-	RETURN_NONE
-
-
+	Py_RETURN_NONE;
 }
 
 

File src/joystick.c

View file
  • Ignore whitespace
 
 	joy_autoquit();
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(!istrue)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		if(!joystick_stickdata[joy_id])
 			return RAISE(PyExc_SDLError, SDL_GetError());
 	}
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		SDL_JoystickClose(joystick_stickdata[joy_id]);
 		joystick_stickdata[joy_id] = NULL;
 	}
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/key.c

View file
  • Ignore whitespace
 	if(SDL_EnableKeyRepeat(delay, interval) == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	VIDEO_INIT_CHECK();
 
 	SDL_SetModState(mods);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/mixer.c

View file
  • Ignore whitespace
 
 	/*make chunk a power of 2*/
 	for(i=0; 1<<i < chunk; ++i); //yes, semicolon on for loop
-	chunk = max(1<<i, 256);
+	chunk = MAX(1<<i, 256);
 
 	if(!SDL_WasInit(SDL_INIT_AUDIO))
 	{
 
 	autoquit();
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(!value)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		return NULL;
 
 	if(!SDL_WasInit(SDL_INIT_AUDIO))
-		RETURN_NONE
+            Py_RETURN_NONE;
 
 	if(!Mix_QuerySpec(&freq, &format, &channels))
-		RETURN_NONE
+            Py_RETURN_NONE;
 
 	//create a signed or unsigned number of bits per sample
 	realform = format&~0xff ? -(format&0xff) : format&0xff;
 				&request_stereo, &request_chunksize))
 		return NULL;
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 
 	channelnum = Mix_PlayChannelTimed(-1, chunk, loops, playtime);
 	if(channelnum == -1)
-		RETURN_NONE
+            Py_RETURN_NONE;
 
         Py_XDECREF(channeldata[channelnum].sound);
 	Py_XDECREF(channeldata[channelnum].queue);
 	MIXER_INIT_CHECK();
 
 	Mix_FadeOutGroup((intptr_t)chunk, time);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_HaltGroup((intptr_t)chunk);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_VolumeChunk(chunk, (int)(volume*128));
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	channeldata[channelnum].queue = NULL;
         Py_INCREF(sound);
 
-
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	    Py_INCREF(sound);
 	}
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_FadeOutChannel(channelnum, time);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_HaltChannel(channelnum);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_Pause(channelnum);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_Resume(channelnum);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 
 	result = Mix_Volume(channelnum, (int)(volume*128));
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 
 	sound = channeldata[channelnum].sound;
 	if(!sound)
-	    RETURN_NONE
+	    Py_RETURN_NONE;
 
 	Py_INCREF(sound);
 	return sound;
 
 	sound = channeldata[channelnum].queue;
 	if(!sound)
-	    RETURN_NONE
+	    Py_RETURN_NONE;
 
 	Py_INCREF(sound);
 	return sound;
 		return NULL;
 
 	channeldata[channelnum].endevent = event;
-    	RETURN_NONE
+        Py_RETURN_NONE;
 }
 
 
         }
 
 	Mix_AllocateChannels(numchans);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_ReserveChannels(numchans);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(chan == -1)
 	{
 		if(!force)
-			RETURN_NONE
+                    Py_RETURN_NONE;
 		chan = Mix_GroupOldest(-1);
 	}
 	return PyChannel_New(chan);
 	MIXER_INIT_CHECK();
 
 	Mix_FadeOutChannel(-1, time);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_HaltChannel(-1);
-	RETURN_NONE
+        Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_Pause(-1);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_Resume(-1);
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/mouse.c

View file
  • Ignore whitespace
 
 	SDL_WarpMouse((Uint16)x, (Uint16)y);
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	SDL_SetCursor(cursor);
 	SDL_FreeCursor(lastcursor);
 
-	RETURN_NONE;
+	Py_RETURN_NONE;
 
 interror:
 	if(xordata) free(xordata);

File src/movie.c

View file
  • Ignore whitespace
 	SMPEG_loop(movie, loops);
 	SMPEG_play(movie);
         Py_END_ALLOW_THREADS
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
         Py_BEGIN_ALLOW_THREADS
 	SMPEG_stop(movie);
         Py_END_ALLOW_THREADS
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
         Py_BEGIN_ALLOW_THREADS
 	SMPEG_pause(movie);
         Py_END_ALLOW_THREADS
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
         Py_BEGIN_ALLOW_THREADS
 	SMPEG_rewind(movie);
         Py_END_ALLOW_THREADS
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
         Py_BEGIN_ALLOW_THREADS
 	SMPEG_skip(movie, seconds);
         Py_END_ALLOW_THREADS
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	SMPEG_setvolume(movie, volume);
         Py_END_ALLOW_THREADS
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		       return RAISE(PyExc_TypeError, "destination must be a Surface");
 	}
 
-	RETURN_NONE;
+	Py_RETURN_NONE;
 }
 
 

File src/music.c

View file
  • Ignore whitespace
 	if(val == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		Mix_FreeMusic(queue_music);
 		queue_music = NULL;
 	}
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 		Mix_FreeMusic(queue_music);
 		queue_music = NULL;
 	}
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_PauseMusic();
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_ResumeMusic();
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_RewindMusic();
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	MIXER_INIT_CHECK();
 
 	Mix_VolumeMusic((int)(volume*128));
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
 	if(!PyArg_ParseTuple(args, "|i", &eventid))
 		return NULL;
 	endmusic_event = eventid;
-	RETURN_NONE;
+	Py_RETURN_NONE;;
 }
 
 
 	}
 
 
-	RETURN_NONE;
+	Py_RETURN_NONE;;
 }
 
 
 		queue_music = NULL;
 	}
 	queue_music = new_music;
-    	RETURN_NONE
+    	Py_RETURN_NONE;
 }
 
 

File src/overlay.c

View file
  • Ignore whitespace
         self->cRect.w = rect->w;
         self->cRect.h = rect->h;
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 
     cRect.h = self->cRect.h;
     SDL_DisplayYUVOverlay(self->cOverlay, &cRect);
 
-	RETURN_NONE
+	Py_RETURN_NONE;
 }
 
 

File src/pygame.h

View file
  • Ignore whitespace
     pete@shinners.org
 */
 
-	/** This header file includes all the definitions for the
-	 ** base pygame extensions. This header only requires
-	 ** SDL and Python includes. The reason for functions
-	 ** prototyped with #define's is to allow for maximum
-	 ** python portability. It also uses python as the
-	 ** runtime linker, which allows for late binding. For more
-	 ** information on this style of development, read the Python
-	 ** docs on this subject.
-	 ** http://www.python.org/doc/current/ext/using-cobjects.html
-	 **
-	 ** If using this to build your own derived extensions,
-	 ** you'll see that the functions available here are mainly
-	 ** used to help convert between python objects and SDL objects.
-	 ** Since this library doesn't add a lot of functionality to
-	 ** the SDL libarary, it doesn't need to offer a lot either.
-	 **
-	 ** When initializing your extension module, you must manually
-	 ** import the modules you want to use. (this is the part about
-	 ** using python as the runtime linker). Each module has its
-	 ** own import_xxx() routine. You need to perform this import
-	 ** after you have initialized your own module, and before
-	 ** you call any routines from that module. Since every module
-	 ** in pygame does this, there are plenty of examples.
-	 **
-	 ** The base module does include some useful conversion routines
-	 ** that you are free to use in your own extension.
-	 **
-	 ** When making changes, it is very important to keep the
-	 ** FIRSTSLOT and NUMSLOT constants up to date for each
-	 ** section. Also be sure not to overlap any of the slots.
-	 ** When you do make a mistake with this, it will result
-	 ** is a dereferenced NULL pointer that is easier to diagnose
-	 ** than it could be :]
-	 **/
+/** This header file includes all the definitions for the
+ ** base pygame extensions. This header only requires
+ ** SDL and Python includes. The reason for functions
+ ** prototyped with #define's is to allow for maximum
+ ** python portability. It also uses python as the
+ ** runtime linker, which allows for late binding. For more
+ ** information on this style of development, read the Python
+ ** docs on this subject.
+ ** http://www.python.org/doc/current/ext/using-cobjects.html
+ **
+ ** If using this to build your own derived extensions,
+ ** you'll see that the functions available here are mainly
+ ** used to help convert between python objects and SDL objects.
+ ** Since this library doesn't add a lot of functionality to
+ ** the SDL libarary, it doesn't need to offer a lot either.
+ **
+ ** When initializing your extension module, you must manually
+ ** import the modules you want to use. (this is the part about
+ ** using python as the runtime linker). Each module has its
+ ** own import_xxx() routine. You need to perform this import
+ ** after you have initialized your own module, and before
+ ** you call any routines from that module. Since every module
+ ** in pygame does this, there are plenty of examples.
+ **
+ ** The base module does include some useful conversion routines
+ ** that you are free to use in your own extension.
+ **
+ ** When making changes, it is very important to keep the
+ ** FIRSTSLOT and NUMSLOT constants up to date for each
+ ** section. Also be sure not to overlap any of the slots.
+ ** When you do make a mistake with this, it will result
+ ** is a dereferenced NULL pointer that is easier to diagnose
+ ** than it could be :]
+ **/
 #include <Python.h>
 
 #ifdef MS_WIN32 /*Python gives us MS_WIN32, SDL needs just WIN32*/
 
 #include <SDL.h>
 
-
-
 /* macros used throughout the source */
 #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
-#define RETURN_NONE return (Py_INCREF(Py_None), Py_None);
+
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF (Py_None), Py_None
+#endif
+
 #define PyType_Init(x) (((x).ob_type) = &PyType_Type)
 #define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"
-#ifndef min
-#define min(a,b) ((a)<=(b)?(a):(b))
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
-#ifndef max
-#define max(a,b) ((a)>=(b)?(a):(b))
+
+#ifndef MAX
+#define MAX(a,b) ( (a) > (b) ? (a) : (b))
 #endif
 
 /* test sdl initializations */
-#define VIDEO_INIT_CHECK() \
-	if(!SDL_WasInit(SDL_INIT_VIDEO)) \
-		return RAISE(PyExc_SDLError, "video system not initialized")
-#define CDROM_INIT_CHECK() \
-	if(!SDL_WasInit(SDL_INIT_CDROM)) \
-		return RAISE(PyExc_SDLError, "cdrom system not initialized")
-#define JOYSTICK_INIT_CHECK() \
-	if(!SDL_WasInit(SDL_INIT_JOYSTICK)) \
-		return RAISE(PyExc_SDLError, "joystick system not initialized")
+#define VIDEO_INIT_CHECK()                                              \
+    if(!SDL_WasInit(SDL_INIT_VIDEO))                                    \
+        return RAISE(PyExc_SDLError, "video system not initialized")
 
+#define CDROM_INIT_CHECK()                                              \
+    if(!SDL_WasInit(SDL_INIT_CDROM))                                    \
+        return RAISE(PyExc_SDLError, "cdrom system not initialized")
+
+#define JOYSTICK_INIT_CHECK()                                           \
+    if(!SDL_WasInit(SDL_INIT_JOYSTICK))                                 \
+        return RAISE(PyExc_SDLError, "joystick system not initialized")
 
 /* BASE */
 #define PYGAMEAPI_BASE_FIRSTSLOT 0
 #define PYGAMEAPI_BASE_NUMSLOTS 13
 #ifndef PYGAMEAPI_BASE_INTERNAL
 #define PyExc_SDLError ((PyObject*)PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT])
-#define PyGame_RegisterQuit \
-			(*(void(*)(void(*)(void)))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 1])
-#define IntFromObj \
-			(*(int(*)(PyObject*, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 2])
-#define IntFromObjIndex \
-			(*(int(*)(PyObject*, int, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 3])
-#define TwoIntsFromObj \
-			(*(int(*)(PyObject*, int*, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 4])
-#define FloatFromObj \
-			(*(int(*)(PyObject*, float*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 5])
-#define FloatFromObjIndex \
-			(*(float(*)(PyObject*, int, float*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 6])
-#define TwoFloatsFromObj \
-			(*(int(*)(PyObject*, float*, float*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 7])
-#define UintFromObj \
-			(*(int(*)(PyObject*, Uint32*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 8])
-#define UintFromObjIndex \
-			(*(int(*)(PyObject*, int, Uint32*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 9])
-#define PyGame_Video_AutoQuit \
-			(*(void(*)(void))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 10])
-#define PyGame_Video_AutoInit \
-			(*(int(*)(void))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 11])
-#define RGBAFromObj \
-			(*(int(*)(PyObject*, Uint8*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 12])
-#define import_pygame_base() { \
-	PyObject *module = PyImport_ImportModule("pygame.base"); \
-	if (module != NULL) { \
-		PyObject *dict = PyModule_GetDict(module); \
-		PyObject *c_api = PyDict_GetItemString(dict, PYGAMEAPI_LOCAL_ENTRY); \
-		if(PyCObject_Check(c_api)) {\
-			int i; void** localptr = (void**)PyCObject_AsVoidPtr(c_api); \
-			for(i = 0; i < PYGAMEAPI_BASE_NUMSLOTS; ++i) \
-				PyGAME_C_API[i + PYGAMEAPI_BASE_FIRSTSLOT] = localptr[i]; \
-} Py_DECREF(module); } }
+
+#define PyGame_RegisterQuit                                             \
+    (*(void(*)(void(*)(void)))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 1])
+
+#define IntFromObj                                                      \
+    (*(int(*)(PyObject*, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 2])
+
+#define IntFromObjIndex                                                 \
+    (*(int(*)(PyObject*, int, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 3])
+
+#define TwoIntsFromObj                                                  \
+    (*(int(*)(PyObject*, int*, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 4])
+
+#define FloatFromObj                                                    \
+    (*(int(*)(PyObject*, float*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 5])
+
+#define FloatFromObjIndex                                               \
+    (*(float(*)(PyObject*, int, float*))                                \
+     PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 6])
+
+#define TwoFloatsFromObj                                \
+    (*(int(*)(PyObject*, float*, float*))               \
+     PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 7])
+
+#define UintFromObj                                                     \
+    (*(int(*)(PyObject*, Uint32*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 8])
+
+#define UintFromObjIndex                                                \
+    (*(int(*)(PyObject*, int, Uint32*))                                 \
+     PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 9])
+
+#define PyGame_Video_AutoQuit                                           \
+    (*(void(*)(void))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 10])
+
+#define PyGame_Video_AutoInit                                           \
+    (*(int(*)(void))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 11])
+
+#define RGBAFromObj                                                     \
+    (*(int(*)(PyObject*, Uint8*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 12])
+
+#define import_pygame_base() {                                          \
+	PyObject *module = PyImport_ImportModule("pygame.base");        \
+	if (module != NULL) {                                           \
+            PyObject *dict = PyModule_GetDict(module);                  \
+            PyObject *c_api = PyDict_GetItemString(dict,                \
+                                                   PYGAMEAPI_LOCAL_ENTRY); \