1. pygame
  2. Untitled project
  3. pygame

Commits

marcus  committed 57a302e

Added IS_XXX define to determine the platform at compile time-
Added more module faq entries.
Added first sdlgfx documentation.
Added missing sdl.rwops imports where necessary.
Changed multiple methods and classes to make use of PointFromObject() and
SizeFromObject().
Fixed sdlgfx.constants module entries.
Fixed sdl.image.save_bmp() method to make use of file objects and file
names the right way.

  • Participants
  • Parent commits ecba0b4
  • Branches pgreloaded

Comments (0)

Files changed (34)

File TODO.txt

View file
 * reorganise and add camera module
 * add portmidi wrapper.
 * Subsurfaces via surface[x:y,a:b]? Brought up by ctgPi via IRC
+* add filledPieColor wrapper for sdlgfx.primitives
+* add characterXXX wrappers for sdlgdfx
 
 Things to FIX:
 ==============
 * get rid of os.system() output under msys (2>/dev/null does not seem to work)
 * correct argument checks in pyg_scrap* functions
 * check for clipboard resource destruction within pygame.sdlext.scrap.
+* uniform method and argument layout (see sdlext.draw and sdlgfx.primitives
+  how not to do it)
 * SDL_gfx has to set the correct errors (SDL_SetError()). Fix that and
   merge it back to the SDL_gfx upstream
+* all methods taking or returning angles as arguments should use degrees, not
+  radians - an implicit conversion (DEG2RAD/RAD2DEG) will be done
 
 Things to WRAP:
 ===============

File doc/MODULES.txt

View file
 Make sure, you load the correct modules within the module initialization
 function. Take a look at the src/mask/maskmod.c module file for an example.
 
+Build environment dependencies
+------------------------------
+If it is necessary to rely on certain features specific to a particular
+environment, you can check for the build system flags, which are automatically
+added at compile time. Currently, the following flags are available:
+
+  IS_WIN32      - Win32 build with Visual C++
+  IS_MSYS       - (Win32) Msys build with GCC
+  IS_UNIX       - Any other build plattform that successfully passes the
+                  preparations
+
+You can easily check for those flags in the C code using the usualy preprocessor
+magic:
+
+#ifdef IS_WIN32 
+  /* Visual C++ specific Win32 instructions */
+#elif defined(IS_MSYS)
+  /* GCC/Msys specific Win32 instructions */
+#elif defined(IS_UNIX)
+ /* Unix specific instructions */
+#endif
+
 Python modules
 --------------
 Python modules have no special restriction, but should follow the

File doc/MODULE_FAQ.txt

View file
 developer's life. In order to have a similar behaviour without
 implementing the same things again and again, those will be listed here.
 
+If it is necessary to rely on certain features specific to a particular
+environment, you can check for the build system flags, which are automatically
+added at compile time. Currently, the following flags and macros are available:
+
+  IS_WIN32      - Win32 build with Visual C++
+  IS_MSYS       - (Win32) Msys build with GCC
+  IS_UNIX       - Any other build plattform that successfully passes the
+                  preparations
+
 base/pgdefines.h contains some useful numeric macros:
 
   MIN(x,y)       - returns the minimum of two values
 or floating point value from a PyObject. Those however require other
 modules to import the base module.
 
+* Text handling *
+
+For text guaranteed to be UTF-8 or ASCII, use the related Text_***() macros
+instead of the specific PyUnicode/PyString APIs. The Text_***() macros assure
+that for each Python version the current API is used.
+For other objects that contain text (but not necessarily UTF-8 or ASCII), use 
+the UTF8FromObject() and ASCIIFromObject() conversion functions.
+
+* Sizes and points *
+
+Whereever typical two-value tuples for denoting points or sizes are necessary
+or used, use the [F]PointFromObject() and [F]SizeFromObject() functions from 
+base/pgbase.h. Those guarantee interoperability with rectangular arguments,
+tuples, lists and any other sequence and take care of the most basic value
+checks.
+
 * SDL Rectangles *
 
 sdl/pgsdl.h defines some handy routines to quickly get a SDL_Rect from

File doc/src/sdlextdraw.xml

View file
       Draws an anti-aliased line on a surface. If blend is true, the shades
       will be be blended with existing pixel shades instead of overwriting them.
       
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
       surface. If blend is true, the shades will be be blended with
       existing pixel shades instead of overwriting them.
 
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
   <func name="aapolygon">
     <call>aapolygon (surface, color, ((x1, y2), (x2, y2), ...) [, blend]) -> Rect</call>
-    <desc>Draws a anti-aliased polygonal shape on a surface.
+    <desc>Draws an anti-aliased polygonal shape on a surface.
     
-      Draws a polygonal shape on a surface with an fixed line width of 1px. If
+      Draws an polygonal shape on a surface with an fixed line width of 1px. If
       blend is true, the shades will be be blended with existing pixel shades
       instead of overwriting them.
       
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
       the width is set to 0, a filled shape will be drawn. The startangle and
       stopangle arguments are the initial and final angle in degrees.
       
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
       the width is set to 0, a filled circular shape will be drawn. The (x, y)
       tuple denotes the center of the circle.
       
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
       Draws an elliptical shape on a surface with an optionally specified line
       width. If the width argument is omitted, the line will be 1px thick. If
       the width is set to 0, a filled elliptical shape will be drawn.
-      The passed :class:`pygame.Rect` denotes the area, the elliptical shape
+      The passed :class:`pygame2.Rect` denotes the area, the elliptical shape
       will be drawn in.
       
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
       line width. If the width argument is omitted, the line will be 1px thick.
       There are no endcaps, the ends are squared off for thick lines.
       
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
       Draws a sequence of lines on a surface with an optionally specified line
       width. If the width argument is omitted, the lines will be 1px thick.
 
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
       width. If the width argument is omitted, the line will be 1px thick. If
       the width is set to 0, a filled polygon will be drawn.
       
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>
       width. If the width argument is omitted, the line will be 1px thick. If
       the width is set to 0, a filled rectangular shape will be drawn.
 
-      The returned :class:`pygame.Rect` describes the area affected by the
+      The returned :class:`pygame2.Rect` describes the area affected by the
       changes.
     </desc>
   </func>

File doc/src/sdlgfxbase.xml

View file
 
 <module name="pygame2.sdlgfx.base">
   <short>basic SDL_gfx wrapper module</short>
-  <desc></desc>
+  <desc>Basic SDL_gfx library wrapper module</desc>
 
   <class name="FPSmanager">
-    <constructor>TODO</constructor>
-    <desc></desc>
+    <constructor>FPSManager (framerate) -> FPSManager</constructor>
+    <desc>
+      Creates a new FPSManager using the specified frame rate.
+      
+      The FPSManager takes care of measuring and keeping constant frame rates
+      for the application it is used with. On demand it automatically delays
+      the execution to keep the required frame rate.
+      
+      The desired frame rate must be within the range of constants.FPS_LOWER_LIMIT
+      and constants.FPS_UPPER_LIMIT.
+    </desc>
     <method name="delay">
-      <call></call>
-      <desc></desc>
+      <call>delay () -> None</call>
+      <desc>
+        Delays the execution of the application to keep up the desired frame
+        rate.
+      </desc>
     </method>
-    <attr name="framerate"></attr>
+    <attr name="framerate">Gets or sets the frame rate to keep.</attr>
   </class>
 
   <func name="get_compiled_version">
-    <call></call>
-    <desc></desc>
+    <call>get_compiled_version () -> tuple</call>
+    <desc>
+      Gets the SDL_gfx version pygame2 was compiled against as three-value tuple.
+
+      This version is built at compile time. It can be used to detect
+      which features may not be available through Pygame, if it is used
+      as precompiled package using a different version of the SDL_gfx
+      library.
+    </desc>
   </func>
 </module>
 

