Make lash_get_pending_event_count() working.
[ladish.git] / pylash / lash.i
blobd7267b61d9031915edfcb3f13ff00120d77c44e9
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Python bindings for LASH
5 *
6 * Copyright (C) 2006 Nedko Arnaudov <nedko@arnaudov.name>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *****************************************************************************/
24 #ifndef LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
25 #define LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
27 #ifdef SWIG
28 %module lash
30 %typemap(in) (int *argc, char ***argv)
32 int i;
34 if (!PyList_Check($input))
36 PyErr_SetString(PyExc_ValueError, "Expecting a list");
37 goto fail;
40 $1 = (int *) malloc(sizeof(int));
41 if ($1 == NULL)
43 PyErr_SetString(PyExc_ValueError, "malloc() failed.");
44 goto fail;
47 *$1 = PyList_Size($input);
49 $2 = (char ***) malloc(sizeof(char **));
50 if ($2 == NULL)
52 PyErr_SetString(PyExc_ValueError, "malloc() failed.");
53 goto fail;
56 *$2 = (char **) malloc((*$1+1)*sizeof(char *));
57 if (*$2 == NULL)
59 PyErr_SetString(PyExc_ValueError, "malloc() failed.");
60 goto fail;
63 for (i = 0; i < *$1; i++)
65 PyObject *s = PyList_GetItem($input,i);
66 if (!PyString_Check(s))
68 PyErr_SetString(PyExc_ValueError, "List items must be strings");
69 goto fail;
72 (*$2)[i] = PyString_AsString(s);
75 (*$2)[i] = 0;
78 %typemap(argout) (int *argc, char ***argv)
80 int i;
82 for (i = 0; i < *$1; i++)
84 PyObject *s = PyString_FromString((*$2)[i]);
85 PyList_SetItem($input,i,s);
88 while (i < PySequence_Size($input))
90 PySequence_DelItem($input,i);
94 %typemap(freearg) (int *argc, char ***argv)
96 if ($1 != NULL)
98 //printf("freeing argc pointer storage\n");
99 free($1);
100 $1 = NULL;
103 if ($2 != NULL)
105 if (*$2 != NULL)
107 //printf("freeing array pointed by argv pointer storage\n");
108 free(*$2);
111 //printf("freeing argv pointer storage\n");
112 free($2);
113 $1 = NULL;
118 #include <lash/client_interface.h>
119 #include <lash/types.h>
120 #include <lash/event.h>
121 #include <lash/config.h>
122 #include "lash.h"
123 typedef unsigned char * uuid_t_compat;
124 #define uuid_t uuid_t_compat
127 #endif
129 %include <lash/client_interface.h>
130 %include <lash/types.h>
131 %include <lash/event.h>
132 %include <lash/config.h>
133 %include <lash.h>
135 #endif /* #ifndef LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED */