[pypy-svn] r54828 - in pypy/dist/pypy/rlib/rsdl: . test

arigo at codespeak.net arigo at codespeak.net
Sat May 17 15:32:23 CEST 2008


Author: arigo
Date: Sat May 17 15:32:22 2008
New Revision: 54828

Added:
   pypy/dist/pypy/rlib/rsdl/test/test_video.py
      - copied, changed from r54824, pypy/dist/pypy/rlib/rsdl/test/test_basic.py
Modified:
   pypy/dist/pypy/rlib/rsdl/RSDL.py
   pypy/dist/pypy/rlib/rsdl/test/test_basic.py
Log:
Basic logic to run interactive tests.  Some more functions implemented.


Modified: pypy/dist/pypy/rlib/rsdl/RSDL.py
==============================================================================
--- pypy/dist/pypy/rlib/rsdl/RSDL.py	(original)
+++ pypy/dist/pypy/rlib/rsdl/RSDL.py	Sat May 17 15:32:22 2008
@@ -10,27 +10,46 @@
 def external(name, args, result):
     return rffi.llexternal(name, args, result, compilation_info=eci)
 
+RectPtr        = lltype.Ptr(lltype.ForwardReference())
+SurfacePtr     = lltype.Ptr(lltype.ForwardReference())
+PixelFormatPtr = lltype.Ptr(lltype.ForwardReference())
+
 class CConfig:
     _compilation_info_ = eci
 
+    Uint8  = platform.SimpleType('Uint8',  rffi.INT)
     Uint32 = platform.SimpleType('Uint32', rffi.INT)
 
     INIT_VIDEO = platform.ConstantInteger('SDL_INIT_VIDEO')
 
+    Rect = platform.Struct('SDL_Rect', [('x', rffi.INT),
+                                        ('y', rffi.INT),
+                                        ('w', rffi.INT),
+                                        ('h', rffi.INT)])
     Surface = platform.Struct('SDL_Surface', [('w', rffi.INT),
-                                              ('h', rffi.INT)])
+                                              ('h', rffi.INT),
+                                              ('format', PixelFormatPtr)])
+    PixelFormat = platform.Struct('SDL_PixelFormat', [])
 
 globals().update(platform.configure(CConfig))
 
+RectPtr.TO.become(Rect)
+SurfacePtr.TO.become(Surface)
+PixelFormatPtr.TO.become(PixelFormat)
+
 
 Init = external('SDL_Init', [Uint32], rffi.INT)
 Quit = external('SDL_Quit', [], lltype.Void)
 SetVideoMode = external('SDL_SetVideoMode', [rffi.INT, rffi.INT,
                                              rffi.INT, Uint32],
-                        lltype.Ptr(Surface))
+                        SurfacePtr)
+Flip = external('SDL_Flip', [SurfacePtr], rffi.INT)
 CreateRGBSurface = external('SDL_CreateRGBSurface', [Uint32, rffi.INT,
                                                      rffi.INT, rffi.INT,
                                                      Uint32, Uint32,
                                                      Uint32, Uint32],
-                            lltype.Ptr(Surface))
-FreeSurface = external('SDL_FreeSurface', [lltype.Ptr(Surface)], lltype.Void)
+                            SurfacePtr)
+FreeSurface = external('SDL_FreeSurface', [SurfacePtr], lltype.Void)
+
+MapRGB = external('SDL_MapRGB', [PixelFormatPtr, Uint8, Uint8, Uint8], Uint32)
+FillRect = external('SDL_FillRect', [SurfacePtr, RectPtr, Uint32], rffi.INT)

Modified: pypy/dist/pypy/rlib/rsdl/test/test_basic.py
==============================================================================
--- pypy/dist/pypy/rlib/rsdl/test/test_basic.py	(original)
+++ pypy/dist/pypy/rlib/rsdl/test/test_basic.py	Sat May 17 15:32:22 2008
@@ -2,7 +2,6 @@
 from pypy.rlib.rsdl import RSDL
 from pypy.rlib.rarithmetic import r_uint
 from pypy.rpython.lltypesystem import rffi
-from pypy import conftest
 
 
 def test_sdl_init():
@@ -21,20 +20,3 @@
     assert rffi.getintfield(surface, 'c_h') == 50
     RSDL.FreeSurface(surface)
     RSDL.Quit()
-
-
-class TestVideo:
-
-    def setup_method(self, meth):
-        if not conftest.option.view:
-            py.test.skip("'--view' not specified, "
-                         "skipping tests that open a window")
-        assert RSDL.Init(RSDL.INIT_VIDEO) >= 0
-        self.surface = RSDL.SetVideoMode(640, 480, 32, 0)
-        assert self.surface
-
-    def test_simple(self):
-        pass   # only checks that opening and closing the window works
-
-    def teardown_method(self, meth):
-        RSDL.Quit()



More information about the Pypy-commit mailing list