rubysdl 1.3.1 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/MANIFEST +22 -2
  2. data/NEWS.en +80 -0
  3. data/NEWS.ja +83 -0
  4. data/README.en +2 -1
  5. data/README.ja +2 -2
  6. data/doc-en/Makefile +18 -0
  7. data/doc-en/cdrom.rsd +417 -0
  8. data/doc-en/collision.rsd +174 -0
  9. data/doc-en/event.rsd +1476 -0
  10. data/doc-en/font.rsd +811 -0
  11. data/doc-en/general.rsd +43 -0
  12. data/doc-en/init.rsd +168 -0
  13. data/doc-en/joystick.rsd +401 -0
  14. data/doc-en/mixer.rsd +869 -0
  15. data/doc-en/mpeg.rsd +585 -0
  16. data/doc-en/opengl.rsd +155 -0
  17. data/doc-en/sdlskk.rsd +472 -0
  18. data/doc-en/time.rsd +46 -0
  19. data/doc-en/video.rsd +2806 -0
  20. data/doc-en/wm.rsd +112 -0
  21. data/doc/Makefile +1 -1
  22. data/doc/cdrom.rsd +3 -3
  23. data/doc/event.rsd +178 -179
  24. data/doc/general.rsd +10 -0
  25. data/doc/init.rsd +2 -2
  26. data/doc/joystick.rsd +29 -5
  27. data/doc/mixer.rsd +20 -0
  28. data/doc/rsd.rb +42 -9
  29. data/doc/sdlskk.rsd +7 -7
  30. data/doc/video.rsd +461 -168
  31. data/doc/wm.rsd +2 -2
  32. data/extconf.rb +1 -8
  33. data/lib/rubysdl_aliases.rb +52 -190
  34. data/lib/rubysdl_compatible_ver1.rb +243 -0
  35. data/lib/sdl.rb +58 -92
  36. data/rubysdl.h +59 -68
  37. data/rubysdl_cdrom.c +125 -102
  38. data/{rubysdl_doc.en.rd → rubysdl_doc_old.en.rd} +3 -2
  39. data/rubysdl_event.c +318 -255
  40. data/rubysdl_event_key.c +299 -287
  41. data/rubysdl_image.c +37 -13
  42. data/rubysdl_joystick.c +180 -67
  43. data/rubysdl_kanji.c +61 -75
  44. data/rubysdl_main.c +65 -138
  45. data/rubysdl_mixer.c +339 -214
  46. data/rubysdl_mouse.c +50 -43
  47. data/rubysdl_opengl.c +31 -28
  48. data/rubysdl_pixel.c +17 -28
  49. data/rubysdl_ref.en.html +5658 -0
  50. data/rubysdl_ref.en.rd +6337 -0
  51. data/rubysdl_ref.html +2253 -1964
  52. data/rubysdl_ref.rd +823 -469
  53. data/rubysdl_rwops.c +9 -6
  54. data/rubysdl_sdlskk.c +137 -165
  55. data/rubysdl_sge_video.c +355 -469
  56. data/rubysdl_smpeg.c +189 -190
  57. data/rubysdl_time.c +1 -1
  58. data/rubysdl_ttf.c +147 -215
  59. data/rubysdl_video.c +486 -405
  60. data/rubysdl_wm.c +30 -30
  61. data/sample/aadraw.rb +9 -9
  62. data/sample/alpha.rb +12 -13
  63. data/sample/alphadraw.rb +10 -10
  64. data/sample/bfont.rb +4 -4
  65. data/sample/cdrom.rb +11 -4
  66. data/sample/collision.rb +20 -20
  67. data/sample/cursor.rb +5 -5
  68. data/sample/ellipses.rb +20 -16
  69. data/sample/event2.rb +11 -9
  70. data/sample/font.rb +4 -4
  71. data/sample/fpstimer.rb +3 -3
  72. data/sample/icon.bmp.gz +0 -0
  73. data/sample/icon.png +0 -0
  74. data/sample/joy2.rb +14 -14
  75. data/sample/kanji.rb +7 -7
  76. data/sample/load_from_io.rb +44 -0
  77. data/sample/movesp.rb +13 -12
  78. data/sample/playmod.rb +2 -3
  79. data/sample/plaympeg.rb +8 -8
  80. data/sample/playwave.rb +5 -6
  81. data/sample/sdlskk.rb +11 -11
  82. data/sample/sgetest.rb +14 -12
  83. data/sample/stetris.rb +12 -13
  84. data/sample/testgl.rb +13 -14
  85. data/sample/testsprite.rb +12 -11
  86. data/sample/transformblit.rb +23 -22
  87. metadata +62 -35
  88. data/rubysdl_event2.c +0 -417