File doc/src/sdlgfxprimitives.xml

View file
 
 
 <module name="pygame2.sdlgfx.primitives">
-  <short>SDL_gfx primitives drawing</short>
-  <desc></desc>
+  <short>SDL_gfx primitives drawing module</short>
+  <desc>SDL_gfx primitives drawing module</desc>
 
   <func name="aacircle">
-    <call></call>
-    <desc></desc>
+    <call>aacircle (surface, (x, y), radius, color) -> None</call>
+    <desc>Draws an anti-aliased circular shape on a surface.
+    
+      Draws a anti-aliased circular shape on a surface with a fixed line width
+      of 1px. The (x, y) tuple denotes the center of the circle.
+    </desc>
   </func>
   <func name="aaellipse">
-    <call></call>
-    <desc></desc>
+    <call>aaellipse (surface, (x, y), (rx, ry), color) -> None</call>
+    <desc>Draws an anti-aliased elliptical shape on a surface.
+    
+      Draws an anti-aliased elliptical shape on a surface with a fixed line width
+      of 1px. The (x, y) tuple denotes the center of the ellipse, (rx, ry) the
+      radius for the x- and y-axis.
+    </desc>
   </func>
   <func name="aapolygon">
-    <call></call>
-    <desc></desc>
+    <call>aapolygon (surface, ((x1, y2), (x2, y2), ...), color) -> None</call>
+    <desc>Draws an anti-aliased polygonal shape on a surface.
+    
+      Draws an anti-aliased polygonal shape on a surface with an fixed line
+      width of 1px.
+    </desc>
   </func>
   <func name="aatrigon">
-    <call></call>
-    <desc></desc>
+    <call>aatrigon (surface, (x1, y1), (x2, y2), (x3, y3), color) -> None</call>
+    <desc>Draws an anti-aliased triangular shape on a surface.
+      
+      Draws an anti-aliased triangular shape on a surface with an fixed line
+      width of 1px. The three (x, y) tuples denote the edges of the triangle.
+    </desc>
   </func>
   <func name="arc">
-    <call></call>
-    <desc></desc>
+    <call>arc (surface, (x, y), radius, startangle, stopangle, color) -> None</call>
+    <desc>Draws an elliptical arc on a surface.
+    
+      Draws an elliptical arc on a surface. The startangle and stopangle
+      arguments are the initial and final angle in degrees.
+    </desc>
   </func>
   <func name="bezier">
-    <call></call>
-    <desc></desc>
+    <call>bezier (surface, ((x1, y1), (x2, y2), ...), steps, color) -> None</call>
+    <desc>Draws a bezier curve on a surface.
+      
+      Draws a bezier curve through the given points on a surface. steps denotes
+      the amount of steps to perform for interpolating the curve.
+    </desc>
   </func>
   <func name="box">
-    <call></call>
-    <desc></desc>
+    <call>box (surface, rect, color) -> None</call>
+    <desc>Draws a filled rectangular shape on a surface.
+      
+      Draws a filled rectangular shape on a surface.
+    </desc>
   </func>
   <func name="circle">
-    <call></call>
-    <desc></desc>
+    <call>circle (surface, (x, y), radius, color) -> None</call>
+    <desc>Draws a circular shape on a surface.
+    
+      Draws a circular shape on a surface with a fixed line width
+      of 1px. The (x, y) tuple denotes the center of the circle.
+    </desc>
   </func>
   <func name="ellipse">
-    <call></call>
-    <desc></desc>
+    <call>ellipse (surface, (x, y), (rx, ry), color) -> None</call>
+    <desc>Draws an elliptical shape on a surface.
+    
+      Draws an elliptical shape on a surface with a fixed line width of 1px.
+      The (x, y) tuple denotes the center of the ellipse, (rx, ry) the
+      radius for the x- and y-axis.
+    </desc>
   </func>
   <func name="filled_circle">
-    <call></call>
-    <desc></desc>
+    <call>filled_circle (surface, (x, y), radius, color) -> None</call>
+    <desc>Draws a filled circular shape on a surface.
+    
+      Draws a filled circular shape on a surface. The (x, y) tuple denotes the
+      center of the circle.
+    </desc>
   </func>
   <func name="filled_ellipse">
-    <call></call>
-    <desc></desc>
+    <call>filled_ellipse (surface, (x, y), (rx, ry), color) -> None</call>
+    <desc>Draws a filled elliptical shape on a surface.
+    
+      Draws a filled elliptical shape on a surface. The (x, y) tuple denotes the
+      center of the ellipse, (rx, ry) the radius for the x- and y-axis.
+    </desc>
   </func>
   <func name="filled_polygon">
-    <call></call>
-    <desc></desc>
+    <call>filled_polygon (surface, ((x1, y1), (x2, y2), ...), color) -> None</call>
+    <desc>Draws a filled polygonal shape on a surface.
+    
+      Draws a filled polygonal shape on a surface.
+    </desc>
   </func>
   <func name="filled_trigon">
-    <call></call>
-    <desc></desc>
+    <call>filled_trigon (surface, (x1, y1), (x2, y2), (x3, y3), color) -> None</call>
+    <desc>Draws a filled triangular shape on a surface.
+    
+      Draws a filled triangular shape on a surface. The three (x, y) tuples
+      denote the edges of the triangle.
+    </desc>
   </func>
   <func name="hline">
-    <call></call>
-    <desc></desc>
+    <call>hline (surface, x1, x2, y, color) -> None</call>
+    <desc>Draws a horizontal line on a surface.
+    
+      Draws a horizontal line on a surface with the fixed width of 1 px.
+      x1 and x2 denote the start and end position on the x-axis, y the
+      vertical position of the line on the y-axis.
+    </desc>
   </func>
   <func name="line">
-    <call></call>
-    <desc></desc>
+    <call>line (surface, (x1, y1), (x2, y2), color) -> Nones</call>
+    <desc>Draws a line on a surface.
+    
+      Draws a line on a surface with a fixed width of 1px. The (x, y) tuples 
+      denote the start and end position of the line.
+    </desc>
   </func>
   <func name="pie">
-    <call></call>
-    <desc></desc>
+    <call>pie (surface, (x, y), r, startangle, stopangle) -> None</call>
+    <desc>Draws a pie-like shape on a surface.
+    
+      Draws a pie-like shape on a surface with a fixed width of 1px. The (x, y)
+      tuple denotes the center of the pie segment, startangle and stopangle the
+      initial and final angle in degrees.
+    </desc>
   </func>
   <func name="pixel">
-    <call></call>
-    <desc></desc>
+    <call>pixel (surface, (x, y), color) -> None</call>
+    <desc>Draws a single pixel on a surface.
+      
+      Draws a single pixel on a surface.
+    </desc>
   </func>
   <func name="polygon">
-    <call></call>
-    <desc></desc>
+    <call>polygon (surface, ((x1, y1), (x2, y2), ...), color) -> None</call>
+    <desc>Draws a polygonal shape on a surface.
+    
+      Draws a polygonal shape on a surface.
+    </desc>
   </func>
   <func name="rectangle">
-    <call></call>
-    <desc></desc>
+    <call>rectangle (surface, rect, color) -> None</call>
+    <desc>Draws a rectangular shape on a surface.
+      
+      Draws a rectangular shape on a surface.
+    </desc>
   </func>
   <func name="textured_polygon">
