[Kazehakase-cvs] kazehakase-svn [2972] * ext/ruby/kz-rb-ext.[ch]: moved kz-module-impl related functions to ...

Back to archive index

svnno****@sourc***** svnno****@sourc*****
Fri Mar 23 11:59:49 JST 2007


Revision: 2972
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=2972
Author:   kous
Date:     2007-03-23 11:59:49 +0900 (Fri, 23 Mar 2007)

Log Message:
-----------
* ext/ruby/kz-rb-ext.[ch]: moved kz-module-impl related functions to ...
* ext/ruby/kz-ruby-ext.c: ... here.

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    kazehakase/trunk/ext/ruby/Makefile.am
    kazehakase/trunk/ext/ruby/kz-rb-ext.c
    kazehakase/trunk/ext/ruby/kz-rb-ext.h

Added Paths:
-----------
    kazehakase/trunk/ext/ruby/kz-ruby-ext.c

Modified: kazehakase/trunk/ChangeLog
===================================================================
--- kazehakase/trunk/ChangeLog	2007-03-23 02:45:11 UTC (rev 2971)
+++ kazehakase/trunk/ChangeLog	2007-03-23 02:59:49 UTC (rev 2972)
@@ -1,5 +1,11 @@
 2007-03-23  Kouhei Sutou  <kou****@cozmi*****>
 
+	* ext/ruby/kz-rb-ext.[ch]: moved kz-module-impl related functions
+	to ...
+	* ext/ruby/kz-ruby-ext.c: ... here.
+
+	* ext/ruby/Makefile.am: added kz-ruby-ext.c.
+
 	* src/actions/kz-history-action.c: moved PCRE workaround to ...
 	* src/kz-migemo.c: ... here.
 

Modified: kazehakase/trunk/ext/ruby/Makefile.am
===================================================================
--- kazehakase/trunk/ext/ruby/Makefile.am	2007-03-23 02:45:11 UTC (rev 2971)
+++ kazehakase/trunk/ext/ruby/Makefile.am	2007-03-23 02:59:49 UTC (rev 2972)
@@ -41,6 +41,7 @@
 	-I$(top_srcdir)/src/widget
 
 ruby_la_SOURCES =				\
+	kz-ruby-ext.c				\
 	kz-rb-ext.c kz-rb-ext.h			\
 	kz-rb-app.c				\
 	kz-rb-window.c				\

