glib2 0.90.2 → 0.90.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,52 @@
1
+ 2010-10-23 Kouhei Sutou <kou@cozmixng.org>
2
+
3
+ * ext/glib2/glib2.def: add missing exported symbols.
4
+
5
+ * lib/mkmf-gnome2.rb: ignore nonexistent directory.
6
+
7
+ * ext/glib2/rbglib.c, ext/glib2/rbglib.h:
8
+ fix alived string may be GCed in RVAL2CSTR and
9
+ RVAL2CSTR_ACCEPT_NIL problem.
10
+ Suggested by Neil Roberts. Thanks!!!
11
+
12
+ 2010-10-21 Kouhei Sutou <kou@cozmixng.org>
13
+
14
+ * ext/glib2/rbgobj_paramspecs.c: add missing type declarations.
15
+ Reported by Nobuyoshi Nakada. Thanks!!!
16
+
17
+ 2010-10-08 Guillaume Cottenceau
18
+
19
+ * fix some uses of rb_str_new* and StringValuePtr to use
20
+ encoding-aware Strings
21
+
22
+ 2010-10-08 Guillaume Cottenceau
23
+
24
+ * RVAL2CSTR2 is deprecated, replace with RVAL2CSTR_ACCEPT_NIL
25
+
26
+ * CSTR2RVAL2 is deprecated, replace with CSTR2RVAL_FREE
27
+
28
+ 2010-10-07 Guillaume Cottenceau
29
+
30
+ * ext/glib2/rbglib.c, ext/glib2/rbglib.h, ext/glib2/glib2.def,
31
+ ext/glib2/rbglib_bookmarkfile.c: have RVAL2CSTRFILENAME,
32
+ CSTRFILENAME2RVAL_FREE and CSTRFILENAMEARRAY2RVAL_FREE, to handle
33
+ filename String to/from rg2 manipulations, in glib2 to use them in
34
+ any rg2 submodules
35
+
36
+ 2010-10-06 Guillaume Cottenceau
37
+
38
+ * ext/glib2/rbglib.c, ext/glib2/extconf.rb: use
39
+ HAVE_RUBY_ENCODING_H, not HAVE_RB_STR_ENCODE
40
+
41
+ 2010-09-30 Guillaume Cottenceau
42
+
43
+ * ext/glib2/rbglib.c, ext/glib2/rbgobj_value.c,
44
+ ext/glib2/rbglib.h, ext/glib2/glib2.def: improve CSTR2RVAL,
45
+ RVAL2CSTR, gvalue2rvalue, and rvalue2gvalue, to use UTF-8 strings
46
+ when Ruby supports String encoding (Ruby 1.9) - in particular this
47
+ should allow retrieving usable Strings from rg2 (Strings with a
48
+ set encoding)
49
+
1
50
  2010-09-26 Kouhei Sutou <kou@cozmixng.org>
2
51
 
3
52
  * ext/glib2/rbglib.h: 0.90.2 -> 0.90.3.
data/Rakefile CHANGED
@@ -35,6 +35,7 @@ spec = Gem::Specification.new do |s|
35
35
  s.platform = Gem::Platform::RUBY
36
36
  s.extensions = FileList["ext/#{package_name}/extconf.rb"]
37
37
  s.require_paths = ["lib"]
38
+ s.add_development_dependency("pkg-config", ">= 0")
38
39
  s.files = FileList["ChangeLog", "README", "Rakefile", "extconf.rb",
39
40
  "lib/**/*.rb", "{ext,sample,test,test-unit}/**/*"]
40
41
  end
@@ -6,5 +6,7 @@ install-so:
6
6
  $(INSTALL_DATA) glib-enum-types.h $(RUBYARCHDIR)
7
7
 
8
8
  install:
9
- $(MAKEDIRS) $(libdir)/pkgconfig
10
- $(INSTALL_DATA) ruby-glib2.pc $(libdir)/pkgconfig
9
+ if test -n "$(pkgconfigdir)"; then \
10
+ $(MAKEDIRS) $(pkgconfigdir); \
11
+ $(INSTALL_DATA) ruby-glib2.pc $(pkgconfigdir); \
12
+ fi
@@ -37,7 +37,6 @@ have_func("rb_sourceline", ruby_header)
37
37
  have_func("ruby_set_current_source", ruby_header)
38
38
  have_func("rb_thread_blocking_region", ruby_header)
39
39
  have_func("ruby_native_thread_p", ruby_header)
40
- have_func("rb_str_encode", ruby_header)
41
40
 
42
41
  have_var("curr_thread", [ruby_header, "node.h"])
43
42
  have_var("rb_curr_thread", [ruby_header, "node.h"])
@@ -56,9 +56,13 @@ EXPORTS
56
56
  g_value_set_ruby_value
57
57
  g_key_file_get_type
