Class instantiation fixes.
authorTilman Sauerbeck <tilman@code-monkey.de>
Fri, 10 Feb 2006 18:27:31 +0000 (18:27 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Fri, 10 Feb 2006 18:27:31 +0000 (18:27 +0000)
src/esmart_container/rb_esmart_container.c
src/esmart_draggies/rb_esmart_draggies.c
src/esmart_file_dialog/rb_esmart_file_dialog.c
src/esmart_trans_x11/rb_esmart_trans_x11.c

index 45e13f8958173a7ba5a93518cef1dedb8e7b936f..85b9fdc79f35d5d44a9803104edf1ebd24165212 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_esmart_container.c 317 2005-04-25 21:48:10Z tilman $
+ * $Id: rb_esmart_container.c 356 2006-02-10 18:27:31Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -45,20 +45,23 @@ static void c_free (RbContainer *e)
        free (e);
 }
 
        free (e);
 }
 
-static VALUE c_new (VALUE klass, VALUE evas)
+static VALUE c_alloc (VALUE klass)
 {
 {
-       VALUE self, argv[1];
-       RbContainer *cont;
+       RbContainer *cont = NULL;
 
 
+       return Data_Make_Struct (klass, RbContainer, c_mark,
+                                c_free, cont);
+}
+
+static VALUE c_init (VALUE self, VALUE evas)
+{
        CHECK_CLASS (evas, cEvas);
        GET_OBJ (evas, RbEvas, e);
        CHECK_CLASS (evas, cEvas);
        GET_OBJ (evas, RbEvas, e);
+       GET_OBJ (self, RbContainer, cont);
 
 
-       self = Data_Make_Struct (klass, RbContainer, c_mark,
-                                c_free, cont);
        cont->real.real = esmart_container_new (e->real);
 
        cont->real.real = esmart_container_new (e->real);
 
-       argv[0] = evas;
-       rb_obj_call_init (self, 1, argv);
+       rb_call_super (1, &evas);
 
        cont->elements = rb_ary_new ();
 
 
        cont->elements = rb_ary_new ();
 
@@ -280,7 +283,8 @@ void Init_esmart_container (void)
 
        c = rb_define_class_under (mEsmart, "Container", cEvasObject);
 
 
        c = rb_define_class_under (mEsmart, "Container", cEvasObject);
 
-       rb_define_singleton_method (c, "new", c_new, 1);
+       rb_define_alloc_func (c, c_alloc);
+       rb_define_method (c, "initialize", c_init, 1);
        rb_define_method (c, "direction", c_direction_get, 0);
        rb_define_method (c, "direction=", c_direction_set, 1);
        rb_define_method (c, "spacing", c_spacing_get, 0);
        rb_define_method (c, "direction", c_direction_get, 0);
        rb_define_method (c, "direction=", c_direction_set, 1);
        rb_define_method (c, "spacing", c_spacing_get, 0);
index c422af512e30ad2d7d97afcbc11d90cab75660c2..e9eac004163b20124a61db79f36f73cc4548ca7b 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_esmart_draggies.c 316 2005-04-24 20:07:36Z tilman $
+ * $Id: rb_esmart_draggies.c 356 2006-02-10 18:27:31Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -32,29 +32,22 @@ static void on_mouse_up (void *data, Evas *e, Evas_Object *o, void *ev)
        ecore_evas_raise (data);
 }
 
        ecore_evas_raise (data);
 }
 
-static void c_free (RbEvasObject *e)
+static VALUE c_init (VALUE self, VALUE ecore_evas)
 {
 {
-       c_evas_object_free (e, true);
-}
-
-static VALUE c_new (VALUE klass, VALUE ecore_evas)
-{
-       VALUE self, argv[1];
        static ID evas;
        static ID evas;
-       RbEvasObject *draggies;
+       VALUE tmp;
 
        CHECK_CLASS (ecore_evas, cEcoreEvas);
        GET_OBJ (ecore_evas, RbEcoreEvas, ee);
 
        CHECK_CLASS (ecore_evas, cEcoreEvas);
        GET_OBJ (ecore_evas, RbEcoreEvas, ee);
+       GET_OBJ (self, RbEvasObject, draggies);
 
 
-       self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
-                                c_free, draggies);
        draggies->real = esmart_draggies_new (ee->real);
 
        if (!evas)
                evas = rb_intern ("evas");
 
        draggies->real = esmart_draggies_new (ee->real);
 
        if (!evas)
                evas = rb_intern ("evas");
 
-       argv[0] = rb_funcall (ecore_evas, evas, 0);
-       rb_obj_call_init (self, 1, argv);
+       tmp = rb_funcall (ecore_evas, evas, 0);
+       rb_call_super (1, &tmp);
 
        esmart_draggies_event_callback_add (draggies->real,
                                            EVAS_CALLBACK_MOUSE_UP,
 
        esmart_draggies_event_callback_add (draggies->real,
                                            EVAS_CALLBACK_MOUSE_UP,
@@ -83,6 +76,6 @@ void Init_esmart_draggies (void)
 
        c = rb_define_class_under (mEsmart, "Draggies", cEvasObject);
 
 
        c = rb_define_class_under (mEsmart, "Draggies", cEvasObject);
 
-       rb_define_singleton_method (c, "new", c_new, 1);
+       rb_define_method (c, "initialize", c_init, 1);
        rb_define_method (c, "button=", c_button_set, 1);
 }
        rb_define_method (c, "button=", c_button_set, 1);
 }
index a45d3a49e245cb87e1b3bc280aa8f5b650aa51be..4c60feccdbf2b1d1e4cf6bfd5f7ca0bbf66ab390 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_esmart_file_dialog.c 337 2005-05-02 17:48:20Z tilman $
+ * $Id: rb_esmart_file_dialog.c 356 2006-02-10 18:27:31Z tilman $
  *
  * Copyright (C) 2005 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2005 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -52,11 +52,15 @@ static void c_free (RbFileDialog *e)
        free (e);
 }
 
        free (e);
 }
 
