rubysdl 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/doc/general.rsd CHANGED
@@ -50,6 +50,18 @@ Ruby/SDL
50
50
  * ����¾�ˤ⡢((<Window�δ���|Window Management>))��
51
51
  ((<����Ƚ��>))�ʤ�
52
52
 
53
+ = Ruby 1.9��m17n�ˤĤ���
54
+ Ruby 1.9�Ǥϡ�String�˥��󥳡��ǥ��󥰾����դ���
55
+ ���ޤ�����Ruby/SDL�Ǥϴ���Ū�ˤ��ξ����̵�뤷�ޤ���
56
+ SDL�Ǥ��Τ褦�ʾ����ɤ����٤����������Ƥ��ʤ�����Ǥ���
57
+
58
+ �����������Ĥ��Υ᥽�åɤǤ�Ruby 1.9�ˤ����Ƥ�
59
+ ���󥳡��ǥ�������Ѥ�����ղä�Ԥ��ޤ���
60
+ �ܤ����ϳƥ᥽�åɤι�򸫤Ƥ���������
61
+
62
+ extconf.rb��¹Ԥ���Ȥ���--enable-m17n/--disable-m17n
63
+ ���ץ�����Ȥ����Ȥǡ�������Ruby/SDL��
64
+ m17n��Ϣ�ε�ǽ��ͭ��/̵���ˤǤ��ޤ���
53
65
 
54
66
  == SDL::Error
55
67
  SDL��ͭ�Υ��顼��ɽ�魯�㳰���饹�Ǥ���StandardError��Ѿ����Ƥ��ޤ���
data/doc/mixer.rsd CHANGED
@@ -226,6 +226,39 @@ OGG
226
226
 
227
227
  EXCEPTION *
228
228
 