58
58
  rbg_rval_inspect
59
+ rbg_rval2cstr
59
60
  rbg_rval2cstr_accept_nil
60
61
  rbg_cstr2rval
61
62
  rbg_cstr2rval_with_free
63
+ rbg_filename_to_ruby_free
64
+ rbg_filename_from_ruby
65
+ rbg_filename_gslist_to_array_free
62
66
  rbg_string_value_ptr
63
67
  rbgutil_id_module_eval DATA
64
68
  rbgutil_def_setters
@@ -85,5 +89,10 @@ EXPORTS
85
89
  rbgobj_fund_define_fundamental
86
90
  rbgobj_gc_mark_gvalue
87
91
  rbgobj_gc_mark_instance
92
+ rbglib_num_to_uint64
93
+ rbglib_uint64_to_num
94
+ rbglib_num_to_int64
95
+ rbglib_int64_to_num
88
96
 
89
97
  g_connect_flags_get_type
98
+ g_poll_fd_get_type
@@ -43,6 +43,18 @@ extern void Init_glib_unicode();
43
43
  extern void Init_glib_keyfile();
44
44
  extern void Init_glib_bookmark_file();
45
45
 
46
+ gchar *
47
+ rbg_rval2cstr(VALUE *str)
48
+ {
49
+ StringValue(*str);
50
+ #ifdef HAVE_RUBY_ENCODING_H
51
+ if (rb_enc_get(*str) != rb_utf8_encoding()) {
52
+ str = rb_str_export_to_enc(*str, rb_utf8_encoding());
53
+ }
54
+ #endif
55
+ return RSTRING_PTR(*str);
56
+ }
57
+
46
58
  const gchar *
47
59
  rbg_rval_inspect(VALUE object)
48
60
  {
@@ -60,21 +72,29 @@ rbg_string_value_ptr(ptr)
60
72
  }
61
73
 
62
74
  gchar *
63
- rbg_rval2cstr_accept_nil(VALUE str)
75
+ rbg_rval2cstr_accept_nil(VALUE *str)
64
76
  {
65
- return NIL_P(str) ? NULL : StringValuePtr(str);
77
+ return NIL_P(*str) ? NULL : RVAL2CSTR(*str);
66
78
  }
67
79
 
68
80
  VALUE
69
81
  rbg_cstr2rval(const char* str)
70
82
  {
83
+ #ifdef HAVE_RUBY_ENCODING_H
84
+ return str ? rb_external_str_new_with_enc(str, strlen(str), rb_utf8_encoding()) : Qnil;
85
+ #else
71
86
  return str ? rb_str_new2(str) : Qnil;
87
+ #endif
72
88
  }
73
89
 
74
90
  static VALUE
75
91
  rbg_cstr2rval_with_free_body(VALUE str)
76
92
  {
93
+ #ifdef HAVE_RUBY_ENCODING_H
94
+ return rb_external_str_new_with_enc((gchar *)str, strlen((gchar *)str), rb_utf8_encoding());
95
+ #else
77
96
  return rb_str_new2((gchar *)str);
97
+ #endif
78
98
  }
79
99
 
80
100
  static VALUE
@@ -92,6 +112,94 @@ rbg_cstr2rval_with_free(gchar *str)
92
112
  rbg_cstr2rval_with_free_ensure, (VALUE)str) : Qnil;
93
113
  }
94
114
 
