Removed some stuff that wasn't needed any more in the window module

Also made the required changed for Rdoc to the system module and generated rdoc documentation for both modules.
It's safe to say now that rbSFML is available to be used for at least opening up a window and opengl context and render something in opengl.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1658 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
groogy 2010-11-16 16:26:00 +00:00
parent 13e9b006e7
commit 85a4e5155e
7 changed files with 83 additions and 72 deletions

View File

@ -24,7 +24,6 @@
#include "main.hpp" #include "main.hpp"
#include <SFML/System/Clock.hpp> #include <SFML/System/Clock.hpp>
/* Utility class for manipulating time. */
VALUE globalClockClass; VALUE globalClockClass;
/* Free a heap allocated object /* Free a heap allocated object
@ -76,14 +75,22 @@ static VALUE Clock_New( VALUE aKlass )
void Init_Clock( void ) void Init_Clock( void )
{ {
globalClockClass = rb_define_class_under( GetNamespace(), "Clock", rb_cObject ); /* SFML namespace which contains the classes of this module. */
VALUE sfml = rb_define_module( "SFML" );
/* Utility class for manipulating time.
*
* sf::Clock is a lightweight class for measuring time.
*
* Its resolution depends on the underlying OS, but you can generally expect a 1 ms resolution.
*/
globalClockClass = rb_define_class_under( sfml, "Clock", rb_cObject );
// Class methods // Class methods
rb_define_singleton_method( globalClockClass, "new", FUNCPTR( Clock_New ), 0 ); rb_define_singleton_method( globalClockClass, "new", Clock_New, 0 );
// Instance methods // Instance methods
rb_define_method( globalClockClass, "getElapsedTime", FUNCPTR( Clock_GetElapsedTime ), 0 ); rb_define_method( globalClockClass, "getElapsedTime", Clock_GetElapsedTime, 0 );
rb_define_method( globalClockClass, "reset", FUNCPTR( Clock_Reset ), 0 ); rb_define_method( globalClockClass, "reset", Clock_Reset, 0 );
// Aliases // Aliases
rb_define_alias( globalClockClass, "elapsedTime", "getElapsedTime" ); rb_define_alias( globalClockClass, "elapsedTime", "getElapsedTime" );

View File

