Added a #initialize_copy method to all classes which are wrapped around a C++ object in order to properly copy the values.
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1740 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
0920da5d8e
commit
bb7a6fac1f
14 changed files with 156 additions and 8 deletions
|
@ -156,6 +156,16 @@ static VALUE ContextSettings_SetMinorVersion( VALUE self, VALUE aValue )
|
|||
return INT2FIX( object->MinorVersion = NUM2UINT( aValue ) );
|
||||
}
|
||||
|
||||
static VALUE ContextSettings_InitializeCopy( VALUE self, VALUE aSource )
|
||||
{
|
||||
sf::ContextSettings *object = NULL;
|
||||
Data_Get_Struct( self, sf::ContextSettings, object );
|
||||
sf::ContextSettings *source = NULL;
|
||||
Data_Get_Struct( aSource, sf::ContextSettings, source );
|
||||
*object = *source;
|
||||
return self;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* ContextSettings.new( depth = 24, stencil = 8, antialiasing = 0, major = 2, minor = 0) -> settings
|
||||
*
|
||||
|
@ -212,7 +222,7 @@ static VALUE ContextSettings_New( VALUE aKlass, VALUE someArgs )
|
|||
}
|
||||
|
||||
VALUE rbData = Data_Wrap_Struct( aKlass, 0, ContextSettings_Free, object );
|
||||
rb_obj_call_init( rbData, 0, 0 );
|
||||
rb_obj_call_init( rbData, argc, args );
|
||||
return rbData;
|
||||
}
|
||||
|
||||
|
@ -251,6 +261,8 @@ void Init_ContextSettings( void )
|
|||
rb_define_singleton_method( globalContextSettingsClass, "new", ContextSettings_New, -2 );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalContextSettingsClass, "initialize_copy", ContextSettings_InitializeCopy, 1 );
|
||||
|
||||
rb_define_method( globalContextSettingsClass, "depthBits", ContextSettings_GetDepth, 0 );
|
||||
rb_define_method( globalContextSettingsClass, "depthBits=", ContextSettings_SetDepth, 1 );
|
||||
|
||||
|
|
|
@ -214,6 +214,16 @@ static VALUE Event_Initialize( VALUE self, VALUE aType )
|
|||
}
|
||||
}
|
||||
|
||||
static VALUE Event_InitializeCopy( VALUE self, VALUE aSource )
|
||||
{
|
||||
sf::Event *object = NULL;
|
||||
Data_Get_Struct( self, sf::Event, object );
|
||||
sf::Event *source = NULL;
|
||||
Data_Get_Struct( aSource, sf::Event, source );
|
||||
*object = *source;
|
||||
return Event_Initialize( VALUE self, INT2FIX( object->Type ) );
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* Event.new(type) -> event
|
||||
*
|
||||
|
@ -230,7 +240,6 @@ static VALUE Event_New( int argc, VALUE * args, VALUE aKlass )
|
|||
return rbData;
|
||||
}
|
||||
|
||||
|
||||
void Init_Event( void )
|
||||
{
|
||||
/* SFML namespace which contains the classes of this module. */
|
||||
|
@ -302,6 +311,8 @@ void Init_Event( void )
|
|||
|
||||
// Instance methods
|
||||
rb_define_method( globalEventClass, "initialize", Event_Initialize, 1 );
|
||||
rb_define_method( globalEventClass, "initialize_copy", Event_InitializeCopy, 1 );
|
||||
|
||||
rb_define_attr( globalEventClass, "type", 1, 0 );
|
||||
rb_define_attr( globalEventClass, "joyButton", 1, 0 );
|
||||
rb_define_attr( globalEventClass, "joyMove", 1, 0 );
|
||||
|
|
|
@ -152,6 +152,15 @@ static VALUE VideoMode_IsValid( VALUE self )
|
|||
return ( object->IsValid() == true ? Qtrue : Qfalse );
|
||||
}
|
||||
|
||||
static VALUE VideoMode_InitializeCopy( VALUE self, VALUE aSource )
|
||||
{
|
||||
sf::VideoMode *object = NULL;
|
||||
Data_Get_Struct( self, sf::VideoMode, object );
|
||||
sf::VideoMode *source = NULL;
|
||||
Data_Get_Struct( aSource, sf::VideoMode, source );
|
||||
*object = *source;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* VideoMode.getDesktopMode -> desktop_mode
|
||||
*
|
||||
|
@ -260,6 +269,8 @@ void Init_VideoMode( void )
|
|||
rb_define_singleton_method( globalVideoModeClass, "getFullscreenModes", VideoMode_GetFullscreenModes, 0 );
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalVideoModeClass, "initialize_copy", VideoMode_InitializeCopy, 1 );
|
||||
|
||||
rb_define_method( globalVideoModeClass, "width", VideoMode_GetWidth, 0 );
|
||||
rb_define_method( globalVideoModeClass, "width=", VideoMode_SetWidth, 1 );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue