Fixed class instantiation.
[ruby-ecore.git] / src / ecore / rb_animator.c
index 41837ded1c0d5832864e647f2a7f1c06817e09ce..9a3ce2778bb7a5fd2d6718448616c11c37633aa1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_animator.c 150 2004-12-03 13:45:00Z tilman $
+ * $Id: rb_animator.c 351 2006-02-10 15:25:40Z tilman $
  *
  * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
@@ -73,24 +73,26 @@ static void c_free (RbAnimator *animator)
        free (animator);
 }
 
-static VALUE c_new (VALUE klass)
+static VALUE c_alloc (VALUE klass)
 {
-       VALUE self;
        RbAnimator *animator = NULL;
 
-       if (!rb_block_given_p ())
-               return Qnil;
+       ecore_init ();
 
-       self = Data_Make_Struct (klass, RbAnimator, c_mark, c_free, animator);
+       return Data_Make_Struct (klass, RbAnimator, c_mark, c_free, animator);
+}
 
-       ecore_init ();
+static VALUE c_init (VALUE self)
+{
+       GET_OBJ (self, RbAnimator, animator);
+
+       if (!rb_block_given_p ())
+               rb_raise (rb_eStandardError, "block missing");
 
        animator->callback = rb_block_proc ();
        animator->deleted = false;
        animator->real = ecore_animator_add (on_animator, animator);
 
-       rb_obj_call_init (self, 0, NULL);
-
        return self;
 }
 
@@ -112,6 +114,7 @@ void Init_Animator (void)
 {
        VALUE c = rb_define_class_under (mEcore, "Animator", 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);
 }