115
+ #ifdef HAVE_RUBY_ENCODING_H
116
+ static rb_encoding *filename_encoding_if_not_utf8;
117
+ #endif
118
+
119
+ VALUE
120
+ rbg_filename_to_ruby_free(gchar *filename)
121
+ {
122
+ #ifdef HAVE_RUBY_ENCODING_H
123
+ gchar *filename_utf8;
124
+ GError *error = NULL;
125
+ gsize written;
126
+ VALUE rb_filename = Qnil;
127
+
128
+ if (filename == NULL)
129
+ return Qnil;
130
+
131
+ /* convert filename to UTF-8 if needed */
132
+ if (filename_encoding_if_not_utf8 != NULL) {
133
+ filename_utf8 = g_filename_to_utf8(filename, -1, NULL, &written, &error);
134
+ g_free(filename);
135
+ if (error != NULL)
136
+ RAISE_GERROR(error);
137
+ } else {
138
+ filename_utf8 = filename;
139
+ }
140
+
141
+ /* create Ruby String in UTF-8 */
142
+ rb_filename = rb_external_str_new_with_enc(filename_utf8,
143
+ strlen(filename_utf8),
144
+ rb_utf8_encoding());
145
+ g_free(filename_utf8);
146
+
147
+ /* if needed, change encoding of Ruby String to filename encoding, so that
148
+ upcoming File operations will work properly */
149
+ if (filename_encoding_if_not_utf8 != NULL) {
150
+ return rb_str_export_to_enc(rb_filename, filename_encoding_if_not_utf8);
151
+ } else {
152
+ return rb_filename;
153
+ }
154
+
155
+ #else
156
+ return CSTR2RVAL_FREE(filename);
157
+ #endif
158
+ }
159
+
160
+ gchar *
161
+ rbg_filename_from_ruby(VALUE filename)
162
+ {
163
+ #ifdef HAVE_RUBY_ENCODING_H
164
+ GError *error = NULL;
165
+ gchar *retval;
166
+ gsize written;
167
+
168
+ /* if needed, change encoding of Ruby String to UTF-8 */
169
+ StringValue(filename);
170
+ if (rb_enc_get(filename) != rb_utf8_encoding()) {
171
+ filename = rb_str_export_to_enc(filename, rb_utf8_encoding());
172
+ }
173
+
174
+ /* convert it to filename encoding if needed */
175
+ if (filename_encoding_if_not_utf8 != NULL) {
176
+ retval = g_filename_from_utf8(RSTRING_PTR(filename), -1, NULL, &written, &error);
177
+ if (error != NULL)
178
+ RAISE_GERROR(error);
179
+ } else {
180
+ retval = RSTRING_PTR(filename);
181
+ }
182
+
183
+ return retval;
184
+
185
+ #else
186
+ return RVAL2CSTR(filename);
187
+ #endif
188
+ }
189
+
190
+ VALUE
191
+ rbg_filename_gslist_to_array_free(GSList *list)
192
+ {
193
+ GSList *l;
194
+ VALUE ary = rb_ary_new();
195
+ for (l = list; l != NULL; l = g_slist_next(l)) {
196
+ rb_ary_push(ary, rbg_filename_to_ruby_free(l->data));
197
+ }
198
+ g_slist_free(list);
199
+ return ary;
200
+ }
201
+
202
+
95
203
  #if 0
96
204
  /*
97
205
  2004-04-15 Commented out by Masao.
@@ -175,6 +283,10 @@ rbg_s_os_unix(self)
175
283
  void
176
284
  Init_glib2()
177
285
  {
286
+ #ifdef HAVE_RUBY_ENCODING_H
287
+ const gchar **filename_charsets;
288
+ #endif
289
+
178
290
  id_inspect = rb_intern("inspect");
179
291
 
180
292
  mGLib = rb_define_module("GLib");
@@ -254,6 +366,21 @@ Init_glib2()
254
366
  rb_define_const(mGLib, "DIR_SEPARATOR", CSTR2RVAL(G_DIR_SEPARATOR_S));
255
367
  rb_define_const(mGLib, "SEARCHPATH_SEPARATOR", CSTR2RVAL(G_SEARCHPATH_SEPARATOR_S));
256
368
 
369
+ /* discover and store glib filename encoding */
370
+ #ifdef HAVE_RUBY_ENCODING_H
371
+ if (g_get_filename_charsets(&filename_charsets)
372
+ || filename_charsets == NULL
373
+ || filename_charsets[0] == NULL
374
+ || !strcmp(filename_charsets[0], "UTF-8")
375
+ || rb_enc_find(filename_charsets[0]) == rb_enc_find("ASCII-8BIT")) {
376
+ /* set to NULL, mean do not perform transcoding, either filename
377
+ encoding is unknown, UTF-8, or unsupported */
378
+ filename_encoding_if_not_utf8 = NULL;
379
+ } else {
380
+ filename_encoding_if_not_utf8 = rb_enc_find(filename_charsets[0]);
381
+ }
382
+ #endif
383
+
257
384
  /* Don't implement them.
258
385
  #define G_DIR_SEPARATOR_S
259
386
  #define G_IS_DIR_SEPARATOR (c)
@@ -23,7 +23,7 @@ extern "C" {
23
23
 
24
24
  #define RBGLIB_MAJOR_VERSION 0
25
25
  #define RBGLIB_MINOR_VERSION 90
26
- #define RBGLIB_MICRO_VERSION 2
26
+ #define RBGLIB_MICRO_VERSION 3
27
27
 
28
28
  #ifndef RSTRING_PTR
29
29
  # define RSTRING_PTR(s) (RSTRING(s)->ptr)
@@ -45,13 +45,17 @@ typedef int GPid;
45
45
 
46
46
  #define RBG_INSPECT(object) (rbg_rval_inspect(object))
47
47
 
48
- #define RVAL2CSTR(v) (StringValuePtr(v))
49
- #define RVAL2CSTR_ACCEPT_NIL(v) (rbg_rval2cstr_accept_nil(v))
48
+ #define RVAL2CSTR(v) (rbg_rval2cstr(&v))
49
+ #define RVAL2CSTR_ACCEPT_NIL(v) (rbg_rval2cstr_accept_nil(&v))
50
50
  #define RVAL2CSTR2(v) (RVAL2CSTR_ACCEPT_NIL(v))
51
51
  #define CSTR2RVAL(s) (rbg_cstr2rval(s))
52
52
  #define CSTR2RVAL_FREE(s) (rbg_cstr2rval_with_free(s))
53
53
  #define CSTR2RVAL2(s) (CSTR2RVAL_FREE(s))
54
54
 
55
+ #define RVAL2CSTRFILENAME(v) (rbg_filename_from_ruby(v))
56
+ #define CSTRFILENAME2RVAL_FREE(s) (rbg_filename_to_ruby_free(s))
57
+ #define CSTRFILENAMEARRAY2RVAL_FREE(s) (rbg_filename_gslist_to_array_free(s))
58
+
55
59
  #define CBOOL2RVAL(b) ((b) ? Qtrue : Qfalse)
56
60
  #define RVAL2CBOOL(b) (RTEST(b))
57
61
  #define GERROR2RVAL(error) (rbgerr_gerror2exception(error))
@@ -76,10 +80,15 @@ RUBY_GLIB2_VAR VALUE mGLib;
76
80
  extern const gchar *rbg_rval_inspect(VALUE object);
77
81
 
78
82
  extern gchar* rbg_string_value_ptr(volatile VALUE* ptr); /* no longer used */