Modified: kazehakase/trunk/ext/ruby/kz-rb-ext.c
===================================================================
--- kazehakase/trunk/ext/ruby/kz-rb-ext.c	2007-03-23 02:45:11 UTC (rev 2971)
+++ kazehakase/trunk/ext/ruby/kz-rb-ext.c	2007-03-23 02:59:49 UTC (rev 2972)
@@ -1,6 +1,7 @@
 /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
 
 /*
+ *  Copyright (C) 2007 Kouhei Sutou <kou****@cozmi*****>
  *  Copyright (C) 2006 Eriko Sato
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -22,10 +23,6 @@
 #include <glib/gi18n.h>
 #include "kz-rb-ext.h"
 
-#include "kz-ext.h"
-#include "kz-module-impl.h"
-
-
 #ifdef POSIX_SIGNAL
 #define ruby_signal(sig, handle) posix_signal((sig), (handle))
 #else
@@ -128,8 +125,8 @@
 }
 
 
-static void
-init (gpointer initial_address)
+void
+kz_rb_ext_init (gpointer initial_address)
 {
     gchar *dirname;
     char *argv[] = {"kazehakase"};
@@ -170,8 +167,8 @@
     }
 }
 
-static void
-setup (KzExt *ext, KzWindow *kz)
+void
+kz_rb_ext_setup (KzWindow *kz)
 {
     if (RTEST(rb_const_get(mKz, rb_intern("ENABLE")))) {
         rb_funcall(mKz, rb_intern("setup"), 1, GOBJ2RVAL(kz));
@@ -179,197 +176,9 @@
     }
 }
 
-static void
-cleanup (void)
+void
+kz_rb_ext_cleanup (void)
 {
     rb_funcall(mKz, rb_intern("exit"), 0);
     ruby_cleanup(0);
 }
-
-
-enum {
-    PROP_0,
-    PROP_INITIAL_ADDRESS
-};
-
-#define KZ_TYPE_RUBY_EXT		kz_type_ruby_ext
-#define KZ_RUBY_EXT(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_RUBY_EXT, KzRubyExt))
-#define KZ_RUBY_EXT_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_RUBY_EXT, KzRubyExtClass))
-#define KZ_IS_RUBY_EXT(obj)	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_RUBY_EXT))
-#define KZ_IS_RUBY_EXT_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_RUBY_EXT))
-#define KZ_RUBY_EXT_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_RUBY_EXT, KzRubyExtClass))
-
-typedef struct _KzRubyExt		KzRubyExt;
-typedef struct _KzRubyExtClass		KzRubyExtClass;
-
-struct _KzRubyExt
-{
-    GObject	parent;
-
-    gpointer	initial_address;
-};
-
-struct _KzRubyExtClass
-{
-    GObjectClass parent_class;
-};
-
-static GType kz_type_ruby_ext = 0;
-static GObjectClass *kz_ruby_ext_parent_class;
-
-static void kz_ruby_ext_class_init	(KzRubyExtClass *klass);
-static void kz_ruby_ext_iface_init	(KzExtIFace	*iface);
-
-static void setup (KzExt *ext, KzWindow *window);
-
-static void     dispose      (GObject      *object);
-static void     set_property (GObject      *object,
-                              guint         prop_id,
-                              const GValue *value,
-                              GParamSpec   *pspec);
-static void     get_property (GObject      *object,
-                              guint         prop_id,
-                              GValue       *value,
-                              GParamSpec   *pspec);
-
-static void
-kz_ruby_ext_register_type (GTypeModule *module)
-{
-    static const GTypeInfo kz_ruby_ext_info =
-	{
-            sizeof (KzRubyExtClass),
-            NULL,		/* base_init */
-            NULL,		/* base_finalize */
-            (GClassInitFunc) kz_ruby_ext_class_init,
-            NULL,		/* class_finalize */
-            NULL,		/* class_data */
-            sizeof (KzRubyExt),
-            0,		/* n_preallocs */
-            NULL,
-	};
-
-    const GInterfaceInfo kz_ext_info =
-	{
-            (GInterfaceInitFunc) kz_ruby_ext_iface_init,
-            NULL,
-            NULL
-	};
-
-    kz_type_ruby_ext = g_type_module_register_type(module,
-                                                   G_TYPE_OBJECT,
-                                                   "KzRubyExt",
-                                                   &kz_ruby_ext_info,
-                                                   (GTypeFlags)0);
-
-    g_type_module_add_interface(module,
-                                KZ_TYPE_RUBY_EXT,
-                                KZ_TYPE_EXT,
-                                &kz_ext_info);
-}
-
-G_MODULE_EXPORT void
-KZ_MODULE_IMPL_INIT (GTypeModule *module)
-{
-    kz_ruby_ext_register_type(module);
-}
-
-G_MODULE_EXPORT void
-KZ_MODULE_IMPL_EXIT (void)
-{
-}
-
-G_MODULE_EXPORT GObject *
-KZ_MODULE_IMPL_INSTANTIATE (const gchar *first_property,
-			    va_list      var_args)
-{
-    KzRubyExt *ext;
-
-    ext = KZ_RUBY_EXT(g_object_new_valist(KZ_TYPE_RUBY_EXT,
-                                          first_property, var_args));
-    init(ext->initial_address);
-    return G_OBJECT(ext);
-}
-
-static void
-kz_ruby_ext_class_init (KzRubyExtClass *klass)
-{
-    GObjectClass *gobject_class;
-
-    kz_ruby_ext_parent_class = (GObjectClass *)g_type_class_peek_parent(klass);
-
-    gobject_class   = (GObjectClass *) klass;
-
-    gobject_class->dispose      = dispose;
-    gobject_class->set_property = set_property;
-    gobject_class->get_property = get_property;
-
-    g_object_class_install_property
-        (gobject_class,
-         PROP_INITIAL_ADDRESS,
-         g_param_spec_pointer(
-             "initial-address",
-             _("The initial address"),
-             _("The initial address of the program"),
-             (GParamFlags) G_PARAM_READWRITE));
-}
-
-
-static void
-dispose (GObject *object)
-{
-    KzRubyExt *ext = KZ_RUBY_EXT(object);
-
-    if (ext->initial_address) {
-        ext->initial_address = 0;
-        cleanup();
-    }
-
-    if (G_OBJECT_CLASS (kz_ruby_ext_parent_class)->dispose)
-        G_OBJECT_CLASS (kz_ruby_ext_parent_class)->dispose(object);
-}
-
-static void
-set_property (GObject         *object,
-              guint            prop_id,
-              const GValue    *value,
-              GParamSpec      *pspec)
-{
-    KzRubyExt *ext = KZ_RUBY_EXT(object);
-
-    switch (prop_id)
-    {
-      case PROP_INITIAL_ADDRESS:
-        ext->initial_address = g_value_get_pointer(value);
-        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)
-{
-    KzRubyExt *ext = KZ_RUBY_EXT (object);
-
-    switch (prop_id)
-    {
-      case PROP_INITIAL_ADDRESS:
-        g_value_set_pointer(value, ext->initial_address);
-        break;
-      default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-        break;
-    }
-}
-
-
-static void
-kz_ruby_ext_iface_init (KzExtIFace *iface)
-{
-    iface->setup = setup;
-}

Modified: kazehakase/trunk/ext/ruby/kz-rb-ext.h
===================================================================
--- kazehakase/trunk/ext/ruby/kz-rb-ext.h	2007-03-23 02:45:11 UTC (rev 2971)
+++ kazehakase/trunk/ext/ruby/kz-rb-ext.h	2007-03-23 02:59:49 UTC (rev 2972)
@@ -19,6 +19,11 @@
 #include "kz-enum-types.h"
 #include "kz-embed-event.h"
 
+void kz_rb_ext_init (gpointer initial_address);
+void kz_rb_ext_setup (KzWindow *kz);
+void kz_rb_ext_cleanup (void);
+
+
 #define RVAL2DLGRP(obj)    (KZ_DOWNLOADER_GROUP(RVAL2GOBJ(obj)))
 #define RVAL2DL(obj)       (KZ_DOWNLOADER(RVAL2GOBJ(obj)))
 #define EVENTMOUSE2RVAL(obj) \

Added: kazehakase/trunk/ext/ruby/kz-ruby-ext.c
===================================================================
--- kazehakase/trunk/ext/ruby/kz-ruby-ext.c	2007-03-23 02:45:11 UTC (rev 2971)
+++ kazehakase/trunk/ext/ruby/kz-ruby-ext.c	2007-03-23 02:59:49 UTC (rev 2972)
@@ -0,0 +1,220 @@
+/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
+
+/*
+ *  Copyright (C) 2007 Kouhei Sutou <kou****@cozmi*****>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU 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.
+ */
+
+#include <stdio.h>
+#include <glib/gi18n.h>
+#include "kz-rb-ext.h"
+
+#include "kz-ext.h"
+#include "kz-module-impl.h"
+
+enum {
+    PROP_0,
+    PROP_INITIAL_ADDRESS
+};
+
+#define KZ_TYPE_RUBY_EXT		kz_type_ruby_ext
+#define KZ_RUBY_EXT(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_RUBY_EXT, KzRubyExt))
+#define KZ_RUBY_EXT_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_RUBY_EXT, KzRubyExtClass))
+#define KZ_IS_RUBY_EXT(obj)	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_RUBY_EXT))
+#define KZ_IS_RUBY_EXT_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_RUBY_EXT))
+#define KZ_RUBY_EXT_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_RUBY_EXT, KzRubyExtClass))
+
+typedef struct _KzRubyExt		KzRubyExt;
+typedef struct _KzRubyExtClass		KzRubyExtClass;
+
+struct _KzRubyExt
+{
+    GObject	parent;
+
+    gpointer	initial_address;
+};
+
+struct _KzRubyExtClass
+{
+    GObjectClass parent_class;
+};
+
+static GType kz_type_ruby_ext = 0;
+static GObjectClass *kz_ruby_ext_parent_class;
+
+static void kz_ruby_ext_class_init	(KzRubyExtClass *klass);
+static void kz_ruby_ext_iface_init	(KzExtIFace	*iface);
+
+static void setup (KzExt *ext, KzWindow *window);
+
+static void     dispose      (GObject      *object);
+static void     set_property (GObject      *object,
+                              guint         prop_id,
+                              const GValue *value,
+                              GParamSpec   *pspec);
+static void     get_property (GObject      *object,
+                              guint         prop_id,
+                              GValue       *value,
+                              GParamSpec   *pspec);
+
+static void
+kz_ruby_ext_register_type (GTypeModule *module)
+{
+    static const GTypeInfo kz_ruby_ext_info =
+	{
+            sizeof (KzRubyExtClass),
+            NULL,		/* base_init */
+            NULL,		/* base_finalize */
+            (GClassInitFunc) kz_ruby_ext_class_init,
+            NULL,		/* class_finalize */
+            NULL,		/* class_data */
+            sizeof (KzRubyExt),
+            0,		/* n_preallocs */
+            NULL,
+	};
+
+    const GInterfaceInfo kz_ext_info =
+	{
+            (GInterfaceInitFunc) kz_ruby_ext_iface_init,
+            NULL,
+            NULL
+	};
+
+    kz_type_ruby_ext = g_type_module_register_type(module,
+                                                   G_TYPE_OBJECT,
+                                                   "KzRubyExt",
+                                                   &kz_ruby_ext_info,
+                                                   (GTypeFlags)0);
+
+    g_type_module_add_interface(module,
+                                KZ_TYPE_RUBY_EXT,
+                                KZ_TYPE_EXT,
+                                &kz_ext_info);
+}
+
+G_MODULE_EXPORT void
+KZ_MODULE_IMPL_INIT (GTypeModule *module)
+{
+    kz_ruby_ext_register_type(module);
+}
+
+G_MODULE_EXPORT void
+KZ_MODULE_IMPL_EXIT (void)
+{
+}
+
+G_MODULE_EXPORT GObject *
+KZ_MODULE_IMPL_INSTANTIATE (const gchar *first_property,
+			    va_list      var_args)
+{
+    KzRubyExt *ext;
+
+    ext = KZ_RUBY_EXT(g_object_new_valist(KZ_TYPE_RUBY_EXT,
+                                          first_property, var_args));
+    kz_rb_ext_init(ext->initial_address);
+    return G_OBJECT(ext);
+}
+
+static void
+kz_ruby_ext_class_init (KzRubyExtClass *klass)
+{
+    GObjectClass *gobject_class;
+
+    kz_ruby_ext_parent_class = (GObjectClass *)g_type_class_peek_parent(klass);
+
+    gobject_class   = (GObjectClass *) klass;
+
+    gobject_class->dispose      = dispose;
+    gobject_class->set_property = set_property;
+    gobject_class->get_property = get_property;
+
+    g_object_class_install_property
+        (gobject_class,
+         PROP_INITIAL_ADDRESS,
+         g_param_spec_pointer(
+             "initial-address",
+             _("The initial address"),
+             _("The initial address of the program"),
+             (GParamFlags) G_PARAM_READWRITE));
+}
+
+
+static void
+dispose (GObject *object)
+{
+    KzRubyExt *ext = KZ_RUBY_EXT(object);
+
+    if (ext->initial_address) {
+        ext->initial_address = 0;
+        kz_rb_ext_cleanup();
+    }
+
+    if (G_OBJECT_CLASS (kz_ruby_ext_parent_class)->dispose)
+        G_OBJECT_CLASS (kz_ruby_ext_parent_class)->dispose(object);
+}
+
+static void
+set_property (GObject         *object,
+              guint            prop_id,
+              const GValue    *value,
+              GParamSpec      *pspec)
+{
+    KzRubyExt *ext = KZ_RUBY_EXT(object);
+
+    switch (prop_id)
+    {
+      case PROP_INITIAL_ADDRESS:
+        ext->initial_address = g_value_get_pointer(value);
+        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)
+{
+    KzRubyExt *ext = KZ_RUBY_EXT (object);
+
+    switch (prop_id)
+    {
+      case PROP_INITIAL_ADDRESS:
+        g_value_set_pointer(value, ext->initial_address);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+
+static void
+kz_ruby_ext_iface_init (KzExtIFace *iface)
+{
+    iface->setup = setup;
+}
+
+
+static void
+setup (KzExt *ext, KzWindow *window)
+{
+    kz_rb_ext_setup(window);
+}




More information about the Kazehakase-cvs mailing list
Back to archive index