From: Tilman Sauerbeck Date: Tue, 22 Mar 2005 17:51:51 +0000 (+0000) Subject: Added EvasObject#userdata. X-Git-Url: http://git.code-monkey.de/?p=ruby-evas.git;a=commitdiff_plain;h=e012a51b703ddd23c407d308602246d07ff73d2e Added EvasObject#userdata. --- diff --git a/src/rb_evas_object.c b/src/rb_evas_object.c index c2d39af..6e93a8f 100644 --- a/src/rb_evas_object.c +++ b/src/rb_evas_object.c @@ -1,5 +1,5 @@ /* - * $Id: rb_evas_object.c 302 2005-03-22 17:41:35Z tilman $ + * $Id: rb_evas_object.c 304 2005-03-22 17:51:51Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -52,6 +52,9 @@ void c_evas_object_mark (RbEvasObject *e) if (!NIL_P (e->callbacks)) rb_gc_mark (e->callbacks); + + if (!NIL_P (e->userdata)) + rb_gc_mark (e->userdata); } void c_evas_object_free (RbEvasObject *e, bool free_mem) @@ -489,6 +492,16 @@ static VALUE c_below_get (VALUE self) return TO_EVAS_OBJECT (evas_object_below_get (e->real)); } +static VALUE c_userdata_get (VALUE self) +{ + GET_OBJ (self, RbEvasObject, e); + + if (NIL_P (e->userdata)) + e->userdata = rb_hash_new (); + + return e->userdata; +} + void Init_EvasObject (void) { cEvasObject = rb_define_class_under (mEvas, "EvasObject", @@ -526,4 +539,5 @@ void Init_EvasObject (void) rb_define_method (cEvasObject, "stack_below", c_stack_below, 1); rb_define_method (cEvasObject, "above", c_above_get, 0); rb_define_method (cEvasObject, "below", c_below_get, 0); + rb_define_method (cEvasObject, "userdata", c_userdata_get, 0); } diff --git a/src/rb_evas_object.h b/src/rb_evas_object.h index ae60574..99e0743 100644 --- a/src/rb_evas_object.h +++ b/src/rb_evas_object.h @@ -1,5 +1,5 @@ /* - * $Id: rb_evas_object.h 281 2005-03-14 20:51:40Z tilman $ + * $Id: rb_evas_object.h 304 2005-03-22 17:51:51Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -29,6 +29,7 @@ typedef struct { Evas_Object *real; VALUE parent; VALUE callbacks; + VALUE userdata; } RbEvasObject; void Init_EvasObject (void);