Added UserEvent
Kartik Thakore [Thu, 5 Nov 2009 23:48:37 +0000 (18:48 -0500)]
Build.PL
src/Core/objects/UserEvent.xs [new file with mode: 0644]
src/Core/objects/typemap [new file with mode: 0644]

index 47b1046..7d0e178 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -112,6 +112,13 @@ my %subsystems =
                },
                libraries => [qw( SDL )],
        },
+       UserEvent => {
+               file      => {
+                       from  => 'src/Core/objects/UserEvent.xs',
+                       to    => 'lib/SDL/UserEvent.xs',
+               },
+               libraries => [qw( SDL )],
+       },
        MultiThread => {
                file      => {
                        from  => 'src/Core/MultiThread.xs',
diff --git a/src/Core/objects/UserEvent.xs b/src/Core/objects/UserEvent.xs
new file mode 100644 (file)
index 0000000..bc66ab2
--- /dev/null
@@ -0,0 +1,65 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+
+MODULE = SDL::UserEvent        PACKAGE = SDL::UserEvent    PREFIX = uevent_
+
+=for documentation
+
+SDL_UserEvent -- A user-defined event type
+
+ typedef struct{
+  Uint8 type;
+  int code;
+  void* data1;
+  void* data2; 
+ } SDL_UserEvent;
+
+
+=cut
+Uint8
+uevent_type ( event, ... )
+       SDL_UserEvent *event
+       CODE: 
+               if( items > 2)
+               {
+                       event->type = SvIV(ST(1));
+               }
+               RETVAL = event->type;
+       OUTPUT:
+               RETVAL
+
+int
+uevent_code ( event, ... )
+       SDL_UserEvent *event
+       CODE: 
+               if( items > 2 )
+               {
+                       event->code = SvIV(ST(1));
+               }
+               RETVAL = event->code;
+       OUTPUT:
+               RETVAL
+
+void
+uevent_data1 ( event, data )
+       SDL_UserEvent *event    
+       IV data
+       CODE:
+               void * dataP = INT2PTR( void *, data);
+               event->data1 = dataP;
+
+
+void
+uevent_data2 ( event, data )
+       SDL_UserEvent *event    
+       IV data
+       CODE:
+               void * dataP = INT2PTR( void *, data);
+               event->data2 = dataP;
diff --git a/src/Core/objects/typemap b/src/Core/objects/typemap
new file mode 100644 (file)
index 0000000..e69de29