-    <call></call>
-    <desc></desc>
+    <call>textured_polygon (surface, ((x1, y1), (x2, y2), ...), texture, (tx, ty)) -> None</call>
+    <desc>Draws a textured polygonal shape on a surface.
+    
+      Draws a textured polygonal shape on a surface. texture is a
+      :class:`pygame2.sdl.video.Surface` to be used for filling the shape,
+      (tx, ty) are the offset of the texture relative to the screen.
+    </desc>
   </func>
   <func name="trigon">
-    <call></call>
-    <desc></desc>
+    <call>trigon (surface, (x1, y1), (x2, y2), (x3, y3), color) -> None</call>
+    <desc>Draws a triangular shape on a surface.
+    
+      Draws a filled triangular shape on a surface with a fixed line width of
+      1px. The three (x, y) tuples denote the edges of the triangle.
+    </desc>
   </func>
   <func name="vline">
-    <call></call>
-    <desc></desc>
+    <call>vline (surface, x, y1, y2, color) -> None</call>
+    <desc>Draws a vertical line on a surface.
+    
+      Draws a vertical line on a surface with a fixed width of 1px. y1 and y2
+      denote the start and end position on the y-axis, x the horizontal position
+      of the line on the x-axis.
+    </desc>
   </func>
 </module>
 

File doc/src/sdlgfxrotozoom.xml

View file
 
 
 <module name="pygame2.sdlgfx.rotozoom">
-  <short>SDL_gfx rotozoom methods</short>
-  <desc></desc>
+  <short>SDL_gfx rotozoom wrapper module</short>
+  <desc>SDL_gfx rotozoom wrapper module</desc>
 
   <func name="rotate_90">
-    <call></call>
-    <desc></desc>
+    <call>rotate_90 (surface, times) -> :class:`pygame2.sdl.video.Surface`</call>
+    <desc>Rotates a surface clockwise by 90 degrees.
+      
+      Rotates the passed surface clockwise by 90 degrees and returns a new
+      :class:`pygame2.sdl.video.Surface` with the rotated result.
+      times denotes the amount of rotations to perform.
+    </desc>
   </func>
   <func name="rotozoom">
-    <call></call>
-    <desc></desc>
+    <call>rotozoom (surface, angle, zoom[, smooth]) -> :class:`pygame2.sdl.video.Surface`</call>
+    <desc>Rotates and zooms a surface.
+    
+      Rotates and zooms a surface at the same time and returns a new
+      :class:`pygame2.sdl.video.Surface` with the result. angle is the rotation
+      angle in degrees, zoom the zoom factor. The optional smooth argument is
+      used for smoothing the edges and pixels of the returned surface.
+    </desc>
   </func>
   <func name="rotozoom_size">
-    <call></call>
-    <desc></desc>
+    <call>rotozoom_size (width, height, angle, zoom) -> int, int
+          rotozoom_size (surface, angle, zoom) -> int, int
+    </call>
+    <desc>Calculates the resulting surface size for a rotozoom operation.
+      
+      Calculates the size of the resulting surface, if a rotozoom operation
+      takes place on a specific :class:`pygame2.sdl.video.Surface`.
+    </desc>
   </func>
   <func name="rotozoom_size_xy">
-    <call></call>
-    <desc></desc>
+    <call>rotozoom_size_xy (width, height, angle, zoomx, zoomy) -> int, int
+          rotozoom_size_xy (surface, angle, zoomx, zoomy) -> int, int
+    </call>
+    <desc>Calculates the resulting surface size for a rotozoom operation.
+      
+      Calculates the size of the resulting surface, if a rotozoom operation
+      takes place on a specific :class:`pygame2.sdl.video.Surface`.
+    </desc>
   </func>
   <func name="rotozoom_xy">
-    <call></call>
-    <desc></desc>
+    <call>rotozoom_xy (surface, angle, zoomx, zoomy[, smooth]) -> :class:`pygame2.sdl.video.Surface`</call>
+    <desc>Rotates and zooms a surface with different scaling factors for the x- and y- axes.
+    
+      Rotates and zooms a surface at the same time and returns a new
+      :class:`pygame2.sdl.video.Surface` with the result. angle is the rotation
+      angle in degrees, zoomx and zoomy the zoom factors for the x- and y-axis.
+      The optional smooth argument is used for smoothing the edges and pixels
+      of the returned surface.
+    </desc>
   </func>
   <func name="shrink">
-    <call></call>
-    <desc></desc>
+    <call>zoom (surface, shrinkx, shrinky) -> :class:`pygame2.sdl.video.Surface`</call>
+    <desc>Shrinks a surface.
+      
+      Shrinks a surface and returns new :class:`pygame2.sdl.video.Surface` with
+      the result. shrinkx and shrinky are the shrink factors for the x- and
+      y-axis.
+    </desc>
   </func>
   <func name="zoom">
-    <call></call>
-    <desc></desc>
+    <call>zoom (surface, zoomx, zoomy[, smooth]) -> :class:`pygame2.sdl.video.Surface`</call>
+    <desc>Zooms a surface.
+    
+      Zooms a surface an returns a new :class:`pygame2.sdl.video.Surface` with
+      the result. zoomx and zoomy are the zoom factors for the x- and y-axis.
+      The optional smooth argument is used for smoothing the edges and pixels
+      of the returned surface.
+    </desc>
   </func>
   <func name="zoom_size">
-    <call></call>
-    <desc></desc>
+    <call>zoom_size (width, height, angle, zoom) -> int, int
+          zoom_size (surface, angle, zoom) -> int, int
+    </call>
+    <desc>Calculates the resulting surface size for a zoom operation.
+      
+      Calculates the size of the resulting surface, if a zoom operation
+      takes place on a specific :class:`pygame2.sdl.video.Surface`.
+    </desc>
   </func>
 </module>
 

File doc/src/sdlimage.xml

View file
 
 <module name="pygame2.sdl.image">
   <short>SDL image I/O wrapper module</short>
-  <desc>None</desc>
+  <desc>SDL image I/O wrapper module</desc>
 
   <func name="load_bmp">
-    <call></call>
-    <desc></desc>
+    <call>load_bmp (file) -> :class:`pygame2.sdl.video.Surface`</call>
+    <desc>Loads a BMP file and creates a :class:`pygame2.sdl.video.Surface` from it.
+    
+      Loads a BMP file and creates a :class:`pygame2.sdl.video.Surface` from it.
+      The file argument can be either a file object or the filename.
+    </desc>
   </func>
   <func name="save_bmp">
-    <call></call>
-    <desc></desc>
+    <call>save_bmp (surface, file) -> None</call>
+    <desc>Saves a surface to a bitmap file.
+
+      Saves a :class:`pygame2.sdl.video.Surface` to the specified file, where
+      file can be a filename or file object.
+    </desc>
   </func>
 </module>
 

File doc/src/sdlimagebase.xml

View file
 
 <module name="pygame2.sdlimage.base">
   <short>basic SDL_image wrapper module</short>
-  <desc>TODO</desc>
+  <desc>basic SDL_image wrapper module</desc>
 
   <func name="get_error">
-    <call></call>
-    <desc></desc>
+    <call>get_error () -> pygame2.Error</call>
+    <desc>
+      Gets the last :exc:`pygame2.base.Error` occured.
+
+      SDL_image maintains an internal error message. This message will usually
+      be given to you when a :exc:`pygame2.base.Error` is raised. You will rarely
+      need to call this function.
+    </desc>
   </func>
   <func name="load">
