2 * $Id: rb_messages.c 139 2004-10-30 09:41:17Z tilman $
4 * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
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.
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.
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
25 #define __RB_MESSAGES_C
26 #include "rb_edje_main.h"
28 #include "rb_messages.h"
30 #define DEF_CONST(mod, prefix, name) \
31 rb_define_const ((mod), #name, \
32 INT2FIX (prefix##name));
36 static VALUE c_msg_init (VALUE self)
38 rb_iv_set (self, "@id", UINT2NUM (0));
43 static VALUE c_str_msg_init (VALUE self, VALUE str)
45 Check_Type (str, T_STRING);
47 rb_call_super (0, NULL);
49 rb_iv_set (self, "@type", UINT2NUM (EDJE_MESSAGE_STRING));
50 rb_iv_set (self, "@string", str);
55 static VALUE c_str_msg_serialize (VALUE self)
57 static volatile Edje_Message_String ret;
60 s = rb_iv_get (self, "@string");
61 ret.str = StringValuePtr (s);
66 void Init_Messages (void)
68 cMsg = rb_define_class_under (mEdje, "Message", rb_cObject);
70 rb_define_method (cMsg, "initialize", c_msg_init, 0);
72 rb_define_attr (cMsg, "type", 1, 0);
73 rb_define_attr (cMsg, "id", 1, 1);
75 cStrMsg = rb_define_class_under (mEdje, "StringMessage", cMsg);
76 rb_define_method (cStrMsg, "initialize", c_str_msg_init, 1);
77 rb_define_method (cStrMsg, "serialize", c_str_msg_serialize, 0);
79 rb_define_attr (cStrMsg, "string", 1, 1);