/*
- * $Id: rb_edje.c 28 2004-07-08 18:35:51Z tilman $
+ * $Id: rb_edje.c 31 2004-07-10 14:06:07Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_edje_main.h"
-#define GET_OBJ(obj, type, o, desc) \
+#define GET_OBJ(obj, type, o) \
type **(o) = NULL; \
\
Data_Get_Struct ((obj), type *, (o)); \
\
if (!*(o)) { \
- rb_raise (rb_eException, desc " destroyed already"); \
+ rb_raise (rb_eException, \
+ "%s destroyed already", \
+ rb_obj_classname ((obj))); \
return Qnil; \
}
return Qnil; \
}
+#define CHECK_CLASS(val, klass) \
+ if (!rb_obj_is_kind_of ((val), (klass))) { \
+ rb_raise (rb_eTypeError, \
+ "wrong argument type %s (expected %s)", \
+ rb_obj_classname ((val)), \
+ rb_obj_classname ((klass))); \
+ return Qnil; \
+ }
+
static void c_free (Evas_Object **e)
{
c_evas_object_free (e);
VALUE self, argv[1];
Evas_Object **edje;
- if (!rb_obj_is_kind_of (evas, cEvas)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected Evas)",
- rb_obj_classname (evas));
- return Qnil;
- }
-
- GET_OBJ (evas, Evas, e, "Evas");
+ CHECK_CLASS (evas, cEvas);
+ GET_OBJ (evas, Evas, e);
edje_init ();
static VALUE c_load (VALUE self, VALUE eet, VALUE group)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (eet, T_STRING);
Check_Type (group, T_STRING);
{
int w = 0, h = 0;
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
edje_object_size_min_get (*e, &w, &h);
{
int w = 0, h = 0;
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
edje_object_size_max_get (*e, &w, &h);
{
int r;
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (part, T_STRING);
static VALUE c_part_swallow (VALUE self, VALUE part, VALUE target)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (part, T_STRING);
- if (!rb_obj_is_kind_of (target, cEvasObject)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected EvasObject)",
- rb_obj_classname (target));
- return Qnil;
- }
-
- GET_OBJ (target, Evas_Object, target2, "EvasObject");
+ CHECK_CLASS (target, cEvasObject);
+ GET_OBJ (target, Evas_Object, target2);
edje_object_part_swallow (*e, StringValuePtr (part), *target2);
static VALUE c_part_unswallow (VALUE self, VALUE target)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
-
- if (!rb_obj_is_kind_of (target, cEvasObject)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected EvasObject)",
- rb_obj_classname (target));
- return Qnil;
- }
+ GET_OBJ (self, Evas_Object, e);
- GET_OBJ (target, Evas_Object, target2, "EvasObject");
+ CHECK_CLASS (target, cEvasObject);
+ GET_OBJ (target, Evas_Object, target2);
edje_object_part_unswallow (*e, *target2);
Evas_Object *o;
void *obj;
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (part, T_STRING);
{
const char *s;
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (part, T_STRING);
static VALUE c_set_part_text (VALUE self, VALUE part, VALUE text)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (part, T_STRING);
Check_Type (text, T_STRING);
static VALUE c_on_text_changed (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
if (!rb_block_given_p ())
return Qnil;
static VALUE c_signal_emit (VALUE self, VALUE emission, VALUE source)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (emission, T_STRING);
Check_Type (source, T_STRING);
static VALUE c_on_signal (VALUE self, VALUE signal, VALUE src)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (signal, T_STRING);
Check_Type (src, T_STRING);
static VALUE c_play_get (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
return edje_object_play_get (*e) ? Qtrue : Qfalse;
}
static VALUE c_play_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
CHECK_BOOL(val);
static VALUE c_animation_get (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
return edje_object_animation_get (*e) ? Qtrue : Qfalse;
}
static VALUE c_animation_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object, e, "Edje");
+ GET_OBJ (self, Evas_Object, e);
CHECK_BOOL(val);