X-Git-Url: http://git.code-monkey.de/?p=ruby-ecore.git;a=blobdiff_plain;f=src%2Fecore%2Frb_idler.c;h=41f1cb30711f46892a2fb70a054f0bbd3cd57e70;hp=05550fd6f9786584271e6be0babbb2edc1392f29;hb=0f8d24c745efc1057f8d25ada1375c88a1ab2ed7;hpb=041804188a058aa7bbc76c81e4a816255a635f00 diff --git a/src/ecore/rb_idler.c b/src/ecore/rb_idler.c index 05550fd..41f1cb3 100644 --- a/src/ecore/rb_idler.c +++ b/src/ecore/rb_idler.c @@ -1,7 +1,5 @@ /* - * $Id: rb_idler.c 60 2004-08-10 14:12:36Z 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 @@ -62,6 +60,15 @@ static void c_free (RbIdler *idler) free (idler); } +static VALUE c_alloc (VALUE klass) +{ + RbIdler *idler; + + ecore_init (); + + return Data_Make_Struct (klass, RbIdler, c_mark, c_free, idler); +} + /* * call-seq: * Ecore::Idler.new { block } => idler @@ -70,23 +77,17 @@ static void c_free (RbIdler *idler) * When Ecore is idle, the specified block will be called. * If the block returns false, the idler is deleted. */ -static VALUE c_new (VALUE klass) +static VALUE c_init (VALUE self) { - VALUE self; - RbIdler *idler; + GET_OBJ (self, RbIdler, idler); if (!rb_block_given_p ()) - return Qnil; - - self = Data_Make_Struct (klass, RbIdler, c_mark, c_free, idler); - - ecore_init (); + rb_raise (rb_eStandardError, "block missing"); idler->callback = rb_block_proc (); + idler->deleted = false; idler->real = ecore_idler_add (on_idler, idler); - rb_obj_call_init (self, 0, NULL); - return self; } @@ -114,6 +115,7 @@ void Init_Idler (void) { VALUE c = rb_define_class_under (mEcore, "Idler", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 1); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 0); rb_define_method (c, "delete", c_delete, 0); }