gio2 0.90.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +60 -0
- data/README +34 -0
- data/Rakefile +76 -0
- data/ext/gio2/depend +5 -0
- data/ext/gio2/extconf.rb +91 -0
- data/ext/gio2/gappinfo.c +318 -0
- data/ext/gio2/gapplaunchcontext.c +79 -0
- data/ext/gio2/gasyncinitable.c +244 -0
- data/ext/gio2/gasyncresult.c +39 -0
- data/ext/gio2/gbufferedinputstream.c +184 -0
- data/ext/gio2/gbufferedoutputstream.c +82 -0
- data/ext/gio2/gcancellable.c +177 -0
- data/ext/gio2/gcharsetconverter.c +72 -0
- data/ext/gio2/gcontenttype.c +135 -0
- data/ext/gio2/gconverter.c +117 -0
- data/ext/gio2/gconverterinputstream.c +48 -0
- data/ext/gio2/gconverteroutputstream.c +48 -0
- data/ext/gio2/gdatainputstream.c +341 -0
- data/ext/gio2/gdataoutputstream.c +202 -0
- data/ext/gio2/gdesktopappinfo.c +90 -0
- data/ext/gio2/gdrive.c +267 -0
- data/ext/gio2/gemblem.c +71 -0
- data/ext/gio2/gemblemedicon.c +63 -0
- data/ext/gio2/gfile.c +2058 -0
- data/ext/gio2/gfileattribute.c +263 -0
- data/ext/gio2/gfileattributematcher.c +90 -0
- data/ext/gio2/gfiledescriptorbased.c +42 -0
- data/ext/gio2/gfileenumerator.c +167 -0
- data/ext/gio2/gfileicon.c +46 -0
- data/ext/gio2/gfileinfo.c +641 -0
- data/ext/gio2/gfileinputstream.c +92 -0
- data/ext/gio2/gfileiostream.c +98 -0
- data/ext/gio2/gfilemonitor.c +63 -0
- data/ext/gio2/gfilenamecompleter.c +72 -0
- data/ext/gio2/gfileoutputstream.c +100 -0
- data/ext/gio2/gfilterinputstream.c +56 -0
- data/ext/gio2/gfilteroutputstream.c +56 -0
- data/ext/gio2/gicon.c +69 -0
- data/ext/gio2/ginetaddress.c +188 -0
- data/ext/gio2/ginetsocketaddress.c +54 -0
- data/ext/gio2/ginitable.c +195 -0
- data/ext/gio2/ginputstream.c +341 -0
- data/ext/gio2/gio2.c +120 -0
- data/ext/gio2/gio2.def +2 -0
- data/ext/gio2/gio2.h +343 -0
- data/ext/gio2/gioerror.c +67 -0
- data/ext/gio2/giomodule.c +63 -0
- data/ext/gio2/gioscheduler.c +195 -0
- data/ext/gio2/giostream.c +129 -0
- data/ext/gio2/gloadableicon.c +91 -0
- data/ext/gio2/gmemoryinputstream.c +65 -0
- data/ext/gio2/gmemoryoutputstream.c +65 -0
- data/ext/gio2/gmount.c +283 -0
- data/ext/gio2/gmountoperation.c +168 -0
- data/ext/gio2/gnetworkaddress.c +71 -0
- data/ext/gio2/gnetworkservice.c +64 -0
- data/ext/gio2/goutputstream.c +343 -0
- data/ext/gio2/gresolver.c +230 -0
- data/ext/gio2/gseekable.c +89 -0
- data/ext/gio2/gsimpleasyncresult.c +153 -0
- data/ext/gio2/gsocket.c +451 -0
- data/ext/gio2/gsocketaddress.c +45 -0
- data/ext/gio2/gsocketclient.c +273 -0
- data/ext/gio2/gsocketconnectable.c +97 -0
- data/ext/gio2/gsocketconnection.c +82 -0
- data/ext/gio2/gsocketcontrolmessage.c +82 -0
- data/ext/gio2/gsocketlistener.c +239 -0
- data/ext/gio2/gsocketservice.c +64 -0
- data/ext/gio2/gsrvtarget.c +77 -0
- data/ext/gio2/gtcpconnection.c +48 -0
- data/ext/gio2/gthemedicon.c +86 -0
- data/ext/gio2/gthreadedsocketservice.c +39 -0
- data/ext/gio2/gunixconnection.c +69 -0
- data/ext/gio2/gunixfdlist.c +112 -0
- data/ext/gio2/gunixfdmessage.c +81 -0
- data/ext/gio2/gunixinputstream.c +73 -0
- data/ext/gio2/gunixmounts.c +346 -0
- data/ext/gio2/gunixoutputstream.c +73 -0
- data/ext/gio2/gunixsocketaddress.c +79 -0
- data/ext/gio2/gvfs.c +84 -0
- data/ext/gio2/gvolume.c +191 -0
- data/ext/gio2/gvolumemonitor.c +77 -0
- data/ext/gio2/gzlibcompressor.c +47 -0
- data/ext/gio2/gzlibdecompressor.c +43 -0
- data/ext/gio2/util.c +323 -0
- data/extconf.rb +49 -0
- data/lib/gio2.rb +141 -0
- metadata +184 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
2
|
+
/*
|
3
|
+
* Ruby/GIO: a Ruby binding of gio-2.0.x.
|
4
|
+
* Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
|
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.
|
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 "gio2.h"
|
22
|
+
|
23
|
+
#define _SELF(value) G_FILTER_OUTPUT_STREAM(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
filteroutputstream_get_base_stream(VALUE self)
|
27
|
+
{
|
28
|
+
return GOBJ2RVAL(g_filter_output_stream_get_base_stream(_SELF(self)));
|
29
|
+
}
|
30
|
+
|
31
|
+
static VALUE
|
32
|
+
filteroutputstream_get_close_base_stream(VALUE self)
|
33
|
+
{
|
34
|
+
return CBOOL2RVAL(g_filter_output_stream_get_close_base_stream(_SELF(self)));
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE
|
38
|
+
filteroutputstream_set_close_base_stream(VALUE self, VALUE close_base)
|
39
|
+
{
|
40
|
+
g_filter_output_stream_set_close_base_stream(_SELF(self), RVAL2CBOOL(close_base));
|
41
|
+
|
42
|
+
return self;
|
43
|
+
}
|
44
|
+
|
45
|
+
void
|
46
|
+
Init_gfilteroutputstream(VALUE glib)
|
47
|
+
{
|
48
|
+
VALUE filteroutputstream = G_DEF_CLASS(G_TYPE_FILTER_OUTPUT_STREAM, "FilterOutputStream", glib);
|
49
|
+
|
50
|
+
rb_undef_alloc_func(filteroutputstream);
|
51
|
+
|
52
|
+
rb_define_method(filteroutputstream, "base_stream", filteroutputstream_get_base_stream, 0);
|
53
|
+
rb_define_method(filteroutputstream, "close_base_stream?", filteroutputstream_get_close_base_stream, 0);
|
54
|
+
rb_define_method(filteroutputstream, "set_close_base_stream", filteroutputstream_set_close_base_stream, 1);
|
55
|
+
G_DEF_SETTER(filteroutputstream, "close_base_stream");
|
56
|
+
}
|
data/ext/gio2/gicon.c
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
2
|
+
/*
|
3
|
+
* Ruby/GIO: a Ruby binding of gio-2.0.x.
|
4
|
+
* Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
|
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.
|
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 "gio2.h"
|
22
|
+
|
23
|
+
#define _SELF(value) RVAL2GICON(value)
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
icon_new_for_string(G_GNUC_UNUSED VALUE self, VALUE string)
|
27
|
+
{
|
28
|
+
GError *error = NULL;
|
29
|
+
GIcon *icon;
|
30
|
+
|
31
|
+
icon = g_icon_new_for_string(RVAL2CSTR(string), &error);
|
32
|
+
if (icon == NULL)
|
33
|
+
rbgio_raise_error(error);
|
34
|
+
|
35
|
+
return GOBJ2RVAL_UNREF(icon);
|
36
|
+
}
|
37
|
+
|
38
|
+
static VALUE
|
39
|
+
icon_hash(VALUE self)
|
40
|
+
{
|
41
|
+
return GUINT2RVAL(g_icon_hash(_SELF(self)));
|
42
|
+
}
|
43
|
+
|
44
|
+
static VALUE
|
45
|
+
icon_equal(VALUE self, VALUE other)
|
46
|
+
{
|
47
|
+
return CBOOL2RVAL(g_icon_equal(_SELF(self), _SELF(other)));
|
48
|
+
}
|
49
|
+
|
50
|
+
static VALUE
|
51
|
+
icon_to_string(VALUE self)
|
52
|
+
{
|
53
|
+
/* TODO: Should we raise if it returns NULL? */
|
54
|
+
return CSTR2RVAL_FREE(g_icon_to_string(_SELF(self)));
|
55
|
+
}
|
56
|
+
|
57
|
+
void
|
58
|
+
Init_gicon(VALUE glib)
|
59
|
+
{
|
60
|
+
VALUE icon = G_DEF_INTERFACE(G_TYPE_ICON, "Icon", glib);
|
61
|
+
|
62
|
+
rb_define_singleton_method(icon, "new_for_string", icon_new_for_string, 1);
|
63
|
+
|
64
|
+
rb_define_method(icon, "hash", icon_hash, 0);
|
65
|
+
rb_define_method(icon, "==", icon_equal, 1);
|
66
|
+
rb_define_method(icon, "to_string", icon_to_string, 0);
|
67
|
+
rb_define_alias(icon, "to_str", "to_string");
|
68
|
+
rb_define_alias(icon, "to_s", "to_string");
|
69
|
+
}
|
@@ -0,0 +1,188 @@
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
2
|
+
/*
|
3
|
+
* Ruby/GIO: a Ruby binding of gio-2.0.x.
|
4
|
+
* Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
|
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.
|
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 "gio2.h"
|
22
|
+
|
23
|
+
#define _SELF(value) RVAL2GINETADDRESS(value)
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
inetaddress_new_from_string(G_GNUC_UNUSED VALUE self, VALUE string)
|
27
|
+
{
|
28
|
+
return GOBJ2RVAL_UNREF(g_inet_address_new_from_string(RVAL2CSTR(string)));
|
29
|
+
}
|
30
|
+
|
31
|
+
/* TODO: Should this take an array instead? */
|
32
|
+
static VALUE
|
33
|
+
inetaddress_new_from_bytes(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
34
|
+
{
|
35
|
+
VALUE rbbytes, rbfamily;
|
36
|
+
guint8 *bytes;
|
37
|
+
GSocketFamily family;
|
38
|
+
|
39
|
+
rb_scan_args(argc, argv, "11", &rbbytes, &rbfamily);
|
40
|
+
bytes = (guint8 *)RVAL2CSTR(rbbytes);
|
41
|
+
family = RVAL2GSOCKETFAMILY(rbfamily);
|
42
|
+
|
43
|
+
/* TODO: Should check encoding. */
|
44
|
+
/* TODO: We can’t pass bytes as such, as it will be NULL-terminated. */
|
45
|
+
/* TODO: Do we need to deal with G_SOCKET_FAMILY_UNIX? */
|
46
|
+
switch (family) {
|
47
|
+
case G_SOCKET_FAMILY_IPV4:
|
48
|
+
if (RSTRING_LEN(rbbytes) != 4)
|
49
|
+
rb_raise(rb_eArgError, "string containing 4 bytes expected");
|
50
|
+
break;
|
51
|
+
case G_SOCKET_FAMILY_IPV6:
|
52
|
+
if (RSTRING_LEN(rbbytes) != 16)
|
53
|
+
rb_raise(rb_eArgError, "string containing 16 bytes expected");
|
54
|
+
break;
|
55
|
+
case G_SOCKET_FAMILY_INVALID:
|
56
|
+
case G_SOCKET_FAMILY_UNIX:
|
57
|
+
rb_raise(rb_eArgError, "invalid family: %d", family);
|
58
|
+
default:
|
59
|
+
rb_raise(rb_eArgError, "unknown family: %d", family);
|
60
|
+
break;
|
61
|
+
}
|
62
|
+
|
63
|
+
return GOBJ2RVAL_UNREF(g_inet_address_new_from_bytes(bytes, family));
|
64
|
+
}
|
65
|
+
|
66
|
+
static VALUE
|
67
|
+
inetaddress_new_any(G_GNUC_UNUSED VALUE self, VALUE family)
|
68
|
+
{
|
69
|
+
return GOBJ2RVAL_UNREF(g_inet_address_new_any(RVAL2GSOCKETFAMILY(family)));
|
70
|
+
}
|
71
|
+
|
72
|
+
static VALUE
|
73
|
+
inetaddress_new_loopback(G_GNUC_UNUSED VALUE self, VALUE family)
|
74
|
+
{
|
75
|
+
return GOBJ2RVAL_UNREF(g_inet_address_new_loopback(RVAL2GSOCKETFAMILY(family)));
|
76
|
+
}
|
77
|
+
|
78
|
+
/* TODO: Return array of bytes instead? */
|
79
|
+
static VALUE
|
80
|
+
inetaddress_to_bytes(VALUE self)
|
81
|
+
{
|
82
|
+
gsize size;
|
83
|
+
|
84
|
+
size = g_inet_address_get_native_size(_SELF(self));
|
85
|
+
return rb_str_new((const gchar *)g_inet_address_to_bytes(_SELF(self)),
|
86
|
+
size);
|
87
|
+
}
|
88
|
+
|
89
|
+
static VALUE
|
90
|
+
inetaddress_get_native_size(VALUE self)
|
91
|
+
{
|
92
|
+
return GSIZE2RVAL(g_inet_address_get_native_size(_SELF(self)));
|
93
|
+
}
|
94
|
+
|
95
|
+
static VALUE
|
96
|
+
inetaddress_to_string(VALUE self)
|
97
|
+
{
|
98
|
+
return CSTR2RVAL_FREE(g_inet_address_to_string(_SELF(self)));
|
99
|
+
}
|
100
|
+
|
101
|
+
static VALUE
|
102
|
+
inetaddress_get_family(VALUE self)
|
103
|
+
{
|
104
|
+
return GSOCKETFAMILY2RVAL(g_inet_address_get_family(_SELF(self)));
|
105
|
+
}
|
106
|
+
|
107
|
+
static VALUE
|
108
|
+
inetaddress_get_is_any(VALUE self)
|
109
|
+
{
|
110
|
+
return CBOOL2RVAL(g_inet_address_get_is_any(_SELF(self)));
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
inetaddress_get_is_loopback(VALUE self)
|
115
|
+
{
|
116
|
+
return CBOOL2RVAL(g_inet_address_get_is_loopback(_SELF(self)));
|
117
|
+
}
|
118
|
+
|
119
|
+
static VALUE
|
120
|
+
inetaddress_get_is_link_local(VALUE self)
|
121
|
+
{
|
122
|
+
return CBOOL2RVAL(g_inet_address_get_is_link_local(_SELF(self)));
|
123
|
+
}
|
124
|
+
|
125
|
+
static VALUE
|
126
|
+
inetaddress_get_is_site_local(VALUE self)
|
127
|
+
{
|
128
|
+
return CBOOL2RVAL(g_inet_address_get_is_site_local(_SELF(self)));
|
129
|
+
}
|
130
|
+
|
131
|
+
static VALUE
|
132
|
+
inetaddress_get_is_multicast(VALUE self)
|
133
|
+
{
|
134
|
+
return CBOOL2RVAL(g_inet_address_get_is_multicast(_SELF(self)));
|
135
|
+
}
|
136
|
+
|
137
|
+
static VALUE
|
138
|
+
inetaddress_get_is_mc_link_local(VALUE self)
|
139
|
+
{
|
140
|
+
return CBOOL2RVAL(g_inet_address_get_is_mc_link_local(_SELF(self)));
|
141
|
+
}
|
142
|
+
|
143
|
+
static VALUE
|
144
|
+
inetaddress_get_is_mc_node_local(VALUE self)
|
145
|
+
{
|
146
|
+
return CBOOL2RVAL(g_inet_address_get_is_mc_node_local(_SELF(self)));
|
147
|
+
}
|
148
|
+
|
149
|
+
static VALUE
|
150
|
+
inetaddress_get_is_mc_site_local(VALUE self)
|
151
|
+
{
|
152
|
+
return CBOOL2RVAL(g_inet_address_get_is_mc_site_local(_SELF(self)));
|
153
|
+
}
|
154
|
+
|
155
|
+
static VALUE
|
156
|
+
inetaddress_get_is_mc_global(VALUE self)
|
157
|
+
{
|
158
|
+
return CBOOL2RVAL(g_inet_address_get_is_mc_global(_SELF(self)));
|
159
|
+
}
|
160
|
+
|
161
|
+
void
|
162
|
+
Init_ginetaddress(VALUE glib)
|
163
|
+
{
|
164
|
+
VALUE inetaddress = G_DEF_INTERFACE(G_TYPE_INET_ADDRESS, "InetAddress", glib);
|
165
|
+
|
166
|
+
rb_define_singleton_method(inetaddress, "new_from_string", inetaddress_new_from_string, 1);
|
167
|
+
rb_define_singleton_method(inetaddress, "new_from_bytes", inetaddress_new_from_bytes, -1);
|
168
|
+
rb_define_singleton_method(inetaddress, "new_any", inetaddress_new_any, 1);
|
169
|
+
rb_define_singleton_method(inetaddress, "new_loopback", inetaddress_new_loopback, 1);
|
170
|
+
|
171
|
+
rb_undef_alloc_func(inetaddress);
|
172
|
+
|
173
|
+
rb_define_method(inetaddress, "to_bytes", inetaddress_to_bytes, 0);
|
174
|
+
rb_define_method(inetaddress, "get_native_size", inetaddress_get_native_size, 0);
|
175
|
+
rb_define_method(inetaddress, "to_string", inetaddress_to_string, 0);
|
176
|
+
rb_define_alias(inetaddress, "to_str", "to_string");
|
177
|
+
rb_define_alias(inetaddress, "to_s", "to_string");
|
178
|
+
rb_define_method(inetaddress, "family", inetaddress_get_family, 0);
|
179
|
+
rb_define_method(inetaddress, "any?", inetaddress_get_is_any, 0);
|
180
|
+
rb_define_method(inetaddress, "loopback?", inetaddress_get_is_loopback, 0);
|
181
|
+
rb_define_method(inetaddress, "link_local?", inetaddress_get_is_link_local, 0);
|
182
|
+
rb_define_method(inetaddress, "site_local?", inetaddress_get_is_site_local, 0);
|
183
|
+
rb_define_method(inetaddress, "multicast?", inetaddress_get_is_multicast, 0);
|
184
|
+
rb_define_method(inetaddress, "mc_link_local?", inetaddress_get_is_mc_link_local, 0);
|
185
|
+
rb_define_method(inetaddress, "mc_node_local?", inetaddress_get_is_mc_node_local, 0);
|
186
|
+
rb_define_method(inetaddress, "mc_site_local?", inetaddress_get_is_mc_site_local, 0);
|
187
|
+
rb_define_method(inetaddress, "mc_global?", inetaddress_get_is_mc_global, 0);
|
188
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
2
|
+
/*
|
3
|
+
* Ruby/GIO: a Ruby binding of gio-2.0.x.
|
4
|
+
* Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
|
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.
|
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 "gio2.h"
|
22
|
+
|
23
|
+
#define _SELF(value) G_INET_SOCKET_ADDRESS(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
inetsocketaddress_initialize(VALUE self, VALUE address, VALUE port)
|
27
|
+
{
|
28
|
+
G_INITIALIZE(self, g_inet_socket_address_new(RVAL2GINETADDRESS(address),
|
29
|
+
RVAL2GUINT16(port)));
|
30
|
+
|
31
|
+
return Qnil;
|
32
|
+
}
|
33
|
+
|
34
|
+
static VALUE
|
35
|
+
inetsocketaddress_get_address(VALUE self)
|
36
|
+
{
|
37
|
+
return GOBJ2RVAL(g_inet_socket_address_get_address(_SELF(self)));
|
38
|
+
}
|
39
|
+
|
40
|
+
static VALUE
|
41
|
+
inetsocketaddress_get_port(VALUE self)
|
42
|
+
{
|
43
|
+
return GUINT162RVAL(g_inet_socket_address_get_port(_SELF(self)));
|
44
|
+
}
|
45
|
+
|
46
|
+
void
|
47
|
+
Init_ginetsocketaddress(VALUE glib)
|
48
|
+
{
|
49
|
+
VALUE inetsocketaddress = G_DEF_CLASS(G_TYPE_INET_SOCKET_ADDRESS, "InetSocketAddress", glib);
|
50
|
+
|
51
|
+
rb_define_method(inetsocketaddress, "initialize", inetsocketaddress_initialize, 2);
|
52
|
+
rb_define_method(inetsocketaddress, "address", inetsocketaddress_get_address, 0);
|
53
|
+
rb_define_method(inetsocketaddress, "port", inetsocketaddress_get_port, 0);
|
54
|
+
}
|
@@ -0,0 +1,195 @@
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
2
|
+
/*
|
3
|
+
* Ruby/GIO: a Ruby binding of gio-2.0.x.
|
4
|
+
* Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
|
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.
|
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 "gio2.h"
|
22
|
+
|
23
|
+
#define _SELF(value) G_INITABLE(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
initable_init(int argc, VALUE *argv, VALUE self)
|
27
|
+
{
|
28
|
+
VALUE cancellable;
|
29
|
+
GError *error = NULL;
|
30
|
+
|
31
|
+
rb_scan_args(argc, argv, "01", &cancellable);
|
32
|
+
if (!g_initable_init(_SELF(self),
|
33
|
+
RVAL2GCANCELLABLE(cancellable),
|
34
|
+
&error))
|
35
|
+
rbgio_raise_error(error);
|
36
|
+
|
37
|
+
return self;
|
38
|
+
}
|
39
|
+
|
40
|
+
struct rbgio_ginitable_new_data {
|
41
|
+
GObjectClass *gclass;
|
42
|
+
GCancellable *cancellable;
|
43
|
+
VALUE rbparameters;
|
44
|
+
guint index;
|
45
|
+
guint n_parameters;
|
46
|
+
GParameter *parameters;
|
47
|
+
GError *error;
|
48
|
+
};
|
49
|
+
|
50
|
+
static VALUE
|
51
|
+
rbgio_ginitiable_new_parameters_initialize(VALUE key_value,
|
52
|
+
struct rbgio_ginitable_new_data *data)
|
53
|
+
{
|
54
|
+
VALUE key, value;
|
55
|
+
GParamSpec *spec;
|
56
|
+
|
57
|
+
if (data->index >= data->n_parameters)
|
58
|
+
rb_raise(rb_eArgError,
|
59
|
+
"too many parameters (%d >= %d)",
|
60
|
+
data->index, data->n_parameters);
|
61
|
+
|
62
|
+
key = rb_ary_entry(key_value, 0);
|
63
|
+
value = rb_ary_entry(key_value, 1);
|
64
|
+
|
65
|
+
data->parameters[data->index].name = SYMBOL_P(key) ?
|
66
|
+
rb_id2name(SYM2ID(key)) :
|
67
|
+
StringValuePtr(key);
|
68
|
+
spec = g_object_class_find_property(data->gclass,
|
69
|
+
data->parameters[data->index].name);
|
70
|
+
if (spec == NULL)
|
71
|
+
rb_raise(rb_eArgError,
|
72
|
+
"%s: no such property",
|
73
|
+
data->parameters[data->index].name);
|
74
|
+
g_value_init(&(data->parameters[data->index].value),
|
75
|
+
G_PARAM_SPEC_VALUE_TYPE(spec));
|
76
|
+
rbgobj_rvalue_to_gvalue(value, &(data->parameters[data->index].value));
|
77
|
+
|
78
|
+
data->index++;
|
79
|
+
|
80
|
+
return Qnil;
|
81
|
+
}
|
82
|
+
|
83
|
+
static VALUE
|
84
|
+
rbgio_ginitable_new_body(struct rbgio_ginitable_new_data *data)
|
85
|
+
{
|
86
|
+
rb_iterate(rb_each,
|
87
|
+
data->rbparameters,
|
88
|
+
rbgio_ginitiable_new_parameters_initialize,
|
89
|
+
(VALUE)data);
|
90
|
+
|
91
|
+
return (VALUE)g_initable_newv(G_TYPE_FROM_CLASS(data->gclass),
|
92
|
+
data->n_parameters,
|
93
|
+
data->parameters,
|
94
|
+
data->cancellable,
|
95
|
+
&data->error);
|
96
|
+
}
|
97
|
+
|
98
|
+
static VALUE
|
99
|
+
rbgio_ginitable_new_ensure(struct rbgio_ginitable_new_data *data)
|
100
|
+
{
|
101
|
+
guint i;
|
102
|
+
|
103
|
+
g_type_class_unref(data->gclass);
|
104
|
+
for (i = 0; i < data->n_parameters; i++)
|
105
|
+
if (G_IS_VALUE(&data->parameters[i].value))
|
106
|
+
g_value_unset(&data->parameters[i].value);
|
107
|
+
|
108
|
+
return Qnil;
|
109
|
+
}
|
110
|
+
|
111
|
+
GObject *
|
112
|
+
rbgio_ginitable_new(GType type, VALUE parameters, VALUE cancellable)
|
113
|
+
{
|
114
|
+
static ID s_id_length;
|
115
|
+
GError *error = NULL;
|
116
|
+
GObject *object;
|
117
|
+
struct rbgio_ginitable_new_data data;
|
118
|
+
|
119
|
+
if (s_id_length == 0)
|
120
|
+
s_id_length = rb_intern("length");
|
121
|
+
|
122
|
+
if (!g_type_is_a(type, G_TYPE_OBJECT))
|
123
|
+
rb_raise(rb_eArgError,
|
124
|
+
"%s is not a descendant of GObject",
|
125
|
+
g_type_name(type));
|
126
|
+
|
127
|
+
if (NIL_P(parameters)) {
|
128
|
+
object = g_initable_newv(type,
|
129
|
+
0,
|
130
|
+
NULL,
|
131
|
+
RVAL2GCANCELLABLE(cancellable),
|
132
|
+
&error);
|
133
|
+
if (object == NULL)
|
134
|
+
rbgio_raise_error(error);
|
135
|
+
|
136
|
+
return object;
|
137
|
+
} else {
|
138
|
+
parameters = rb_convert_type(parameters,
|
139
|
+
T_HASH,
|
140
|
+
"Hash",
|
141
|
+
"to_hash");
|
142
|
+
}
|
143
|
+
|
144
|
+
data.gclass = G_OBJECT_CLASS(g_type_class_ref(type));
|
145
|
+
data.cancellable = RVAL2GCANCELLABLE(cancellable);
|
146
|
+
data.rbparameters = parameters;
|
147
|
+
data.index = 0;
|
148
|
+
data.n_parameters = RVAL2GUINT(rb_funcall(parameters, s_id_length, 0));
|
149
|
+
data.parameters = ALLOCA_N(GParameter, data.n_parameters);
|
150
|
+
data.error = NULL;
|
151
|
+
|
152
|
+
object = (GObject *)rb_ensure(rbgio_ginitable_new_body, (VALUE)&data,
|
153
|
+
rbgio_ginitable_new_ensure, (VALUE)&data);
|
154
|
+
if (object == NULL)
|
155
|
+
rbgio_raise_error(data.error);
|
156
|
+
|
157
|
+
return object;
|
158
|
+
}
|
159
|
+
|
160
|
+
/* NOTE: We don’t implement g_initable_new. */
|
161
|
+
|
162
|
+
/* NOTE: We don’t implement g_initable_new_valist. */
|
163
|
+
|
164
|
+
static VALUE
|
165
|
+
initable_initialize(int argc, VALUE *argv, VALUE self)
|
166
|
+
{
|
167
|
+
const RGObjClassInfo* info;
|
168
|
+
VALUE cancellable, parameters;
|
169
|
+
GObject *object;
|
170
|
+
VALUE result;
|
171
|
+
|
172
|
+
rb_scan_args(argc, argv, "02", &cancellable, ¶meters);
|
173
|
+
|
174
|
+
info = CLASS2CINFO(self);
|
175
|
+
if (info->klass != self)
|
176
|
+
rb_raise(rb_eTypeError,
|
177
|
+
"%s: class not registered with GLib",
|
178
|
+
rb_class2name(self));
|
179
|
+
|
180
|
+
object = rbgio_ginitable_new(info->gtype, parameters, cancellable);
|
181
|
+
result = GOBJ2RVAL(object);
|
182
|
+
g_object_unref(object);
|
183
|
+
|
184
|
+
return result;
|
185
|
+
}
|
186
|
+
|
187
|
+
void
|
188
|
+
Init_ginitable(VALUE glib)
|
189
|
+
{
|
190
|
+
VALUE initable = G_DEF_INTERFACE(G_TYPE_INITABLE, "Initable", glib);
|
191
|
+
|
192
|
+
rb_define_module_function(initable, "new", initable_initialize, -1);
|
193
|
+
|
194
|
+
rb_define_method(initable, "init", initable_init, -1);
|
195
|
+
}
|