From: Tilman Sauerbeck Date: Sat, 26 Jun 2004 22:59:56 +0000 (+0000) Subject: No need to use a global variable for the Ruby class. X-Git-Url: http://git.code-monkey.de/?p=ruby-edje.git;a=commitdiff_plain;h=2a5cc4f76a87c455279019fbe55b96826ba4fd1f No need to use a global variable for the Ruby class. --- diff --git a/src/rb_edje.c b/src/rb_edje.c index 6e32bf6..483067c 100644 --- a/src/rb_edje.c +++ b/src/rb_edje.c @@ -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) * @@ -44,13 +44,18 @@ 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); } -