[libgda] GdaPostgresBlobOp: ported to G_DECLARE/G_DEFINE
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaPostgresBlobOp: ported to G_DECLARE/G_DEFINE
- Date: Fri, 5 Apr 2019 23:00:37 +0000 (UTC)
commit 272ab6b0c2cd56e5fe40e038514ccfe40342790b
Author: Daniel Espinosa <esodan gmail com>
Date: Fri Apr 5 12:54:30 2019 -0600
GdaPostgresBlobOp: ported to G_DECLARE/G_DEFINE
Takes a hard references to GdaConnection
providers/postgres/gda-postgres-blob-op.c | 205 ++++++++++-----------
providers/postgres/gda-postgres-blob-op.h | 15 +-
providers/postgres/gda-postgres-ddl.c | 3 +-
providers/reuseable/postgres/gda-postgres-parser.c | 31 +---
providers/reuseable/postgres/gda-postgres-parser.h | 17 +-
5 files changed, 101 insertions(+), 170 deletions(-)
---
diff --git a/providers/postgres/gda-postgres-blob-op.c b/providers/postgres/gda-postgres-blob-op.c
index ede0b74c6..ad00eefb9 100644
--- a/providers/postgres/gda-postgres-blob-op.c
+++ b/providers/postgres/gda-postgres-blob-op.c
@@ -28,62 +28,31 @@
#include <libgda/gda-blob-op-impl.h>
#include "gda-postgres-util.h"
-struct _GdaPostgresBlobOpPrivate {
- GdaConnection *cnc;
- Oid blobid; /* SQL ID in database */
- gint fd; /* to use with lo_read, lo_write, lo_lseek, lo_tell, and lo_close */
-};
static void gda_postgres_blob_op_class_init (GdaPostgresBlobOpClass *klass);
-static void gda_postgres_blob_op_init (GdaPostgresBlobOp *blob,
- GdaPostgresBlobOpClass *klass);
-static void gda_postgres_blob_op_finalize (GObject *object);
+static void gda_postgres_blob_op_init (GdaPostgresBlobOp *blob);
+static void gda_postgres_blob_op_dispose (GObject *object);
static glong gda_postgres_blob_op_get_length (GdaBlobOp *op);
static glong gda_postgres_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size);
static glong gda_postgres_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset);
-static GObjectClass *parent_class = NULL;
+typedef struct {
+ GdaConnection *cnc;
+ Oid blobid; /* SQL ID in database */
+ gint fd; /* to use with lo_read, lo_write, lo_lseek, lo_tell, and lo_close */
+} GdaPostgresBlobOpPrivate;
-/*
- * Object init and finalize
- */
-GType
-gda_postgres_blob_op_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static GMutex registering;
- static const GTypeInfo info = {
- sizeof (GdaPostgresBlobOpClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gda_postgres_blob_op_class_init,
- NULL,
- NULL,
- sizeof (GdaPostgresBlobOp),
- 0,
- (GInstanceInitFunc) gda_postgres_blob_op_init,
- 0
- };
- g_mutex_lock (®istering);
- if (type == 0)
- type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaPostgresBlobOp", &info, 0);
- g_mutex_unlock (®istering);
- }
- return type;
-}
+G_DEFINE_TYPE_WITH_PRIVATE(GdaPostgresBlobOp, gda_postgres_blob_op, GDA_TYPE_BLOB_OP)
static void
-gda_postgres_blob_op_init (GdaPostgresBlobOp *op,
- G_GNUC_UNUSED GdaPostgresBlobOpClass *klass)
+gda_postgres_blob_op_init (GdaPostgresBlobOp *op)
{
g_return_if_fail (GDA_IS_POSTGRES_BLOB_OP (op));
- op->priv = g_new0 (GdaPostgresBlobOpPrivate, 1);
- op->priv->blobid = InvalidOid;
- op->priv->fd = -1;
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (op);
+ priv->blobid = InvalidOid;
+ priv->fd = -1;
}
static void
@@ -92,9 +61,7 @@ gda_postgres_blob_op_class_init (GdaPostgresBlobOpClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdaBlobOpClass *blob_class = GDA_BLOB_OP_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = gda_postgres_blob_op_finalize;
+ object_class->dispose = gda_postgres_blob_op_dispose;
GDA_BLOB_OP_FUNCTIONS (blob_class->functions)->get_length = gda_postgres_blob_op_get_length;
GDA_BLOB_OP_FUNCTIONS (blob_class->functions)->read = gda_postgres_blob_op_read;
GDA_BLOB_OP_FUNCTIONS (blob_class->functions)->write = gda_postgres_blob_op_write;
@@ -116,51 +83,57 @@ static gboolean
blob_op_open (GdaPostgresBlobOp *pgop)
{
gboolean use_svp = FALSE;
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
- if (pgop->priv->blobid == InvalidOid)
+ if (priv->blobid == InvalidOid)
return FALSE;
- if (pgop->priv->fd >= 0)
+ if (priv->fd >= 0)
return TRUE;
- if (gda_connection_get_transaction_status (pgop->priv->cnc))
+ if (gda_connection_get_transaction_status (priv->cnc))
/* add a savepoint to prevent a blob open failure from rendering the transaction unusable */
use_svp = TRUE;
if (use_svp)
- use_svp = gda_connection_add_savepoint (pgop->priv->cnc, "__gda_blob_read_svp", NULL);
+ use_svp = gda_connection_add_savepoint (priv->cnc, "__gda_blob_read_svp", NULL);
- pgop->priv->fd = lo_open (get_pconn (pgop->priv->cnc), pgop->priv->blobid, INV_READ | INV_WRITE);
- if (pgop->priv->fd < 0) {
- _gda_postgres_make_error (pgop->priv->cnc, get_pconn (pgop->priv->cnc), NULL, NULL);
+ priv->fd = lo_open (get_pconn (priv->cnc), priv->blobid, INV_READ | INV_WRITE);
+ if (priv->fd < 0) {
+ _gda_postgres_make_error (priv->cnc, get_pconn (priv->cnc), NULL, NULL);
if (use_svp)
- gda_connection_rollback_savepoint (pgop->priv->cnc, "__gda_blob_read_svp", NULL);
+ gda_connection_rollback_savepoint (priv->cnc, "__gda_blob_read_svp", NULL);
return FALSE;
}
if (use_svp)
- gda_connection_delete_savepoint (pgop->priv->cnc, "__gda_blob_read_svp", NULL);
+ gda_connection_delete_savepoint (priv->cnc, "__gda_blob_read_svp", NULL);
return TRUE;
}
static void
blob_op_close (GdaPostgresBlobOp *pgop)
{
- lo_close (get_pconn (pgop->priv->cnc), pgop->priv->fd);
- pgop->priv->fd = -1;
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+ lo_close (get_pconn (priv->cnc), priv->fd);
+ priv->fd = -1;
}
static void
-gda_postgres_blob_op_finalize (GObject * object)
+gda_postgres_blob_op_dispose (GObject * object)
{
GdaPostgresBlobOp *pgop = (GdaPostgresBlobOp *) object;
g_return_if_fail (GDA_IS_POSTGRES_BLOB_OP (pgop));
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
- if (pgop->priv->fd >= 0)
- lo_close (get_pconn (pgop->priv->cnc), pgop->priv->fd);
- g_free (pgop->priv);
- pgop->priv = NULL;
+ if (priv->fd >= 0) {
+ lo_close (get_pconn (priv->cnc), priv->fd);
+ if (priv->cnc != NULL) {
+ g_object_unref (priv->cnc);
+ priv->cnc = NULL;
+ }
+ }
- parent_class->finalize (object);
+ G_OBJECT_CLASS(gda_postgres_blob_op_parent_class)->finalize (object);
}
GdaBlobOp *
@@ -171,7 +144,10 @@ gda_postgres_blob_op_new (GdaConnection *cnc)
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
pgop = g_object_new (GDA_TYPE_POSTGRES_BLOB_OP, "connection", cnc, NULL);
- pgop->priv->cnc = cnc;
+
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+
+ priv->cnc = g_object_ref (cnc);
return GDA_BLOB_OP (pgop);
}
@@ -185,8 +161,10 @@ gda_postgres_blob_op_new_with_id (GdaConnection *cnc, const gchar *sql_id)
pgop = g_object_new (GDA_TYPE_POSTGRES_BLOB_OP, "connection", cnc, NULL);
- pgop->priv->blobid = atoi (sql_id);
- pgop->priv->cnc = cnc;
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+
+ priv->blobid = atoi (sql_id);
+ priv->cnc = g_object_ref (cnc);
return GDA_BLOB_OP (pgop);
}
@@ -200,13 +178,14 @@ gboolean
gda_postgres_blob_op_declare_blob (GdaPostgresBlobOp *pgop)
{
g_return_val_if_fail (GDA_IS_POSTGRES_BLOB_OP (pgop), FALSE);
- g_return_val_if_fail (pgop->priv, FALSE);
- if (pgop->priv->blobid == InvalidOid) {
- PGconn *pconn = get_pconn (pgop->priv->cnc);
- pgop->priv->blobid = lo_creat (pconn, INV_READ | INV_WRITE);
- if (pgop->priv->blobid == InvalidOid) {
- _gda_postgres_make_error (pgop->priv->cnc, pconn, NULL, NULL);
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+
+ if (priv->blobid == InvalidOid) {
+ PGconn *pconn = get_pconn (priv->cnc);
+ priv->blobid = lo_creat (pconn, INV_READ | INV_WRITE);
+ if (priv->blobid == InvalidOid) {
+ _gda_postgres_make_error (priv->cnc, pconn, NULL, NULL);
return FALSE;
}
}
@@ -223,12 +202,13 @@ gchar *
gda_postgres_blob_op_get_id (GdaPostgresBlobOp *pgop)
{
g_return_val_if_fail (GDA_IS_POSTGRES_BLOB_OP (pgop), NULL);
- g_return_val_if_fail (pgop->priv, NULL);
- if (pgop->priv->blobid == InvalidOid)
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+
+ if (priv->blobid == InvalidOid)
return NULL;
else
- return g_strdup_printf ("%d", pgop->priv->blobid);
+ return g_strdup_printf ("%d", priv->blobid);
}
/**
@@ -238,21 +218,22 @@ void
gda_postgres_blob_op_set_id (GdaPostgresBlobOp *pgop, const gchar *sql_id)
{
g_return_if_fail (GDA_IS_POSTGRES_BLOB_OP (pgop));
- g_return_if_fail (pgop->priv);
g_return_if_fail (sql_id);
- if (pgop->priv->fd >= 0)
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+
+ if (priv->fd >= 0)
blob_op_close (pgop);
- pgop->priv->blobid = atoi (sql_id);
+ priv->blobid = atoi (sql_id);
}
static gboolean
check_transaction_started (GdaConnection *cnc, gboolean *out_started)
{
- GdaTransactionStatus *trans;
+ GdaTransactionStatus *trans;
- trans = gda_connection_get_transaction_status (cnc);
- if (!trans) {
+ trans = gda_connection_get_transaction_status (cnc);
+ if (!trans) {
if (!gda_connection_begin_transaction (cnc, NULL,
GDA_TRANSACTION_ISOLATION_UNKNOWN, NULL))
return FALSE;
@@ -275,33 +256,34 @@ gda_postgres_blob_op_get_length (GdaBlobOp *op)
g_return_val_if_fail (GDA_IS_POSTGRES_BLOB_OP (op), -1);
pgop = GDA_POSTGRES_BLOB_OP (op);
- g_return_val_if_fail (pgop->priv, -1);
- g_return_val_if_fail (GDA_IS_CONNECTION (pgop->priv->cnc), -1);
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+
+ g_return_val_if_fail (GDA_IS_CONNECTION (priv->cnc), -1);
- if (! check_transaction_started (pgop->priv->cnc, &transaction_started))
+ if (! check_transaction_started (priv->cnc, &transaction_started))
return -1;
if (!blob_op_open (pgop))
goto out_error;
- pconn = get_pconn (pgop->priv->cnc);
- pos = lo_lseek (pconn, pgop->priv->fd, 0, SEEK_END);
+ pconn = get_pconn (priv->cnc);
+ pos = lo_lseek (pconn, priv->fd, 0, SEEK_END);
if (pos < 0) {
- _gda_postgres_make_error (pgop->priv->cnc, pconn, NULL, NULL);
+ _gda_postgres_make_error (priv->cnc, pconn, NULL, NULL);
goto out_error;
}
blob_op_close (pgop);
if (transaction_started)
- gda_connection_rollback_transaction (pgop->priv->cnc, NULL, NULL);
+ gda_connection_rollback_transaction (priv->cnc, NULL, NULL);
return pos;
out_error:
blob_op_close (pgop);
if (transaction_started)
- gda_connection_rollback_transaction (pgop->priv->cnc, NULL, NULL);
+ gda_connection_rollback_transaction (priv->cnc, NULL, NULL);
return -1;
}
@@ -316,40 +298,41 @@ gda_postgres_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong siz
g_return_val_if_fail (GDA_IS_POSTGRES_BLOB_OP (op), -1);
pgop = GDA_POSTGRES_BLOB_OP (op);
- g_return_val_if_fail (pgop->priv, -1);
- g_return_val_if_fail (GDA_IS_CONNECTION (pgop->priv->cnc), -1);
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+
+ g_return_val_if_fail (GDA_IS_CONNECTION (priv->cnc), -1);
if (offset >= G_MAXINT)
return -1;
g_return_val_if_fail (blob, -1);
- if (! check_transaction_started (pgop->priv->cnc, &transaction_started))
+ if (! check_transaction_started (priv->cnc, &transaction_started))
return -1;
if (!blob_op_open (pgop))
goto out_error;
- pconn = get_pconn (pgop->priv->cnc);
- if (lo_lseek (pconn, pgop->priv->fd, offset, SEEK_SET) < 0) {
- _gda_postgres_make_error (pgop->priv->cnc, pconn, NULL, NULL);
+ pconn = get_pconn (priv->cnc);
+ if (lo_lseek (pconn, priv->fd, offset, SEEK_SET) < 0) {
+ _gda_postgres_make_error (priv->cnc, pconn, NULL, NULL);
goto out_error;
}
bin = gda_blob_get_binary (blob);
gda_binary_reset_data (bin);
guchar *buffer = g_new0 (guchar, size);
- glong l = lo_read (pconn, pgop->priv->fd, (char *) (buffer), size);
+ glong l = lo_read (pconn, priv->fd, (char *) (buffer), size);
gda_binary_set_data (bin, buffer, l);
blob_op_close (pgop);
if (transaction_started)
- gda_connection_rollback_transaction (pgop->priv->cnc, NULL, NULL);
+ gda_connection_rollback_transaction (priv->cnc, NULL, NULL);
return gda_binary_get_size (bin);
out_error:
blob_op_close (pgop);
if (transaction_started)
- gda_connection_rollback_transaction (pgop->priv->cnc, NULL, NULL);
+ gda_connection_rollback_transaction (priv->cnc, NULL, NULL);
return -1;
}
@@ -364,19 +347,21 @@ gda_postgres_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
g_return_val_if_fail (GDA_IS_POSTGRES_BLOB_OP (op), -1);
pgop = GDA_POSTGRES_BLOB_OP (op);
- g_return_val_if_fail (pgop->priv, -1);
- g_return_val_if_fail (GDA_IS_CONNECTION (pgop->priv->cnc), -1);
+
+ GdaPostgresBlobOpPrivate *priv = gda_postgres_blob_op_get_instance_private (pgop);
+
+ g_return_val_if_fail (GDA_IS_CONNECTION (priv->cnc), -1);
g_return_val_if_fail (blob, -1);
- if (! check_transaction_started (pgop->priv->cnc, &transaction_started))
+ if (! check_transaction_started (priv->cnc, &transaction_started))
return -1;
if (!blob_op_open (pgop))
goto out_error;
- pconn = get_pconn (pgop->priv->cnc);
- if (lo_lseek (pconn, pgop->priv->fd, offset, SEEK_SET) < 0) {
- _gda_postgres_make_error (pgop->priv->cnc, pconn, NULL, NULL);
+ pconn = get_pconn (priv->cnc);
+ if (lo_lseek (pconn, priv->fd, offset, SEEK_SET) < 0) {
+ _gda_postgres_make_error (priv->cnc, pconn, NULL, NULL);
goto out_error;
}
@@ -394,10 +379,10 @@ gda_postgres_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
nread = gda_blob_op_read (gda_blob_get_op (tmpblob), tmpblob, nbwritten, buf_size)) {
GdaBinary *bin = gda_blob_get_binary (tmpblob);
glong tmp_written;
- tmp_written = lo_write (pconn, pgop->priv->fd, (char*) gda_binary_get_data (bin),
+ tmp_written = lo_write (pconn, priv->fd, (char*) gda_binary_get_data (bin),
gda_binary_get_size (bin));
if (tmp_written < gda_binary_get_size (bin)) {
- _gda_postgres_make_error (pgop->priv->cnc, pconn, NULL, NULL);
+ _gda_postgres_make_error (priv->cnc, pconn, NULL, NULL);
gda_blob_free (tmpblob);
goto out_error;
}
@@ -411,16 +396,16 @@ gda_postgres_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
else {
/* use data in (GdaBinary *) blob */
GdaBinary *bin = gda_blob_get_binary (blob);
- nbwritten = lo_write (pconn, pgop->priv->fd, (char*) gda_binary_get_data (bin),
gda_binary_get_size (bin));
+ nbwritten = lo_write (pconn, priv->fd, (char*) gda_binary_get_data (bin), gda_binary_get_size
(bin));
if (nbwritten == -1) {
- _gda_postgres_make_error (pgop->priv->cnc, pconn, NULL, NULL);
+ _gda_postgres_make_error (priv->cnc, pconn, NULL, NULL);
goto out_error;
}
}
blob_op_close (pgop);
if (transaction_started)
- if (!gda_connection_commit_transaction (pgop->priv->cnc, NULL, NULL))
+ if (!gda_connection_commit_transaction (priv->cnc, NULL, NULL))
return -1;
return nbwritten;
@@ -428,6 +413,6 @@ gda_postgres_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
out_error:
blob_op_close (pgop);
if (transaction_started)
- gda_connection_rollback_transaction (pgop->priv->cnc, NULL, NULL);
+ gda_connection_rollback_transaction (priv->cnc, NULL, NULL);
return -1;
}
diff --git a/providers/postgres/gda-postgres-blob-op.h b/providers/postgres/gda-postgres-blob-op.h
index 06d6786d3..45f16ea52 100644
--- a/providers/postgres/gda-postgres-blob-op.h
+++ b/providers/postgres/gda-postgres-blob-op.h
@@ -26,25 +26,12 @@
G_BEGIN_DECLS
#define GDA_TYPE_POSTGRES_BLOB_OP (gda_postgres_blob_op_get_type())
-#define GDA_POSTGRES_BLOB_OP(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_POSTGRES_BLOB_OP,
GdaPostgresBlobOp))
-#define GDA_POSTGRES_BLOB_OP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_POSTGRES_BLOB_OP,
GdaPostgresBlobOpClass))
-#define GDA_IS_POSTGRES_BLOB_OP(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GDA_TYPE_POSTGRES_BLOB_OP))
-#define GDA_IS_POSTGRES_BLOB_OP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDA_TYPE_POSTGRES_BLOB_OP))
-
-typedef struct _GdaPostgresBlobOp GdaPostgresBlobOp;
-typedef struct _GdaPostgresBlobOpClass GdaPostgresBlobOpClass;
-typedef struct _GdaPostgresBlobOpPrivate GdaPostgresBlobOpPrivate;
-
-struct _GdaPostgresBlobOp {
- GdaBlobOp parent;
- GdaPostgresBlobOpPrivate *priv;
-};
+G_DECLARE_DERIVABLE_TYPE(GdaPostgresBlobOp, gda_postgres_blob_op, GDA, POSTGRES_BLOB_OP, GdaBlobOp)
struct _GdaPostgresBlobOpClass {
GdaBlobOpClass parent_class;
};
-GType gda_postgres_blob_op_get_type (void) G_GNUC_CONST;
GdaBlobOp *gda_postgres_blob_op_new (GdaConnection *cnc);
GdaBlobOp *gda_postgres_blob_op_new_with_id (GdaConnection *cnc, const gchar *sql_id);
gboolean gda_postgres_blob_op_declare_blob (GdaPostgresBlobOp *pgop);
diff --git a/providers/postgres/gda-postgres-ddl.c b/providers/postgres/gda-postgres-ddl.c
index e8ca3d48e..31fbea7be 100644
--- a/providers/postgres/gda-postgres-ddl.c
+++ b/providers/postgres/gda-postgres-ddl.c
@@ -284,8 +284,7 @@ gda_postgres_render_CREATE_TABLE (GdaServerProvider *provider, GdaConnection *cn
}
g_string_append_c (string, ')');
}
- g_slist_foreach (pkfields, (GFunc) g_free, NULL);
- g_slist_free (pkfields);
+ g_slist_free_full (pkfields, (GDestroyNotify) g_free);
/* foreign keys */
first = TRUE;
diff --git a/providers/reuseable/postgres/gda-postgres-parser.c
b/providers/reuseable/postgres/gda-postgres-parser.c
index 8418d2640..6d1e7380b 100644
--- a/providers/reuseable/postgres/gda-postgres-parser.c
+++ b/providers/reuseable/postgres/gda-postgres-parser.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2008 - 2013 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2010 David King <davidk openismus com>
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -28,35 +29,7 @@
static void gda_postgres_parser_class_init (GdaPostgresParserClass *klass);
static void gda_postgres_parser_init (GdaPostgresParser *stmt);
-GType
-gda_postgres_parser_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static GMutex registering;
- static const GTypeInfo info = {
- sizeof (GdaPostgresParserClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gda_postgres_parser_class_init,
- NULL,
- NULL,
- sizeof (GdaPostgresParser),
- 0,
- (GInstanceInitFunc) gda_postgres_parser_init,
- 0
- };
-
- g_mutex_lock (®istering);
- if (type == 0)
- type = g_type_from_name ("GdaPostgresParser");
- if (type == 0)
- type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaPostgresParser", &info, 0);
- g_mutex_unlock (®istering);
- }
- return type;
-}
+G_DEFINE_TYPE(GdaPostgresParser, gda_postgres_parser, GDA_TYPE_SQL_PARSER)
/*
* The interface to the LEMON-generated parser
diff --git a/providers/reuseable/postgres/gda-postgres-parser.h
b/providers/reuseable/postgres/gda-postgres-parser.h
index bbaf1e0a7..d8a564683 100644
--- a/providers/reuseable/postgres/gda-postgres-parser.h
+++ b/providers/reuseable/postgres/gda-postgres-parser.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 - 2012 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -26,21 +27,8 @@
G_BEGIN_DECLS
#define GDA_TYPE_POSTGRES_PARSER (gda_postgres_parser_get_type())
-#define GDA_POSTGRES_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_POSTGRES_PARSER,
GdaPostgresParser))
-#define GDA_POSTGRES_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_POSTGRES_PARSER,
GdaPostgresParserClass))
-#define GDA_IS_POSTGRES_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GDA_TYPE_POSTGRES_PARSER))
-#define GDA_IS_POSTGRES_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDA_TYPE_POSTGRES_PARSER))
-typedef struct _GdaPostgresParser GdaPostgresParser;
-typedef struct _GdaPostgresParserClass GdaPostgresParserClass;
-typedef struct _GdaPostgresParserPrivate GdaPostgresParserPrivate;
-
-/* struct for the object's data */
-struct _GdaPostgresParser
-{
- GdaSqlParser object;
- GdaPostgresParserPrivate *priv;
-};
+G_DECLARE_DERIVABLE_TYPE(GdaPostgresParser, gda_postgres_parser, GDA, POSTGRES_PARSER, GdaSqlParser)
/* struct for the object's class */
struct _GdaPostgresParserClass
@@ -48,7 +36,6 @@ struct _GdaPostgresParserClass
GdaSqlParserClass parent_class;
};
-GType gda_postgres_parser_get_type (void) G_GNUC_CONST;
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]