Kouhei Sutou
kous****@users*****
2006年 11月 22日 (水) 18:04:47 JST
Index: tomoe/ext/ruby/Makefile.am diff -u tomoe/ext/ruby/Makefile.am:1.6 tomoe/ext/ruby/Makefile.am:1.7 --- tomoe/ext/ruby/Makefile.am:1.6 Wed Nov 22 16:24:19 2006 +++ tomoe/ext/ruby/Makefile.am Wed Nov 22 18:04:47 2006 @@ -16,14 +16,16 @@ $(GLIB_CFLAGS) \ -I$(top_srcdir)/lib -tomoe_la_SOURCES = \ - tomoe-rb.c tomoe-rb.h \ - tomoe-rb-candidate.c \ - tomoe-rb-char.c \ - tomoe-rb-config.c \ - tomoe-rb-context.c \ - tomoe-rb-dict.c \ - tomoe-rb-recognizer.c \ +tomoe_la_SOURCES = \ + tomoe-rb.c tomoe-rb.h \ + tomoe-rb-candidate.c \ + tomoe-rb-char.c \ + tomoe-rb-config.c \ + tomoe-rb-context.c \ + tomoe-rb-dict.c \ + tomoe-rb-query.c \ + tomoe-rb-reading.c \ + tomoe-rb-recognizer.c \ tomoe-rb-writing.c tomoe_la_LDFLAGS = \ Index: tomoe/ext/ruby/tomoe-rb-context.c diff -u tomoe/ext/ruby/tomoe-rb-context.c:1.7 tomoe/ext/ruby/tomoe-rb-context.c:1.8 --- tomoe/ext/ruby/tomoe-rb-context.c:1.7 Wed Nov 22 15:43:38 2006 +++ tomoe/ext/ruby/tomoe-rb-context.c Wed Nov 22 18:04:47 2006 @@ -24,18 +24,17 @@ } static VALUE -tc_search_by_strokes(VALUE self, VALUE writing) +tc_search(VALUE self, VALUE query) { - return GLIST2ARYF(tomoe_context_search_by_strokes(_SELF(self), - RVAL2TWTG(writing))); + return GLIST2ARYF(tomoe_context_search(_SELF(self), RVAL2TQRY(query))); } -static VALUE -tc_search_by_reading(VALUE self, VALUE reading) -{ - return GLIST2ARYF(tomoe_context_search_by_reading(_SELF(self), - RVAL2CSTR(reading))); -} +/* static VALUE */ +/* tc_advanced_search(VALUE self, VALUE rb_queries) */ +/* { */ +/* return GLIST2ARYF(tomoe_context_advanced_search(_SELF(self), */ +/* RVAL2GLIST(queries))); */ +/* } */ void @@ -47,8 +46,6 @@ rb_define_method(cTomoeContext, "add_dict", tc_add_dict, 1); rb_define_method(cTomoeContext, "load_config", tc_load_config, -1); - rb_define_method(cTomoeContext, "search_by_strokes", tc_search_by_strokes, - 1); - rb_define_method(cTomoeContext, "search_by_reading", tc_search_by_reading, - 1); + rb_define_method(cTomoeContext, "search", tc_search, 1); +/* rb_define_method(cTomoeContext, "advanced_search", tc_advanced_search, 1); */ } Index: tomoe/ext/ruby/tomoe-rb-query.c diff -u /dev/null tomoe/ext/ruby/tomoe-rb-query.c:1.1 --- /dev/null Wed Nov 22 18:04:47 2006 +++ tomoe/ext/ruby/tomoe-rb-query.c Wed Nov 22 18:04:47 2006 @@ -0,0 +1,36 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ + +#include "tomoe-rb.h" + +#define _SELF(obj) RVAL2TQRY(obj) + +static VALUE +tq_add_reading(VALUE self, VALUE reading) +{ + tomoe_query_add_reading(_SELF(self), RVAL2TRDG(reading)); + return Qnil; +} + +static VALUE +tq_set_writing(VALUE self, VALUE writing) +{ + tomoe_query_set_writing(_SELF(self), RVAL2TWTG(writing)); + return Qnil; +} + +void +Init_tomoe_query(VALUE mTomoe) +{ + VALUE cTomoeQuery; + + cTomoeQuery = G_DEF_CLASS(TOMOE_TYPE_QUERY, "Query", mTomoe); + + rb_define_method(cTomoeQuery, "add_reading", tq_add_reading, 1); +/* rb_define_method(cTomoeQuery, "set_number_of_stroke", */ +/* tq_set_number_of_stroke, 1); */ +/* rb_define_method(cTomoeQuery, "add_radical", tq_add_radical, 1); */ +/* rb_define_method(cTomoeQuery, "add_variant", tq_add_variant, 1); */ + rb_define_method(cTomoeQuery, "set_writing", tq_set_writing, 1); + + G_DEF_SETTERS(cTomoeQuery); +} Index: tomoe/ext/ruby/tomoe-rb-reading.c diff -u /dev/null tomoe/ext/ruby/tomoe-rb-reading.c:1.1 --- /dev/null Wed Nov 22 18:04:47 2006 +++ tomoe/ext/ruby/tomoe-rb-reading.c Wed Nov 22 18:04:47 2006 @@ -0,0 +1,23 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ + +#include "tomoe-rb.h" + +#define _SELF(obj) RVAL2TRDG(obj) + +static VALUE +tr_initialize(VALUE self, VALUE type, VALUE reading) +{ + G_INITIALIZE(self, tomoe_reading_new(RVAL2TRT(type), RVAL2CSTR(reading))); + return Qnil; +} + +void +Init_tomoe_reading(VALUE mTomoe) +{ + VALUE cTomoeReading; + + cTomoeReading = G_DEF_CLASS(TOMOE_TYPE_READING, "Reading", mTomoe); + G_DEF_CONSTANTS(mTomoe, TOMOE_TYPE_READING_TYPE, "TOMOE_"); + + rb_define_method(cTomoeReading, "initialize", tr_initialize, 2); +} Index: tomoe/ext/ruby/tomoe-rb-writing.c diff -u tomoe/ext/ruby/tomoe-rb-writing.c:1.2 tomoe/ext/ruby/tomoe-rb-writing.c:1.3 --- tomoe/ext/ruby/tomoe-rb-writing.c:1.2 Wed Nov 22 15:43:38 2006 +++ tomoe/ext/ruby/tomoe-rb-writing.c Wed Nov 22 18:04:47 2006 @@ -96,7 +96,7 @@ } void -Init_tomoe_handwrite(VALUE mTomoe) +Init_tomoe_writing(VALUE mTomoe) { VALUE cTomoeWriting; Index: tomoe/ext/ruby/tomoe-rb.c diff -u tomoe/ext/ruby/tomoe-rb.c:1.3 tomoe/ext/ruby/tomoe-rb.c:1.4 --- tomoe/ext/ruby/tomoe-rb.c:1.3 Wed Nov 22 10:59:09 2006 +++ tomoe/ext/ruby/tomoe-rb.c Wed Nov 22 18:04:47 2006 @@ -17,6 +17,8 @@ Init_tomoe_config(mTomoe); Init_tomoe_context(mTomoe); Init_tomoe_dict(mTomoe); - Init_tomoe_handwrite(mTomoe); + Init_tomoe_query(mTomoe); + Init_tomoe_reading(mTomoe); Init_tomoe_recognizer(mTomoe); + Init_tomoe_writing(mTomoe); } Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.5 tomoe/ext/ruby/tomoe-rb.h:1.6 --- tomoe/ext/ruby/tomoe-rb.h:1.5 Wed Nov 22 15:43:38 2006 +++ tomoe/ext/ruby/tomoe-rb.h Wed Nov 22 18:04:47 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.5 2006/11/22 06:43:38 kous Exp $ + * $Id: tomoe-rb.h,v 1.6 2006/11/22 09:04:47 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -33,6 +33,10 @@ #define RVAL2TCTX(obj) (TOMOE_CONTEXT(RVAL2GOBJ(obj))) #define RVAL2TDIC(obj) (TOMOE_DICT(RVAL2GOBJ(obj))) #define RVAL2TWTG(obj) (TOMOE_WRITING(RVAL2GOBJ(obj))) +#define RVAL2TQRY(obj) (TOMOE_QUERY(RVAL2GOBJ(obj))) +#define RVAL2TRDG(obj) (TOMOE_READING(RVAL2GOBJ(obj))) + +#define RVAL2TRT(obj) (RVAL2GENUM(obj, TOMOE_TYPE_READING_TYPE)) void Init_tomoe(void); void Init_tomoe_candidate(VALUE mTomoe); @@ -40,8 +44,10 @@ void Init_tomoe_config(VALUE mTomoe); void Init_tomoe_context(VALUE mTomoe); void Init_tomoe_dict(VALUE mTomoe); -void Init_tomoe_handwrite(VALUE mTomoe); +void Init_tomoe_query(VALUE mTomoe); +void Init_tomoe_reading(VALUE mTomoe); void Init_tomoe_recognizer(VALUE mTomoe); +void Init_tomoe_writing(VALUE mTomoe); #endif /* __TOMOE_RB_H__ */