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

src/esmart_container/rb_esmart_container.c
src/esmart_draggies/rb_esmart_draggies.c
src/esmart_trans_x11/rb_esmart_trans_x11.c
src/rb_esmart.h

index c2eb60cfe2a854032cd2930c92ef2db28fa6d41a..3c91108774b7cbc5835b8c2368f0006a2df10e1b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_esmart_container.c 36 2004-07-25 10:45:47Z tilman $
+ * $Id: rb_esmart_container.c 52 2004-08-01 10:19:14Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include <ruby.h>
 
 #include <Esmart/Esmart_Container.h>
-#include <rb_evas.h>
-#include <rb_evas_object.h>
+#include <evas/rb_evas.h>
+#include <evas/rb_evas_object.h>
 
 #include "../rb_esmart.h"
 
+static void c_free (RbEvasObject *e)
+{
+       c_evas_object_free (e, true);
+}
+
 static VALUE c_new (VALUE klass, VALUE evas)
 {
        VALUE self, argv[1];
-       Evas_Object **cont;
+       RbEvasObject *cont;
 
        CHECK_CLASS (evas, cEvas);
-       GET_OBJ (evas, Evas *, e);
+       GET_OBJ (evas, RbEvas, e);
 
-       self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
-                                c_evas_object_free, cont);
-       *cont = esmart_container_new (*e);
+       self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
+                                c_free, cont);
+       cont->real = esmart_container_new (e->real);
 
        argv[0] = evas;
        rb_obj_call_init (self, 1, argv);
@@ -46,90 +51,90 @@ static VALUE c_new (VALUE klass, VALUE evas)
 
 static VALUE c_element_append (VALUE self, VALUE element)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        CHECK_CLASS (element, cEvasObject);
        GET_OBJ (element, Evas_Object *, o);
 
-       esmart_container_element_append (*e, *o);
+       esmart_container_element_append (e->real, *o);
 
        return Qnil;
 }
 
 static VALUE c_element_prepend (VALUE self, VALUE element)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        CHECK_CLASS (element, cEvasObject);
        GET_OBJ (element, Evas_Object *, o);
 
-       esmart_container_element_prepend (*e, *o);
+       esmart_container_element_prepend (e->real, *o);
 
        return Qnil;
 }
 
 static VALUE c_element_remove (VALUE self, VALUE element)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        CHECK_CLASS (element, cEvasObject);
        GET_OBJ (element, Evas_Object *, o);
 
-       esmart_container_element_remove (*e, *o);
+       esmart_container_element_remove (e->real, *o);
 
        return Qnil;
 }
 
 static VALUE c_direction_get (VALUE self)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
-       return INT2FIX (esmart_container_direction_get (*e));
+       return INT2FIX (esmart_container_direction_get (e->real));
 }
 
 static VALUE c_direction_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (val, T_FIXNUM);
 
-       esmart_container_direction_set (*e, FIX2INT (val));
+       esmart_container_direction_set (e->real, FIX2INT (val));
 
        return Qnil;
 }
 
 static VALUE c_spacing_get (VALUE self)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
-       return INT2FIX (esmart_container_spacing_get (*e));
+       return INT2FIX (esmart_container_spacing_get (e->real));
 }
 
 static VALUE c_spacing_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (val, T_FIXNUM);
 
-       esmart_container_spacing_set (*e, FIX2INT (val));
+       esmart_container_spacing_set (e->real, FIX2INT (val));
 
        return Qnil;
 }
 
 static VALUE c_fill_policy_get (VALUE self)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
-       return INT2FIX (esmart_container_fill_policy_get (*e));
+       return INT2FIX (esmart_container_fill_policy_get (e->real));
 }
 
 static VALUE c_fill_policy_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (val, T_FIXNUM);
 
-       esmart_container_fill_policy_set (*e, FIX2INT (val));
+       esmart_container_fill_policy_set (e->real, FIX2INT (val));
 
        return Qnil;
 }
