You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
(58) |
May
(28) |
Jun
(308) |
Jul
(11) |
Aug
(1) |
Sep
|
Oct
(3) |
Nov
(4) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(4) |
Feb
(8) |
Mar
(3) |
Apr
(3) |
May
(8) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(1) |
2009 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ik...@us...> - 2007-06-18 02:45:41
|
Revision: 1513 http://tomoe.svn.sourceforge.net/tomoe/?rev=1513&view=rev Author: ikezoe Date: 2007-06-17 19:45:43 -0700 (Sun, 17 Jun 2007) Log Message: ----------- * bindings/ruby/tomoe-rb-dict.c: Implement copy() function. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/bindings/ruby/tomoe-rb-dict.c Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 11:46:33 UTC (rev 1512) +++ tomoe/trunk/ChangeLog 2007-06-18 02:45:43 UTC (rev 1513) @@ -1,3 +1,7 @@ +2007-06-18 Hiroyuki Ikezoe <poi...@ik...> + + * bindings/ruby/tomoe-rb-dict.c: Implement copy() function. + 2007-06-17 Kouhei Sutou <ko...@co...> * test/python/*.py: fixed encoding preamble(?). Modified: tomoe/trunk/bindings/ruby/tomoe-rb-dict.c =================================================================== --- tomoe/trunk/bindings/ruby/tomoe-rb-dict.c 2007-06-17 11:46:33 UTC (rev 1512) +++ tomoe/trunk/bindings/ruby/tomoe-rb-dict.c 2007-06-18 02:45:43 UTC (rev 1513) @@ -84,6 +84,12 @@ return CBOOL2RVAL(tomoe_dict_flush(_SELF(self))); } +static VALUE +td_copy(VALUE self, VALUE dest_dict) +{ + return CBOOL2RVAL(tomoe_dict_copy(_SELF(self), RVAL2TDIC(dest_dict))); +} + void _tomoe_rb_init_tomoe_dict(VALUE _mTomoe) { @@ -109,4 +115,5 @@ rb_define_method(cTomoeDict, "available_private_utf8", td_get_available_private_utf8, 0); rb_define_method(cTomoeDict, "flush", td_flush, 0); + rb_define_method(cTomoeDict, "copy", td_copy, 1); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 11:46:32
|
Revision: 1512 http://tomoe.svn.sourceforge.net/tomoe/?rev=1512&view=rev Author: ikezoe Date: 2007-06-17 04:46:33 -0700 (Sun, 17 Jun 2007) Log Message: ----------- * module/dict/tomoe-dict-unihan.c: Now TomoeDictUnihan is a singleton object. But it is fragile because _tomoe_unihan_create() takes a lot of time. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/module/dict/tomoe-dict-unihan.c Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 11:17:06 UTC (rev 1511) +++ tomoe/trunk/ChangeLog 2007-06-17 11:46:33 UTC (rev 1512) @@ -28,6 +28,9 @@ * test/python/test_common.py, test/python/test_recognizer.py: parseStrokeData() was moved into test_common.py. * test/python/test_context.py: Implement all tests. + * module/dict/tomoe-dict-unihan.c: Now TomoeDictUnihan is a singleton + object. But it is fragile because _tomoe_unihan_create() takes a lot + of time. 2007-06-15 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/module/dict/tomoe-dict-unihan.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-unihan.c 2007-06-17 11:17:06 UTC (rev 1511) +++ tomoe/trunk/module/dict/tomoe-dict-unihan.c 2007-06-17 11:46:33 UTC (rev 1512) @@ -69,13 +69,12 @@ static GType tomoe_type_dict_unihan = 0; static TomoeDictPtrArray *parent_class; -static guint chars_ref_count = 0; +static TomoeDictUnihan *the_singleton = NULL; static GObject *constructor (GType type, guint n_props, GObjectConstructParam *props); static void dispose (GObject *object); -static void finalize (GObject *object); static void set_property (GObject *object, guint prop_id, const GValue *value, @@ -102,7 +101,6 @@ gobject_class->constructor = constructor; gobject_class->dispose = dispose; - gobject_class->finalize = finalize; gobject_class->set_property = set_property; gobject_class->get_property = get_property; @@ -190,12 +188,16 @@ GObject *object; GObjectClass *klass = G_OBJECT_CLASS (parent_class); - object = klass->constructor (type, n_props, props); + if (!the_singleton) { + GPtrArray *chars; + object = klass->constructor (type, n_props, props); + the_singleton = TOMOE_DICT_UNIHAN (object); - chars_ref_count++; - if (chars_ref_count == 1) { - GPtrArray *chars = _tomoe_dict_ptr_array_get_array (TOMOE_DICT_PTR_ARRAY (object)); + chars = _tomoe_dict_ptr_array_get_array (TOMOE_DICT_PTR_ARRAY (object)); _tomoe_unihan_create (chars); + + } else { + object = g_object_ref (G_OBJECT (the_singleton)); } return object; @@ -254,16 +256,6 @@ G_OBJECT_CLASS (parent_class)->dispose (object); } -static void -finalize (GObject *object) -{ - chars_ref_count--; - if (chars_ref_count == 0) { - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - static const gchar* get_name (TomoeDict *_dict) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 11:17:10
|
Revision: 1511 http://tomoe.svn.sourceforge.net/tomoe/?rev=1511&view=rev Author: ikezoe Date: 2007-06-17 04:17:06 -0700 (Sun, 17 Jun 2007) Log Message: ----------- added. Modified Paths: -------------- tomoe/trunk/test/python/Makefile.am Added Paths: ----------- tomoe/trunk/test/python/test_dict_mysql.py Modified: tomoe/trunk/test/python/Makefile.am =================================================================== --- tomoe/trunk/test/python/Makefile.am 2007-06-17 11:16:27 UTC (rev 1510) +++ tomoe/trunk/test/python/Makefile.am 2007-06-17 11:17:06 UTC (rev 1511) @@ -29,6 +29,7 @@ test_char.py \ test_dict.py \ test_dict_est.py \ + test_dict_mysql.py \ test_dict_unihan.py \ test_dict_xml.py \ test_query.py \ Added: tomoe/trunk/test/python/test_dict_mysql.py =================================================================== --- tomoe/trunk/test/python/test_dict_mysql.py (rev 0) +++ tomoe/trunk/test/python/test_dict_mysql.py 2007-06-17 11:17:06 UTC (rev 1511) @@ -0,0 +1,11 @@ +# encoding: utf-8 +import os +import sys +import shutil +import unittest +import tomoe +import test_dict + +class TomoeDictMySQLTest(test_dict.TomoeDictTest): + +# vi:ts=4:nowrap:ai:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 11:16:26
|
Revision: 1510 http://tomoe.svn.sourceforge.net/tomoe/?rev=1510&view=rev Author: ikezoe Date: 2007-06-17 04:16:27 -0700 (Sun, 17 Jun 2007) Log Message: ----------- test only building dict modules Modified Paths: -------------- tomoe/trunk/test/python/runtests.py Modified: tomoe/trunk/test/python/runtests.py =================================================================== --- tomoe/trunk/test/python/runtests.py 2007-06-17 10:36:31 UTC (rev 1509) +++ tomoe/trunk/test/python/runtests.py 2007-06-17 11:16:27 UTC (rev 1510) @@ -6,7 +6,8 @@ import unittest import test_common -SKIP_FILES = ['runtests', 'test_dict', 'test_common'] +dict_modules = os.getenv('DICT_MODULES').split() +SKIP_FILES = ['runtests', 'test_dict', 'test_common', 'test_dict_est', 'test_dict_mysql', 'test_dict_unihan', 'test_dict_xml'] dir = os.path.split(os.path.abspath(__file__))[0] os.chdir(dir) @@ -14,6 +15,8 @@ def gettestnames(): files = glob.glob('*.py') names = map(lambda x: x[:-3], files) + dict_files = map(lambda x: 'test_dict_'+x , dict_modules) + map(SKIP_FILES.remove, dict_files) map(names.remove, SKIP_FILES) return names This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 10:36:32
|
Revision: 1509 http://tomoe.svn.sourceforge.net/tomoe/?rev=1509&view=rev Author: ikezoe Date: 2007-06-17 03:36:31 -0700 (Sun, 17 Jun 2007) Log Message: ----------- add encoding attribute. Modified Paths: -------------- tomoe/trunk/test/data/test-dict.xml Modified: tomoe/trunk/test/data/test-dict.xml =================================================================== --- tomoe/trunk/test/data/test-dict.xml 2007-06-17 08:45:44 UTC (rev 1508) +++ tomoe/trunk/test/data/test-dict.xml 2007-06-17 10:36:31 UTC (rev 1509) @@ -1,4 +1,4 @@ -<?xml version="1.0" standalone="no"?> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE dictionary SYSTEM "/usr/share/tomoe/dict.dtd"> <dictionary> <character> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 08:45:44
|
Revision: 1508 http://tomoe.svn.sourceforge.net/tomoe/?rev=1508&view=rev Author: ikezoe Date: 2007-06-17 01:45:44 -0700 (Sun, 17 Jun 2007) Log Message: ----------- * test/python/test_context.py: Implement all tests. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/test/python/test_common.py Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 08:44:35 UTC (rev 1507) +++ tomoe/trunk/ChangeLog 2007-06-17 08:45:44 UTC (rev 1508) @@ -27,6 +27,7 @@ * test/data/test-dict.xml: Added stroke data. * test/python/test_common.py, test/python/test_recognizer.py: parseStrokeData() was moved into test_common.py. + * test/python/test_context.py: Implement all tests. 2007-06-15 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/test/python/test_common.py =================================================================== --- tomoe/trunk/test/python/test_common.py 2007-06-17 08:44:35 UTC (rev 1507) +++ tomoe/trunk/test/python/test_common.py 2007-06-17 08:45:44 UTC (rev 1508) @@ -11,4 +11,19 @@ data_dir = os.path.join(top_dir, 'data') test_data_dir = os.path.join(top_dir, 'test', 'data') +def parseStrokeData(file): + writing = tomoe.Writing() + lines = open(file, 'r').readlines() + results = lines.pop(0) + for line in lines: + points = line.split(',') + first_point = points.pop(0) + x, y = first_point.split() + writing.move_to(int(x), int(y)) + for point in points: + x, y = point.split() + writing.line_to(int(x), int(y)) + + return results, writing + # vi:ts=4:nowrap:ai:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 08:44:33
|
Revision: 1507 http://tomoe.svn.sourceforge.net/tomoe/?rev=1507&view=rev Author: ikezoe Date: 2007-06-17 01:44:35 -0700 (Sun, 17 Jun 2007) Log Message: ----------- * test/python/test_common.py, test/python/test_recognizer.py: parseStrokeData() was moved into test_common.py. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/test/python/test_context.py tomoe/trunk/test/python/test_recognizer.py Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 08:41:47 UTC (rev 1506) +++ tomoe/trunk/ChangeLog 2007-06-17 08:44:35 UTC (rev 1507) @@ -25,6 +25,8 @@ * test/python/test_dict_xml.py: Use test-dict.xml. * test/python/test_context.py: Use test-dict.xml. * test/data/test-dict.xml: Added stroke data. + * test/python/test_common.py, test/python/test_recognizer.py: + parseStrokeData() was moved into test_common.py. 2007-06-15 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/test/python/test_context.py =================================================================== --- tomoe/trunk/test/python/test_context.py 2007-06-17 08:41:47 UTC (rev 1506) +++ tomoe/trunk/test/python/test_context.py 2007-06-17 08:44:35 UTC (rev 1507) @@ -28,6 +28,9 @@ """ % (self.dict_name) config_file.write(contents) config_file.close() + + self.context = tomoe.Context() + self.context.load_config(self.config_filename) def tearDown(self): if os.access(self.config_filename, os.F_OK): @@ -36,46 +39,51 @@ if os.access(self.dict_name, os.F_OK): os.unlink(self.dict_name) - def testLoadConfig(self): - context = tomoe.Context() - context.load_config(self.config_filename) - self.assert_(False) + def testSearchByStrokes(self): + char_code = '池' + stroke_file = os.path.join(test_common.test_data_dir, 'ike.data') - def testSearch(self): - self.assert_(False) + results, writing = test_common.parseStrokeData(stroke_file) - def testGetChar(self): - context = tomoe.Context() - context.load_config(self.config_filename) + tomoe_query = tomoe.Query() + tomoe_query.set_writing(writing) + candidates = self.context.search(tomoe_query) + self.assertEqual(char_code, candidates[0].get_char().get_utf8()) + + def testSearchByQuery(self): char_code = '池' - tomoe_char = context.get_char(char_code) + reading = 'チ' + tomoe_reading = tomoe.Reading(tomoe.READING_UNKNOWN, reading) + tomoe_query = tomoe.Query() + tomoe_query.add_reading(tomoe_reading) + + candidates = self.context.search(tomoe_query) + self.assertEqual(char_code, candidates[0].get_char().get_utf8()) + + def testGetChar(self): + char_code = '池' + tomoe_char = self.context.get_char(char_code) self.assertEqual(char_code, tomoe_char.get_utf8()) def testRegister(self): - context = tomoe.Context() - context.load_config(self.config_filename) - char_code = '地' - tomoe_char = context.get_char(char_code) + tomoe_char = self.context.get_char(char_code) self.assertEqual(None, tomoe_char) tomoe_char = tomoe.Char(char_code) - self.assert_(context.register(tomoe_char)) + self.assert_(self.context.register(tomoe_char)) - tomoe_char = context.get_char(char_code) + tomoe_char = self.context.get_char(char_code) self.assertNotEqual(None, tomoe_char) self.assertEqual(char_code, tomoe_char.get_utf8()) def testUnregister(self): - context = tomoe.Context() - context.load_config(self.config_filename) - char_code = '池' - tomoe_char = context.get_char(char_code) + tomoe_char = self.context.get_char(char_code) self.assertEqual(char_code, tomoe_char.get_utf8()) - self.assert_(context.unregister(char_code)) - self.assertEqual(None, context.get_char(char_code)) + self.assert_(self.context.unregister(char_code)) + self.assertEqual(None, self.context.get_char(char_code)) # vi:ts=4:nowrap:ai:expandtab Modified: tomoe/trunk/test/python/test_recognizer.py =================================================================== --- tomoe/trunk/test/python/test_recognizer.py 2007-06-17 08:41:47 UTC (rev 1506) +++ tomoe/trunk/test/python/test_recognizer.py 2007-06-17 08:44:35 UTC (rev 1507) @@ -14,25 +14,10 @@ self.writings = [] self.results = [] for file in glob.glob(os.path.join(test_common.test_data_dir, '*.data')): - results, writing = self.parseStrokeData(file) + results, writing = test_common.parseStrokeData(file) self.writings.append(writing) self.results.append(results) - def parseStrokeData(self, file): - writing = tomoe.Writing() - lines = open(file, 'r').readlines() - results = lines.pop(0) - for line in lines: - points = line.split(',') - first_point = points.pop(0) - x, y = first_point.split() - writing.move_to(int(x), int(y)) - for point in points: - x, y = point.split() - writing.line_to(int(x), int(y)) - - return results, writing - def testStrokeSearch(self): for writing, result in zip(self.writings, self.results): for a, b in zip(self.recognizer.search(writing), result.split()): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 08:41:49
|
Revision: 1506 http://tomoe.svn.sourceforge.net/tomoe/?rev=1506&view=rev Author: ikezoe Date: 2007-06-17 01:41:47 -0700 (Sun, 17 Jun 2007) Log Message: ----------- * test/data/test-dict.xml: Added stroke data. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/test/data/test-dict.xml Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 07:49:18 UTC (rev 1505) +++ tomoe/trunk/ChangeLog 2007-06-17 08:41:47 UTC (rev 1506) @@ -24,6 +24,7 @@ * test/data/test-dict.xml: Added. * test/python/test_dict_xml.py: Use test-dict.xml. * test/python/test_context.py: Use test-dict.xml. + * test/data/test-dict.xml: Added stroke data. 2007-06-15 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/test/data/test-dict.xml =================================================================== --- tomoe/trunk/test/data/test-dict.xml 2007-06-17 07:49:18 UTC (rev 1505) +++ tomoe/trunk/test/data/test-dict.xml 2007-06-17 08:41:47 UTC (rev 1506) @@ -10,6 +10,35 @@ <reading type="ja_kun">いけ</reading> <reading type="ja_unknown">あんのうん</reading> </readings> + <strokes> + <stroke> + <point x="123" y="223"/> + <point x="216" y="343"/> + </stroke> + <stroke> + <point x="103" y="530"/> + <point x="230" y="636"/> + </stroke> + <stroke> + <point x="116" y="910"/> + <point x="260" y="773"/> + </stroke> + <stroke> + <point x="373" y="400"/> + <point x="773" y="316"/> + <point x="703" y="580"/> + </stroke> + <stroke> + <point x="643" y="216"/> + <point x="636" y="480"/> + </stroke> + <stroke> + <point x="493" y="200"/> + <point x="503" y="780"/> + <point x="810" y="850"/> + <point x="853" y="753"/> + </stroke> + </strokes> <meta> <jis208>35-51</jis208> <ucs>6c60</ucs> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 07:49:16
|
Revision: 1505 http://tomoe.svn.sourceforge.net/tomoe/?rev=1505&view=rev Author: ikezoe Date: 2007-06-17 00:49:18 -0700 (Sun, 17 Jun 2007) Log Message: ----------- * test/python/test_context.py: Use test-dict.xml. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/test/python/test_context.py Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 07:23:08 UTC (rev 1504) +++ tomoe/trunk/ChangeLog 2007-06-17 07:49:18 UTC (rev 1505) @@ -23,6 +23,7 @@ * lib/tomoe-dict.c: Call copy() only if the class has copy function. * test/data/test-dict.xml: Added. * test/python/test_dict_xml.py: Use test-dict.xml. + * test/python/test_context.py: Use test-dict.xml. 2007-06-15 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/test/python/test_context.py =================================================================== --- tomoe/trunk/test/python/test_context.py 2007-06-17 07:23:08 UTC (rev 1504) +++ tomoe/trunk/test/python/test_context.py 2007-06-17 07:49:18 UTC (rev 1505) @@ -1,6 +1,7 @@ # encoding: utf-8 import os import sys +import shutil import glob import unittest import test_common @@ -9,18 +10,22 @@ class TomoeContextTest(unittest.TestCase): def setUp(self): + test_dict_name = os.path.join(test_common.test_data_dir, 'test-dict.xml') + self.dict_name = "tomoe-test-xmldict.xml" + shutil.copy(test_dict_name, self.dict_name) + self.config_filename = "test-config" config_file = open(self.config_filename, "w") contents = """ [config] use-system-dictionaries = false -user-dictionary = user-dict +user-dictionary = test languages = ja;zh_CN [test-dictionary] type = xml -file = test-dict.xml - """ +file = %s + """ % (self.dict_name) config_file.write(contents) config_file.close() @@ -28,6 +33,9 @@ if os.access(self.config_filename, os.F_OK): os.unlink(self.config_filename) + if os.access(self.dict_name, os.F_OK): + os.unlink(self.dict_name) + def testLoadConfig(self): context = tomoe.Context() context.load_config(self.config_filename) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 07:23:29
|
Revision: 1504 http://tomoe.svn.sourceforge.net/tomoe/?rev=1504&view=rev Author: ikezoe Date: 2007-06-17 00:23:08 -0700 (Sun, 17 Jun 2007) Log Message: ----------- * test/data/test-dict.xml: Added. * test/python/test_dict_xml.py: Use test-dict.xml. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/test/data/Makefile.am tomoe/trunk/test/python/test_dict_xml.py Added Paths: ----------- tomoe/trunk/test/data/test-dict.xml Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 05:20:02 UTC (rev 1503) +++ tomoe/trunk/ChangeLog 2007-06-17 07:23:08 UTC (rev 1504) @@ -21,6 +21,8 @@ TomoeDictPtrArray object. * module/dict/tomoe-unihan.[ch]: Adapt to TomoeDictPtrArray. * lib/tomoe-dict.c: Call copy() only if the class has copy function. + * test/data/test-dict.xml: Added. + * test/python/test_dict_xml.py: Use test-dict.xml. 2007-06-15 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/test/data/Makefile.am =================================================================== --- tomoe/trunk/test/data/Makefile.am 2007-06-17 05:20:02 UTC (rev 1503) +++ tomoe/trunk/test/data/Makefile.am 2007-06-17 07:23:08 UTC (rev 1504) @@ -18,7 +18,7 @@ ## Free Software Foundation, Inc., 59 Temple Place, Suite 330, ## Boston, MA 02111-1307 USA -EXTRA_DIST = \ +stroke_FILES = \ aki.data \ asi.data \ fuyu.data \ @@ -32,3 +32,10 @@ niku.data \ one_stroke.data \ su.data + +dict_FILES = \ + test-dict.xml + +EXTRA_DIST = \ + $(stroke_FILES) \ + $(dict_FILES) Added: tomoe/trunk/test/data/test-dict.xml =================================================================== --- tomoe/trunk/test/data/test-dict.xml (rev 0) +++ tomoe/trunk/test/data/test-dict.xml 2007-06-17 07:23:08 UTC (rev 1504) @@ -0,0 +1,20 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE dictionary SYSTEM "/usr/share/tomoe/dict.dtd"> +<dictionary> + <character> + <utf8>池</utf8> + <number-of-strokes>6</number-of-strokes> + <readings> + <reading type="ja_on">タ</reading> + <reading type="ja_on">チ</reading> + <reading type="ja_kun">いけ</reading> + <reading type="ja_unknown">あんのうん</reading> + </readings> + <meta> + <jis208>35-51</jis208> + <ucs>6c60</ucs> + <jouyou>2</jouyou> + <meaning>pond, cistern, pool, reservoir</meaning> + </meta> + </character> +</dictionary> Modified: tomoe/trunk/test/python/test_dict_xml.py =================================================================== --- tomoe/trunk/test/python/test_dict_xml.py 2007-06-17 05:20:02 UTC (rev 1503) +++ tomoe/trunk/test/python/test_dict_xml.py 2007-06-17 07:23:08 UTC (rev 1504) @@ -1,38 +1,17 @@ # encoding: utf-8 import os import sys +import shutil import unittest +import test_common import tomoe import test_dict class TomoeDictXMLTest(test_dict.TomoeDictTest): def setUp(self): + test_dict_name = os.path.join(test_common.test_data_dir, 'test-dict.xml') self.dict_name = "tomoe-test-xmldict.xml" - dict_file = open(self.dict_name, "w") - contents = """ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE dictionary SYSTEM "/usr/share/tomoe/dict.dtd"> -<dictionary> - <character> - <utf8>池</utf8> - <number-of-strokes>6</number-of-strokes> - <readings> - <reading type="ja_on">タ</reading> - <reading type="ja_on">チ</reading> - <reading type="ja_kun">いけ</reading> - <reading type="ja_unknown">あんのうん</reading> - </readings> - <meta> - <jis208>35-51</jis208> - <ucs>6c60</ucs> - <jouyou>2</jouyou> - <meaning>pond, cistern, pool, reservoir</meaning> - </meta> - </character> -</dictionary> - """ - dict_file.write(contents) - dict_file.close() + shutil.copy(test_dict_name, self.dict_name) self.dict = tomoe.Dict("XML", filename = self.dict_name, editable = True) def tearDown(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kt...@us...> - 2007-06-17 05:20:01
|
Revision: 1503 http://tomoe.svn.sourceforge.net/tomoe/?rev=1503&view=rev Author: ktou Date: 2007-06-16 22:20:02 -0700 (Sat, 16 Jun 2007) Log Message: ----------- * test/python/*.py: fixed encoding preamble(?). Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/test/python/test_candidate.py tomoe/trunk/test/python/test_char.py tomoe/trunk/test/python/test_common.py tomoe/trunk/test/python/test_config.py tomoe/trunk/test/python/test_context.py tomoe/trunk/test/python/test_dict.py tomoe/trunk/test/python/test_dict_est.py tomoe/trunk/test/python/test_dict_unihan.py tomoe/trunk/test/python/test_dict_xml.py tomoe/trunk/test/python/test_query.py tomoe/trunk/test/python/test_reading.py tomoe/trunk/test/python/test_recognizer.py tomoe/trunk/test/python/test_shelf.py tomoe/trunk/test/python/test_writing.py Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/ChangeLog 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,5 +1,7 @@ 2007-06-17 Kouhei Sutou <ko...@co...> + * test/python/*.py: fixed encoding preamble(?). + * macros/python.m4: - disabled Python bindings not error if pygobject-2.0 package is not found. Modified: tomoe/trunk/test/python/test_candidate.py =================================================================== --- tomoe/trunk/test/python/test_candidate.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_candidate.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import glob Modified: tomoe/trunk/test/python/test_char.py =================================================================== --- tomoe/trunk/test/python/test_char.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_char.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import unittest Modified: tomoe/trunk/test/python/test_common.py =================================================================== --- tomoe/trunk/test/python/test_common.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_common.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import glob import os import sys Modified: tomoe/trunk/test/python/test_config.py =================================================================== --- tomoe/trunk/test/python/test_config.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_config.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import glob Modified: tomoe/trunk/test/python/test_context.py =================================================================== --- tomoe/trunk/test/python/test_context.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_context.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import glob Modified: tomoe/trunk/test/python/test_dict.py =================================================================== --- tomoe/trunk/test/python/test_dict.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_dict.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import shutil Modified: tomoe/trunk/test/python/test_dict_est.py =================================================================== --- tomoe/trunk/test/python/test_dict_est.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_dict_est.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import shutil Modified: tomoe/trunk/test/python/test_dict_unihan.py =================================================================== --- tomoe/trunk/test/python/test_dict_unihan.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_dict_unihan.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import unittest Modified: tomoe/trunk/test/python/test_dict_xml.py =================================================================== --- tomoe/trunk/test/python/test_dict_xml.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_dict_xml.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import unittest Modified: tomoe/trunk/test/python/test_query.py =================================================================== --- tomoe/trunk/test/python/test_query.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_query.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import unittest Modified: tomoe/trunk/test/python/test_reading.py =================================================================== --- tomoe/trunk/test/python/test_reading.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_reading.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import unittest Modified: tomoe/trunk/test/python/test_recognizer.py =================================================================== --- tomoe/trunk/test/python/test_recognizer.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_recognizer.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import glob Modified: tomoe/trunk/test/python/test_shelf.py =================================================================== --- tomoe/trunk/test/python/test_shelf.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_shelf.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import glob Modified: tomoe/trunk/test/python/test_writing.py =================================================================== --- tomoe/trunk/test/python/test_writing.py 2007-06-17 04:58:32 UTC (rev 1502) +++ tomoe/trunk/test/python/test_writing.py 2007-06-17 05:20:02 UTC (rev 1503) @@ -1,4 +1,4 @@ -# -*- coding: UTF=8 -*- +# encoding: utf-8 import os import sys import glob This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kt...@us...> - 2007-06-17 04:58:30
|
Revision: 1502 http://tomoe.svn.sourceforge.net/tomoe/?rev=1502&view=rev Author: ktou Date: 2007-06-16 21:58:32 -0700 (Sat, 16 Jun 2007) Log Message: ----------- * macros/python.m4: used $CPPFLAGS not $CFLAGS. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/macros/python.m4 Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 04:32:20 UTC (rev 1501) +++ tomoe/trunk/ChangeLog 2007-06-17 04:58:32 UTC (rev 1502) @@ -5,6 +5,7 @@ package is not found. - removed needless spaces. - removed needless macros. + - used $CPPFLAGS not $CFLAGS. 2007-06-16 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/macros/python.m4 =================================================================== --- tomoe/trunk/macros/python.m4 2007-06-17 04:32:20 UTC (rev 1501) +++ tomoe/trunk/macros/python.m4 2007-06-17 04:58:32 UTC (rev 1502) @@ -39,17 +39,20 @@ AC_SUBST(PYGOBJECT_CFLAGS) - CFLAGS="$CFLAGS $PYTHON_CFLAGS" + _SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS" AC_CHECK_HEADERS(Python.h, [], [python_available="no" AC_MSG_WARN([$python_disable_message])]) - CFLAGS=$_SAVE_CFLAGS + CPPFLAGS=$_SAVE_CPPFLAGS fi if test "$python_available" = "yes"; then - AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, - [python_available="no" - AC_MSG_WARN([$python_disable_message])]) + AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0) + if test -z "$PYGTK_CODEGEN"; then + python_available="no" + AC_MSG_WARN([$python_disable_message]) + fi fi fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kt...@us...> - 2007-06-17 04:32:18
|
Revision: 1501 http://tomoe.svn.sourceforge.net/tomoe/?rev=1501&view=rev Author: ktou Date: 2007-06-16 21:32:20 -0700 (Sat, 16 Jun 2007) Log Message: ----------- * macros/python.m4: removed needless macros. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/macros/python.m4 Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 04:30:58 UTC (rev 1500) +++ tomoe/trunk/ChangeLog 2007-06-17 04:32:20 UTC (rev 1501) @@ -4,6 +4,7 @@ - disabled Python bindings not error if pygobject-2.0 package is not found. - removed needless spaces. + - removed needless macros. 2007-06-16 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/macros/python.m4 =================================================================== --- tomoe/trunk/macros/python.m4 2007-06-17 04:30:58 UTC (rev 1500) +++ tomoe/trunk/macros/python.m4 2007-06-17 04:32:20 UTC (rev 1501) @@ -39,17 +39,10 @@ AC_SUBST(PYGOBJECT_CFLAGS) - python_undef_package_macros=" -#undef PACKAGE_NAME -#undef PACKAGE_TARNAME -#undef PACKAGE_STRING -#undef PACKAGE_VERSION -" CFLAGS="$CFLAGS $PYTHON_CFLAGS" AC_CHECK_HEADERS(Python.h, [], [python_available="no" - AC_MSG_WARN([$python_disable_message])], - [$python_undef_package_macros]) + AC_MSG_WARN([$python_disable_message])]) CFLAGS=$_SAVE_CFLAGS fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kt...@us...> - 2007-06-17 04:30:56
|
Revision: 1500 http://tomoe.svn.sourceforge.net/tomoe/?rev=1500&view=rev Author: ktou Date: 2007-06-16 21:30:58 -0700 (Sat, 16 Jun 2007) Log Message: ----------- * macros/python.m4: removed needless spaces. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/macros/python.m4 Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 04:29:50 UTC (rev 1499) +++ tomoe/trunk/ChangeLog 2007-06-17 04:30:58 UTC (rev 1500) @@ -1,7 +1,9 @@ 2007-06-17 Kouhei Sutou <ko...@co...> - * macros/python.m4: disabled Python bindings not error if pygobject-2.0 - package is not found. + * macros/python.m4: + - disabled Python bindings not error if pygobject-2.0 + package is not found. + - removed needless spaces. 2007-06-16 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/macros/python.m4 =================================================================== --- tomoe/trunk/macros/python.m4 2007-06-17 04:29:50 UTC (rev 1499) +++ tomoe/trunk/macros/python.m4 2007-06-17 04:30:58 UTC (rev 1500) @@ -27,8 +27,8 @@ python_available="no"]) if test "$python_available" = "yes"; then - PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'` - PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'` + PY_PREFIX=`$PYTHON -c 'import sys; print sys.prefix'` + PY_EXEC_PREFIX=`$PYTHON -c 'import sys; print sys.exec_prefix'` PYTHON_LIBS="-lpython$PYTHON_VERSION" PYTHON_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config" PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kt...@us...> - 2007-06-17 04:29:50
|
Revision: 1499 http://tomoe.svn.sourceforge.net/tomoe/?rev=1499&view=rev Author: ktou Date: 2007-06-16 21:29:50 -0700 (Sat, 16 Jun 2007) Log Message: ----------- * macros/python.m4: disabled Python bindings not error if pygobject-2.0 package is not found. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/macros/python.m4 Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-17 00:15:09 UTC (rev 1498) +++ tomoe/trunk/ChangeLog 2007-06-17 04:29:50 UTC (rev 1499) @@ -1,3 +1,8 @@ +2007-06-17 Kouhei Sutou <ko...@co...> + + * macros/python.m4: disabled Python bindings not error if pygobject-2.0 + package is not found. + 2007-06-16 Hiroyuki Ikezoe <poi...@ik...> * lib/tomoe-char.c: tomoe_char_to_xml_readings() puts each reading Modified: tomoe/trunk/macros/python.m4 =================================================================== --- tomoe/trunk/macros/python.m4 2007-06-17 00:15:09 UTC (rev 1498) +++ tomoe/trunk/macros/python.m4 2007-06-17 04:29:50 UTC (rev 1499) @@ -21,35 +21,43 @@ fi if test "$python_available" = "yes"; then - PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'` - PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'` - PYTHON_LIBS="-lpython$PYTHON_VERSION" - PYTHON_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config" - PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION" + python_disable_message="Disable Python binding." + PKG_CHECK_MODULES(PYGOBJECT, pygobject-2.0, , + [AC_MSG_WARN([$python_disable_message]) + python_available="no"]) - PKG_CHECK_MODULES(PYGOBJECT, pygobject-2.0) + if test "$python_available" = "yes"; then + PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'` + PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'` + PYTHON_LIBS="-lpython$PYTHON_VERSION" + PYTHON_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config" + PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION" - AC_SUBST(PYTHON_CFLAGS) - AC_SUBST(PYTHON_LIBS) - AC_SUBST(PYTHON_LDFLAGS) + AC_SUBST(PYTHON_CFLAGS) + AC_SUBST(PYTHON_LIBS) + AC_SUBST(PYTHON_LDFLAGS) - AC_SUBST(PYGOBJECT_CFLAGS) + AC_SUBST(PYGOBJECT_CFLAGS) - python_undef_package_macros=" + python_undef_package_macros=" #undef PACKAGE_NAME #undef PACKAGE_TARNAME #undef PACKAGE_STRING #undef PACKAGE_VERSION " - python_disable_message="Disable Python binding." - CFLAGS="$CFLAGS $PYTHON_CFLAGS" - AC_CHECK_HEADERS(Python.h, [], - [python_available="no" - AC_MSG_WARN([$python_disable_message])], - [$python_undef_package_macros]) - CFLAGS=$_SAVE_CFLAGS + CFLAGS="$CFLAGS $PYTHON_CFLAGS" + AC_CHECK_HEADERS(Python.h, [], + [python_available="no" + AC_MSG_WARN([$python_disable_message])], + [$python_undef_package_macros]) + CFLAGS=$_SAVE_CFLAGS + fi - AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, [python_avairable="no"]) + if test "$python_available" = "yes"; then + AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, + [python_available="no" + AC_MSG_WARN([$python_disable_message])]) + fi fi AM_CONDITIONAL([WITH_PYTHON], [test "$python_available" = "yes"]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-17 00:15:07
|
Revision: 1498 http://tomoe.svn.sourceforge.net/tomoe/?rev=1498&view=rev Author: ikezoe Date: 2007-06-16 17:15:09 -0700 (Sat, 16 Jun 2007) Log Message: ----------- implement some tests. Modified Paths: -------------- tomoe/trunk/test/python/test_context.py Modified: tomoe/trunk/test/python/test_context.py =================================================================== --- tomoe/trunk/test/python/test_context.py 2007-06-16 12:30:30 UTC (rev 1497) +++ tomoe/trunk/test/python/test_context.py 2007-06-17 00:15:09 UTC (rev 1498) @@ -13,8 +13,13 @@ config_file = open(self.config_filename, "w") contents = """ [config] +use-system-dictionaries = false user-dictionary = user-dict languages = ja;zh_CN + +[test-dictionary] +type = xml +file = test-dict.xml """ config_file.write(contents) config_file.close() @@ -35,13 +40,34 @@ context = tomoe.Context() context.load_config(self.config_filename) - char = context.get_char('池') - self.assertEqual('池', char.get_utf8()) + char_code = '池' + tomoe_char = context.get_char(char_code) + self.assertEqual(char_code, tomoe_char.get_utf8()) def testRegister(self): - self.assert_(False) + context = tomoe.Context() + context.load_config(self.config_filename) + char_code = '地' + tomoe_char = context.get_char(char_code) + self.assertEqual(None, tomoe_char) + + tomoe_char = tomoe.Char(char_code) + self.assert_(context.register(tomoe_char)) + + tomoe_char = context.get_char(char_code) + self.assertNotEqual(None, tomoe_char) + self.assertEqual(char_code, tomoe_char.get_utf8()) + def testUnregister(self): - self.assert_(False) + context = tomoe.Context() + context.load_config(self.config_filename) + char_code = '池' + tomoe_char = context.get_char(char_code) + self.assertEqual(char_code, tomoe_char.get_utf8()) + + self.assert_(context.unregister(char_code)) + self.assertEqual(None, context.get_char(char_code)) + # vi:ts=4:nowrap:ai:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 13:03:07
|
Revision: 1497 http://tomoe.svn.sourceforge.net/tomoe/?rev=1497&view=rev Author: ikezoe Date: 2007-06-16 05:30:30 -0700 (Sat, 16 Jun 2007) Log Message: ----------- implement tomoe.Config().make_shelf() test. Modified Paths: -------------- tomoe/trunk/test/python/test_config.py Modified: tomoe/trunk/test/python/test_config.py =================================================================== --- tomoe/trunk/test/python/test_config.py 2007-06-16 12:13:32 UTC (rev 1496) +++ tomoe/trunk/test/python/test_config.py 2007-06-16 12:30:30 UTC (rev 1497) @@ -13,8 +13,17 @@ config_file = open(self.config_filename, "w") contents = """ [config] +use-system-dictionaries = false user-dictionary = user-dict languages = ja;zh_CN + +[test1-dictionary] +type = xml +file = ../../data/kanjidic2.xml + +[test2-dictionary] +type = xml +file = ../../data/kanjidic2.xml """ config_file.write(contents) config_file.close() @@ -34,6 +43,7 @@ self.assertEqual(sorted(['ja', 'zh_CN']), sorted(self.config.get_languages())) def testMakeShelf(self): - self.assert_(False) + shelf = self.config.make_shelf('') + self.assertEqual(sorted(['test1', 'test2']), sorted(shelf.get_dict_names())) # vi:ts=4:nowrap:ai:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 12:13:30
|
Revision: 1496 http://tomoe.svn.sourceforge.net/tomoe/?rev=1496&view=rev Author: ikezoe Date: 2007-06-16 05:13:32 -0700 (Sat, 16 Jun 2007) Log Message: ----------- minor fix. Modified Paths: -------------- tomoe/trunk/test/python/test_dict.py Modified: tomoe/trunk/test/python/test_dict.py =================================================================== --- tomoe/trunk/test/python/test_dict.py 2007-06-16 11:16:25 UTC (rev 1495) +++ tomoe/trunk/test/python/test_dict.py 2007-06-16 12:13:32 UTC (rev 1496) @@ -56,6 +56,7 @@ char_code = '池' n_strokes = 6 tomoe_char = self.dict.get_char(char_code) + self.assertNotEqual(None, tomoe_char) self.assertEqual(char_code, tomoe_char.get_utf8()) self.assertEqual(n_strokes, tomoe_char.get_n_strokes()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 11:16:25
|
Revision: 1495 http://tomoe.svn.sourceforge.net/tomoe/?rev=1495&view=rev Author: ikezoe Date: 2007-06-16 04:16:25 -0700 (Sat, 16 Jun 2007) Log Message: ----------- sort before comparison. Modified Paths: -------------- tomoe/trunk/test/python/test_dict.py Modified: tomoe/trunk/test/python/test_dict.py =================================================================== --- tomoe/trunk/test/python/test_dict.py 2007-06-16 11:16:00 UTC (rev 1494) +++ tomoe/trunk/test/python/test_dict.py 2007-06-16 11:16:25 UTC (rev 1495) @@ -28,8 +28,8 @@ self.assert_(self.dict.copy(dest_dict)) query = tomoe.Query() - for src_char, dest_char in zip(map(lambda x: x.get_char(), self.dict.search(query)), - map(lambda x: x.get_char(), dest_dict.search(query))): + for src_char, dest_char in zip(sorted(map(lambda x: x.get_char(), self.dict.search(query)), key=lambda char: char.get_utf8()), + sorted(map(lambda x: x.get_char(), dest_dict.search(query)), key=lambda char: char.get_utf8())): self.assertEqual(src_char.to_xml(), dest_char.to_xml()) def testRegisterChar(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 11:15:58
|
Revision: 1494 http://tomoe.svn.sourceforge.net/tomoe/?rev=1494&view=rev Author: ikezoe Date: 2007-06-16 04:16:00 -0700 (Sat, 16 Jun 2007) Log Message: ----------- remove test config file. Modified Paths: -------------- tomoe/trunk/test/python/test_context.py Modified: tomoe/trunk/test/python/test_context.py =================================================================== --- tomoe/trunk/test/python/test_context.py 2007-06-16 10:59:43 UTC (rev 1493) +++ tomoe/trunk/test/python/test_context.py 2007-06-16 11:16:00 UTC (rev 1494) @@ -19,6 +19,10 @@ config_file.write(contents) config_file.close() + def tearDown(self): + if os.access(self.config_filename, os.F_OK): + os.unlink(self.config_filename) + def testLoadConfig(self): context = tomoe.Context() context.load_config(self.config_filename) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 10:59:45
|
Revision: 1493 http://tomoe.svn.sourceforge.net/tomoe/?rev=1493&view=rev Author: ikezoe Date: 2007-06-16 03:59:43 -0700 (Sat, 16 Jun 2007) Log Message: ----------- parent class should be TomoeDictClass. Modified Paths: -------------- tomoe/trunk/module/dict/tomoe-dict-est.c tomoe/trunk/module/dict/tomoe-dict-mysql.c tomoe/trunk/module/dict/tomoe-dict-ruby.c tomoe/trunk/module/dict/tomoe-dict-svn.c Modified: tomoe/trunk/module/dict/tomoe-dict-est.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-est.c 2007-06-16 10:29:46 UTC (rev 1492) +++ tomoe/trunk/module/dict/tomoe-dict-est.c 2007-06-16 10:59:43 UTC (rev 1493) @@ -79,7 +79,7 @@ } TomoeDictSearchContext; static GType tomoe_type_dict_est = 0; -static GObjectClass *parent_class; +static TomoeDictClass *parent_class; static GObject *constructor (GType type, guint n_props, Modified: tomoe/trunk/module/dict/tomoe-dict-mysql.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-mysql.c 2007-06-16 10:29:46 UTC (rev 1492) +++ tomoe/trunk/module/dict/tomoe-dict-mysql.c 2007-06-16 10:59:43 UTC (rev 1493) @@ -94,7 +94,7 @@ static GType tomoe_type_dict_mysql = 0; -static GObjectClass *parent_class; +static TomoeDictClass *parent_class; static GObject *constructor (GType type, guint n_props, Modified: tomoe/trunk/module/dict/tomoe-dict-ruby.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-ruby.c 2007-06-16 10:29:46 UTC (rev 1492) +++ tomoe/trunk/module/dict/tomoe-dict-ruby.c 2007-06-16 10:59:43 UTC (rev 1493) @@ -86,7 +86,7 @@ extern VALUE rb_load_path; static GType tomoe_type_dict_ruby = 0; -static GObjectClass *parent_class; +static TomoeDictClass *parent_class; static GObject *constructor (GType type, guint n_props, Modified: tomoe/trunk/module/dict/tomoe-dict-svn.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-svn.c 2007-06-16 10:29:46 UTC (rev 1492) +++ tomoe/trunk/module/dict/tomoe-dict-svn.c 2007-06-16 10:59:43 UTC (rev 1493) @@ -74,7 +74,7 @@ }; static GType tomoe_type_dict_svn = 0; -static GObjectClass *parent_class; +static TomoeDictClass *parent_class; static apr_pool_t *pool; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 10:29:50
|
Revision: 1492 http://tomoe.svn.sourceforge.net/tomoe/?rev=1492&view=rev Author: ikezoe Date: 2007-06-16 03:29:46 -0700 (Sat, 16 Jun 2007) Log Message: ----------- remove test config file. Modified Paths: -------------- tomoe/trunk/test/python/test_config.py Modified: tomoe/trunk/test/python/test_config.py =================================================================== --- tomoe/trunk/test/python/test_config.py 2007-06-16 10:22:38 UTC (rev 1491) +++ tomoe/trunk/test/python/test_config.py 2007-06-16 10:29:46 UTC (rev 1492) @@ -20,6 +20,10 @@ config_file.close() self.config = tomoe.Config(self.config_filename) + def tearDown(self): + if os.access(self.config_filename, os.F_OK): + os.unlink(self.config_filename) + def testGetFilename(self): self.assertEqual(self.config_filename, self.config.get_filename()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 10:22:36
|
Revision: 1491 http://tomoe.svn.sourceforge.net/tomoe/?rev=1491&view=rev Author: ikezoe Date: 2007-06-16 03:22:38 -0700 (Sat, 16 Jun 2007) Log Message: ----------- * lib/tomoe-dict.c: Call copy() only if the class has copy function. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/lib/tomoe-dict.c Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-16 10:21:33 UTC (rev 1490) +++ tomoe/trunk/ChangeLog 2007-06-16 10:22:38 UTC (rev 1491) @@ -9,6 +9,7 @@ * module/dict/tomoe-dict-ptr-array.[ch]: Removed. All functions were moved into TomoeDictPtrArray object. * module/dict/tomoe-unihan.[ch]: Adapt to TomoeDictPtrArray. + * lib/tomoe-dict.c: Call copy() only if the class has copy function. 2007-06-15 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/lib/tomoe-dict.c =================================================================== --- tomoe/trunk/lib/tomoe-dict.c 2007-06-16 10:21:33 UTC (rev 1490) +++ tomoe/trunk/lib/tomoe-dict.c 2007-06-16 10:22:38 UTC (rev 1491) @@ -329,10 +329,8 @@ return FALSE; } - if (G_OBJECT_TYPE (src_dict) == G_OBJECT_TYPE (dest_dict) && - TOMOE_DICT_GET_CLASS (src_dict)->copy) { + if (TOMOE_DICT_GET_CLASS (src_dict)->copy) return TOMOE_DICT_GET_CLASS (src_dict)->copy (src_dict, dest_dict); - } return tomoe_dict_plain_copy (src_dict, dest_dict); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 10:21:34
|
Revision: 1490 http://tomoe.svn.sourceforge.net/tomoe/?rev=1490&view=rev Author: ikezoe Date: 2007-06-16 03:21:33 -0700 (Sat, 16 Jun 2007) Log Message: ----------- * lib/tomoe-dict-ptr-array.[ch]: A new abstract object. * module/dict/tomoe-dict-xml.c, module/dict/tomoe-dict-unihan.c: Use TomoeDictPtrArray. * module/dict/tomoe-dict-ptr-array.[ch]: Removed. All functions were moved into TomoeDictPtrArray object. * module/dict/tomoe-unihan.[ch]: Adapt to TomoeDictPtrArray. Modified Paths: -------------- tomoe/trunk/ChangeLog tomoe/trunk/lib/Makefile.am tomoe/trunk/module/dict/Makefile.am tomoe/trunk/module/dict/tomoe-dict-unihan.c tomoe/trunk/module/dict/tomoe-dict-xml.c tomoe/trunk/module/dict/tomoe-unihan.c tomoe/trunk/module/dict/tomoe-unihan.h Added Paths: ----------- tomoe/trunk/lib/tomoe-dict-ptr-array.c tomoe/trunk/lib/tomoe-dict-ptr-array.h Removed Paths: ------------- tomoe/trunk/module/dict/tomoe-dict-ptr-array.c tomoe/trunk/module/dict/tomoe-dict-ptr-array.h Modified: tomoe/trunk/ChangeLog =================================================================== --- tomoe/trunk/ChangeLog 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/ChangeLog 2007-06-16 10:21:33 UTC (rev 1490) @@ -3,6 +3,12 @@ * lib/tomoe-char.c: tomoe_char_to_xml_readings() puts each reading from the last element of its list for the sake of preserving the order of readings. + * lib/tomoe-dict-ptr-array.[ch]: A new abstract object. + * module/dict/tomoe-dict-xml.c, module/dict/tomoe-dict-unihan.c: Use + TomoeDictPtrArray. + * module/dict/tomoe-dict-ptr-array.[ch]: Removed. All functions were moved into + TomoeDictPtrArray object. + * module/dict/tomoe-unihan.[ch]: Adapt to TomoeDictPtrArray. 2007-06-15 Hiroyuki Ikezoe <poi...@ik...> Modified: tomoe/trunk/lib/Makefile.am =================================================================== --- tomoe/trunk/lib/Makefile.am 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/lib/Makefile.am 2007-06-16 10:21:33 UTC (rev 1490) @@ -69,6 +69,8 @@ tomoe-context.c \ tomoe-config.c \ tomoe-dict.c \ + tomoe-dict-ptr-array.c \ + tomoe-dict-ptr-array.h \ tomoe-module.c \ tomoe-query.c \ tomoe-reading.c \ Added: tomoe/trunk/lib/tomoe-dict-ptr-array.c =================================================================== --- tomoe/trunk/lib/tomoe-dict-ptr-array.c (rev 0) +++ tomoe/trunk/lib/tomoe-dict-ptr-array.c 2007-06-16 10:21:33 UTC (rev 1490) @@ -0,0 +1,434 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou <ko...@co...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-ptr-array.c 1486 2007-06-15 12:48:40Z ikezoe $ + */ + +#include <string.h> + +#include "tomoe-dict-ptr-array.h" + +#include "tomoe-candidate.h" +#include <glib-utils.h> + +typedef struct _TomoeDictSearchContext { + TomoeQuery *query; + GList *results; +} TomoeDictSearchContext; + +#define TOMOE_DICT_PTR_ARRAY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_DICT_PTR_ARRAY, TomoeDictPtrArrayPrivate)) + +typedef struct _TomoeDictPtrArrayPrivate TomoeDictPtrArrayPrivate; +struct _TomoeDictPtrArrayPrivate +{ + GPtrArray *chars; +}; + +static TomoeDictClass *parent_class; + +G_DEFINE_ABSTRACT_TYPE (TomoeDictPtrArray, _tomoe_dict_ptr_array, TOMOE_TYPE_DICT) + +static void dispose (GObject *object); +static gboolean register_char (TomoeDict *dict, + TomoeChar *chr); +static gboolean unregister_char (TomoeDict *dict, + const gchar *utf8); +static TomoeChar *get_char (TomoeDict *dict, + const gchar *utf8); +static GList *search (TomoeDict *dict, + TomoeQuery *query); +static gboolean copy (TomoeDict *src_dict, + TomoeDict *dest_dict); +static gchar *get_available_private_utf8 (TomoeDict *dict); + +static void +_tomoe_dict_ptr_array_class_init (TomoeDictPtrArrayClass *klass) +{ + GObjectClass *gobject_class; + TomoeDictClass *dict_class; + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->dispose = dispose; + + parent_class = g_type_class_peek_parent (klass); + + dict_class = TOMOE_DICT_CLASS (klass); + dict_class->get_name = NULL; + dict_class->register_char = register_char; + dict_class->unregister_char = unregister_char; + dict_class->get_char = get_char; + dict_class->search = search; + dict_class->flush = NULL; + dict_class->copy = copy; + dict_class->is_editable = NULL; + dict_class->is_available = NULL; + dict_class->get_available_private_utf8 = get_available_private_utf8; + + g_type_class_add_private (gobject_class, sizeof (TomoeDictPtrArrayPrivate)); +} + +static void +_tomoe_dict_ptr_array_init (TomoeDictPtrArray *dict) +{ + TomoeDictPtrArrayPrivate *priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dict); + priv->chars = g_ptr_array_new(); +} + +static void +dispose (GObject *object) +{ + TomoeDictPtrArrayPrivate *priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (object); + + if (priv->chars) + TOMOE_PTR_ARRAY_FREE_ALL(priv->chars, g_object_unref); + + priv->chars = NULL; + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static gint +char_compare_func (gconstpointer a, gconstpointer b) +{ + TomoeChar *ca = *(TomoeChar **) a; + TomoeChar *cb = *(TomoeChar **) b; + return tomoe_char_compare (ca, cb); +} + +void +_tomoe_dict_ptr_array_sort (TomoeDictPtrArray *dict) +{ + TomoeDictPtrArrayPrivate *priv; + + g_return_if_fail (TOMOE_IS_DICT_PTR_ARRAY (dict)); + + priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dict); + + g_ptr_array_sort (priv->chars, char_compare_func); +} + +static gboolean +register_char (TomoeDict *dict, TomoeChar *chr) +{ + TomoeDictPtrArrayPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_DICT_PTR_ARRAY (dict), FALSE); + g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); + + priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dict); + + unregister_char (dict, tomoe_char_get_utf8 (chr)); + g_ptr_array_add (priv->chars, g_object_ref (G_OBJECT (chr))); + _tomoe_dict_ptr_array_sort (TOMOE_DICT_PTR_ARRAY (dict)); + + return TRUE; +} + +static gboolean +unregister_char (TomoeDict *dict, const gchar *utf8) +{ + TomoeDictPtrArrayPrivate *priv; + TomoeChar *removed = NULL; + gint i, len, index = -1; + + g_return_val_if_fail (TOMOE_IS_DICT_PTR_ARRAY (dict), FALSE); + g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); + + priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dict); + + len = priv->chars->len; + for (i = 0; i < len; i++) { + TomoeChar *chr = g_ptr_array_index (priv->chars, i); + if (g_str_equal (tomoe_char_get_utf8(chr), utf8)) { + index = i; + removed = chr; + break; + } + } + + if (index >= 0) { + g_ptr_array_remove_index (priv->chars, index); + g_object_unref (removed); + return TRUE; + } else { + return FALSE; + } +} + +static TomoeChar * +get_char (TomoeDict *dict, const gchar *utf8) +{ + TomoeDictPtrArrayPrivate *priv; + gint i, len; + + g_return_val_if_fail (TOMOE_IS_DICT_PTR_ARRAY (dict), NULL); + g_return_val_if_fail (utf8 && *utf8 != '\0', NULL); + + priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dict); + + len = priv->chars->len; + for (i = 0; i < len; i++) { + TomoeChar *chr = g_ptr_array_index (priv->chars, i); + if (g_str_equal (tomoe_char_get_utf8(chr), utf8)) { + return g_object_ref (chr); + } + } + + return NULL; +} + +static gboolean +does_match_char_with_utf8 (TomoeChar *chr, const gchar *utf8) +{ + if (!utf8) + return TRUE; + + return g_utf8_collate (tomoe_char_get_utf8 (chr), utf8) == 0; +} + +static gboolean +does_match_char_with_variant (TomoeChar *chr, const gchar *variant) +{ + const gchar *chr_variant; + + if (!variant) + return TRUE; + + chr_variant = tomoe_char_get_variant (chr); + if (!chr_variant) + return FALSE; + + return g_utf8_collate (chr_variant, variant) == 0; +} + +static gboolean +does_match_char_with_n_strokes (TomoeChar *chr, gint min, gint max) +{ + TomoeWriting *writing; + gint n_strokes; + + if (min < 0 && max < 0) + return TRUE; + + n_strokes = tomoe_char_get_n_strokes (chr); + if (n_strokes < 0) { + writing = tomoe_char_get_writing (chr); + if (!writing) + return FALSE; + n_strokes = tomoe_writing_get_n_strokes (writing); + } + + return ((min < 0 || min <= n_strokes) && + (max < 0 || max >= n_strokes)); +} + +static gint +reading_compare_func (gconstpointer a, gconstpointer b) +{ + return tomoe_reading_has_prefix (TOMOE_READING (a), TOMOE_READING (b)) ? 0 : -1; +} + +static gboolean +does_match_char_with_reading (TomoeChar *chr, TomoeReading *reading) +{ + if (!reading) + return TRUE; + + if (g_list_find_custom ((GList *)tomoe_char_get_readings (chr), + reading, reading_compare_func)) + return TRUE; + else + return FALSE; +} + +static gboolean +does_match_char_with_readings (TomoeChar *chr, const GList *readings) +{ + GList *node; + + for (node = (GList *)readings; node; node = g_list_next (node)) { + TomoeReading *reading = node->data; + if (!does_match_char_with_reading (chr, reading)) + return FALSE; + } + + return TRUE; +} + +static gboolean +does_match_char_with_radical (TomoeChar *chr, const gchar *radical) +{ + if (!radical) + return TRUE; + + if (g_list_find_custom ((GList *)tomoe_char_get_radicals (chr), + radical, (GCompareFunc)g_utf8_collate)) + return TRUE; + else + return FALSE; +} + +static gboolean +does_match_char_with_radicals (TomoeChar *chr, const GList *radicals) +{ + GList *node; + + for (node = (GList *)radicals; node; node = g_list_next (node)) { + const gchar *radical = node->data; + if (!does_match_char_with_radical (chr, radical)) + return FALSE; + } + + return TRUE; +} + +static void +collect_chars_by_query (gpointer data, gpointer user_data) +{ + TomoeChar *chr = data; + TomoeDictSearchContext *context = user_data; + TomoeQuery *q; + + q = context->query; + if (does_match_char_with_utf8 (chr, tomoe_query_get_utf8 (q)) && + does_match_char_with_variant (chr, tomoe_query_get_variant (q)) && + does_match_char_with_n_strokes (chr, + tomoe_query_get_min_n_strokes (q), + tomoe_query_get_max_n_strokes (q)) && + does_match_char_with_readings (chr, tomoe_query_get_readings (q)) && + does_match_char_with_radicals (chr, tomoe_query_get_radicals (q))) { + context->results = g_list_prepend (context->results, + tomoe_candidate_new (chr)); + } +} + +static void +collect_all_chars (gpointer data, gpointer user_data) +{ + TomoeChar *chr = data; + TomoeDictSearchContext *context = user_data; + + context->results = g_list_prepend (context->results, + tomoe_candidate_new (chr)); +} + +static GList * +search (TomoeDict *dict, TomoeQuery *query) +{ + TomoeDictSearchContext search_context; + TomoeDictPtrArrayPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_DICT_PTR_ARRAY (dict), NULL); + + priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dict); + + search_context.query = g_object_ref (query); + search_context.results = NULL; + + if (tomoe_query_is_empty (query)) { + g_ptr_array_foreach_reverse (priv->chars, collect_all_chars, + &search_context); + } else { + g_ptr_array_foreach_reverse (priv->chars, collect_chars_by_query, + &search_context); + } + g_object_unref (search_context.query); + + return search_context.results; +} + +static void +copy_all_chars (gpointer data, gpointer user_data) +{ + TomoeChar *chr = data; + GPtrArray **dest_chars = user_data; + + g_ptr_array_add (*dest_chars, tomoe_char_dup (chr)); +} + +gboolean +copy (TomoeDict *src_dict, TomoeDict *dest_dict) +{ + TomoeDictPtrArrayPrivate *src_priv, *dest_priv; + g_return_val_if_fail (TOMOE_IS_DICT_PTR_ARRAY (src_dict), FALSE); + + if (!TOMOE_IS_DICT_PTR_ARRAY (dest_dict)) { + tomoe_dict_plain_copy (src_dict, dest_dict); + return TRUE; + } + src_priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (src_dict); + dest_priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dest_dict); + + /* remove all chars from destination */ + if (dest_priv->chars->len > 0) { + g_ptr_array_foreach (dest_priv->chars, (GFunc) g_object_unref, NULL); + g_ptr_array_remove_range (dest_priv->chars, 0, dest_priv->chars->len); + } + + g_ptr_array_foreach_reverse (src_priv->chars, copy_all_chars, &dest_priv->chars); + + return TRUE; +} + +gchar * +get_available_private_utf8 (TomoeDict *dict) +{ + TomoeDictPtrArrayPrivate *priv; + gint i, len, result_len; + gchar *result; + gunichar result_ucs = TOMOE_CHAR_PRIVATE_USE_AREA_START; + + g_return_val_if_fail (TOMOE_IS_DICT_PTR_ARRAY (dict), NULL); + + priv = TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dict); + + len = priv->chars->len; + for (i = 0; i < len; i++) { + TomoeChar *chr; + gunichar ucs; + + chr = priv->chars->pdata[i]; + ucs = g_utf8_get_char (tomoe_char_get_utf8 (chr)); + if (ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_START) { + if (ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_END) { + return NULL; + } else { + result_ucs = ucs + 1; + } + } + } + + result_len = g_unichar_to_utf8 (result_ucs, NULL); + result = g_new (gchar, result_len + 1); + g_unichar_to_utf8 (result_ucs, result); + result[result_len] = '\0'; + return result; +} + +GPtrArray * +_tomoe_dict_ptr_array_get_array (TomoeDictPtrArray *dict) +{ + g_return_val_if_fail (TOMOE_IS_DICT_PTR_ARRAY (dict), NULL); + + return TOMOE_DICT_PTR_ARRAY_GET_PRIVATE (dict)->chars; +} + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Added: tomoe/trunk/lib/tomoe-dict-ptr-array.h =================================================================== --- tomoe/trunk/lib/tomoe-dict-ptr-array.h (rev 0) +++ tomoe/trunk/lib/tomoe-dict-ptr-array.h 2007-06-16 10:21:33 UTC (rev 1490) @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou <ko...@co...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-ptr-array.h 1486 2007-06-15 12:48:40Z ikezoe $ + */ + +#ifndef __TOMOE_DICT_PTR_ARRAY_H__ +#define __TOMOE_DICT_PTR_ARRAY_H__ + +#include <glib.h> + +G_BEGIN_DECLS + +#include "tomoe-dict.h" + +#define TOMOE_TYPE_DICT_PTR_ARRAY (_tomoe_dict_ptr_array_get_type ()) +#define TOMOE_DICT_PTR_ARRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_PTR_ARRAY, TomoeDictPtrArray)) +#define TOMOE_DICT_PTR_ARRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_PTR_ARRAY, TomoeDictPtrArrayClass)) +#define TOMOE_IS_DICT_PTR_ARRAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_PTR_ARRAY)) +#define TOMOE_IS_DICT_PTR_ARRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_PTR_ARRAY)) +#define TOMOE_DICT_PTR_ARRAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_PTR_ARRAY, TomoeDictPtrArrayClass)) + +typedef struct _TomoeDictPtrArray TomoeDictPtrArray; +typedef struct _TomoeDictPtrArrayClass TomoeDictPtrArrayClass; + +struct _TomoeDictPtrArray +{ + TomoeDict object; +}; + +struct _TomoeDictPtrArrayClass +{ + TomoeDictClass parent_class; +}; + +GType _tomoe_dict_ptr_array_get_type (void) G_GNUC_CONST; +void _tomoe_dict_ptr_array_sort (TomoeDictPtrArray *dict); +GPtrArray *_tomoe_dict_ptr_array_get_array (TomoeDictPtrArray *dict); + +G_END_DECLS + +#endif /* __TOMOE_DICT_PTR_ARRAY_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Modified: tomoe/trunk/module/dict/Makefile.am =================================================================== --- tomoe/trunk/module/dict/Makefile.am 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/module/dict/Makefile.am 2007-06-16 10:21:33 UTC (rev 1490) @@ -38,14 +38,10 @@ -rpath $(dict_moduledir) -avoid-version -module \ -export-dynamic $(no_undefined) $(LIBTOOL_EXPORT_OPTIONS) -ptr_array_based_dict_sources = \ - tomoe-dict-ptr-array.c \ - tomoe-dict-ptr-array.h - dict_module_LTLIBRARIES = xml.la xml_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Dict:XML\" $(AM_CPPFLAGS) -xml_la_SOURCES = tomoe-dict-xml.c $(ptr_array_based_dict_sources) +xml_la_SOURCES = tomoe-dict-xml.c xml_la_LIBADD = $(LIBADD) if USE_EST @@ -81,8 +77,7 @@ tomoe-dict-unihan.c \ tomoe-unihan.c \ tomoe-unihan.h \ - $(unihan_built_sources) \ - $(ptr_array_based_dict_sources) + $(unihan_built_sources) unihan_la_LIBADD = $(LIBADD) unihan-compiler.rb: xml.la Deleted: tomoe/trunk/module/dict/tomoe-dict-ptr-array.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-ptr-array.c 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/module/dict/tomoe-dict-ptr-array.c 2007-06-16 10:21:33 UTC (rev 1490) @@ -1,314 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2006 Kouhei Sutou <ko...@co...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#include <string.h> - -#include "tomoe-dict-ptr-array.h" - -#include <tomoe-candidate.h> -#include <glib-utils.h> - -typedef struct _TomoeDictSearchContext { - TomoeQuery *query; - GList *results; -} TomoeDictSearchContext; - -static gint -char_compare_func (gconstpointer a, gconstpointer b) -{ - TomoeChar *ca = *(TomoeChar **) a; - TomoeChar *cb = *(TomoeChar **) b; - return tomoe_char_compare (ca, cb); -} - -void -_tomoe_dict_ptr_array_sort (GPtrArray *chars) -{ - g_ptr_array_sort (chars, char_compare_func); -} - -gboolean -_tomoe_dict_ptr_array_register_char (GPtrArray *chars, TomoeChar *chr) -{ - _tomoe_dict_ptr_array_unregister_char (chars, tomoe_char_get_utf8 (chr)); - g_ptr_array_add (chars, g_object_ref (G_OBJECT (chr))); - _tomoe_dict_ptr_array_sort (chars); - - return TRUE; -} - -gboolean -_tomoe_dict_ptr_array_unregister_char (GPtrArray *chars, const gchar *utf8) -{ - TomoeChar *removed = NULL; - gint i, len, index = -1; - - g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); - - len = chars->len; - for (i = 0; i < len; i++) { - TomoeChar *chr = g_ptr_array_index (chars, i); - if (g_str_equal (tomoe_char_get_utf8(chr), utf8)) { - index = i; - removed = chr; - break; - } - } - - if (index >= 0) { - g_ptr_array_remove_index (chars, index); - g_object_unref (removed); - return TRUE; - } else { - return FALSE; - } -} - -TomoeChar * -_tomoe_dict_ptr_array_get_char (GPtrArray *chars, const gchar *utf8) -{ - gint i, len; - - g_return_val_if_fail (utf8 && *utf8 != '\0', NULL); - - len = chars->len; - for (i = 0; i < len; i++) { - TomoeChar *chr = g_ptr_array_index (chars, i); - if (g_str_equal (tomoe_char_get_utf8(chr), utf8)) { - return g_object_ref (chr); - } - } - - return NULL; -} - -static gboolean -does_match_char_with_utf8 (TomoeChar *chr, const gchar *utf8) -{ - if (!utf8) - return TRUE; - - return g_utf8_collate (tomoe_char_get_utf8 (chr), utf8) == 0; -} - -static gboolean -does_match_char_with_variant (TomoeChar *chr, const gchar *variant) -{ - const gchar *chr_variant; - - if (!variant) - return TRUE; - - chr_variant = tomoe_char_get_variant (chr); - if (!chr_variant) - return FALSE; - - return g_utf8_collate (chr_variant, variant) == 0; -} - -static gboolean -does_match_char_with_n_strokes (TomoeChar *chr, gint min, gint max) -{ - TomoeWriting *writing; - gint n_strokes; - - if (min < 0 && max < 0) - return TRUE; - - n_strokes = tomoe_char_get_n_strokes (chr); - if (n_strokes < 0) { - writing = tomoe_char_get_writing (chr); - if (!writing) - return FALSE; - n_strokes = tomoe_writing_get_n_strokes (writing); - } - - return ((min < 0 || min <= n_strokes) && - (max < 0 || max >= n_strokes)); -} - -static gint -reading_compare_func (gconstpointer a, gconstpointer b) -{ - return tomoe_reading_has_prefix (TOMOE_READING (a), TOMOE_READING (b)) ? 0 : -1; -} - -static gboolean -does_match_char_with_reading (TomoeChar *chr, TomoeReading *reading) -{ - if (!reading) - return TRUE; - - if (g_list_find_custom ((GList *)tomoe_char_get_readings (chr), - reading, reading_compare_func)) - return TRUE; - else - return FALSE; -} - -static gboolean -does_match_char_with_readings (TomoeChar *chr, const GList *readings) -{ - GList *node; - - for (node = (GList *)readings; node; node = g_list_next (node)) { - TomoeReading *reading = node->data; - if (!does_match_char_with_reading (chr, reading)) - return FALSE; - } - - return TRUE; -} - -static gboolean -does_match_char_with_radical (TomoeChar *chr, const gchar *radical) -{ - if (!radical) - return TRUE; - - if (g_list_find_custom ((GList *)tomoe_char_get_radicals (chr), - radical, (GCompareFunc)g_utf8_collate)) - return TRUE; - else - return FALSE; -} - -static gboolean -does_match_char_with_radicals (TomoeChar *chr, const GList *radicals) -{ - GList *node; - - for (node = (GList *)radicals; node; node = g_list_next (node)) { - const gchar *radical = node->data; - if (!does_match_char_with_radical (chr, radical)) - return FALSE; - } - - return TRUE; -} - -static void -collect_chars_by_query (gpointer data, gpointer user_data) -{ - TomoeChar *chr = data; - TomoeDictSearchContext *context = user_data; - TomoeQuery *q; - - q = context->query; - if (does_match_char_with_utf8 (chr, tomoe_query_get_utf8 (q)) && - does_match_char_with_variant (chr, tomoe_query_get_variant (q)) && - does_match_char_with_n_strokes (chr, - tomoe_query_get_min_n_strokes (q), - tomoe_query_get_max_n_strokes (q)) && - does_match_char_with_readings (chr, tomoe_query_get_readings (q)) && - does_match_char_with_radicals (chr, tomoe_query_get_radicals (q))) { - context->results = g_list_prepend (context->results, - tomoe_candidate_new (chr)); - } -} - -static void -collect_all_chars (gpointer data, gpointer user_data) -{ - TomoeChar *chr = data; - TomoeDictSearchContext *context = user_data; - - context->results = g_list_prepend (context->results, - tomoe_candidate_new (chr)); -} - -GList * -_tomoe_dict_ptr_array_search (GPtrArray *chars, TomoeQuery *query) -{ - TomoeDictSearchContext search_context; - - search_context.query = g_object_ref (query); - search_context.results = NULL; - - if (tomoe_query_is_empty (query)) { - g_ptr_array_foreach_reverse (chars, collect_all_chars, - &search_context); - } else { - g_ptr_array_foreach_reverse (chars, collect_chars_by_query, - &search_context); - } - g_object_unref (search_context.query); - - return search_context.results; -} - -static void -copy_all_chars (gpointer data, gpointer user_data) -{ - TomoeChar *chr = data; - GPtrArray **dest_chars = user_data; - - g_ptr_array_add (*dest_chars, tomoe_char_dup (chr)); -} - -gboolean -_tomoe_dict_ptr_array_copy (GPtrArray *src_chars, GPtrArray *dest_chars) -{ - /* remove all chars from destination */ - if (dest_chars->len > 0) { - g_ptr_array_foreach (dest_chars, (GFunc) g_object_unref, NULL); - g_ptr_array_remove_range (dest_chars, 0, dest_chars->len); - } - - g_ptr_array_foreach_reverse (src_chars, copy_all_chars, &dest_chars); - - return TRUE; -} - -gchar * -_tomoe_dict_ptr_array_get_available_private_utf8 (GPtrArray *chars) -{ - gint i, len, result_len; - gchar *result; - gunichar result_ucs = TOMOE_CHAR_PRIVATE_USE_AREA_START; - - len = chars->len; - for (i = 0; i < len; i++) { - TomoeChar *chr; - gunichar ucs; - - chr = chars->pdata[i]; - ucs = g_utf8_get_char (tomoe_char_get_utf8 (chr)); - if (ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_START) { - if (ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_END) { - return NULL; - } else { - result_ucs = ucs + 1; - } - } - } - - result_len = g_unichar_to_utf8 (result_ucs, NULL); - result = g_new (gchar, result_len + 1); - g_unichar_to_utf8 (result_ucs, result); - result[result_len] = '\0'; - return result; -} - -/* -vi:ts=4:nowrap:ai:expandtab -*/ Deleted: tomoe/trunk/module/dict/tomoe-dict-ptr-array.h =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-ptr-array.h 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/module/dict/tomoe-dict-ptr-array.h 2007-06-16 10:21:33 UTC (rev 1490) @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2006 Kouhei Sutou <ko...@co...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#ifndef __TOMOE_DICT_PTR_ARRAY_H__ -#define __TOMOE_DICT_PTR_ARRAY_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -#include <tomoe-dict.h> - -void _tomoe_dict_ptr_array_sort (GPtrArray *chars); -gboolean _tomoe_dict_ptr_array_register_char (GPtrArray *chars, - TomoeChar *chr); -gboolean _tomoe_dict_ptr_array_unregister_char (GPtrArray *chars, - const gchar *utf8); -TomoeChar *_tomoe_dict_ptr_array_get_char (GPtrArray *chars, - const gchar *utf8); -GList *_tomoe_dict_ptr_array_search (GPtrArray *chars, - TomoeQuery *query); -gboolean _tomoe_dict_ptr_array_copy (GPtrArray *src_chars, - GPtrArray *dest_chars); -gchar *_tomoe_dict_ptr_array_get_available_private_utf8 (GPtrArray *chars); - -G_END_DECLS - -#endif /* __TOMOE_DICT_PTR_ARRAY_H__ */ - -/* -vi:ts=4:nowrap:ai:expandtab -*/ Modified: tomoe/trunk/module/dict/tomoe-dict-unihan.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-unihan.c 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/module/dict/tomoe-dict-unihan.c 2007-06-16 10:21:33 UTC (rev 1490) @@ -68,8 +68,7 @@ }; static GType tomoe_type_dict_unihan = 0; -static GObjectClass *parent_class; -static GPtrArray *chars = NULL; +static TomoeDictPtrArray *parent_class; static guint chars_ref_count = 0; static GObject *constructor (GType type, @@ -86,10 +85,6 @@ GValue *value, GParamSpec *pspec); static const gchar *get_name (TomoeDict *dict); -static TomoeChar *get_char (TomoeDict *dict, - const gchar *utf8); -static GList *search (TomoeDict *dict, - TomoeQuery *query); static gboolean flush (TomoeDict *dict); static gboolean is_editable (TomoeDict *dict); static gboolean is_available (TomoeDict *dict); @@ -113,8 +108,6 @@ dict_class = TOMOE_DICT_CLASS (klass); dict_class->get_name = get_name; - dict_class->get_char = get_char; - dict_class->search = search; dict_class->flush = flush; dict_class->is_editable = is_editable; dict_class->is_available = is_available; @@ -154,7 +147,7 @@ }; tomoe_type_dict_unihan = g_type_module_register_type (type_module, - TOMOE_TYPE_DICT, + TOMOE_TYPE_DICT_PTR_ARRAY, "TomoeDictUnihan", &info, 0); } @@ -201,8 +194,8 @@ chars_ref_count++; if (chars_ref_count == 1) { - g_assert (chars == NULL); - chars = _tomoe_unihan_create (); + GPtrArray *chars = _tomoe_dict_ptr_array_get_array (TOMOE_DICT_PTR_ARRAY (object)); + _tomoe_unihan_create (chars); } return object; @@ -266,9 +259,6 @@ { chars_ref_count--; if (chars_ref_count == 0) { - g_assert (chars != NULL); - TOMOE_PTR_ARRAY_FREE_ALL (chars, g_object_unref); - chars = NULL; } G_OBJECT_CLASS (parent_class)->finalize (object); @@ -282,26 +272,7 @@ return dict->name ? dict->name : DEFAULT_NAME; } -static TomoeChar * -get_char (TomoeDict *_dict, const gchar *utf8) -{ - TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); - g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), NULL); - - return _tomoe_dict_ptr_array_get_char (chars, utf8); -} - -static GList * -search (TomoeDict *_dict, TomoeQuery *query) -{ - TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); - - g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), FALSE); - - return _tomoe_dict_ptr_array_search (chars, query); -} - static gboolean flush (TomoeDict *_dict) { Modified: tomoe/trunk/module/dict/tomoe-dict-xml.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-xml.c 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/module/dict/tomoe-dict-xml.c 2007-06-16 10:21:33 UTC (rev 1490) @@ -61,10 +61,9 @@ typedef struct _TomoeDictXMLClass TomoeDictXMLClass; struct _TomoeDictXML { - TomoeDict object; + TomoeDictPtrArray object; gchar *filename; gchar *name; - GPtrArray *chars; gboolean editable; gboolean modified; @@ -72,11 +71,11 @@ struct _TomoeDictXMLClass { - TomoeDictClass parent_class; + TomoeDictPtrArrayClass parent_class; }; static GType tomoe_type_dict_xml = 0; -static GObjectClass *parent_class; +static TomoeDictPtrArrayClass *parent_class; static GObject *constructor (GType type, guint n_props, @@ -91,20 +90,9 @@ GValue *value, GParamSpec *pspec); static const gchar *get_name (TomoeDict *dict); -static gboolean register_char (TomoeDict *dict, - TomoeChar *chr); -static gboolean unregister_char (TomoeDict *dict, - const gchar *utf8); -static TomoeChar *get_char (TomoeDict *dict, - const gchar *utf8); -static GList *search (TomoeDict *dict, - TomoeQuery *query); static gboolean flush (TomoeDict *dict); -static gboolean copy (TomoeDict *src_dict, - TomoeDict *dest_dict); static gboolean is_editable (TomoeDict *dict); static gboolean is_available (TomoeDict *dict); -static gchar *get_available_private_utf8 (TomoeDict *dict); static gboolean tomoe_dict_xml_load (TomoeDictXML *dict); static gboolean tomoe_dict_xml_save (TomoeDictXML *dict); @@ -125,17 +113,10 @@ dict_class = TOMOE_DICT_CLASS (klass); dict_class->get_name = get_name; - dict_class->register_char = register_char; - dict_class->unregister_char = unregister_char; - dict_class->get_char = get_char; - dict_class->search = search; dict_class->flush = flush; - dict_class->copy = copy; dict_class->is_editable = is_editable; dict_class->is_available = is_available; - dict_class->get_available_private_utf8 = get_available_private_utf8; - g_object_class_install_property ( gobject_class, PROP_FILENAME, @@ -161,7 +142,6 @@ { dict->filename = NULL; dict->name = NULL; - dict->chars = g_ptr_array_new(); dict->modified = FALSE; dict->editable = FALSE; } @@ -183,7 +163,7 @@ }; tomoe_type_dict_xml = g_type_module_register_type (type_module, - TOMOE_TYPE_DICT, + TOMOE_TYPE_DICT_PTR_ARRAY, "TomoeDictXML", &info, 0); } @@ -291,12 +271,9 @@ g_free (dict->name); if (dict->filename) g_free (dict->filename); - if (dict->chars) - TOMOE_PTR_ARRAY_FREE_ALL(dict->chars, g_object_unref); dict->name = NULL; dict->filename = NULL; - dict->chars = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -310,57 +287,6 @@ } static gboolean -register_char (TomoeDict *_dict, TomoeChar *chr) -{ - TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - - g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); - - if (_tomoe_dict_ptr_array_register_char (dict->chars, chr)) { - dict->modified = TRUE; - return TRUE; - } else { - return FALSE; - } -} - -static gboolean -unregister_char (TomoeDict *_dict, const gchar *utf8) -{ - TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - - g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - - if (_tomoe_dict_ptr_array_unregister_char (dict->chars, utf8)) { - dict->modified = TRUE; - return TRUE; - } else { - return FALSE; - } -} - -static TomoeChar * -get_char (TomoeDict *_dict, const gchar *utf8) -{ - TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - - g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - - return _tomoe_dict_ptr_array_get_char (dict->chars, utf8); -} - -static GList * -search (TomoeDict *_dict, TomoeQuery *query) -{ - TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - - g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - - return _tomoe_dict_ptr_array_search (dict->chars, query); -} - -static gboolean flush (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); @@ -371,19 +297,6 @@ } static gboolean -copy (TomoeDict *src_dict, TomoeDict *dest_dict) -{ - g_return_val_if_fail (TOMOE_IS_DICT_XML (src_dict), FALSE); - - if (TOMOE_IS_DICT_XML (dest_dict)) - _tomoe_dict_ptr_array_copy (TOMOE_DICT_XML (src_dict)->chars, TOMOE_DICT_XML (dest_dict)->chars); - else - tomoe_dict_plain_copy (src_dict, dest_dict); - - return TRUE; -} - -static gboolean is_editable (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); @@ -410,16 +323,6 @@ return TRUE; } -static gchar * -get_available_private_utf8 (TomoeDict *_dict) -{ - TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - - g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - - return _tomoe_dict_ptr_array_get_available_private_utf8 (dict->chars); -} - static gboolean tomoe_dict_xml_load (TomoeDictXML *dict) { @@ -430,14 +333,14 @@ return success; result.name = NULL; - result.chars = dict->chars; + result.chars = _tomoe_dict_ptr_array_get_array (TOMOE_DICT_PTR_ARRAY (dict)); success = _tomoe_xml_parser_parse_dictionary_file (dict->filename, &result); if (result.name) { g_free (dict->name); dict->name = g_strdup (result.name); g_free (result.name); } - _tomoe_dict_ptr_array_sort (dict->chars); + _tomoe_dict_ptr_array_sort (TOMOE_DICT_PTR_ARRAY (dict)); return success; } @@ -449,6 +352,7 @@ GError *error = NULL; gboolean success; guint i; + GPtrArray *chars; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); @@ -467,9 +371,10 @@ else g_string_append (xml, "<dictionary>\n"); - for (i = 0; i < dict->chars->len; i++) { + chars = _tomoe_dict_ptr_array_get_array (TOMOE_DICT_PTR_ARRAY (dict)); + for (i = 0; i < chars->len; i++) { gchar *chr_xml; - TomoeChar *chr = g_ptr_array_index (dict->chars, i); + TomoeChar *chr = g_ptr_array_index (chars, i); chr_xml = tomoe_char_to_xml (chr); if (chr_xml) { Modified: tomoe/trunk/module/dict/tomoe-unihan.c =================================================================== --- tomoe/trunk/module/dict/tomoe-unihan.c 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/module/dict/tomoe-unihan.c 2007-06-16 10:21:33 UTC (rev 1490) @@ -9,14 +9,13 @@ #include "tomoe-unihan.h" #include "tomoe-unihan-data.h" -GPtrArray * -_tomoe_unihan_create (void) +void +_tomoe_unihan_create (GPtrArray *array) { - GPtrArray *array; gint i, infos_size; infos_size = G_N_ELEMENTS (tomoe_unihan_infos); - array = g_ptr_array_sized_new (infos_size); + g_ptr_array_set_size (array, infos_size); array->len = infos_size; for (i = 0; i < infos_size; i++) { @@ -64,6 +63,4 @@ array->pdata[i] = chr; } - - return array; } Modified: tomoe/trunk/module/dict/tomoe-unihan.h =================================================================== --- tomoe/trunk/module/dict/tomoe-unihan.h 2007-06-16 09:36:47 UTC (rev 1489) +++ tomoe/trunk/module/dict/tomoe-unihan.h 2007-06-16 10:21:33 UTC (rev 1490) @@ -27,7 +27,7 @@ G_BEGIN_DECLS -GPtrArray *_tomoe_unihan_create (void); +void _tomoe_unihan_create (GPtrArray *array); G_END_DECLS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ik...@us...> - 2007-06-16 09:36:50
|
Revision: 1489 http://tomoe.svn.sourceforge.net/tomoe/?rev=1489&view=rev Author: ikezoe Date: 2007-06-16 02:36:47 -0700 (Sat, 16 Jun 2007) Log Message: ----------- return NULL; Modified Paths: -------------- tomoe/trunk/module/dict/tomoe-dict-xml.c Modified: tomoe/trunk/module/dict/tomoe-dict-xml.c =================================================================== --- tomoe/trunk/module/dict/tomoe-dict-xml.c 2007-06-16 01:16:23 UTC (rev 1488) +++ tomoe/trunk/module/dict/tomoe-dict-xml.c 2007-06-16 09:36:47 UTC (rev 1489) @@ -355,7 +355,7 @@ { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); + g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); return _tomoe_dict_ptr_array_search (dict->chars, query); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |