From 30865b6ef9df8dd6ed3e5a067488788d66cfe06b Mon Sep 17 00:00:00 2001 From: groogy Date: Fri, 3 Dec 2010 14:12:16 +0000 Subject: [PATCH] Made the classes that is non-copyable in the C++ library also non-copyable in rbSFML. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1738 4e206d99-4929-0410-ac5d-dfc041789085 --- bindings/ruby/sfml-audio/audio/SoundRecorder.cpp | 4 ++++ bindings/ruby/sfml-audio/audio/SoundStream.cpp | 2 ++ bindings/ruby/sfml-audio/audio/main.cpp | 2 ++ bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp | 4 +++- bindings/ruby/sfml-graphics/graphics/Renderer.cpp | 2 ++ bindings/ruby/sfml-graphics/graphics/main.cpp | 2 ++ bindings/ruby/sfml-window/window/Context.cpp | 4 ++++ bindings/ruby/sfml-window/window/Input.cpp | 4 ++++ bindings/ruby/sfml-window/window/Window.cpp | 2 ++ bindings/ruby/sfml-window/window/main.cpp | 2 ++ 10 files changed, 27 insertions(+), 1 deletion(-) diff --git a/bindings/ruby/sfml-audio/audio/SoundRecorder.cpp b/bindings/ruby/sfml-audio/audio/SoundRecorder.cpp index 2501efea..583f13c8 100644 --- a/bindings/ruby/sfml-audio/audio/SoundRecorder.cpp +++ b/bindings/ruby/sfml-audio/audio/SoundRecorder.cpp @@ -26,6 +26,9 @@ VALUE globalSoundRecorderClass; +/* External classes */ +extern VALUE globalNonCopyableModule; + class rbSoundRecorder : public sf::SoundRecorder { public: @@ -244,6 +247,7 @@ void Init_SoundRecorder( void ) * end */ globalSoundRecorderClass = rb_define_class_under( sfml, "SoundRecorder", rb_cObject ); + rb_include_module( globalSoundRecorderClass, globalNonCopyableModule ); // Class methods rb_define_singleton_method( globalSoundRecorderClass, "new", SoundRecorder_New, -1 ); diff --git a/bindings/ruby/sfml-audio/audio/SoundStream.cpp b/bindings/ruby/sfml-audio/audio/SoundStream.cpp index c5a64a14..50cdcf8b 100644 --- a/bindings/ruby/sfml-audio/audio/SoundStream.cpp +++ b/bindings/ruby/sfml-audio/audio/SoundStream.cpp @@ -28,6 +28,7 @@ VALUE globalSoundStreamClass; /* External classes */ extern VALUE globalSoundSourceClass; +extern VALUE globalNonCopyableModule; class rbSoundStream : public sf::SoundStream { @@ -357,6 +358,7 @@ void Init_SoundStream( void ) * stream.play */ globalSoundStreamClass = rb_define_class_under( sfml, "SoundStream", globalSoundSourceClass ); + rb_include_module( globalSoundStreamClass, globalNonCopyableModule ); // Class methods rb_define_singleton_method( globalSoundStreamClass, "new", SoundStream_New, -1 ); diff --git a/bindings/ruby/sfml-audio/audio/main.cpp b/bindings/ruby/sfml-audio/audio/main.cpp index 71e83ba7..aa2aea92 100644 --- a/bindings/ruby/sfml-audio/audio/main.cpp +++ b/bindings/ruby/sfml-audio/audio/main.cpp @@ -27,6 +27,7 @@ VALUE globalSFMLNamespace; /* External classes */ VALUE globalVector2Class; VALUE globalVector3Class; +VALUE globalNonCopyableModule; static bool CheckDependencies( void ) { @@ -48,5 +49,6 @@ void Init_audio( void ) } globalVector2Class = RetrieveSFMLClass( "Vector2" ); globalVector3Class = RetrieveSFMLClass( "Vector3" ); + globalNonCopyableModule = RetrieveSFMLClass( "NonCopyable" ); rb_define_const(globalSFMLNamespace, "AudioLoaded", Qtrue); } diff --git a/bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp b/bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp index 5d8276f8..f1a721a8 100644 --- a/bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp +++ b/bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp @@ -37,6 +37,7 @@ extern VALUE globalRectClass; extern VALUE globalDrawableModule; extern VALUE globalShaderClass; extern VALUE globalViewClass; +extern VALUE globalNonCopyableModule; static VALUE View_Free( sf::View *anObject ) { @@ -323,7 +324,8 @@ void Init_RenderTarget( void ) * classes that inherits from sf::RenderTarget(sf::RenderWindow, sf::RenderImage) and you will only use it as the * first argument in the SFML::Drawable#render method. */ - globalRenderTargetModule = rb_define_module_under( sfml, "RenderTarget" ); + globalRenderTargetModule = rb_define_module_under( sfml, "RenderTarget" ); + rb_include_module( globalRenderTargetModule, globalNonCopyableModule ); globalRenderTargetInstanceClass = rb_define_class_under( globalRenderTargetModule, "Instance", rb_cObject ); rb_include_module( globalRenderTargetInstanceClass, globalRenderTargetModule ); diff --git a/bindings/ruby/sfml-graphics/graphics/Renderer.cpp b/bindings/ruby/sfml-graphics/graphics/Renderer.cpp index a76675db..1241af93 100644 --- a/bindings/ruby/sfml-graphics/graphics/Renderer.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Renderer.cpp @@ -32,6 +32,7 @@ VALUE globalRendererClass; extern VALUE globalColorClass; extern VALUE globalImageClass; extern VALUE globalShaderClass; +extern VALUE globalNonCopyableModule; /* call-seq: * renderer.saveGLStates() @@ -336,6 +337,7 @@ void Init_Renderer( void ) * SFML::Drawable class that uses raw geometry in its Render function. */ globalRendererClass = rb_define_class_under( sfml, "Renderer", rb_cObject ); + rb_include_module( globalRendererClass, globalNonCopyableModule ); DefinePrimitiveTypesEnum(); // Instance methods diff --git a/bindings/ruby/sfml-graphics/graphics/main.cpp b/bindings/ruby/sfml-graphics/graphics/main.cpp index 255a7543..48ccd48e 100644 --- a/bindings/ruby/sfml-graphics/graphics/main.cpp +++ b/bindings/ruby/sfml-graphics/graphics/main.cpp @@ -46,6 +46,7 @@ VALUE globalBlendNamespace; VALUE globalVector2Class; VALUE globalVector3Class; VALUE globalWindowClass; +VALUE globalNonCopyableModule; static bool CheckDependencies( void ) { @@ -78,6 +79,7 @@ void Init_graphics( void ) globalVector2Class = RetrieveSFMLClass( "Vector2" ); globalVector3Class = RetrieveSFMLClass( "Vector3" ); globalWindowClass = RetrieveSFMLClass( "Window" ); + globalNonCopyableModule = RetrieveSFMLClass( "NonCopyable" ); rb_define_const(globalSFMLNamespace, "GraphicsLoaded", Qtrue); CreateBlendEnum(); diff --git a/bindings/ruby/sfml-window/window/Context.cpp b/bindings/ruby/sfml-window/window/Context.cpp index d61a7ea3..6aa67fe5 100644 --- a/bindings/ruby/sfml-window/window/Context.cpp +++ b/bindings/ruby/sfml-window/window/Context.cpp @@ -26,6 +26,9 @@ VALUE globalContextClass; +/* External classes */ +extern VALUE globalNonCopyableModule; + /* Free a heap allocated object * Not accessible trough ruby directly! */ @@ -109,6 +112,7 @@ void Init_Context( void ) * the attached resources. */ globalContextClass = rb_define_class_under( sfml, "Context", rb_cObject ); + rb_include_module( globalContextClass, globalNonCopyableModule ); // Class methods rb_define_singleton_method( globalContextClass, "new", Context_New, 0 ); diff --git a/bindings/ruby/sfml-window/window/Input.cpp b/bindings/ruby/sfml-window/window/Input.cpp index d21b519f..0a52b69b 100644 --- a/bindings/ruby/sfml-window/window/Input.cpp +++ b/bindings/ruby/sfml-window/window/Input.cpp @@ -26,6 +26,9 @@ VALUE globalInputClass; +/* External classes */ +extern VALUE globalNonCopyableModule; + /* Free a heap allocated object * Not accessible trough ruby directly! */ @@ -178,6 +181,7 @@ void Init_Input( void ) * entity.move( 0, offset ) if input.keyDown?( SFML::Key::Down ) */ globalInputClass = rb_define_class_under( sfml, "Input", rb_cObject ); + rb_include_module( globalInputClass, globalNonCopyableModule ); // Class methods rb_define_singleton_method( globalInputClass, "new", Input_New, -1 ); diff --git a/bindings/ruby/sfml-window/window/Window.cpp b/bindings/ruby/sfml-window/window/Window.cpp index e70c8140..24f85f80 100644 --- a/bindings/ruby/sfml-window/window/Window.cpp +++ b/bindings/ruby/sfml-window/window/Window.cpp @@ -34,6 +34,7 @@ extern VALUE globalContextSettingsClass; extern VALUE globalEventClass; extern VALUE globalInputClass; extern VALUE globalVector2Class; +extern VALUE globalNonCopyableModule; /* Free a heap allocated object * Not accessible trough ruby directly! @@ -676,6 +677,7 @@ void Init_Window( void ) * end */ globalWindowClass = rb_define_class_under( sfml, "Window", rb_cObject ); + rb_include_module( globalWindowClass, globalNonCopyableModule ); // Class methods rb_define_singleton_method( globalWindowClass, "new", Window_New , -1 ); diff --git a/bindings/ruby/sfml-window/window/main.cpp b/bindings/ruby/sfml-window/window/main.cpp index 9ba82559..3f689577 100644 --- a/bindings/ruby/sfml-window/window/main.cpp +++ b/bindings/ruby/sfml-window/window/main.cpp @@ -41,6 +41,7 @@ VALUE globalStyleNamespace; /* External classes */ VALUE globalVector2Class; +VALUE globalNonCopyableModule; static const char * keyNamesMisc[] = { @@ -162,6 +163,7 @@ void Init_window( void ) } globalVector2Class = RetrieveSFMLClass( "Vector2" ); + globalNonCopyableModule = RetrieveSFMLClass( "NonCopyable" ); rb_define_const( globalSFMLNamespace, "WindowLoaded", Qtrue );