[Tomoe-cvs 1381] CVS update: tomoe/ext/ruby

Back to archive index

Kouhei Sutou kous****@users*****
2006年 11月 29日 (水) 11:53:11 JST


Index: tomoe/ext/ruby/tomoe-rb-dict.c
diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.6 tomoe/ext/ruby/tomoe-rb-dict.c:1.7
--- tomoe/ext/ruby/tomoe-rb-dict.c:1.6	Wed Nov 29 00:07:02 2006
+++ tomoe/ext/ruby/tomoe-rb-dict.c	Wed Nov 29 11:53:11 2006
@@ -3,45 +3,45 @@
 #define _SELF(obj) RVAL2TDIC(obj)
 
 static VALUE
-td_get_char(VALUE self, VALUE code_point)
+td_s_load(VALUE self, VALUE base_dir)
 {
-    return GOBJ2RVAL(tomoe_dict_get_char(_SELF(self), RVAL2CSTR(code_point)));
+    tomoe_dict_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir));
+    return Qnil;
 }
 
 static VALUE
-tdl_s_load(VALUE self, VALUE base_dir)
+td_s_unload(VALUE self)
 {
-    tomoe_dict_loader_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir));
+    tomoe_dict_unload();
     return Qnil;
 }
 
 static VALUE
-tdl_s_unload(VALUE self)
+td_s_new(VALUE self, VALUE name, VALUE filename, VALUE editable)
 {
-    tomoe_dict_loader_unload();
-    return Qnil;
+    return GOBJ2RVAL(tomoe_dict_new(RVAL2CSTR(name),
+                                    "filename", RVAL2CSTR(filename),
+                                    "editable", RVAL2CBOOL(editable),
+                                    NULL));
 }
 
 static VALUE
-tdl_s_instantiate(VALUE self, VALUE name, VALUE filename, VALUE editable)
+td_get_char(VALUE self, VALUE code_point)
 {
-    return GOBJ2RVAL(tomoe_dict_loader_instantiate(RVAL2CSTR(name),
-                                                   RVAL2CSTR(filename),
-                                                   RVAL2CBOOL(editable)));
+    return GOBJ2RVAL(tomoe_dict_get_char(_SELF(self), RVAL2CSTR(code_point)));
 }
 
 void
 Init_tomoe_dict(VALUE mTomoe)
 {
-    VALUE cTomoeDict, mTomoeDictLoader;
+    VALUE cTomoeDict;
 
     cTomoeDict = G_DEF_CLASS(TOMOE_TYPE_DICT, "Dict", mTomoe);
-    mTomoeDictLoader = rb_define_module_under(mTomoe, "DictLoader");
 
-    rb_define_method(cTomoeDict, "[]", td_get_char, 1);
+    rb_define_singleton_method(cTomoeDict, "load", td_s_load, 1);
+    rb_define_singleton_method(cTomoeDict, "unload", td_s_unload, 0);
 
-    rb_define_module_function(mTomoeDictLoader, "load", tdl_s_load, 1);
-    rb_define_module_function(mTomoeDictLoader, "unload", tdl_s_unload, 0);
-    rb_define_module_function(mTomoeDictLoader, "instantiate",
-                              tdl_s_instantiate, 3);
+    rb_define_singleton_method(cTomoeDict, "new", td_s_new, 3);
+
+    rb_define_method(cTomoeDict, "[]", td_get_char, 1);
 }
Index: tomoe/ext/ruby/tomoe-rb-recognizer.c
diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.2 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.3
--- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.2	Wed Nov 29 00:07:02 2006
+++ tomoe/ext/ruby/tomoe-rb-recognizer.c	Wed Nov 29 11:53:11 2006
@@ -1,36 +1,34 @@
 #include "tomoe-rb.h"
 
 static VALUE
-trl_s_load(VALUE self, VALUE base_dir)
+tr_s_load(VALUE self, VALUE base_dir)
 {
-    tomoe_recognizer_loader_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir));
+    tomoe_recognizer_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir));
     return Qnil;
 }
 
 static VALUE
-trl_s_unload(VALUE self)
+tr_s_unload(VALUE self)
 {
-    tomoe_recognizer_loader_unload();
+    tomoe_recognizer_unload();
     return Qnil;
 }
 
 static VALUE
-trl_s_instantiate(VALUE self, VALUE name)
+tr_s_new(VALUE self, VALUE name)
 {
-    return GOBJ2RVAL(tomoe_recognizer_loader_instantiate(RVAL2CSTR(name)));
+    return GOBJ2RVAL(tomoe_recognizer_new(RVAL2CSTR(name), NULL));
 }
 
 void
 Init_tomoe_recognizer(VALUE mTomoe)
 {
-    VALUE cTomoeRecognizer, mTomoeRecognizerLoader;
+    VALUE cTomoeRecognizer;
 
     cTomoeRecognizer = G_DEF_CLASS(TOMOE_TYPE_RECOGNIZER, "Recognizer", mTomoe);
-    mTomoeRecognizerLoader = rb_define_module_under(mTomoe, "RecognizerLoader");
 
-    rb_define_module_function(mTomoeRecognizerLoader, "load", trl_s_load, 1);
-    rb_define_module_function(mTomoeRecognizerLoader, "unload",
-                              trl_s_unload, 0);
-    rb_define_module_function(mTomoeRecognizerLoader, "instantiate",
-                              trl_s_instantiate, 3);
+    rb_define_singleton_method(cTomoeRecognizer, "load", tr_s_load, 1);
+    rb_define_singleton_method(cTomoeRecognizer, "unload", tr_s_unload, 0);
+
+    rb_define_singleton_method(cTomoeRecognizer, "new", tr_s_new, 1);
 }


tomoe-cvs メーリングリストの案内
Back to archive index