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

Zurück zum Archiv-Index

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


Index: tomoe/ext/ruby/tomoe-rb-context.c
diff -u tomoe/ext/ruby/tomoe-rb-context.c:1.11 tomoe/ext/ruby/tomoe-rb-context.c:1.12
--- tomoe/ext/ruby/tomoe-rb-context.c:1.11	Fri Nov 24 14:54:34 2006
+++ tomoe/ext/ruby/tomoe-rb-context.c	Wed Nov 29 00:07:02 2006
@@ -17,19 +17,6 @@
 }
 
 static VALUE
-tc_load_recognizer(int argc, VALUE *argv, VALUE self)
-{
-    VALUE base_dir, name;
-
-    rb_scan_args(argc, argv, "02", &base_dir, &name);
-
-    tomoe_context_load_recognizer(_SELF(self),
-                                  NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir),
-                                  NIL_P(name) ? NULL : RVAL2CSTR(name));
-    return Qnil;
-}
-
-static VALUE
 tc_search(VALUE self, VALUE query)
 {
     return GLIST2ARYF(tomoe_context_search(_SELF(self), RVAL2TQRY(query)));
@@ -51,7 +38,6 @@
     cTomoeContext = G_DEF_CLASS(TOMOE_TYPE_CONTEXT, "Context", mTomoe);
 
     rb_define_method(cTomoeContext, "load_config", tc_load_config, -1);
-    rb_define_method(cTomoeContext, "load_recognizer", tc_load_recognizer, -1);
     rb_define_method(cTomoeContext, "search", tc_search, 1);
 /*     rb_define_method(cTomoeContext, "multi_search", tc_multi_search, 1); */
 }
Index: tomoe/ext/ruby/tomoe-rb-dict.c
diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.5 tomoe/ext/ruby/tomoe-rb-dict.c:1.6
--- tomoe/ext/ruby/tomoe-rb-dict.c:1.5	Tue Nov 28 17:11:31 2006
+++ tomoe/ext/ruby/tomoe-rb-dict.c	Wed Nov 29 00:07:02 2006
@@ -3,34 +3,45 @@
 #define _SELF(obj) RVAL2TDIC(obj)
 
 static VALUE
-td_initialize(VALUE self, VALUE filename, VALUE editable,
-              VALUE rb_base_dir, VALUE rb_name)
+td_get_char(VALUE self, VALUE code_point)
 {
-    gchar *base_dir, *name;
+    return GOBJ2RVAL(tomoe_dict_get_char(_SELF(self), RVAL2CSTR(code_point)));
+}
 
-    base_dir = NIL_P(rb_base_dir) ? NULL : RVAL2CSTR(rb_base_dir);
-    name = NIL_P(rb_name) ? NULL : RVAL2CSTR(rb_name);
-    G_INITIALIZE(self, tomoe_dict_new(RVAL2CSTR(filename),
-                                      RVAL2CBOOL(editable),
-                                      base_dir, name));
+static VALUE
+tdl_s_load(VALUE self, VALUE base_dir)
+{
+    tomoe_dict_loader_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir));
     return Qnil;
 }
 
 static VALUE
-td_get_char(VALUE self, VALUE code_point)
+tdl_s_unload(VALUE self)
 {
-    return GOBJ2RVAL(tomoe_dict_get_char(_SELF(self), RVAL2CSTR(code_point)));
+    tomoe_dict_loader_unload();
+    return Qnil;
 }
 
+static VALUE
+tdl_s_instantiate(VALUE self, VALUE name, VALUE filename, VALUE editable)
+{
+    return GOBJ2RVAL(tomoe_dict_loader_instantiate(RVAL2CSTR(name),
+                                                   RVAL2CSTR(filename),
+                                                   RVAL2CBOOL(editable)));
+}
 
 void
 Init_tomoe_dict(VALUE mTomoe)
 {
-    VALUE cTomoeDict;
+    VALUE cTomoeDict, mTomoeDictLoader;
 
     cTomoeDict = G_DEF_CLASS(TOMOE_TYPE_DICT, "Dict", mTomoe);
-
-    rb_define_method(cTomoeDict, "initialize", td_initialize, 4);
+    mTomoeDictLoader = rb_define_module_under(mTomoe, "DictLoader");
 
     rb_define_method(cTomoeDict, "[]", td_get_char, 1);
+
+    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);
 }
Index: tomoe/ext/ruby/tomoe-rb-recognizer.c
diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.1 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.2
--- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.1	Mon Nov 20 15:47:09 2006
+++ tomoe/ext/ruby/tomoe-rb-recognizer.c	Wed Nov 29 00:07:02 2006
@@ -1,9 +1,36 @@
 #include "tomoe-rb.h"
 
+static VALUE
+trl_s_load(VALUE self, VALUE base_dir)
+{
+    tomoe_recognizer_loader_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir));
+    return Qnil;
+}
+
+static VALUE
+trl_s_unload(VALUE self)
+{
+    tomoe_recognizer_loader_unload();
+    return Qnil;
+}
+
+static VALUE
+trl_s_instantiate(VALUE self, VALUE name)
+{
+    return GOBJ2RVAL(tomoe_recognizer_loader_instantiate(RVAL2CSTR(name)));
+}
+
 void
 Init_tomoe_recognizer(VALUE mTomoe)
 {
-    VALUE cTomoeRecognizer;
+    VALUE cTomoeRecognizer, mTomoeRecognizerLoader;
 
     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);
 }


tomoe-cvs メーリングリストの案内
Zurück zum Archiv-Index