data/rubysdl_rwops.c CHANGED
@@ -26,8 +26,8 @@ static int rubyio_read(SDL_RWops* context, void* ptr, int size, int maxnum)
26
26
  str = rb_funcall(io, rb_intern("read"), 1, INT2NUM(size*maxnum));
27
27
  StringValue(str);
28
28
 
29
- memcpy(ptr, RSTRING(str)->ptr, RSTRING(str)->len);
30
- return RSTRING(str)->len/size;
29
+ memcpy(ptr, RSTRING_PTR(str), RSTRING_LEN(str));
30
+ return RSTRING_LEN(str)/size;
31
31
  }
32
32
 
33
33
  static int rubyio_write(SDL_RWops* context, const void* ptr, int size, int num)
@@ -39,9 +39,6 @@ static int rubyio_pseudo_seek(SDL_RWops* context, int offset, int whence)
39
39
  {
40
40
  volatile VALUE io = (VALUE)context->hidden.unknown.data1;
41
41
  volatile VALUE str;
42
- if(offset < 0)
43
- rb_raise(eSDLError, "cannot seek backward");
44
-
45
42
 
46
43
  switch(whence){
47
44
  case SEEK_SET:
@@ -49,7 +46,13 @@ static int rubyio_pseudo_seek(SDL_RWops* context, int offset, int whence)
49
46
  rb_funcall(io, rb_intern("read"), 1, INT2NUM(offset));
50
47
  break;
51
48
  case SEEK_CUR:
52
- str = rb_funcall(io, rb_intern("read"), 1, INT2NUM(offset));
49
+ if (offset >= 0) {
50
+ str = rb_funcall(io, rb_intern("read"), 1, INT2NUM(offset));
51
+ } else {
52
+ int d = NUM2INT(rb_funcall(io, rb_intern("tell"), 0)) + offset;
53
+ rb_funcall(io, rb_intern("rewind"), 0);
54
+ rb_funcall(io, rb_intern("read"), 1, INT2NUM(d));
55
+ }
53
56
  break;
54
57
  case SEEK_END:
55
58
  rb_raise(eSDLError, "cannot seek SEEK_END");
data/rubysdl_sdlskk.c CHANGED
@@ -22,6 +22,19 @@
22
22
  #include <sdlskk.h>
23
23
  #include <SDL_ttf.h>
24
24
 
25
+ static VALUE cEvent = Qnil;
26
+ static VALUE cKeyDownEvent = Qnil;
27
+
28
+ static VALUE cContext = Qnil;
29
+ static VALUE cDictionary = Qnil;
30
+ static VALUE cRomKanaRuleTable = Qnil;
31
+ static VALUE cKeybind = Qnil;
32
+
33
+ DEFINE_GET_STRUCT(SDLSKK_Context, Get_SDLSKK_Context, cContext, "SDL::SKK::Context");
34
+ DEFINE_GET_STRUCT(SDLSKK_Dictionary, Get_SDLSKK_Dictionary, cDictionary, "SDL::SKK::Dictionary");
35
+ DEFINE_GET_STRUCT(SDLSKK_RomKanaRuleTable, Get_SDLSKK_RomKanaRuleTable, cRomKanaRuleTable, "SDL::SKK::RomKanaRuleTable");
36
+ DEFINE_GET_STRUCT(SDLSKK_Keybind, Get_SDLSKK_Keybind, cKeybind, "SDL::SKK::Keybind");
37
+
25
38
  typedef SDL_Surface* (*Renderer)(SDLSKK_Context*,TTF_Font*,SDL_Color);
26
39
 
27
40
  static void skk_error_handler(SDLSKK_Error err)
@@ -34,279 +47,238 @@ static void skk_error_handler(SDLSKK_Error err)
34
47
  }
35
48
  }
