[libgda] Allow the two kinds of Firebird providers to be used at the same time



commit 58efe61cd9cb15f149aedc3a7414a1075b678370
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Dec 13 20:24:42 2011 +0100

    Allow the two kinds of Firebird providers to be used at the same time

 providers/firebird/Makefile.am              |    1 +
 providers/firebird/gda-firebird-blob-op.c   |    7 ++++++-
 providers/firebird/gda-firebird-parser.c    |    7 ++++++-
 providers/firebird/gda-firebird-provider.c  |   13 ++++++++++---
 providers/firebird/gda-firebird-pstmt.c     |    7 ++++++-
 providers/firebird/gda-firebird-recordset.c |    7 ++++++-
 6 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/providers/firebird/Makefile.am b/providers/firebird/Makefile.am
index 87db6ee..7394eb2 100644
--- a/providers/firebird/Makefile.am
+++ b/providers/firebird/Makefile.am
@@ -56,6 +56,7 @@ libgda_firebird_client_la_LIBADD = \
 	$(COREDEPS_LIBS) $(FIREBIRD_CLIENT_LIBS)
 
 libgda_firebird_embed_la_SOURCES = $(firebird_sources) libmain-embed.c
+libgda_firebird_embed_la_CFLAGS = -DFIREBIRD_EMBED
 libgda_firebird_embed_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) $(LIBTOOL_PROV_EXPORT_OPTIONS)
 libgda_firebird_embed_la_LIBADD = \
 	$(top_builddir)/libgda/libgda-5.0.la \
diff --git a/providers/firebird/gda-firebird-blob-op.c b/providers/firebird/gda-firebird-blob-op.c
index 34dcb48..e51aa26 100644
--- a/providers/firebird/gda-firebird-blob-op.c
+++ b/providers/firebird/gda-firebird-blob-op.c
@@ -61,8 +61,13 @@ gda_firebird_blob_op_get_type (void)
 			(GInstanceInitFunc) gda_firebird_blob_op_init
 		};
 		g_static_mutex_lock (&registering);
-		if (type == 0)
+		if (type == 0) {
+#ifdef FIREBIRD_EMBED
+			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaFirebirdBlobOpEmbed", &info, 0);
+#else
 			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaFirebirdBlobOp", &info, 0);
+#endif
+		}
 		g_static_mutex_unlock (&registering);
 	}
 	return type;
diff --git a/providers/firebird/gda-firebird-parser.c b/providers/firebird/gda-firebird-parser.c
index 4a804db..0963a77 100644
--- a/providers/firebird/gda-firebird-parser.c
+++ b/providers/firebird/gda-firebird-parser.c
@@ -47,8 +47,13 @@ gda_firebird_parser_get_type (void)
 		};
 		
 		g_static_mutex_lock (&registering);
-		if (type == 0)
+		if (type == 0) {
+#ifdef FIREBIRD_EMBED
+			type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaFirebirdParserEmbed", &info, 0);
+#else
 			type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaFirebirdParser", &info, 0);
+#endif
+		}
 		g_static_mutex_unlock (&registering);
 	}
 	return type;
diff --git a/providers/firebird/gda-firebird-provider.c b/providers/firebird/gda-firebird-provider.c
index 890f79e..33f13b3 100644
--- a/providers/firebird/gda-firebird-provider.c
+++ b/providers/firebird/gda-firebird-provider.c
@@ -301,7 +301,7 @@ gda_firebird_provider_get_type (void)
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
-		//static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaFirebirdProviderClass),
 			(GBaseInitFunc) NULL,
@@ -312,8 +312,15 @@ gda_firebird_provider_get_type (void)
 			0,
 			(GInstanceInitFunc) gda_firebird_provider_init
 		};
-		type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaFirebirdProvider",
-					       &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+#ifdef FIREBIRD_EMBED
+		type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaFirebirdProviderEmbed", &info, 0);
+#else
+		type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaFirebirdProvider", &info, 0);
+#endif
+		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
diff --git a/providers/firebird/gda-firebird-pstmt.c b/providers/firebird/gda-firebird-pstmt.c
index 1e6f4f8..103d3f8 100644
--- a/providers/firebird/gda-firebird-pstmt.c
+++ b/providers/firebird/gda-firebird-pstmt.c
@@ -52,8 +52,13 @@ gda_firebird_pstmt_get_type (void)
 		};
 
 		g_static_mutex_lock (&registering);
-		if (type == 0)
+		if (type == 0) {
+#ifdef FIREBIRD_EMBED
+			type = g_type_register_static (GDA_TYPE_PSTMT, "GdaFirebirdPStmtEmbed", &info, 0);
+#else
 			type = g_type_register_static (GDA_TYPE_PSTMT, "GdaFirebirdPStmt", &info, 0);
+#endif
+		}
 		g_static_mutex_unlock (&registering);
 	}
 	return type;
diff --git a/providers/firebird/gda-firebird-recordset.c b/providers/firebird/gda-firebird-recordset.c
index 4b94e69..d7087fa 100644
--- a/providers/firebird/gda-firebird-recordset.c
+++ b/providers/firebird/gda-firebird-recordset.c
@@ -152,8 +152,13 @@ gda_firebird_recordset_get_type (void)
 			(GInstanceInitFunc) gda_firebird_recordset_init
 		};
 		g_static_mutex_lock (&registering);
-		if (type == 0)
+		if (type == 0) {
+#ifdef FIREBIRD_EMBED
+			type = g_type_register_static (GDA_TYPE_DATA_SELECT, "GdaFirebirdRecordsetEmbed", &info, 0);
+#else
 			type = g_type_register_static (GDA_TYPE_DATA_SELECT, "GdaFirebirdRecordset", &info, 0);
+#endif
+		}
 		g_static_mutex_unlock (&registering);
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]