Fixed class instantiation.
[ruby-ecore.git] / src / ecore_x / rb_cursor.c
index 0612666818ced7f212710a0d3cfbdc90f97bb774..f025f6ebd5c2de6e12fab3ce9f4504cb78cfd532 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_cursor.c 109 2004-09-01 20:33:15Z tilman $
+ * $Id: rb_cursor.c 351 2006-02-10 15:25:40Z tilman $
  *
  * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
@@ -38,18 +38,25 @@ static void c_free (RbCursor *c)
        free (c);
 }
 
+static VALUE c_alloc (VALUE klass)
+{
+       RbCursor *cursor = NULL;
+
+       return Data_Make_Struct (klass, RbCursor, NULL, c_free, cursor);
+}
+
 static VALUE c_new_from_shape (VALUE klass, VALUE shape)
 {
        VALUE self;
        RbCursor *cursor = NULL;
 
-       self = Data_Make_Struct (klass, RbCursor, NULL, c_free, cursor);
+       self = rb_class_new_instance (1, &shape, klass);
+
+       Data_Get_Struct (self, RbCursor, cursor);
 
        cursor->real = ecore_x_cursor_shape_get (FIX2INT (shape));
        cursor->need_free = false;
 
-       rb_obj_call_init (self, 0, NULL);
-
        return self;
 }
 
@@ -57,6 +64,7 @@ void Init_Cursor (void)
 {
        cCursor = rb_define_class_under (mX, "Cursor", rb_cObject);
 
+       rb_define_alloc_func (cCursor, c_alloc);
        rb_define_singleton_method (cCursor, "new_from_shape",
                                    c_new_from_shape, 1);