36
49
 
37
- static VALUE skk_set_encoding(VALUE mod,VALUE encoding)
50
+ static VALUE SKK_set_encoding(VALUE mod, VALUE encoding)
38
51
  {
39
- SDLSKK_set_encoding( NUM2INT(encoding) );
52
+ SDLSKK_set_encoding(NUM2INT(encoding));
40
53
  return Qnil;
41
54
  }
42
55
 
43
- static VALUE skk_get_encoding(VALUE mod)
56
+ static VALUE SKK_get_encoding(VALUE mod)
44
57
  {
45
58
  return INT2FIX(SDLSKK_get_encoding());
46
59
  }
47
60
 
48
-
49
- static VALUE skk_Context_new(VALUE class,VALUE dict,VALUE rule_table,
50
- VALUE keybind, VALUE use_minibuffer )
61
+ static VALUE Context_s_new(VALUE klass, VALUE dict, VALUE rule_table,
62
+ VALUE keybind, VALUE use_minibuffer)
51
63
  {
52
64
  SDLSKK_Context* c_context;
53
- SDLSKK_RomKanaRuleTable* c_table;
54
- SDLSKK_Dictionary* c_dict;
55
- SDLSKK_Keybind* c_bind;
56
65
  VALUE context;
57
66
 
58
- if( !rb_obj_is_kind_of(dict,cDictionary) )
59
- rb_raise(rb_eArgError,"type mismatch(expect SDL::SKK::Dictionary)");
60
- if( !rb_obj_is_kind_of(rule_table,cRomKanaRuleTable) )
61
- rb_raise(rb_eArgError,"type mismatch(expect SDL::SKK::RomKanaRuleTable)");
62
- if( !rb_obj_is_kind_of(keybind,cKeybind) )
63
- rb_raise(rb_eArgError,"type mismatch(expect SDL::SKK::Keybind)");
64
-
65
- Data_Get_Struct(dict,SDLSKK_Dictionary,c_dict);
66
- Data_Get_Struct(rule_table,SDLSKK_RomKanaRuleTable,c_table);
67
- Data_Get_Struct(keybind,SDLSKK_Keybind,c_bind);
67
+ c_context = SDLSKK_Context_new(Get_SDLSKK_Dictionary(dict),
68
+ Get_SDLSKK_RomKanaRuleTable(rule_table),
69
+ Get_SDLSKK_Keybind(keybind),
70
+ RTEST(use_minibuffer));
68
71
 
69
- c_context = SDLSKK_Context_new( c_dict, c_table, c_bind, RTEST(use_minibuffer) );
70
- if( c_context == NULL )
72
+ if(c_context == NULL)
71
73
  rb_raise(eSDLError,"Couldn't create Context");
72
74
 
73
- context = Data_Wrap_Struct(class,0,SDLSKK_Context_delete,c_context);
74
- rb_iv_set(context,"dict",dict);
75
- rb_iv_set(context,"rule_table",rule_table);
75
+ context = Data_Wrap_Struct(klass, 0, SDLSKK_Context_delete ,c_context);
76
+ rb_iv_set(context, "dict", dict);
77
+ rb_iv_set(context, "rule_table", rule_table);
76
78
 
77
79
  return context;
78
80
  }
