-
Notifications
You must be signed in to change notification settings - Fork 0
/
parsebridgemodule.c
65 lines (55 loc) · 1.24 KB
/
parsebridgemodule.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//#include "node_visitor.h"
#include "gsp_base.h"
#include "gsp_node.h"
#include "gsp_list.h"
#include "gsp_sourcetoken.h"
#include "gsp_sqlparser.h"
#include <stdlib.h>
#include <Python.h>
#include <structmember.h>
#include "Parser.h"
#include "Statement.h"
#include "Node.h"
#include "ENodeType.h"
#if PY_MAJOR_VERSION >= 3
static PyModuleDef SqlParserModule = {
PyModuleDef_HEAD_INIT,
.m_name = "sqlparser",
.m_doc = "Bridge between python and sqlparser",
.m_size = -1
};
PyMODINIT_FUNC PyInit_sqlparser(void)
{
PyObject *m;
if (PyType_Ready(&ParserType) < 0)
return NULL;
// initialize module
m = PyModule_Create(&SqlParserModule);
if (m == NULL) return NULL;
// Initialize our custom types
Parser_init_type(m);
Node_init_type(m);
Statement_init_type(m);
Enum_init_type(m);
return m;
}
#else
// Module functions
static PyMethodDef BridgeMethods[] =
{
{NULL, NULL, 0, NULL}
};
PyMODINIT_FUNC
initsqlparser(void)
{
PyObject *m;
// initialize module
m = Py_InitModule3("sqlparser", BridgeMethods, "Bridge between python and sqlparser");
if (m == NULL) return;
// Initialize our custom types
Parser_init_type(m);
Node_init_type(m);
Statement_init_type(m);
Enum_init_type(m);
}
#endif