[libgit2-glib] Port GgitObjectFactory to G_DECLARE_FINAL_TYPE macro
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Port GgitObjectFactory to G_DECLARE_FINAL_TYPE macro
- Date: Tue, 14 Jul 2015 10:55:27 +0000 (UTC)
commit 3dc7f09de0ef5b744a8a7ee90ea609ddf447a4c1
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Tue Jul 14 12:38:06 2015 +0200
Port GgitObjectFactory to G_DECLARE_FINAL_TYPE macro
libgit2-glib/ggit-autocleanup.h | 1 -
libgit2-glib/ggit-object-factory.c | 32 +++++++++++++++++---------------
libgit2-glib/ggit-object-factory.h | 33 ++-------------------------------
libgit2-glib/ggit-types.h | 7 -------
4 files changed, 19 insertions(+), 54 deletions(-)
---
diff --git a/libgit2-glib/ggit-autocleanup.h b/libgit2-glib/ggit-autocleanup.h
index 022c662..31e6712 100644
--- a/libgit2-glib/ggit-autocleanup.h
+++ b/libgit2-glib/ggit-autocleanup.h
@@ -93,7 +93,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitIndex, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitMergeOptions, ggit_merge_options_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitNative, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitNote, ggit_note_unref)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitObjectFactory, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitObjectFactoryBase, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitObject, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitOId, ggit_oid_free)
diff --git a/libgit2-glib/ggit-object-factory.c b/libgit2-glib/ggit-object-factory.c
index f184e50..c21e1c6 100644
--- a/libgit2-glib/ggit-object-factory.c
+++ b/libgit2-glib/ggit-object-factory.c
@@ -28,7 +28,13 @@ typedef struct
GType type;
} TypeWrap;
-struct _GgitObjectFactoryPrivate
+
+/**
+ * GgitObjectFactory:
+ *
+ * Represents an object factory.
+ */
+struct _GgitObjectFactory
{
GHashTable *typemap;
};
@@ -61,7 +67,7 @@ ggit_object_factory_finalize (GObject *object)
factory = GGIT_OBJECT_FACTORY (object);
- g_hash_table_destroy (factory->priv->typemap);
+ g_hash_table_destroy (factory->typemap);
G_OBJECT_CLASS (ggit_object_factory_parent_class)->finalize (object);
}
@@ -93,19 +99,15 @@ ggit_object_factory_class_init (GgitObjectFactoryClass *klass)
object_class->finalize = ggit_object_factory_finalize;
object_class->constructor = ggit_object_factory_constructor;
-
- g_type_class_add_private (object_class, sizeof (GgitObjectFactoryPrivate));
}
static void
-ggit_object_factory_init (GgitObjectFactory *self)
+ggit_object_factory_init (GgitObjectFactory *factory)
{
- self->priv = GGIT_OBJECT_FACTORY_GET_PRIVATE (self);
-
- self->priv->typemap = g_hash_table_new_full ((GHashFunc)g_direct_hash,
- (GEqualFunc)g_direct_equal,
- NULL,
- (GDestroyNotify)type_wrap_free);
+ factory->typemap = g_hash_table_new_full ((GHashFunc)g_direct_hash,
+ (GEqualFunc)g_direct_equal,
+ NULL,
+ (GDestroyNotify)type_wrap_free);
}
/**
@@ -150,7 +152,7 @@ ggit_object_factory_register (GgitObjectFactory *factory,
g_return_if_fail (basetype == subtype || g_type_is_a (subtype, basetype));
g_return_if_fail (g_type_is_a (basetype, GGIT_TYPE_OBJECT_FACTORY_BASE));
- g_hash_table_insert (factory->priv->typemap,
+ g_hash_table_insert (factory->typemap,
GINT_TO_POINTER (g_type_qname (basetype)),
type_wrap_new (subtype));
}
@@ -173,12 +175,12 @@ ggit_object_factory_unregister (GgitObjectFactory *factory,
g_return_if_fail (GGIT_IS_OBJECT_FACTORY (factory));
- val = g_hash_table_lookup (factory->priv->typemap,
+ val = g_hash_table_lookup (factory->typemap,
GINT_TO_POINTER (g_type_qname (basetype)));
if (val && val->type == subtype)
{
- g_hash_table_remove (factory->priv->typemap,
+ g_hash_table_remove (factory->typemap,
GINT_TO_POINTER (g_type_qname (basetype)));
}
}
@@ -228,7 +230,7 @@ ggit_object_factory_construct (GgitObjectFactory *factory,
g_return_val_if_fail (GGIT_IS_OBJECT_FACTORY (factory), NULL);
- val = g_hash_table_lookup (factory->priv->typemap,
+ val = g_hash_table_lookup (factory->typemap,
GINT_TO_POINTER (g_type_qname (basetype)));
if (val)
diff --git a/libgit2-glib/ggit-object-factory.h b/libgit2-glib/ggit-object-factory.h
index 458c54b..e440764 100644
--- a/libgit2-glib/ggit-object-factory.h
+++ b/libgit2-glib/ggit-object-factory.h
@@ -27,37 +27,8 @@
G_BEGIN_DECLS
-#define GGIT_TYPE_OBJECT_FACTORY (ggit_object_factory_get_type ())
-#define GGIT_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GGIT_TYPE_OBJECT_FACTORY,
GgitObjectFactory))
-#define GGIT_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GGIT_TYPE_OBJECT_FACTORY,
GgitObjectFactoryClass))
-#define GGIT_IS_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GGIT_TYPE_OBJECT_FACTORY))
-#define GGIT_IS_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GGIT_TYPE_OBJECT_FACTORY))
-#define GGIT_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GGIT_TYPE_OBJECT_FACTORY,
GgitObjectFactoryClass))
-
-typedef struct _GgitObjectFactoryClass GgitObjectFactoryClass;
-typedef struct _GgitObjectFactoryPrivate GgitObjectFactoryPrivate;
-
-struct _GgitObjectFactory
-{
- /*< private >*/
- GObject parent;
-
- GgitObjectFactoryPrivate *priv;
-};
-
-/**
- * GgitObjectFactoryClass:
- * @parent_class: The parent class.
- *
- * The class structure for #GgitObjectFactoryClass.
- */
-struct _GgitObjectFactoryClass
-{
- /*< private >*/
- GObjectClass parent_class;
-};
-
-GType ggit_object_factory_get_type (void) G_GNUC_CONST;
+#define GGIT_TYPE_OBJECT_FACTORY (ggit_object_factory_get_type ())
+G_DECLARE_FINAL_TYPE (GgitObjectFactory, ggit_object_factory, GGIT, OBJECT_FACTORY, GObject)
GgitObjectFactory *ggit_object_factory_get_default (void);
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index d4a90aa..189e646 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -278,13 +278,6 @@ typedef struct _GgitNote GgitNote;
typedef struct _GgitObject GgitObject;
/**
- * GgitObjectFactory:
- *
- * Represents an object factory.
- */
-typedef struct _GgitObjectFactory GgitObjectFactory;
-
-/**
* GgitObjectFactoryBase:
*
* Represents the base type for objects created by an object factory.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]