Don't use global variables for the Ruby classes.
[ruby-ecore.git] / src / ecore_evas / rb_fb.c
1 /*
2  * $Id: rb_fb.c 25 2004-06-26 23:07:01Z tilman $
3  *
4  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <ruby.h>
22
23 #include <Ecore_Evas.h>
24
25 #include "rb_ecore_evas_main.h"
26 #include "rb_ecore_evas.h"
27
28 static VALUE c_init (int argc, VALUE *argv, VALUE self)
29 {
30         VALUE disp, rot, w, h;
31         Ecore_Evas **ee = NULL;
32         char *cdisp = NULL;
33         int irot = 0, iw = 0, ih = 0;
34
35         Data_Get_Struct (self, Ecore_Evas *, ee);
36
37         rb_scan_args (argc, argv, "04", &disp, &rot, &w, &h);
38
39         if (!NIL_P (disp)) {
40                 Check_Type (disp, T_STRING);
41                 cdisp = StringValuePtr (disp);
42         }
43
44         if (!NIL_P (rot)) {
45                 Check_Type (rot, T_FIXNUM);
46                 irot = NUM2INT (rot);
47         }
48
49         if (!NIL_P (w)) {
50                 Check_Type (w, T_FIXNUM);
51                 iw = NUM2INT (w);
52         }
53
54         if (!NIL_P (h)) {
55                 Check_Type (h, T_FIXNUM);
56                 ih = NUM2INT (h);
57         }
58
59         *ee = ecore_evas_fb_new (cdisp, irot, iw, ih);
60
61         return self;
62 }
63
64 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
65 {
66         VALUE self;
67         Ecore_Evas **ee;
68
69         self = Data_Make_Struct (klass, Ecore_Evas *,
70                                  NULL, c_ecore_evas_free, ee);
71
72         rb_obj_call_init (self, argc, argv);
73
74         return self;
75 }
76
77 void Init_Fb (void)
78 {
79         VALUE cFb = rb_define_class_under (mEvas, "Fb", cEcoreEvas);
80
81         rb_define_singleton_method (cFb, "new", c_new, -1);
82         rb_define_method (cFb, "initialize", c_init, -1);
83 }
84