@@ -138,9 +143,9 @@ static VALUE c_get_padding (VALUE self)
 {
        double l = 0, r = 0, t = 0, b = 0;
 
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
-       esmart_container_padding_get (*e, &l, &r, &t, &b);
+       esmart_container_padding_get (e->real, &l, &r, &t, &b);
 
        return rb_ary_new3 (4, rb_float_new (l), rb_float_new (r),
                            rb_float_new (t), rb_float_new (b));
@@ -149,14 +154,14 @@ static VALUE c_get_padding (VALUE self)
 static VALUE c_set_padding (VALUE self, VALUE l, VALUE r,
                             VALUE t, VALUE b)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (l, T_FLOAT);
        Check_Type (r, T_FLOAT);
        Check_Type (t, T_FLOAT);
        Check_Type (b, T_FLOAT);
 
-       esmart_container_padding_set (*e, NUM2DBL (l), NUM2DBL (r),
+       esmart_container_padding_set (e->real, NUM2DBL (l), NUM2DBL (r),
                                      NUM2DBL (t), NUM2DBL (b));
 
        return Qnil;
@@ -164,11 +169,11 @@ static VALUE c_set_padding (VALUE self, VALUE l, VALUE r,
 
 static VALUE c_scroll (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (val, T_FIXNUM);
 
-       esmart_container_scroll (*e, FIX2INT (val));
+       esmart_container_scroll (e->real, FIX2INT (val));
 
        return Qnil;
 }
index c67dd7b76745d8e16eca5fe3fd42adfd45237e65..681e1958bc8b4dbfc27935f3eca2f5812589ee53 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_esmart_draggies.c 36 2004-07-25 10:45:47Z tilman $
+ * $Id: rb_esmart_draggies.c 52 2004-08-01 10:19:14Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include <ruby.h>
 
 #include <Esmart/Esmart_Draggies.h>
-#include <rb_evas.h>
-#include <rb_evas_object.h>
-#include <rb_ecore_evas.h>
+#include <evas/rb_evas.h>
+#include <evas/rb_evas_object.h>
+#include <ecore/rb_ecore_evas.h>
 
 #include "../rb_esmart.h"
 
+static void c_free (RbEvasObject *e)
+{
+       c_evas_object_free (e, true);
+}
+
 static VALUE c_new (VALUE klass, VALUE ecore_evas)
 {
        VALUE self, argv[1];
        static ID evas;
-       Evas_Object **draggies;
+       RbEvasObject *draggies;
 
        CHECK_CLASS (ecore_evas, cEcoreEvas);
-       GET_OBJ (ecore_evas, Ecore_Evas *, ee);
+       GET_OBJ (ecore_evas, RbEcoreEvas, ee);
 
-       self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
-                                c_evas_object_free, draggies);
-       *draggies = esmart_draggies_new (*ee);
+       self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
+                                c_free, draggies);
+       draggies->real = esmart_draggies_new (ee->real);
 
        if (!evas)
                evas = rb_intern ("evas");
@@ -51,11 +56,11 @@ static VALUE c_new (VALUE klass, VALUE ecore_evas)
 
 static VALUE c_button_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (val, T_FIXNUM);
 
-       esmart_draggies_button_set (*e, FIX2INT (val));
+       esmart_draggies_button_set (e->real, FIX2INT (val));
 
        return Qnil;
 }
index fa2983698d9e47f9c08f4025350996a6021f4730..4671d62dabde06d4fc2762467438559eb013c67a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_esmart_trans_x11.c 41 2004-07-25 13:15:54Z tilman $
+ * $Id: rb_esmart_trans_x11.c 52 2004-08-01 10:19:14Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include <ruby.h>
 
 #include <Esmart/Esmart_Trans_X11.h>
-#include <rb_evas.h>
-#include <rb_evas_object.h>
+#include <evas/rb_evas.h>
+#include <evas/rb_evas_object.h>
+#include <ecore/rb_window.h>
 
 #include "../rb_esmart.h"
 
+static void c_free (RbEvasObject *e)
+{
+       c_evas_object_free (e, true);
+}
+
 static VALUE c_new (VALUE klass, VALUE evas)
 {
        VALUE self, argv[1];
-       Evas_Object **trans;
+       RbEvasObject *trans;
 
        CHECK_CLASS (evas, cEvas);
-       GET_OBJ (evas, Evas *, e);
+       GET_OBJ (evas, RbEvas, e);
 
-       self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
-                                c_evas_object_free, trans);
-       *trans = esmart_trans_x11_new (*e);
+       self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
+                                c_free, trans);
+       trans->real = esmart_trans_x11_new (e->real);
 
        argv[0] = evas;
        rb_obj_call_init (self, 1, argv);
@@ -46,49 +52,44 @@ static VALUE c_new (VALUE klass, VALUE evas)
 
 static VALUE c_type_get (VALUE self)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
-       return INT2FIX (esmart_trans_x11_type_get (*e));
+       return INT2FIX (esmart_trans_x11_type_get (e->real));
 }
 
 static VALUE c_type_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (val, T_FIXNUM);
 
-       esmart_trans_x11_type_set (*e, FIX2INT (val));
+       esmart_trans_x11_type_set (e->real, FIX2INT (val));
 
        return Qnil;
 }
 
 static VALUE c_window_set (VALUE self, VALUE window)
 {
-       static VALUE c;
-
-       GET_OBJ (self, Evas_Object *, e);
-
-       if (!c)
-               c = rb_eval_string ("Ecore::X::Window");
+       GET_OBJ (self, RbEvasObject, e);
 
-       CHECK_CLASS (window, c);
-       GET_OBJ (window, Ecore_X_Window, w);
+       CHECK_CLASS (window, cWindow);
+       GET_OBJ (window, RbWindow, w);
 
-       esmart_trans_x11_window_set (*e, *w);
+       esmart_trans_x11_window_set (e->real, w->real);
 
        return Qnil;
 }
 
 static VALUE c_freshen (VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (x, T_FIXNUM);
        Check_Type (y, T_FIXNUM);
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);
 
-       esmart_trans_x11_freshen (*e, FIX2INT (x), FIX2INT (y),
+       esmart_trans_x11_freshen (e->real, FIX2INT (x), FIX2INT (y),
                                  FIX2INT (w), FIX2INT (h));
 
        return Qnil;
index a4bcb29324469dc63db8fa2019eaf403a4fdb0dd..a6e3b0ab7dcb0743a679d62efdc893a6e2032ff6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_esmart.h 44 2004-07-26 10:56:48Z tilman $
+ * $Id: rb_esmart.h 52 2004-08-01 10:19:14Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #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_CLASS(val, klass) \
        if (!rb_obj_is_kind_of ((val), (klass))) { \