79
- extern gchar *rbg_rval2cstr_accept_nil(VALUE str);
83
+ extern gchar *rbg_rval2cstr(VALUE *str);
84
+ extern gchar *rbg_rval2cstr_accept_nil(VALUE *str);
80
85
  extern VALUE rbg_cstr2rval(const char* str);
81
86
  extern VALUE rbg_cstr2rval_with_free(gchar* str);
82
87
 
88
+ extern VALUE rbg_filename_to_ruby_free(gchar *filename);
89
+ extern gchar *rbg_filename_from_ruby(VALUE filename);
90
+ extern VALUE rbg_filename_gslist_to_array_free(GSList *list);
91
+
83
92
  /* rbgerror.h */
84
93
  extern VALUE rbgerr_gerror2exception(GError *error);
85
94
  extern VALUE rbgerr_define_gerror(GQuark domain, const gchar* name, VALUE module, VALUE parent, VALUE gtype);
@@ -56,7 +56,7 @@ bf_load_from_file(self, filename)
56
56
  {
57
57
  GError* error = NULL;
58
58
  gboolean ret = g_bookmark_file_load_from_file(_SELF(self),
59
- (const gchar*)RVAL2CSTR(filename),
59
+ RVAL2CSTRFILENAME(filename),
60
60
  &error);
61
61
  if (!ret) RAISE_GERROR(error);
62
62
  return self;
@@ -98,17 +98,12 @@ static VALUE
98
98
  bf_to_data(self)
99
99
  VALUE self;
100
100
  {
101
- VALUE ret;
102
- gsize len;
103
101
  GError* error = NULL;
104
- gchar* data = g_bookmark_file_to_data(_SELF(self), &len, &error);
102
+ gchar* data = g_bookmark_file_to_data(_SELF(self), NULL, &error);
105
103
 
106
104
  if (error) RAISE_GERROR(error);
107
105
 
108
- ret = rb_str_new(data, len);
109
- g_free(data);
110
-
111
- return ret;
106
+ return CSTR2RVAL_FREE(data);
112
107
  }
113
108
 
114
109
  static VALUE
@@ -117,7 +112,7 @@ bf_to_file(self, filename)
117
112
  {
118
113
  GError* error = NULL;
119
114
  gboolean ret = g_bookmark_file_to_file(_SELF(self),
120
- (const gchar *)RVAL2CSTR(filename),
115
+ RVAL2CSTRFILENAME(filename),
121
116
  &error);
122
117
  if (!ret) RAISE_GERROR(error);
123
118
  return self;
@@ -187,7 +182,7 @@ bf_get_title(self, uri)
187
182
  (const gchar *)RVAL2CSTR(uri),
188
183
  &error);
189
184
  if (error) RAISE_GERROR(error);
190
- return CSTR2RVAL2(ret);
185
+ return CSTR2RVAL_FREE(ret);
191
186
  }
192
187
 
193
188
  static VALUE
@@ -199,7 +194,7 @@ bf_get_description(self, uri)
199
194
  (const gchar *)RVAL2CSTR(uri),
200
195
  &error);
201
196
  if (error) RAISE_GERROR(error);
202
- return CSTR2RVAL2(ret);
197
+ return CSTR2RVAL_FREE(ret);
203
198
  }
204
199
 
205
200
  static VALUE
@@ -211,7 +206,7 @@ bf_get_mime_type(self, uri)
211
206
  (const gchar *)RVAL2CSTR(uri),
