/*
- * $Id: rb_evas.c 283 2005-03-15 17:59:03Z tilman $
+ * $Id: rb_evas.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
rb_gc_mark (e->parent);
}
+static VALUE c_alloc (VALUE klass)
+{
+ RbEvas *evas = NULL;
+
+ return Data_Make_Struct (cEvas, RbEvas, c_mark, free, evas);
+}
+
VALUE TO_EVAS (VALUE parent, Evas *e)
{
VALUE self;
- RbEvas *evas = NULL;
if (NIL_P (parent) || !e)
return Qnil;
- self = Data_Make_Struct (cEvas, RbEvas,
- c_mark, free, evas);
+ self = rb_class_new_instance (0, NULL, cEvas);
+
+ GET_OBJ (self, RbEvas, evas);
+
evas->real = e;
evas->parent = parent;
- rb_obj_call_init (self, 0, NULL);
-
return self;
}
{
cEvas = rb_define_class_under (mEvas, "Evas", rb_cObject);
+ rb_define_alloc_func (cEvas, c_alloc);
+
/* not publically instantiable yet */
rb_define_private_method (rb_singleton_class (cEvas),
"new", NULL, 0);
/*
- * $Id: rb_evas_object.c 350 2006-02-08 21:13:34Z tilman $
+ * $Id: rb_evas_object.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
free (e);
}
+static void c_free (RbEvasObject *e)
+{
+ c_evas_object_free (e, true);
+}
+
+static VALUE c_alloc (VALUE klass)
+{
+ RbEvasObject *e;
+
+ return Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
+ c_free, e);
+}
+
/* :nodoc: */
static VALUE c_init (VALUE self, VALUE parent)
{
cEvasObject = rb_define_class_under (mEvas, "EvasObject",
rb_cObject);
- rb_define_private_method (rb_singleton_class (cEvasObject),
- "new", NULL, 0);
+ rb_define_alloc_func (cEvasObject, c_alloc);
rb_define_method (cEvasObject, "initialize", c_init, 1);
rb_define_method (cEvasObject, "inspect", c_inspect, 0);
rb_define_method (cEvasObject, "type", c_type_get, 0);
/*
- * $Id: rb_evas_object.h 304 2005-03-22 17:51:51Z tilman $
+ * $Id: rb_evas_object.h 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
void Init_EvasObject (void);
-void c_evas_object_free (RbEvasObject *e, bool free_mem);
-void c_evas_object_mark (RbEvasObject *e);
-
VALUE TO_EVAS_OBJECT (Evas_Object *o);
#ifndef __RB_EVAS_OBJECT_C
/*
- * $Id: rb_gradient.c 58 2004-08-10 14:10:02Z tilman $
+ * $Id: rb_gradient.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.h"
-static void c_free (RbEvasObject *e)
-{
- c_evas_object_free (e, true);
-}
-
/*
* call-seq:
* Evas::Gradient.new(evas) => gradient
*
* Creates an Evas::Gradient object.
*/
-static VALUE c_new (VALUE klass, VALUE evas)
+static VALUE c_init (VALUE self, VALUE evas)
{
- VALUE self, argv[1];
- RbEvasObject *rect;
-
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
+ GET_OBJ (self, RbEvasObject, grad);
- self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
- c_free, rect);
- rect->real = evas_object_gradient_add (e->real);
+ grad->real = evas_object_gradient_add (e->real);
- argv[0] = evas;
- rb_obj_call_init (self, 1, argv);
+ rb_call_super (1, &evas);
return self;
}
{
VALUE c = rb_define_class_under (mEvas, "Gradient", cEvasObject);
- rb_define_singleton_method (c, "new", c_new, 1);
+ rb_define_method (c, "initialize", c_init, 1);
rb_define_method (c, "add_color", c_add_color, 5);
rb_define_method (c, "clear_colors", c_clear_colors, 0);
rb_define_method (c, "angle", c_angle_get, 0);
/*
- * $Id: rb_image.c 284 2005-03-15 18:00:33Z tilman $
+ * $Id: rb_image.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.h"
-static void c_free (RbEvasObject *e)
-{
- c_evas_object_free (e, true);
-}
-
/*
* call-seq:
* Evas::Image.new(evas) => img
*
* Creates an Evas::Image object.
*/
-static VALUE c_new (VALUE klass, VALUE evas)
+static VALUE c_init (VALUE self, VALUE evas)
{
- VALUE self, argv[1];
- RbEvasObject *img;
-
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
+ GET_OBJ (self, RbEvasObject, img);
- self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
- c_free, img);
img->real = evas_object_image_add (e->real);
- argv[0] = evas;
- rb_obj_call_init (self, 1, argv);
+ rb_call_super (1, &evas);
return self;
}
{
VALUE c = rb_define_class_under (mEvas, "Image", cEvasObject);
- rb_define_singleton_method (c, "new", c_new, 1);
+ rb_define_method (c, "initialize", c_init, 1);
rb_define_method (c, "get_file", c_get_file, -1);
rb_define_method (c, "set_file", c_set_file, -1);
rb_define_method (c, "has_alpha?", c_has_alpha_get, 0);
/*
- * $Id: rb_line.c 49 2004-08-01 10:17:39Z tilman $
+ * $Id: rb_line.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.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 *line;
-
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
+ GET_OBJ (self, RbEvasObject, line);
- self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
- c_free, line);
line->real = evas_object_line_add (e->real);
- argv[0] = evas;
- rb_obj_call_init (self, 1, argv);
+ rb_call_super (1, &evas);
return self;
}
{
VALUE c = rb_define_class_under (mEvas, "Line", cEvasObject);
- rb_define_singleton_method (c, "new", c_new, 1);
+ rb_define_method (c, "initialize", c_init, 1);
rb_define_method (c, "get_xy", c_get_xy, 0);
rb_define_method (c, "set_xy", c_set_xy, 4);
}
/*
- * $Id: rb_polygon.c 58 2004-08-10 14:10:02Z tilman $
+ * $Id: rb_polygon.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.h"
-static void c_free (RbEvasObject *e)
-{
- c_evas_object_free (e, true);
-}
-
/*
* call-seq:
* Evas::Polygon.new(evas) => polygon
*
* Creates an new Evas::Polygon object.
*/
-static VALUE c_new (VALUE klass, VALUE evas)
+static VALUE c_init (VALUE self, VALUE evas)
{
- VALUE self, argv[1];
- RbEvasObject *poly;
-
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
+ GET_OBJ (self, RbEvasObject, poly);
- self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
- c_free, poly);
poly->real = evas_object_polygon_add (e->real);
- argv[0] = evas;
- rb_obj_call_init (self, 1, argv);
+ rb_call_super (1, &evas);
return self;
}
{
VALUE c = rb_define_class_under (mEvas, "Polygon", cEvasObject);
- rb_define_singleton_method (c, "new", c_new, 1);
+ rb_define_method (c, "initialize", c_init, 1);
rb_define_method (c, "add_point", c_add_point, 2);
rb_define_method (c, "clear_points", c_clear_points, 0);
}
/*
- * $Id: rb_rectangle.c 58 2004-08-10 14:10:02Z tilman $
+ * $Id: rb_rectangle.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.h"
-static void c_free (RbEvasObject *e)
-{
- c_evas_object_free (e, true);
-}
-
/*
* call-seq:
* Evas::Rectangle.new(evas) => rect
*
* Creates an Evas::Rectangle object.
*/
-static VALUE c_new (VALUE klass, VALUE evas)
+static VALUE c_init (VALUE self, VALUE evas)
{
- VALUE self, argv[1];
- RbEvasObject *rect;
-
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
+ GET_OBJ (self, RbEvasObject, rect);
- self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
- c_free, rect);
rect->real = evas_object_rectangle_add (e->real);
- argv[0] = evas;
- rb_obj_call_init (self, 1, argv);
+ rb_call_super (1, &evas);
return self;
}
{
VALUE c = rb_define_class_under (mEvas, "Rectangle", cEvasObject);
- rb_define_singleton_method (c, "new", c_new, 1);
+ rb_define_method (c, "initialize", c_init, 1);
}
/*
- * $Id: rb_smart.c 68 2004-08-16 15:42:19Z tilman $
+ * $Id: rb_smart.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.h"
-#define RUBY_EVAS_SMART_OBJECT_KEY "__RB_EVAS_OBJECT_SMART_OBJECT"
-
-#define GET_EVAS_OBJECT(obj, o) \
- VALUE (obj); \
-\
- obj = (VALUE) evas_object_data_get (o, \
- RUBY_EVAS_SMART_OBJECT_KEY); \
- if (!obj) { \
- rb_raise (rb_eException, \
- "EvasObject Ruby object key missing"); \
- return; \
- }
-
#define SMART_CB_BODY(name) \
+ VALUE self = TO_EVAS_OBJECT (o); \
static ID id; \
-\
- GET_EVAS_OBJECT (self, o); \
\
if (!id) \
id = rb_intern ("on_"#name); \
INT2FIX (a));
}
+static VALUE c_alloc (VALUE klass)
+{
+ Evas_Smart **smart = NULL;
+
+ return Data_Make_Struct (klass, Evas_Smart *, NULL, free, smart);
+}
+
/*
* call-seq:
* Evas::Smart.new(name) => smart
*
* Creates a Evas::Smart object with the given name.
*/
-static VALUE c_new (VALUE klass, VALUE name)
+static VALUE c_init (VALUE self, VALUE name)
{
- VALUE self;
- Evas_Smart **smart;
+ GET_OBJ (self, Evas_Smart *, smart);
Check_Type (name, T_STRING);
- self = Data_Make_Struct (klass, Evas_Smart *, NULL, free, smart);
*smart = evas_smart_new (StringValuePtr (name),
NULL, on_delete, on_layer_set,
on_raise, on_lower, on_stack_above,
on_show, on_hide, on_color_set,
on_clip_set, on_clip_unset, NULL);
- rb_obj_call_init (self, 0, NULL);
-
return self;
}
-static void c_object_free (RbEvasObject *e)
-{
- c_evas_object_free (e, true);
-}
-
/*
* call-seq:
* smart.new_object(class, evas) => smart_obj
*/
static VALUE c_new_object (VALUE self, VALUE klass, VALUE evas)
{
- VALUE obj, argv[1];
- RbEvasObject *smart;
+ VALUE obj;
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
GET_OBJ (self, Evas_Smart *, s);
- obj = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
- c_object_free, smart);
- smart->real = evas_object_smart_add (e->real, *s);
+ obj = rb_obj_alloc (klass);
- evas_object_data_set (smart->real, RUBY_EVAS_SMART_OBJECT_KEY,
- (void *) obj);
+ GET_OBJ (obj, RbEvasObject, smart);
+
+ smart->real = evas_object_smart_add (e->real, *s);
- argv[0] = evas;
- rb_obj_call_init (obj, 1, argv);
+ rb_obj_call_init (obj, 1, &evas);
return obj;
}
{
VALUE c = rb_define_class_under (mEvas, "Smart", 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, 1);
rb_define_method (c, "new_object", c_new_object, 2);
}
/*
- * $Id: rb_text.c 143 2004-11-26 21:39:08Z tilman $
+ * $Id: rb_text.c 354 2006-02-10 18:14:08Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.h"
-static void c_free (RbEvasObject *e)
-{
- c_evas_object_free (e, true);
-}
-
/*
* call-seq:
* Evas::Text.new(evas) => text
*
* Creates an Evas::Text object.
*/
-static VALUE c_new (VALUE klass, VALUE evas)
+static VALUE c_init (VALUE self, VALUE evas)
{
- VALUE self, argv[1];
- RbEvasObject *text;
-
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
+ GET_OBJ (self, RbEvasObject, text);
- self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
- c_free, text);
text->real = evas_object_text_add (e->real);
- argv[0] = evas;
- rb_obj_call_init (self, 1, argv);
+ rb_call_super (1, &evas);
return self;
}
{
VALUE c = rb_define_class_under (mEvas, "Text", cEvasObject);
- rb_define_singleton_method (c, "new", c_new, 1);
+ rb_define_method (c, "initialize", c_init, 1);
rb_define_method (c, "font_source", c_font_source_get, 0);
rb_define_method (c, "font_source=", c_font_source_set, 1);
rb_define_method (c, "get_font", c_get_font, 0);