/*
- * $Id: rb_idler.c 77 2004-08-19 17:39:29Z tilman $
- *
* Copyright (C) 2004 ruby-ecore team (see AUTHORS)
*
* This library is free software; you can redistribute it and/or
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
* 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;
}
{
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);
}