Some refactoring, moved C++ allocation into the *_Alloc function instead of directly in new, removed new in most of classes too. Cloning should work on all copyable classes now.
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1802 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
0a2abc6933
commit
7d7c4c999f
26 changed files with 235 additions and 301 deletions
|
@ -529,18 +529,28 @@ static VALUE Drawable_Initialize( int argc, VALUE *args, VALUE self )
|
|||
return rb_call_super( argc, args );
|
||||
}
|
||||
|
||||
static VALUE Drawable_New( int argc, VALUE *args, VALUE aKlass )
|
||||
|
||||
static VALUE Drawable_InitializeCopy( VALUE self, VALUE aSource )
|
||||
{
|
||||
sf::Drawable *selfDrawable = NULL;
|
||||
Data_Get_Struct( self, sf::Drawable, selfDrawable );
|
||||
sf::Drawable *sourceDrawable = NULL;
|
||||
Data_Get_Struct( aSource, sf::Drawable, sourceDrawable );
|
||||
*selfDrawable = *sourceDrawable;
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE Drawable_Allocate( VALUE aKlass )
|
||||
{
|
||||
rbDrawable *object = new rbDrawable();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, Drawable_Free, object );
|
||||
object->Init( rbData );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
}
|
||||
|
||||
static VALUE Drawable_Included( VALUE aModule, VALUE aBase )
|
||||
{
|
||||
rb_define_singleton_method( aBase, "new", Drawable_New, -1 );
|
||||
rb_define_singleton_method( aBase, "allocate", Drawable_Allocate, 0 );
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -615,6 +625,7 @@ void Init_Drawable( void )
|
|||
|
||||
// Instance methods
|
||||
rb_define_method( globalDrawableModule, "initialize", Drawable_Initialize, -1 );
|
||||
rb_define_method( globalDrawableModule, "initialize_copy", Drawable_Initialize, 1 );
|
||||
rb_define_method( globalDrawableModule, "setPosition", Drawable_SetPosition, -1 );
|
||||
rb_define_method( globalDrawableModule, "setX", Drawable_SetX, 1 );
|
||||
rb_define_method( globalDrawableModule, "setY", Drawable_SetY, 1 );
|
||||
|
|
|
@ -156,17 +156,10 @@ static VALUE Font_InitializeCopy( VALUE self, VALUE aSource )
|
|||
*object = *source;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* Font.new() -> font
|
||||
*
|
||||
* Creates an empty font
|
||||
*/
|
||||
static VALUE Font_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE Font_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::Font *object = new sf::Font();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, Font_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, Font_Free, object );
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
|
@ -241,7 +234,8 @@ void Init_Font( void )
|
|||
globalFontClass = rb_define_class_under( sfml, "Font", rb_cObject );
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalFontClass, "new", Font_New, -1 );
|
||||
//rb_define_singleton_method( globalFontClass, "new", Font_New, -1 );
|
||||
rb_define_alloc_func( globalFontClass, Font_Alloc );
|
||||
rb_define_singleton_method( globalFontClass, "getDefaultFont", Font_GetDefaultFont, 0 );
|
||||
|
||||
// Instance methods
|
||||
|
|
|
@ -43,15 +43,6 @@ 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. */
|
||||
|
@ -70,7 +61,6 @@ void Init_Glyph( void )
|
|||
|
||||
// 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 );
|
||||
|
|
|
@ -524,8 +524,8 @@ static VALUE Image_GetTexCoords( VALUE self, VALUE aRectangle )
|
|||
*
|
||||
* 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.
|
||||
* 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 )
|
||||
{
|
||||
|
@ -549,17 +549,10 @@ static VALUE Image_InitializeCopy( VALUE self, VALUE aSource )
|
|||
*object = *source;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* Image.new() -> image
|
||||
*
|
||||
* Creates an image instance for us.
|
||||
*/
|
||||
static VALUE Image_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE Image_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::Image *object = new sf::Image();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, Image_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, Image_Free, object );
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
|
@ -624,7 +617,8 @@ void Init_Image( void )
|
|||
globalImageClass = rb_define_class_under( sfml, "Image", rb_cObject );
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalImageClass, "new", Image_New, -1 );
|
||||
//rb_define_singleton_method( globalImageClass, "new", Image_New, -1 );
|
||||
rb_define_alloc_func( globalImageClass, Image_Alloc );
|
||||
rb_define_singleton_method( globalImageClass, "getMaximumSize", Image_GetMaximumSize, 0 );
|
||||
|
||||
// Instance methods
|
||||
|
|
|
@ -300,17 +300,10 @@ static VALUE RenderImage_Initialize( int argc, VALUE *args, VALUE self )
|
|||
return self;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* RenderImage.new() -> render_image
|
||||
*
|
||||
* Constructs an empty, invalid render-image. You must call create() to have a valid render-image.
|
||||
*/
|
||||
static VALUE RenderImage_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE RenderImage_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::RenderImage *object = new sf::RenderImage();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, RenderImage_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, RenderImage_Free, object );
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
|
@ -396,7 +389,8 @@ void Init_RenderImage( void )
|
|||
rb_include_module( globalRenderImageClass, globalRenderTargetModule );
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalRenderImageClass, "new", RenderImage_New, 0 );
|
||||
//rb_define_singleton_method( globalRenderImageClass, "new", RenderImage_New, 0 );
|
||||
rb_define_alloc_func( globalRenderImageClass, RenderImage_Alloc );
|
||||
rb_define_singleton_method( globalRenderImageClass, "isAvailable", RenderImage_IsAvailable, 0 );
|
||||
|
||||
// Instance methods
|
||||
|
|
|
@ -121,28 +121,10 @@ static VALUE RenderWindow_GetHeight( VALUE self )
|
|||
return INT2FIX( object->GetHeight() );
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* Window.new() -> render_window
|
||||
* Window.new( mode, title, style = SFML::Style::Default, settings = SFML::ContextSettings.new ) -> render_window
|
||||
*
|
||||
* Construct a new window.
|
||||
*
|
||||
* The first form of new doesn't actually create the visual window, use the other form of new or call
|
||||
* SFML::Window#create to do so.
|
||||
*
|
||||
* The second form of new creates the window with the size and pixel depth defined in mode. An optional style can be passed
|
||||
* to customize the look and behaviour of the window (borders, title bar, resizable, closable, ...). If style contains
|
||||
* Style::Fullscreen, then mode must be a valid video mode.
|
||||
*
|
||||
* 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 RenderWindow_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE RenderWindow_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::RenderWindow *object = new sf::RenderWindow();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, RenderWindow_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, RenderWindow_Free, object );
|
||||
}
|
||||
|
||||
void Init_RenderWindow( void )
|
||||
|
@ -236,7 +218,8 @@ void Init_RenderWindow( void )
|
|||
rb_include_module( globalRenderWindowClass, globalRenderTargetModule );
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalRenderWindowClass, "new", RenderWindow_New, -1 );
|
||||
//rb_define_singleton_method( globalRenderWindowClass, "new", RenderWindow_New, -1 );
|
||||
rb_define_alloc_func( globalRenderWindowClass, RenderWindow_Alloc );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalRenderWindowClass, "draw", RenderWindow_Draw, -1 );
|
||||
|
|
|
@ -246,12 +246,10 @@ static VALUE Shader_InitializeCopy( VALUE self, VALUE aSource )
|
|||
*
|
||||
* Create a new shader.
|
||||
*/
|
||||
static VALUE Shader_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE Shader_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::Shader *object = new sf::Shader();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, Shader_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, Shader_Free, object );
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
|
@ -335,7 +333,8 @@ void Init_Shader( void )
|
|||
globalShaderClass = rb_define_class_under( sfml, "Shader", rb_cObject );
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalShaderClass, "new", Shader_New, -1 );
|
||||
//rb_define_singleton_method( globalShaderClass, "new", Shader_New, -1 );
|
||||
rb_define_alloc_func( globalShaderClass, Shader_Alloc );
|
||||
rb_define_singleton_method( globalShaderClass, "isAvailable", Shader_IsAvailable, 0 );
|
||||
|
||||
// Class Constants
|
||||
|
|
|
@ -344,12 +344,10 @@ static VALUE Shape_InitializeCopy( VALUE self, VALUE aSource )
|
|||
*
|
||||
* Create an empty shape.
|
||||
*/
|
||||
static VALUE Shape_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE Shape_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::Shape *object = new sf::Shape();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, Shape_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, Shape_Free, object );
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
|
@ -646,7 +644,8 @@ void Init_Shape( void )
|
|||
rb_include_module( globalShapeClass, globalDrawableModule );
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalShapeClass, "new", Shape_New, -1 );
|
||||
//rb_define_singleton_method( globalShapeClass, "new", Shape_New, -1 );
|
||||
rb_define_alloc_func( globalShapeClass, Shape_Alloc );
|
||||
rb_define_singleton_method( globalShapeClass, "line", Shape_Line, -1 );
|
||||
rb_define_singleton_method( globalShapeClass, "rectangle", Shape_Rectangle, -1 );
|
||||
rb_define_singleton_method( globalShapeClass, "circle", Shape_Circle, -1 );
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* 3. This notice may not be removed or altered from any
|
||||
* source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "Sprite.hpp"
|
||||
#include "Vector2.hpp"
|
||||
#include "Rect.hpp"
|
||||
|
@ -44,7 +44,7 @@ static void Sprite_Free( sf::Sprite *anObject )
|
|||
* Sprite.new() -> sprite
|
||||
* Sprite.new( image, position = [0, 0], scale = [1, 1], rotation = 0.0, color = SFML::Color::White ) -> sprite
|
||||
*
|
||||
* Construct the sprite from a source image.
|
||||
* Construct the sprite from a source image.
|
||||
*/
|
||||
static VALUE Sprite_Initialize( int argc, VALUE *args, VALUE self )
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ static VALUE Sprite_Initialize( int argc, VALUE *args, VALUE self )
|
|||
sf::Vector2f scale = sf::Vector2f( 1, 1 );
|
||||
float rotation = 0;
|
||||
sf::Color color = sf::Color::White;
|
||||
|
||||
|
||||
sf::Sprite *object = NULL;
|
||||
Data_Get_Struct( self, sf::Sprite, object );
|
||||
switch( argc )
|
||||
|
@ -102,17 +102,17 @@ static VALUE Sprite_InitializeCopy( VALUE self, VALUE aSource )
|
|||
*
|
||||
* Change the source image of the sprite.
|
||||
*
|
||||
* The image argument refers to an image that must exist as long as the sprite uses it. Indeed, the sprite doesn't
|
||||
* store its own copy of the image, but rather keeps a pointer to the one that you passed to this function. If the
|
||||
* The image argument refers to an image that must exist as long as the sprite uses it. Indeed, the sprite doesn't
|
||||
* store its own copy of the image, but rather keeps a pointer to the one that you passed to this function. If the
|
||||
* source image is destroyed and the sprite tries to use it, it may appear as a white rectangle. If adjustToNewSize is
|
||||
* true, the SubRect property of the sprite is adjusted to the size of the new image. If it is false, the SubRect
|
||||
* true, the SubRect property of the sprite is adjusted to the size of the new image. If it is false, the SubRect
|
||||
* is unchanged.
|
||||
*/
|
||||
static VALUE Sprite_SetImage( int argc, VALUE *args, VALUE self )
|
||||
{
|
||||
sf::Image *image = NULL;
|
||||
bool adjustToNewSize = false;
|
||||
|
||||
|
||||
sf::Sprite *object = NULL;
|
||||
Data_Get_Struct( self, sf::Sprite, object );
|
||||
rb_iv_set( self, "@__image_ref", Qnil );
|
||||
|
@ -202,7 +202,7 @@ static VALUE Sprite_Resize( int argc, VALUE *args, VALUE self )
|
|||
/* call-seq:
|
||||
* sprite.flipX( flipped )
|
||||
*
|
||||
* Flip the sprite horizontally.
|
||||
* Flip the sprite horizontally.
|
||||
*/
|
||||
static VALUE Sprite_FlipX( VALUE self, VALUE aFlippedFlag )
|
||||
{
|
||||
|
@ -226,7 +226,7 @@ static VALUE Sprite_FlipX( VALUE self, VALUE aFlippedFlag )
|
|||
/* call-seq:
|
||||
* sprite.flipY( flipped )
|
||||
*
|
||||
* Flip the sprite vertically.
|
||||
* Flip the sprite vertically.
|
||||
*/
|
||||
static VALUE Sprite_FlipY( VALUE self, VALUE aFlippedFlag )
|
||||
{
|
||||
|
@ -262,15 +262,15 @@ static VALUE Sprite_GetImage( VALUE self )
|
|||
/* call-seq:
|
||||
* sprite.getSubRect() -> rectangle
|
||||
*
|
||||
* Get the region of the image displayed by the sprite.
|
||||
* Get the region of the image displayed by the sprite.
|
||||
*/
|
||||
static VALUE Sprite_GetSubRect( VALUE self )
|
||||
{
|
||||
sf::Sprite *object = NULL;
|
||||
Data_Get_Struct( self, sf::Sprite, object );
|
||||
const sf::IntRect &rect = object->GetSubRect();
|
||||
return rb_funcall( globalRectClass, rb_intern( "new" ), 4,
|
||||
INT2FIX( rect.Left ), INT2FIX( rect.Top ),
|
||||
return rb_funcall( globalRectClass, rb_intern( "new" ), 4,
|
||||
INT2FIX( rect.Left ), INT2FIX( rect.Top ),
|
||||
INT2FIX( rect.Width ), INT2FIX( rect.Height ) );
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ static VALUE Sprite_GetSize( VALUE self )
|
|||
sf::Sprite *object = NULL;
|
||||
Data_Get_Struct( self, sf::Sprite, object );
|
||||
const sf::Vector2f size = object->GetSize();
|
||||
return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, rb_float_new( size.x ), rb_float_new( size.y ) );
|
||||
return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, rb_float_new( size.x ), rb_float_new( size.y ) );
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
|
@ -294,8 +294,8 @@ static VALUE Sprite_GetSize( VALUE self )
|
|||
*
|
||||
* Get the color of a given pixel in the sprite.
|
||||
*
|
||||
* This function returns the source image pixel, multiplied by the global color of the sprite. The input point must
|
||||
* be in local coordinates. If you have a global point, you can use the TransformToLocal function to make it local.
|
||||
* This function returns the source image pixel, multiplied by the global color of the sprite. The input point must
|
||||
* be in local coordinates. If you have a global point, you can use the TransformToLocal function to make it local.
|
||||
* This function doesn't perform any check, you must ensure that the x and y coordinates are not out of bounds.
|
||||
*/
|
||||
static VALUE Sprite_GetPixel( VALUE self, VALUE aX, VALUE aY )
|
||||
|
@ -303,17 +303,15 @@ static VALUE Sprite_GetPixel( VALUE self, VALUE aX, VALUE aY )
|
|||
sf::Sprite *object = NULL;
|
||||
Data_Get_Struct( self, sf::Sprite, object );
|
||||
const sf::Color color = object->GetPixel( FIX2UINT( aX ), FIX2UINT( aY ) );
|
||||
return rb_funcall( globalColorClass, rb_intern( "new" ), 4,
|
||||
INT2FIX( color.r ), INT2FIX( color.g ),
|
||||
return rb_funcall( globalColorClass, rb_intern( "new" ), 4,
|
||||
INT2FIX( color.r ), INT2FIX( color.g ),
|
||||
INT2FIX( color.b ), INT2FIX( color.a ) );
|
||||
}
|
||||
|
||||
static VALUE Sprite_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE Sprite_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::Sprite *object = new sf::Sprite();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, Sprite_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, Sprite_Free, object );
|
||||
}
|
||||
|
||||
void Init_Sprite( void )
|
||||
|
@ -324,20 +322,20 @@ void Init_Sprite( void )
|
|||
*
|
||||
* SFML::Sprite is a drawable class that allows to easily display an image (or a part of it) on a render target.
|
||||
*
|
||||
* It inherits all the functions from SFML::Drawable: position, rotation, scale, origin, global color and blend mode.
|
||||
* It also adds sprite-specific properties such as the image to use, the part of it to display, and some convenience
|
||||
* It inherits all the functions from SFML::Drawable: position, rotation, scale, origin, global color and blend mode.
|
||||
* It also adds sprite-specific properties such as the image to use, the part of it to display, and some convenience
|
||||
* functions to flip or resize the sprite.
|
||||
*
|
||||
* SFML::Sprite works in combination with the SFML::Image class, which loads and provides the pixel data of a
|
||||
* SFML::Sprite works in combination with the SFML::Image class, which loads and provides the pixel data of a
|
||||
* given image.
|
||||
*
|
||||
* The separation of SFML::Sprite and SFML::Image allows more flexibility and better performances: indeed a SFML::Image
|
||||
* is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side,
|
||||
* a SFML::Sprite is a lightweight object which can use the pixel data of a SFML::Image and draw it with its own
|
||||
* The separation of SFML::Sprite and SFML::Image allows more flexibility and better performances: indeed a SFML::Image
|
||||
* is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side,
|
||||
* a SFML::Sprite is a lightweight object which can use the pixel data of a SFML::Image and draw it with its own
|
||||
* transformation / color / blending attributes.
|
||||
*
|
||||
* It is important to note that the SFML::Sprite instance doesn't copy the image that it uses, it only keeps a reference
|
||||
* to it. Thus, a SFML::Image must not be destructed while it is used by a SFML::Sprite (i.e. never write a function that
|
||||
* It is important to note that the SFML::Sprite instance doesn't copy the image that it uses, it only keeps a reference
|
||||
* to it. Thus, a SFML::Image must not be destructed while it is used by a SFML::Sprite (i.e. never write a function that
|
||||
* uses a local SFML::Image instance for creating a sprite).
|
||||
*
|
||||
* NOTE: This is the ruby bindings so the images will be managed by the ruby garbage collector and thus the image won't
|
||||
|
@ -361,10 +359,11 @@ void Init_Sprite( void )
|
|||
*/
|
||||
globalSpriteClass = rb_define_class_under( sfml, "Sprite", rb_cObject );
|
||||
rb_include_module( globalSpriteClass, globalDrawableModule );
|
||||
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalSpriteClass, "new", Sprite_New, -1 );
|
||||
|
||||
//rb_define_singleton_method( globalSpriteClass, "new", Sprite_New, -1 );
|
||||
rb_define_alloc_func( globalSpriteClass, Sprite_Alloc );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalSpriteClass, "initialize", Sprite_Initialize, -1 );
|
||||
rb_define_method( globalSpriteClass, "initialize_copy", Sprite_InitializeCopy, 1 );
|
||||
|
@ -377,27 +376,27 @@ void Init_Sprite( void )
|
|||
rb_define_method( globalSpriteClass, "getSubRect", Sprite_GetSubRect, 0 );
|
||||
rb_define_method( globalSpriteClass, "getSize", Sprite_GetSize, 0 );
|
||||
rb_define_method( globalSpriteClass, "getPixel", Sprite_GetPixel, 2 );
|
||||
|
||||
|
||||
// Instance Aliases
|
||||
rb_define_alias( globalSpriteClass, "image=", "setImage" );
|
||||
rb_define_alias( globalSpriteClass, "set_image", "setImage" );
|
||||
rb_define_alias( globalSpriteClass, "image", "getImage" );
|
||||
rb_define_alias( globalSpriteClass, "get_image", "getImage" );
|
||||
|
||||
|
||||
rb_define_alias( globalSpriteClass, "subRect=", "setSubRect" );
|
||||
rb_define_alias( globalSpriteClass, "sub_rect=", "setSubRect" );
|
||||
rb_define_alias( globalSpriteClass, "subRect", "getSubRect" );
|
||||
rb_define_alias( globalSpriteClass, "sub_rect", "getSubRect" );
|
||||
|
||||
|
||||
rb_define_alias( globalSpriteClass, "flip_x", "flipX" );
|
||||
rb_define_alias( globalSpriteClass, "flip_y", "flipY" );
|
||||
rb_define_alias( globalSpriteClass, "flip_x=", "flipX" );
|
||||
rb_define_alias( globalSpriteClass, "flip_y=", "flipY" );
|
||||
rb_define_alias( globalSpriteClass, "flipX=", "flipX" );
|
||||
rb_define_alias( globalSpriteClass, "flipY=", "flipY" );
|
||||
|
||||
|
||||
rb_define_alias( globalSpriteClass, "get_size", "getSize" );
|
||||
rb_define_alias( globalSpriteClass, "size", "getSize" );
|
||||
|
||||
|
||||
rb_define_alias( globalSpriteClass, "get_pixel", "getPixel" );
|
||||
}
|
||||
|
|
|
@ -229,12 +229,10 @@ static VALUE Text_GetRect( VALUE self )
|
|||
rb_float_new( rect.Width ), rb_float_new( rect.Height ) );
|
||||
}
|
||||
|
||||
static VALUE Text_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE Text_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::Text *object = new sf::Text();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, Text_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, Text_Free, object );
|
||||
}
|
||||
|
||||
static void CreateStyleEnum()
|
||||
|
@ -293,7 +291,8 @@ void Init_Text( void )
|
|||
CreateStyleEnum();
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalTextClass, "new", Text_New, -1 );
|
||||
//rb_define_singleton_method( globalTextClass, "new", Text_New, -1 );
|
||||
rb_define_alloc_func( globalTextClass, Text_Alloc );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalTextClass, "initialize", Text_Initialize, -1 );
|
||||
|
|
|
@ -349,12 +349,10 @@ static VALUE View_Zoom( VALUE self, VALUE aFactor )
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE View_New( int argc, VALUE *args, VALUE aKlass )
|
||||
static VALUE View_Alloc( VALUE aKlass )
|
||||
{
|
||||
sf::View *object = new sf::View();
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, View_Free, object );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
return Data_Wrap_Struct( aKlass, 0, View_Free, object );
|
||||
}
|
||||
|
||||
void Init_View( void )
|
||||
|
@ -408,7 +406,8 @@ void Init_View( void )
|
|||
globalViewClass = rb_define_class_under( sfml, "View", rb_cObject );
|
||||
|
||||
// Class methods
|
||||
rb_define_singleton_method( globalViewClass, "new", View_New, -1 );
|
||||
//rb_define_singleton_method( globalViewClass, "new", View_New, -1 );
|
||||
rb_define_alloc_func( globalViewClass, View_Alloc );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalViewClass, "initialize", View_Initialize, -1 );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue