Initial commit.
[ruby-ecore.git] / src / ecore / rb_ecore.c
1 /*
2  * $Id$
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.h>
24
25 #include "rb_ecore.h"
26 #include "rb_timer.h"
27 #include "rb_idler.h"
28
29 static VALUE m_init (VALUE self)
30 {
31         return INT2FIX (ecore_init ());
32 }
33
34 static VALUE m_main_loop_begin (VALUE self)
35 {
36         ecore_main_loop_begin ();
37
38         return Qnil;
39 }
40
41 static VALUE m_main_loop_iterate (VALUE self)
42 {
43         ecore_main_loop_iterate ();
44
45         return Qnil;
46 }
47
48 static VALUE m_main_loop_quit (VALUE self)
49 {
50         ecore_main_loop_quit ();
51
52         return Qnil;
53 }
54
55 static VALUE m_shutdown (VALUE self)
56 {
57         rb_gc_start ();
58
59         return INT2FIX (ecore_shutdown ());
60 }
61
62 void Init_ecore (void)
63 {
64         mEcore = rb_define_module ("Ecore");
65
66         rb_define_module_function (mEcore, "init",
67                                    m_init, 0);
68         rb_define_module_function (mEcore, "main_loop_begin",
69                                    m_main_loop_begin, 0);
70         rb_define_module_function (mEcore, "main_loop_iterate",
71                                    m_main_loop_iterate, 0);
72         rb_define_module_function (mEcore, "main_loop_quit",
73                                    m_main_loop_quit, 0);
74         rb_define_module_function (mEcore, "shutdown",
75                                    m_shutdown, 0);
76
77         Init_Timer ();
78         Init_Idler ();
79 }
80