3 * Ãæ¿È¤Ïwtype_t¤ÎÆâÉô¤Î¥ì¥¤¥¢¥¦¥È¤Ë¶¯¤¯°Í¸¤¹¤ë¡£
5 * Copyright (C) 2000-2007 TABATA Yusuke
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <anthy/wtype.h>
28 wtype_t anthy_wt_none, anthy_wt_all;
40 /* ÉÊ»ì¤ÎÆüËܸì¤Î̾Á°¤òÉÊ»ì¤ËÊÑ´¹¤¹¤ë¥Æ¡¼¥Ö¥ë */
41 static struct wttable pos_name_tab[]= {
45 /* ¼½ñÃæ¤ÎÉÊ»ì¤Î̾Á°¤òÉÊ»ì¤ËÊÑ´¹¤¹¤ë¥Æ¡¼¥Ö¥ë */
46 static struct wttable wt_name_tab[]= {
50 static struct wttable *
51 find_wttab(struct wttable *array, const char *name)
54 for (w = array; w->name; w++) {
55 if (!strcmp(w->name, name)) {
63 anthy_init_wtypes(void)
65 anthy_wt_all.pos = POS_NONE;
66 anthy_wt_all.cc = CC_NONE;
67 anthy_wt_all.ct = CT_NONE;
68 anthy_wt_all.cos = COS_NONE;
69 anthy_wt_all.scos = SCOS_NONE;
70 anthy_wt_all.wf = WF_NONE;
72 anthy_wt_none = anthy_wt_all;
73 anthy_wt_none.pos = POS_INVAL;
77 * ÊÖ¤êÃͤˤÏÉÊ»ì¤Î̾Á°
81 anthy_type_to_wtype(const char *s, wtype_t *t)
88 w = find_wttab(wt_name_tab, s);
93 *t = anthy_get_wtype(w->pos, w->cos, w->scos, w->cc, w->ct, w->flags);
98 anthy_init_wtype_by_name(const char *name)
101 p = find_wttab(pos_name_tab, name);
104 return anthy_get_wtype(p->pos, p->cos, p->scos, p->cc, p->ct, p->flags);
107 printf("Failed to find wtype(%s).\n", name);
111 /* Æó¤Ä¤ÎÉʻ줬´°Á´¤Ë°ìÃפ·¤Æ¤¤¤ë¤«¤É¤¦¤« */
113 anthy_wtype_equal(wtype_t lhs, wtype_t rhs)
115 if (lhs.pos == rhs.pos &&
116 lhs.cos == rhs.cos &&
117 lhs.scos == rhs.scos &&
128 /* n ¤Ï hs ¤Î°ìÉô¤«¤É¤¦¤«¡© */
130 anthy_wtype_include(wtype_t hs, wtype_t n)
132 /*printf("POS %d,%d\n", hs.type[WT_POS], n.type[WT_POS]);*/
133 if (hs.pos != POS_NONE &&
137 if (hs.cc != CC_NONE &&
141 if (hs.ct != CT_NONE &&
145 if (hs.cos != COS_NONE &&
149 if (hs.scos != SCOS_NONE &&
157 anthy_wtype_get_cc(wtype_t t)
163 anthy_wtype_get_ct(wtype_t t)
169 anthy_wtype_get_pos(wtype_t t)
175 anthy_wtype_get_cos(wtype_t t)
181 anthy_wtype_get_scos(wtype_t t)
187 anthy_wtype_get_wf(wtype_t t)
193 anthy_wtype_get_indep(wtype_t t)
195 return t.wf & WF_INDEP;
199 anthy_wtype_get_meisi(wtype_t w)
201 return w.wf & WF_MEISI;
205 anthy_wtype_get_sv(wtype_t w)
211 anthy_wtype_get_ajv(wtype_t w)
213 return w.wf & WF_AJV;
217 anthy_wtype_set_cc(wtype_t *w, int cc)
223 anthy_wtype_set_ct(wtype_t *w, int ct)
229 anthy_wtype_set_pos(wtype_t *w, int pos)
235 anthy_wtype_set_cos(wtype_t *w, int cs)
241 anthy_wtype_set_scos(wtype_t *w, int sc)
247 anthy_wtype_set_dep(wtype_t *w, int isDep)
250 w->wf &= (~WF_INDEP);
257 anthy_print_wtype(wtype_t w)
259 printf("(POS=%d,COS=%d,SCOS=%d,CC=%d,CT=%d,flags=%d)\n",
260 anthy_wtype_get_pos(w),
261 anthy_wtype_get_cos(w),
262 anthy_wtype_get_scos(w),
263 anthy_wtype_get_cc(w),
264 anthy_wtype_get_ct(w),
265 anthy_wtype_get_wf(w));
269 anthy_get_wtype_with_ct(wtype_t base, int ct)
280 anthy_get_wtype(int pos, int cos, int scos, int cc, int ct, int wf)