[groonga-commit:1615] ranguba/chupatext [master] changed ChupaTextInputStream to ChupaGsfStream

null+ranguba at clear-code.com null+ranguba at clear-code.com
Mon Oct 18 03:37:45 EDT 2010


Yuto Hayamizu	2010-10-18 07:37:45 +0000 (Mon, 18 Oct 2010)

  New Revision: aba497e1d6b17163e128c7d0b6fe270b04f8af1c

  Log:
    changed ChupaTextInputStream to ChupaGsfStream

  Removed files:
    chupatext/chupa_text_input_stream.c
    chupatext/chupa_text_input_stream.h
    test/test_text_input_stream.c
  Modified files:
    chupatext/Makefile.am
    chupatext/chupa_text.c
    chupatext/chupa_text_input.c
    module/powerpoint.c
    test/Makefile.am

  Modified: chupatext/Makefile.am (+2 -2)
===================================================================
--- chupatext/Makefile.am    2010-10-18 06:29:02 +0000 (72d112c)
+++ chupatext/Makefile.am    2010-10-18 07:37:45 +0000 (03e7701)
@@ -25,7 +25,7 @@ libchupatext_la_SOURCES =			\
 	chupa_decomposer_factory.c		\
 	chupa_decomposer_description.c		\
 	chupa_dispatcher.c			\
-	chupa_text_input_stream.c		\
+	chupa_gsf_input_stream.c		\
 	chupa_memory_input_stream.c		\
 	chupa_logger.c				\
 	chupa_decomposer.c			\
@@ -60,7 +60,7 @@ chupa_public_headers =				\
 	chupa_feeder.h				\
 	chupa_text_input.h			\
 	chupa_text.h				\
-	chupa_text_input_stream.h		\
+	chupa_gsf_input_stream.h		\
 	chupa_memory_input_stream.h		\
 	chupa_logger.h				\
 	external_decomposer.h			\

  Modified: chupatext/chupa_text.c (+6 -6)
===================================================================
--- chupatext/chupa_text.c    2010-10-18 06:29:02 +0000 (f254372)
+++ chupatext/chupa_text.c    2010-10-18 07:37:45 +0000 (e4d790e)
@@ -19,7 +19,7 @@
  */
 
 #include "chupa_text.h"
-#include "chupa_text_input_stream.h"
+#include "chupa_gsf_input_stream.h"
 #include <gio/gio.h>
 #include <gsf/gsf-input-gio.h>
 
@@ -31,7 +31,7 @@ G_DEFINE_TYPE(ChupaText, chupa_text, G_TYPE_OBJECT)
 
 #define CHUPA_TEXT_GET_PRIVATE(obj) \
     (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
-                                 CHUPA_TYPE_TEXT_INPUT, \
+                                 CHUPA_TYPE_TEXT, \
                                  ChupaTextPrivate))
 
 typedef struct _ChupaTextPrivate ChupaTextPrivate;
@@ -90,7 +90,7 @@ chupa_text_init(ChupaText *input)
 static void
 constructed(GObject *object)
 {
-    ChupaText *input = CHUPA_TEXT(object);
+    GsfInput *input = GSF_INPUT(object);
     ChupaTextPrivate *priv = CHUPA_TEXT_GET_PRIVATE(input);
     const gchar *mime_type;
     GInputStream *stream = (GInputStream *)priv->stream;
@@ -108,7 +108,7 @@ constructed(GObject *object)
         path = chupa_metadata_get_first_value(priv->metadata, meta_filename);
     }
     if (!stream) {
-        stream = G_INPUT_STREAM(chupa_text_input_stream_new(input));
+        stream = G_INPUT_STREAM(chupa_gsf_input_stream_new(input));
     }
     if (G_IS_DATA_INPUT_STREAM(stream)) {
         priv->stream = G_DATA_INPUT_STREAM(stream);
@@ -257,7 +257,7 @@ chupa_text_new(ChupaMetadata *metadata, GsfInput *input)
         }
         chupa_metadata_add_value(metadata, meta_filename, path);
     }
-    return g_object_new(CHUPA_TYPE_TEXT_INPUT,
+    return g_object_new(CHUPA_TYPE_TEXT,
                         "input", input,
                         "metadata", metadata,
                         NULL);
@@ -273,7 +273,7 @@ chupa_text_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const
         }
         chupa_metadata_add_value(metadata, meta_filename, path);
     }
-    return g_object_new(CHUPA_TYPE_TEXT_INPUT,
+    return g_object_new(CHUPA_TYPE_TEXT,
                         "stream", stream,
                         "metadata", metadata,
                         NULL);

  Modified: chupatext/chupa_text_input.c (+2 -2)
===================================================================
--- chupatext/chupa_text_input.c    2010-10-18 06:29:02 +0000 (eff3804)
+++ chupatext/chupa_text_input.c    2010-10-18 07:37:45 +0000 (c4480af)
@@ -19,7 +19,7 @@
  */
 
 #include "chupa_text_input.h"
-#include "chupa_text_input_stream.h"
+#include "chupa_gsf_input_stream.h"
 #include <gio/gio.h>
 #include <gsf/gsf-input-gio.h>
 
@@ -108,7 +108,7 @@ constructed(GObject *object)
         path = chupa_metadata_get_first_value(priv->metadata, meta_filename);
     }
     if (!stream) {
-        stream = G_INPUT_STREAM(chupa_text_input_stream_new(input));
+        stream = G_INPUT_STREAM(chupa_gsf_input_stream_new(priv->input));
     }
     if (G_IS_DATA_INPUT_STREAM(stream)) {
         priv->stream = G_DATA_INPUT_STREAM(stream);

  Deleted: chupatext/chupa_text_input_stream.c (+0 -189) 100644
===================================================================
--- chupatext/chupa_text_input_stream.c    2010-10-18 06:29:02 +0000 (798cd9d)
+++ /dev/null
@@ -1,189 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- *  Copyright (C) 2010  Nobuyoshi Nakada <nakada at clear-code.com>
- *
- *  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.1 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 library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- *  MA  02110-1301  USA
- */
-
-#include "chupa_text_input_stream.h"
-
-G_DEFINE_TYPE(ChupaTextInputStream, chupa_text_input_stream, G_TYPE_INPUT_STREAM)
-
-#define CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(obj) \
-    (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
-                                 CHUPA_TYPE_TEXT_INPUT_STREAM, \
-                                 ChupaTextInputStreamPrivate))
-
-typedef struct _ChupaTextInputStreamPrivate ChupaTextInputStreamPrivate;
-
-struct _ChupaTextInputStreamPrivate
-{
-    ChupaTextInput *input;
-};
-
-enum {
-    PROP_0,
-    PROP_INPUT,
-    PROP_DUMMY
-};
-
-enum {
-    peek_buffer_size = 1024
-};
-
-static void
-chupa_text_input_stream_init(ChupaTextInputStream *stream)
-{
-    ChupaTextInputStreamPrivate *priv;
-
-    priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream);
-    priv->input = NULL;
-}
-
-static void
-dispose(GObject *object)
-{
-    ChupaTextInputStreamPrivate *priv;
-
-    priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(object);
-    if (priv->input) {
-        g_object_unref(priv->input);
-        priv->input = NULL;
-    }
-    G_OBJECT_CLASS(chupa_text_input_stream_parent_class)->dispose(object);
-}
-
-static void
-set_property(GObject *object,
-             guint prop_id,
-             const GValue *value,
-             GParamSpec *pspec)
-{
-    ChupaTextInputStreamPrivate *priv;
-    GObject *obj;
-
-    priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(object);
-    switch (prop_id) {
-    case PROP_INPUT:
-        obj = g_value_dup_object(value);
-        priv->input = CHUPA_TEXT_INPUT(obj);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-        break;
-    }
-}
-
-static void
-get_property(GObject *object,
-             guint prop_id,
-             GValue *value,
-             GParamSpec *pspec)
-{
-    ChupaTextInputStreamPrivate *priv;
-
-    priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(object);
-    switch (prop_id) {
-    case PROP_INPUT:
-        g_value_set_object(value, priv->input);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-        break;
-    }
-}
-
-static gssize
-read_fn(GInputStream *stream, void *buffer, gsize count,
-        GCancellable *cancellable, GError **error)
-{
-    ChupaTextInputStreamPrivate *priv;
-    GsfInput *input;
-    gsf_off_t remaining;
-
-    priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream);
-    input = chupa_text_input_get_base_input(priv->input);
-    remaining = gsf_input_remaining(input);
-    if (count > remaining) {
-        count = remaining;
-    }
-    if (!gsf_input_read(input, count, buffer)) {
-        return 0;
-    }
-    return count;
-}
-
-static gssize
-skip_fn(GInputStream *stream, gsize count,
-        GCancellable *cancellable, GError **error)
-{
-    ChupaTextInputStreamPrivate *priv;
-    GsfInput *input;
-
-    priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream);
-    input = chupa_text_input_get_base_input(priv->input);
-    if (gsf_input_seek(input, count, G_SEEK_CUR)) {
-        return (gssize)-1;
-    }
-    return gsf_input_tell(input);
-}
-
-static gboolean
-close_fn(GInputStream *stream, GCancellable *cancellable, GError **error)
-{
-    ChupaTextInputStreamPrivate *priv;
-
-    priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream);
-    if (priv->input) {
-        g_object_unref(priv->input);
-        priv->input = NULL;
-    }
-    return TRUE;
-}
-
-static void
-chupa_text_input_stream_class_init(ChupaTextInputStreamClass *klass)
-{
-    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-    GInputStreamClass *input_stream_class = G_INPUT_STREAM_CLASS(klass);
-    GParamSpec *spec;
-
-    gobject_class->dispose      = dispose;
-    gobject_class->set_property = set_property;
-    gobject_class->get_property = get_property;
-    input_stream_class->read_fn = read_fn;
-    input_stream_class->skip    = skip_fn;
-    input_stream_class->close_fn = close_fn;
-
-    spec = g_param_spec_object("input",
-                               "Input",
-                               "Input",
-                               CHUPA_TYPE_TEXT_INPUT,
-                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
-                               G_PARAM_STATIC_STRINGS);
-    g_object_class_install_property(gobject_class, PROP_INPUT, spec);
-
-    g_type_class_add_private(gobject_class, sizeof(ChupaTextInputStreamPrivate));
-}
-
-ChupaTextInputStream *
-chupa_text_input_stream_new(ChupaTextInput *input)
-{
-    return g_object_new(CHUPA_TYPE_TEXT_INPUT_STREAM,
-                        "input", input,
-                        NULL);
-}
-

  Deleted: chupatext/chupa_text_input_stream.h (+0 -64) 100644
