From 7389b77f481a867dd769c5ee08eb75329184ae04 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Mon, 16 Aug 2004 15:42:19 +0000 Subject: [PATCH] Introduced TO_EVAS_OBJECT. --- src/rb_evas.c | 26 ++++---------------------- src/rb_evas_object.c | 33 ++++++++++++++++++--------------- src/rb_evas_object.h | 4 +++- src/rb_smart.c | 13 ++----------- 4 files changed, 27 insertions(+), 49 deletions(-) diff --git a/src/rb_evas.c b/src/rb_evas.c index 3e333a5..c581e4f 100644 --- a/src/rb_evas.c +++ b/src/rb_evas.c @@ -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) * @@ -253,19 +253,13 @@ static VALUE c_image_cache_flush (VALUE self) 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; - 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; - void *obj; 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; - void *obj; 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 (!(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) diff --git a/src/rb_evas_object.c b/src/rb_evas_object.c index 6c0a90f..f29114f 100644 --- a/src/rb_evas_object.c +++ b/src/rb_evas_object.c @@ -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) * @@ -30,6 +30,21 @@ 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) { @@ -420,19 +435,13 @@ static VALUE c_stack_below (VALUE self, VALUE target) 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; - 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; - void *obj; 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) diff --git a/src/rb_evas_object.h b/src/rb_evas_object.h index 8760498..91a90c5 100644 --- a/src/rb_evas_object.h +++ b/src/rb_evas_object.h @@ -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) * @@ -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); +VALUE TO_EVAS_OBJECT (Evas_Object *o); + #ifndef __RB_EVAS_OBJECT_C extern VALUE cEvasObject; #endif diff --git a/src/rb_smart.c b/src/rb_smart.c index 366c602..b9379e0 100644 --- a/src/rb_smart.c +++ b/src/rb_smart.c @@ -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) * @@ -60,17 +60,8 @@ #define SMART_CB_OBJ(name) \ static void on_##name (Evas_Object *o, Evas_Object *other) \ { \ - void *obj; \ -\ 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) \ -- 2.30.2