From 0aafc6b6ba46eef41500af13942fe964c1d456ce Mon Sep 17 00:00:00 2001 From: groogy Date: Sat, 4 Dec 2010 21:17:35 +0000 Subject: [PATCH] Added commentaries to all new initialize methods. Also moved the commentaries in SFML::Window from the Window_New function to Window_Initialize. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1746 4e206d99-4929-0410-ac5d-dfc041789085 --- bindings/ruby/sfml-audio/audio/Music.cpp | 7 +++++-- .../ruby/sfml-audio/audio/SoundBuffer.cpp | 11 ++++++++++ bindings/ruby/sfml-graphics/graphics/Font.cpp | 8 ++++++++ .../ruby/sfml-graphics/graphics/Image.cpp | 10 ++++++++++ .../sfml-graphics/graphics/RenderImage.cpp | 8 ++++++++ .../ruby/sfml-graphics/graphics/Shader.cpp | 9 ++++++++- bindings/ruby/sfml-window/window/Window.cpp | 20 +++++++++---------- 7 files changed, 60 insertions(+), 13 deletions(-) diff --git a/bindings/ruby/sfml-audio/audio/Music.cpp b/bindings/ruby/sfml-audio/audio/Music.cpp index 19a74009..a97cdd1b 100644 --- a/bindings/ruby/sfml-audio/audio/Music.cpp +++ b/bindings/ruby/sfml-audio/audio/Music.cpp @@ -58,9 +58,12 @@ static VALUE Music_OpenFromFile( VALUE self, VALUE aFilename ) } /* call-seq: - * Music.new() -> music + * Music.new() -> music + * Music.new( filename ) -> music * - * Creates a new music instance. + * Will create a new music instance. + * + * If a filename argument is specified then music#openFromFile will be called on the created instance. */ static VALUE Music_Initialize( int argc, VALUE *args, VALUE self ) { diff --git a/bindings/ruby/sfml-audio/audio/SoundBuffer.cpp b/bindings/ruby/sfml-audio/audio/SoundBuffer.cpp index 34ac3ca2..d296885b 100644 --- a/bindings/ruby/sfml-audio/audio/SoundBuffer.cpp +++ b/bindings/ruby/sfml-audio/audio/SoundBuffer.cpp @@ -193,6 +193,17 @@ static VALUE SoundBuffer_GetDuration( VALUE self ) return rb_float_new( object->GetDuration() ); } +/* call-seq: + * SoundBuffer.new() -> sound_buffer + * SoundBuffer.new( filename ) -> sound_buffer + * SoundBuffer.new( samples, samplesCount, channelsCount, sampleRate ) -> sound_buffer + * + * Will create a new sound buffer instance. + * + * If a filename argument is specified then sound_buffer#loadFromFile will be called on the created instance. If + * samples, samplesCount, channelsCount and sampleRate are specified then image#loadFromPixels will be called on the + * created instance. + */ static VALUE SoundBuffer_Initialize( int argc, VALUE *args, VALUE self ) { if( argc > 1 ) diff --git a/bindings/ruby/sfml-graphics/graphics/Font.cpp b/bindings/ruby/sfml-graphics/graphics/Font.cpp index 7f654705..c434c2c5 100644 --- a/bindings/ruby/sfml-graphics/graphics/Font.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Font.cpp @@ -130,6 +130,14 @@ static VALUE Font_GetImage( VALUE self, VALUE aCharacterSize ) return rbImage; } +/* call-seq: + * Font.new() -> font + * Font.new( filename ) -> font + * + * Will create a new font instance. + * + * If a filename argument is specified then font#loadFromFile will be called on the created instance. + */ static VALUE Font_Initialize( int argc, VALUE *args, VALUE self ) { if( argc > 0 ) diff --git a/bindings/ruby/sfml-graphics/graphics/Image.cpp b/bindings/ruby/sfml-graphics/graphics/Image.cpp index f007f809..d9ff99c4 100644 --- a/bindings/ruby/sfml-graphics/graphics/Image.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Image.cpp @@ -517,6 +517,16 @@ static VALUE Image_GetTexCoords( VALUE self, VALUE aRectangle ) rb_float_new( result.Width ), rb_float_new( result.Height ) ); } +/* call-seq: + * Image.new() -> image + * Image.new( filename ) -> image + * Image.new( width, height, pixels ) -> image + * + * Will create a new image instance. + * + * If a filename argument is specified then image#loadFromFile will be called on the created instance. If width, height + * and pixels are specified then image#loadFromPixels will be called on the created instance. + */ static VALUE Image_Initialize( int argc, VALUE *args, VALUE self ) { if( argc > 1 ) diff --git a/bindings/ruby/sfml-graphics/graphics/RenderImage.cpp b/bindings/ruby/sfml-graphics/graphics/RenderImage.cpp index 1d611728..b566194c 100644 --- a/bindings/ruby/sfml-graphics/graphics/RenderImage.cpp +++ b/bindings/ruby/sfml-graphics/graphics/RenderImage.cpp @@ -283,6 +283,14 @@ static VALUE RenderImage_GetHeight( VALUE self ) return INT2FIX( object->GetHeight() ); } +/* call-seq: + * RenderImage.new() -> render_image + * RenderImage.new( width, height, depthBuffer = false ) -> render_image + * + * Will create a new render image instance. + * + * If any arguments are specified then a call to the #create method will be made passing the arguments to it. + */ static VALUE RenderImage_Initialize( int argc, VALUE *args, VALUE self ) { if( argc > 0 ) diff --git a/bindings/ruby/sfml-graphics/graphics/Shader.cpp b/bindings/ruby/sfml-graphics/graphics/Shader.cpp index eb588d0f..92c1f859 100644 --- a/bindings/ruby/sfml-graphics/graphics/Shader.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Shader.cpp @@ -215,7 +215,14 @@ static VALUE Shader_Unbind( VALUE self ) return Qnil; } - +/* call-seq: + * Shader.new() -> shader + * Shader.new( filename ) -> shader + * + * Will create a new shader instance. + * + * If a filename argument is specified then shader#loadFromFile will be called on the created instance. + */ static VALUE Shader_Initialize( int argc, VALUE *args, VALUE self ) { if( argc > 0 ) diff --git a/bindings/ruby/sfml-window/window/Window.cpp b/bindings/ruby/sfml-window/window/Window.cpp index 24f85f80..d081c1ff 100644 --- a/bindings/ruby/sfml-window/window/Window.cpp +++ b/bindings/ruby/sfml-window/window/Window.cpp @@ -595,17 +595,8 @@ static VALUE Window_WaitEvent( VALUE self ) } } -static VALUE Window_Initialize( int argc, VALUE *args, VALUE self ) -{ - if( argc > 0 ) - { - rb_funcall2( self, rb_intern( "create" ), argc, args ); - } - return self; -} - /* call-seq: - * Window.new() -> window + * Window.new() -> window * Window.new( mode, title, style = SFML::Style::Default, settings = SFML::ContextSettings.new ) -> window * * Construct a new window. @@ -620,6 +611,15 @@ static VALUE Window_Initialize( int argc, VALUE *args, VALUE self ) * The fourth parameter is an optional structure specifying advanced OpenGL context settings such as antialiasing, * depth-buffer bits, etc. You shouldn't care about these parameters for a regular usage of the graphics module. */ +static VALUE Window_Initialize( int argc, VALUE *args, VALUE self ) +{ + if( argc > 0 ) + { + rb_funcall2( self, rb_intern( "create" ), argc, args ); + } + return self; +} + static VALUE Window_New( int argc, VALUE *args, VALUE aKlass ) { sf::Window *object = new sf::Window();