We now use real structs to wrap objects.
authorTilman Sauerbeck <tilman@code-monkey.de>
Sun, 1 Aug 2004 10:18:39 +0000 (10:18 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Sun, 1 Aug 2004 10:18:39 +0000 (10:18 +0000)
This way we can get rid of rb_global_variable()'s.
Also put headers in their own subdirectory.

13 files changed:
src/ecore/rb_ecore.h
src/ecore/rb_idler.c
src/ecore/rb_timer.c
src/ecore_evas/Makefile.am
src/ecore_evas/rb_ecore_evas.c
src/ecore_evas/rb_ecore_evas.h
src/ecore_evas/rb_fb.c
src/ecore_evas/rb_gl_x11.c
src/ecore_evas/rb_software_x11.c
src/ecore_job/rb_job.c
src/ecore_x/Makefile.am
src/ecore_x/rb_window.c
src/ecore_x/rb_window.h

index 2c5d8165dca4cb6905fbb389f679c48ea9ee4c30..0c46a434f8f33f247b4391a58e9cd2e9a26490fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_ecore.h 45 2004-07-26 11:00:14Z tilman $
+ * $Id: rb_ecore.h 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #define GET_OBJ(obj, type, o) \
        type *(o) = NULL; \
 \
 #define GET_OBJ(obj, type, o) \
        type *(o) = NULL; \
 \
-       Data_Get_Struct ((obj), type, (o)); \
-\
-       if (!*(o)) { \
-               rb_raise (rb_eException, \
-                         "%s destroyed already", \
-                         rb_obj_classname ((obj))); \
-               return Qnil; \
-       }
+       Data_Get_Struct ((obj), type, (o));
 
 #define CHECK_BOOL(val) \
        if (TYPE ((val)) != T_TRUE && TYPE ((val)) != T_FALSE) { \
 
 #define CHECK_BOOL(val) \
        if (TYPE ((val)) != T_TRUE && TYPE ((val)) != T_FALSE) { \
                return Qnil; \
        }
 
                return Qnil; \
        }
 
+#define CHECK_CLASS(val, klass) \
+       if (!rb_obj_is_kind_of ((val), (klass))) { \
+               rb_raise (rb_eTypeError, \
+                         "wrong argument type %s (expected %s)", \
+                         rb_obj_classname ((val)), \
+                         rb_class2name ((klass))); \
+               return Qnil; \
+       }
+
 #define INSPECT(obj, type) \
        char buf[128]; \
 \
 #define INSPECT(obj, type) \
        char buf[128]; \
 \
@@ -48,7 +50,7 @@
 \
        snprintf (buf, sizeof (buf), \
                  "#<%s:%p ptr=%p>", rb_obj_classname ((obj)), \
 \
        snprintf (buf, sizeof (buf), \
                  "#<%s:%p ptr=%p>", rb_obj_classname ((obj)), \
-                 (void *) obj, *o); \
+                 (void *) obj, o->real); \
 \
        return rb_str_new2 (buf);
 
 \
        return rb_str_new2 (buf);
 
index ce6bc03817828da9f55585eb9517ad22adfa1b72..b890ef59a49b5726523e610a134c68ee03c33524 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_idler.c 40 2004-07-25 13:14:34Z tilman $
+ * $Id: rb_idler.c 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  */
 
 #include <ruby.h>
  */
 
 #include <ruby.h>
+#include <stdbool.h>
 
 #include <Ecore.h>
 
 #include <Ecore.h>
-#include <stdbool.h>
 
 #include "rb_ecore.h"
 
 typedef struct {
 
 #include "rb_ecore.h"
 
 typedef struct {
-       Ecore_Idler *idler;
-       void *cb;
+       Ecore_Idler *real;
+       VALUE callback;
        bool deleted;
        bool deleted;
-} RbEcoreIdler;
+} RbIdler;
 
 static int on_idler (void *data)
 {
        VALUE r;
 
 static int on_idler (void *data)
 {
        VALUE r;
-       RbEcoreIdler *idler = data;
+       RbIdler *idler = data;
 
 
-       r = rb_funcall ((VALUE) idler->cb, rb_intern ("call"), 0);
+       r = rb_funcall (idler->callback, rb_intern ("call"), 0);
 
        /* if the callback returns false, we return 0 and Ecore
         * will remove the idler
 
        /* if the callback returns false, we return 0 and Ecore
         * will remove the idler
@@ -47,10 +47,15 @@ static int on_idler (void *data)
        return (r != Qfalse);
 }
 
        return (r != Qfalse);
 }
 
-static void c_free (RbEcoreIdler *idler)
+static void c_mark (RbIdler *idler)
+{
+       rb_gc_mark (idler->callback);
+}
+
+static void c_free (RbIdler *idler)
 {
 {
-       if (idler->idler && !idler->deleted)
-               ecore_idler_del (idler->idler);
+       if (idler->real && !idler->deleted)
+               ecore_idler_del (idler->real);
 
        ecore_shutdown ();
 
 
        ecore_shutdown ();
 
@@ -60,17 +65,17 @@ static void c_free (RbEcoreIdler *idler)
 static VALUE c_new (VALUE klass)
 {
        VALUE self;
 static VALUE c_new (VALUE klass)
 {
        VALUE self;
-       RbEcoreIdler *idler;
+       RbIdler *idler;
 
        if (!rb_block_given_p ())
                return Qnil;
 
 
        if (!rb_block_given_p ())
                return Qnil;
 
-       self = Data_Make_Struct (klass, RbEcoreIdler, NULL, c_free, idler);
+       self = Data_Make_Struct (klass, RbIdler, c_mark, c_free, idler);
 
        ecore_init ();
 
 
        ecore_init ();
 
-       idler->cb = (void *) rb_block_proc ();
-       idler->idler = ecore_idler_add (on_idler, idler);
+       idler->callback = rb_block_proc ();
+       idler->real = ecore_idler_add (on_idler, idler);
 
        rb_obj_call_init (self, 0, NULL);
 
 
        rb_obj_call_init (self, 0, NULL);
 
@@ -79,13 +84,11 @@ static VALUE c_new (VALUE klass)
 
 static VALUE c_delete (VALUE self)
 {
 
 static VALUE c_delete (VALUE self)
 {
-       RbEcoreIdler *idler = NULL;
-
-       Data_Get_Struct (self, RbEcoreIdler, idler);
+       GET_OBJ (self, RbIdler, idler);
 
 
-       if (idler->idler && !idler->deleted) {
-               ecore_idler_del (idler->idler);
-               idler->idler = NULL;
+       if (idler->real && !idler->deleted) {
+               ecore_idler_del (idler->real);
+               idler->real = NULL;
                idler->deleted = true;
        } else
                rb_raise (rb_eException, "Idler already deleted!");
                idler->deleted = true;
        } else
                rb_raise (rb_eException, "Idler already deleted!");
index 543a5415f6dcc2c3ad2a423dce81ec361b8d04b1..fa9ab155cb960d0a10482272215e00b945a1fad2 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_timer.c 40 2004-07-25 13:14:34Z tilman $
+ * $Id: rb_timer.c 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  */
 
 #include <ruby.h>
  */
 
 #include <ruby.h>
+#include <stdbool.h>
 
 #include <Ecore.h>
 
 #include <Ecore.h>
-#include <stdbool.h>
 
 #include "rb_ecore.h"
 
 typedef struct {
 
 #include "rb_ecore.h"
 
 typedef struct {
-       Ecore_Timer *timer;
-       void *cb;
+       Ecore_Timer *real;
+       VALUE callback;
        bool deleted;
        bool deleted;
-} RbEcoreTimer;
+} RbTimer;
 
 static int on_timer (void *data)
 {
        VALUE r;
 
 static int on_timer (void *data)
 {
        VALUE r;
-       RbEcoreTimer *timer = data;
+       RbTimer *timer = data;
 
 
-       r = rb_funcall ((VALUE) timer->cb, rb_intern ("call"), 0);
+       r = rb_funcall (timer->callback, rb_intern ("call"), 0);
 
        /* if the callback returns false, we return 0 and Ecore
         * will remove the timer
 
        /* if the callback returns false, we return 0 and Ecore
         * will remove the timer
@@ -47,10 +47,15 @@ static int on_timer (void *data)
        return (r != Qfalse);
 }
 
        return (r != Qfalse);
 }
 
-static void c_free (RbEcoreTimer *timer)
+static void c_mark (RbTimer *timer)
+{
+       rb_gc_mark (timer->callback);
+}
+
+static void c_free (RbTimer *timer)
 {
 {
-       if (timer->timer && !timer->deleted)
-               ecore_timer_del (timer->timer);
+       if (timer->real && !timer->deleted)
+               ecore_timer_del (timer->real);
 
        ecore_shutdown ();
 
 
        ecore_shutdown ();
 
@@ -60,18 +65,18 @@ static void c_free (RbEcoreTimer *timer)
 static VALUE c_new (VALUE klass, VALUE interval)
 {
        VALUE self;
 static VALUE c_new (VALUE klass, VALUE interval)
 {
        VALUE self;
-       RbEcoreTimer *timer;
+       RbTimer *timer = NULL;
 
        if (!rb_block_given_p ())
                return Qnil;
 
 
        if (!rb_block_given_p ())
                return Qnil;
 
-       self = Data_Make_Struct (klass, RbEcoreTimer, NULL, c_free, timer);
+       self = Data_Make_Struct (klass, RbTimer, c_mark, c_free, timer);
 
        ecore_init ();
 
 
        ecore_init ();
 
-       timer->cb = (void *) rb_block_proc ();
-       timer->timer = ecore_timer_add (NUM2DBL (interval),
-                                       on_timer, timer);
+       timer->callback = rb_block_proc ();
+       timer->real = ecore_timer_add (NUM2DBL (interval),
+                                      on_timer, timer);
 
        rb_obj_call_init (self, 0, NULL);
 
 
        rb_obj_call_init (self, 0, NULL);
 
@@ -80,13 +85,11 @@ static VALUE c_new (VALUE klass, VALUE interval)
 
 static VALUE c_delete (VALUE self)
 {
 
 static VALUE c_delete (VALUE self)
 {
-       RbEcoreTimer *timer = NULL;
-
-       Data_Get_Struct (self, RbEcoreTimer, timer);
+       GET_OBJ (self, RbTimer, timer);
 
 
-       if (timer->timer && !timer->deleted) {
-               ecore_timer_del (timer->timer);
-               timer->timer = NULL;
+       if (timer->real && !timer->deleted) {
+               ecore_timer_del (timer->real);
+               timer->real = NULL;
                timer->deleted = true;
        } else
                rb_raise (rb_eException, "Timer already deleted!");
                timer->deleted = true;
        } else
                rb_raise (rb_eException, "Timer already deleted!");
index 9b4b71a32c1ef4fb48f6414c7b4a6aa936ed3b29..355e99d0947052d37dfb518cf346eea0b3ce024a 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am 40 2004-07-25 13:14:34Z tilman $
+## $Id: Makefile.am 50 2004-08-01 10:18:39Z tilman $
 
 AM_CFLAGS = $(ECORE_CFLAGS) $(EVAS_CFLAGS)
 INCLUDES = -I$(RUBYDIR) -I$(RUBYSITEDIR)
 
 AM_CFLAGS = $(ECORE_CFLAGS) $(EVAS_CFLAGS)
 INCLUDES = -I$(RUBYDIR) -I$(RUBYSITEDIR)
@@ -15,5 +15,5 @@ ecore_evas_la_SOURCES = rb_ecore_evas_main.c rb_ecore_evas_main.h \
 ecore_evas_la_LIBADD = -lruby $(ECORE_LIBS) $(EVAS_LIBS)
 ecore_evas_la_LDFLAGS = -module -avoid-version
 
 ecore_evas_la_LIBADD = -lruby $(ECORE_LIBS) $(EVAS_LIBS)
 ecore_evas_la_LDFLAGS = -module -avoid-version
 
-pkgincludedir = $(RUBYSITEDIR)
+pkgincludedir = $(RUBYSITEDIR)/ecore
 pkginclude_HEADERS = rb_ecore_evas.h
 pkginclude_HEADERS = rb_ecore_evas.h
index 5362cf88f3361ca7e0934399ba6b8ee01d9a2d26..057b5be85c62de4b4590b519da9ee0ca93eae33b 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_ecore_evas.c 45 2004-07-26 11:00:14Z tilman $
+ * $Id: rb_ecore_evas.c 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  */
 
 #include <ruby.h>
  */
 
 #include <ruby.h>
+#include <stdbool.h>
 
 #include <Ecore.h>
 #include <Ecore_Evas.h>
 
 #include <Ecore.h>
 #include <Ecore_Evas.h>
-#include <rb_evas.h>
+#include <evas/rb_evas.h>
 
 #define __RB_ECORE_EVAS_C
 #include "../ecore/rb_ecore.h"
 
 #define __RB_ECORE_EVAS_C
 #include "../ecore/rb_ecore.h"
 #include "rb_ecore_evas.h"
 
 #define CALLBACK_ADD_HANDLER(name) \
 #include "rb_ecore_evas.h"
 
 #define CALLBACK_ADD_HANDLER(name) \
-       static void on_##name (Ecore_Evas *ee) \
+       static void on_##name (Ecore_Evas *real) \
        { \
        { \
-               VALUE self = rb_hash_aref (objects, INT2NUM ((long) ee)); \
-               VALUE hash = rb_hash_aref (callbacks, self); \
+               VALUE self = rb_hash_aref (objects, INT2NUM ((long) real)); \
+               VALUE cb; \
 \
 \
-               rb_funcall (rb_hash_aref (hash, rb_str_new2 (#name)), \
-                           rb_intern ("call"), 0); \
+               GET_OBJ (self, RbEcoreEvas, ee); \
+\
+               cb = rb_hash_aref (ee->callbacks, rb_str_new2 (#name)); \
+               rb_funcall (cb, rb_intern ("call"), 0); \
        } \
 \
        static VALUE c_on_##name (VALUE self) \
        { \
        } \
 \
        static VALUE c_on_##name (VALUE self) \
        { \
-               VALUE hash; \
-\
-               GET_OBJ (self, Ecore_Evas *, ee); \
+               GET_OBJ (self, RbEcoreEvas, ee); \
 \
                if (!rb_block_given_p ()) \
                        return Qnil; \
 \
 \
                if (!rb_block_given_p ()) \
                        return Qnil; \
 \
-               if (NIL_P ((hash = rb_hash_aref (callbacks, self)))) { \
-                       hash = rb_hash_new (); \
-\
-                       rb_global_variable (&hash); \
-                       rb_hash_aset (callbacks, self, hash); \
-               } \
+               rb_hash_aset (ee->callbacks, rb_str_new2 (#name), \
+                             rb_block_proc ()); \
 \
 \
-               rb_hash_aset (hash, rb_str_new2 (#name), rb_block_proc ()); \
-\
-               ecore_evas_callback_##name##_set (*ee, on_##name); \
+               ecore_evas_callback_##name##_set (ee->real, on_##name); \
 \
                return Qnil; \
        }
 \
                return Qnil; \
        }
        rb_define_method ((mod), "on_"#name, c_on_##name, 0);
 
 VALUE cEcoreEvas;
        rb_define_method ((mod), "on_"#name, c_on_##name, 0);
 
 VALUE cEcoreEvas;
-static VALUE evases, callbacks, objects;
+static VALUE objects;
 
 /* called by the child classes */
 
 /* called by the child classes */
-void c_ecore_evas_free (Ecore_Evas **ee)
+void c_ecore_evas_mark (RbEcoreEvas *ee)
 {
 {
-       if (*ee) {
-               rb_hash_aset (objects, INT2NUM ((long) *ee), Qnil);
-               ecore_evas_free (*ee);
-       }
+       if (!NIL_P (ee->evas))
+               rb_gc_mark (ee->evas);
+
+       rb_gc_mark (ee->callbacks);
+}
 
 
-       rb_hash_aset (evases, INT2NUM ((long) ee), Qnil);
+void c_ecore_evas_free (RbEcoreEvas *ee, bool free_mem)
+{
+       if (ee->real)
+               ecore_evas_free (ee->real);
 
        ecore_evas_shutdown ();
        ecore_shutdown ();
 
 
        ecore_evas_shutdown ();
        ecore_shutdown ();
 
-       free (ee);
+       if (free_mem)
+               free (ee);
 }
 
 }
 
-static VALUE c_initialize (int argc, VALUE *argv, VALUE self)
+static VALUE c_init (int argc, VALUE *argv, VALUE self)
 {
 {
-       Ecore_Evas **ee = NULL;
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       Data_Get_Struct (self, Ecore_Evas *, ee);
+       ee->evas = Qnil;
+       ee->callbacks = rb_hash_new ();
 
 
-       rb_hash_aset (objects, INT2NUM ((long) *ee), self);
+       rb_hash_aset (objects, INT2NUM ((long) ee->real), self);
 
        return Qnil;
 }
 
 static VALUE c_inspect (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_inspect (VALUE self)
 {
-       INSPECT (self, Ecore_Evas *);
+       INSPECT (self, RbEcoreEvas);
 }
 
 static VALUE c_show (VALUE self)
 {
 }
 
 static VALUE c_show (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       ecore_evas_show (*ee);
+       ecore_evas_show (ee->real);
 
        return Qnil;
 }
 
 static VALUE c_hide (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_hide (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       ecore_evas_hide (*ee);
+       ecore_evas_hide (ee->real);
 
        return Qnil;
 }
 
 static VALUE c_visible_get (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_visible_get (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       return ecore_evas_visibility_get (*ee) ? Qtrue : Qfalse;
+       return ecore_evas_visibility_get (ee->real) ? Qtrue : Qfalse;
 }
 
 static VALUE c_raise (VALUE self)
 {
 }
 
 static VALUE c_raise (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       ecore_evas_raise (*ee);
+       ecore_evas_raise (ee->real);
 
        return Qnil;
 }
 
 static VALUE c_lower (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_lower (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       ecore_evas_lower (*ee);
+       ecore_evas_lower (ee->real);
 
        return Qnil;
 }
 
 static VALUE c_layer_get (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_layer_get (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       return INT2FIX (ecore_evas_layer_get (*ee));
+       return INT2FIX (ecore_evas_layer_get (ee->real));
 }
 
 static VALUE c_layer_set (VALUE self, VALUE val)
 {
 }
 
 static VALUE c_layer_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        Check_Type (val, T_FIXNUM);
 
 
        Check_Type (val, T_FIXNUM);
 
-       ecore_evas_layer_set (*ee, FIX2INT (val));
+       ecore_evas_layer_set (ee->real, FIX2INT (val));
 
        return Qnil;
 }
 
 static VALUE c_evas_get (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_evas_get (VALUE self)
 {
-       VALUE evas;
-
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       if (NIL_P (evas = rb_hash_aref (evases, INT2NUM ((long) (ee))))) {
-               evas = TO_EVAS (self, ecore_evas_get (*ee));
-               rb_hash_aset (evases, INT2NUM ((long) ee), evas);
-       }
+       if (NIL_P (ee->evas))
+               ee->evas = TO_EVAS (self, ecore_evas_get (ee->real));
 
 
-       return evas;
+       return ee->evas;
 }
 
 static VALUE c_geometry_get (VALUE self)
 {
        int x = 0, y = 0, w = 0, h = 0;
 
 }
 
 static VALUE c_geometry_get (VALUE self)
 {
        int x = 0, y = 0, w = 0, h = 0;
 
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       ecore_evas_geometry_get (*ee, &x, &y, &w, &h);
+       ecore_evas_geometry_get (ee->real, &x, &y, &w, &h);
 
        return rb_ary_new3 (4, INT2FIX (x), INT2FIX (y),
                            INT2FIX (w), INT2FIX (h));
 
        return rb_ary_new3 (4, INT2FIX (x), INT2FIX (y),
                            INT2FIX (w), INT2FIX (h));
@@ -191,21 +188,21 @@ static VALUE c_get_size_min (VALUE self)
 {
        int w = 0, h = 0;
 
 {
        int w = 0, h = 0;
 
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       ecore_evas_size_min_get (*ee, &w, &h);
+       ecore_evas_size_min_get (ee->real, &w, &h);
 
        return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h));
 }
 
 static VALUE c_set_size_min (VALUE self, VALUE w, VALUE h)
 {
 
        return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h));
 }
 
 static VALUE c_set_size_min (VALUE self, VALUE w, VALUE h)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);
 
 
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);
 
-       ecore_evas_size_min_set (*ee, FIX2INT (w), FIX2INT (h));
+       ecore_evas_size_min_set (ee->real, FIX2INT (w), FIX2INT (h));
 
        return Qnil;
 }
 
        return Qnil;
 }
@@ -214,45 +211,45 @@ static VALUE c_get_size_max (VALUE self)
 {
        int w = 0, h = 0;
 
 {
        int w = 0, h = 0;
 
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       ecore_evas_size_max_get (*ee, &w, &h);
+       ecore_evas_size_max_get (ee->real, &w, &h);
 
        return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h));
 }
 
 static VALUE c_set_size_max (VALUE self, VALUE w, VALUE h)
 {
 
        return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h));
 }
 
 static VALUE c_set_size_max (VALUE self, VALUE w, VALUE h)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);
 
 
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);
 
-       ecore_evas_size_max_set (*ee, FIX2INT (w), FIX2INT (h));
+       ecore_evas_size_max_set (ee->real, FIX2INT (w), FIX2INT (h));
 
        return Qnil;
 }
 
 static VALUE c_move (VALUE self, VALUE x, VALUE y)
 {
 
        return Qnil;
 }
 
 static VALUE c_move (VALUE self, VALUE x, VALUE y)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        Check_Type (x, T_FIXNUM);
        Check_Type (y, T_FIXNUM);
 
 
        Check_Type (x, T_FIXNUM);
        Check_Type (y, T_FIXNUM);
 
-       ecore_evas_move (*ee, FIX2INT (x), FIX2INT (y));
+       ecore_evas_move (ee->real, FIX2INT (x), FIX2INT (y));
 
        return Qnil;
 }
 
 static VALUE c_resize (VALUE self, VALUE w, VALUE h)
 {
 
        return Qnil;
 }
 
 static VALUE c_resize (VALUE self, VALUE w, VALUE h)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);
 
 
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);
 
-       ecore_evas_resize (*ee, FIX2INT (w), FIX2INT (h));
+       ecore_evas_resize (ee->real, FIX2INT (w), FIX2INT (h));
 
        return Qnil;
 }
 
        return Qnil;
 }
@@ -261,9 +258,9 @@ static VALUE c_title_get (VALUE self)
 {
        const char *tmp;
 
 {
        const char *tmp;
 
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       if (!(tmp = ecore_evas_title_get (*ee)))
+       if (!(tmp = ecore_evas_title_get (ee->real)))
                return Qnil;
        else
                return rb_str_new2 (tmp);
                return Qnil;
        else
                return rb_str_new2 (tmp);
@@ -271,83 +268,83 @@ static VALUE c_title_get (VALUE self)
 
 static VALUE c_title_set (VALUE self, VALUE val)
 {
 
 static VALUE c_title_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        Check_Type (val, T_STRING);
 
 
        Check_Type (val, T_STRING);
 
-       ecore_evas_title_set (*ee, StringValuePtr (val));
+       ecore_evas_title_set (ee->real, StringValuePtr (val));
 
        return Qnil;
 }
 
 static VALUE c_borderless_get (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_borderless_get (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       return ecore_evas_borderless_get (*ee) ? Qtrue : Qfalse;
+       return ecore_evas_borderless_get (ee->real) ? Qtrue : Qfalse;
 }
 
 static VALUE c_borderless_set (VALUE self, VALUE val)
 {
 }
 
 static VALUE c_borderless_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        CHECK_BOOL (val);
 
 
        CHECK_BOOL (val);
 
-       ecore_evas_borderless_set (*ee, val == Qtrue ? 1 : 0);
+       ecore_evas_borderless_set (ee->real, val == Qtrue);
 
        return Qnil;
 }
 
 static VALUE c_shaped_get (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_shaped_get (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       return ecore_evas_shaped_get (*ee) ? Qtrue : Qfalse;
+       return ecore_evas_shaped_get (ee->real) ? Qtrue : Qfalse;
 }
 
 static VALUE c_shaped_set (VALUE self, VALUE val)
 {
 }
 
 static VALUE c_shaped_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        CHECK_BOOL (val);
 
 
        CHECK_BOOL (val);
 
-       ecore_evas_shaped_set (*ee, val == Qtrue ? 1 : 0);
+       ecore_evas_shaped_set (ee->real, val == Qtrue);
 
        return Qnil;
 }
 
 static VALUE c_sticky_get (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_sticky_get (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       return ecore_evas_sticky_get (*ee) ? Qtrue : Qfalse;
+       return ecore_evas_sticky_get (ee->real) ? Qtrue : Qfalse;
 }
 
 static VALUE c_sticky_set (VALUE self, VALUE val)
 {
 }
 
 static VALUE c_sticky_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        CHECK_BOOL (val);
 
 
        CHECK_BOOL (val);
 
-       ecore_evas_sticky_set (*ee, val == Qtrue ? 1 : 0);
+       ecore_evas_sticky_set (ee->real, val == Qtrue);
 
        return Qnil;
 }
 
 static VALUE c_rotation_get (VALUE self)
 {
 
        return Qnil;
 }
 
 static VALUE c_rotation_get (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
 
-       return INT2FIX (ecore_evas_rotation_get (*ee));
+       return INT2FIX (ecore_evas_rotation_get (ee->real));
 }
 
 static VALUE c_rotation_set (VALUE self, VALUE val)
 {
 }
 
 static VALUE c_rotation_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        Check_Type (val, T_FIXNUM);
 
 
        Check_Type (val, T_FIXNUM);
 
-       ecore_evas_rotation_set (*ee, FIX2INT (val));
+       ecore_evas_rotation_set (ee->real, FIX2INT (val));
 
        return Qnil;
 }
 
        return Qnil;
 }
@@ -355,14 +352,14 @@ static VALUE c_rotation_set (VALUE self, VALUE val)
 /* FIXME: this is unsafe! */
 static VALUE c_delete (VALUE self)
 {
 /* FIXME: this is unsafe! */
 static VALUE c_delete (VALUE self)
 {
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        /* reap our children */
        rb_gc_start ();
 
 
        /* reap our children */
        rb_gc_start ();
 
-       ecore_evas_free (*ee);
-       rb_hash_aset (objects, INT2NUM ((long) *ee), Qnil);
-       *ee = NULL;
+       ecore_evas_free (ee->real);
+       rb_hash_aset (objects, INT2NUM ((long) ee->real), Qnil);
+       ee->real = NULL;
 
        return Qnil;
 }
 
        return Qnil;
 }
@@ -386,7 +383,7 @@ void Init_EcoreEvas (void)
 
        rb_define_private_method (rb_singleton_class (cEcoreEvas),
                                  "new", NULL, 0);
 
        rb_define_private_method (rb_singleton_class (cEcoreEvas),
                                  "new", NULL, 0);
-       rb_define_method (cEcoreEvas, "initialize", c_initialize, -1);
+       rb_define_method (cEcoreEvas, "initialize", c_init, -1);
        rb_define_method (cEcoreEvas, "inspect", c_inspect, 0);
        rb_define_method (cEcoreEvas, "delete", c_delete, 0);
        rb_define_method (cEcoreEvas, "show", c_show, 0);
        rb_define_method (cEcoreEvas, "inspect", c_inspect, 0);
        rb_define_method (cEcoreEvas, "delete", c_delete, 0);
        rb_define_method (cEcoreEvas, "show", c_show, 0);
@@ -428,12 +425,6 @@ void Init_EcoreEvas (void)
        CALLBACK_ADD (cEcoreEvas, pre_render);
        CALLBACK_ADD (cEcoreEvas, post_render);
 
        CALLBACK_ADD (cEcoreEvas, pre_render);
        CALLBACK_ADD (cEcoreEvas, post_render);
 
-       evases = rb_hash_new ();
-       rb_global_variable (&evases);
-
        objects = rb_hash_new ();
        rb_global_variable (&objects);
        objects = rb_hash_new ();
        rb_global_variable (&objects);
-
-       callbacks = rb_hash_new ();
-       rb_global_variable (&callbacks);
 }
 }
index 25d4209d31b99e7fd5f06ef9039b2b4d9c6f6d84..8f9bff0f416c2c6d5d1b34239d5ffe2d755e22d3 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_ecore_evas.h 45 2004-07-26 11:00:14Z tilman $
+ * $Id: rb_ecore_evas.h 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #ifndef __RB_ECORE_EVAS_H
 #define __RB_ECORE_EVAS_H
 
 #ifndef __RB_ECORE_EVAS_H
 #define __RB_ECORE_EVAS_H
 
-#ifndef __RB_ECORE_EVAS_C
-VALUE cEcoreEvas;
-#endif
+#include <stdbool.h>
+
+typedef struct {
+       Ecore_Evas *real;
+       VALUE evas;
+       VALUE callbacks;
+} RbEcoreEvas;
 
 void Init_EcoreEvas (void);
 
 
 void Init_EcoreEvas (void);
 
-void c_ecore_evas_free (Ecore_Evas **ee);
+void c_ecore_evas_mark (RbEcoreEvas *ee);
+void c_ecore_evas_free (RbEcoreEvas *ee, bool free_mem);
+
+#ifndef __RB_ECORE_EVAS_C
+VALUE cEcoreEvas;
+#endif
 
 #endif
 
 #endif
index 8359ef2b6a943eba3582f7a96ad149f6b86ec984..42412ee25740371595059069315794036f9911e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_fb.c 40 2004-07-25 13:14:34Z tilman $
+ * $Id: rb_fb.c 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include "rb_ecore_evas_main.h"
 #include "rb_ecore_evas.h"
 
 #include "rb_ecore_evas_main.h"
 #include "rb_ecore_evas.h"
 
+static void c_free (RbEcoreEvas *ee)
+{
+       c_ecore_evas_free (ee, true);
+}
+
 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 {
        VALUE self, disp, rot, w, h;
 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 {
        VALUE self, disp, rot, w, h;
-       Ecore_Evas **ee = NULL;
+       RbEcoreEvas *ee = NULL;
        char *cdisp = NULL;
        int irot = 0, iw = 0, ih = 0;
 
        char *cdisp = NULL;
        int irot = 0, iw = 0, ih = 0;
 
-       self = Data_Make_Struct (klass, Ecore_Evas *,
-                                NULL, c_ecore_evas_free, ee);
+       self = Data_Make_Struct (klass, RbEcoreEvas,
+                                c_ecore_evas_mark, c_free, ee);
 
        rb_scan_args (argc, argv, "04", &disp, &rot, &w, &h);
 
 
        rb_scan_args (argc, argv, "04", &disp, &rot, &w, &h);
 
@@ -45,23 +50,23 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 
        if (!NIL_P (rot)) {
                Check_Type (rot, T_FIXNUM);
 
        if (!NIL_P (rot)) {
                Check_Type (rot, T_FIXNUM);
-               irot = NUM2INT (rot);
+               irot = FIX2INT (rot);
        }
 
        if (!NIL_P (w)) {
                Check_Type (w, T_FIXNUM);
        }
 
        if (!NIL_P (w)) {
                Check_Type (w, T_FIXNUM);
-               iw = NUM2INT (w);
+               iw = FIX2INT (w);
        }
 
        if (!NIL_P (h)) {
                Check_Type (h, T_FIXNUM);
        }
 
        if (!NIL_P (h)) {
                Check_Type (h, T_FIXNUM);
-               ih = NUM2INT (h);
+               ih = FIX2INT (h);
        }
 
        ecore_init ();
        ecore_evas_init ();
 
        }
 
        ecore_init ();
        ecore_evas_init ();
 
-       *ee = ecore_evas_fb_new (cdisp, irot, iw, ih);
+       ee->real = ecore_evas_fb_new (cdisp, irot, iw, ih);
 
        rb_obj_call_init (self, 0, NULL);
 
 
        rb_obj_call_init (self, 0, NULL);
 
index 274230e4cb01bfcf8ac9500071e7b8b8dafa744d..c143ea7bcf68dee77f2a101c3c1246ae0508f88a 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_gl_x11.c 40 2004-07-25 13:14:34Z tilman $
+ * $Id: rb_gl_x11.c 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include "rb_ecore_evas_main.h"
 #include "rb_ecore_evas.h"
 
 #include "rb_ecore_evas_main.h"
 #include "rb_ecore_evas.h"
 
+static void c_free (RbEcoreEvas *ee)
+{
+       c_ecore_evas_free (ee, true);
+}
+
 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 {
        VALUE self, disp, parent, geom[4];
 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 {
        VALUE self, disp, parent, geom[4];
-       Ecore_Evas **ee = NULL;
+       RbEcoreEvas *ee = NULL;
        char *cdisp = NULL;
        int i, igeom[4] = {0, 0, 0, 0};
 
        char *cdisp = NULL;
        int i, igeom[4] = {0, 0, 0, 0};
 
-       self = Data_Make_Struct (klass, Ecore_Evas *,
-                                NULL, c_ecore_evas_free, ee);
+       self = Data_Make_Struct (klass, RbEcoreEvas,
+                                c_ecore_evas_mark, c_free, ee);
 
        rb_scan_args (argc, argv, "06", &disp, &parent,
                      &geom[0], &geom[1], &geom[2], &geom[3]);
 
        rb_scan_args (argc, argv, "06", &disp, &parent,
                      &geom[0], &geom[1], &geom[2], &geom[3]);
@@ -47,15 +52,15 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass)
        for (i = 0; i < 4; i++)
                if (!NIL_P (geom[i])) {
                        Check_Type (geom[i], T_FIXNUM);
        for (i = 0; i < 4; i++)
                if (!NIL_P (geom[i])) {
                        Check_Type (geom[i], T_FIXNUM);
-                       igeom[i] = NUM2INT (geom[i]);
+                       igeom[i] = FIX2INT (geom[i]);
                }
 
        ecore_init ();
        ecore_evas_init ();
 
                }
 
        ecore_init ();
        ecore_evas_init ();
 
-       *ee = ecore_evas_gl_x11_new (cdisp, 0,
-                                    igeom[0], igeom[1],
-                                    igeom[2], igeom[3]);
+       ee->real = ecore_evas_gl_x11_new (cdisp, 0,
+                                         igeom[0], igeom[1],
+                                         igeom[2], igeom[3]);
 
        rb_obj_call_init (self, 0, NULL);
 
 
        rb_obj_call_init (self, 0, NULL);
 
index 055c17e1a357a6c55f0c95de89784e33675a7295..f694e3e68e7eda916b7fe93620f0d7a5f7ae210c 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_software_x11.c 40 2004-07-25 13:14:34Z tilman $
+ * $Id: rb_software_x11.c 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -19,6 +19,7 @@
  */
 
 #include <ruby.h>
  */
 
 #include <ruby.h>
+#include <stdbool.h>
 
 #include <Ecore.h>
 #include <Ecore_Evas.h>
 
 #include <Ecore.h>
 #include <Ecore_Evas.h>
 #include "rb_ecore_evas_main.h"
 #include "rb_ecore_evas.h"
 
 #include "rb_ecore_evas_main.h"
 #include "rb_ecore_evas.h"
 
-static VALUE windows;
+typedef struct {
+       RbEcoreEvas ee;
+       VALUE window;
+} RbEcoreEvasSoftwareX11;
+
+static void c_mark (RbEcoreEvasSoftwareX11 *ee)
+{
+       c_ecore_evas_mark (&ee->ee);
+
+       if (!NIL_P (ee->window))
+               rb_gc_mark (ee->window);
+}
+
+static void c_free (RbEcoreEvasSoftwareX11 *ee)
+{
+       c_ecore_evas_free (&ee->ee, false);
+
+       free (ee);
+}
 
 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 {
        VALUE self, disp, parent, geom[4];
 
 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 {
        VALUE self, disp, parent, geom[4];
-       Ecore_Evas **ee = NULL;
+       RbEcoreEvasSoftwareX11 *ee = NULL;
        char *cdisp = NULL;
        int i, igeom[4] = {0, 0, 0, 0};
 
        char *cdisp = NULL;
        int i, igeom[4] = {0, 0, 0, 0};
 
-       self = Data_Make_Struct (klass, Ecore_Evas *,
-                                NULL, c_ecore_evas_free, ee);
+       self = Data_Make_Struct (klass, RbEcoreEvasSoftwareX11,
+                                c_mark, c_free, ee);
 
        rb_scan_args (argc, argv, "06", &disp, &parent,
                      &geom[0], &geom[1], &geom[2], &geom[3]);
 
        rb_scan_args (argc, argv, "06", &disp, &parent,
                      &geom[0], &geom[1], &geom[2], &geom[3]);
@@ -51,15 +70,16 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass)
        for (i = 0; i < 4; i++)
                if (!NIL_P (geom[i])) {
                        Check_Type (geom[i], T_FIXNUM);
        for (i = 0; i < 4; i++)
                if (!NIL_P (geom[i])) {
                        Check_Type (geom[i], T_FIXNUM);
-                       igeom[i] = NUM2INT (geom[i]);
+                       igeom[i] = FIX2INT (geom[i]);
                }
 
        ecore_init ();
        ecore_evas_init ();
 
                }
 
        ecore_init ();
        ecore_evas_init ();
 
-       *ee = ecore_evas_software_x11_new (cdisp, 0,
-                                          igeom[0], igeom[1],
-                                          igeom[2], igeom[3]);
+       ee->ee.real = ecore_evas_software_x11_new (cdisp, 0,
+                                                  igeom[0], igeom[1],
+                                                  igeom[2], igeom[3]);
+       ee->window = Qnil;
 
        rb_obj_call_init (self, 0, NULL);
 
 
        rb_obj_call_init (self, 0, NULL);
 
@@ -68,18 +88,16 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass)
 
 static VALUE c_window_get (VALUE self)
 {
 
 static VALUE c_window_get (VALUE self)
 {
-       VALUE o;
        Ecore_X_Window w;
 
        Ecore_X_Window w;
 
-       GET_OBJ (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvasSoftwareX11, ee);
 
 
-       if (NIL_P (o = rb_hash_aref (windows, INT2NUM ((long) (ee))))) {
-               w = ecore_evas_software_x11_window_get (*ee);
-               o = TO_ECORE_X_WINDOW (self, w);
-               rb_hash_aset (windows, INT2NUM ((long) ee), o);
+       if (NIL_P (ee->window)) {
+               w = ecore_evas_software_x11_window_get (ee->ee.real);
+               ee->window = TO_ECORE_X_WINDOW (self, w);
        }
 
        }
 
-       return o;
+       return ee->window;
 }
 
 void Init_SoftwareX11 (void)
 }
 
 void Init_SoftwareX11 (void)
@@ -92,7 +110,4 @@ void Init_SoftwareX11 (void)
 
        rb_define_singleton_method (c, "new", c_new, -1);
        rb_define_method (c, "window", c_window_get, 0);
 
        rb_define_singleton_method (c, "new", c_new, -1);
        rb_define_method (c, "window", c_window_get, 0);
-
-       windows = rb_hash_new ();
-       rb_global_variable (&windows);
 }
 }
index 0ef669be9d91b53a4b5ada85d2ce7fb529190f5c..d4348cffb0660f8c6ebb598eaddd0f8e6583e960 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_job.c 40 2004-07-25 13:14:34Z tilman $
+ * $Id: rb_job.c 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include "rb_ecore_job.h"
 
 typedef struct {
 #include "rb_ecore_job.h"
 
 typedef struct {
-       Ecore_Job *job;
-       void *cb;
+       Ecore_Job *real;
+       VALUE callback;
        bool deleted;
        bool deleted;
-} RbEcoreJob;
+} RbJob;
 
 static void on_job (void *data)
 {
 
 static void on_job (void *data)
 {
-       RbEcoreJob *job = data;
+       RbJob *job = data;
 
 
-       rb_funcall ((VALUE) job->cb, rb_intern ("call"), 0);
+       rb_funcall (job->callback, rb_intern ("call"), 0);
        job->deleted = true;
 }
 
        job->deleted = true;
 }
 
-static void c_free (RbEcoreJob *job)
+static void c_mark (RbJob *job)
 {
 {
-       if (job->job && !job->deleted)
-               ecore_job_del (job->job);
+       rb_gc_mark (job->callback);
+}
+
+static void c_free (RbJob *job)
+{
+       if (job->real && !job->deleted)
+               ecore_job_del (job->real);
 
        ecore_shutdown ();
 
 
        ecore_shutdown ();
 
@@ -53,17 +58,17 @@ static void c_free (RbEcoreJob *job)
 static VALUE c_new (VALUE klass)
 {
        VALUE self;
 static VALUE c_new (VALUE klass)
 {
        VALUE self;
-       RbEcoreJob *job;
+       RbJob *job;
 
        if (!rb_block_given_p ())
                return Qnil;
 
 
        if (!rb_block_given_p ())
                return Qnil;
 
-       self = Data_Make_Struct (klass, RbEcoreJob, NULL, c_free, job);
+       self = Data_Make_Struct (klass, RbJob, c_mark, c_free, job);
 
        ecore_init ();
 
 
        ecore_init ();
 
-       job->cb = (void *) rb_block_proc ();
-       job->job = ecore_job_add (on_job, job);
+       job->callback = rb_block_proc ();
+       job->real = ecore_job_add (on_job, job);
 
        rb_obj_call_init (self, 0, NULL);
 
 
        rb_obj_call_init (self, 0, NULL);
 
@@ -73,14 +78,14 @@ static VALUE c_new (VALUE klass)
 static VALUE c_delete (VALUE self)
 {
        VALUE ret = Qfalse;
 static VALUE c_delete (VALUE self)
 {
        VALUE ret = Qfalse;
-       RbEcoreJob *job = NULL;
+       RbJob *job = NULL;
 
 
-       Data_Get_Struct (self, RbEcoreJob, job);
+       Data_Get_Struct (self, RbJob, job);
 
 
-       if (job->job && !job->deleted) {
-               ecore_job_del (job->job);
+       if (job->real && !job->deleted) {
+               ecore_job_del (job->real);
                job->deleted = true;
                job->deleted = true;
-               job->job = NULL;
+               job->real = NULL;
                ret = Qtrue;
        }
 
                ret = Qtrue;
        }
 
index 0969cccb25ea22d76a3018a6b64fcc5b62d940f0..5632d00067142b007ed622375f5574a945cd6d68 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am 39 2004-07-25 13:13:57Z tilman $
+## $Id: Makefile.am 50 2004-08-01 10:18:39Z tilman $
 
 AM_CFLAGS = $(ECORE_CFLAGS)
 INCLUDES = -I$(RUBYDIR) -I$(RUBYSITEDIR)
 
 AM_CFLAGS = $(ECORE_CFLAGS)
 INCLUDES = -I$(RUBYDIR) -I$(RUBYSITEDIR)
@@ -11,3 +11,6 @@ ecore_x_la_SOURCES = rb_ecore_x.c rb_ecore_x.h \
 
 ecore_x_la_LIBADD = -lruby $(ECORE_LIBS)
 ecore_x_la_LDFLAGS = -module -avoid-version
 
 ecore_x_la_LIBADD = -lruby $(ECORE_LIBS)
 ecore_x_la_LDFLAGS = -module -avoid-version
+
+pkgincludedir = $(RUBYSITEDIR)/ecore
+pkginclude_HEADERS = rb_window.h
index 2d7e3c0d7b4f666218a8329c669ae22cccfc7b91..e046b6f37f67d1bc81ba511cea111a5beb6910f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_window.c 39 2004-07-25 13:13:57Z tilman $
+ * $Id: rb_window.c 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include <Ecore.h>
 #include <Ecore_X.h>
 
 #include <Ecore.h>
 #include <Ecore_X.h>
 
+#define __RB_WINDOW_C
+#include "../ecore/rb_ecore.h"
 #include "rb_ecore_x.h"
 #include "rb_ecore_x.h"
+#include "rb_window.h"
 
 
-static VALUE cWindow, parents;
+VALUE cWindow;
 
 
-static void c_mark (Ecore_X_Window *w)
+static void c_mark (RbWindow *w)
 {
 {
-       VALUE parent;
-
-       parent = rb_hash_aref (parents, INT2NUM ((long) (w)));
-       if (parent != Qnil)
-               rb_gc_mark (parent);
-}
-
-static void c_free (Ecore_X_Window *w)
-{
-       rb_hash_aset (parents, INT2NUM ((long) w), Qnil);
-
-       free (w);
+       if (!NIL_P (w->parent))
+               rb_gc_mark (w->parent);
 }
 
 VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w)
 {
        VALUE self;
 }
 
 VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w)
 {
        VALUE self;
-       Ecore_X_Window *my_w = NULL;
+       RbWindow *window = NULL;
 
 
-       if (NIL_P (parent) || !w)
+       if (!w)
                return Qnil;
 
                return Qnil;
 
-       self = Data_Make_Struct (cWindow, Ecore_X_Window,
-                                c_mark, c_free, my_w);
-       *my_w = w;
+       self = Data_Make_Struct (cWindow, RbWindow, c_mark, free, window);
 
 
-       rb_hash_aset (parents, INT2NUM ((long) my_w), parent);
+       window->real = w;
+       window->parent = parent;
 
        rb_obj_call_init (self, 0, NULL);
 
 
        rb_obj_call_init (self, 0, NULL);
 
@@ -69,7 +61,4 @@ void Init_Window (void)
        /* not publically instantiable yet */
        rb_define_private_method (rb_singleton_class (cWindow),
                                  "new", NULL, 0);
        /* not publically instantiable yet */
        rb_define_private_method (rb_singleton_class (cWindow),
                                  "new", NULL, 0);
-
-       parents = rb_hash_new ();
-       rb_global_variable (&parents);
 }
 }
index 198244fa1c4b457f069d886a72adb3d826548161..3dd8e3e40811880e6bc9fc49883d9d61b60f347f 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_window.h 39 2004-07-25 13:13:57Z tilman $
+ * $Id: rb_window.h 50 2004-08-01 10:18:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #ifndef __RB_WINDOW_H
 #define __RB_WINDOW_H
 
 #ifndef __RB_WINDOW_H
 #define __RB_WINDOW_H
 
+typedef struct {
+       Ecore_X_Window real;
+       VALUE parent;
+} RbWindow;
+
 void Init_Window (void);
 VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w);
 
 void Init_Window (void);
 VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w);
 
+#ifndef __RB_WINDOW_C
+extern VALUE cWindow;
+#endif
+
 #endif
 #endif