1 /* File : fl_draw.i */
2 //%module fl_draw
3 
4 %include "typemaps.i"
5 
6 %{
7 #include "FL/fl_draw.H"
8 %}
9 
10 %typemap(in) const uchar * {
11        /* Check if the input support the buffer protocol */
12        Py_ssize_t size_buffer;
13        const void * buffer;
14        int failure = PyObject_AsReadBuffer($input,&buffer,&size_buffer);
15        if (!failure) {
16 	 // work with array object
17          $1 = (uchar *) buffer;
18        } else {
19 	 // work with list object
20 	 // clear the error from PyObject_AsReadBuffer
21 	 PyErr_Clear();
22          size_buffer=0;
23          buffer=0;
24 	 /* Check if is a list */
25          if (PyList_Check($input)) {
26            int size = PyList_Size($input);
27            int i = 0;
28            $1 = (uchar *) malloc((size+1)*sizeof(char));
29            for (i = 0; i < size; i++) {
30 		PyObject *o = 	PyList_GetItem($input,i);
31              if (PyInt_Check(o))
32                $1[i] = (char)PyInt_AsLong(o);
33              else {
34                PyErr_SetString(PyExc_TypeError,"list must contain ints");
35                free($1);
36                return NULL;
37              }
38            }
39            $1[i] = 0;
40          } else {
41            PyErr_SetString(PyExc_TypeError,"not a list or does not support single-segment readable buffer interface");
42            return NULL;
43 	 }
44        }
45      }
46 
47 
48 %ignore fl_color(int c);
49 %ignore fl_draw_pixmap(const char* const* data, int x,int y,Fl_Color=FL_GRAY);
50 %ignore fl_measure_pixmap(const char* const* data, int &w, int &h);
51 %ignore fl_chord(int x, int y, int w, int h, double a1, double a2);
52 %ignore fl_read_image(uchar *p, int x,int y, int w, int h, int alpha=0);
53 %ignore fl_draw_image(Fl_Draw_Image_Cb, void*, int,int,int,int, int delta=3);
54 %ignore fl_draw_image_mono(Fl_Draw_Image_Cb, void*, int,int,int,int, int delta=1);
55 
56 %apply int* OUTPUT { int& };
57 
58 %include "FL/fl_draw.H"
59 
60