-    <call></call>
-    <desc></desc>
+    <call>load (file[, type]) -> :class:`pygame2.sdl.video.Surface`</call>
+    <desc>Loads an image file and creates a :class:`pygame2.sdl.video.Surface` from it.
+    
+      Loads an image file and creates a :class:`pygame2.sdl.video.Surface` from
+      it. The file argument can be a file object or filename. type is an
+      optional argument indicating the image type as string.
+    </desc>
   </func>
   <func name="read_xpm_from_array">
-    <call></call>
-    <desc></desc>
+    <call>read_xpm_from_array (buffer) -> :class:`pygame2.sdl.video.Surface`</call>
+    <desc>Creates a :class:`pygame2.sdl.video.Surface` from a XPM buffer.
+    
+      Creates a :class:`pygame2.sdl.video.Surface` from a XPM buffer. The
+      buffer can be any type that can be used as character buffer.
+    </desc>
   </func>
 </module>
 

File setup.py

View file
                          "installed." % PYTHON_MINIMUM)
 
     buildsystem = None
+    buildcflags = None
     if sys.platform == "win32":
         if msys.is_msys ():
             buildsystem = "msys"
+            buildcflags = "-DIS_MSYS"
         else:
             buildsystem = "win"
+            buildcflags = "-DIS_WIN32"
     else:
         buildsystem = "unix"
+        buildcflags = "-DIS_UNIX"
 
     if cfg.WITH_SDL:
         sdlversion = config_modules.sdl_get_version (buildsystem)
     print ("\t Python: %d.%d.%d" % helpers.getversion ())
     if cfg.WITH_SDL:
         print ("\t SDL:    %s" % sdlversion)
-    return buildsystem
+    return buildsystem, buildcflags
 
 if __name__ == "__main__":
 
     buildsystem = None
+    buildcflags = None
     try:
-        buildsystem = run_checks ()
+        buildsystem, buildcflags = run_checks ()
     except:
         print (helpers.geterror ())
         sys.exit (1)
     headerfiles = []
     print ("The following modules will be built:")
     for ext in ext_modules:
+        ext.extra_compile_args.append (buildcflags)
         headerfiles += ext.basemodule.installheaders
         print ("\t%s" % ext.name)
 

File src/base/floatrect.c

View file
 _frect_setcenter (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError, "center must be a 2-value sequence");
+    if (!FPointFromObject (value, &x, &y))
         return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
-        return -1;
-
+    
     ((PyFRect*)self)->x = DBL_SUB_LIMIT (x, (((PyFRect*)self)->w / 2));
     ((PyFRect*)self)->y = DBL_SUB_LIMIT (y, (((PyFRect*)self)->h / 2));
     return 0;
 {
     double w, h;
 
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError, "size must be a 2-value sequence");
-        return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &w))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &h))
+    if (!FSizeFromObject (value, &w, &h))
         return -1;
 
     if (w < 0 || h < 0)
 _frect_setmidtop (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError, "midtop must be a 2-value sequence");
-        return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
+    if (!FPointFromObject (value, &x, &y))
         return -1;
 
     ((PyFRect*)self)->x = DBL_SUB_LIMIT (x, (((PyFRect*)self)->w / 2));
 _frect_setmidleft (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "midleft must be a 2-value sequence");
-        return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
+    if (!FPointFromObject (value, &x, &y))
         return -1;
 
     ((PyFRect*)self)->x = x;
 _frect_setmidbottom (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "midbottom must be a 2-value sequence");
+    if (!FPointFromObject (value, &x, &y))
         return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
-        return -1;
-
+    
     ((PyFRect*)self)->x = DBL_SUB_LIMIT (x, (((PyFRect*)self)->w / 2));
     ((PyFRect*)self)->y = DBL_SUB_LIMIT (y, ((PyFRect*)self)->h);
     return 0;
 _frect_setmidright (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "midright must be a 2-value sequence");
-        return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
+    if (!FPointFromObject (value, &x, &y))
         return -1;
 
     ((PyFRect*)self)->x = DBL_SUB_LIMIT (x, ((PyFRect*)self)->w);
 _frect_settopleft (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "topleft must be a 2-value sequence");
-        return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
+    if (!FPointFromObject (value, &x, &y))
         return -1;
 
     ((PyFRect*)self)->x = x;
 _frect_settopright (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "topright must be a 2-value sequence");
-        return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
+    if (!FPointFromObject (value, &x, &y))
         return -1;
 
     ((PyFRect*)self)->x = DBL_SUB_LIMIT (x, ((PyFRect*)self)->w);
 _frect_setbottomleft (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "bottomleft must be a 2-value sequence");
-        return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
+    if (!FPointFromObject (value, &x, &y))
         return -1;
 
     ((PyFRect*)self)->x = x;
 _frect_setbottomright (PyObject *self, PyObject *value, void *closure)
 {
     double x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "bottomleft must be a 2-value sequence");
-        return -1;
-    }
-    if (!DoubleFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!DoubleFromSeqIndex (value, 1, &y))
+    if (!FPointFromObject (value, &x, &y))
         return -1;
 
     ((PyFRect*)self)->x = DBL_SUB_LIMIT (x, ((PyFRect*)self)->w);

File src/base/rect.c

View file
             }
             else
             {
-                if (!PointFromObject (pt, &x, &y))
+                if (!PointFromObject (pt, (int*)&x, (int*)&y))
                     return -1;
                 if (!SizeFromObject (rect, &w, &h))
                     return -1;
 _rect_setcenter (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError, "center must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     INT16_SUB_UINT16_LIMIT (x, (((PyRect*)self)->w >> 1), ((PyRect*)self)->x);
 {
     pguint16 w, h;
 
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError, "size must be a 2-value sequence");
-        return -1;
-    }
-    if (!UintFromSeqIndex (value, 0, &w))
-        return -1;
-    if (!UintFromSeqIndex (value, 1, &h))
+    if (!SizeFromObject (value, (pgint32*)&w, (pgint32*)&h))
         return -1;
 
     ((PyRect*)self)->w = w;
 _rect_setmidtop (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError, "midtop must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     INT16_SUB_UINT16_LIMIT (x, (((PyRect*)self)->w >> 1), ((PyRect*)self)->x);
 _rect_setmidleft (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "midleft must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     ((PyRect*)self)->x = x;
 _rect_setmidbottom (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "midbottom must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     INT16_SUB_UINT16_LIMIT (x, (((PyRect*)self)->w >> 1), ((PyRect*)self)->x);
 _rect_setmidright (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "midright must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     INT16_SUB_UINT16_LIMIT (x, ((PyRect*)self)->w, ((PyRect*)self)->x);
 _rect_settopleft (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "topleft must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     ((PyRect*)self)->x = x;
 _rect_settopright (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "topright must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     INT16_SUB_UINT16_LIMIT (x, ((PyRect*)self)->w, ((PyRect*)self)->x);
 _rect_setbottomleft (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "bottomleft must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     ((PyRect*)self)->x = x;
 _rect_setbottomright (PyObject *self, PyObject *value, void *closure)
 {
     pgint16 x, y;
-    if (!PySequence_Check (value) || PySequence_Size (value) != 2)
-    {
-        PyErr_SetString (PyExc_ValueError,
-            "bottomleft must be a 2-value sequence");
-        return -1;
-    }
-    if (!IntFromSeqIndex (value, 0, &x))
-        return -1;
-    if (!IntFromSeqIndex (value, 1, &y))
+    if (!PointFromObject (value, (int*)&x, (int*)&y))
         return -1;
 
     INT16_SUB_UINT16_LIMIT (x, ((PyRect*)self)->w, ((PyRect*)self)->x);

File src/mask/mask.c

View file
     bitmask_t *m;
 
     if (!PyArg_ParseTuple (args, "ii", &w, &h))
-        return -1;
-
+    {
+        PyObject *size;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O", &size))
+            return -1;
+        if (!SizeFromObject (size, (pgint32*)&w, (pgint32*)&h))
+            return -1;
+    }
     if (w <= 0 || h <= 0)
     {
         PyErr_SetString (PyExc_ValueError,
     int x, y, val;
 
     if (!PyArg_ParseTuple (args, "ii", &x, &y))
-        return NULL;
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O", &pt))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
 
     if (x >= 0 && x < mask->w && y >= 0 && y < mask->h)
     {
     int x, y, value = 1;
 
     if (!PyArg_ParseTuple (args, "ii|i", &x, &y, &value))
-        return NULL;
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O|i", &pt, &value))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
 
     if (x >= 0 && x < mask->w && y >= 0 && y < mask->h)
     {
     int x, y, val;
     int xp,yp;
 
-    if (!PyArg_ParseTuple (args, "O!(ii)", &PyMask_Type, &maskobj, &x, &y))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "O!ii", &PyMask_Type, &maskobj, &x, &y))
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O!O", &PyMask_Type, &maskobj, &pt))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
+
     othermask = PyMask_AsBitmask(maskobj);
 
     val = bitmask_overlap_pos (mask, othermask, x, y, &xp, &yp);
     PyObject *maskobj;
     int x, y, val;
 
-    if (!PyArg_ParseTuple (args, "O!(ii)", &PyMask_Type, &maskobj, &x, &y))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "O!ii", &PyMask_Type, &maskobj, &x, &y))
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O!O", &PyMask_Type, &maskobj, &pt))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
 
     othermask = PyMask_AsBitmask (maskobj);
 
     PyObject *maskobj;
     PyMask *maskobj2;
 
-    if (!PyArg_ParseTuple (args, "O!(ii)", &PyMask_Type, &maskobj, &x, &y))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "O!ii", &PyMask_Type, &maskobj, &x, &y))
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O!O", &PyMask_Type, &maskobj, &pt))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
 
     output = bitmask_create (mask->w, mask->h);
     if (!output)
     bitmask_t *output;
     PyMask *maskobj;
     
-    if (!PyArg_ParseTuple (args, "(ii)", &x, &y))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "ii", &x, &y))
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O", &pt))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
 
     maskobj = (PyMask*)PyMask_Type.tp_new (&PyMask_Type, NULL, NULL);
     maskobj->mask = NULL;
     PyObject *maskobj;
     int x, y;
 
-    if (!PyArg_ParseTuple (args, "O!(ii)", &PyMask_Type, &maskobj, &x, &y))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "O!ii", &PyMask_Type, &maskobj, &x, &y))
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O!O", &PyMask_Type, &maskobj, &pt))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
 
     othermask = PyMask_AsBitmask (maskobj);
     bitmask_draw(mask, othermask, x, y);
     PyObject *maskobj;
     int x, y;
 
-    if (!PyArg_ParseTuple (args, "O!(ii)", &PyMask_Type, &maskobj, &x, &y))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "O!ii", &PyMask_Type, &maskobj, &x, &y))
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "O!O", &PyMask_Type, &maskobj, &pt))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
     
     othermask = PyMask_AsBitmask(maskobj);
     bitmask_erase (mask, othermask, x, y);
     y = x = -1;
 
     if (!PyArg_ParseTuple (args, "|ii", &x, &y))
-        return NULL;
+    {
+        PyObject *pt;
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "|O", &pt))
+            return NULL;
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
     
     output = bitmask_create (input->w, input->h);
     if (!output)

File src/mask/maskmod.c

View file
     if (c_api_obj)
         PyModule_AddObject (mod, PYGAME_MASK_ENTRY, c_api_obj);
 
-    import_pygame2_base ();
+    if (import_pygame2_base () < 0)
+        goto fail;
 
 #ifdef HAVE_PYGAME_SDL_VIDEO
     if (import_pygame2_sdl_base () < 0)

File src/sdl/cursor.c

View file
     PyObject *databuf, *maskbuf;
     SDL_Cursor *cursor;
 
+    /* Cursor (buf, mask, w, h, x, y) */
     if (!PyArg_ParseTuple (args, "OOii|ii", &databuf, &maskbuf, &w, &h, 
             &hotx, &hoty))
