From 98ce45a70b8b219b738bb804297417aae0ae9baa Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Thu, 8 Jul 2004 18:25:05 +0000 Subject: [PATCH] ecore_init and ecore_shutdown aren't exported anymore. Instead, they are called automatically in the objects' (de)constructors. --- src/ecore/rb_ecore.c | 23 ++++++++++++--------- src/ecore/rb_idler.c | 25 ++++++++++------------ src/ecore/rb_timer.c | 32 +++++++++++++---------------- src/ecore_evas/rb_ecore_evas.c | 8 ++++++-- src/ecore_evas/rb_ecore_evas_main.c | 6 +++++- src/ecore_evas/rb_fb.c | 28 +++++++++---------------- src/ecore_evas/rb_gl_x11.c | 28 +++++++++---------------- src/ecore_evas/rb_software_x11.c | 28 +++++++++---------------- src/ecore_job/rb_job.c | 26 +++++++++++------------ 9 files changed, 91 insertions(+), 113 deletions(-) diff --git a/src/ecore/rb_ecore.c b/src/ecore/rb_ecore.c index aba5f52..7cd8641 100644 --- a/src/ecore/rb_ecore.c +++ b/src/ecore/rb_ecore.c @@ -1,5 +1,5 @@ /* - * $Id: rb_ecore.c 9 2004-06-19 19:53:47Z tilman $ + * $Id: rb_ecore.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -26,11 +26,18 @@ #include "rb_timer.h" #include "rb_idler.h" +#ifdef DEBUG static VALUE m_init (VALUE self) { return INT2FIX (ecore_init ()); } +static VALUE m_shutdown (VALUE self) +{ + return INT2FIX (ecore_shutdown ()); +} +#endif + static VALUE m_main_loop_begin (VALUE self) { ecore_main_loop_begin (); @@ -52,27 +59,23 @@ static VALUE m_main_loop_quit (VALUE self) return Qnil; } -static VALUE m_shutdown (VALUE self) -{ - rb_gc_start (); - - return INT2FIX (ecore_shutdown ()); -} - void Init_ecore (void) { mEcore = rb_define_module ("Ecore"); +#ifdef DEBUG rb_define_module_function (mEcore, "init", m_init, 0); + rb_define_module_function (mEcore, "shutdown", + m_shutdown, 0); +#endif + rb_define_module_function (mEcore, "main_loop_begin", m_main_loop_begin, 0); rb_define_module_function (mEcore, "main_loop_iterate", m_main_loop_iterate, 0); rb_define_module_function (mEcore, "main_loop_quit", m_main_loop_quit, 0); - rb_define_module_function (mEcore, "shutdown", - m_shutdown, 0); Init_Timer (); Init_Idler (); diff --git a/src/ecore/rb_idler.c b/src/ecore/rb_idler.c index 77c35a3..414b6fb 100644 --- a/src/ecore/rb_idler.c +++ b/src/ecore/rb_idler.c @@ -1,5 +1,5 @@ /* - * $Id: rb_idler.c 25 2004-06-26 23:07:01Z tilman $ + * $Id: rb_idler.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -49,23 +49,13 @@ static int on_idler (void *data) return (r != Qfalse); } -static VALUE c_init (VALUE self) -{ - RbEcoreIdler *idler = NULL; - - Data_Get_Struct (self, RbEcoreIdler, idler); - - idler->cb = (void *) rb_block_proc (); - idler->idler = ecore_idler_add (on_idler, idler); - - return self; -} - static void c_free (RbEcoreIdler *idler) { if (idler->idler && !idler->deleted) ecore_idler_del (idler->idler); + ecore_shutdown (); + free (idler); } @@ -74,8 +64,16 @@ static VALUE c_new (VALUE klass) VALUE self; RbEcoreIdler *idler; + if (!rb_block_given_p ()) + return Qnil; + self = Data_Make_Struct (klass, RbEcoreIdler, NULL, c_free, idler); + ecore_init (); + + idler->cb = (void *) rb_block_proc (); + idler->idler = ecore_idler_add (on_idler, idler); + rb_obj_call_init (self, 0, NULL); return self; @@ -102,7 +100,6 @@ void Init_Idler (void) cIdler = rb_define_class_under (mEcore, "Idler", rb_cObject); rb_define_singleton_method (cIdler, "new", c_new, 1); - rb_define_method (cIdler, "initialize", c_init, 1); rb_define_method (cIdler, "delete", c_delete, 0); } diff --git a/src/ecore/rb_timer.c b/src/ecore/rb_timer.c index c9e93ec..315a65a 100644 --- a/src/ecore/rb_timer.c +++ b/src/ecore/rb_timer.c @@ -1,5 +1,5 @@ /* - * $Id: rb_timer.c 25 2004-06-26 23:07:01Z tilman $ + * $Id: rb_timer.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -49,36 +49,33 @@ static int on_timer (void *data) return (r != Qfalse); } -static VALUE c_init (VALUE self, VALUE interval) -{ - RbEcoreTimer *timer = NULL; - - Data_Get_Struct (self, RbEcoreTimer, timer); - - timer->cb = (void *) rb_block_proc (); - timer->timer = ecore_timer_add (NUM2DBL (interval), - on_timer, timer); - - return self; -} - static void c_free (RbEcoreTimer *timer) { if (timer->timer && !timer->deleted) ecore_timer_del (timer->timer); + ecore_shutdown (); + free (timer); } static VALUE c_new (VALUE klass, VALUE interval) { - VALUE self, argv[1]; + VALUE self; RbEcoreTimer *timer; + if (!rb_block_given_p ()) + return Qnil; + self = Data_Make_Struct (klass, RbEcoreTimer, NULL, c_free, timer); - argv[0] = interval; - rb_obj_call_init (self, 1, argv); + ecore_init (); + + timer->cb = (void *) rb_block_proc (); + timer->timer = ecore_timer_add (NUM2DBL (interval), + on_timer, timer); + + rb_obj_call_init (self, 0, NULL); return self; } @@ -104,7 +101,6 @@ void Init_Timer (void) cTimer = rb_define_class_under (mEcore, "Timer", rb_cObject); rb_define_singleton_method (cTimer, "new", c_new, 1); - rb_define_method (cTimer, "initialize", c_init, 1); rb_define_method (cTimer, "delete", c_delete, 0); } diff --git a/src/ecore_evas/rb_ecore_evas.c b/src/ecore_evas/rb_ecore_evas.c index 52b78a8..b508339 100644 --- a/src/ecore_evas/rb_ecore_evas.c +++ b/src/ecore_evas/rb_ecore_evas.c @@ -1,5 +1,5 @@ /* - * $Id: rb_ecore_evas.c 26 2004-07-06 18:27:19Z tilman $ + * $Id: rb_ecore_evas.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -20,6 +20,7 @@ #include +#include #include #include @@ -54,6 +55,9 @@ void c_ecore_evas_free (Ecore_Evas **ee) rb_hash_aset (evases, INT2NUM ((long) ee), Qnil); + ecore_evas_shutdown (); + ecore_shutdown (); + free (ee); } @@ -63,7 +67,7 @@ static VALUE c_inspect (VALUE self) GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas"); - snprintf (buf, sizeof (buf), "#", + snprintf (buf, sizeof (buf), "#", (void *) self, *ee); return rb_str_new2 (buf); diff --git a/src/ecore_evas/rb_ecore_evas_main.c b/src/ecore_evas/rb_ecore_evas_main.c index d3487df..8ef7c2c 100644 --- a/src/ecore_evas/rb_ecore_evas_main.c +++ b/src/ecore_evas/rb_ecore_evas_main.c @@ -1,5 +1,5 @@ /* - * $Id: rb_ecore_evas_main.c 22 2004-06-26 16:43:41Z tilman $ + * $Id: rb_ecore_evas_main.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -29,6 +29,7 @@ #include "rb_gl_x11.h" #include "rb_fb.h" +#ifdef DEBUG static VALUE m_init (VALUE self) { return INT2FIX (ecore_evas_init ()); @@ -38,6 +39,7 @@ static VALUE m_shutdown (VALUE self) { return INT2FIX (ecore_evas_shutdown ()); } +#endif void Init_ecore_evas (void) { @@ -46,8 +48,10 @@ void Init_ecore_evas (void) mEvas = rb_define_module_under (mEcore, "Evas"); +#ifdef DEBUG rb_define_module_function (mEvas, "init", m_init, 0); rb_define_module_function (mEvas, "shutdown", m_shutdown, 0); +#endif Init_EcoreEvas (); Init_SoftwareX11 (); diff --git a/src/ecore_evas/rb_fb.c b/src/ecore_evas/rb_fb.c index 00635de..b5c262b 100644 --- a/src/ecore_evas/rb_fb.c +++ b/src/ecore_evas/rb_fb.c @@ -1,5 +1,5 @@ /* - * $Id: rb_fb.c 25 2004-06-26 23:07:01Z tilman $ + * $Id: rb_fb.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -20,19 +20,21 @@ #include +#include #include #include "rb_ecore_evas_main.h" #include "rb_ecore_evas.h" -static VALUE c_init (int argc, VALUE *argv, VALUE self) +static VALUE c_new (int argc, VALUE *argv, VALUE klass) { - VALUE disp, rot, w, h; + VALUE self, disp, rot, w, h; Ecore_Evas **ee = NULL; char *cdisp = NULL; int irot = 0, iw = 0, ih = 0; - Data_Get_Struct (self, Ecore_Evas *, ee); + self = Data_Make_Struct (klass, Ecore_Evas *, + NULL, c_ecore_evas_free, ee); rb_scan_args (argc, argv, "04", &disp, &rot, &w, &h); @@ -56,20 +58,12 @@ static VALUE c_init (int argc, VALUE *argv, VALUE self) ih = NUM2INT (h); } - *ee = ecore_evas_fb_new (cdisp, irot, iw, ih); - - return self; -} - -static VALUE c_new (int argc, VALUE *argv, VALUE klass) -{ - VALUE self; - Ecore_Evas **ee; + ecore_init (); + ecore_evas_init (); - self = Data_Make_Struct (klass, Ecore_Evas *, - NULL, c_ecore_evas_free, ee); + *ee = ecore_evas_fb_new (cdisp, irot, iw, ih); - rb_obj_call_init (self, argc, argv); + rb_obj_call_init (self, 0, NULL); return self; } @@ -79,6 +73,4 @@ void Init_Fb (void) VALUE cFb = rb_define_class_under (mEvas, "Fb", cEcoreEvas); rb_define_singleton_method (cFb, "new", c_new, -1); - rb_define_method (cFb, "initialize", c_init, -1); } - diff --git a/src/ecore_evas/rb_gl_x11.c b/src/ecore_evas/rb_gl_x11.c index 061517a..de65a73 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 25 2004-06-26 23:07:01Z tilman $ + * $Id: rb_gl_x11.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -20,19 +20,21 @@ #include +#include #include #include "rb_ecore_evas_main.h" #include "rb_ecore_evas.h" -static VALUE c_init (int argc, VALUE *argv, VALUE self) +static VALUE c_new (int argc, VALUE *argv, VALUE klass) { - VALUE disp, parent, geom[4]; + VALUE self, disp, parent, geom[4]; Ecore_Evas **ee = NULL; char *cdisp = NULL; int i, igeom[4] = {0, 0, 0, 0}; - Data_Get_Struct (self, Ecore_Evas *, ee); + self = Data_Make_Struct (klass, Ecore_Evas *, + NULL, c_ecore_evas_free, ee); rb_scan_args (argc, argv, "06", &disp, &parent, &geom[0], &geom[1], &geom[2], &geom[3]); @@ -48,22 +50,14 @@ static VALUE c_init (int argc, VALUE *argv, VALUE self) igeom[i] = NUM2INT (geom[i]); } + ecore_init (); + ecore_evas_init (); + *ee = ecore_evas_gl_x11_new (cdisp, 0, igeom[0], igeom[1], igeom[2], igeom[3]); - return self; -} - -static VALUE c_new (int argc, VALUE *argv, VALUE klass) -{ - VALUE self; - Ecore_Evas **ee; - - self = Data_Make_Struct (klass, Ecore_Evas *, - NULL, c_ecore_evas_free, ee); - - rb_obj_call_init (self, argc, argv); + rb_obj_call_init (self, 0, NULL); return self; } @@ -73,6 +67,4 @@ void Init_GlX11 (void) VALUE cGlX11 = rb_define_class_under (mEvas, "GlX11", cEcoreEvas); rb_define_singleton_method (cGlX11, "new", c_new, -1); - rb_define_method (cGlX11, "initialize", c_init, -1); } - diff --git a/src/ecore_evas/rb_software_x11.c b/src/ecore_evas/rb_software_x11.c index 04f70b0..d61c66f 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 25 2004-06-26 23:07:01Z tilman $ + * $Id: rb_software_x11.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -20,19 +20,21 @@ #include +#include #include #include "rb_ecore_evas_main.h" #include "rb_ecore_evas.h" -static VALUE c_init (int argc, VALUE *argv, VALUE self) +static VALUE c_new (int argc, VALUE *argv, VALUE klass) { - VALUE disp, parent, geom[4]; + VALUE self, disp, parent, geom[4]; Ecore_Evas **ee = NULL; char *cdisp = NULL; int i, igeom[4] = {0, 0, 0, 0}; - Data_Get_Struct (self, Ecore_Evas *, ee); + self = Data_Make_Struct (klass, Ecore_Evas *, + NULL, c_ecore_evas_free, ee); rb_scan_args (argc, argv, "06", &disp, &parent, &geom[0], &geom[1], &geom[2], &geom[3]); @@ -48,22 +50,14 @@ static VALUE c_init (int argc, VALUE *argv, VALUE self) igeom[i] = NUM2INT (geom[i]); } + ecore_init (); + ecore_evas_init (); + *ee = ecore_evas_software_x11_new (cdisp, 0, igeom[0], igeom[1], igeom[2], igeom[3]); - return self; -} - -static VALUE c_new (int argc, VALUE *argv, VALUE klass) -{ - VALUE self; - Ecore_Evas **ee; - - self = Data_Make_Struct (klass, Ecore_Evas *, - NULL, c_ecore_evas_free, ee); - - rb_obj_call_init (self, argc, argv); + rb_obj_call_init (self, 0, NULL); return self; } @@ -75,6 +69,4 @@ void Init_SoftwareX11 (void) cEcoreEvas); rb_define_singleton_method (cSoftwareX11, "new", c_new, -1); - rb_define_method (cSoftwareX11, "initialize", c_init, -1); } - diff --git a/src/ecore_job/rb_job.c b/src/ecore_job/rb_job.c index 255c1d6..e0b1691 100644 --- a/src/ecore_job/rb_job.c +++ b/src/ecore_job/rb_job.c @@ -1,5 +1,5 @@ /* - * $Id: rb_job.c 25 2004-06-26 23:07:01Z tilman $ + * $Id: rb_job.c 27 2004-07-08 18:25:05Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -20,6 +20,7 @@ #include +#include #include #include @@ -41,23 +42,13 @@ static void on_job (void *data) job->deleted = true; } -static VALUE c_init (VALUE self) -{ - RbEcoreJob *job = NULL; - - Data_Get_Struct (self, RbEcoreJob, job); - - job->cb = (void *) rb_block_proc (); - job->job = ecore_job_add (on_job, job); - - return self; -} - static void c_free (RbEcoreJob *job) { if (job->job && !job->deleted) ecore_job_del (job->job); + ecore_shutdown (); + free (job); } @@ -66,8 +57,16 @@ static VALUE c_new (VALUE klass) VALUE self; RbEcoreJob *job; + if (!rb_block_given_p ()) + return Qnil; + self = Data_Make_Struct (klass, RbEcoreJob, NULL, c_free, job); + ecore_init (); + + job->cb = (void *) rb_block_proc (); + job->job = ecore_job_add (on_job, job); + rb_obj_call_init (self, 0, NULL); return self; @@ -95,7 +94,6 @@ void Init_Job (void) cJob = rb_define_class_under (mJob, "Job", rb_cObject); rb_define_singleton_method (cJob, "new", c_new, 0); - rb_define_method (cJob, "initialize", c_init, 0); rb_define_method (cJob, "delete", c_delete, 0); } -- 2.30.2