From 8199fa03795414546bb9f55d1f7eaa490160b22a Mon Sep 17 00:00:00 2001 From: groogy Date: Sun, 5 Dec 2010 15:40:24 +0000 Subject: [PATCH] some small fixes for mistakes I made and that Trickster noticed. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1748 4e206d99-4929-0410-ac5d-dfc041789085 --- .../ruby/sfml-graphics/graphics/Glyph.cpp | 1 + bindings/ruby/sfml-system/system/Clock.cpp | 2 +- .../sfml-window/window/ContextSettings.cpp | 44 ++++++------------- bindings/ruby/sfml-window/window/Event.cpp | 2 +- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/bindings/ruby/sfml-graphics/graphics/Glyph.cpp b/bindings/ruby/sfml-graphics/graphics/Glyph.cpp index 08e376bd..a201f2c4 100644 --- a/bindings/ruby/sfml-graphics/graphics/Glyph.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Glyph.cpp @@ -23,6 +23,7 @@ #include "Glyph.hpp" #include "Rect.hpp" #include "main.hpp" +#include VALUE globalGlyphClass; diff --git a/bindings/ruby/sfml-system/system/Clock.cpp b/bindings/ruby/sfml-system/system/Clock.cpp index 8f445e28..9b279178 100644 --- a/bindings/ruby/sfml-system/system/Clock.cpp +++ b/bindings/ruby/sfml-system/system/Clock.cpp @@ -75,7 +75,7 @@ static VALUE Clock_InitializeCopy( VALUE self, VALUE aSource ) * * The clock starts automatically after being constructed. */ -static VALUE Clock_New( int argc, VALUE *args VALUE aKlass ) +static VALUE Clock_New( int argc, VALUE *args, VALUE aKlass ) { sf::Clock *object = new sf::Clock(); VALUE rbData = Data_Wrap_Struct( aKlass, 0, Clock_Free, object ); diff --git a/bindings/ruby/sfml-window/window/ContextSettings.cpp b/bindings/ruby/sfml-window/window/ContextSettings.cpp index 22bbcfb2..6b9912a9 100644 --- a/bindings/ruby/sfml-window/window/ContextSettings.cpp +++ b/bindings/ruby/sfml-window/window/ContextSettings.cpp @@ -171,53 +171,37 @@ static VALUE ContextSettings_InitializeCopy( VALUE self, VALUE aSource ) * * The constructor creates the settings */ -static VALUE ContextSettings_New( VALUE aKlass, VALUE someArgs ) +static VALUE ContextSettings_New( int argc, VALUE *args, VALUE aKlass ) { - long arrayLength = RARRAY_LEN( someArgs ); sf::ContextSettings *object = NULL; - if( arrayLength == 0 ) + if( argc == 0 ) { object = new sf::ContextSettings(); } - else if( arrayLength == 1 ) + else if( argc == 1 ) { - VALUE arg1 = rb_ary_entry( someArgs, 0 ); - object = new sf::ContextSettings( NUM2UINT( arg1 ) ); + object = new sf::ContextSettings( NUM2UINT( args[0] ) ); } - else if( arrayLength == 2 ) + else if( argc == 2 ) { - VALUE arg1 = rb_ary_entry( someArgs, 0 ); - VALUE arg2 = rb_ary_entry( someArgs, 1 ); - object = new sf::ContextSettings( NUM2UINT( arg1 ), NUM2UINT( arg2 ) ); + object = new sf::ContextSettings( NUM2UINT( args[0] ), NUM2UINT( args[1] ) ); } - else if( arrayLength == 3 ) + else if( argc == 3 ) { - VALUE arg1 = rb_ary_entry( someArgs, 0 ); - VALUE arg2 = rb_ary_entry( someArgs, 1 ); - VALUE arg3 = rb_ary_entry( someArgs, 2 ); - object = new sf::ContextSettings( NUM2UINT( arg1 ), NUM2UINT( arg2 ), NUM2UINT( arg3 ) ); + object = new sf::ContextSettings( NUM2UINT( args[0] ), NUM2UINT( args[1] ), NUM2UINT( args[2] ) ); } - else if( arrayLength == 4 ) + else if( argc == 4 ) { - VALUE arg1 = rb_ary_entry( someArgs, 0 ); - VALUE arg2 = rb_ary_entry( someArgs, 1 ); - VALUE arg3 = rb_ary_entry( someArgs, 2 ); - VALUE arg4 = rb_ary_entry( someArgs, 3 ); - object = new sf::ContextSettings( NUM2UINT( arg1 ), NUM2UINT( arg2 ), NUM2UINT( arg3 ), NUM2UINT( arg4 ) ); + object = new sf::ContextSettings( NUM2UINT( args[0] ), NUM2UINT( args[1] ), NUM2UINT( args[2] ), NUM2UINT( args[3] ) ); } - else if( arrayLength == 5 ) + else if( argc == 5 ) { - VALUE arg1 = rb_ary_entry( someArgs, 0 ); - VALUE arg2 = rb_ary_entry( someArgs, 1 ); - VALUE arg3 = rb_ary_entry( someArgs, 2 ); - VALUE arg4 = rb_ary_entry( someArgs, 3 ); - VALUE arg5 = rb_ary_entry( someArgs, 4 ); - object = new sf::ContextSettings( NUM2UINT( arg1 ), NUM2UINT( arg2 ), NUM2UINT( arg3 ), NUM2UINT( arg4 ), NUM2UINT( arg5 ) ); + object = new sf::ContextSettings( NUM2UINT( args[0] ), NUM2UINT( args[1] ), NUM2UINT( args[2] ), NUM2UINT( args[3] ), NUM2UINT( args[4] ) ); } else { - rb_raise( rb_eArgError, "Expected 0..5 arguments but was given %ld", arrayLength ); + rb_raise( rb_eArgError, "Expected 0..5 arguments but was given %d", argc ); return Qnil; } @@ -258,7 +242,7 @@ void Init_ContextSettings( void ) globalContextSettingsClass = rb_define_class_under( sfml, "ContextSettings", rb_cObject ); // Class methods - rb_define_singleton_method( globalContextSettingsClass, "new", ContextSettings_New, -2 ); + rb_define_singleton_method( globalContextSettingsClass, "new", ContextSettings_New, -1 ); // Instance methods rb_define_method( globalContextSettingsClass, "initialize_copy", ContextSettings_InitializeCopy, 1 ); diff --git a/bindings/ruby/sfml-window/window/Event.cpp b/bindings/ruby/sfml-window/window/Event.cpp index b1e59c5b..c3f62d2c 100644 --- a/bindings/ruby/sfml-window/window/Event.cpp +++ b/bindings/ruby/sfml-window/window/Event.cpp @@ -221,7 +221,7 @@ static VALUE Event_InitializeCopy( VALUE self, VALUE aSource ) sf::Event *source = NULL; Data_Get_Struct( aSource, sf::Event, source ); *object = *source; - return Event_Initialize( VALUE self, INT2FIX( object->Type ) ); + return Event_Initialize( self, INT2FIX( object->Type ) ); } /* call-seq: