=cut
+
+SDL_UserEvent *
+uevent_new ( CLASS )
+ char* CLASS
+ CODE:
+ RETVAL = safemalloc(sizeof(SDL_UserEvent));
+ RETVAL->type = SDL_USEREVENT;
+ OUTPUT:
+ RETVAL
+
Uint8
-uevent_type ( event, ... )
+uevent_type ( event )
SDL_UserEvent *event
CODE:
- if( items > 2)
- {
- event->type = SvIV(ST(1));
- }
RETVAL = event->type;
OUTPUT:
RETVAL
uevent_code ( event, ... )
SDL_UserEvent *event
CODE:
- if( items > 2 )
+ if( items > 1 )
{
- event->code = SvIV(ST(1));
+ event->code = SvIV( ST(1) );
+
}
- RETVAL = event->code;
+ RETVAL = (int)event->code;
OUTPUT:
RETVAL
-void
-uevent_data1 ( event, data )
+SV*
+uevent_data1 ( event, ... )
SDL_UserEvent *event
- IV data
- CODE:
- void * dataP = INT2PTR( void *, data);
- event->data1 = dataP;
+ CODE:
+ if( items > 1 )
+ {
+ event->data1 = (void *)SvIV(ST(1));
+ }
+ RETVAL = event->data1;
+ OUTPUT:
+ RETVAL
-void
-uevent_data2 ( event, data )
+SV*
+uevent_data2 ( event, ... )
SDL_UserEvent *event
- IV data
+ CODE:
+ if( items > 1 )
+ {
+ event->data1 = (void *) ST(1);
+ }
+ RETVAL = event->data1;
+ OUTPUT:
+ RETVAL
+
+
+void
+uevent_DESTROY(self)
+ SDL_UserEvent *self
CODE:
- void * dataP = INT2PTR( void *, data);
- event->data2 = dataP;
+ safefree( (char *)self );
use SDL::Video;
use Test::More;
-plan ( tests => 33 );
+plan ( tests => 38 );
my @done =qw/
pump_events
is(SDL::Events::pump_events(), undef, '[pump_events] Returns undef');
+my $uevent = SDL::UserEvent->new();
+$uevent->code(200 );
+isa_ok( $uevent, 'SDL::UserEvent', '[SDL::UserEvent::new] is creating a User Event');
+is( $uevent->type, 0x0018, '[SDL::UserEvent->type] returns correctly');
+is( $uevent->code, 200, '[SDL::UserEvent->code] is set correctly');
+
+TODO:
+{
+ local $TODO = 'Try to send a Scalar Ref as an IV and return a Scalar Ref';
+
+my $data1 = 'wow';
+$uevent->data1(\$data1);
+$uevent->data2('notwow');
+is( $uevent->data1, 'wow', '[SDL::UserEvent->data1] is set correctly');
+is( $uevent->data2, 'notwow','[SDL::UserEvent->data2] is set correctly');
+}
+
=pod
my $events = SDL::Event->new();