X-Git-Url: http://git.code-monkey.de/?p=ruby-ecore.git;a=blobdiff_plain;f=src%2Fecore%2Frb_idler.c;fp=src%2Fecore%2Frb_idler.c;h=746229050c055168531666b11b332d76a42507a0;hp=d03a5ba8f0abe34c7c65e0cd039f3b1f5315d6ca;hb=fa957a85d2bac8f3ec0845737540254f25d6685c;hpb=abb800d76a0c982e0038289d4df96e357f791005 diff --git a/src/ecore/rb_idler.c b/src/ecore/rb_idler.c index d03a5ba..7462290 100644 --- a/src/ecore/rb_idler.c +++ b/src/ecore/rb_idler.c @@ -1,5 +1,5 @@ /* - * $Id: rb_idler.c 154 2004-12-09 18:49:18Z tilman $ + * $Id: rb_idler.c 351 2006-02-10 15:25:40Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -62,6 +62,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,24 +79,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; } @@ -115,6 +117,7 @@ void Init_Idler (void) { VALUE c = rb_define_class_under (mEcore, "Idler", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 0); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 0); rb_define_method (c, "delete", c_delete, 0); }