david135 / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

[patch] a fix and additions to SDL_Event bindings #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
First, there's a trivial error in current SDL bindings:
the definition of SDL_MouseButtonEvent lacks `button' field.
First attached patch fixes this.

Second, there are a number of constants specific to SDL_Event,
which are missing.
The second attached patch adds most (if not all) of them.

Third, if you want to use SDL_Event, you currently pretty much have to
define-c-struct-methods in your code for each of the SDL_{*}Event structure,
since the accessors for those structures are not exported (or defined).
Unless that's by design, I can submit another patch.

Original issue reported on code.google.com by vmage...@gmail.com on 19 Apr 2009 at 9:10

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for your bug report!
I fixed the bugs and trunk directory is updated to revision 420. Thank you! :)

Regarding define-c-struct-methods,
Current libraries are designed as is, since I have plan to make framework 
library
which may looks like below to avoid large amount of unused accessors/mutators 
stay in
memory.

(library (ypsilon sdl framework)
  (export using-sdl)
  (import (rnrs) (ypsilon sdl))
  (define-syntax using-sdl
    (syntax-rules (core event)
      ((_ core) (define-c-struct-methods
                     SDL_Rect
                     SDL_PixelFormat
                     SDL_Surface
                     SDL_keysym))
      ((_ event) (define-c-struct-methods
                    SDL_ActiveEvent
                    SDL_KeyboardEvent
                    SDL_MouseMotionEvent
                    SDL_MouseButtonEvent
                    SDL_JoyAxisEvent
                    SDL_JoyBallEvent
                    SDL_JoyHatEvent
                    SDL_JoyButtonEvent
                    SDL_ResizeEvent
                    SDL_ExposeEvent
                    SDL_QuitEvent
                    SDL_UserEvent
                    SDL_SysWMEvent)))))
---------------                                              
And, client library may looks like:

(library (myapp)
  (export)
  (import (ypsilon sdl)
          (ypsilon sdl framework))

  (using-sdl core)
  (using-sdl event)

      :
      :
  )
-----------------
However, It is incomplete at this moment. :(
-- fujita

Original comment by y.fujita...@gmail.com on 20 Apr 2009 at 1:07