[libgda] GdaRepetitiveStatement: ported to G_DEFINE
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaRepetitiveStatement: ported to G_DEFINE
- Date: Thu, 4 Apr 2019 19:49:04 +0000 (UTC)
commit a773bd21ead8814bfcc4b137501d633c98bb51d5
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Apr 3 17:51:40 2019 -0600
GdaRepetitiveStatement: ported to G_DEFINE
libgda/gda-repetitive-statement.c | 42 ++++++++++++---------------------------
libgda/gda-repetitive-statement.h | 15 ++------------
2 files changed, 15 insertions(+), 42 deletions(-)
---
diff --git a/libgda/gda-repetitive-statement.c b/libgda/gda-repetitive-statement.c
index 8103695d7..fdc9b7219 100644
--- a/libgda/gda-repetitive-statement.c
+++ b/libgda/gda-repetitive-statement.c
@@ -22,28 +22,23 @@
#include <libgda/gda-holder.h>
#include <libgda/gda-connection.h>
-typedef struct _GdaRepetitiveStatementPrivate GdaRepetitiveStatementPrivate;
-struct _GdaRepetitiveStatementPrivate
+typedef struct
{
GdaStatement* statement;
GSList* values_sets; /* list of GdaSet pointers, objects referenced here */
-};
+} GdaRepetitiveStatementPrivate;
-#define GDA_REPETITIVE_STATEMENT_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
GDA_TYPE_REPETITIVE_STATEMENT, GdaRepetitiveStatementPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE(GdaRepetitiveStatement, gda_repetitive_statement, G_TYPE_OBJECT)
enum {
PROP_0,
PROP_STATEMENT
};
-G_DEFINE_TYPE (GdaRepetitiveStatement, gda_repetitive_statement, G_TYPE_OBJECT);
-
static void
gda_repetitive_statement_init (GdaRepetitiveStatement *object)
{
- GdaRepetitiveStatementPrivate *priv;
-
- priv = GDA_REPETITIVE_STATEMENT_PRIVATE (object);
+ GdaRepetitiveStatementPrivate *priv = gda_repetitive_statement_get_instance_private (object);
priv->statement = NULL;
priv->values_sets = NULL;
@@ -52,9 +47,7 @@ gda_repetitive_statement_init (GdaRepetitiveStatement *object)
static void
gda_repetitive_statement_finalize (GObject *object)
{
- GdaRepetitiveStatementPrivate *priv;
-
- priv = GDA_REPETITIVE_STATEMENT_PRIVATE (object);
+ GdaRepetitiveStatementPrivate *priv = gda_repetitive_statement_get_instance_private
(GDA_REPETITIVE_STATEMENT (object));
g_object_unref (priv->statement);
g_slist_free_full (priv->values_sets, (GDestroyNotify) g_object_unref);
@@ -65,11 +58,10 @@ gda_repetitive_statement_finalize (GObject *object)
static void
gda_repetitive_statement_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec
*pspec)
{
- GdaRepetitiveStatementPrivate *priv;
-
g_return_if_fail (GDA_IS_REPETITIVE_STATEMENT (object));
- priv = GDA_REPETITIVE_STATEMENT_PRIVATE (object);
+ GdaRepetitiveStatementPrivate *priv = gda_repetitive_statement_get_instance_private
(GDA_REPETITIVE_STATEMENT (object));
+
switch (prop_id) {
case PROP_STATEMENT:
priv->statement = g_value_dup_object (value);
@@ -83,11 +75,10 @@ gda_repetitive_statement_set_property (GObject *object, guint prop_id, const GVa
static void
gda_repetitive_statement_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- GdaRepetitiveStatementPrivate *priv;
-
g_return_if_fail (GDA_IS_REPETITIVE_STATEMENT (object));
- priv = GDA_REPETITIVE_STATEMENT_PRIVATE (object);
+ GdaRepetitiveStatementPrivate *priv = gda_repetitive_statement_get_instance_private
(GDA_REPETITIVE_STATEMENT (object));
+
switch (prop_id) {
case PROP_STATEMENT:
g_value_set_object (value, priv->statement);
@@ -103,8 +94,6 @@ gda_repetitive_statement_class_init (GdaRepetitiveStatementClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GdaRepetitiveStatementPrivate));
-
object_class->finalize = gda_repetitive_statement_finalize;
object_class->set_property = gda_repetitive_statement_set_property;
object_class->get_property = gda_repetitive_statement_get_property;
@@ -159,9 +148,7 @@ gda_repetitive_statement_new (GdaStatement *stmt)
gboolean
gda_repetitive_statement_get_template_set (GdaRepetitiveStatement *rstmt, GdaSet **set, GError **error)
{
- GdaRepetitiveStatementPrivate *priv;
-
- priv = GDA_REPETITIVE_STATEMENT_PRIVATE (rstmt);
+ GdaRepetitiveStatementPrivate *priv = gda_repetitive_statement_get_instance_private (rstmt);
return gda_statement_get_parameters (priv->statement, set, error);
}
@@ -184,13 +171,12 @@ gda_repetitive_statement_get_template_set (GdaRepetitiveStatement *rstmt, GdaSet
gboolean
gda_repetitive_statement_append_set (GdaRepetitiveStatement *rstmt, GdaSet *values, gboolean make_copy)
{
- GdaRepetitiveStatementPrivate *priv;
GdaSet *set;
g_return_val_if_fail (GDA_IS_REPETITIVE_STATEMENT(rstmt), FALSE);
g_return_val_if_fail (GDA_IS_SET (values), FALSE);
-
- priv = GDA_REPETITIVE_STATEMENT_PRIVATE (rstmt);
+
+ GdaRepetitiveStatementPrivate *priv = gda_repetitive_statement_get_instance_private (rstmt);
if (make_copy)
set = gda_set_copy (values);
@@ -214,9 +200,7 @@ gda_repetitive_statement_append_set (GdaRepetitiveStatement *rstmt, GdaSet *valu
GSList*
gda_repetitive_statement_get_all_sets (GdaRepetitiveStatement *rstmt)
{
- GdaRepetitiveStatementPrivate *priv;
-
- priv = GDA_REPETITIVE_STATEMENT_PRIVATE (rstmt);
+ GdaRepetitiveStatementPrivate *priv = gda_repetitive_statement_get_instance_private (rstmt);
return g_slist_copy (g_slist_reverse (priv->values_sets));
}
diff --git a/libgda/gda-repetitive-statement.h b/libgda/gda-repetitive-statement.h
index e5fa061ad..94f34cae6 100644
--- a/libgda/gda-repetitive-statement.h
+++ b/libgda/gda-repetitive-statement.h
@@ -27,20 +27,11 @@
G_BEGIN_DECLS
#define GDA_TYPE_REPETITIVE_STATEMENT (gda_repetitive_statement_get_type ())
-#define GDA_REPETITIVE_STATEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GDA_TYPE_REPETITIVE_STATEMENT, GdaRepetitiveStatement))
-#define GDA_REPETITIVE_STATEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GDA_TYPE_REPETITIVE_STATEMENT, GdaRepetitiveStatementClass))
-#define GDA_IS_REPETITIVE_STATEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GDA_TYPE_REPETITIVE_STATEMENT))
-#define GDA_IS_REPETITIVE_STATEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GDA_TYPE_REPETITIVE_STATEMENT))
-#define GDA_REPETITIVE_STATEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GDA_TYPE_REPETITIVE_STATEMENT, GdaRepetitiveStatementClass))
+G_DECLARE_DERIVABLE_TYPE(GdaRepetitiveStatement, gda_repetitive_statement, GDA, REPETITIVE_STATEMENT,
GObject)
struct _GdaRepetitiveStatementClass
{
- GObjectClass parent_class;
-};
-
-struct _GdaRepetitiveStatement
-{
- GObject parent_instance;
+ GObjectClass parent_class;
};
/**
@@ -57,8 +48,6 @@ struct _GdaRepetitiveStatement
* Use the gda_connection_repetitive_statement_execute() method to execute the repetitive statement.
*/
-GType gda_repetitive_statement_get_type (void) G_GNUC_CONST;
-
GdaRepetitiveStatement* gda_repetitive_statement_new (GdaStatement *stmt);
gboolean gda_repetitive_statement_get_template_set (GdaRepetitiveStatement *rstmt, GdaSet
**set, GError **error);
GSList *gda_repetitive_statement_get_all_sets (GdaRepetitiveStatement *rstmt);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]