-        return -1;
+    {
+        PyObject *size, *pt;
+        PyErr_Clear ();
+        
+        /* Cursor (buf, mask, size, x, y) */
+        if (!PyArg_ParseTuple (args, "OOO|ii", &databuf, &maskbuf, &size, 
+            &hotx, &hoty))
+        {
+            PyErr_Clear ();
+            /* Cursor (buf, mask, size, pt) */
+            if (!PyArg_ParseTuple (args, "OOO|O", &databuf, &maskbuf, &size,
+                &pt))
+            if (!SizeFromObject (size, (pgint32*)&w, (pgint32*)&h))
+                return -1;
+            if (!PointFromObject (pt, &hotx, &hoty))
+                return -1;
+        }            
+        else
+        {
+            PyErr_Clear ();
+            /* Cursor (buf, mask, w, h, pt) */
+            if (!PyArg_ParseTuple (args, "OOii|O", &databuf, &maskbuf, &w, &h,
+                &pt))
+                return -1;
+            if (!PointFromObject (pt, &hotx, &hoty))
+                return -1;
+        }
+    }
 
     if (w < 0 || h < 0)
     {

File src/sdl/imagemod.c

View file
 #define PYGAME_SDLIMAGE_INTERNAL
 
 #include "pgsdl.h"
+#include "sdlimage_doc.h"
 
 static PyObject* _sdl_loadbmp (PyObject *self, PyObject *args);
 static PyObject* _sdl_savebmp (PyObject *self, PyObject *args);
 
 static PyMethodDef _image_methods[] = {
-    { "load_bmp", _sdl_loadbmp, METH_VARARGS, "" },
-    { "save_bmp", _sdl_savebmp, METH_VARARGS, "" },
+    { "load_bmp", _sdl_loadbmp, METH_VARARGS, DOC_IMAGE_LOAD_BMP },
+    { "save_bmp", _sdl_savebmp, METH_VARARGS, DOC_IMAGE_SAVE_BMP },
     { NULL, NULL, 0, NULL }
 };
 
 static PyObject*
 _sdl_savebmp (PyObject *self, PyObject *args)
 {
-    PyObject *surface;
+    PyObject *surface, *file;
     char *filename;
     int _stat;
     
-    if (!PyArg_ParseTuple (args, "OO:save_bmp", &surface, &filename))
+    if (!PyArg_ParseTuple (args, "OO:save_bmp", &surface, &file))
         return NULL;
     if (!PySDLSurface_Check (surface))
     {
         return NULL;
     }
 
-    Py_BEGIN_ALLOW_THREADS;
-    _stat = SDL_SaveBMP (((PySDLSurface*)surface)->surface, filename);
-    Py_END_ALLOW_THREADS;
-    
+    if (IsTextObj (file))
+    {
+        PyObject *tmp;
+        if (!UTF8FromObject (file, &filename, &tmp))
+            return NULL;
+
+        Py_BEGIN_ALLOW_THREADS;
+        _stat = SDL_SaveBMP (((PySDLSurface*)surface)->surface, filename);
+        Py_END_ALLOW_THREADS;
+
+        Py_XDECREF (tmp);
+    }
+#ifdef IS_PYTHON_3
+    else if (PyObject_AsFileDescriptor (file) != -1)
+#else
+    else if (PyFile_Check (file))
+#endif
+    {
+        SDL_RWops *rw = RWopsFromPython (file);
+        if (!rw)
+            return NULL;
+
+        Py_BEGIN_ALLOW_THREADS;
+        _stat = SDL_SaveBMP_RW (((PySDLSurface*)surface)->surface, rw, 1);
+        Py_END_ALLOW_THREADS;
+    }
+    else
+    {
+#ifdef IS_PYTHON_3
+        PyErr_Clear (); /* Set by the PyObject_AsFileDescriptor() call */
+#endif
+        PyErr_SetString (PyExc_TypeError, "file must be a string or file");
+        return NULL;
+    }
+
     if (_stat == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
 
 #ifdef IS_PYTHON_3
     static struct PyModuleDef _module = {
-        PyModuleDef_HEAD_INIT, "image", "", -1, _image_methods,
+        PyModuleDef_HEAD_INIT, "image", DOC_IMAGE, -1, _image_methods,
         NULL, NULL, NULL, NULL
     };
     mod = PyModule_Create (&_module);
 #else
-    mod = Py_InitModule3 ("image", _image_methods, "");
+    mod = Py_InitModule3 ("image", _image_methods, DOC_IMAGE);
 #endif
     if (!mod)
         goto fail;
 
     if (import_pygame2_base () < 0)
         goto fail;
+    if (import_pygame2_sdl_rwops () < 0)
+        goto fail;
     if (import_pygame2_sdl_video () < 0)
         goto fail;
     MODINIT_RETURN(mod);

File src/sdl/keyboardmod.c

View file
 
     if (val == Py_None)
         enable = SDL_EnableUNICODE (-1);
-    else if (val == Py_True)
-        enable = SDL_EnableUNICODE (1);
-    else if (val == Py_False)
-        enable = SDL_EnableUNICODE (0);
-    else
+    else 
     {
-        PyErr_SetString (PyExc_ValueError, "enable must be bool or None");
-        return NULL;
-    }
+        enable = PyObject_IsTrue (val);
+        if (enable == -1)
+            return NULL;
+        enable = SDL_EnableUNICODE (enable);
+    }        
     
     if (enable == 1)
         Py_RETURN_TRUE;

File src/sdl/mousemod.c

View file
     ASSERT_VIDEO_SURFACE_SET(NULL);
 
     if (!PyArg_ParseTuple (args, "ii:warp", &x, &y))
-        return NULL;
+    {
+        PyObject *pt;
+        if (!PyArg_ParseTuple (args, "O:warp", &pt))
+            return NULL;
+        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+            return NULL;
+    }
     SDL_WarpMouse (x, y);
     Py_RETURN_NONE;
 }
 
     if (!PyArg_ParseTuple (args, "O:set_visible", &val))
         return NULL;
-
+    
     if (PyBool_Check (val))
     {
         if (val == Py_True)
         state = SDL_ShowCursor (state);
     else
     {
-        PyErr_SetString (PyExc_TypeError, "argument must be a bool");
+        PyErr_SetString (PyExc_TypeError, "argument must be a bool or int");
         return NULL;
     }
 

File src/sdl/overlay.c

View file
     ASSERT_VIDEO_INIT(-1);
     
     if (!PyArg_ParseTuple (args, "Oiil", &surf, &width, &height, &format))
-        return -1;
-
+    {
+        PyObject *size;
+        
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OOl", &surf, &size, &format))
+            return -1;
+        if (!SizeFromObject (size, (pgint32*)&width, (pgint32*)&height))
+            return -1;
+    }
+    
     if (!PySDLSurface_Check (surf))
     {
         PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
     ASSERT_VIDEO_INIT(NULL);
     
     return PyLong_FromUnsignedLong (overlay->format);
-    
 }
 
 static PyObject*
     Py_RETURN_FALSE;
 }
 
-
 /* Overlay methods */
 static PyObject*
 _overlay_lock (PyObject *self)

File src/sdl/rwopsmod.c

View file
         /* TODO: allow wb ops! */
         return SDL_RWFromFile (name, "rb");
     }
+
+#ifdef IS_WIN32
+#pragma message("FIXME: Do not use the file descriptor, but a FILE* handle!")
+#else
 #warning FIXME: Do not use the file descriptor, but a FILE* handle!
+#endif
+
 #ifdef IS_PYTHON_3
     else if ((fd = PyObject_AsFileDescriptor (obj)) != -1)
         return SDL_RWFromFP (fd, 0);

File src/sdl/surface.c

View file
     SDL_SetClipRect (surface, &rect);
     return 0;
 }
+
 static PyObject*
 _surface_getwidth (PyObject *self, void *closure)
 {
     SDL_Surface *surface = ((PySDLSurface*)self)->surface;
     return PyInt_FromLong (surface->w);
 }
