[libgda] GdaMysqlParser: ported to G_DECLARE/G_DEFINE
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaMysqlParser: ported to G_DECLARE/G_DEFINE
- Date: Fri, 5 Apr 2019 23:00:47 +0000 (UTC)
commit dea475aa3740362aa23a6e77cc354a4933b8c43c
Author: Daniel Espinosa <esodan gmail com>
Date: Fri Apr 5 13:23:42 2019 -0600
GdaMysqlParser: ported to G_DECLARE/G_DEFINE
providers/mysql/gda-mysql-ddl.c | 3 +--
providers/reuseable/mysql/gda-mysql-parser.c | 34 +++-------------------------
providers/reuseable/mysql/gda-mysql-parser.h | 18 ++-------------
3 files changed, 6 insertions(+), 49 deletions(-)
---
diff --git a/providers/mysql/gda-mysql-ddl.c b/providers/mysql/gda-mysql-ddl.c
index 4ef85c5e6..708d3601d 100644
--- a/providers/mysql/gda-mysql-ddl.c
+++ b/providers/mysql/gda-mysql-ddl.c
@@ -276,8 +276,7 @@ gda_mysql_render_CREATE_TABLE (GdaServerProvider *provider, GdaConnection *cnc,
}
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/mysql/gda-mysql-parser.c b/providers/reuseable/mysql/gda-mysql-parser.c
index 339944bdd..b492fb097 100644
--- a/providers/reuseable/mysql/gda-mysql-parser.c
+++ b/providers/reuseable/mysql/gda-mysql-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,36 +29,7 @@
static void gda_mysql_parser_class_init (GdaMysqlParserClass *klass);
static void gda_mysql_parser_init (GdaMysqlParser *stmt);
-GType
-gda_mysql_parser_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static GMutex registering;
- static const GTypeInfo info = {
- sizeof (GdaMysqlParserClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gda_mysql_parser_class_init,
- NULL,
- NULL,
- sizeof (GdaMysqlParser),
- 0,
- (GInstanceInitFunc) gda_mysql_parser_init,
- 0
- };
-
- g_mutex_lock (®istering);
- if (type == 0)
- type = g_type_from_name ("GdaMysqlParser");
- if (type == 0)
- type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaMysqlParser", &info, 0);
- g_mutex_unlock (®istering);
- }
- return type;
-}
-
+G_DEFINE_TYPE (GdaMysqlParser, gda_mysql_parser, GDA_TYPE_SQL_PARSER)
/*
* The interface to the LEMON-generated parser
*/
@@ -75,7 +47,7 @@ gda_mysql_parser_class_init (GdaMysqlParserClass * klass)
pclass->parser_free = gda_lemon_mysql_parserFree;
pclass->parser_trace = gda_lemon_mysql_parserTrace;
pclass->parser_parse = gda_lemon_mysql_parser;
- pclass->parser_tokens_trans = mysql_parser_tokens;
+ pclass->parser_tokens_trans = NULL;
}
static void
diff --git a/providers/reuseable/mysql/gda-mysql-parser.h b/providers/reuseable/mysql/gda-mysql-parser.h
index 44c09ae25..1a31a834f 100644
--- a/providers/reuseable/mysql/gda-mysql-parser.h
+++ b/providers/reuseable/mysql/gda-mysql-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_MYSQL_PARSER (gda_mysql_parser_get_type())
-#define GDA_MYSQL_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_MYSQL_PARSER,
GdaMysqlParser))
-#define GDA_MYSQL_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_MYSQL_PARSER,
GdaMysqlParserClass))
-#define GDA_IS_MYSQL_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GDA_TYPE_MYSQL_PARSER))
-#define GDA_IS_MYSQL_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDA_TYPE_MYSQL_PARSER))
-typedef struct _GdaMysqlParser GdaMysqlParser;
-typedef struct _GdaMysqlParserClass GdaMysqlParserClass;
-typedef struct _GdaMysqlParserPrivate GdaMysqlParserPrivate;
-
-/* struct for the object's data */
-struct _GdaMysqlParser
-{
- GdaSqlParser object;
- GdaMysqlParserPrivate *priv;
-};
+G_DECLARE_DERIVABLE_TYPE (GdaMysqlParser, gda_mysql_parser, GDA, MYSQL_PARSER, GdaSqlParser)
/* struct for the object's class */
struct _GdaMysqlParserClass
@@ -48,8 +36,6 @@ struct _GdaMysqlParserClass
GdaSqlParserClass parent_class;
};
-GType gda_mysql_parser_get_type (void) G_GNUC_CONST;
-
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]