[libgda] GdaVirtualProvider: ported to G_DECLARE/G_DEFINE
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaVirtualProvider: ported to G_DECLARE/G_DEFINE
- Date: Mon, 25 Feb 2019 23:13:18 +0000 (UTC)
commit 7797799509f832525fa952b1ecdfa50344f6b662
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date: Mon Feb 25 11:36:55 2019 -0600
GdaVirtualProvider: ported to G_DECLARE/G_DEFINE
libgda/gda-tree.c | 3 +-
libgda/sqlite/gda-sqlite-provider.c | 3 ++
libgda/sqlite/gda-symbols-util.c | 2 +-
libgda/sqlite/virtual/gda-virtual-provider.c | 57 +---------------------------
libgda/sqlite/virtual/gda-virtual-provider.h | 22 ++---------
5 files changed, 11 insertions(+), 76 deletions(-)
---
diff --git a/libgda/gda-tree.c b/libgda/gda-tree.c
index 19236f3c8..0aa125337 100644
--- a/libgda/gda-tree.c
+++ b/libgda/gda-tree.c
@@ -314,9 +314,8 @@ gda_tree_clean (GdaTree *tree)
g_return_if_fail (GDA_IS_TREE (tree));
TO_IMPLEMENT; /* signal changes */
- GdaTreePrivate *priv = gda_tree_get_instance_private (tree);
- new_root = gda_tree_node_new (NULL);
+ new_root = gda_tree_node_new (NULL);
take_root_node (tree, new_root);
}
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index f6d362720..2963d9688 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -67,6 +67,7 @@
#include <libgda/gda-debug-macros.h>
#include <libgda/gda-provider-meta.h>
#include <libgda/gda-provider.h>
+#include "gda-symbols-util.h"
#define FILE_EXTENSION ".db"
static gchar *get_table_nth_column_name (GdaServerProvider *prov, GdaConnection *cnc, const gchar
*table_name, gint pos);
@@ -255,6 +256,8 @@ gda_sqlite_provider_meta_iface_init (GdaProviderMetaInterface *iface);
static void
gda_sqlite_provider_iface_init (GdaProviderInterface *iface);
+extern Sqlite3ApiRoutines *s3r;
+
/*
* GObject methods
*/
diff --git a/libgda/sqlite/gda-symbols-util.c b/libgda/sqlite/gda-symbols-util.c
index ff879bf85..959bbb54c 100644
--- a/libgda/sqlite/gda-symbols-util.c
+++ b/libgda/sqlite/gda-symbols-util.c
@@ -22,7 +22,7 @@
#include <libgda/libgda.h>
#include "gda-symbols-util.h"
-Sqlite3ApiRoutines *s3r = NULL;
+Sqlite3ApiRoutines *s3r;
diff --git a/libgda/sqlite/virtual/gda-virtual-provider.c b/libgda/sqlite/virtual/gda-virtual-provider.c
index 3e1474dfb..72afda24e 100644
--- a/libgda/sqlite/virtual/gda-virtual-provider.c
+++ b/libgda/sqlite/virtual/gda-virtual-provider.c
@@ -26,13 +26,7 @@
#include <libgda/gda-debug-macros.h>
#include <libgda/gda-server-provider-impl.h>
-#define PARENT_TYPE GDA_TYPE_SQLITE_PROVIDER
-#define CLASS(obj) (GDA_VIRTUAL_PROVIDER_CLASS (G_OBJECT_GET_CLASS (obj)))
-
-static void gda_virtual_provider_class_init (GdaVirtualProviderClass *klass);
-static void gda_virtual_provider_init (GdaVirtualProvider *prov, GdaVirtualProviderClass *klass);
-static void gda_virtual_provider_finalize (GObject *object);
-static GObjectClass *parent_class = NULL;
+G_DEFINE_TYPE (GdaVirtualProvider, gda_virtual_provider, GDA_TYPE_SQLITE_PROVIDER)
/*
* GdaVirtualProvider class implementation
@@ -40,60 +34,13 @@ static GObjectClass *parent_class = NULL;
static void
gda_virtual_provider_class_init (GdaVirtualProviderClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
gda_server_provider_set_impl_functions (GDA_SERVER_PROVIDER_CLASS (klass),
GDA_SERVER_PROVIDER_FUNCTIONS_BASE,
(gpointer) NULL);
-
- /* virtual methods */
- object_class->finalize = gda_virtual_provider_finalize;
}
static void
-gda_virtual_provider_init (G_GNUC_UNUSED GdaVirtualProvider *vprov, G_GNUC_UNUSED GdaVirtualProviderClass
*klass)
+gda_virtual_provider_init (G_GNUC_UNUSED GdaVirtualProvider *vprov)
{
}
-static void
-gda_virtual_provider_finalize (GObject *object)
-{
- GdaVirtualProvider *prov = (GdaVirtualProvider *) object;
-
- g_return_if_fail (GDA_IS_VIRTUAL_PROVIDER (prov));
-
- /* chain to parent class */
- parent_class->finalize (object);
-}
-
-GType
-gda_virtual_provider_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static GMutex registering;
- if (type == 0) {
- static GTypeInfo info = {
- sizeof (GdaVirtualProviderClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gda_virtual_provider_class_init,
- NULL, NULL,
- sizeof (GdaVirtualProvider),
- 0,
- (GInstanceInitFunc) gda_virtual_provider_init,
- 0
- };
-
- g_mutex_lock (®istering);
- if (type == 0)
- type = g_type_register_static (PARENT_TYPE, "GdaVirtualProvider", &info,
G_TYPE_FLAG_ABSTRACT);
- g_mutex_unlock (®istering);
- }
- }
-
- return type;
-}
diff --git a/libgda/sqlite/virtual/gda-virtual-provider.h b/libgda/sqlite/virtual/gda-virtual-provider.h
index eab93841d..3ac04f4a6 100644
--- a/libgda/sqlite/virtual/gda-virtual-provider.h
+++ b/libgda/sqlite/virtual/gda-virtual-provider.h
@@ -24,31 +24,19 @@
#include <libgda/sqlite/gda-sqlite-provider.h>
-#define GDA_TYPE_VIRTUAL_PROVIDER (gda_virtual_provider_get_type())
-#define GDA_VIRTUAL_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_VIRTUAL_PROVIDER,
GdaVirtualProvider))
-#define GDA_VIRTUAL_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_VIRTUAL_PROVIDER,
GdaVirtualProviderClass))
-#define GDA_IS_VIRTUAL_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GDA_TYPE_VIRTUAL_PROVIDER))
-#define GDA_IS_VIRTUAL_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDA_TYPE_VIRTUAL_PROVIDER))
-
G_BEGIN_DECLS
-typedef struct _GdaVirtualProvider GdaVirtualProvider;
-typedef struct _GdaVirtualProviderClass GdaVirtualProviderClass;
+#define GDA_TYPE_VIRTUAL_PROVIDER (gda_virtual_provider_get_type())
-struct _GdaVirtualProvider {
- GdaSqliteProvider provider;
-
- /*< private >*/
- void (*_gda_reserved1) (void);
- void (*_gda_reserved2) (void);
-};
+G_DECLARE_DERIVABLE_TYPE (GdaVirtualProvider, gda_virtual_provider, GDA, VIRTUAL_PROVIDER, GdaSqliteProvider)
struct _GdaVirtualProviderClass {
GdaSqliteProviderClass parent_class;
/*< private >*/
void (*_gda_reserved1) (void);
- void (*_gda_reserved2) (void);};
+ void (*_gda_reserved2) (void);
+};
/**
* SECTION:gda-virtual-provider
@@ -60,8 +48,6 @@ struct _GdaVirtualProviderClass {
* This is a base virtual class for all virtual providers implementations.
*/
-GType gda_virtual_provider_get_type (void) G_GNUC_CONST;
-
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]