From da2cec5a9f1aa4e92233fd853d527846d6d69105 Mon Sep 17 00:00:00 2001 From: groogy Date: Tue, 16 Nov 2010 09:04:35 +0000 Subject: [PATCH] Added support for external classes from sfml-system and the ability to include them. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1652 4e206d99-4929-0410-ac5d-dfc041789085 --- bindings/ruby/sfml-window/window/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bindings/ruby/sfml-window/window/main.cpp b/bindings/ruby/sfml-window/window/main.cpp index ae7087e0..eba1f63c 100644 --- a/bindings/ruby/sfml-window/window/main.cpp +++ b/bindings/ruby/sfml-window/window/main.cpp @@ -38,6 +38,9 @@ VALUE globalMouseNamespace; VALUE globalJoyNamespace; VALUE globalStyleNamespace; +/* External classes */ +VALUE globalVector2Class; + VALUE GetNamespace( void ) { return globalSFMLNamespace; @@ -135,6 +138,22 @@ bool CheckDependencies( void ) return false; } +VALUE RetrieveSFMLClass( const char * aName ) +{ + ID name = rb_intern( aName ); + if( rb_cvar_defined( globalSFMLNamespace, name ) == Qfalse ) + { + rb_raise( rb_eRuntimeError, "This module depends on SFML::%s", aName ); + } + + return rb_cvar_get( globalSFMLNamespace, name ); +} + +void RetrieveVector2Class( void ) +{ + globalVector2Class = RetrieveSFMLClass( "Vector2" ); +} + void Init_window( void ) { globalSFMLNamespace = rb_define_module( "SFML" ); @@ -143,6 +162,8 @@ void Init_window( void ) rb_raise( rb_eRuntimeError, "This module depends on sfml-system" ); } + RetrieveVector2Class(); + rb_define_const( globalSFMLNamespace, "WindowLoaded", Qtrue ); CreateKeyEnum();