212
207
  &error);
213
208
  if (error) RAISE_GERROR(error);
214
- return CSTR2RVAL2(ret);
209
+ return CSTR2RVAL_FREE(ret);
215
210
  }
216
211
 
217
212
  static VALUE
@@ -241,7 +236,7 @@ bf_get_icon(self, uri)
241
236
  if (error) RAISE_GERROR(error);
242
237
  return Qnil;
243
238
  }
244
- return rb_assoc_new(CSTR2RVAL2(href), CSTR2RVAL2(mime_type));
239
+ return rb_assoc_new(CSTR2RVAL_FREE(href), CSTR2RVAL_FREE(mime_type));
245
240
  }
246
241
 
247
242
  static VALUE
@@ -192,13 +192,12 @@ static VALUE
192
192
  keyfile_to_data(self)
193
193
  VALUE self;
194
194
  {
195
- gsize length;
196
195
  GError* error = NULL;
197
- gchar* data = g_key_file_to_data(_SELF(self), &length, &error);
196
+ gchar* data = g_key_file_to_data(_SELF(self), NULL, &error);
198
197
 
199
198
  if (error) RAISE_GERROR(error);
200
199
 
201
- return rb_str_new(data, length);
200
+ return CSTR2RVAL_FREE(data);
202
201
  }
203
202
 
204
203
  static VALUE
@@ -284,7 +283,7 @@ keyfile_get_value(self, group_name, key)
284
283
 
285
284
  if (error) RAISE_GERROR(error);
286
285
 
287
- return ret ? CSTR2RVAL2(ret) : Qnil;
286
+ return CSTR2RVAL_FREE(ret);
288
287
  }
289
288
 
290
289
  static VALUE
@@ -299,7 +298,7 @@ keyfile_get_string(self, group_name, key)
299
298
 
300
299
  if (error) RAISE_GERROR(error);
301
300
 
302
- return ret ? CSTR2RVAL2(ret) : Qnil;
301
+ return CSTR2RVAL_FREE(ret);
303
302
  }
304
303
 
305
304
  static VALUE
@@ -322,7 +321,7 @@ keyfile_get_locale_string(argc, argv, self)
322
321
 
323
322
  if (error) RAISE_GERROR(error);
324
323
 
325
- return ret ? CSTR2RVAL2(ret) : Qnil;
324
+ return CSTR2RVAL_FREE(ret);
326
325
  }
327
326
 
328
327
  static VALUE
@@ -508,7 +507,7 @@ keyfile_get_comment(self, group_name, key)
508
507
 
509
508
  if (error) RAISE_GERROR(error);
510
509
 
511
- return CSTR2RVAL2(ret);
510
+ return CSTR2RVAL_FREE(ret);
512
511
  }
513
512
 
514
513
  static VALUE
@@ -37,7 +37,7 @@ static VALUE
37
37
  shell_quote(self, unquoted_string)
38
38
  VALUE self, unquoted_string;
39
39
  {
40
- return CSTR2RVAL2(g_shell_quote((const gchar*)RVAL2CSTR(unquoted_string)));
40
+ return CSTR2RVAL_FREE(g_shell_quote((const gchar*)RVAL2CSTR(unquoted_string)));
41
41
  }
42
42
 
43
43
  static VALUE
@@ -49,7 +49,7 @@ shell_unquote(self, quoted_string)
49
49
 
50
50
  if (! str) RAISE_GERROR(err);
51
51
 
52
- return CSTR2RVAL2(str);
52
+ return CSTR2RVAL_FREE(str);
53
53
  }
54
54
 
55
55
  void
@@ -241,7 +241,7 @@ rbglib_m_spawn_command_line_sync(self, str)
241
241
  VALUE std_out, std_err;
242
242
  gboolean ret;
243
243
 
