From: Tilman Sauerbeck Date: Fri, 10 Feb 2006 15:25:40 +0000 (+0000) Subject: Fixed class instantiation. X-Git-Url: http://git.code-monkey.de/?p=ruby-ecore.git;a=commitdiff_plain;h=fa957a85d2bac8f3ec0845737540254f25d6685c Fixed class instantiation. --- diff --git a/src/ecore/rb_animator.c b/src/ecore/rb_animator.c index 41837de..9a3ce27 100644 --- a/src/ecore/rb_animator.c +++ b/src/ecore/rb_animator.c @@ -1,5 +1,5 @@ /* - * $Id: rb_animator.c 150 2004-12-03 13:45:00Z tilman $ + * $Id: rb_animator.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -73,24 +73,26 @@ static void c_free (RbAnimator *animator) free (animator); } -static VALUE c_new (VALUE klass) +static VALUE c_alloc (VALUE klass) { - VALUE self; RbAnimator *animator = NULL; - if (!rb_block_given_p ()) - return Qnil; + ecore_init (); - self = Data_Make_Struct (klass, RbAnimator, c_mark, c_free, animator); + return Data_Make_Struct (klass, RbAnimator, c_mark, c_free, animator); +} - ecore_init (); +static VALUE c_init (VALUE self) +{ + GET_OBJ (self, RbAnimator, animator); + + if (!rb_block_given_p ()) + rb_raise (rb_eStandardError, "block missing"); animator->callback = rb_block_proc (); animator->deleted = false; animator->real = ecore_animator_add (on_animator, animator); - rb_obj_call_init (self, 0, NULL); - return self; } @@ -112,6 +114,7 @@ void Init_Animator (void) { VALUE c = rb_define_class_under (mEcore, "Animator", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 0); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 0); rb_define_method (c, "delete", c_delete, 0); } diff --git a/src/ecore/rb_fd_handler.c b/src/ecore/rb_fd_handler.c index 4d7e08c..c37e310 100644 --- a/src/ecore/rb_fd_handler.c +++ b/src/ecore/rb_fd_handler.c @@ -1,5 +1,5 @@ /* - * $Id: rb_fd_handler.c 109 2004-09-01 20:33:15Z tilman $ + * $Id: rb_fd_handler.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -62,28 +62,30 @@ static void c_free (RbFdHandler *fdh) free (fdh); } -static VALUE c_new (VALUE klass, VALUE fd, VALUE flags) +static VALUE c_alloc (VALUE klass) { - VALUE self; RbFdHandler *fdh = NULL; + ecore_init (); + + return Data_Make_Struct (klass, RbFdHandler, c_mark, c_free, fdh); +} + +static VALUE c_init (VALUE self, VALUE fd, VALUE flags) +{ + GET_OBJ (self, RbFdHandler, fdh); + if (!rb_block_given_p ()) - return Qnil; + rb_raise (rb_eStandardError, "block missing"); Check_Type (fd, T_FIXNUM); Check_Type (flags, T_FIXNUM); - self = Data_Make_Struct (klass, RbFdHandler, c_mark, c_free, fdh); - - ecore_init (); - fdh->callback = rb_block_proc (); fdh->real = ecore_main_fd_handler_add (FIX2INT (fd), FIX2INT (flags), on_change, fdh, NULL, NULL); - rb_obj_call_init (self, 0, NULL); - return self; } @@ -132,7 +134,8 @@ void Init_FdHandler (void) { VALUE c = rb_define_class_under (mEcore, "FdHandler", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 2); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 2); rb_define_method (c, "delete", c_delete, 0); rb_define_method (c, "fd", c_fd_get, 0); rb_define_method (c, "get_active", c_get_active, 1); diff --git a/src/ecore/rb_idle_enterer.c b/src/ecore/rb_idle_enterer.c index 39bac7e..236f891 100644 --- a/src/ecore/rb_idle_enterer.c +++ b/src/ecore/rb_idle_enterer.c @@ -1,5 +1,5 @@ /* - * $Id: rb_idle_enterer.c 154 2004-12-09 18:49:18Z tilman $ + * $Id: rb_idle_enterer.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -62,6 +62,16 @@ static void c_free (RbIdleEnterer *idle_enterer) free (idle_enterer); } +static VALUE c_alloc (VALUE klass) +{ + RbIdleEnterer *idle_enterer; + + ecore_init (); + + return Data_Make_Struct (klass, RbIdleEnterer, c_mark, c_free, + idle_enterer); +} + /* * call-seq: * Ecore::IdleEnterer.new { block } => idle_enterer @@ -70,26 +80,18 @@ static void c_free (RbIdleEnterer *idle_enterer) * When Ecore enters the idle state, the specified block will be called. * If the block returns false, the IdleEnterer is deleted. */ -static VALUE c_new (VALUE klass) +static VALUE c_init (VALUE self) { - VALUE self; - RbIdleEnterer *idle_enterer; + GET_OBJ (self, RbIdleEnterer, idle_enterer); if (!rb_block_given_p ()) - return Qnil; - - self = Data_Make_Struct (klass, RbIdleEnterer, c_mark, c_free, - idle_enterer); - - ecore_init (); + rb_raise (rb_eStandardError, "block missing"); idle_enterer->callback = rb_block_proc (); idle_enterer->deleted = false; idle_enterer->real = ecore_idle_enterer_add (on_idle_enter, idle_enterer); - rb_obj_call_init (self, 0, NULL); - return self; } @@ -117,6 +119,7 @@ void Init_IdleEnterer (void) { VALUE c = rb_define_class_under (mEcore, "IdleEnterer", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 0); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 0); rb_define_method (c, "delete", c_delete, 0); } diff --git a/src/ecore/rb_idler.c b/src/ecore/rb_idler.c index d03a5ba..7462290 100644 --- a/src/ecore/rb_idler.c +++ b/src/ecore/rb_idler.c @@ -1,5 +1,5 @@ /* - * $Id: rb_idler.c 154 2004-12-09 18:49:18Z tilman $ + * $Id: rb_idler.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -62,6 +62,15 @@ static void c_free (RbIdler *idler) free (idler); } +static VALUE c_alloc (VALUE klass) +{ + RbIdler *idler; + + ecore_init (); + + return Data_Make_Struct (klass, RbIdler, c_mark, c_free, idler); +} + /* * call-seq: * Ecore::Idler.new { block } => idler @@ -70,24 +79,17 @@ static void c_free (RbIdler *idler) * When Ecore is idle, the specified block will be called. * If the block returns false, the idler is deleted. */ -static VALUE c_new (VALUE klass) +static VALUE c_init (VALUE self) { - VALUE self; - RbIdler *idler; + GET_OBJ (self, RbIdler, idler); if (!rb_block_given_p ()) - return Qnil; - - self = Data_Make_Struct (klass, RbIdler, c_mark, c_free, idler); - - ecore_init (); + rb_raise (rb_eStandardError, "block missing"); idler->callback = rb_block_proc (); idler->deleted = false; idler->real = ecore_idler_add (on_idler, idler); - rb_obj_call_init (self, 0, NULL); - return self; } @@ -115,6 +117,7 @@ void Init_Idler (void) { VALUE c = rb_define_class_under (mEcore, "Idler", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 0); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 0); rb_define_method (c, "delete", c_delete, 0); } diff --git a/src/ecore/rb_timer.c b/src/ecore/rb_timer.c index 05e2592..939a88d 100644 --- a/src/ecore/rb_timer.c +++ b/src/ecore/rb_timer.c @@ -1,5 +1,5 @@ /* - * $Id: rb_timer.c 279 2005-03-13 14:32:25Z tilman $ + * $Id: rb_timer.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -62,6 +62,15 @@ static void c_free (RbTimer *timer) free (timer); } +static VALUE c_alloc (VALUE klass) +{ + RbTimer *timer = NULL; + + ecore_init (); + + return Data_Make_Struct (klass, RbTimer, c_mark, c_free, timer); +} + /* * call-seq: * Ecore::Timer.new(interval) { block } => timer @@ -70,25 +79,18 @@ static void c_free (RbTimer *timer) * When the timeout is hit, the block is called. * If the block returns false, the timer is deleted. */ -static VALUE c_new (VALUE klass, VALUE interval) +static VALUE c_init (VALUE self, VALUE interval) { - VALUE self; - RbTimer *timer = NULL; + GET_OBJ (self, RbTimer, timer); if (!rb_block_given_p ()) - return Qnil; - - self = Data_Make_Struct (klass, RbTimer, c_mark, c_free, timer); - - ecore_init (); + rb_raise (rb_eStandardError, "block missing"); timer->callback = rb_block_proc (); timer->deleted = false; timer->real = ecore_timer_add (NUM2DBL (interval), on_timer, timer); - rb_obj_call_init (self, 0, NULL); - return self; } @@ -132,7 +134,8 @@ void Init_Timer (void) { VALUE c = rb_define_class_under (mEcore, "Timer", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 1); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 1); rb_define_method (c, "delete", c_delete, 0); rb_define_method (c, "deleted?", c_deleted_get, 0); rb_define_method (c, "interval=", c_interval_set, 1); diff --git a/src/ecore_evas/rb_buffer.c b/src/ecore_evas/rb_buffer.c index db316cc..9526f96 100644 --- a/src/ecore_evas/rb_buffer.c +++ b/src/ecore_evas/rb_buffer.c @@ -1,5 +1,5 @@ /* - * $Id: rb_buffer.c 174 2005-01-19 21:31:04Z tilman $ + * $Id: rb_buffer.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004-2005 ruby-ecore team (see AUTHORS) * @@ -32,20 +32,29 @@ static void c_free (RbEcoreEvas *ee) c_ecore_evas_free (ee, true); } +static VALUE c_alloc (VALUE klass) +{ + RbEcoreEvas *ee = NULL; + + ecore_init (); + ecore_evas_init (); + + return Data_Make_Struct (klass, RbEcoreEvas, + c_ecore_evas_mark, c_free, ee); +} + /* * call-seq: * Ecore::Evas::Buffer.new([w, h]) => buffer * * Creates an Ecore::Evas::Buffer object. */ -static VALUE c_new (int argc, VALUE *argv, VALUE klass) +static VALUE c_init (int argc, VALUE *argv, VALUE self) { - VALUE self, w, h; - RbEcoreEvas *ee = NULL; + VALUE w, h; int iw = 0, ih = 0; - self = Data_Make_Struct (klass, RbEcoreEvas, - c_ecore_evas_mark, c_free, ee); + GET_OBJ (self, RbEcoreEvas, ee); rb_scan_args (argc, argv, "02", &w, &h); @@ -59,12 +68,9 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) ih = FIX2INT (h); } - ecore_init (); - ecore_evas_init (); - ee->real = ecore_evas_buffer_new (iw, ih); - rb_obj_call_init (self, 0, NULL); + rb_call_super (argc, argv); return self; } @@ -89,6 +95,7 @@ void Init_Buffer (void) { VALUE c = rb_define_class_under (mEvas, "Buffer", cEcoreEvas); - rb_define_singleton_method (c, "new", c_new, -1); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, -1); rb_define_method (c, "pixels", c_pixels_get, 0); } diff --git a/src/ecore_evas/rb_fb.c b/src/ecore_evas/rb_fb.c index 8192169..830448d 100644 --- a/src/ecore_evas/rb_fb.c +++ b/src/ecore_evas/rb_fb.c @@ -1,5 +1,5 @@ /* - * $Id: rb_fb.c 77 2004-08-19 17:39:29Z tilman $ + * $Id: rb_fb.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -23,6 +23,7 @@ #include #include +#include "../ecore/rb_ecore.h" #include "rb_ecore_evas_main.h" #include "rb_ecore_evas.h" @@ -31,21 +32,30 @@ static void c_free (RbEcoreEvas *ee) c_ecore_evas_free (ee, true); } +static VALUE c_alloc (VALUE klass) +{ + RbEcoreEvas *ee = NULL; + + ecore_init (); + ecore_evas_init (); + + return Data_Make_Struct (klass, RbEcoreEvas, + c_ecore_evas_mark, c_free, ee); +} + /* * call-seq: * Ecore::Evas::Fb.new([display, rotation, w, h]) => fb * * Creates an Ecore::Evas::Fb object. */ -static VALUE c_new (int argc, VALUE *argv, VALUE klass) +static VALUE c_init (int argc, VALUE *argv, VALUE self) { - VALUE self, disp, rot, w, h; - RbEcoreEvas *ee = NULL; + VALUE disp, rot, w, h; char *cdisp = NULL; int irot = 0, iw = 0, ih = 0; - self = Data_Make_Struct (klass, RbEcoreEvas, - c_ecore_evas_mark, c_free, ee); + GET_OBJ (self, RbEcoreEvas, ee); rb_scan_args (argc, argv, "04", &disp, &rot, &w, &h); @@ -69,12 +79,9 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) ih = FIX2INT (h); } - ecore_init (); - ecore_evas_init (); - ee->real = ecore_evas_fb_new (cdisp, irot, iw, ih); - rb_obj_call_init (self, 0, NULL); + rb_call_super (argc, argv); return self; } @@ -83,5 +90,6 @@ void Init_Fb (void) { VALUE c = rb_define_class_under (mEvas, "Fb", cEcoreEvas); - rb_define_singleton_method (c, "new", c_new, -1); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, -1); } diff --git a/src/ecore_evas/rb_gl_x11.c b/src/ecore_evas/rb_gl_x11.c index 6e9263c..c0e5136 100644 --- a/src/ecore_evas/rb_gl_x11.c +++ b/src/ecore_evas/rb_gl_x11.c @@ -1,5 +1,5 @@ /* - * $Id: rb_gl_x11.c 100 2004-08-27 09:31:26Z tilman $ + * $Id: rb_gl_x11.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -52,22 +52,31 @@ static void c_free (RbEcoreEvasGlX11 *ee) free (ee); } +static VALUE c_alloc (VALUE klass) +{ + RbEcoreEvasGlX11 *ee = NULL; + + ecore_init (); + ecore_evas_init (); + + return Data_Make_Struct (klass, RbEcoreEvasGlX11, + c_mark, c_free, ee); +} + /* * call-seq: * Ecore::Evas::GlX11.new([display, parent, x, y, w, h]) => glx11 * * Creates an Ecore::Evas::GlX11 object. */ -static VALUE c_new (int argc, VALUE *argv, VALUE klass) +static VALUE c_init (int argc, VALUE *argv, VALUE self) { - VALUE self, disp, parent, geom[4]; - RbEcoreEvasGlX11 *ee = NULL; + VALUE disp, parent, geom[4]; RbWindow *win = NULL; char *cdisp = NULL; int i, igeom[4] = {0, 0, 0, 0}; - self = Data_Make_Struct (klass, RbEcoreEvasGlX11, - c_mark, c_free, ee); + GET_OBJ (self, RbEcoreEvasGlX11, ee); rb_scan_args (argc, argv, "06", &disp, &parent, &geom[0], &geom[1], &geom[2], &geom[3]); @@ -88,9 +97,6 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) igeom[i] = FIX2INT (geom[i]); } - ecore_init (); - ecore_evas_init (); - ee->ee.real = ecore_evas_gl_x11_new (cdisp, win ? win->real : 0, igeom[0], igeom[1], @@ -98,7 +104,7 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) ee->parent_window = parent; ee->window = Qnil; - rb_obj_call_init (self, 0, NULL); + rb_call_super (argc, argv); return self; } @@ -131,6 +137,7 @@ void Init_GlX11 (void) c = rb_define_class_under (mEvas, "GlX11", cEcoreEvas); - rb_define_singleton_method (c, "new", c_new, -1); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, -1); rb_define_method (c, "window", c_window_get, 0); } diff --git a/src/ecore_evas/rb_software_x11.c b/src/ecore_evas/rb_software_x11.c index 9aafa26..8549dc5 100644 --- a/src/ecore_evas/rb_software_x11.c +++ b/src/ecore_evas/rb_software_x11.c @@ -1,5 +1,5 @@ /* - * $Id: rb_software_x11.c 100 2004-08-27 09:31:26Z tilman $ + * $Id: rb_software_x11.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -52,22 +52,31 @@ static void c_free (RbEcoreEvasSoftwareX11 *ee) free (ee); } +static VALUE c_alloc (VALUE klass) +{ + RbEcoreEvasSoftwareX11 *ee = NULL; + + ecore_init (); + ecore_evas_init (); + + return Data_Make_Struct (klass, RbEcoreEvasSoftwareX11, + c_mark, c_free, ee); +} + /* * call-seq: * Ecore::Evas::SoftwareX11.new([display, parent, x, y, w, h]) => swx11 * * Creates an Ecore::Evas::SoftwareX11 object. */ -static VALUE c_new (int argc, VALUE *argv, VALUE klass) +static VALUE c_init (int argc, VALUE *argv, VALUE self) { - VALUE self, disp, parent, geom[4]; - RbEcoreEvasSoftwareX11 *ee = NULL; + VALUE disp, parent, geom[4]; RbWindow *win = NULL; char *cdisp = NULL; int i, igeom[4] = {0, 0, 0, 0}; - self = Data_Make_Struct (klass, RbEcoreEvasSoftwareX11, - c_mark, c_free, ee); + GET_OBJ (self, RbEcoreEvasSoftwareX11, ee); rb_scan_args (argc, argv, "06", &disp, &parent, &geom[0], &geom[1], &geom[2], &geom[3]); @@ -88,9 +97,6 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) igeom[i] = FIX2INT (geom[i]); } - ecore_init (); - ecore_evas_init (); - ee->ee.real = ecore_evas_software_x11_new (cdisp, win ? win->real : 0, igeom[0], igeom[1], @@ -98,7 +104,7 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) ee->parent_window = parent; ee->window = Qnil; - rb_obj_call_init (self, 0, NULL); + rb_call_super (argc, argv); return self; } @@ -131,6 +137,7 @@ void Init_SoftwareX11 (void) c = rb_define_class_under (mEvas, "SoftwareX11", cEcoreEvas); - rb_define_singleton_method (c, "new", c_new, -1); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, -1); rb_define_method (c, "window", c_window_get, 0); } diff --git a/src/ecore_evas/rb_xrender_x11.c b/src/ecore_evas/rb_xrender_x11.c index a403bfa..505638d 100644 --- a/src/ecore_evas/rb_xrender_x11.c +++ b/src/ecore_evas/rb_xrender_x11.c @@ -1,5 +1,5 @@ /* - * $Id: rb_xrender_x11.c 348 2005-12-24 17:11:24Z tilman $ + * $Id: rb_xrender_x11.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2005 ruby-ecore team (see AUTHORS) * @@ -52,22 +52,31 @@ static void c_free (RbEcoreEvasXRenderX11 *ee) free (ee); } +static VALUE c_alloc (VALUE klass) +{ + RbEcoreEvasXRenderX11 *ee = NULL; + + ecore_init (); + ecore_evas_init (); + + return Data_Make_Struct (klass, RbEcoreEvasXRenderX11, + c_mark, c_free, ee); +} + /* * call-seq: * Ecore::Evas::XRenderX11.new([display, parent, x, y, w, h]) => xrx11 * * Creates an Ecore::Evas::XRenderX11 object. */ -static VALUE c_new (int argc, VALUE *argv, VALUE klass) +static VALUE c_init (int argc, VALUE *argv, VALUE self) { - VALUE self, disp, parent, geom[4]; - RbEcoreEvasXRenderX11 *ee = NULL; + VALUE disp, parent, geom[4]; RbWindow *win = NULL; char *cdisp = NULL; int i, igeom[4] = {0, 0, 0, 0}; - self = Data_Make_Struct (klass, RbEcoreEvasXRenderX11, - c_mark, c_free, ee); + GET_OBJ (self, RbEcoreEvasXRenderX11, ee); rb_scan_args (argc, argv, "06", &disp, &parent, &geom[0], &geom[1], &geom[2], &geom[3]); @@ -88,9 +97,6 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) igeom[i] = FIX2INT (geom[i]); } - ecore_init (); - ecore_evas_init (); - ee->ee.real = ecore_evas_xrender_x11_new (cdisp, win ? win->real : 0, igeom[0], igeom[1], @@ -98,7 +104,7 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) ee->parent_window = parent; ee->window = Qnil; - rb_obj_call_init (self, 0, NULL); + rb_call_super (argc, argv); return self; } @@ -131,6 +137,7 @@ void Init_XRenderX11 (void) c = rb_define_class_under (mEvas, "XRenderX11", cEcoreEvas); - rb_define_singleton_method (c, "new", c_new, -1); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, -1); rb_define_method (c, "window", c_window_get, 0); } diff --git a/src/ecore_job/rb_job.c b/src/ecore_job/rb_job.c index 71fe1e3..5c4ff46 100644 --- a/src/ecore_job/rb_job.c +++ b/src/ecore_job/rb_job.c @@ -1,5 +1,5 @@ /* - * $Id: rb_job.c 77 2004-08-19 17:39:29Z tilman $ + * $Id: rb_job.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -55,6 +55,15 @@ static void c_free (RbJob *job) free (job); } +static VALUE c_alloc (VALUE klass) +{ + RbJob *job = NULL; + + ecore_init (); + + return Data_Make_Struct (klass, RbJob, c_mark, c_free, job); +} + /* * call-seq: * Ecore::Job::Job.new { block } => job @@ -62,24 +71,19 @@ static void c_free (RbJob *job) * Creates an Ecore::Job::Job object. * After execution, the object will be deleted. */ -static VALUE c_new (VALUE klass) +static VALUE c_init (VALUE self) { - VALUE self; - RbJob *job; + RbJob *job = NULL; if (!rb_block_given_p ()) - return Qnil; - - self = Data_Make_Struct (klass, RbJob, c_mark, c_free, job); + rb_raise (rb_eStandardError, "block missing"); - ecore_init (); + Data_Get_Struct (self, RbJob, job); job->callback = rb_block_proc (); job->deleted = false; job->real = ecore_job_add (on_job, job); - rb_obj_call_init (self, 0, NULL); - return self; } @@ -110,6 +114,7 @@ void Init_Job (void) { VALUE c = rb_define_class_under (mJob, "Job", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 0); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 0); rb_define_method (c, "delete", c_delete, 0); } diff --git a/src/ecore_x/rb_cursor.c b/src/ecore_x/rb_cursor.c index 0612666..f025f6e 100644 --- a/src/ecore_x/rb_cursor.c +++ b/src/ecore_x/rb_cursor.c @@ -1,5 +1,5 @@ /* - * $Id: rb_cursor.c 109 2004-09-01 20:33:15Z tilman $ + * $Id: rb_cursor.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -38,18 +38,25 @@ static void c_free (RbCursor *c) free (c); } +static VALUE c_alloc (VALUE klass) +{ + RbCursor *cursor = NULL; + + return Data_Make_Struct (klass, RbCursor, NULL, c_free, cursor); +} + static VALUE c_new_from_shape (VALUE klass, VALUE shape) { VALUE self; RbCursor *cursor = NULL; - self = Data_Make_Struct (klass, RbCursor, NULL, c_free, cursor); + self = rb_class_new_instance (1, &shape, klass); + + Data_Get_Struct (self, RbCursor, cursor); cursor->real = ecore_x_cursor_shape_get (FIX2INT (shape)); cursor->need_free = false; - rb_obj_call_init (self, 0, NULL); - return self; } @@ -57,6 +64,7 @@ void Init_Cursor (void) { cCursor = rb_define_class_under (mX, "Cursor", rb_cObject); + rb_define_alloc_func (cCursor, c_alloc); rb_define_singleton_method (cCursor, "new_from_shape", c_new_from_shape, 1); diff --git a/src/ecore_x/rb_window.c b/src/ecore_x/rb_window.c index 6aca509..204d301 100644 --- a/src/ecore_x/rb_window.c +++ b/src/ecore_x/rb_window.c @@ -1,5 +1,5 @@ /* - * $Id: rb_window.c 111 2004-09-02 18:47:00Z tilman $ + * $Id: rb_window.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -60,14 +60,21 @@ VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w) return self; } -static VALUE c_new (int argc, VALUE *argv, VALUE klass) +static VALUE c_alloc (VALUE klass) { - VALUE self, parent, geom[4]; - RbWindow *window = NULL, *p = NULL; + RbWindow *window = NULL; + + return Data_Make_Struct (cWindow, RbWindow, c_mark, c_free, window); +} + +static VALUE c_init (int argc, VALUE *argv, VALUE self) +{ + VALUE parent, geom[4]; + RbWindow *p = NULL; int i, igeom[4] = {0, 0, 0, 0}; Ecore_X_Window pwin = 0; - self = Data_Make_Struct (cWindow, RbWindow, c_mark, c_free, window); + GET_OBJ (self, RbWindow, win); rb_scan_args (argc, argv, "05", &parent, &geom[0], &geom[1], &geom[2], &geom[3]); @@ -84,17 +91,10 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) igeom[i] = FIX2INT (geom[i]); } - window->real = ecore_x_window_new (pwin, igeom[0], igeom[1], - igeom[2], igeom[3]); - window->parent = parent; + win->real = ecore_x_window_new (pwin, igeom[0], igeom[1], + igeom[2], igeom[3]); + win->parent = parent; - rb_obj_call_init (self, 0, NULL); - - return self; -} - -static VALUE c_init (int argc, VALUE *argv, VALUE self) -{ rb_iv_set (self, "@cursor", Qnil); return self; @@ -330,6 +330,7 @@ static VALUE c_parent_get (VALUE self) ecore_x_window_parent_get (win->real)); } +#if 0 static VALUE c_title_get (VALUE self) { char *s; @@ -351,6 +352,7 @@ static VALUE c_title_set (VALUE self, VALUE val) return Qnil; } +#endif static VALUE c_set_event_mask (VALUE self, VALUE val) { @@ -374,6 +376,7 @@ static VALUE c_unset_event_mask (VALUE self, VALUE val) return Qnil; } +#if 0 static VALUE c_set_protocol (VALUE self, VALUE proto, VALUE on) { GET_OBJ (self, RbWindow, win); @@ -386,6 +389,7 @@ static VALUE c_set_protocol (VALUE self, VALUE proto, VALUE on) return Qnil; } +#endif static VALUE c_get_protocol (VALUE self, VALUE proto) { @@ -398,6 +402,7 @@ static VALUE c_get_protocol (VALUE self, VALUE proto) return s ? Qtrue : Qfalse; } +#if 0 static VALUE c_sticky_get (VALUE self) { int s; @@ -442,6 +447,7 @@ static VALUE c_borderless_set (VALUE self, VALUE val) return Qnil; } +#endif static VALUE c_cursor_set (VALUE self, VALUE val) { @@ -505,7 +511,7 @@ void Init_Window (void) { cWindow = rb_define_class_under (mX, "Window", rb_cObject); - rb_define_singleton_method (cWindow, "new", c_new, -1); + rb_define_alloc_func (cWindow, c_alloc); rb_define_method (cWindow, "initialize", c_init, -1); rb_define_method (cWindow, "inspect", c_inspect, 0); rb_define_method (cWindow, "eql?", c_equal_value, 1); @@ -530,17 +536,23 @@ void Init_Window (void) rb_define_method (cWindow, "border_width=", c_border_width_set, 1); rb_define_method (cWindow, "depth", c_depth_get, 0); rb_define_method (cWindow, "parent", c_parent_get, 0); +#if 0 rb_define_method (cWindow, "title", c_title_get, 0); rb_define_method (cWindow, "title=", c_title_set, 1); +#endif rb_define_method (cWindow, "set_event_mask", c_set_event_mask, 1); rb_define_method (cWindow, "unset_event_mask", c_unset_event_mask, 1); +#if 0 rb_define_method (cWindow, "set_protocol", c_set_protocol, 2); +#endif rb_define_method (cWindow, "get_protocol", c_get_protocol, 1); +#if 0 rb_define_method (cWindow, "sticky?", c_sticky_get, 0); rb_define_method (cWindow, "sticky=", c_sticky_set, 1); rb_define_method (cWindow, "borderless?", c_borderless_get, 0); rb_define_method (cWindow, "borderless=", c_borderless_set, 1); +#endif rb_define_method (cWindow, "cursor=", c_cursor_set, 1); rb_define_method (cWindow, "manage", c_manage, 0); rb_define_method (cWindow, "manage_container", c_manage_container, 0);