X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fecore_evas%2Frb_ecore_evas.c;h=3ded59d92230d678f149cb601179cbf53755c00b;hb=04602ae0d3b6898a47caf7f46600a6058b697a81;hp=557ca04b9ff4ed3b05bcf8f758f1fe6ec9b5290d;hpb=041804188a058aa7bbc76c81e4a816255a635f00;p=ruby-ecore.git diff --git a/src/ecore_evas/rb_ecore_evas.c b/src/ecore_evas/rb_ecore_evas.c index 557ca04..3ded59d 100644 --- a/src/ecore_evas/rb_ecore_evas.c +++ b/src/ecore_evas/rb_ecore_evas.c @@ -1,7 +1,7 @@ /* - * $Id: rb_ecore_evas.c 60 2004-08-10 14:12:36Z tilman $ + * $Id: rb_ecore_evas.c 303 2005-03-22 17:42:04Z tilman $ * - * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) + * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,12 +30,16 @@ #include "rb_ecore_evas_main.h" #include "rb_ecore_evas.h" +#define RUBY_ECORE_EVAS_KEY "__RB_ECORE_EVAS_KEY" + #define CALLBACK_DEFINE_HANDLER(name) \ static void on_##name (Ecore_Evas *real) \ { \ - VALUE self = rb_hash_aref (objects, INT2NUM ((long) real)); \ + VALUE self; \ VALUE cb; \ \ + self = (VALUE) ecore_evas_data_get (real, \ + RUBY_ECORE_EVAS_KEY); \ GET_OBJ (self, RbEcoreEvas, ee); \ \ cb = rb_hash_aref (ee->callbacks, rb_str_new2 (#name)); \ @@ -47,6 +51,9 @@ \ if (!rb_block_given_p ()) \ return Qnil; \ +\ + if (NIL_P (ee->callbacks)) \ + ee->callbacks = rb_hash_new (); \ \ rb_hash_aset (ee->callbacks, rb_str_new2 (#name), \ rb_block_proc ()); \ @@ -56,7 +63,6 @@ return Qnil; VALUE cEcoreEvas; -static VALUE objects; /* called by the child classes */ void c_ecore_evas_mark (RbEcoreEvas *ee) @@ -64,7 +70,8 @@ void c_ecore_evas_mark (RbEcoreEvas *ee) if (!NIL_P (ee->evas)) rb_gc_mark (ee->evas); - rb_gc_mark (ee->callbacks); + if (!NIL_P (ee->callbacks)) + rb_gc_mark (ee->callbacks); } void c_ecore_evas_free (RbEcoreEvas *ee, bool free_mem) @@ -85,9 +92,9 @@ static VALUE c_init (int argc, VALUE *argv, VALUE self) GET_OBJ (self, RbEcoreEvas, ee); ee->evas = Qnil; - ee->callbacks = rb_hash_new (); + ee->callbacks = Qnil; - rb_hash_aset (objects, INT2NUM ((long) ee->real), self); + ecore_evas_data_set (ee->real, RUBY_ECORE_EVAS_KEY, (void *) self); return Qnil; } @@ -132,7 +139,7 @@ static VALUE c_hide (VALUE self) * call-seq: * ee.visible? => true or false * - * Returns true if ee is visible, else false. + * Returns true if ee is visible, else returns false. */ static VALUE c_visible_get (VALUE self) { @@ -399,7 +406,7 @@ static VALUE c_title_set (VALUE self, VALUE val) * call-seq: * ee.borderless? => true or false * - * Returns true if ee is borderless, else false. + * Returns true if ee is borderless, else returns false. */ static VALUE c_borderless_get (VALUE self) { @@ -429,7 +436,7 @@ static VALUE c_borderless_set (VALUE self, VALUE val) * call-seq: * ee.shaped? => true or false * - * Returns true if ee is shaped, else false. + * Returns true if ee is shaped, else returns false. */ static VALUE c_shaped_get (VALUE self) { @@ -459,7 +466,7 @@ static VALUE c_shaped_set (VALUE self, VALUE val) * call-seq: * ee.sticky? => true or false * - * Returns true if ee is sticky, else false. + * Returns true if ee is sticky, else returns false. */ static VALUE c_sticky_get (VALUE self) { @@ -526,7 +533,6 @@ static VALUE c_delete (VALUE self) rb_gc_start (); ecore_evas_free (ee->real); - rb_hash_aset (objects, INT2NUM ((long) ee->real), Qnil); ee->real = NULL; return Qnil; @@ -724,7 +730,4 @@ void Init_EcoreEvas (void) rb_define_method (cEcoreEvas, "on_mouse_out", c_on_mouse_out, 0); rb_define_method (cEcoreEvas, "on_pre_render", c_on_pre_render, 0); rb_define_method (cEcoreEvas, "on_post_render", c_on_post_render, 0); - - objects = rb_hash_new (); - rb_global_variable (&objects); }