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
This commit is contained in:
groogy 2010-12-05 15:40:24 +00:00
parent 20e308466a
commit 8199fa0379
4 changed files with 17 additions and 32 deletions

View File

@ -23,6 +23,7 @@
#include "Glyph.hpp" #include "Glyph.hpp"
#include "Rect.hpp" #include "Rect.hpp"
#include "main.hpp" #include "main.hpp"
#include <SFML/Graphics/Glyph.hpp>
VALUE globalGlyphClass; VALUE globalGlyphClass;

View File

@ -75,7 +75,7 @@ static VALUE Clock_InitializeCopy( VALUE self, VALUE aSource )
* *
* The clock starts automatically after being constructed. * 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(); sf::Clock *object = new sf::Clock();
VALUE rbData = Data_Wrap_Struct( aKlass, 0, Clock_Free, object ); VALUE rbData = Data_Wrap_Struct( aKlass, 0, Clock_Free, object );

View File

@ -171,53 +171,37 @@ static VALUE ContextSettings_InitializeCopy( VALUE self, VALUE aSource )
* *
* The constructor creates the settings * 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; sf::ContextSettings *object = NULL;
if( arrayLength == 0 ) if( argc == 0 )
{ {
object = new sf::ContextSettings(); object = new sf::ContextSettings();
} }
else if( arrayLength == 1 ) else if( argc == 1 )
{ {
VALUE arg1 = rb_ary_entry( someArgs, 0 ); object = new sf::ContextSettings( NUM2UINT( args[0] ) );
object = new sf::ContextSettings( NUM2UINT( arg1 ) );
} }
else if( arrayLength == 2 ) else if( argc == 2 )
{ {
VALUE arg1 = rb_ary_entry( someArgs, 0 ); object = new sf::ContextSettings( NUM2UINT( args[0] ), NUM2UINT( args[1] ) );
VALUE arg2 = rb_ary_entry( someArgs, 1 );
object = new sf::ContextSettings( NUM2UINT( arg1 ), NUM2UINT( arg2 ) );
} }
else if( arrayLength == 3 ) else if( argc == 3 )
{ {
VALUE arg1 = rb_ary_entry( someArgs, 0 ); object = new sf::ContextSettings( NUM2UINT( args[0] ), NUM2UINT( args[1] ), NUM2UINT( args[2] ) );
VALUE arg2 = rb_ary_entry( someArgs, 1 );
VALUE arg3 = rb_ary_entry( someArgs, 2 );
object = new sf::ContextSettings( NUM2UINT( arg1 ), NUM2UINT( arg2 ), NUM2UINT( arg3 ) );
} }
else if( arrayLength == 4 ) else if( argc == 4 )
{ {
VALUE arg1 = rb_ary_entry( someArgs, 0 ); object = new sf::ContextSettings( NUM2UINT( args[0] ), NUM2UINT( args[1] ), NUM2UINT( args[2] ), NUM2UINT( args[3] ) );
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 ) );
} }
else if( arrayLength == 5 ) else if( argc == 5 )
{ {
VALUE arg1 = rb_ary_entry( someArgs, 0 ); object = new sf::ContextSettings( NUM2UINT( args[0] ), NUM2UINT( args[1] ), NUM2UINT( args[2] ), NUM2UINT( args[3] ), NUM2UINT( args[4] ) );
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 ) );
} }
else 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; return Qnil;
} }
@ -258,7 +242,7 @@ void Init_ContextSettings( void )
globalContextSettingsClass = rb_define_class_under( sfml, "ContextSettings", rb_cObject ); globalContextSettingsClass = rb_define_class_under( sfml, "ContextSettings", rb_cObject );
// Class methods // Class methods
rb_define_singleton_method( globalContextSettingsClass, "new", ContextSettings_New, -2 ); rb_define_singleton_method( globalContextSettingsClass, "new", ContextSettings_New, -1 );
// Instance methods // Instance methods
rb_define_method( globalContextSettingsClass, "initialize_copy", ContextSettings_InitializeCopy, 1 ); rb_define_method( globalContextSettingsClass, "initialize_copy", ContextSettings_InitializeCopy, 1 );

View File

@ -221,7 +221,7 @@ static VALUE Event_InitializeCopy( VALUE self, VALUE aSource )
sf::Event *source = NULL; sf::Event *source = NULL;
Data_Get_Struct( aSource, sf::Event, source ); Data_Get_Struct( aSource, sf::Event, source );
*object = *source; *object = *source;
return Event_Initialize( VALUE self, INT2FIX( object->Type ) ); return Event_Initialize( self, INT2FIX( object->Type ) );
} }
/* call-seq: /* call-seq: