No need to use a global variable for the Ruby class.
authorTilman Sauerbeck <tilman@code-monkey.de>
Sat, 26 Jun 2004 22:59:56 +0000 (22:59 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Sat, 26 Jun 2004 22:59:56 +0000 (22:59 +0000)
src/rb_edje.c

index 6e32bf669572afdf3dd88296b58709f2b509fe1e..483067c7c76142ddc7e75d4f614a8a9fa2742b83 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_edje.c 21 2004-06-25 17:41:17Z tilman $
+ * $Id: rb_edje.c 24 2004-06-26 22:59:56Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
                return Qnil; \
        }
 
-VALUE cEdje;
-
 static VALUE c_new (VALUE klass, VALUE evas)
 {
        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");
 
        self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
@@ -291,7 +296,7 @@ static VALUE c_animation_set (VALUE self, VALUE val)
 
 void Init_Edje (void)
 {
-       cEdje = rb_define_class_under (mEdje, "Edje", cEvasObject);
+       VALUE cEdje = rb_define_class_under (mEdje, "Edje", cEvasObject);
 
        rb_define_singleton_method (cEdje, "new", c_new, 1);
        rb_define_method (cEdje, "load", c_load, 2);
@@ -311,4 +316,3 @@ void Init_Edje (void)
        rb_define_method (cEdje, "animation?", c_animation_get, 0);
        rb_define_method (cEdje, "animation=", c_animation_set, 1);
 }
-