===================================================================
--- chupatext/chupa_text_input_stream.h    2010-10-18 06:29:02 +0000 (e26612b)
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- *  Copyright (C) 2010  Nobuyoshi Nakada <nakada at clear-code.com>
- *
- *  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.1 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 library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- *  MA  02110-1301  USA
- */
-
-#ifndef CHUPA_TEXT_INPUT_STREAM_H
-#define CHUPA_TEXT_INPUT_STREAM_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gio/gio.h>
-
-#include "chupa_metadata.h"
-#include "chupa_text_input.h"
-
-G_BEGIN_DECLS
-
-#define CHUPA_TYPE_TEXT_INPUT_STREAM            chupa_text_input_stream_get_type()
-#define CHUPA_TEXT_INPUT_STREAM(obj)            \
-  G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TEXT_INPUT_STREAM, ChupaTextInputStream)
-#define CHUPA_TEXT_INPUT_STREAM_CLASS(klass)    \
-  G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TEXT_INPUT_STREAM, ChupaTextInputStreamClass)
-#define CHUPA_IS_TEXT_INPUT_STREAM(obj)         \
-  G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_TEXT_INPUT_STREAM)
-#define CHUPA_IS_TEXT_INPUT_STREAM_CLASS(klass) \
-  G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_TEXT_INPUT_STREAM)
-#define CHUPA_TEXT_INPUT_STREAM_GET_CLASS(obj)  \
-  G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TEXT_INPUT_STREAM, ChupaTextInputStreamClass)
-
-typedef struct _ChupaTextInputStream ChupaTextInputStream;
-typedef struct _ChupaTextInputStreamClass ChupaTextInputStreamClass;
-
-struct _ChupaTextInputStream
-{
-    GInputStream object;
-};
-
-struct _ChupaTextInputStreamClass
-{
-    GInputStreamClass parent_class;
-};
-
-GType        chupa_text_input_stream_get_type(void) G_GNUC_CONST;
-ChupaTextInputStream *chupa_text_input_stream_new(ChupaTextInput *input);
-ChupaTextInput *chupa_text_input_stream_get_input(ChupaTextInputStream *stream);
-
-G_END_DECLS
-
-#endif  /* CHUPA_TEXT_INPUT_STREAM_H */

  Modified: module/powerpoint.c (+1 -1)
