Use ecore_evas_data_set/get to store a pointer to self.
[ruby-ecore.git] / src / ecore_evas / rb_fb.c
1 /*
2  * $Id: rb_fb.c 77 2004-08-19 17:39:29Z tilman $
3  *
4  * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
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.h>
24 #include <Ecore_Evas.h>
25
26 #include "rb_ecore_evas_main.h"
27 #include "rb_ecore_evas.h"
28
29 static void c_free (RbEcoreEvas *ee)
30 {
31         c_ecore_evas_free (ee, true);
32 }
33
34 /*
35  * call-seq:
36  *  Ecore::Evas::Fb.new([display, rotation, w, h]) => fb
37  *
38  * Creates an Ecore::Evas::Fb object.
39  */
40 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
41 {
42         VALUE self, disp, rot, w, h;
43         RbEcoreEvas *ee = NULL;
44         char *cdisp = NULL;
45         int irot = 0, iw = 0, ih = 0;
46
47         self = Data_Make_Struct (klass, RbEcoreEvas,
48                                  c_ecore_evas_mark, c_free, ee);
49
50         rb_scan_args (argc, argv, "04", &disp, &rot, &w, &h);
51
52         if (!NIL_P (disp)) {
53                 Check_Type (disp, T_STRING);
54                 cdisp = StringValuePtr (disp);
55         }
56
57         if (!NIL_P (rot)) {
58                 Check_Type (rot, T_FIXNUM);
59                 irot = FIX2INT (rot);
60         }
61
62         if (!NIL_P (w)) {
63                 Check_Type (w, T_FIXNUM);
64                 iw = FIX2INT (w);
65         }
66
67         if (!NIL_P (h)) {
68                 Check_Type (h, T_FIXNUM);
69                 ih = FIX2INT (h);
70         }
71
72         ecore_init ();
73         ecore_evas_init ();
74
75         ee->real = ecore_evas_fb_new (cdisp, irot, iw, ih);
76
77         rb_obj_call_init (self, 0, NULL);
78
79         return self;
80 }
81
82 void Init_Fb (void)
83 {
84         VALUE c = rb_define_class_under (mEvas, "Fb", cEcoreEvas);
85
86         rb_define_singleton_method (c, "new", c_new, -1);
87 }