+
 static PyObject*
 _surface_getheight (PyObject *self, void *closure)
 {

File src/sdl/videomod.c

View file
 
     if (import_pygame2_base () < 0)
         goto fail;
+    if (import_pygame2_sdl_rwops () < 0)
+        goto fail;
     if (import_pygame2_sdl_base () < 0)
         goto fail;
 

File src/sdlext/drawmod.c

View file
 _draw_aaline (PyObject* self, PyObject* args)
 {
     PyObject *surfobj, *colorobj;
+    PyObject *p1, *p2;
     SDL_Surface* surface;
     SDL_Rect area;
     Uint32 color;
     int x1, _y1, x2, y2, blend = 0;
     int drawn = 0;
     
-    if (!PyArg_ParseTuple (args, "OO(ii)(ii)|i:aaline", &surfobj, &colorobj,
-            &x1, &_y1, &x2, &y2, &blend))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "OOOO|i:aaline", &surfobj, &colorobj, &p1,
+        &p2, &blend))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OOiiii|i:aaline", &surfobj, &colorobj,
+                &x1, &_y1, &x2, &y2, &blend))
+            return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (p1, &x1, &_y1) ||
+            !PointFromObject (p2, &x2, &y2))
+            return NULL;
+    }
+    
     if (!PySDLSurface_Check (surfobj))
     {
         PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
 _draw_line (PyObject* self, PyObject* args)
 {
     PyObject *surfobj, *colorobj;
+    PyObject *p1, *p2;
     SDL_Surface* surface;
     SDL_Rect area;
     Uint32 color;
     int x1, _y1, x2, y2, width = 1;
     int drawn = 0;
     
-    if (!PyArg_ParseTuple (args, "OO(ii)(ii)|i:line", &surfobj, &colorobj, &x1,
-            &_y1, &x2, &y2, &width))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "OOOO|i:line", &surfobj, &colorobj, &p1, &p2,
+        &width))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OOiiii|i:line", &surfobj, &colorobj, &x1,
+                &_y1, &x2, &y2, &width))
+            return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (p1, &x1, &_y1) ||
+            !PointFromObject (p2, &x2, &y2))
+            return NULL;
+    }
+    
     if (!PySDLSurface_Check (surfobj))
     {
         PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
 _draw_circle (PyObject* self, PyObject* args)
 {
     PyObject *surfobj, *colorobj;
+    PyObject *pt;
     SDL_Surface* surface;
     Uint32 color;
     int px, py, radius, loop, width = 0;
     pgint16 l, t;
     pguint16 r, b;
 
-    if (!PyArg_ParseTuple (args, "OO(ii)i|i:circle", &surfobj, &colorobj,
-            &px, &py, &radius, &width))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "OOOi|i:circle", &surfobj, &colorobj, &pt,
+        &radius, &width))
+    {
+        if (!PyArg_ParseTuple (args, "OOiii|i:circle", &surfobj, &colorobj,
+                &px, &py, &radius, &width))
+            return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (pt, &px, &py))
+            return NULL;
+    }
 
     if (!PySDLSurface_Check (surfobj))
     {

File src/sdlext/sdlextmod.c

View file
     static struct PyModuleDef _module = {
         PyModuleDef_HEAD_INIT,
         "base",
-        "",
+        DOC_BASE,
         -1,
         NULL,
         NULL, NULL, NULL, NULL

File src/sdlext/transformmod.c

View file
 _transform_scale (PyObject* self, PyObject* args)
 {
     PyObject *srcobj, *dstobj = NULL;
+    PyObject *size;
     SDL_Surface *srcsurface, *dstsurface = NULL;
     int width, height;
 
     /*get all the arguments*/
-    if (!PyArg_ParseTuple (args, "Oii|O", &srcobj, &width, &height, &dstobj))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "OO|O", &srcobj, &size, &dstobj))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "Oii|O", &srcobj, &width, &height, &dstobj))
+            return NULL;
+    }
+    else
+    {
+        if (!SizeFromObject (size, (pgint32*)&width, (pgint32*)&height))
+            return NULL;
+    }
+    
     if (!PySDLSurface_Check (srcobj))
     {
         PyErr_SetString (PyExc_TypeError, "source surface must be a Surface");
 _transform_smoothscale (PyObject* self, PyObject* args)
 {
     PyObject *surfobj, *dstobj = NULL;
+    PyObject *size;
     SDL_Surface *src, *dst = NULL;
     int width, height;
 
-    if (!PyArg_ParseTuple (args, "Oii|O", &surfobj, &width, &height, &dstobj))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "OO|O", &surfobj, &size, &dstobj))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "Oii|O", &surfobj, &width, &height, &dstobj))
+            return NULL;
+    }
+    else
+    {
+        if (!SizeFromObject (size, (pgint32*)&width, (pgint32*)&height))
+            return NULL;
+    }
+    
     if (!PySDLSurface_Check (surfobj))
     {
         PyErr_SetString (PyExc_TypeError, "source surface must be a Surface");

File src/sdlgfx/constantsmod.c

View file
 
 #include "gfxmod.h"
 #include "pggfx.h"
+#include <SDL_rotozoom.h>
 
 /* macros used to create each constant */
-#define DEC_CONSTS(x)  PyModule_AddIntConstant(module, #x, (int) #x)
+#define DEC_CONSTN(x)  PyModule_AddIntConstant(module, #x, (int) x)
 
 #ifdef IS_PYTHON_3
 PyMODINIT_FUNC PyInit_constants (void)
     static struct PyModuleDef _module = {
         PyModuleDef_HEAD_INIT,
         "constants",
-        "Pygame SDL GFX constants",
+        "Pygame SDL_gfx constants",
         -1,
         NULL,
         NULL, NULL, NULL, NULL
     };
     module = PyModule_Create (&_module);
 #else
-    module = Py_InitModule3 ("constants", NULL, "Pygame SDL GFX constants");
+    module = Py_InitModule3 ("constants", NULL, "Pygame SDL_gfx constants");
 #endif
     if (!module)
         goto fail;
     
-    DEC_CONSTS(FPS_UPPER_LIMIT);
-    DEC_CONSTS(FPS_LOWER_LIMIT);
-    DEC_CONSTS(FPS_DEFAULT);
+    DEC_CONSTN(FPS_UPPER_LIMIT);
+    DEC_CONSTN(FPS_LOWER_LIMIT);
+    DEC_CONSTN(FPS_DEFAULT);
 
-    DEC_CONSTS(SMOOTHING_OFF);
-    DEC_CONSTS(SMOOTHING_ON);
+    DEC_CONSTN(SMOOTHING_OFF);
+    DEC_CONSTN(SMOOTHING_ON);
     
     MODINIT_RETURN(module);
 fail:

File src/sdlgfx/fpsmanager.c

View file
 
 #include "gfxmod.h"
 #include "pggfx.h"
+#include "sdlgfxbase_doc.h"
 
 static PyObject* _fps_new (PyTypeObject *type, PyObject *args, PyObject *kwds);
 static void _fps_dealloc (PyFPSmanager *self);
 static PyObject* _fps_delay (PyObject *self);
 
 static PyMethodDef _fps_methods[] = {
-    { "delay", (PyCFunction) _fps_delay, METH_NOARGS, "" },
+    { "delay", (PyCFunction) _fps_delay, METH_NOARGS,
+      DOC_BASE_FPSMANAGER_DELAY },
     { NULL, NULL, 0, NULL },
 };
 
 static PyGetSetDef _fps_getsets[] = {
-    { "framerate", _fps_getframerate, _fps_setframerate, "", NULL },
+    { "framerate", _fps_getframerate, _fps_setframerate,
+      DOC_BASE_FPSMANAGER_FRAMERATE, NULL },
     { NULL, NULL, NULL, NULL, NULL },
 };
 
     0,                          /* tp_setattro */
     0,                          /* tp_as_buffer */
     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
-    "",
+    DOC_BASE_FPSMANAGER,
     0,                          /* tp_traverse */
     0,                          /* tp_clear */
     0,                          /* tp_richcompare */

File src/sdlgfx/gfxmod.c

View file
 #include "gfxmod.h"
 #include "pggfx.h"
 #include "pgsdl.h"
+#include "sdlgfxbase_doc.h"
 
 static PyObject* _gfx_getcompiledversion (PyObject *self);
 
 static PyMethodDef _gfx_methods[] = {
     { "get_compiled_version", (PyCFunction) _gfx_getcompiledversion,
-      METH_NOARGS, "" },
+      METH_NOARGS, DOC_BASE_GET_COMPILED_VERSION },
     { NULL, NULL, 0, NULL },
 };
 
     static struct PyModuleDef _module = {
         PyModuleDef_HEAD_INIT,
         "base",
-        "",
+        DOC_BASE,
         -1,
         _gfx_methods,
         NULL, NULL, NULL, NULL
 #ifdef IS_PYTHON_3
     mod = PyModule_Create (&_module);
 #else
-    mod = Py_InitModule3 ("base", _gfx_methods, "");
+    mod = Py_InitModule3 ("base", _gfx_methods, DOC_BASE);
 #endif
     if (!mod)
         goto fail;

File src/sdlgfx/primitivesmod.c

View file
 #include "pgsdl.h"
 #include "pggfx.h"
 #include "surface.h"
+#include "sdlgfxprimitives_doc.h"
 #include <SDL_gfxPrimitives.h>
 
 static PyObject* _gfx_pixelcolor (PyObject *self, PyObject* args);
 static PyObject* _gfx_beziercolor (PyObject *self, PyObject* args);
 
 static PyMethodDef _gfx_methods[] = {
-    { "pixel", _gfx_pixelcolor, METH_VARARGS, "" },
-    { "hline", _gfx_hlinecolor, METH_VARARGS, "" },
-    { "vline", _gfx_vlinecolor, METH_VARARGS, "" },
-    { "rectangle", _gfx_rectanglecolor, METH_VARARGS, "" },
-    { "box", _gfx_boxcolor, METH_VARARGS, "" },
-    { "line", _gfx_linecolor, METH_VARARGS, "" },
-    { "arc", _gfx_arccolor, METH_VARARGS, "" },
-    { "circle", _gfx_circlecolor, METH_VARARGS, "" },
-    { "aacircle", _gfx_aacirclecolor, METH_VARARGS, "" },
-    { "filled_circle", _gfx_filledcirclecolor, METH_VARARGS, "" },
-    { "ellipse", _gfx_ellipsecolor, METH_VARARGS, "" },
-    { "aaellipse", _gfx_aaellipsecolor, METH_VARARGS, "" },
-    { "filled_ellipse", _gfx_filledellipsecolor, METH_VARARGS, "" },
-    { "pie", _gfx_piecolor, METH_VARARGS, "" },
-    { "trigon", _gfx_trigoncolor, METH_VARARGS, "" },
-    { "aatrigon", _gfx_aatrigoncolor, METH_VARARGS, "" },
-    { "filled_trigon", _gfx_filledtrigoncolor, METH_VARARGS, "" },
-    { "polygon", _gfx_polygoncolor, METH_VARARGS, "" },
-    { "aapolygon", _gfx_aapolygoncolor, METH_VARARGS, "" },
-    { "filled_polygon", _gfx_filledpolygoncolor, METH_VARARGS, "" },
-    { "textured_polygon", _gfx_texturedpolygon, METH_VARARGS, "" },
-    { "bezier", _gfx_beziercolor, METH_VARARGS, "" },
+    { "pixel", _gfx_pixelcolor, METH_VARARGS, DOC_PRIMITIVES_PIXEL },
+    { "hline", _gfx_hlinecolor, METH_VARARGS, DOC_PRIMITIVES_HLINE },
+    { "vline", _gfx_vlinecolor, METH_VARARGS, DOC_PRIMITIVES_VLINE },
+    { "rectangle", _gfx_rectanglecolor, METH_VARARGS, DOC_PRIMITIVES_RECTANGLE },
+    { "box", _gfx_boxcolor, METH_VARARGS, DOC_PRIMITIVES_BOX },
+    { "line", _gfx_linecolor, METH_VARARGS, DOC_PRIMITIVES_LINE },
+    { "arc", _gfx_arccolor, METH_VARARGS, DOC_PRIMITIVES_ARC },
+    { "circle", _gfx_circlecolor, METH_VARARGS, DOC_PRIMITIVES_CIRCLE },
+    { "aacircle", _gfx_aacirclecolor, METH_VARARGS, DOC_PRIMITIVES_AACIRCLE },
+    { "filled_circle", _gfx_filledcirclecolor, METH_VARARGS,
+      DOC_PRIMITIVES_FILLED_CIRCLE },
+    { "ellipse", _gfx_ellipsecolor, METH_VARARGS, DOC_PRIMITIVES_ELLIPSE },
+    { "aaellipse", _gfx_aaellipsecolor, METH_VARARGS,
+      DOC_PRIMITIVES_AAELLIPSE },
+    { "filled_ellipse", _gfx_filledellipsecolor, METH_VARARGS, 
+      DOC_PRIMITIVES_FILLED_ELLIPSE },
+    { "pie", _gfx_piecolor, METH_VARARGS, DOC_PRIMITIVES_PIE },
+    { "trigon", _gfx_trigoncolor, METH_VARARGS, DOC_PRIMITIVES_TRIGON },
+    { "aatrigon", _gfx_aatrigoncolor, METH_VARARGS, DOC_PRIMITIVES_AATRIGON },
+    { "filled_trigon", _gfx_filledtrigoncolor, METH_VARARGS,
+      DOC_PRIMITIVES_FILLED_TRIGON },
+    { "polygon", _gfx_polygoncolor, METH_VARARGS, DOC_PRIMITIVES_POLYGON },
+    { "aapolygon", _gfx_aapolygoncolor, METH_VARARGS,
+      DOC_PRIMITIVES_AAPOLYGON },
+    { "filled_polygon", _gfx_filledpolygoncolor, METH_VARARGS,
+      DOC_PRIMITIVES_FILLED_POLYGON },
+    { "textured_polygon", _gfx_texturedpolygon, METH_VARARGS,
+      DOC_PRIMITIVES_TEXTURED_POLYGON },
+    { "bezier", _gfx_beziercolor, METH_VARARGS, DOC_PRIMITIVES_BEZIER },
     { NULL, NULL, 0, NULL },
 };
 
 static PyObject*
 _gfx_pixelcolor (PyObject *self, PyObject* args)
 {
-    PyObject *surface, *color;
+    PyObject *surface, *color, *pt;
     Sint16 x, y;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OiiO:pixel", &surface, &x, &y, &color))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "OOO:pixel", &surface, &pt, &color))
+    {
+        if (!PyArg_ParseTuple (args, "OiiO:pixel", &surface, &x, &y, &color))
+            return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+            return NULL;
+    }
     
     if (!PySDLSurface_Check (surface))
     {
 _gfx_linecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color;
+    PyObject *p1, *p2;
     Sint16 x1, x2, _y1, y2;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OiiiiO:line", &surface, &x1, &_y1, &x2, &y2,
-            &color))
+    if (!PyArg_ParseTuple (args, "OOOO:line", &surface, &p1, &p2, color))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OiiiiO:line", &surface, &x1, &_y1,
+            &x2, &y2, &color))
         return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (p1, (int*)&x1, (int*)&_y1) ||
