Introduced TO_EVAS_OBJECT.
authorTilman Sauerbeck <tilman@code-monkey.de>
Mon, 16 Aug 2004 15:42:19 +0000 (15:42 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Mon, 16 Aug 2004 15:42:19 +0000 (15:42 +0000)
src/rb_evas.c
src/rb_evas_object.c
src/rb_evas_object.h
src/rb_smart.c

index 3e333a59dd9c2c1847c29b157380419f8436522f..c581e4f12e1cd86f8453bd65db8b91ce781887fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_evas.c 58 2004-08-10 14:10:02Z tilman $
+ * $Id: rb_evas.c 68 2004-08-16 15:42:19Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -253,19 +253,13 @@ static VALUE c_image_cache_flush (VALUE self)
 static VALUE c_top_get (VALUE self)
 {
        Evas_Object *o;
 static VALUE c_top_get (VALUE self)
 {
        Evas_Object *o;
-       void *obj;
 
        GET_OBJ (self, RbEvas, e);
 
        if (!(o = evas_object_top_get (e->real)))
                return Qnil;
 
 
        GET_OBJ (self, RbEvas, e);
 
        if (!(o = evas_object_top_get (e->real)))
                return Qnil;
 
-       if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
-               rb_raise (rb_eException, "EvasObject Ruby object key missing");
-               return Qnil;
-       }
-
-       return (VALUE) obj;
+       return TO_EVAS_OBJECT (o);
 }
 
 /*
 }
 
 /*
@@ -277,19 +271,13 @@ static VALUE c_top_get (VALUE self)
 static VALUE c_bottom_get (VALUE self)
 {
        Evas_Object *o;
 static VALUE c_bottom_get (VALUE self)
 {
        Evas_Object *o;
-       void *obj;
 
        GET_OBJ (self, RbEvas, e);
 
        if (!(o = evas_object_bottom_get (e->real)))
                return Qnil;
 
 
        GET_OBJ (self, RbEvas, e);
 
        if (!(o = evas_object_bottom_get (e->real)))
                return Qnil;
 
-       if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
-               rb_raise (rb_eException, "EvasObject Ruby object key missing");
-               return Qnil;
-       }
-
-       return (VALUE) obj;
+       return TO_EVAS_OBJECT (o);
 }
 
 /*
 }
 
 /*
@@ -301,7 +289,6 @@ static VALUE c_bottom_get (VALUE self)
 static VALUE c_find_object (VALUE self, VALUE name)
 {
        Evas_Object *o;
 static VALUE c_find_object (VALUE self, VALUE name)
 {
        Evas_Object *o;
-       void *obj;
 
        GET_OBJ (self, RbEvas, e);
 
 
        GET_OBJ (self, RbEvas, e);
 
@@ -310,12 +297,7 @@ static VALUE c_find_object (VALUE self, VALUE name)
        if (!(o = evas_object_name_find (e->real, StringValuePtr (name))))
                return Qnil;
 
        if (!(o = evas_object_name_find (e->real, StringValuePtr (name))))
                return Qnil;
 
-       if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
-               rb_raise (rb_eException, "EvasObject Ruby object key missing");
-               return Qnil;
-       }
-
-       return (VALUE) obj;
+       return TO_EVAS_OBJECT (o);
 }
 
 void Init_Evas (void)
 }
 
 void Init_Evas (void)
index 6c0a90f99498f4d6ea7f68c908765de73bd7b3bc..f29114fe995fe6e3421ad467cd43bdb083b8935e 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_evas_object.c 64 2004-08-12 19:37:04Z tilman $
+ * $Id: rb_evas_object.c 68 2004-08-16 15:42:19Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 
 VALUE cEvasObject;
 
 
 VALUE cEvasObject;
 
+VALUE TO_EVAS_OBJECT (Evas_Object *o)
+{
+       void *obj;
+
+       if (!o)
+               return Qnil;
+
+       if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
+               rb_raise (rb_eException, "EvasObject Ruby object key missing");
+               return Qnil;
+       }
+
+       return (VALUE) obj;
+}
+
 /* called by the child classes */
 void c_evas_object_mark (RbEvasObject *e)
 {
 /* called by the child classes */
 void c_evas_object_mark (RbEvasObject *e)
 {
@@ -420,19 +435,13 @@ static VALUE c_stack_below (VALUE self, VALUE target)
 static VALUE c_above_get (VALUE self)
 {
        Evas_Object *o;
 static VALUE c_above_get (VALUE self)
 {
        Evas_Object *o;
-       void *obj;
 
        GET_OBJ (self, RbEvasObject, e);
 
        if (!(o = evas_object_above_get (e->real)))
                return Qnil;
 
 
        GET_OBJ (self, RbEvasObject, e);
 
        if (!(o = evas_object_above_get (e->real)))
                return Qnil;
 
-       if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
-               rb_raise (rb_eException, "EvasObject Ruby object key missing");
-               return Qnil;
-       }
-
-       return (VALUE) obj;
+       return TO_EVAS_OBJECT (o);
 }
 
 /*
 }
 
 /*
@@ -445,19 +454,13 @@ static VALUE c_above_get (VALUE self)
 static VALUE c_below_get (VALUE self)
 {
        Evas_Object *o;
 static VALUE c_below_get (VALUE self)
 {
        Evas_Object *o;
-       void *obj;
 
        GET_OBJ (self, RbEvasObject, e);
 
        if (!(o = evas_object_below_get (e->real)))
                return Qnil;
 
 
        GET_OBJ (self, RbEvasObject, e);
 
        if (!(o = evas_object_below_get (e->real)))
                return Qnil;
 
-       if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
-               rb_raise (rb_eException, "EvasObject Ruby object key missing");
-               return Qnil;
-       }
-
-       return (VALUE) obj;
+       return TO_EVAS_OBJECT (o);
 }
 
 void Init_EvasObject (void)
 }
 
 void Init_EvasObject (void)
index 8760498541d094c23c5629583d1c3b779822175a..91a90c5a18052d39b9b8257022d17b68c5ef3640 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_evas_object.h 49 2004-08-01 10:17:39Z tilman $
+ * $Id: rb_evas_object.h 68 2004-08-16 15:42:19Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -35,6 +35,8 @@ void Init_EvasObject (void);
 void c_evas_object_free (RbEvasObject *e, bool free_mem);
 void c_evas_object_mark (RbEvasObject *e);
 
 void c_evas_object_free (RbEvasObject *e, bool free_mem);
 void c_evas_object_mark (RbEvasObject *e);
 
+VALUE TO_EVAS_OBJECT (Evas_Object *o);
+
 #ifndef __RB_EVAS_OBJECT_C
 extern VALUE cEvasObject;
 #endif
 #ifndef __RB_EVAS_OBJECT_C
 extern VALUE cEvasObject;
 #endif
index 366c602f9625e37f83e9533b2b0b1d2768872d1b..b9379e0d90dc95916a736ded4e1b91a1ecd7f97e 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_smart.c 61 2004-08-12 10:04:07Z tilman $
+ * $Id: rb_smart.c 68 2004-08-16 15:42:19Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #define SMART_CB_OBJ(name) \
        static void on_##name (Evas_Object *o, Evas_Object *other) \
        { \
 #define SMART_CB_OBJ(name) \
        static void on_##name (Evas_Object *o, Evas_Object *other) \
        { \
-               void *obj; \
-\
                SMART_CB_BODY (name); \
                SMART_CB_BODY (name); \
-\
-               obj = evas_object_data_get (other, RUBY_EVAS_OBJECT_KEY); \
-               if (!obj) { \
-                       rb_raise (rb_eException, "EvasObject Ruby object key missing"); \
-                       return; \
-               } \
-\
-               rb_funcall (self, id, 1, (VALUE) obj); \
+               rb_funcall (self, id, 1, TO_EVAS_OBJECT (other)); \
        }
 
 #define SMART_CB_COORD(name) \
        }
 
 #define SMART_CB_COORD(name) \