244
- command_line = StringValuePtr(str);
244
+ command_line = RVAL2CSTR(str);
245
245
  ret = g_spawn_command_line_sync(command_line,
246
246
  &standard_output,
247
247
  &standard_error,
@@ -83,7 +83,7 @@ rbglib_m_listenv(self)
83
83
  c_list = g_listenv();
84
84
  c_var = c_list;
85
85
  while(*c_var) {
86
- rb_ary_push(r_list, rb_str_new2(*(c_var++)));
86
+ rb_ary_push(r_list, CSTR2RVAL(*(c_var++)));
87
87
  }
88
88
  g_strfreev(c_list);
89
89
  return r_list;
@@ -19,14 +19,14 @@ static VALUE
19
19
  rbglib_m_win32_error_message(self, error)
20
20
  VALUE self, error;
21
21
  {
22
- return CSTR2RVAL2(g_win32_error_message(NUM2INT(error)));
22
+ return CSTR2RVAL_FREE(g_win32_error_message(NUM2INT(error)));
23
23
  }
24
24
 
25
25
  static VALUE
26
26
  rbglib_m_win32_locale(self)
27
27
  VALUE self;
28
28
  {
29
- return CSTR2RVAL2(g_win32_getlocale());
29
+ return CSTR2RVAL_FREE(g_win32_getlocale());
30
30
  }
31
31
 
32
32
  static VALUE
@@ -41,7 +41,7 @@ static VALUE
41
41
  rbglib_m_win32_get_package_installation_directory(self, package, dll_name)
42
42
  VALUE self, package, dll_name;
43
43
  {
44
- return CSTR2RVAL2(g_win32_get_package_installation_directory(RVAL2CSTR(package),
44
+ return CSTR2RVAL_FREE(g_win32_get_package_installation_directory(RVAL2CSTR(package),
45
45
  RVAL2CSTR(dll_name)));
46
46
  }
47
47
 
@@ -49,7 +49,7 @@ static VALUE
49
49
  rbglib_m_get_package_installation_subdirectory(self, package, dll_name, subdir)
50
50
  VALUE self, package, dll_name, subdir;
51
51
  {
52
- return CSTR2RVAL2(g_win32_get_package_installation_subdirectory(RVAL2CSTR(package),
52
+ return CSTR2RVAL_FREE(g_win32_get_package_installation_subdirectory(RVAL2CSTR(package),
53
53
  RVAL2CSTR(dll_name),
54
54
  RVAL2CSTR(subdir)));
55
55
  }
@@ -68,7 +68,7 @@ static VALUE
68
68
  rbglib_m_win32_locale_filename_from_utf8(self, utf8_filename)
69
69
  VALUE self, utf8_filename;
70
70
  {
71
- return CSTR2RVAL2(g_win32_locale_filename_from_utf8(RVAL2CSTR(utf8_filename)));
71
+ return CSTR2RVAL_FREE(g_win32_locale_filename_from_utf8(RVAL2CSTR(utf8_filename)));
72
72
  }
73
73
 
74
74
  static VALUE
@@ -15,39 +15,40 @@
15
15
  #include "rbgprivate.h"
16
16
 
17
17
  #define DEF_NUMERIC_PSPEC_METHODS_FUNC(pspec_type, typename, from_ruby, to_ruby, pspec_cast) \
18
- static VALUE \
19
- typename##_initialize(self, name, nick, blurb, minimum, maximum, default_value, flags) \
20
- VALUE self, name, nick, blurb, minimum, maximum, default_value, flags; \
21
- { \
22
- GParamSpec* pspec; \
23
- pspec = g_param_spec_##typename(StringValuePtr(name), \
24
- StringValuePtr(nick), \
25
- StringValuePtr(blurb), \
26
- from_ruby(minimum), \
27
- from_ruby(maximum), \
28
- from_ruby(default_value), \
29
- NUM2UINT(flags)); \
30
- rbgobj_param_spec_initialize(self, pspec); \
31
- return Qnil; \
32
- } \
33
- \
34
- static \
35
- VALUE typename##_minimum(self) \
36
- { \
37
- return to_ruby(pspec_cast(RVAL2GOBJ(self))->minimum); \
38
- } \
39
- \
40
- static \
41
- VALUE typename##_maximum(self) \
42
- { \
43
- return to_ruby(pspec_cast(RVAL2GOBJ(self))->maximum); \
44
- } \
45
- \
46
- static \
47
- VALUE typename##_range(self) \
48
- { \
49
- pspec_type* pspec = pspec_cast(RVAL2GOBJ(self)); \
50
- return rb_range_new(pspec->minimum, pspec->maximum, 0); \
18
+ static VALUE \
19
+ typename##_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, \
20
+ VALUE minimum, VALUE maximum, VALUE default_value, \
21
+ VALUE flags) \
22
+ { \
23
+ GParamSpec* pspec; \
24
+ pspec = g_param_spec_##typename(StringValuePtr(name), \
25
+ StringValuePtr(nick), \
26
+ StringValuePtr(blurb), \
27
+ from_ruby(minimum), \
28
+ from_ruby(maximum), \
29
+ from_ruby(default_value), \
30
+ NUM2UINT(flags)); \
31
+ rbgobj_param_spec_initialize(self, pspec); \
32
+ return Qnil; \
33
+ } \
34
+ \
35
+ static VALUE \
36
+ typename##_minimum(VALUE self) \
37
+ { \
38
+ return to_ruby(pspec_cast(RVAL2GOBJ(self))->minimum); \
39
+ } \
40
+ \
41
+ static VALUE \
42
+ typename##_maximum(VALUE self) \
43
+ { \
44
+ return to_ruby(pspec_cast(RVAL2GOBJ(self))->maximum); \
45
+ } \
46
+ \
47
+ static VALUE \
48
+ typename##_range(VALUE self) \
49
+ { \
50
+ pspec_type* pspec = pspec_cast(RVAL2GOBJ(self)); \
51
+ return rb_range_new(pspec->minimum, pspec->maximum, 0); \
51
52
  }
52
53
 
53
54
  DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecChar, char, NUM2INT, INT2FIX, G_PARAM_SPEC_CHAR)
@@ -62,23 +63,21 @@ DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecFloat, float, NUM2DBL, rb_float_new, G_
62
63
  DEF_NUMERIC_PSPEC_METHODS_FUNC(GParamSpecDouble, double, NUM2DBL, rb_float_new, G_PARAM_SPEC_DOUBLE)
63
64
 
64
65
  static VALUE
65
- float_epsilon(self)
66
- VALUE self;
66
+ float_epsilon(VALUE self)
67
67
  {
68
68
  return rb_float_new(G_PARAM_SPEC_FLOAT(RVAL2GOBJ(self))->epsilon);
69
69
  }
70
70
 
71
71
  static VALUE
72
- double_epsilon(self)
73
- VALUE self;
72
+ double_epsilon(VALUE self)
74
73
  {
75
74
  return rb_float_new(G_PARAM_SPEC_DOUBLE(RVAL2GOBJ(self))->epsilon);
76
75
  }
77
76
 
78
77
 
79
78
  static VALUE
80
- boolean_initialize(self, name, nick, blurb, default_value, flags)
81
- VALUE self, name, nick, blurb, default_value, flags;
79
+ boolean_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
80
+ VALUE default_value, VALUE flags)
82
81
  {
83
82
  GParamSpec* pspec;
84
83
  pspec = g_param_spec_boolean(StringValuePtr(name),
@@ -91,8 +90,8 @@ boolean_initialize(self, name, nick, blurb, default_value, flags)
91
90
  }
92
91
 
93
92
  static VALUE
94
- unichar_initialize(self, name, nick, blurb, default_value, flags)
95
- VALUE self, name, nick, blurb, default_value, flags;
93
+ unichar_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
94
+ VALUE default_value, VALUE flags)
96
95
  {
97
96
  GParamSpec* pspec;
98
97
  pspec = g_param_spec_unichar(StringValuePtr(name),
@@ -105,8 +104,8 @@ unichar_initialize(self, name, nick, blurb, default_value, flags)
105
104
  }
106
105
 
107
106
  static VALUE
108
- enum_initialize(self, name, nick, blurb, enum_type, default_value, flags)
109
- VALUE self, name, nick, blurb, enum_type, default_value, flags;
107
+ enum_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
108
+ VALUE enum_type, VALUE default_value, VALUE flags)
110
109
  {
111
110
  GParamSpec* pspec;
112
111
  GType gtype = rbgobj_gtype_get(enum_type);
@@ -122,8 +121,8 @@ enum_initialize(self, name, nick, blurb, enum_type, default_value, flags)
122
121
  }
123
122
 
124
123
  static VALUE
125
- flags_initialize(self, name, nick, blurb, flags_type, default_value, flags)
126
- VALUE self, name, nick, blurb, flags_type, default_value, flags;
124
+ flags_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
125
+ VALUE flags_type, VALUE default_value, VALUE flags)
127
126
  {
128
127
  GParamSpec* pspec;
129
128
  GType gtype = rbgobj_gtype_get(flags_type);
@@ -139,8 +138,8 @@ flags_initialize(self, name, nick, blurb, flags_type, default_value, flags)
139
138
  }
