diff --git a/bindings/ruby/sfml-audio/audio/SoundBuffer.cpp b/bindings/ruby/sfml-audio/audio/SoundBuffer.cpp index 9ca6f10b..b41982b1 100644 --- a/bindings/ruby/sfml-audio/audio/SoundBuffer.cpp +++ b/bindings/ruby/sfml-audio/audio/SoundBuffer.cpp @@ -193,6 +193,15 @@ static VALUE SoundBuffer_GetDuration( VALUE self ) return rb_float_new( object->GetDuration() ); } +static VALUE SoundBuffer_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::SoundBuffer *object = NULL; + Data_Get_Struct( self, sf::SoundBuffer, object ); + sf::SoundBuffer *source = NULL; + Data_Get_Struct( aSource, sf::SoundBuffer, source ); + *object = *source; +} + /* call-seq: * SoundBuffer.new() -> sound_buffer * @@ -264,6 +273,7 @@ void Init_SoundBuffer( void ) rb_define_singleton_method( globalSoundBufferClass, "new", SoundBuffer_New, -1 ); // Instance methods + rb_define_method( globalSoundBufferClass, "initialize_copy", SoundBuffer_InitializeCopy, 1 ); rb_define_method( globalSoundBufferClass, "loadFromFile", SoundBuffer_LoadFromFile, 1 ); rb_define_method( globalSoundBufferClass, "loadFromSamples", SoundBuffer_LoadFromSamples, 4 ); rb_define_method( globalSoundBufferClass, "saveToFile", SoundBuffer_SaveToFile, 1 ); diff --git a/bindings/ruby/sfml-audio/audio/SoundSource.cpp b/bindings/ruby/sfml-audio/audio/SoundSource.cpp index 08ebd7cb..e4d34a69 100644 --- a/bindings/ruby/sfml-audio/audio/SoundSource.cpp +++ b/bindings/ruby/sfml-audio/audio/SoundSource.cpp @@ -237,6 +237,15 @@ static VALUE SoundSource_SetVolume( VALUE self, VALUE aValue ) return Qnil; } +static VALUE SoundSource_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::SoundSource *object = NULL; + Data_Get_Struct( self, sf::SoundSource, object ); + sf::SoundSource *source = NULL; + Data_Get_Struct( aSource, sf::SoundSource, source ); + *object = *source; +} + static void DefineStatusEnum( void ) { rb_define_const( globalSoundSourceClass, "Stopped", INT2FIX( sf::SoundSource::Stopped ) ); @@ -260,6 +269,7 @@ void Init_SoundSource( void ) DefineStatusEnum(); // Instance methods + rb_define_method( globalSoundSourceClass, "initialize_copy", SoundSource_InitializeCopy, 1 ); rb_define_method( globalSoundSourceClass, "getAttenuation", SoundSource_GetAttenuation, 0 ); rb_define_method( globalSoundSourceClass, "getMinDistance", SoundSource_GetMinDistance, 0 ); rb_define_method( globalSoundSourceClass, "getPitch", SoundSource_GetPitch, 0 ); diff --git a/bindings/ruby/sfml-graphics/graphics/Font.cpp b/bindings/ruby/sfml-graphics/graphics/Font.cpp index 519af615..73f4b8e7 100644 --- a/bindings/ruby/sfml-graphics/graphics/Font.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Font.cpp @@ -130,6 +130,15 @@ static VALUE Font_GetImage( VALUE self, VALUE aCharacterSize ) return rbImage; } +static VALUE Font_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Font *object = NULL; + Data_Get_Struct( self, sf::Font, object ); + sf::Font *source = NULL; + Data_Get_Struct( aSource, sf::Font, source ); + *object = *source; +} + /* call-seq: * Font.new() -> font * @@ -219,6 +228,7 @@ void Init_Font( void ) rb_define_singleton_method( globalFontClass, "getDefaultFont", Font_GetDefaultFont, 0 ); // Instance methods + rb_define_method( globalFontClass, "initialize_copy", Font_InitializeCopy, 1 ); rb_define_method( globalFontClass, "loadFromFile", Font_LoadFromFile, 1 ); rb_define_method( globalFontClass, "getGlyph", Font_GetGlyph, 3 ); rb_define_method( globalFontClass, "getKerning", Font_GetKerning, 3 ); diff --git a/bindings/ruby/sfml-graphics/graphics/Glyph.cpp b/bindings/ruby/sfml-graphics/graphics/Glyph.cpp index ac89e5eb..08e376bd 100644 --- a/bindings/ruby/sfml-graphics/graphics/Glyph.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Glyph.cpp @@ -42,6 +42,15 @@ static VALUE Glyph_Initialize( VALUE self ) return self; } +static VALUE Glyph_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Glyph *object = NULL; + Data_Get_Struct( self, sf::Glyph, object ); + sf::Glyph *source = NULL; + Data_Get_Struct( aSource, sf::Glyph, source ); + *object = *source; +} + void Init_Glyph( void ) { /* SFML namespace which contains the classes of this module. */ @@ -58,6 +67,10 @@ void Init_Glyph( void ) */ globalGlyphClass = rb_define_class_under( sfml, "Glyph", rb_cObject ); + // Instance methods + rb_define_method( globalGlyphClass, "initialize", Glyph_Initialize, 0 ); + rb_define_method( globalGlyphClass, "initialize_copy", Glyph_InitializeCopy, 1 ); + // Attribute accessors rb_define_attr( globalGlyphClass, "advance", 1, 1 ); rb_define_attr( globalGlyphClass, "bounds", 1, 1 ); diff --git a/bindings/ruby/sfml-graphics/graphics/Image.cpp b/bindings/ruby/sfml-graphics/graphics/Image.cpp index 9eac2521..e5d5e66d 100644 --- a/bindings/ruby/sfml-graphics/graphics/Image.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Image.cpp @@ -517,16 +517,25 @@ static VALUE Image_GetTexCoords( VALUE self, VALUE aRectangle ) rb_float_new( result.Width ), rb_float_new( result.Height ) ); } +static VALUE Image_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Image *object = NULL; + Data_Get_Struct( self, sf::Image, object ); + sf::Image *source = NULL; + Data_Get_Struct( aSource, sf::Image, source ); + *object = *source; +} + /* call-seq: * Image.new() -> image * * Creates an image instance for us. */ -static VALUE Image_New( VALUE aKlass ) +static VALUE Image_New( int argc, VALUE *args, VALUE aKlass ) { sf::Image *object = new sf::Image(); VALUE rbData = Data_Wrap_Struct( aKlass, 0, Image_Free, object ); - rb_obj_call_init( rbData, 0, 0 ); + rb_obj_call_init( rbData, argc, args ); return rbData; } @@ -592,10 +601,11 @@ void Init_Image( void ) globalImageClass = rb_define_class_under( sfml, "Image", rb_cObject ); // Class methods - rb_define_singleton_method( globalImageClass, "new", Image_New, 0 ); + rb_define_singleton_method( globalImageClass, "new", Image_New, -1 ); rb_define_singleton_method( globalImageClass, "getMaximumSize", Image_GetMaximumSize, 0 ); // Instance methods + rb_define_method( globalImageClass, "initialize_copy", Image_InitializeCopy, 1 ); rb_define_method( globalImageClass, "loadFromFile", Image_LoadFromFile, 1 ); rb_define_method( globalImageClass, "loadFromPixels", Image_LoadFromPixels, 3 ); rb_define_method( globalImageClass, "saveToFile", Image_SaveToFile, 1 ); diff --git a/bindings/ruby/sfml-graphics/graphics/Shader.cpp b/bindings/ruby/sfml-graphics/graphics/Shader.cpp index bcfe8a6b..4da50bc1 100644 --- a/bindings/ruby/sfml-graphics/graphics/Shader.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Shader.cpp @@ -215,6 +215,15 @@ static VALUE Shader_Unbind( VALUE self ) return Qnil; } +static VALUE Shader_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Shader *object = NULL; + Data_Get_Struct( self, sf::Shader, object ); + sf::Shader *source = NULL; + Data_Get_Struct( aSource, sf::Shader, source ); + *object = *source; +} + /* call-seq: * Shader.new() * @@ -316,6 +325,7 @@ void Init_Shader( void ) rb_define_const( globalShaderClass, "CurrentTexture", CreateCurrentTextureWrapper() ); // Instance methods + rb_define_method( globalShaderClass, "initialize_copy", Shader_InitializeCopy, 1 ); rb_define_method( globalShaderClass, "loadFromFile", Shader_LoadFromFile, 1 ); rb_define_method( globalShaderClass, "loadFromMemory", Shader_LoadFromMemory, 1 ); rb_define_method( globalShaderClass, "setParameter", Shader_SetParameter, -1 ); diff --git a/bindings/ruby/sfml-graphics/graphics/Shape.cpp b/bindings/ruby/sfml-graphics/graphics/Shape.cpp index f414a93a..0d8eeae2 100644 --- a/bindings/ruby/sfml-graphics/graphics/Shape.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Shape.cpp @@ -330,6 +330,15 @@ static VALUE Shape_GetOutlineWidth( VALUE self ) return rb_float_new( object->GetOutlineWidth() ); } +static VALUE Shape_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Shape *object = NULL; + Data_Get_Struct( self, sf::Shape, object ); + sf::Shape *source = NULL; + Data_Get_Struct( aSource, sf::Shape, source ); + *object = *source; +} + /* call-seq: * Shape.new() -> shape * @@ -643,6 +652,7 @@ void Init_Shape( void ) rb_define_singleton_method( globalShapeClass, "circle", Shape_Circle, -1 ); // Instance methods + rb_define_method( globalShapeClass, "initialize_copy", Shape_InitializeCopy, 1 ); rb_define_method( globalShapeClass, "addPoint", Shape_AddPoint, -1 ); rb_define_method( globalShapeClass, "getPointsCount", Shape_GetPointsCount, 0 ); rb_define_method( globalShapeClass, "enableFill", Shape_EnableFill, 1 ); diff --git a/bindings/ruby/sfml-graphics/graphics/Sprite.cpp b/bindings/ruby/sfml-graphics/graphics/Sprite.cpp index 9d9d05e9..6eefe05d 100644 --- a/bindings/ruby/sfml-graphics/graphics/Sprite.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Sprite.cpp @@ -88,6 +88,15 @@ static VALUE Sprite_Initialize( int argc, VALUE *args, VALUE self ) return self; } +static VALUE Sprite_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Sprite *object = NULL; + Data_Get_Struct( self, sf::Sprite, object ); + sf::Sprite *source = NULL; + Data_Get_Struct( aSource, sf::Sprite, source ); + *object = *source; +} + /* call-seq: * sprite.setImage( image, adjustToNewSize = false) * @@ -355,6 +364,7 @@ void Init_Sprite( void ) // Instance methods rb_define_method( globalSpriteClass, "initialize", Sprite_Initialize, -1 ); + rb_define_method( globalSpriteClass, "initialize_copy", Sprite_InitializeCopy, 1 ); rb_define_method( globalSpriteClass, "setImage", Sprite_SetImage, -1 ); rb_define_method( globalSpriteClass, "setSubRect", Sprite_SetSubRect, 1 ); rb_define_method( globalSpriteClass, "resize", Sprite_Resize, -1 ); diff --git a/bindings/ruby/sfml-graphics/graphics/Text.cpp b/bindings/ruby/sfml-graphics/graphics/Text.cpp index cc17188c..7d546930 100644 --- a/bindings/ruby/sfml-graphics/graphics/Text.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Text.cpp @@ -76,6 +76,15 @@ static VALUE Text_Initialize( int argc, VALUE *args, VALUE self ) return self; } +static VALUE Text_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Text *object = NULL; + Data_Get_Struct( self, sf::Text, object ); + sf::Text *source = NULL; + Data_Get_Struct( aSource, sf::Text, source ); + *object = *source; +} + /* call-seq: * text.setString( string ) * @@ -288,6 +297,7 @@ void Init_Text( void ) // Instance methods rb_define_method( globalTextClass, "initialize", Text_Initialize, -1 ); + rb_define_method( globalTextClass, "initialize_copy", Text_InitializeCopy, 1 ); rb_define_method( globalTextClass, "setString", Text_SetString, 1 ); rb_define_method( globalTextClass, "setFont", Text_SetFont, 1 ); rb_define_method( globalTextClass, "setCharacterSize", Text_SetCharacterSize, 1 ); diff --git a/bindings/ruby/sfml-graphics/graphics/View.cpp b/bindings/ruby/sfml-graphics/graphics/View.cpp index b646bd16..4bb17476 100644 --- a/bindings/ruby/sfml-graphics/graphics/View.cpp +++ b/bindings/ruby/sfml-graphics/graphics/View.cpp @@ -86,6 +86,15 @@ static VALUE View_Initialize( int argc, VALUE *args, VALUE self ) return self; } +static VALUE View_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::View *object = NULL; + Data_Get_Struct( self, sf::View, object ); + sf::View *source = NULL; + Data_Get_Struct( aSource, sf::View, source ); + *object = *source; +} + /* call-seq: * view.getCenter() -> vector2 * @@ -403,6 +412,7 @@ void Init_View( void ) // Instance methods rb_define_method( globalViewClass, "initialize", View_Initialize, -1 ); + rb_define_method( globalViewClass, "initialize_copy", View_InitializeCopy, 1 ); rb_define_method( globalViewClass, "setCenter", View_SetCenter, -1 ); rb_define_method( globalViewClass, "setSize", View_SetSize, -1 ); rb_define_method( globalViewClass, "setRotation", View_SetRotation, 1 ); diff --git a/bindings/ruby/sfml-system/system/Clock.cpp b/bindings/ruby/sfml-system/system/Clock.cpp index 9a5fe074..8f445e28 100644 --- a/bindings/ruby/sfml-system/system/Clock.cpp +++ b/bindings/ruby/sfml-system/system/Clock.cpp @@ -60,16 +60,26 @@ static VALUE Clock_Reset( VALUE self ) return Qnil; } +static VALUE Clock_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Clock *object = NULL; + Data_Get_Struct( self, sf::Clock, object ); + sf::Clock *source = NULL; + Data_Get_Struct( aSource, sf::Clock, source ); + *object = *source ; + return self; +} + /* call-seq: * Clock.new() -> clock * * The clock starts automatically after being constructed. */ -static VALUE Clock_New( 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 ); - rb_obj_call_init( rbData, 0, 0 ); + rb_obj_call_init( rbData, argc, args ); return rbData; } @@ -86,9 +96,10 @@ void Init_Clock( void ) globalClockClass = rb_define_class_under( sfml, "Clock", rb_cObject ); // Class methods - rb_define_singleton_method( globalClockClass, "new", Clock_New, 0 ); + rb_define_singleton_method( globalClockClass, "new", Clock_New, -1 ); // Instance methods + rb_define_method( globalClockClass, "initialize_copy", Clock_InitializeCopy, 1 ); rb_define_method( globalClockClass, "getElapsedTime", Clock_GetElapsedTime, 0 ); rb_define_method( globalClockClass, "reset", Clock_Reset, 0 ); diff --git a/bindings/ruby/sfml-window/window/ContextSettings.cpp b/bindings/ruby/sfml-window/window/ContextSettings.cpp index ddc790f1..22bbcfb2 100644 --- a/bindings/ruby/sfml-window/window/ContextSettings.cpp +++ b/bindings/ruby/sfml-window/window/ContextSettings.cpp @@ -156,6 +156,16 @@ static VALUE ContextSettings_SetMinorVersion( VALUE self, VALUE aValue ) return INT2FIX( object->MinorVersion = NUM2UINT( aValue ) ); } +static VALUE ContextSettings_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::ContextSettings *object = NULL; + Data_Get_Struct( self, sf::ContextSettings, object ); + sf::ContextSettings *source = NULL; + Data_Get_Struct( aSource, sf::ContextSettings, source ); + *object = *source; + return self; +} + /* call-seq: * ContextSettings.new( depth = 24, stencil = 8, antialiasing = 0, major = 2, minor = 0) -> settings * @@ -212,7 +222,7 @@ static VALUE ContextSettings_New( VALUE aKlass, VALUE someArgs ) } VALUE rbData = Data_Wrap_Struct( aKlass, 0, ContextSettings_Free, object ); - rb_obj_call_init( rbData, 0, 0 ); + rb_obj_call_init( rbData, argc, args ); return rbData; } @@ -251,6 +261,8 @@ void Init_ContextSettings( void ) rb_define_singleton_method( globalContextSettingsClass, "new", ContextSettings_New, -2 ); // Instance methods + rb_define_method( globalContextSettingsClass, "initialize_copy", ContextSettings_InitializeCopy, 1 ); + rb_define_method( globalContextSettingsClass, "depthBits", ContextSettings_GetDepth, 0 ); rb_define_method( globalContextSettingsClass, "depthBits=", ContextSettings_SetDepth, 1 ); diff --git a/bindings/ruby/sfml-window/window/Event.cpp b/bindings/ruby/sfml-window/window/Event.cpp index 8896fbdc..b1e59c5b 100644 --- a/bindings/ruby/sfml-window/window/Event.cpp +++ b/bindings/ruby/sfml-window/window/Event.cpp @@ -214,6 +214,16 @@ static VALUE Event_Initialize( VALUE self, VALUE aType ) } } +static VALUE Event_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::Event *object = NULL; + Data_Get_Struct( self, sf::Event, object ); + sf::Event *source = NULL; + Data_Get_Struct( aSource, sf::Event, source ); + *object = *source; + return Event_Initialize( VALUE self, INT2FIX( object->Type ) ); +} + /* call-seq: * Event.new(type) -> event * @@ -230,7 +240,6 @@ static VALUE Event_New( int argc, VALUE * args, VALUE aKlass ) return rbData; } - void Init_Event( void ) { /* SFML namespace which contains the classes of this module. */ @@ -302,6 +311,8 @@ void Init_Event( void ) // Instance methods rb_define_method( globalEventClass, "initialize", Event_Initialize, 1 ); + rb_define_method( globalEventClass, "initialize_copy", Event_InitializeCopy, 1 ); + rb_define_attr( globalEventClass, "type", 1, 0 ); rb_define_attr( globalEventClass, "joyButton", 1, 0 ); rb_define_attr( globalEventClass, "joyMove", 1, 0 ); diff --git a/bindings/ruby/sfml-window/window/VideoMode.cpp b/bindings/ruby/sfml-window/window/VideoMode.cpp index a53050f1..b90d6006 100644 --- a/bindings/ruby/sfml-window/window/VideoMode.cpp +++ b/bindings/ruby/sfml-window/window/VideoMode.cpp @@ -152,6 +152,15 @@ static VALUE VideoMode_IsValid( VALUE self ) return ( object->IsValid() == true ? Qtrue : Qfalse ); } +static VALUE VideoMode_InitializeCopy( VALUE self, VALUE aSource ) +{ + sf::VideoMode *object = NULL; + Data_Get_Struct( self, sf::VideoMode, object ); + sf::VideoMode *source = NULL; + Data_Get_Struct( aSource, sf::VideoMode, source ); + *object = *source; +} + /* call-seq: * VideoMode.getDesktopMode -> desktop_mode * @@ -260,6 +269,8 @@ void Init_VideoMode( void ) rb_define_singleton_method( globalVideoModeClass, "getFullscreenModes", VideoMode_GetFullscreenModes, 0 ); // Instance methods + rb_define_method( globalVideoModeClass, "initialize_copy", VideoMode_InitializeCopy, 1 ); + rb_define_method( globalVideoModeClass, "width", VideoMode_GetWidth, 0 ); rb_define_method( globalVideoModeClass, "width=", VideoMode_SetWidth, 1 );