[libgit2-glib] Port GgitTreeBuilder to G_DECLARE_DERIVABLE_TYPE macro
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Port GgitTreeBuilder to G_DECLARE_DERIVABLE_TYPE macro
- Date: Wed, 22 Jul 2015 15:28:13 +0000 (UTC)
commit cd7b95680914823013f842bda550bf9b98f80ecb
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Jul 22 17:27:55 2015 +0200
Port GgitTreeBuilder to G_DECLARE_DERIVABLE_TYPE macro
libgit2-glib/ggit-autocleanup.h | 1 -
libgit2-glib/ggit-repository.h | 1 +
libgit2-glib/ggit-tree-builder.c | 32 ++++++++++++++++++--------------
libgit2-glib/ggit-tree-builder.h | 22 ++--------------------
libgit2-glib/ggit-types.h | 7 -------
5 files changed, 21 insertions(+), 42 deletions(-)
---
diff --git a/libgit2-glib/ggit-autocleanup.h b/libgit2-glib/ggit-autocleanup.h
index de61219..7c92017 100644
--- a/libgit2-glib/ggit-autocleanup.h
+++ b/libgit2-glib/ggit-autocleanup.h
@@ -66,7 +66,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRemote, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRepository, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRevisionWalker, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitSubmoduleUpdateOptions, g_object_unref)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitTreeBuilder, g_object_unref)
#endif /* GLIB_CHECK_VERSION (2, 44, 0) */
#endif /* __GI_SCANNER__ */
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index b2f7cf8..79aacf4 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -38,6 +38,7 @@
#include <libgit2-glib/ggit-blame.h>
#include <libgit2-glib/ggit-cherry-pick-options.h>
#include <libgit2-glib/ggit-commit.h>
+#include <libgit2-glib/ggit-tree-builder.h>
G_BEGIN_DECLS
diff --git a/libgit2-glib/ggit-tree-builder.c b/libgit2-glib/ggit-tree-builder.c
index 0b5a5ca..2f04dc6 100644
--- a/libgit2-glib/ggit-tree-builder.c
+++ b/libgit2-glib/ggit-tree-builder.c
@@ -25,23 +25,28 @@
#include "ggit-tree-entry.h"
#include "ggit-repository.h"
-#define GGIT_TREE_BUILDER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GGIT_TYPE_TREE_BUILDER,
GgitTreeBuilderPrivate))
+/**
+ * GgitTreeBuilder:
+ *
+ * Represents a tree object.
+ */
-struct _GgitTreeBuilderPrivate
+typedef struct _GgitTreeBuilderPrivate
{
GgitRepository *repository;
-};
+} GgitTreeBuilderPrivate;
-G_DEFINE_TYPE (GgitTreeBuilder, ggit_tree_builder, GGIT_TYPE_NATIVE)
+G_DEFINE_TYPE_WITH_PRIVATE (GgitTreeBuilder, ggit_tree_builder, GGIT_TYPE_NATIVE)
static void
ggit_tree_builder_dispose (GObject *object)
{
- GgitTreeBuilder *builder;
+ GgitTreeBuilder *builder = GGIT_TREE_BUILDER (object);
+ GgitTreeBuilderPrivate *priv;
- builder = GGIT_TREE_BUILDER (object);
+ priv = ggit_tree_builder_get_instance_private (builder);
- g_clear_object (&builder->priv->repository);
+ g_clear_object (&priv->repository);
G_OBJECT_CLASS (ggit_tree_builder_parent_class)->dispose (object);
}
@@ -49,19 +54,14 @@ ggit_tree_builder_dispose (GObject *object)
static void
ggit_tree_builder_class_init (GgitTreeBuilderClass *klass)
{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = ggit_tree_builder_dispose;
-
- g_type_class_add_private (object_class, sizeof (GgitTreeBuilderPrivate));
}
static void
ggit_tree_builder_init (GgitTreeBuilder *self)
{
- self->priv = GGIT_TREE_BUILDER_GET_PRIVATE (self);
}
GgitTreeBuilder *
@@ -70,6 +70,8 @@ _ggit_tree_builder_wrap (git_treebuilder *builder,
gboolean owned)
{
GgitTreeBuilder *gbuilder;
+ GgitTreeBuilderPrivate *priv;
+
g_return_val_if_fail (builder != NULL, NULL);
g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), NULL);
@@ -78,9 +80,11 @@ _ggit_tree_builder_wrap (git_treebuilder *builder,
"native", builder,
NULL);
+ priv = ggit_tree_builder_get_instance_private (gbuilder);
+
if (repository)
{
- gbuilder->priv->repository = g_object_ref (repository);
+ priv->repository = g_object_ref (repository);
}
if (owned)
diff --git a/libgit2-glib/ggit-tree-builder.h b/libgit2-glib/ggit-tree-builder.h
index 8b214ac..fcd4817 100644
--- a/libgit2-glib/ggit-tree-builder.h
+++ b/libgit2-glib/ggit-tree-builder.h
@@ -28,24 +28,8 @@
G_BEGIN_DECLS
-#define GGIT_TYPE_TREE_BUILDER (ggit_tree_builder_get_type ())
-#define GGIT_TREE_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GGIT_TYPE_TREE_BUILDER,
GgitTreeBuilder))
-#define GGIT_TREE_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GGIT_TYPE_TREE_BUILDER,
GgitTreeBuilderClass))
-#define GGIT_IS_TREE_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GGIT_TYPE_TREE_BUILDER))
-#define GGIT_IS_TREE_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GGIT_TYPE_TREE_BUILDER))
-#define GGIT_TREE_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GGIT_TYPE_TREE_BUILDER,
GgitTreeBuilderClass))
-
-typedef struct _GgitTreeBuilderClass GgitTreeBuilderClass;
-typedef struct _GgitTreeBuilderPrivate GgitTreeBuilderPrivate;
-
-struct _GgitTreeBuilder
-{
- /*< private >*/
- GgitNative parent;
-
- /* priv */
- GgitTreeBuilderPrivate *priv;
-};
+#define GGIT_TYPE_TREE_BUILDER (ggit_tree_builder_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GgitTreeBuilder, ggit_tree_builder, GGIT, TREE_BUILDER, GgitNative)
/**
* GgitTreeBuilderClass:
@@ -59,8 +43,6 @@ struct _GgitTreeBuilderClass
GgitNativeClass parent_class;
};
-GType ggit_tree_builder_get_type (void) G_GNUC_CONST;
-
GgitTreeBuilder *_ggit_tree_builder_wrap (git_treebuilder *builder,
GgitRepository *repository,
gboolean owned);
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 73b2568..dc68d1a 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -286,13 +286,6 @@ typedef struct _GgitTransferProgress GgitTransferProgress;
typedef struct _GgitTreeEntry GgitTreeEntry;
/**
- * GgitTreeBuilder:
- *
- * Represents a tree object.
- */
-typedef struct _GgitTreeBuilder GgitTreeBuilder;
-
-/**
* GgitBlameOptions:
*
* Represents blame options.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]