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

cami at codespeak.net cami at codespeak.net
Tue May 20 16:03:16 CEST 2008


Author: cami
Date: Tue May 20 16:03:09 2008
New Revision: 54999

Modified:
   pypy/dist/pypy/rlib/rsdl/RSDL.py
   pypy/dist/pypy/rlib/rsdl/test/test_video.py
Log:
removed useless mousescrolloffset test
changed initialization of RSDL for use with the translator and on the mac
changed file path ro SDLMain.m to work with gcc


Modified: pypy/dist/pypy/rlib/rsdl/RSDL.py
==============================================================================
--- pypy/dist/pypy/rlib/rsdl/RSDL.py	(original)
+++ pypy/dist/pypy/rlib/rsdl/RSDL.py	Tue May 20 16:03:09 2008
@@ -2,14 +2,23 @@
 from pypy.rpython.tool import rffi_platform as platform
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.rlib.rsdl.constants import _constants
+from pypy.rlib.objectmodel import we_are_translated
+import py
 import sys
 
 if sys.platform == 'darwin':
     eci = ExternalCompilationInfo(
-        includes = ['SDL.h'],
-        include_dirs = ['/Library/Frameworks/SDL.framework/Versions/A/Headers'],
+        includes = ['SDL.h', 
+                    #'Init.h',
+                    #'SDLMain.m'
+                    #'SDLMain.h'*/
+                    ],
+        include_dirs = ['/Library/Frameworks/SDL.framework/Versions/A/Headers',
+                        #str(py.magic.autopath().dirpath().join('macosx-sdl-main'))
+                        ],
         link_extra = [
-            'macosx-sdl-main/SDLMain.m',
+            str(py.magic.autopath().dirpath().join('macosx-sdl-main/SDLMain.m')),
+            #'macosx-sdl-main/SDLMain.m',
             '-I', '/Library/Frameworks/SDL.framework/Versions/A/Headers',
         ],
         frameworks = ['SDL', 'Cocoa']
@@ -119,19 +128,21 @@
 Sint16P = lltype.Ptr(lltype.Array(Sint16, hints={'nolength': True}))
 Uint32P = lltype.Ptr(lltype.Array(Uint32, hints={'nolength': True}))
 
-# ------------------------------------------------------------------------------
-
-def Init(flags):
-    if sys.platform == 'darwin':
-        from AppKit import NSApplication
-        NSApplication.sharedApplication()
-    return _Init(flags)
 
 # ------------------------------------------------------------------------------
 
 _Init            = external('SDL_Init', 
                              [Uint32], 
                              rffi.INT)
+#static void CustomApplicationMain (int argc, char **argv)
+
+CustomApplicationMain = external('CustomApplicationMain',
+                                 [rffi.INT, rffi.CCHARP],
+                                  lltype.Void)
+                                  
+Mac_Init        = external('SDL_Init', 
+                             [Uint32], 
+                             rffi.INT)
 
 Quit             = external('SDL_Quit', [], 
                             lltype.Void)
@@ -209,3 +220,20 @@
 UpdateRect       = external('SDL_UpdateRect',
                             [SurfacePtr, rffi.INT, rffi.INT, rffi.INT],
                             lltype.Void)
+
+# ------------------------------------------------------------------------------
+
+
+if sys.platform == 'darwin':
+    def Init(flags):
+        if not we_are_translated():
+            from AppKit import NSApplication
+            NSApplication.sharedApplication()
+        #CustomApplicationMain(0, " ")
+        return _Init(flags)
+        #Mac_Init()
+else:
+    Init = _Init
+    
+    
+    
\ No newline at end of file

Modified: pypy/dist/pypy/rlib/rsdl/test/test_video.py
==============================================================================
--- pypy/dist/pypy/rlib/rsdl/test/test_video.py	(original)
+++ pypy/dist/pypy/rlib/rsdl/test/test_video.py	Tue May 20 16:03:09 2008
@@ -151,44 +151,6 @@
                 py.test.fail("")
         finally:
             lltype.free(event, flavor='raw')
-                
-    def test_mousewheel(self):
-        if not self.is_interactive:
-            py.test.skip("interactive test only")
-        print
-        print "Press the given MouseButtons:"
-        print "        Use Escape to quit."
-        
-        event_tests = [("scroll up",     RSDL.BUTTON_WHEELUP),
-                       ("scroll down",   RSDL.BUTTON_WHEELDOWN)]
-        test_success = []
-        event = lltype.malloc(RSDL.Event, flavor='raw')
-        try:
-            for button_test in event_tests:
-                print "    press %s:" % button_test[0]
-                while True:
-                    ok = RSDL.WaitEvent(event)
-                    assert rffi.cast(lltype.Signed, ok) == 1
-                    c_type = rffi.getintfield(event, 'c_type')
-                    if c_type == RSDL.MOUSEBUTTONDOWN:
-                        b = rffi.cast(RSDL.MouseButtonEventPtr, event)
-                        print "down", rffi.getintfield(b, "c_x"), \
-                                      rffi.getintfield(b, "c_y")
-                    elif c_type == RSDL.MOUSEBUTTONUP:
-                        b = rffi.cast(RSDL.MouseButtonEventPtr, event)
-                        print "up", rffi.getintfield(b, "c_x"), \
-                                    rffi.getintfield(b, "c_y")
-                    elif c_type == RSDL.KEYUP:
-                        p = rffi.cast(RSDL.KeyboardEventPtr, event)
-                        if rffi.getintfield(p.c_keysym, 'c_sym') == RSDL.K_ESCAPE:
-                            test_success.append(False) 
-                            print "        manually aborted"
-                            break
-                        #break
-            if False in test_success:
-                py.test.fail("")
-        finally:
-            lltype.free(event, flavor='raw')
             
             
     def test_show_hide_cursor(self):



More information about the Pypy-commit mailing list