229
+ %%
230
+ NAME destroy
231
+ MOD Mixer::Wave
232
+ TYPE #
233
+ PURPOSE �����ǥ����ǡ�����������ޤ�
234
+
235
+ PROTO
236
+ destroy
237
+
238
+ DESC
239
+ �����ǥ����ǡ��������Ƥ����꥽������������ޤ���
240
+ ������ϰ��ڤ����Ǥ��ʤ��ʤ�ޤ���
241
+
242
+ SEEALSO
243
+ Mixer::Wave#destroyed?
244
+
245
+ %%
246
+ NAME destroyed?
247
+ MOD Mixer::Wave
248
+ TYPE #
249
+ PURPOSE �����ǥ����ǡ���������������ɤ������֤��ޤ���
250
+ RVAL true/false
251
+
252
+ PROTO
253
+ destroyed?
254
+
255
+ DESC
256
+ @[Mixer::Wave#destroy]�ˤ�ä�
257
+ �����ǥ����ǡ���������������ɤ����򿿵��ͤ��֤��ޤ���
258
+
259
+ SEEALSO
260
+ Mixer::Wave#destroy
261
+
229
262
  %%
230
263
  NAME load
231
264
  MOD Mixer::Music
@@ -269,6 +302,41 @@ Windows
269
302
 
270
303
  EXCEPTION *
271
304
 
305
+ %%
306
+ NAME destroy
307
+ MOD Mixer::Music
308
+ TYPE #
309
+ PURPOSE ���ڥǡ�����������ޤ�
310
+
311
+ PROTO
312
+ destroy
313
+
314
+ DESC
315
+ ���ڥǡ��������Ƥ����꥽������������ޤ���
316
+ ������ϰ��ڤ����Ǥ��ʤ��ʤ�ޤ���
317
+
318
+ SEEALSO
319
+ Mixer::Music#destroyed?
320
+ Mixer::Wave#destroy
321
+
322
+ %%
323
+ NAME destroyed?
324
+ MOD Mixer::Music
325
+ TYPE #
326
+ PURPOSE ���ڥǡ���������������ɤ������֤��ޤ���
327
+ RVAL true/false
328
+
329
+ PROTO
330
+ destroyed?
331
+
332
+ DESC
333
+ @[Mixer::Music#destroy]�ˤ�ä�
334
+ ���ڥǡ���������������ɤ����򿿵��ͤ��֤��ޤ���
335
+
336
+ SEEALSO
337
+ Mixer::Music#destroy
338
+ Mixer::Wave#destroyed?
339
+
272
340
  %%
273
341
  NAME set_volume
274
342
  MOD Mixer::Wave
data/doc/mpeg.rsd CHANGED
@@ -591,5 +591,29 @@ total_time
591
591
  DESC
592
592
  not documented yet
593
593
 
594
+ %%
595
+ NAME delete
596
+ MDO MPEG
597
+ TYPE #
598
+ DEP SMPEG
599
+ PURPOSE
600
+
601
+ PROTO
602
+ delete
603
+
604
+ DESC
605
+ not documented yet
594
606
 
607
+ %%
608
+ NAME deleted?
609
+ MDO MPEG
610
+ TYPE #
611
+ DEP SMPEG
612
+ PURPOSE
613
+
614
+ PROTO
615
+ deleted?
616
+
617
+ DESC
618
+ not documented yet
595
619
 
data/doc/sdlskk.rsd CHANGED
@@ -387,6 +387,10 @@ str
387
387
  DESC
388
388
  ���������ʸ������֤��ޤ���
389
389
 
390
+ NOTE
391
+ Ruby 1.9�Ǥ�Ruby/SDL��m17n��ǽ��ͭ���ˤ��Ƥ���¤ꡢ
392
+ �֤��ͤ�ʸ�����Ŭ�ڤʥ��󥳡��ǥ��󥰤��ղä��ޤ���
393
+
390
394
  SEEALSO
391
395
  SKK::Context#render_str
392
396
  SKK::Context#clear
@@ -461,7 +465,7 @@ JISX0208
461
465
 
462
466
  ʣ���Ԥ����Ϥ�¸���������硢@[SKK::Context] ��Ƥ֤�
463
467
  �⡼�ɤ��������ϥ⡼�ɤ���äƤ��ޤ��Τ��Լ����Ǥ����硢
464
- ���δؿ���Ƥ֤Ȥ褤��
468
+ ���δؿ���Ƥ֤Ȥ褤�Ǥ��礦��
465
469
 
466
470
  �ޤ������åȥХåե������Ƥ���¸����ޤ���
467
471
 
data/doc/video.rsd CHANGED
@@ -1277,6 +1277,41 @@ EXCEPTION *
1277
1277
  SEEALSO
1278
1278
  Surface.load_bmp
1279
1279
 
1280
+ %%
1281
+ NAME destroy
1282
+ MOD Surface
1283
+ TYPE #
1284
+ PURPOSE �����ե�����������ޤ���
1285
+
1286
+ PROTO
1287
+ destroy
1288
+
1289
+ DESC
1290
+ ����Surface�����Ƥ���꥽������������ޤ�������������ˤ�
1291
+ ���Υ��֥������Ȥ��Ф������ϰ����Բ�ǽ�ˤʤ�ޤ���
1292
+
1293
+ SEEALSO
1294
+ Surface.new
1295
+ Surface.new_from
1296
+ Surface#destroyed?
1297
+
1298
+ %%
1299
+ NAME destroyed?
1300
+ MOD Surface
1301
+ TYPE #
1302
+ PURPOSE �����ե�������������Ƥ��뤫�ɤ������֤��ޤ���
1303
+ RVAL true/false
1304
+
1305
+ PROTO
1306
+ destroyed?
1307
+
1308
+ DESC
1309
+ ���Υ����ե����� @[Surface#destroy] �ˤ�äƲ�������Ƥ��뤫
1310
+ �ɤ����򿿵��ͤ��֤��ޤ���
1311
+
1312
+ SEEALSO
1313
+ Surface#destroy
1314
+
1280
1315
  %%
1281
1316
  NAME set_color_key
1282
1317
  MOD Surface
data/doc/wm.rsd CHANGED
@@ -24,6 +24,9 @@ caption
24
24
  DESC
25
25
  ������ɥ��Υ����ȥ�ȥ�������̾��ʸ����2�Ĥ�������֤��ޤ���
26
26
 
27
+ NOTES
28
+ �֤��ͤΥ��󥳡��ǥ��󥰤�UTF8�Ǥ���
29
+
27
30
  SEEALSO
28
31
  WM.set_caption
29
32
 
@@ -40,6 +43,13 @@ setCaption(title, icon)
40
43
  DESC
41
44
  ɽ��������ɥ��Υ����ȥ�С��ȥ�������̾�򥻥åȤ��ޤ���
42
45
 
46
+ NOTES
47
+ Ruby 1.8�Ǥ�ʸ����Ȥ���UTF8��Ϳ���뤳�Ȥǥޥ���Х���ʸ����
48
+ ���ѤǤ���Ķ��⤢��ޤ���
49
+
50
+ Ruby 1.9�Ǥ�Ruby/SDL��m17n��ǽ��ͭ���ˤ��Ƥ���¤�
51
+ Ruby��m17n�ε�ǽ���Ѥ�UTF8�ؤ��Ѵ���ưŪ�˹Ԥ��ޤ���
52
+
43
53
  SEEALSO
44
54
  WM.caption
45
55
  WM.icon=
data/extconf.rb CHANGED
@@ -65,6 +65,15 @@ have_func("TTF_FontFaceIsFixedWidth")
65
65
  have_func("TTF_FontFaceFamilyName")
66
66
  have_func("TTF_FontFaceStyleName")
67
67
  have_func("Mix_LoadMUS_RW")
68
+ have_func("rb_thread_blocking_region")
69
+ if enable_config("m17n", true)
70
+ if have_func("rb_enc_str_new") && have_func("rb_str_export_to_enc")
71
+ $CFLAGS += " -D ENABLE_M17N "
72
+ if enable_config("m17n-filesystem", false)
73
+ $CFLAGS += " -D ENABLE_M17N_FILESYSTEM "
74
+ end
75
+ end
76
+ end
68
77
 
69
78
  if have_library("SDLSKK","SDLSKK_Context_new") then
70
79
  $CFLAGS+= " -D HAVE_SDLSKK "
@@ -106,6 +106,7 @@ module SDL
106
106
  if defined?(Kanji) then
107
107
  class Kanji
108
108
  alias set_coding_system setCodingSystem
109
+ alias get_coding_system getCodingSystem
109
110
  alias put_tate putTate
110
111
  end
111
112
  end
@@ -243,6 +244,14 @@ module SDL
243
244
  alias render_solid_utf8 renderSolidUTF8
244
245
  alias render_blended_utf8 renderBlendedUTF8
245
246
  alias render_shaded_utf8 renderShadedUTF8
247
+ if method_defined?(:drawSolid)
248
+ alias draw_solid drawSolid
249
+ alias draw_blended drawBlended
250
+ alias draw_shaded drawShaded
251
+ alias render_solid renderSolid
252
+ alias render_blended renderBlended
253
+ alias render_shaded renderShaded
254
+ end
246
255
  end
247
256
  end
248
257
  end
data/lib/sdl.rb CHANGED
@@ -18,7 +18,7 @@ require 'sdl.so'
18
18
  require 'forwardable'
19
19
 
20
20
  module SDL
21
- VERSION = "2.0 alpha1"
21
+ VERSION = "2.1.0"
22
22
 
23
23
  class Surface
24
24
  def put(surface,x,y)
@@ -175,40 +175,27 @@ module SDL
175
175
  end
176
176
 
177
177
  if defined?(MPEG)
178
- class MPEG
179
- alias info_imp info
180
- private :info_imp
181
- def info(*arg)
182
- case arg.size
183
- when 0
184
- result = SDL::MPEG::Info.new
185
- info_imp(result)
186
- result
187
- when 1
188
- info_imp(arg[0])
189
- arg[0]
190
- end
191
- end
192
- end
193
178
  end
194
179
  if defined?(TTF)
195
180
  class TTF
196
- def drawSolidUTF8(dst, text, x, y, r, g, b)
197
- image = renderSolidUTF8(text, r, g, b)
198
- dst.put(image, x, y)
199
- image.destroy
200
- end
201
-
202
- def drawBlendedUTF8(dst, text, x, y, r, g, b)
203
- image = renderBlendedUTF8(text, r, g, b)
204
- dst.put(image, x, y)
205
- image.destroy
206
- end
207
-
208
- def drawShadedUTF8(dst, text, fg_r, fg_g, fg_b, bg_r, bg_g, bg_b)
209
- image = renderSolidUTF8(text, fg_r, fg_g, fg_b, bg_r, bg_g, bg_b)
210
- dst.put(image, x, y)
211
- image.destroy
181
+ define_draw = proc{|t, n|
182
+ args = (1..n).map{|k| "arg#{k}"}.join(",")
183
+ module_eval(<<-EOS)
184
+ def draw#{t}(dst, text, x, y, #{args})
185
+ image = render#{t}(text, #{args})
186
+ dst.put(image, x, y)
187
+ image.destroy
188
+ end
189
+ EOS
190
+ }
191
+
192
+ define_draw["SolidUTF8", 3]
193
+ define_draw["BlendedUTF8", 3]
194
+ define_draw["ShadedUTF8",6]
195
+ if method_defined?(:drawSolid)
196
+ define_draw["Solid",3]
197
+ define_draw["Blended", 3]
198
+ define_draw["Shaded", 6]
212
199
  end
213
200
  end
214
201
  end
data/rubysdl.h CHANGED
@@ -46,14 +46,47 @@ do{ \
46
46
  Rect.h=NUM2INT(H); \
47
47
  }while(0) \
48
48
 
49
+ #ifdef ENABLE_M17N
50
+ #define ExportStringValueToEnc(v,enc) \
51
+ do { \
52
+ SafeStringValue(v); \
53
+ (v) = rb_str_export_to_enc((v),(enc)); \
54
+ } while (0)
55
+ #else
56
+ #define ExportStringValueToEnc(v,enc) \
57
+ SafeStringValue(v)
58
+ #endif
59
+
60
+ #ifdef ENABLE_M17N_FILESYSTEM
61
+ #define ExportFilenameStringValue(v) \
62
+ ExportStringValueToEnc(v,rb_filesystem_encoding())
63
+ #else
64
+ #define ExportFilenameStringValue(v) \
65
+ SafeStringValue(v)
66
+ #endif
67
+
49
68
  #define INT2BOOL(x) ((x)?Qtrue:Qfalse)
50
69
 
51
- /* Global variables */
52
- #define eSDLError rubysdl_eSDLError
53
70
  #ifdef DEF_GLOBAL
54
- VALUE eSDLError;
71
+ #define GLOBAL(typ, var, val) typ var = val
55
72
  #else
56
- extern VALUE eSDLError;
73
+ #define GLOBAL(typ, var, val) extern typ var
74
+ #endif
75
+ /* Global variables */
76
+ #define eSDLError rubysdl_eSDLError
77
+ GLOBAL(VALUE, eSDLError, Qnil);
78
+
79
+ #ifdef ENABLE_M17N
80
+ #define ENC_STR_NEW2(str, enc) rb_enc_str_new((str), strlen((str)), (enc))
81
+ #include "ruby/encoding.h"
82
+ #define utf8_enc rubysdl_utf8_enc
83
+ #define eucjp_enc rubysdl_eucjp_enc
84
+ #define iso2022jp_enc rubysdl_iso2022jp_enc
85
+ #define sjis_enc rubysdl_sjis_enc
86
+ GLOBAL(rb_encoding*, utf8_enc, NULL);
87
+ GLOBAL(rb_encoding*, eucjp_enc, NULL);
88
+ GLOBAL(rb_encoding*, iso2022jp_enc, NULL);
89
+ GLOBAL(rb_encoding*, sjis_enc, NULL);
57
90
  #endif
58
91
 
59
92
  /* Global functions */
data/rubysdl_cdrom.c CHANGED
@@ -159,6 +159,18 @@ static VALUE CD_s_MSFToFrames(VALUE klass, VALUE m, VALUE s, VALUE f)
159
159
  {
160
160
  return INT2FIX(MSF_TO_FRAMES(NUM2INT(m),NUM2INT(s),NUM2INT(f)));
161
161
  }
162
+ static VALUE CD_close(VALUE self)
163
+ {
164
+ CD* cd = GetCD(self);
165
+ if( !rubysdl_is_quit() && cd->cd )
166
+ SDL_CDClose(cd->cd);
167
+ cd->cd = NULL;
168
+ return Qnil;
169
+ }
170
+ static VALUE CD_closed(VALUE self)
171
+ {
172
+ return INT2BOOL(GetCD(self)->cd == NULL);
173
+ }
162
174
 
163
175
  void rubysdl_init_CD(VALUE mSDL)
164
176
  {
@@ -185,7 +197,8 @@ void rubysdl_init_CD(VALUE mSDL)
185
197
  rb_define_method(cCD, "currentFrame", CD_currentFrame, 0);
186
198
  rb_define_method(cCD, "trackType", CD_trackType, 1);
187
199
  rb_define_method(cCD, "trackLength", CD_trackLength, 1);
188
-
200
+ rb_define_method(cCD, "close", CD_close, 0);
201
+ rb_define_method(cCD, "closed?", CD_closed, 0);
189
202
 
190
203
  rb_define_const(cCD, "TRAYEMPTY", INT2NUM(CD_TRAYEMPTY));
191
204
  rb_define_const(cCD, "STOPPED", INT2NUM(CD_STOPPED));
data/rubysdl_event.c CHANGED
@@ -182,11 +182,25 @@ static VALUE Event_s_poll(VALUE class)
182
182
  else
183
183
  return Qnil;
184
184
  }
185
+ #ifdef HAVE_RB_THREAD_BLOCKING_REGION
186
+ static VALUE wait(void* ev)
187
+ {
188
+ return SDL_WaitEvent((SDL_Event*)ev);
189
+ }
190
+ #endif
185
191
  static VALUE Event_s_wait(VALUE class)
186
192
  {
187
193
  SDL_Event event;
188
194
  rb_secure(4);
195
+ #ifdef HAVE_RB_THREAD_BLOCKING_REGION
196
+ /* Ruby 1.9 and above: Release the global VM lock while calling
197
+ * SDL_WaitEvent, allowing other Ruby threads to execute. */
198
+ if( rb_thread_blocking_region(wait, &event, RUBY_UBF_IO, NULL) == 1)
199
+ #else
200
+ /* Ruby 1.8 and below: Call SDL_WaitEvent directly.
201
+ * No other threads can execute during this call. */
189
202
  if( SDL_WaitEvent(&event) == 1)
203
+ #endif
190
204
  return event_creators[event.type](&event);
191
205
  else
192
206
  rb_raise(eSDLError, "Event handling error");
data/rubysdl_image.c CHANGED
@@ -26,7 +26,7 @@ static VALUE Surface_s_load(VALUE klass, VALUE filename)
26
26
  SDL_Surface *surface;
27
27
 
28
28
  rb_secure(4);
29
- SafeStringValue(filename);
29
+ ExportFilenameStringValue(filename);
30
30
 
31
31
  surface = IMG_Load(RSTRING_PTR(filename));
32
32
  if(surface == NULL)