+            !PointFromObject (p2, (int*)&x2, (int*)&y2))
+            return NULL;
+    }
     
     if (!PySDLSurface_Check (surface))
     {
 static PyObject*
 _gfx_circlecolor (PyObject *self, PyObject* args)
 {
-    PyObject *surface, *color;
+    PyObject *surface, *color, *pt;
     Sint16 x, y, r;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OiiiO:circle", &surface, &x, &y, &r, &color))
+    if (!PyArg_ParseTuple (args, "OOiO:circle", &surface, &pt, &r, &color))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OiiiO:circle", &surface, &x, &y, &r,
+            &color))
         return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+            return NULL;
+    }
     
     if (!PySDLSurface_Check (surface))
     {
 static PyObject*
 _gfx_arccolor (PyObject *self, PyObject* args)
 {
-    PyObject *surface, *color;
+    PyObject *surface, *color, *pt;
     Sint16 x, y, r, start, end;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OiiiiiO:arc", &surface, &x, &y, &r,
-            &start, &end, &color))
-        return NULL;
-    
+    if (!PyArg_ParseTuple (args, "OOiiiO:arc", &surface, &pt, &r, &start, &end,
+        &color))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OiiiiiO:arc", &surface, &x, &y, &r,
+                &start, &end, &color))
+            return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+            return NULL;
+    }
+
     if (!PySDLSurface_Check (surface))
     {
         PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
 static PyObject*
 _gfx_aacirclecolor (PyObject *self, PyObject* args)
 {
-    PyObject *surface, *color;
+    PyObject *surface, *color, *pt;
     Sint16 x, y, r;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OiiiO:aacircle", &surface, &x, &y, &r,
-            &color))
-        return NULL;
-    
+    if (!PyArg_ParseTuple (args, "OOiO:aacircle", &surface, &pt, &r, &color))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OiiiO:aacircle", &surface, &x, &y, &r,
+                &color))
+            return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+            return NULL;
+    }
     if (!PySDLSurface_Check (surface))
     {
         PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
 static PyObject*
 _gfx_filledcirclecolor (PyObject *self, PyObject* args)
 {
-    PyObject *surface, *color;
+    PyObject *surface, *color, *pt;
     Sint16 x, y, r;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OiiiO:filledcircle", &surface, &x, &y, &r,
-            &color))
-        return NULL;
+    if (!PyArg_ParseTuple (args, "OOiO:filledcircle", &surface, &pt, &r,
+        &color))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OiiiO:filledcircle", &surface, &x, &y,
+            &r, &color))
+            return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+            return NULL;
+    }
     
     if (!PySDLSurface_Check (surface))
     {
 static PyObject*
 _gfx_ellipsecolor (PyObject *self, PyObject* args)
 {
-    PyObject *surface, *color;
+    PyObject *surface, *color, *pt, *rd;
     Sint16 x, y, rx, ry;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);