140
139
 
141
140
  static VALUE
142
- string_initialize(self, name, nick, blurb, default_value, flags)
143
- VALUE self, name, nick, blurb, default_value, flags;
141
+ string_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
142
+ VALUE default_value, VALUE flags)
144
143
  {
145
144
  GParamSpec* pspec;
146
145
  pspec = g_param_spec_string(StringValuePtr(name),
@@ -153,8 +152,8 @@ string_initialize(self, name, nick, blurb, default_value, flags)
153
152
  }
154
153
 
155
154
  static VALUE
156
- param_initialize(self, name, nick, blurb, param_type, flags)
157
- VALUE self, name, nick, blurb, param_type, flags;
155
+ param_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
156
+ VALUE param_type, VALUE flags)
158
157
  {
159
158
  GParamSpec* pspec;
160
159
  pspec = g_param_spec_param(StringValuePtr(name),
@@ -167,8 +166,8 @@ param_initialize(self, name, nick, blurb, param_type, flags)
167
166
  }
168
167
 
169
168
  static VALUE
170
- boxed_initialize(self, name, nick, blurb, boxed_type, flags)
171
- VALUE self, name, nick, blurb, boxed_type, flags;
169
+ boxed_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
170
+ VALUE boxed_type, VALUE flags)
172
171
  {
173
172
  GParamSpec* pspec;
174
173
  pspec = g_param_spec_boxed(StringValuePtr(name),
@@ -181,8 +180,7 @@ boxed_initialize(self, name, nick, blurb, boxed_type, flags)
181
180
  }
182
181
 
183
182
  static VALUE
184
- pointer_initialize(self, name, nick, blurb, flags)
185
- VALUE self, name, nick, blurb, flags;
183
+ pointer_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, VALUE flags)
186
184
  {
187
185
  GParamSpec* pspec;
188
186
  pspec = g_param_spec_pointer(StringValuePtr(name),
@@ -194,8 +192,8 @@ pointer_initialize(self, name, nick, blurb, flags)
194
192
  }
195
193
 
196
194
  static VALUE
197
- value_array_initialize(self, name, nick, blurb, element_spec, flags)
198
- VALUE self, name, nick, blurb, element_spec, flags;
195
+ value_array_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
196
+ VALUE element_spec, VALUE flags)
199
197
  {
200
198
  GParamSpec* pspec;
201
199
  pspec = g_param_spec_value_array(StringValuePtr(name),
@@ -208,8 +206,8 @@ value_array_initialize(self, name, nick, blurb, element_spec, flags)
208
206
  }
209
207
 
210
208
  static VALUE
211
- object_initialize(self, name, nick, blurb, object_type, flags)
212
- VALUE self, name, nick, blurb, object_type, flags;
209
+ object_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
210
+ VALUE object_type, VALUE flags)
213
211
  {
214
212
  GParamSpec* pspec;
215
213
  pspec = g_param_spec_object(StringValuePtr(name),
@@ -222,7 +220,7 @@ object_initialize(self, name, nick, blurb, object_type, flags)
222
220
  }
223
221
 
224
222
  void
225
- Init_gobject_gparamspecs()
223
+ Init_gobject_gparamspecs(void)
226
224
  {
227
225
  VALUE cParamSpec = GTYPE2CLASS(G_TYPE_PARAM);
228
226
  VALUE c;
@@ -72,10 +72,7 @@ rbgobj_gvalue_to_rvalue(const GValue* value)
72
72
  case G_TYPE_DOUBLE:
73
73
  return rb_float_new(g_value_get_double(value));
74
74
  case G_TYPE_STRING:
75
- {
76
- const char* str = g_value_get_string(value);
77
- return str ? rb_str_new2(str) : Qnil;
78
- }
75
+ return CSTR2RVAL(g_value_get_string(value));
79
76
  case G_TYPE_ENUM:
80
77
  return rbgobj_make_enum(g_value_get_enum(value), type);
81
78
  case G_TYPE_FLAGS:
@@ -249,7 +246,7 @@ rbgobj_rvalue_to_gvalue(VALUE val, GValue* result)
249
246
  {
250
247
  if (SYMBOL_P(val))
251
248
  val = rb_funcall(val, id_to_s, 0);
252
- g_value_set_string(result, NIL_P(val) ? NULL : StringValuePtr(val));
249
+ g_value_set_string(result, RVAL2CSTR_ACCEPT_NIL(val));
253
250
  return;
254
251
  }
255
252
  case G_TYPE_OBJECT:
@@ -298,7 +298,7 @@ rbgutil_generic_gtype(VALUE self)
298
298
  VALUE
299
299
  rbgutil_string_set_utf8_encoding(VALUE string)
300
300
  {
301
- #ifdef HAVE_RB_STR_ENCODE
301
+ #ifdef HAVE_RUBY_ENCODING_H
302
302
  if (!NIL_P(string))
303
303
  rb_enc_associate(string, rb_utf8_encoding());
304
304
  #endif
@@ -90,6 +90,7 @@ def add_depend_package(target_name, target_srcdir, top_srcdir, options={})
90
90
  unless File.exist?(target_build_dir_full_path)
91
91
  target_build_dir_full_path = File.join(topdir, target_srcdir)
92
92
  end
93
+ next unless File.exist?(target_build_dir_full_path)
93
94
  $INCFLAGS = "-I#{target_build_dir_full_path} #{$INCFLAGS}"
94
95
 
95
96
  if /cygwin|mingw/ =~ RUBY_PLATFORM
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 371
4
+ hash: 369
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 90
9
- - 2
10
- version: 0.90.2
9
+ - 3
10
+ version: 0.90.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - The Ruby-GNOME2 Proejct Team
@@ -15,10 +15,23 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-27 00:00:00 +09:00
18
+ date: 2010-10-23 00:00:00 +09:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: pkg-config
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
22
35
  description: Ruby/GLib2 is a Ruby binding of GLib-2.x.
23
36
  email: ruby-gnome2-devel-en@lists.sourceforge.net
24
37
  executables: []