I made some errors since I couldn't previously test compile my source. Anyway fixed now. Just gonna check runtime later too.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1616 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
groogy 2010-11-05 20:06:30 +00:00
parent 1279cb208c
commit e75c42869d

View File

@ -85,40 +85,49 @@ static void Event_Free( sf::Event *anObject )
delete anObject;
}
#define AXIS2NUM( x ) INT2NUM( static_cast< int > ( x ) )
#define NUM2AXIS( x ) static_cast< sf::Joy::Axis >( NUM2INT( x ) )
#define KEY2NUM( x ) INT2NUM( static_cast< int > ( x ) )
#define NUM2KEY( x ) static_cast< sf::Key::Code >( NUM2INT( x ) )
#define MOUSE2NUM( x ) INT2NUM( static_cast< int > ( x ) )
#define NUM2MOUSE( x ) static_cast< sf::Mouse::Button >( NUM2INT( x ) )
#define EVENT_TYPE_ACCESSORS( a, b, conv1, conv2 ) \
static VALUE a##Event_Get##b##( VALUE self ) \
static VALUE a##Event_Get##b ( VALUE self ) \
{ \
sf::Event::##a##Event * object = NULL; \
Data_Get_Struct( self, sf::Event::##a##Event, object ); \
return conv1##( object->##a##.##b ); \
sf::Event:: a##Event * object = NULL; \
Data_Get_Struct( self, sf::Event:: a##Event, object ); \
return conv1 ( object-> b ); \
} \
\
static VALUE a##Event_Set##b##( VALUE self, VALUE aVal ) \
static VALUE a##Event_Set##b ( VALUE self, VALUE aVal ) \
{ \
sf::Event::##a##Event * object = NULL; \
Data_Get_Struct( self, sf::Event::##a##Event, object ); \
return conv1##( object->##a##.##b = conv2##( aVal ) ); \
sf::Event:: a##Event * object = NULL; \
Data_Get_Struct( self, sf::Event:: a##Event, object ); \
return conv1 ( object-> b = conv2 ( aVal ) ); \
}
#define EVENT_TYÅE_BOOL_ACCESSORS( a, b ) \
static VALUE a##Event_Get##b##( VALUE self ) \
#define EVENT_TYPE_BOOL_ACCESSORS( a, b ) \
static VALUE a##Event_Get##b ( VALUE self ) \
{ \
sf::Event::##a##Event * object = NULL; \
Data_Get_Struct( self, sf::Event::##a##Event, object ); \
if( object->##a##.##b == true ) \
sf::Event:: a##Event * object = NULL; \
Data_Get_Struct( self, sf::Event:: a##Event, object ); \
if( object-> b == true ) \
return Qtrue; \
else \
return Qfalse; \
} \
\
static VALUE a##Event_Set##b##( VALUE self, VALUE aVal ) \
static VALUE a##Event_Set##b ( VALUE self, VALUE aVal ) \
{ \
sf::Event::##a##Event * object = NULL; \
Data_Get_Struct( self, sf::Event::##a##Event, object ); \
sf::Event:: a##Event * object = NULL; \
Data_Get_Struct( self, sf::Event:: a##Event, object ); \
if( aVal == Qtrue ) \
object->##a##.##b = true; \
object-> b = true; \
else \
object->##a##.##b = false; \
object-> b = false; \
return aVal; \
}
@ -140,15 +149,15 @@ EVENT_TYPE_ACCESSORS( JoyButton, JoystickId, INT2NUM, NUM2UINT );
EVENT_TYPE_ACCESSORS( JoyButton, Button, INT2NUM, NUM2UINT );
EVENT_TYPE_ACCESSORS( JoyMove, JoystickId, INT2NUM, NUM2UINT );
EVENT_TYPE_ACCESSORS( JoyMove, Axis, INT2NUM, NUM2INT );
EVENT_TYPE_ACCESSORS( JoyMove, Axis, AXIS2NUM, NUM2AXIS );
EVENT_TYPE_ACCESSORS( JoyMove, Position, rb_float_new, NUM2DBL );
EVENT_TYPE_ACCESSORS( Key, Code, INT2NUM, NUM2INT );
EVENT_TYPE_ACCESSORS( Key, Code, KEY2NUM, NUM2KEY );
EVENT_TYPE_BOOL_ACCESSORS( Key, Alt );
EVENT_TYPE_BOOL_ACCESSORS( Key, Control );
EVENT_TYPE_BOOL_ACCESSORS( Key, Shift );
EVENT_TYPE_ACCESSORS( MouseButton, Button, INT2NUM, NUM2INT );
EVENT_TYPE_ACCESSORS( MouseButton, Button, MOUSE2NUM, NUM2MOUSE );
EVENT_TYPE_ACCESSORS( MouseButton, X, INT2NUM, NUM2INT );
EVENT_TYPE_ACCESSORS( MouseButton, Y, INT2NUM, NUM2INT );
@ -171,33 +180,33 @@ static VALUE Event_Initialize( VALUE self )
bool noSpecialType = false;
VALUE eventType;
switch( self->Type )
switch( object->Type )
{
case JoyButtonPressed:
case JoyButtonReleased:
case sf::Event::JoyButtonPressed:
case sf::Event::JoyButtonReleased:
eventType = Data_Wrap_Struct( globalJoyButtonEventClass, 0, 0, &object->JoyButton );
break;
case JoyMoved:
case sf::Event::JoyMoved:
eventType = Data_Wrap_Struct( globalJoyMoveEventClass, 0, 0, &object->JoyMove );
break;
case KeyPressed:
case KeyReleased:
case sf::Event::KeyPressed:
case sf::Event::KeyReleased:
eventType = Data_Wrap_Struct( globalKeyEventClass, 0, 0, &object->Key );
break;
case MouseButtonPressed:
case MouseButtonReleased:
case sf::Event::MouseButtonPressed:
case sf::Event::MouseButtonReleased:
eventType = Data_Wrap_Struct( globalMouseButtonEventClass, 0, 0, &object->MouseButton );
break;
case MouseMoved:
case sf::Event::MouseMoved:
eventType = Data_Wrap_Struct( globalMouseMoveEventClass, 0, 0, &object->MouseMove );
break;
case MouseWheelMoved:
case sf::Event::MouseWheelMoved:
eventType = Data_Wrap_Struct( globalMouseWheelEventClass, 0, 0, &object->MouseWheel );
break;
case Resized:
case sf::Event::Resized:
eventType = Data_Wrap_Struct( globalSizeEventClass, 0, 0, &object->Size );
break;
case TextEntered:
case sf::Event::TextEntered:
eventType = Data_Wrap_Struct( globalTextEventClass, 0, 0, &object->Text );
break;
default:
@ -307,6 +316,6 @@ void Init_Event( void )
rb_define_method( globalSizeEventClass, "height=", FUNCPTR( SizeEvent_SetWidth ), 1 );
// Text methods
rb_define_method( globalTextEventClass, "unicode", FUNCPTR( SizeEvent_GetUnicode ), 0 );
rb_define_method( globalTextEventClass, "unicode=", FUNCPTR( SizeEvent_SetUnicode ), 1 )
rb_define_method( globalTextEventClass, "unicode", FUNCPTR( TextEvent_GetUnicode ), 0 );
rb_define_method( globalTextEventClass, "unicode=", FUNCPTR( TextEvent_SetUnicode ), 1 );
}