===================================================================
--- module/powerpoint.c    2010-10-18 06:29:02 +0000 (594ec59)
+++ module/powerpoint.c    2010-10-18 07:37:45 +0000 (a46eab7)
@@ -21,7 +21,7 @@
 
 #include <chupatext/chupa_decomposer_module.h>
 #include <chupatext/external_decomposer.h>
-#include <chupatext/chupa_text_input_stream.h>
+#include <chupatext/chupa_gsf_input_stream.h>
 #include <glib.h>
 #include <gio/gio.h>
 #include <gio/gunixinputstream.h>

  Modified: test/Makefile.am (+2 -2)
===================================================================
--- test/Makefile.am    2010-10-18 06:29:02 +0000 (53b5915)
+++ test/Makefile.am    2010-10-18 07:37:45 +0000 (dd2d9b1)
@@ -14,7 +14,7 @@ noinst_LTLIBRARIES =				\
 	test_metadata.la			\
 	test_text.la				\
 	test_text_input.la			\
-	test_text_input_stream.la		\
+	test_gsf_input_stream.la		\
 	test_decomposer.la			\
 	test_tar.la				\
 	test_zip.la				\
@@ -69,7 +69,7 @@ suite_chupatext_test_la_SOURCES = suite_chupatext_test.c chupa_test_util.c
 test_metadata_la_SOURCES = test_metadata.c
 test_text_la_SOURCES = test_text.c
 test_text_input_la_SOURCES = test_text_input.c
-test_text_input_stream_la_SOURCES = test_text_input_stream.c
+test_gsf_input_stream_la_SOURCES = test_gsf_input_stream.c
 test_decomposer_la_SOURCES = test_decomposer.c
 test_pdf_la_SOURCES = test_pdf.c
 test_word_la_SOURCES = test_word.c

  Deleted: test/test_text_input_stream.c (+0 -73) 100644
===================================================================
--- test/test_text_input_stream.c    2010-10-18 06:29:02 +0000 (66cae3d)
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- *  Copyright (C) 2010  Nobuyoshi Nakada <nakada at clear-code.com>
- *
- *  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.1 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 library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- *  MA  02110-1301  USA
- */
-
-#include <chupatext/chupa_text_input_stream.h>
-
-#include <gcutter.h>
-
-void test_new (void);
-void test_new_with_metadata (void);
-void test_read(void);
-
-static GInputStream *memstream;
-static ChupaTextInput *input;
-
-void
-setup (void)
-{
-    memstream = NULL;
-    input = NULL;
-}
-
-void
-teardown (void)
-{
-    if (memstream)
-        g_object_unref(memstream);
-    if (input)
-        g_object_unref(input);
-}
-
-void
-test_read(void)
-{
-    static const char data[] = "plain\n\0text\nfoo\0bar";
-    GDataInputStream *dis;
-    gsize length;
-    const char *str;
-
-    memstream = g_memory_input_stream_new_from_data(data, sizeof(data) - 1, NULL);
-    input = chupa_text_input_new_from_stream(NULL, memstream, NULL);
-    dis = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input));
-    cut_assert_not_null(dis);
-    str = cut_take_string(g_data_input_stream_read_line(dis, &length, NULL, NULL));
-    cut_assert_equal_string("plain", str);
-    cut_assert_equal_uint(5, length);
-    cut_assert_equal_uint(0, g_data_input_stream_read_byte(dis, NULL, NULL));
-    str = cut_take_string(g_data_input_stream_read_line(dis, &length, NULL, NULL));
-    cut_assert_equal_string("text", str);
-    cut_assert_equal_uint(4, length);
-    str = cut_take_memory(g_data_input_stream_read_line(dis, &length, NULL, NULL));
-    cut_assert_equal_memory("foo\0bar", 7, str, length);
-}
-
-/*
-vi:ts=4:nowrap:ai:expandtab:sw=4
-*/



More information about the groonga-commit mailing list