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

arigo at codespeak.net arigo at codespeak.net
Sat May 17 16:37:45 CEST 2008


Author: arigo
Date: Sat May 17 16:37:44 2008
New Revision: 54837

Added:
   pypy/dist/pypy/rlib/rsdl/RIMG.py   (contents, props changed)
   pypy/dist/pypy/rlib/rsdl/test/autopath.py
      - copied unchanged from r54824, pypy/dist/pypy/tool/autopath.py
   pypy/dist/pypy/rlib/rsdl/test/demo.jpg   (contents, props changed)
   pypy/dist/pypy/rlib/rsdl/test/demo.png   (contents, props changed)
   pypy/dist/pypy/rlib/rsdl/test/test_sdl_image.py   (contents, props changed)
Log:
Starting bindings for SDL_image too.


Added: pypy/dist/pypy/rlib/rsdl/RIMG.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rlib/rsdl/RIMG.py	Sat May 17 16:37:44 2008
@@ -0,0 +1,15 @@
+from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rpython.tool import rffi_platform as platform
+from pypy.translator.tool.cbuild import ExternalCompilationInfo
+from pypy.rlib.rsdl import RSDL
+
+eci = ExternalCompilationInfo(
+    includes=['SDL_image.h'],
+    libraries=['SDL_image'],
+    )
+eci = eci.merge(RSDL.eci)
+
+def external(name, args, result):
+    return rffi.llexternal(name, args, result, compilation_info=eci)
+
+Load = external('IMG_Load', [rffi.CCHARP], RSDL.SurfacePtr)

Added: pypy/dist/pypy/rlib/rsdl/test/demo.jpg
==============================================================================
Binary file. No diff available.

Added: pypy/dist/pypy/rlib/rsdl/test/demo.png
==============================================================================
Binary file. No diff available.

Added: pypy/dist/pypy/rlib/rsdl/test/test_sdl_image.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rlib/rsdl/test/test_sdl_image.py	Sat May 17 16:37:44 2008
@@ -0,0 +1,13 @@
+import py, os
+import autopath
+from pypy.rlib.rsdl import RSDL, RIMG
+from pypy.rpython.lltypesystem import rffi
+
+
+def test_load_image():
+    for filename in ["demo.jpg", "demo.png"]:
+        image = RIMG.Load(os.path.join(autopath.this_dir, filename))
+        assert image
+        assert rffi.getintfield(image, 'c_w') == 17
+        assert rffi.getintfield(image, 'c_h') == 23
+        RSDL.FreeSurface(image)



More information about the Pypy-commit mailing list