-static VALUE c_new (VALUE klass, VALUE evas, VALUE edj)
+static VALUE c_alloc (VALUE klass)
 {
 {
-       VALUE self, argv[1];
        RbFileDialog *fd = NULL;
 
        RbFileDialog *fd = NULL;
 
+       return Data_Make_Struct (klass, RbFileDialog, c_mark, c_free, fd);
+}
+
+static VALUE c_init (VALUE self, VALUE evas, VALUE edj)
+{
        if (!rb_block_given_p ()) {
                rb_raise (rb_eStandardError, "no block given");
                return Qnil;
        if (!rb_block_given_p ()) {
                rb_raise (rb_eStandardError, "no block given");
                return Qnil;
@@ -65,16 +69,15 @@ static VALUE c_new (VALUE klass, VALUE evas, VALUE edj)
        CHECK_CLASS (evas, cEvas);
        StringValue (edj);
        GET_OBJ (evas, RbEvas, e);
        CHECK_CLASS (evas, cEvas);
        StringValue (edj);
        GET_OBJ (evas, RbEvas, e);
+       GET_OBJ (self, RbFileDialog, fd);
 
 
-       self = Data_Make_Struct (klass, RbFileDialog, c_mark, c_free, fd);
        fd->real.real = esmart_file_dialog_new (e->real,
                                                StringValuePtr (edj));
 
        if (!fd->real.real)
                rb_raise (rb_eStandardError, "failed");
 
        fd->real.real = esmart_file_dialog_new (e->real,
                                                StringValuePtr (edj));
 
        if (!fd->real.real)
                rb_raise (rb_eStandardError, "failed");
 
-       argv[0] = evas;
-       rb_obj_call_init (self, 1, argv);
+       rb_call_super (1, &evas);
 
        fd->callback = rb_block_proc ();
        fd->edje = Qnil;
 
        fd->callback = rb_block_proc ();
        fd->edje = Qnil;
@@ -179,7 +182,8 @@ void Init_esmart_file_dialog (void)
 
        c = rb_define_class_under (mEsmart, "FileDialog", cEvasObject);
 
 
        c = rb_define_class_under (mEsmart, "FileDialog", cEvasObject);
 
-       rb_define_singleton_method (c, "new", c_new, 2);
+       rb_define_alloc_func (c, c_alloc);
+       rb_define_method (c, "initialize", c_init, 2);
        rb_define_method (c, "edje", c_edje_get, 0);
        rb_define_method (c, "selections", c_selections_get, 0);
        rb_define_method (c, "current_directory", c_current_directory_get, 0);
        rb_define_method (c, "edje", c_edje_get, 0);
        rb_define_method (c, "selections", c_selections_get, 0);
        rb_define_method (c, "current_directory", c_current_directory_get, 0);
index 4671d62dabde06d4fc2762467438559eb013c67a..a06f168b4d7e66b4e6260effc5e7375327b50439 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_esmart_trans_x11.c 52 2004-08-01 10:19:14Z tilman $
+ * $Id: rb_esmart_trans_x11.c 356 2006-02-10 18:27:31Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 
 #include "../rb_esmart.h"
 
 
 #include "../rb_esmart.h"
 
-static void c_free (RbEvasObject *e)
+static VALUE c_init (VALUE self, VALUE evas)
 {
 {
-       c_evas_object_free (e, true);
-}
-
-static VALUE c_new (VALUE klass, VALUE evas)
-{
-       VALUE self, argv[1];
-       RbEvasObject *trans;
-
        CHECK_CLASS (evas, cEvas);
        GET_OBJ (evas, RbEvas, e);
        CHECK_CLASS (evas, cEvas);
        GET_OBJ (evas, RbEvas, e);
+       GET_OBJ (self, RbEvasObject, trans);
 
 
-       self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
-                                c_free, trans);
        trans->real = esmart_trans_x11_new (e->real);
 
        trans->real = esmart_trans_x11_new (e->real);
 
-       argv[0] = evas;
-       rb_obj_call_init (self, 1, argv);
+       rb_call_super (1, &evas);
 
        return self;
 }
 
        return self;
 }
@@ -104,7 +94,7 @@ void Init_esmart_trans_x11 (void)
 
        c = rb_define_class_under (mEsmart, "TransX11", cEvasObject);
 
 
        c = rb_define_class_under (mEsmart, "TransX11", cEvasObject);
 
-       rb_define_singleton_method (c, "new", c_new, 1);
+       rb_define_method (c, "initialize", c_init, 1);
        rb_define_method (c, "type", c_type_get, 0);
        rb_define_method (c, "type=", c_type_set, 1);
        rb_define_method (c, "window=", c_window_set, 1);
        rb_define_method (c, "type", c_type_get, 0);
        rb_define_method (c, "type=", c_type_set, 1);
        rb_define_method (c, "window=", c_window_set, 1);