79
81
 
80
- static VALUE skk_Context_input_event(VALUE obj,VALUE event)
82
+ static VALUE Context_input(VALUE self, VALUE event)
81
83
  {
82
- SDLSKK_Context* context;
83
- SDL_Event *ev;
84
-
85
- Data_Get_Struct(obj,SDLSKK_Context,context);
86
- if( rb_obj_is_kind_of( event,cEvent ) ){
87
- Data_Get_Struct(event,SDL_Event,ev);
88
- SDLSKK_Context_input_event( context, ev );
84
+ if(rb_obj_is_kind_of(event, cKeyDownEvent)){
85
+ SDL_Event ev;
86
+ ev.type = SDL_KEYDOWN;
87
+ ev.key.keysym.sym = NUM2INT(rb_iv_get(event, "@sym"));
88
+ ev.key.keysym.unicode = NUM2UINT(rb_iv_get(event, "@unicode"));
89
+ ev.key.keysym.mod = NUM2INT(rb_iv_get(event, "@mod"));
90
+ SDLSKK_Context_input_event(Get_SDLSKK_Context(self), &ev);
89
91
  return Qnil;
92
+ }else if(rb_obj_is_kind_of(event, cEvent)){
93
+ return Qnil;
94
+ }else{
95
+ rb_raise( rb_eArgError,"type mismatch(expect SDL::Event or SDL::Event2)");
90
96
  }
91
-
92
- #ifdef DEF_EVENT2
93
- if( rb_obj_is_kind_of( event,cEvent2 ) ){
94
- if( rb_obj_is_kind_of( event,cKeyDownEvent ) ){
95
- SDL_Event ev2;
96
- ev2.type = SDL_KEYDOWN;
97
- ev2.key.keysym.sym = NUM2INT( rb_iv_get(event,"@sym") );
98
- ev2.key.keysym.unicode = NUM2UINT( rb_iv_get(event,"@unicode") );
99
- ev2.key.keysym.mod = NUM2INT( rb_iv_get(event,"@mod"));
100
- SDLSKK_Context_input_event( context, &ev2 );
101
- return Qnil;
102
- }else{
103
- return Qnil;
104
- }
105
- }
106
-
107
- #endif
108
- rb_raise( rb_eArgError,"type mismatch(expect SDL::Event or SDL::Event2)");
109
-
110
97
  /* NOT REACHED */
111
98
  }
112
99
 
113
- static VALUE skk_Context_get_str(VALUE obj)
100
+ static VALUE Context_str(VALUE self)
114
101
  {
115
- SDLSKK_Context* context;
116
102
  char cstr[10000];
117
-
118
- Data_Get_Struct(obj,SDLSKK_Context,context);
119
-
120
- SDLSKK_Context_get_str(context,cstr,sizeof(cstr));
121
-
103
+ SDLSKK_Context_get_str(Get_SDLSKK_Context(self), cstr, sizeof(cstr));
122
104
  return rb_str_new2(cstr);
123
105
  }
124
106
 
125
- static VALUE render_str(VALUE obj,VALUE font,VALUE r,VALUE g,VALUE b,
126
- Renderer func)
107
+ static VALUE render_str(VALUE self, VALUE font, VALUE r, VALUE g, VALUE b,
108
+ Renderer func)
127
109
  {
128
- SDLSKK_Context* context;
129
110
  SDL_Surface* surface;
130
- TTF_Font* ttf_font;
131
111
  SDL_Color color;
132
-
133
- if( !rb_obj_is_kind_of(font,cTTF) )
134
- rb_raise( rb_eArgError,"type mismatch(expect SDL::TTF)");
135
112
 
136
113
  color.r = NUM2UINT(r);
137
114
  color.g = NUM2UINT(g);
138
115
  color.b = NUM2UINT(b);
139
116
 
140
- Data_Get_Struct(obj,SDLSKK_Context,context);
141
- Data_Get_Struct(font,TTF_Font,ttf_font);
142
-
143
- surface = func(context,ttf_font,color);
117
+ surface = func(Get_SDLSKK_Context(self), Get_TTF_Font(font), color);
144
118
 
145
- if( surface == NULL )
119
+ if(surface == NULL)
146
120
  return Qnil;
147
121
 
148
- return Data_Wrap_Struct(cSurface,0,sdl_freeSurface,surface);
122
+ return Surface_create(surface);
149
123
  }
150
124
 
151
- static VALUE skk_Context_render_str(VALUE obj,VALUE font,VALUE r,VALUE g,
152
- VALUE b)
125
+ static VALUE Context_render_str(VALUE self, VALUE font,
126
+ VALUE r, VALUE g, VALUE b)
127
+
153
128
  {
154
- return render_str(obj,font,r,g,b,SDLSKK_Context_render_display_str);
129
+ return render_str(self, font, r, g, b, SDLSKK_Context_render_display_str);
155
130
  }
156
131
 
157
- static VALUE skk_Context_render_minibuffer_str(VALUE obj,VALUE font,VALUE r,
158
- VALUE g,VALUE b)
132
+ static VALUE Context_render_minibuffer_str(VALUE self, VALUE font,
133
+ VALUE r, VALUE g,VALUE b)
159
134
  {
160
- return render_str(obj,font,r,g,b,SDLSKK_Context_render_minibuffer_str);
135
+ return render_str(self, font, r, g, b, SDLSKK_Context_render_minibuffer_str);
161
136
  }
162
137
 
163
- static VALUE skk_Context_get_basic_mode(VALUE obj)
138
+ static VALUE Context_get_basic_mode(VALUE self)
164
139
  {
165
- SDLSKK_Context* context;
166
-
167
- Data_Get_Struct(obj,SDLSKK_Context,context);
168
- return BOOL(SDLSKK_Context_get_basic_mode(context));
140
+ return INT2BOOL(SDLSKK_Context_get_basic_mode(Get_SDLSKK_Context(self)));
169
141
  }
170
142
 
171
- static VALUE skk_Context_clear(VALUE obj)
143
+ static VALUE Context_clear(VALUE self)
172
144
  {
173
- SDLSKK_Context* context;
174
-
175
- Data_Get_Struct(obj,SDLSKK_Context,context);
176
- SDLSKK_Context_clear(context);
145
+ SDLSKK_Context_clear(Get_SDLSKK_Context(self));
177
146
  return Qnil;
178
147
  }
179
148
 
180
- static VALUE skk_Context_clear_text(VALUE obj)
149
+ static VALUE Context_clear_text(VALUE self)
181
150
  {
182
- SDLSKK_Context* context;
183
-
184
- Data_Get_Struct(obj,SDLSKK_Context,context);
185
- SDLSKK_Context_clear_text(context);
151
+ SDLSKK_Context_clear_text(Get_SDLSKK_Context(self));
186
152
  return Qnil;
187
153
  }
188
154
 
189
- static VALUE skk_Dictionary_new(VALUE class)
155
+ static VALUE Dictionary_s_new(VALUE klass)
190
156
  {
191
157
  SDLSKK_Dictionary* dict;
192
158
 
193
159
  dict = SDLSKK_Dict_new();
194
- if( dict == NULL )
195
- rb_raise(eSDLError,"Couldn't create SDL::SKK::Dictionary" );
160
+ if(dict == NULL)
161
+ rb_raise(eSDLError, "Couldn't create SDL::SKK::Dictionary");
196
162
 
197
- return Data_Wrap_Struct(class,0,SDLSKK_Dict_delete,dict);
163
+ return Data_Wrap_Struct(klass, 0, SDLSKK_Dict_delete, dict);
198
164
  }
199
165
 
200
- static VALUE skk_Dict_load(VALUE obj,VALUE filename,VALUE users)
166
+ static VALUE Dictionary_load(VALUE self, VALUE filename, VALUE users)
201
167
  {
202
- SDLSKK_Dictionary* dict;
203
-
204
- Data_Get_Struct(obj,SDLSKK_Dictionary,dict);
168
+ SDLSKK_Dictionary* dict = Get_SDLSKK_Dictionary(self);
169
+ rb_secure(4);
170
+ SafeStringValue(filename);
205
171
 
206
- if( !SDLSKK_Dict_load(dict,GETCSTR(filename),RTEST(users)) )
207
- rb_raise(eSDLError,"Couldn't load %s",GETCSTR(filename));
172
+ if(!SDLSKK_Dict_load(dict, RSTRING_PTR(filename), RTEST(users)))
173
+ rb_raise(eSDLError, "Couldn't load %s", RSTRING_PTR(filename));
208
174
 
209
175
  return Qnil;
210
176
  }
211
177
 
212
- static VALUE skk_Dict_save(VALUE obj, VALUE filename)
178
+ static VALUE Dictionary_save(VALUE self, VALUE filename)
213
179
  {
214
- SDLSKK_Dictionary* dict;
215
-
216
- Data_Get_Struct(obj,SDLSKK_Dictionary,dict);
217
-
218
- if( !SDLSKK_Dict_save_user_dict(dict,GETCSTR(filename)) )
219
- rb_raise(eSDLError,"Couldn't save %s",GETCSTR(filename));
180
+ SDLSKK_Dictionary* dict = Get_SDLSKK_Dictionary(self);
181
+ rb_secure(4);
182
+ SafeStringValue(self);
220
183
 
184
+ if(!SDLSKK_Dict_save_user_dict(dict, RSTRING_PTR(filename)))
185
+ rb_raise(eSDLError, "Couldn't save %s", RSTRING_PTR(filename));
221
186
  return Qnil;
222
187
  }
223
188
 
224
- static VALUE skk_RomKanaRuleTable_new(VALUE class,VALUE table_file)
189
+ static VALUE RomKanaRuleTable_s_new(VALUE klass, VALUE table_file)
225
190
  {
226
191
  SDLSKK_RomKanaRuleTable* rule_table;
192
+ rb_secure(4);
193
+ SafeStringValue(table_file);
194
+
195
+ rule_table = SDLSKK_RomKanaRuleTable_new(RSTRING_PTR(table_file));
227
196
 
228
- rule_table = SDLSKK_RomKanaRuleTable_new( GETCSTR(table_file) );
229
-
230
- if( rule_table == NULL )
231
- rb_raise(eSDLError,"Couldn't load %s",GETCSTR(table_file));
197
+ if(rule_table == NULL)
198
+ rb_raise(eSDLError, "Couldn't load %s", RSTRING_PTR(table_file));
232
199
 
233
- return Data_Wrap_Struct(class,0,SDLSKK_RomKanaRuleTable_delete,rule_table);
200
+ return Data_Wrap_Struct(klass, 0, SDLSKK_RomKanaRuleTable_delete, rule_table);
234
201
  }
235
202
 
236
- static VALUE skk_Keybind_new(VALUE class)
203
+ static VALUE Keybind_s_new(VALUE klass)
237
204
  {
238
- return Data_Wrap_Struct(class,0,SDLSKK_Keybind_delete,SDLSKK_Keybind_new());
205
+ return Data_Wrap_Struct(klass, 0, SDLSKK_Keybind_delete, SDLSKK_Keybind_new());
239
206
  }
240
207
 
241
- static VALUE skk_Keybind_set_key(VALUE obj,VALUE key_str,VALUE cmd_str)
208
+ static VALUE Keybind_set_key(VALUE self, VALUE key_str, VALUE cmd_str)
242
209
  {
243
- SDLSKK_Keybind* keybind;
244
-
245
- Data_Get_Struct(obj,SDLSKK_Keybind,keybind);
246
- SDLSKK_Keybind_set_key(keybind,GETCSTR(key_str),GETCSTR(cmd_str));
210
+ SDLSKK_Keybind_set_key(Get_SDLSKK_Keybind(self),
211
+ StringValuePtr(key_str),
212
+ StringValuePtr(cmd_str));
247
213
  return Qnil;
248
214
  }
249
215
 
250
- static VALUE skk_Keybind_set_default_key(VALUE obj)
216
+ static VALUE Keybind_set_default_key(VALUE self)
251
217
  {
252
- SDLSKK_Keybind* keybind;
253
-
254
- Data_Get_Struct(obj,SDLSKK_Keybind,keybind);
255
- SDLSKK_Keybind_set_default_key(keybind);
218
+ SDLSKK_Keybind_set_default_key(Get_SDLSKK_Keybind(self));
256
219
  return Qnil;
257
220
  }
258
221
 
259
- static VALUE skk_Keybind_unset_key(VALUE obj,VALUE key_str)
222
+ static VALUE Keybind_unset_key(VALUE self, VALUE key_str)
260
223
  {
261
- SDLSKK_Keybind* keybind;
262
-
263
- Data_Get_Struct(obj,SDLSKK_Keybind,keybind);
264
- SDLSKK_Keybind_unset_key(keybind,GETCSTR(key_str));
224
+ SDLSKK_Keybind_unset_key(Get_SDLSKK_Keybind(self), StringValuePtr(key_str));
265
225
  return Qnil;
266
226
  }
267
227
 
268
- static void defineConstForSDLSKK(void)
228
+ void rubysdl_init_SKK(VALUE mSDL)
269
229
  {
270
- rb_define_const(mSDLSKK,"EUCJP",INT2NUM(SDLSKK_EUCJP));
271
- rb_define_const(mSDLSKK,"UTF8",INT2NUM(SDLSKK_UTF8));
272
- rb_define_const(mSDLSKK,"SJIS",INT2NUM(SDLSKK_SJIS));
273
- }
274
-
275
- void init_sdlskk(void)
276
- {
277
- mSDLSKK = rb_define_module_under(mSDL,"SKK");
278
- cContext = rb_define_class_under(mSDLSKK,"Context",rb_cObject);
279
- cDictionary = rb_define_class_under(mSDLSKK,"Dictionary",rb_cObject);
280
- cRomKanaRuleTable = rb_define_class_under(mSDLSKK,"RomKanaRuleTable",
230
+ VALUE mSDLSKK;
231
+
232
+ cEvent = rb_const_get(mSDL, rb_intern("Event"));
233
+ cKeyDownEvent = rb_const_get(cEvent, rb_intern("KeyDown"));
234
+
235
+ mSDLSKK = rb_define_module_under(mSDL, "SKK");
236
+ cContext = rb_define_class_under(mSDLSKK, "Context", rb_cObject);
237
+ cDictionary = rb_define_class_under(mSDLSKK, "Dictionary", rb_cObject);
238
+ cRomKanaRuleTable = rb_define_class_under(mSDLSKK, "RomKanaRuleTable",
281
239
  rb_cObject);
282
- cKeybind = rb_define_class_under(mSDLSKK,"Keybind",rb_cObject);
240
+ cKeybind = rb_define_class_under(mSDLSKK, "Keybind", rb_cObject);
241
+
242
+ rb_undef_alloc_func(cContext);
243
+ rb_undef_alloc_func(cDictionary);
244
+ rb_undef_alloc_func(cRomKanaRuleTable);
245
+ rb_undef_alloc_func(cKeybind);
283
246
 
284
- rb_define_module_function(mSDLSKK,"encoding=",skk_set_encoding,1);
285
- rb_define_module_function(mSDLSKK,"encoding",skk_get_encoding,0);
247
+ rb_define_module_function(mSDLSKK, "encoding=", SKK_set_encoding, 1);
248
+ rb_define_module_function(mSDLSKK, "encoding", SKK_get_encoding, 0);
286
249
 
287
- rb_define_singleton_method(cContext,"new",skk_Context_new,4);
288
- rb_define_method(cContext,"input",skk_Context_input_event,1);
289
- rb_define_method(cContext,"str",skk_Context_get_str,0);
290
- rb_define_method(cContext,"render_str",skk_Context_render_str,4);
291
- rb_define_method(cContext,"render_minibuffer_str",skk_Context_render_minibuffer_str,4);
292
- rb_define_method(cContext,"get_basic_mode",skk_Context_get_basic_mode,0);
293
- rb_define_method(cContext,"clear",skk_Context_clear,0);
294
- rb_define_method(cContext,"clear_text",skk_Context_clear_text,0);
250
+ rb_define_singleton_method(cContext, "new", Context_s_new, 4);
251
+ rb_define_method(cContext, "input", Context_input, 1);
252
+ rb_define_method(cContext, "str", Context_str, 0);
253
+ rb_define_method(cContext, "render_str", Context_render_str, 4);
254
+ rb_define_method(cContext, "render_minibuffer_str",
255
+ Context_render_minibuffer_str, 4);
256
+ rb_define_method(cContext, "get_basic_mode", Context_get_basic_mode, 0);
257
+ rb_define_method(cContext, "clear", Context_clear, 0);
258
+ rb_define_method(cContext, "clear_text", Context_clear_text, 0);
295
259
 
296
- rb_define_singleton_method(cDictionary,"new",skk_Dictionary_new,0);
297
- rb_define_method(cDictionary,"load",skk_Dict_load,2);
298
- rb_define_method(cDictionary,"save",skk_Dict_save,1);
260
+ rb_define_singleton_method(cDictionary, "new", Dictionary_s_new, 0);
261
+ rb_define_method(cDictionary, "load", Dictionary_load, 2);
262
+ rb_define_method(cDictionary, "save", Dictionary_save, 1);
299
263
 
300
- rb_define_singleton_method(cRomKanaRuleTable,"new",
301
- skk_RomKanaRuleTable_new,1);
264
+ rb_define_singleton_method(cRomKanaRuleTable, "new",
265
+ RomKanaRuleTable_s_new, 1);
302
266
 
303
- rb_define_singleton_method(cKeybind,"new",skk_Keybind_new,0);
304
- rb_define_method(cKeybind,"set_key",skk_Keybind_set_key,2);
305
- rb_define_method(cKeybind,"set_default_key",skk_Keybind_set_default_key,0);
306
- rb_define_method(cKeybind,"unset_key",skk_Keybind_unset_key,1);
267
+ rb_define_singleton_method(cKeybind, "new", Keybind_s_new, 0);
268
+ rb_define_method(cKeybind, "set_key", Keybind_set_key, 2);
269
+ rb_define_method(cKeybind, "set_default_key", Keybind_set_default_key, 0);
270
+ rb_define_method(cKeybind, "unset_key", Keybind_unset_key, 1);
307
271
 
308
272
  SDLSKK_set_error_func(skk_error_handler);
273
+
309
274
 
310
- defineConstForSDLSKK();
275
+ rb_define_const(mSDLSKK, "EUCJP", INT2NUM(SDLSKK_EUCJP));
276
+ rb_define_const(mSDLSKK, "UTF8", INT2NUM(SDLSKK_UTF8));
277
+ rb_define_const(mSDLSKK, "SJIS", INT2NUM(SDLSKK_SJIS));
278
+ }
279
+ #else /* HAVE_SDLSKK */
280
+ #include "rubysdl.h"
281
+ void rubysdl_init_SKK(VALUE mSDL)
282
+ {
311
283
  }
312
284
  #endif /* HAVE_SDLSKK */