28 static PyTypeObject groongaql_ContextType;
33 groongaql_ContextObject_new(PyTypeObject *
type, PyObject *args, PyObject *keywds)
40 static char *kwlist[] = {
"flags",
"encoding", NULL};
42 if (!PyArg_ParseTupleAndKeywords(args, keywds,
"ii", kwlist,
49 Py_BEGIN_ALLOW_THREADS
54 self->ob_type->tp_free(
self);
58 return (PyObject *)
self;
65 Py_BEGIN_ALLOW_THREADS
69 self->ob_type->tp_free(
self);
82 static char *kwlist[] = {
"host",
"port",
"flags", NULL};
84 if (!PyArg_ParseTupleAndKeywords(args, keywds,
"sii", kwlist,
85 &host, &port, &flags)) {
88 if (self->closed) {
return NULL; }
89 Py_BEGIN_ALLOW_THREADS
92 return Py_BuildValue(
"i", rc);
101 static char *kwlist[] = {
"str",
"flags", NULL};
103 if (!PyArg_ParseTupleAndKeywords(args, keywds,
"s#i", kwlist,
109 if (self->closed) {
return NULL; }
110 Py_BEGIN_ALLOW_THREADS
113 return Py_BuildValue(
"i", rc);
122 unsigned int str_len;
124 if (self->closed) {
return NULL; }
125 Py_BEGIN_ALLOW_THREADS
128 return Py_BuildValue(
"(is#i)", rc, str, str_len, flags);
136 if (self->closed) {
return NULL; }
137 Py_BEGIN_ALLOW_THREADS
143 return Py_BuildValue(
"i", rc);
152 if (self->closed) {
return NULL; }
156 return Py_BuildValue(
"{s:i,s:i,s:i}",
166 static PyMethodDef groongaql_Context_methods[] = {
167 {
"ql_connect", (PyCFunction)groongaql_ContextClass_ql_connect,
168 METH_VARARGS | METH_KEYWORDS,
169 "Create a remote groonga context."},
170 {
"ql_send", (PyCFunction)groongaql_Context_ql_send,
171 METH_VARARGS | METH_KEYWORDS,
172 "Send message to context."},
173 {
"ql_recv", (PyCFunction)groongaql_Context_ql_recv,
175 "Receive message from context."},
176 {
"fin", (PyCFunction)groongaql_Context_fin,
178 "Release groonga context."},
179 {
"ql_info_get", (PyCFunction)groongaql_Context_ql_info_get,
181 "Get QL context information."},
182 {NULL, NULL, 0, NULL}
185 static PyMethodDef module_methods[] = {
186 {NULL, NULL, 0, NULL}
191 static PyTypeObject groongaql_ContextType = {
192 PyObject_HEAD_INIT(NULL)
197 (destructor)groongaql_ContextObject_dealloc,
213 "groonga Context objects",
220 groongaql_Context_methods,
230 groongaql_ContextObject_new,
326 #ifndef PyMODINIT_FUNC
327 #define PyMODINIT_FUNC void
335 if (!(m = Py_InitModule3(
"groongaql", module_methods,
336 "groonga ql module."))) {
343 if (PyType_Ready(&groongaql_ContextType) < 0) {
goto exit; }
344 Py_INCREF(&groongaql_ContextType);
345 PyModule_AddObject(m,
"Context", (PyObject *)&groongaql_ContextType);
349 if (!(dict = PyModule_GetDict(m))) {
goto exit; }
351 for (i = 0; consts[
i].
name; i++) {
353 if (!(v = PyInt_FromLong(consts[i].value))) {
356 PyDict_SetItemString(dict, consts[i].name, v);
359 if (Py_AtExit((
void (*)(
void))
grn_fin)) {
goto exit; }
361 if (PyErr_Occurred()) {
362 PyErr_SetString(PyExc_ImportError,
"groongaql: init failed");