@ -23,22 +23,6 @@
#include "Vector2.hpp" #include "Vector2.hpp"
#include "main.hpp" #include "main.hpp"
/* SFML::Vector2 is a simple class that defines a mathematical vector with two coordinates (x and y).
*
* It can be used to represent anything that has two dimensions: a size, a point, a velocity, etc.
*
* This class differs from the C++ version. It will accept any value that is Numeric and both x and y must be of the same class.
*
* v1 = SFML::Vector2.new(16.5, 24.0)
* v1.x = 18.2
* y = v1.y
*
* v2 = v1 * v1;
* v3 = SFML::Vector2.new
* v3 = v1 + v2
*
* different = (v2 != v3);
*/
VALUE globalVector2Class; VALUE globalVector2Class;
/* Internal function /* Internal function
@ -94,6 +78,7 @@ static void Vector2_internal_ValidateTypes( VALUE aFirst, VALUE aSecond )
} }
} }
/* */
static VALUE Vector2_Negate( VALUE self ) static VALUE Vector2_Negate( VALUE self )
{ {
VALUE x = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE x = rb_funcall( self, rb_intern( "x" ), 0 );
@ -103,6 +88,7 @@ static VALUE Vector2_Negate( VALUE self )
return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, negatedX, negatedY ); return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, negatedX, negatedY );
} }
/* */
static VALUE Vector2_Add( VALUE self, VALUE aRightOperand ) static VALUE Vector2_Add( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector2_ForceType( aRightOperand ); VALUE rightVector = Vector2_ForceType( aRightOperand );
@ -119,6 +105,7 @@ static VALUE Vector2_Add( VALUE self, VALUE aRightOperand )
return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, newX, newY ); return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, newX, newY );
} }
/* */
static VALUE Vector2_Subtract( VALUE self, VALUE aRightOperand ) static VALUE Vector2_Subtract( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector2_ForceType( aRightOperand ); VALUE rightVector = Vector2_ForceType( aRightOperand );
@ -135,6 +122,7 @@ static VALUE Vector2_Subtract( VALUE self, VALUE aRightOperand )
return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, newX, newY ); return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, newX, newY );
} }
/* */
static VALUE Vector2_Multiply( VALUE self, VALUE aRightOperand ) static VALUE Vector2_Multiply( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector2_ForceType( aRightOperand ); VALUE rightVector = Vector2_ForceType( aRightOperand );
@ -151,6 +139,7 @@ static VALUE Vector2_Multiply( VALUE self, VALUE aRightOperand )
return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, newX, newY ); return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, newX, newY );
} }
/* */
static VALUE Vector2_Divide( VALUE self, VALUE aRightOperand ) static VALUE Vector2_Divide( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector2_ForceType( aRightOperand ); VALUE rightVector = Vector2_ForceType( aRightOperand );
@ -167,6 +156,7 @@ static VALUE Vector2_Divide( VALUE self, VALUE aRightOperand )
return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, newX, newY ); return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, newX, newY );
} }
/* */
static VALUE Vector2_Equal( VALUE self, VALUE anArgument ) static VALUE Vector2_Equal( VALUE self, VALUE anArgument )
{ {
VALUE aVector = Vector2_ForceType( anArgument ); VALUE aVector = Vector2_ForceType( anArgument );
@ -186,6 +176,7 @@ static VALUE Vector2_Equal( VALUE self, VALUE anArgument )
} }
} }
/* */
static VALUE Vector2_StrictEqual( VALUE self, VALUE anArgument ) static VALUE Vector2_StrictEqual( VALUE self, VALUE anArgument )
{ {
VALUE aVector = Vector2_ForceType( anArgument ); VALUE aVector = Vector2_ForceType( anArgument );
@ -243,19 +234,37 @@ static VALUE Vector2_Initialize( VALUE self, VALUE someArgs )
void Init_Vector2( void ) void Init_Vector2( void )
{ {
globalVector2Class = rb_define_class_under( GetNamespace(), "Vector2", rb_cObject ); /* SFML namespace which contains the classes of this module. */
VALUE sfml = rb_define_module( "SFML" );
/* SFML::Vector2 is a simple class that defines a mathematical vector with two coordinates (x and y).
*
* It can be used to represent anything that has two dimensions: a size, a point, a velocity, etc.
*
* This class differs from the C++ version. It will accept any value that is Numeric and both x and y must be of the same class.
*
* v1 = SFML::Vector2.new(16.5, 24.0)
* v1.x = 18.2
* y = v1.y
*
* v2 = v1 * v1;
* v3 = SFML::Vector2.new
* v3 = v1 + v2
*
* different = (v2 != v3);
*/
globalVector2Class = rb_define_class_under( sfml, "Vector2", rb_cObject );
// Instance methods // Instance methods
rb_define_method( globalVector2Class, "initialize", FUNCPTR( Vector2_Initialize ), -2 ); rb_define_method( globalVector2Class, "initialize", Vector2_Initialize, -2 );
rb_define_method( globalVector2Class, "eql?", FUNCPTR( Vector2_Initialize ), 1 ); rb_define_method( globalVector2Class, "eql?", Vector2_StrictEqual, 1 );
// Instance operators // Instance operators
rb_define_method( globalVector2Class, "-@", FUNCPTR( Vector2_Negate ), 0 ); rb_define_method( globalVector2Class, "-@", Vector2_Negate, 0 );
rb_define_method( globalVector2Class, "+", FUNCPTR( Vector2_Add ), 1 ); rb_define_method( globalVector2Class, "+", Vector2_Add, 1 );
rb_define_method( globalVector2Class, "-", FUNCPTR( Vector2_Subtract ), 1 ); rb_define_method( globalVector2Class, "-", Vector2_Subtract, 1 );
rb_define_method( globalVector2Class, "*", FUNCPTR( Vector2_Multiply ), 1 ); rb_define_method( globalVector2Class, "*", Vector2_Multiply, 1 );
rb_define_method( globalVector2Class, "/", FUNCPTR( Vector2_Divide ), 1 ); rb_define_method( globalVector2Class, "/", Vector2_Divide, 1 );
rb_define_method( globalVector2Class, "==", FUNCPTR( Vector2_Divide ), 1 ); rb_define_method( globalVector2Class, "==", Vector2_Equal, 1 );
// Attribute accessors // Attribute accessors
rb_define_attr( globalVector2Class, "x", 1, 1 ); rb_define_attr( globalVector2Class, "x", 1, 1 );

View File

@ -23,22 +23,6 @@
#include "Vector3.hpp" #include "Vector3.hpp"
#include "main.hpp" #include "main.hpp"
/* SFML::Vector3 is a simple class that defines a mathematical vector with three coordinates (x, y and z).
*
* It can be used to represent anything that has three dimensions: a size, a point, a velocity, etc.
*
* This class differs from the C++ version. It will accept any value that is Numeric and both x, y an z must be of the same class.
*
* v1 = SFML::Vector3.new(16.5, 24.0, -8.2)
* v1.z = 18.2
* y = v1.y
*
* v2 = v1 * v1;
* v3 = SFML::Vector3.new
* v3 = v1 + v2
*
* different = (v2 != v3);
*/
VALUE globalVector3Class; VALUE globalVector3Class;
/* Internal function /* Internal function
@ -97,6 +81,7 @@ static void Vector3_internal_ValidateTypes( VALUE aFirst, VALUE aSecond, VALUE a
} }
} }
/* */
static VALUE Vector3_Negate( VALUE self ) static VALUE Vector3_Negate( VALUE self )
{ {
VALUE x = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE x = rb_funcall( self, rb_intern( "x" ), 0 );
@ -108,6 +93,7 @@ static VALUE Vector3_Negate( VALUE self )
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, negatedX, negatedY, negatedZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, negatedX, negatedY, negatedZ );
} }
/* */
static VALUE Vector3_Add( VALUE self, VALUE aRightOperand ) static VALUE Vector3_Add( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector3_ForceType( aRightOperand ); VALUE rightVector = Vector3_ForceType( aRightOperand );
@ -127,6 +113,7 @@ static VALUE Vector3_Add( VALUE self, VALUE aRightOperand )
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ );
} }
/* */
static VALUE Vector3_Subtract( VALUE self, VALUE aRightOperand ) static VALUE Vector3_Subtract( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector3_ForceType( aRightOperand ); VALUE rightVector = Vector3_ForceType( aRightOperand );
@ -146,6 +133,7 @@ static VALUE Vector3_Subtract( VALUE self, VALUE aRightOperand )
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ );
} }
/* */
static VALUE Vector3_Multiply( VALUE self, VALUE aRightOperand ) static VALUE Vector3_Multiply( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector3_ForceType( aRightOperand ); VALUE rightVector = Vector3_ForceType( aRightOperand );
@ -165,6 +153,7 @@ static VALUE Vector3_Multiply( VALUE self, VALUE aRightOperand )
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ );
} }
/* */
static VALUE Vector3_Divide( VALUE self, VALUE aRightOperand ) static VALUE Vector3_Divide( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector3_ForceType( aRightOperand ); VALUE rightVector = Vector3_ForceType( aRightOperand );
@ -184,6 +173,7 @@ static VALUE Vector3_Divide( VALUE self, VALUE aRightOperand )
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ );
} }
/* */
static VALUE Vector3_Equal( VALUE self, VALUE anArgument ) static VALUE Vector3_Equal( VALUE self, VALUE anArgument )
{ {
VALUE aVector = Vector3_ForceType( anArgument ); VALUE aVector = Vector3_ForceType( anArgument );
@ -206,6 +196,7 @@ static VALUE Vector3_Equal( VALUE self, VALUE anArgument )
} }
} }
/* */
static VALUE Vector3_StrictEqual( VALUE self, VALUE anArgument ) static VALUE Vector3_StrictEqual( VALUE self, VALUE anArgument )
{ {
VALUE aVector = Vector3_ForceType( anArgument ); VALUE aVector = Vector3_ForceType( anArgument );
@ -269,19 +260,37 @@ static VALUE Vector3_Initialize( VALUE self, VALUE someArgs )
void Init_Vector3( void ) void Init_Vector3( void )
{ {
globalVector3Class = rb_define_class_under( GetNamespace(), "Vector3", rb_cObject ); /* SFML namespace which contains the classes of this module. */
VALUE sfml = rb_define_module( "SFML" );
/* SFML::Vector3 is a simple class that defines a mathematical vector with three coordinates (x, y and z).
*
* It can be used to represent anything that has three dimensions: a size, a point, a velocity, etc.
*
* This class differs from the C++ version. It will accept any value that is Numeric and both x, y an z must be of the same class.
*
* v1 = SFML::Vector3.new(16.5, 24.0, -8.2)
* v1.z = 18.2
* y = v1.y
*
* v2 = v1 * v1;
* v3 = SFML::Vector3.new
* v3 = v1 + v2
*
* different = (v2 != v3);
*/
globalVector3Class = rb_define_class_under( sfml, "Vector3", rb_cObject );
// Instance methods // Instance methods
rb_define_method( globalVector3Class, "initialize", FUNCPTR( Vector3_Initialize ), -2 ); rb_define_method( globalVector3Class, "initialize", Vector3_Initialize, -2 );
rb_define_method( globalVector3Class, "eql?", FUNCPTR( Vector3_Initialize ), 1 ); rb_define_method( globalVector3Class, "eql?", Vector3_StrictEqual, 1 );
// Instance operators // Instance operators
rb_define_method( globalVector3Class, "-@", FUNCPTR( Vector3_Negate ), 0 ); rb_define_method( globalVector3Class, "-@", Vector3_Negate, 0 );
rb_define_method( globalVector3Class, "+", FUNCPTR( Vector3_Add ), 1 ); rb_define_method( globalVector3Class, "+", Vector3_Add, 1 );
rb_define_method( globalVector3Class, "-", FUNCPTR( Vector3_Subtract ), 1 ); rb_define_method( globalVector3Class, "-", Vector3_Subtract, 1 );
rb_define_method( globalVector3Class, "*", FUNCPTR( Vector3_Multiply ), 1 ); rb_define_method( globalVector3Class, "*", Vector3_Multiply, 1 );
rb_define_method( globalVector3Class, "/", FUNCPTR( Vector3_Divide ), 1 ); rb_define_method( globalVector3Class, "/", Vector3_Divide, 1 );
rb_define_method( globalVector3Class, "==", FUNCPTR( Vector3_Divide ), 1 ); rb_define_method( globalVector3Class, "==", Vector3_Equal, 1 );
// Attribute accessors // Attribute accessors
rb_define_attr( globalVector3Class, "x", 1, 1 ); rb_define_attr( globalVector3Class, "x", 1, 1 );

View File

@ -27,13 +27,9 @@
VALUE globalSFMLNamespace; VALUE globalSFMLNamespace;
VALUE GetNamespace( void )
{
return globalSFMLNamespace;
}
void Init_system( void ) void Init_system( void )
{ {
/* SFML namespace which contains the classes of this module. */
globalSFMLNamespace = rb_define_module( "SFML" ); globalSFMLNamespace = rb_define_module( "SFML" );
rb_define_const(globalSFMLNamespace, "SystemLoaded", Qtrue); rb_define_const(globalSFMLNamespace, "SystemLoaded", Qtrue);
Init_Clock(); Init_Clock();

View File

@ -25,13 +25,12 @@
#include "ruby.h" #include "ruby.h"
VALUE GetNamespace( void );
// Ruby initiation function // Ruby initiation function
extern "C" void Init_system( void ); extern "C" void Init_system( void );
typedef VALUE ( *RubyFunctionPtr )( ... ); typedef VALUE ( *RubyFunctionPtr )( ... );
#define FUNCPTR( x ) ( reinterpret_cast< RubyFunctionPtr >( x ) ) #define rb_define_singleton_method( klass, name, func, argc, ... ) rb_define_singleton_method( klass, name, reinterpret_cast< RubyFunctionPtr >( func ), argc, ##__VA_ARGS__ )
#define rb_define_method( klass, name, func, argc, ... ) rb_define_method( klass, name, reinterpret_cast< RubyFunctionPtr >( func ), argc, ##__VA_ARGS__ )
#endif // SFML_RUBYEXT_MAIN_HEADER_ #endif // SFML_RUBYEXT_MAIN_HEADER_

View File

@ -42,11 +42,6 @@ VALUE globalStyleNamespace;
/* External classes */ /* External classes */
VALUE globalVector2Class; VALUE globalVector2Class;
VALUE GetNamespace( void )
{
return globalSFMLNamespace;
}
static const char * keyNamesMisc[] = static const char * keyNamesMisc[] =
{ {
"Escape", "LControl", "LShift", "LAlt", "LSystem", "RControl", "RShift", "RAlt", "RSystem", "Escape", "LControl", "LShift", "LAlt", "LSystem", "RControl", "RShift", "RAlt", "RSystem",

View File

@ -25,10 +25,6 @@
#include "ruby.h" #include "ruby.h"
#define SFML_STATIC
VALUE GetNamespace( void );
// Ruby initiation function // Ruby initiation function
extern "C" void Init_window( void ); extern "C" void Init_window( void );