Mercurial > vim
comparison src/if_py_both.h @ 2727:62e8d93241cd v7.3.142
updated for version 7.3.142
Problem: Python stdout doesn't have a flush() method, causing an import to
fail.
Solution: Add a dummy flush() method. (Tobias Columbus)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 22 Mar 2011 15:47:44 +0100 |
parents | c6fe65c000d2 |
children | fe9c7da98b5e |
comparison
equal
deleted
inserted
replaced
2726:0d201adaf9c5 | 2727:62e8d93241cd |
---|---|
31 /* Output object definition | 31 /* Output object definition |
32 */ | 32 */ |
33 | 33 |
34 static PyObject *OutputWrite(PyObject *, PyObject *); | 34 static PyObject *OutputWrite(PyObject *, PyObject *); |
35 static PyObject *OutputWritelines(PyObject *, PyObject *); | 35 static PyObject *OutputWritelines(PyObject *, PyObject *); |
36 static PyObject *OutputFlush(PyObject *, PyObject *); | |
36 | 37 |
37 /* Function to write a line, points to either msg() or emsg(). */ | 38 /* Function to write a line, points to either msg() or emsg(). */ |
38 typedef void (*writefn)(char_u *); | 39 typedef void (*writefn)(char_u *); |
39 static void writer(writefn fn, char_u *str, PyInt n); | 40 static void writer(writefn fn, char_u *str, PyInt n); |
40 | 41 |
45 long error; | 46 long error; |
46 } OutputObject; | 47 } OutputObject; |
47 | 48 |
48 static struct PyMethodDef OutputMethods[] = { | 49 static struct PyMethodDef OutputMethods[] = { |
49 /* name, function, calling, documentation */ | 50 /* name, function, calling, documentation */ |
50 {"write", OutputWrite, 1, "" }, | 51 {"write", OutputWrite, 1, ""}, |
51 {"writelines", OutputWritelines, 1, "" }, | 52 {"writelines", OutputWritelines, 1, ""}, |
52 { NULL, NULL, 0, NULL } | 53 {"flush", OutputFlush, 1, ""}, |
54 { NULL, NULL, 0, NULL} | |
53 }; | 55 }; |
54 | 56 |
55 #define PyErr_SetVim(str) PyErr_SetString(VimError, str) | 57 #define PyErr_SetVim(str) PyErr_SetString(VimError, str) |
56 | 58 |
57 /*************/ | 59 /*************/ |
120 | 122 |
121 Py_DECREF(list); | 123 Py_DECREF(list); |
122 Py_INCREF(Py_None); | 124 Py_INCREF(Py_None); |
123 return Py_None; | 125 return Py_None; |
124 } | 126 } |
127 | |
128 static PyObject * | |
129 OutputFlush(PyObject *self UNUSED, PyObject *args UNUSED) | |
130 { | |
131 /* do nothing */ | |
132 Py_INCREF(Py_None); | |
133 return Py_None; | |
134 } | |
135 | |
125 | 136 |
126 /* Buffer IO, we write one whole line at a time. */ | 137 /* Buffer IO, we write one whole line at a time. */ |
127 static garray_T io_ga = {0, 0, 1, 80, NULL}; | 138 static garray_T io_ga = {0, 0, 1, 80, NULL}; |
128 static writefn old_fn = NULL; | 139 static writefn old_fn = NULL; |
129 | 140 |