1 /*
2  * Copyright (C) 2008 - 2011 Vivien Malerba <malerba@gnome-db.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19 
20 #include "gda-firebird-parser.h"
21 #include "firebird_token_types.h"
22 #include <string.h>
23 
24 /*
25  * Main static functions
26  */
27 static void gda_firebird_parser_class_init (GdaFirebirdParserClass *klass);
28 static void gda_firebird_parser_init (GdaFirebirdParser *stmt);
29 
30 GType
gda_firebird_parser_get_type(void)31 gda_firebird_parser_get_type (void)
32 {
33 	static GType type = 0;
34 
35 	if (G_UNLIKELY (type == 0)) {
36 		static GMutex registering;
37 		static const GTypeInfo info = {
38 			sizeof (GdaFirebirdParserClass),
39 			(GBaseInitFunc) NULL,
40 			(GBaseFinalizeFunc) NULL,
41 			(GClassInitFunc) gda_firebird_parser_class_init,
42 			NULL,
43 			NULL,
44 			sizeof (GdaFirebirdParser),
45 			0,
46 			(GInstanceInitFunc) gda_firebird_parser_init
47 		};
48 
49 		g_mutex_lock (&registering);
50 		if (type == 0) {
51 #ifdef FIREBIRD_EMBED
52 			type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaFirebirdParserEmbed", &info, 0);
53 #else
54 			type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaFirebirdParser", &info, 0);
55 #endif
56 		}
57 		g_mutex_unlock (&registering);
58 	}
59 	return type;
60 }
61 
62 /*
63  * The interface to the LEMON-generated parser
64  */
65 void *gda_lemon_firebird_parserAlloc (void*(*)(size_t));
66 void gda_lemon_firebird_parserFree (void*, void(*)(void*));
67 void gda_lemon_firebird_parserTrace (void*, char *);
68 void gda_lemon_firebird_parser (void*, int, GValue *, GdaSqlParserIface *);
69 
70 static void
gda_firebird_parser_class_init(GdaFirebirdParserClass * klass)71 gda_firebird_parser_class_init (GdaFirebirdParserClass * klass)
72 {
73 	GdaSqlParserClass *pclass = GDA_SQL_PARSER_CLASS (klass);
74 
75 	pclass->parser_alloc = gda_lemon_firebird_parserAlloc;
76 	pclass->parser_free = gda_lemon_firebird_parserFree;
77 	pclass->parser_trace = gda_lemon_firebird_parserTrace;
78 	pclass->parser_parse = gda_lemon_firebird_parser;
79 	pclass->parser_tokens_trans = firebird_parser_tokens;
80 }
81 
82 static void
gda_firebird_parser_init(GdaFirebirdParser * parser)83 gda_firebird_parser_init (GdaFirebirdParser *parser)
84 {
85 }
86