• R/O
  • SSH
  • HTTPS

comatz: 提交


Commit MetaInfo

修订版12 (tree)
时间2007-04-20 16:21:48
作者kous

Log Message

* comatz/cm-word.[ch]: renamed from ch-char.[ch]. We handle words

not characters.

更改概述

差异

--- comatz/trunk/ChangeLog (revision 11)
+++ comatz/trunk/ChangeLog (revision 12)
@@ -1,3 +1,8 @@
1+2007-04-20 Kouhei Sutou <kou@cozmixng.org>
2+
3+ * comatz/cm-word.[ch]: renamed from ch-char.[ch]. We handle words
4+ not characters.
5+
16 2007-04-19 Kouhei Sutou <kou@cozmixng.org>
27
38 * comatz/cm-char.[ch]: added.
--- comatz/trunk/comatz/cm-char.h (revision 11)
+++ comatz/trunk/comatz/cm-char.h (nonexistent)
@@ -1,66 +0,0 @@
1-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2-
3-/*
4- * Copyright (C) 2007 Kouhei Sutou <kou@cozmixng.org>
5- *
6- * This library is free software; you can redistribute it and/or
7- * modify it under the terms of the GNU Lesser General Public
8- * License as published by the Free Software Foundation; either
9- * version 2 of the License, or (at your option) any later version.
10- *
11- * This library is distributed in the hope that it will be useful,
12- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- * GNU Lesser General Public License for more details.
15- *
16- * You should have received a copy of the GNU Lesser General Public
17- * License along with this program; if not, write to the
18- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19- * Boston, MA 02111-1307 USA
20- */
21-
22-#ifndef __CM_CHAR_H__
23-#define __CM_CHAR_H__
24-
25-#include <glib-object.h>
26-
27-G_BEGIN_DECLS
28-
29-#define CM_TYPE_CHAR (cm_char_get_type())
30-#define CM_CHAR(o) (G_TYPE_CHECK_INSTANCE_CAST((o), CM_TYPE_CHAR, CmChar))
31-#define CM_IS_CHAR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), CM_TYPE_CHAR))
32-#define CM_CHAR_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), CM_TYPE_CHAR, CmCharIFace))
33-
34-typedef struct _CmChar CmChar;
35-typedef struct _CmCharClass CmCharClass;
36-
37-struct _CmChar
38-{
39- GObject *object;
40-};
41-
42-struct _CmCharClass
43-{
44- GObjectClass parent;
45-};
46-
47-GType cm_char_get_type (void) G_GNUC_CONST;
48-
49-CmChar *cm_char_new (const gchar *reading,
50- const gchar *utf8);
51-
52-const gchar *cm_char_get_reading (CmChar *chr);
53-const gchar *cm_char_get_utf8 (CmChar *chr);
54-
55-void cm_char_set_reading (CmChar *chr,
56- const gchar *reading);
57-void cm_char_set_utf8 (CmChar *chr,
58- const gchar *utf8);
59-
60-G_END_DECLS
61-
62-#endif /* __CM_CHAR_H__ */
63-
64-/*
65-vi:ts=4:nowrap:ai:expandtab
66-*/
--- comatz/trunk/comatz/cm-char.c (revision 11)
+++ comatz/trunk/comatz/cm-char.c (nonexistent)
@@ -1,220 +0,0 @@
1-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2-
3-/*
4- * Copyright (C) 2007 Kouhei Sutou <kou@cozmixng.org>
5- *
6- * This library is free software; you can redistribute it and/or
7- * modify it under the terms of the GNU Lesser General Public
8- * License as published by the Free Software Foundation; either
9- * version 2 of the License, or (at your option) any later version.
10- *
11- * This library is distributed in the hope that it will be useful,
12- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- * GNU Lesser General Public License for more details.
15- *
16- * You should have received a copy of the GNU Lesser General Public
17- * License along with this program; if not, write to the
18- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19- * Boston, MA 02111-1307 USA
20- */
21-
22-#ifdef HAVE_CONFIG_H
23-# include "config.h"
24-#endif /* HAVE_CONFIG_H */
25-
26-#include <glib/gi18n.h>
27-
28-#include "cm-char.h"
29-
30-#define CM_CHAR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CM_TYPE_CHAR, CmCharPrivate))
31-
32-typedef struct _CmCharPrivate CmCharPrivate;
33-struct _CmCharPrivate
34-{
35- gchar *reading;
36- gchar *utf8;
37-};
38-
39-enum
40-{
41- PROP_0,
42- PROP_READING,
43- PROP_UTF8
44-};
45-
46-G_DEFINE_TYPE (CmChar, cm_char, G_TYPE_OBJECT)
47-
48-static void dispose (GObject *object);
49-static void set_property (GObject *object,
50- guint prop_id,
51- const GValue *value,
52- GParamSpec *pspec);
53-static void get_property (GObject *object,
54- guint prop_id,
55- GValue *value,
56- GParamSpec *pspec);
57-
58-static void
59-cm_char_class_init (CmCharClass *klass)
60-{
61- GObjectClass *gobject_class;
62- GParamSpec *spec;
63-
64- gobject_class = G_OBJECT_CLASS (klass);
65-
66- gobject_class->dispose = dispose;
67- gobject_class->set_property = set_property;
68- gobject_class->get_property = get_property;
69-
70- spec = g_param_spec_string("reading",
71- N_("UTF8"),
72- N_("UTF8 encoding of the character."),
73- NULL,
74- G_PARAM_READABLE | G_PARAM_WRITABLE);
75- g_object_class_install_property(gobject_class, PROP_READING, spec);
76-
77- spec = g_param_spec_string("utf8",
78- N_("UTF8"),
79- N_("UTF8 encoding of the character."),
80- NULL,
81- G_PARAM_READABLE | G_PARAM_WRITABLE);
82- g_object_class_install_property(gobject_class, PROP_UTF8, spec);
83-
84- g_type_class_add_private (gobject_class, sizeof(CmCharPrivate));
85-}
86-
87-static void
88-cm_char_init (CmChar *chr)
89-{
90- CmCharPrivate *priv = CM_CHAR_GET_PRIVATE (chr);
91- priv->reading = NULL;
92- priv->utf8 = NULL;
93-}
94-
95-static void
96-dispose (GObject *object)
97-{
98- CmCharPrivate *priv = CM_CHAR_GET_PRIVATE(object);
99-
100- if (priv->reading)
101- g_free(priv->reading);
102- if (priv->utf8)
103- g_free(priv->utf8);
104-
105- priv->reading = NULL;
106- priv->utf8 = NULL;
107-
108- G_OBJECT_CLASS(cm_char_parent_class)->dispose(object);
109-}
110-
111-static void
112-set_property (GObject *object,
113- guint prop_id,
114- const GValue *value,
115- GParamSpec *pspec)
116-{
117- CmChar *chr;
118-
119- chr = CM_CHAR(object);
120- switch (prop_id) {
121- case PROP_READING:
122- cm_char_set_reading(chr, g_value_get_string(value));
123- break;
124- case PROP_UTF8:
125- cm_char_set_utf8(chr, g_value_get_string(value));
126- break;
127- default:
128- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
129- break;
130- }
131-}
132-
133-static void
134-get_property (GObject *object,
135- guint prop_id,
136- GValue *value,
137- GParamSpec *pspec)
138-{
139- CmChar *chr;
140- CmCharPrivate *priv;
141-
142- chr = CM_CHAR(object);
143- priv = CM_CHAR_GET_PRIVATE(chr);
144-
145- switch (prop_id) {
146- case PROP_READING:
147- g_value_set_string(value, priv->reading);
148- break;
149- case PROP_UTF8:
150- g_value_set_string(value, priv->utf8);
151- break;
152- default:
153- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
154- break;
155- }
156-}
157-
158-/**
159- * cm_char_new:
160- *
161- * Create a new #CmChar.
162- *
163- * Return value: a new #CmChar
164- */
165-CmChar*
166-cm_char_new (const gchar *reading, const gchar *utf8)
167-{
168- return g_object_new(CM_TYPE_CHAR,
169- "reading", reading,
170- "utf8", utf8,
171- NULL);
172-}
173-
174-const gchar *
175-cm_char_get_reading (CmChar *chr)
176-{
177- g_return_val_if_fail(CM_IS_CHAR(chr), NULL);
178- return CM_CHAR_GET_PRIVATE(chr)->reading;
179-}
180-
181-const gchar *
182-cm_char_get_utf8 (CmChar *chr)
183-{
184- g_return_val_if_fail(CM_IS_CHAR(chr), NULL);
185- return CM_CHAR_GET_PRIVATE(chr)->utf8;
186-}
187-
188-void
189-cm_char_set_reading (CmChar *chr, const gchar *reading)
190-{
191- CmCharPrivate *priv;
192- g_return_if_fail(CM_IS_CHAR(chr));
193-
194- priv = CM_CHAR_GET_PRIVATE(chr);
195- if (priv->reading)
196- g_free(priv->reading);
197- priv->reading = NULL;
198-
199- if (reading)
200- priv->reading = g_strdup(priv->reading);
201-}
202-
203-void
204-cm_char_set_utf8 (CmChar *chr, const gchar *utf8)
205-{
206- CmCharPrivate *priv;
207- g_return_if_fail(CM_IS_CHAR(chr));
208-
209- priv = CM_CHAR_GET_PRIVATE(chr);
210- if (priv->utf8)
211- g_free(priv->utf8);
212- priv->utf8 = NULL;
213-
214- if (utf8)
215- priv->utf8 = g_strdup(priv->utf8);
216-}
217-
218-/*
219-vi:ts=4:nowrap:ai:expandtab
220-*/
--- comatz/trunk/comatz/Makefile.am (revision 11)
+++ comatz/trunk/comatz/Makefile.am (revision 12)
@@ -24,7 +24,7 @@
2424 INCLUDES = $(COMATZ_CFLAGS)
2525
2626 comatz_public_h_sources = \
27- cm-char.h \
27+ cm-word.h \
2828 cm-dict.h \
2929 cm-module.h \
3030 cm-module-impl.h
@@ -53,7 +53,7 @@
5353 libcomatz_la_SOURCES = \
5454 comatz.c \
5555 cm-module.c \
56- cm-char.c \
56+ cm-word.c \
5757 cm-dict.c \
5858 @enum_types_prefix@.c
5959
--- comatz/trunk/comatz/cm-word.c (nonexistent)
+++ comatz/trunk/comatz/cm-word.c (revision 12)
@@ -0,0 +1,220 @@
1+/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+/*
4+ * Copyright (C) 2007 Kouhei Sutou <kou@cozmixng.org>
5+ *
6+ * This library is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2 of the License, or (at your option) any later version.
10+ *
11+ * This library is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with this program; if not, write to the
18+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19+ * Boston, MA 02111-1307 USA
20+ */
21+
22+#ifdef HAVE_CONFIG_H
23+# include "config.h"
24+#endif /* HAVE_CONFIG_H */
25+
26+#include <glib/gi18n.h>
27+
28+#include "cm-word.h"
29+
30+#define CM_WORD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CM_TYPE_WORD, CmWordPrivate))
31+
32+typedef struct _CmWordPrivate CmWordPrivate;
33+struct _CmWordPrivate
34+{
35+ gword *reading;
36+ gword *utf8;
37+};
38+
39+enum
40+{
41+ PROP_0,
42+ PROP_READING,
43+ PROP_UTF8
44+};
45+
46+G_DEFINE_TYPE (CmWord, cm_word, G_TYPE_OBJECT)
47+
48+static void dispose (GObject *object);
49+static void set_property (GObject *object,
50+ guint prop_id,
51+ const GValue *value,
52+ GParamSpec *pspec);
53+static void get_property (GObject *object,
54+ guint prop_id,
55+ GValue *value,
56+ GParamSpec *pspec);
57+
58+static void
59+cm_word_class_init (CmWordClass *klass)
60+{
61+ GObjectClass *gobject_class;
62+ GParamSpec *spec;
63+
64+ gobject_class = G_OBJECT_CLASS (klass);
65+
66+ gobject_class->dispose = dispose;
67+ gobject_class->set_property = set_property;
68+ gobject_class->get_property = get_property;
69+
70+ spec = g_param_spec_string("reading",
71+ N_("UTF8"),
72+ N_("UTF8 encoding of the wordacter."),
73+ NULL,
74+ G_PARAM_READABLE | G_PARAM_WRITABLE);
75+ g_object_class_install_property(gobject_class, PROP_READING, spec);
76+
77+ spec = g_param_spec_string("utf8",
78+ N_("UTF8"),
79+ N_("UTF8 encoding of the wordacter."),
80+ NULL,
81+ G_PARAM_READABLE | G_PARAM_WRITABLE);
82+ g_object_class_install_property(gobject_class, PROP_UTF8, spec);
83+
84+ g_type_class_add_private (gobject_class, sizeof(CmWordPrivate));
85+}
86+
87+static void
88+cm_word_init (CmWord *word)
89+{
90+ CmWordPrivate *priv = CM_WORD_GET_PRIVATE (word);
91+ priv->reading = NULL;
92+ priv->utf8 = NULL;
93+}
94+
95+static void
96+dispose (GObject *object)
97+{
98+ CmWordPrivate *priv = CM_WORD_GET_PRIVATE(object);
99+
100+ if (priv->reading)
101+ g_free(priv->reading);
102+ if (priv->utf8)
103+ g_free(priv->utf8);
104+
105+ priv->reading = NULL;
106+ priv->utf8 = NULL;
107+
108+ G_OBJECT_CLASS(cm_word_parent_class)->dispose(object);
109+}
110+
111+static void
112+set_property (GObject *object,
113+ guint prop_id,
114+ const GValue *value,
115+ GParamSpec *pspec)
116+{
117+ CmWord *word;
118+
119+ word = CM_WORD(object);
120+ switch (prop_id) {
121+ case PROP_READING:
122+ cm_word_set_reading(word, g_value_get_string(value));
123+ break;
124+ case PROP_UTF8:
125+ cm_word_set_utf8(word, g_value_get_string(value));
126+ break;
127+ default:
128+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
129+ break;
130+ }
131+}
132+
133+static void
134+get_property (GObject *object,
135+ guint prop_id,
136+ GValue *value,
137+ GParamSpec *pspec)
138+{
139+ CmWord *word;
140+ CmWordPrivate *priv;
141+
142+ word = CM_WORD(object);
143+ priv = CM_WORD_GET_PRIVATE(word);
144+
145+ switch (prop_id) {
146+ case PROP_READING:
147+ g_value_set_string(value, priv->reading);
148+ break;
149+ case PROP_UTF8:
150+ g_value_set_string(value, priv->utf8);
151+ break;
152+ default:
153+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
154+ break;
155+ }
156+}
157+
158+/**
159+ * cm_word_new:
160+ *
161+ * Create a new #CmWord.
162+ *
163+ * Return value: a new #CmWord
164+ */
165+CmWord*
166+cm_word_new (const gword *reading, const gword *utf8)
167+{
168+ return g_object_new(CM_TYPE_WORD,
169+ "reading", reading,
170+ "utf8", utf8,
171+ NULL);
172+}
173+
174+const gword *
175+cm_word_get_reading (CmWord *word)
176+{
177+ g_return_val_if_fail(CM_IS_WORD(word), NULL);
178+ return CM_WORD_GET_PRIVATE(word)->reading;
179+}
180+
181+const gword *
182+cm_word_get_utf8 (CmWord *word)
183+{
184+ g_return_val_if_fail(CM_IS_WORD(word), NULL);
185+ return CM_WORD_GET_PRIVATE(word)->utf8;
186+}
187+
188+void
189+cm_word_set_reading (CmWord *word, const gword *reading)
190+{
191+ CmWordPrivate *priv;
192+ g_return_if_fail(CM_IS_WORD(word));
193+
194+ priv = CM_WORD_GET_PRIVATE(word);
195+ if (priv->reading)
196+ g_free(priv->reading);
197+ priv->reading = NULL;
198+
199+ if (reading)
200+ priv->reading = g_strdup(priv->reading);
201+}
202+
203+void
204+cm_word_set_utf8 (CmWord *word, const gword *utf8)
205+{
206+ CmWordPrivate *priv;
207+ g_return_if_fail(CM_IS_WORD(word));
208+
209+ priv = CM_WORD_GET_PRIVATE(word);
210+ if (priv->utf8)
211+ g_free(priv->utf8);
212+ priv->utf8 = NULL;
213+
214+ if (utf8)
215+ priv->utf8 = g_strdup(priv->utf8);
216+}
217+
218+/*
219+vi:ts=4:nowrap:ai:expandtab
220+*/
--- comatz/trunk/comatz/cm-word.h (nonexistent)
+++ comatz/trunk/comatz/cm-word.h (revision 12)
@@ -0,0 +1,66 @@
1+/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+/*
4+ * Copyright (C) 2007 Kouhei Sutou <kou@cozmixng.org>
5+ *
6+ * This library is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2 of the License, or (at your option) any later version.
10+ *
11+ * This library is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with this program; if not, write to the
18+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19+ * Boston, MA 02111-1307 USA
20+ */
21+
22+#ifndef __CM_WORD_H__
23+#define __CM_WORD_H__
24+
25+#include <glib-object.h>
26+
27+G_BEGIN_DECLS
28+
29+#define CM_TYPE_WORD (cm_word_get_type())
30+#define CM_WORD(o) (G_TYPE_CHECK_INSTANCE_CAST((o), CM_TYPE_WORD, CmWord))
31+#define CM_IS_WORD(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), CM_TYPE_WORD))
32+#define CM_WORD_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), CM_TYPE_WORD, CmWordIFace))
33+
34+typedef struct _CmWord CmWord;
35+typedef struct _CmWordClass CmWordClass;
36+
37+struct _CmWord
38+{
39+ GObject *object;
40+};
41+
42+struct _CmWordClass
43+{
44+ GObjectClass parent;
45+};
46+
47+GType cm_word_get_type (void) G_GNUC_CONST;
48+
49+CmWord *cm_word_new (const gword *reading,
50+ const gword *utf8);
51+
52+const gword *cm_word_get_reading (CmWord *word);
53+const gword *cm_word_get_utf8 (CmWord *word);
54+
55+void cm_word_set_reading (CmWord *word,
56+ const gword *reading);
57+void cm_word_set_utf8 (CmWord *word,
58+ const gword *utf8);
59+
60+G_END_DECLS
61+
62+#endif /* __CM_WORD_H__ */
63+
64+/*
65+vi:ts=4:nowrap:ai:expandtab
66+*/
Show on old repository browser