Compare commits

...

21 Commits

Author SHA1 Message Date
Bram Moolenaar
8661b17843 updated for version 7.3.951
Problem:    Python exceptions have problems.
Solution:   Change some IndexErrors to TypeErrors. Make “line number out of
            range” an IndexError.  Make “unable to get option value” a
            RuntimeError. Make all PyErr_SetString messages start with
            lowercase letter and use _(). (ZyX)
2013-05-15 15:44:28 +02:00
Bram Moolenaar
4d188da22b updated for version 7.3.950
Problem:    Python: Stack trace printer can't handle messages.
Solution:   Make KeyErrors use PyErr_SetObject. (ZyX)
2013-05-15 15:35:09 +02:00
Bram Moolenaar
5e538ecd5e updated for version 7.3.949
Problem:    Python: no easy access to tabpages.
Solution:   Add vim.tabpages and vim.current.tabpage. (ZyX)
2013-05-15 15:12:29 +02:00
Bram Moolenaar
03db85b398 updated for version 7.3.948
Problem:    Cannot build with Python 2.2
Solution:   Make Python interface work with Python 2.2
            Make 2.2 the first supported version. (ZyX)
2013-05-15 14:51:35 +02:00
Bram Moolenaar
b6c589a529 updated for version 7.3.947
Problem:    Python: No iterator for vim.list and vim.bufferlist.
Solution:   Add the iterators. Also fix name of FunctionType. Add tests for
            vim.buffers.  (ZyX)
2013-05-15 14:39:52 +02:00
Bram Moolenaar
46a7561f3a updated for version 7.3.946
Problem:    Sometimes get stuck in waiting for cursor position report,
            resulting in keys starting with <Esc>[ not working.
Solution:   Only wait for more characters after <Esc>[ if followed by '?', '>'
            or a digit.
2013-05-15 14:22:41 +02:00
Bram Moolenaar
dfa38d4e45 updated for version 7.3.945
Problem:    Python: List of buffers is not very useful.
Solution:   Make vim.buffers a map. No iterator yet. (ZyX)
2013-05-15 13:38:47 +02:00
Bram Moolenaar
29607acff6 updated for version 7.3.944
Problem:    External program receives the termrespone.
Solution:   Insert a delay and discard input. (Hayaki Saito)
2013-05-13 20:26:53 +02:00
Bram Moolenaar
bd80f35bc5 updated for version 7.3.943
Problem:    Python: Negative indices were failing.
Solution:   Fix negative indices. Add tests. (ZyX)
2013-05-12 21:16:23 +02:00
Bram Moolenaar
8f1723de47 updated for version 7.3.942
Problem:    Python: SEGV in Buffer functions.
Solution:   Call CheckBuffer() at the right time. (ZyX)
2013-05-12 20:36:14 +02:00
Bram Moolenaar
3d0c52db9c updated for version 7.3.941
Problem:    Stuff in if_py_both.h is ordered badly.
Solution:   Reorder by type. (ZyX)
2013-05-12 19:45:35 +02:00
Bram Moolenaar
4e5dfb5700 updated for version 7.3.940
Problem:    Python: Can't get position of window.
Solution:   Add window.row and window.col. (ZyX)
2013-05-12 19:30:31 +02:00
Bram Moolenaar
99add41656 updated for version 7.3.939
Problem:    Using Py_BuildValue is inefficient sometimes.
Solution:   Use PyLong_FromLong(). (ZyX)
2013-05-12 19:09:51 +02:00
Bram Moolenaar
6d21645f46 updated for version 7.3.938
Problem:    Python: not easy to get to window number.
Solution:   Add vim.window.number. (ZyX)
2013-05-12 19:00:41 +02:00
Bram Moolenaar
971db46799 updated for version 7.3.937
Problem:    More can be shared between Python 2 and 3.
Solution:   Move code to if_py_both.h. (ZyX)
2013-05-12 18:44:48 +02:00
Bram Moolenaar
3b9abb6cc2 updated for version 7.3.936
Problem:    Ruby 1.8: Missing piece for static linking on 64 bit systems.
Solution:   Define ruby_init_stack() (Hiroshi Shirosaki)
            Also fix preprocessor indents.
2013-05-12 14:11:17 +02:00
Bram Moolenaar
76a86063ca updated for version 7.3.935
Problem:    Init stack works differently on 64 bit systems.
Solution:   Handle 64 bit systems and also static library. (Yukihiro
            Nakadaira)
2013-05-11 17:45:48 +02:00
Bram Moolenaar
82e803b055 updated for version 7.3.934
Problem:    E381 and E380 make the user think nothing happened.
Solution:   Display the message indicating what error list is now active.
            (Christian Brabandt)
2013-05-11 15:50:33 +02:00
Bram Moolenaar
99685e6a7e updated for version 7.3.933
Problem:    Ruby on Mac crashes due to GC failure.
Solution:   Init the stack from main(). (Hiroshi Shirosaki)
2013-05-11 13:56:18 +02:00
Bram Moolenaar
6800186a03 updated for version 7.3.932
Problem:    Compiler warning for uninitialized variable. (Tony Mechelynck)
Solution:   Initialize the variable.
2013-05-11 13:45:05 +02:00
Bram Moolenaar
09bb33dde9 updated for version 7.3.931
Problem:    No completion for :xmap and :smap. (Yukihiro Nakadaira)
Solution:   Add the case statements. (Christian Brabandt)
2013-05-07 05:18:20 +02:00
25 changed files with 1845 additions and 1009 deletions

View File

@@ -209,12 +209,12 @@ Constants of the "vim" module
to which the variables referred.
vim.buffers *python-buffers*
A sequence object providing access to the list of vim buffers. The
A mapping object providing access to the list of vim buffers. The
object supports the following operations: >
:py b = vim.buffers[i] # Indexing (read-only)
:py b in vim.buffers # Membership test
:py n = len(vim.buffers) # Number of elements
:py for b in vim.buffers: # Sequential access
:py for b in vim.buffers: # Iterating over buffer list
<
vim.windows *python-windows*
A sequence object providing access to the list of vim windows. The
@@ -223,6 +223,20 @@ vim.windows *python-windows*
:py w in vim.windows # Membership test
:py n = len(vim.windows) # Number of elements
:py for w in vim.windows: # Sequential access
< Note: vim.windows object always accesses current tab page,.
|python-tabpage|.windows objects are bound to parent |python-tabpage|
object and always use windows from that tab page (or throw vim.error
in case tab page was deleted). You can keep a reference to both
without keeping a reference to vim module object or |python-tabpage|,
they will not loose their properties in this case.
vim.tabpages *python-tabpages*
A sequence object providing access to the list of vim tab pages. The
object supports the following operations: >
:py t = vim.tabpages[i] # Indexing (read-only)
:py t in vim.tabpages # Membership test
:py n = len(vim.tabpages) # Number of elements
:py for t in vim.tabpages: # Sequential access
<
vim.current *python-current*
An object providing access (via specific attributes) to various
@@ -230,6 +244,7 @@ vim.current *python-current*
vim.current.line The current line (RW) String
vim.current.buffer The current buffer (RO) Buffer
vim.current.window The current window (RO) Window
vim.current.tabpage The current tab page (RO) TabPage
vim.current.range The current line range (RO) Range
The last case deserves a little explanation. When the :python or
@@ -375,6 +390,8 @@ Example (assume r is the current range):
Window objects represent vim windows. You can obtain them in a number of ways:
- via vim.current.window (|python-current|)
- from indexing vim.windows (|python-windows|)
- from indexing "windows" attribute of a tab page (|python-tabpage|)
- from the "window" attribute of a tab page (|python-tabpage|)
You can manipulate window objects only through their attributes. They have no
methods, and no sequence or other interface.
@@ -396,9 +413,34 @@ Window attributes are:
|python-options|. If option is |global-local|
and local value is missing getting it will
return None.
number (read-only) Window number. The first window has number 1.
This is zero in case it cannot be determined
(e.g. when the window object belongs to other
tab page).
row, col (read-only) On-screen window position in display cells.
First position is zero.
The height attribute is writable only if the screen is split horizontally.
The width attribute is writable only if the screen is split vertically.
==============================================================================
6. Tab page objects *python-tabpage*
Tab page objects represent vim tab pages. You can obtain them in a number of
ways:
- via vim.current.tabpage (|python-current|)
- from indexing vim.tabpages (|python-tabpages|)
You can use this object to access tab page windows. They have no methods and
no sequence or other interfaces.
Tab page attributes are:
number The tab page number like the one returned by
|tabpagenr()|.
windows Like |python-windows|, but for current tab page.
vars The tab page |t:| variables.
window Current tabpage window.
==============================================================================
6. pyeval() and py3eval() Vim functions *python-pyeval*

6
src/auto/configure vendored
View File

@@ -5289,10 +5289,10 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python_version" >&5
$as_echo "$vi_cv_var_python_version" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python is 1.4 or better" >&5
$as_echo_n "checking Python is 1.4 or better... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python is 2.2 or better" >&5
$as_echo_n "checking Python is 2.2 or better... " >&6; }
if ${vi_cv_path_python} -c \
"import sys; sys.exit(${vi_cv_var_python_version} < 1.4)"
"import sys; sys.exit(${vi_cv_var_python_version} < 2.2)"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yep" >&5
$as_echo "yep" >&6; }

View File

@@ -863,10 +863,10 @@ if test "$enable_pythoninterp" = "yes" -o "$enable_pythoninterp" = "dynamic"; th
${vi_cv_path_python} -c 'import sys; print sys.version[:3]'`
]])
dnl -- it must be at least version 1.4
AC_MSG_CHECKING(Python is 1.4 or better)
dnl -- it must be at least version 2.2
AC_MSG_CHECKING(Python is 2.2 or better)
if ${vi_cv_path_python} -c \
"import sys; sys.exit(${vi_cv_var_python_version} < 1.4)"
"import sys; sys.exit(${vi_cv_var_python_version} < 2.2)"
then
AC_MSG_RESULT(yep)

View File

@@ -390,8 +390,6 @@ static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int u
static void clear_lval __ARGS((lval_T *lp));
static void set_var_lval __ARGS((lval_T *lp, char_u *endp, typval_T *rettv, int copy, char_u *op));
static int tv_op __ARGS((typval_T *tv1, typval_T *tv2, char_u *op));
static void list_add_watch __ARGS((list_T *l, listwatch_T *lw));
static void list_rem_watch __ARGS((list_T *l, listwatch_T *lwrem));
static void list_fix_watch __ARGS((list_T *l, listitem_T *item));
static void ex_unletlock __ARGS((exarg_T *eap, char_u *argstart, int deep));
static int do_unlet_var __ARGS((lval_T *lp, char_u *name_end, int forceit));
@@ -3106,7 +3104,7 @@ tv_op(tv1, tv2, op)
/*
* Add a watcher to a list.
*/
static void
void
list_add_watch(l, lw)
list_T *l;
listwatch_T *lw;
@@ -3119,7 +3117,7 @@ list_add_watch(l, lw)
* Remove a watcher from a list.
* No warning when it isn't found...
*/
static void
void
list_rem_watch(l, lwrem)
list_T *l;
listwatch_T *lwrem;

View File

@@ -3889,6 +3889,8 @@ set_one_cmd_context(xp, buff)
case CMD_imap: case CMD_inoremap:
case CMD_cmap: case CMD_cnoremap:
case CMD_lmap: case CMD_lnoremap:
case CMD_smap: case CMD_snoremap:
case CMD_xmap: case CMD_xnoremap:
return set_context_in_map_cmd(xp, cmd, arg, forceit,
FALSE, FALSE, ea.cmdidx);
case CMD_unmap:
@@ -3898,6 +3900,8 @@ set_one_cmd_context(xp, buff)
case CMD_iunmap:
case CMD_cunmap:
case CMD_lunmap:
case CMD_sunmap:
case CMD_xunmap:
return set_context_in_map_cmd(xp, cmd, arg, forceit,
FALSE, TRUE, ea.cmdidx);
case CMD_abbreviate: case CMD_noreabbrev:

File diff suppressed because it is too large Load Diff

View File

@@ -155,6 +155,7 @@ struct PyMethodDef { Py_ssize_t a; };
# define PyErr_Occurred dll_PyErr_Occurred
# define PyErr_SetNone dll_PyErr_SetNone
# define PyErr_SetString dll_PyErr_SetString
# define PyErr_SetObject dll_PyErr_SetObject
# define PyEval_InitThreads dll_PyEval_InitThreads
# define PyEval_RestoreThread dll_PyEval_RestoreThread
# define PyEval_SaveThread dll_PyEval_SaveThread
@@ -229,6 +230,7 @@ struct PyMethodDef { Py_ssize_t a; };
# define _Py_TrueStruct (*dll__Py_TrueStruct)
# define PyObject_Init dll__PyObject_Init
# define PyObject_GetIter dll_PyObject_GetIter
# define PyObject_IsTrue dll_PyObject_IsTrue
# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02020000
# define PyType_IsSubtype dll_PyType_IsSubtype
# endif
@@ -259,6 +261,7 @@ static PyObject*(*dll_PyErr_NoMemory)(void);
static PyObject*(*dll_PyErr_Occurred)(void);
static void(*dll_PyErr_SetNone)(PyObject *);
static void(*dll_PyErr_SetString)(PyObject *, const char *);
static void(*dll_PyErr_SetObject)(PyObject *, PyObject *);
static void(*dll_PyEval_InitThreads)(void);
static void(*dll_PyEval_RestoreThread)(PyThreadState *);
static PyThreadState*(*dll_PyEval_SaveThread)(void);
@@ -324,6 +327,7 @@ static int(*dll_Py_IsInitialized)(void);
static PyObject*(*dll__PyObject_New)(PyTypeObject *, PyObject *);
static PyObject*(*dll__PyObject_Init)(PyObject *, PyTypeObject *);
static PyObject* (*dll_PyObject_GetIter)(PyObject *);
static int (*dll_PyObject_IsTrue)(PyObject *);
# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
static iternextfunc dll__PyObject_NextNotImplemented;
# endif
@@ -354,6 +358,7 @@ static PyObject *imp_PyExc_KeyError;
static PyObject *imp_PyExc_KeyboardInterrupt;
static PyObject *imp_PyExc_TypeError;
static PyObject *imp_PyExc_ValueError;
static PyObject *imp_PyExc_RuntimeError;
# define PyExc_AttributeError imp_PyExc_AttributeError
# define PyExc_IndexError imp_PyExc_IndexError
@@ -361,6 +366,7 @@ static PyObject *imp_PyExc_ValueError;
# define PyExc_KeyboardInterrupt imp_PyExc_KeyboardInterrupt
# define PyExc_TypeError imp_PyExc_TypeError
# define PyExc_ValueError imp_PyExc_ValueError
# define PyExc_RuntimeError imp_PyExc_RuntimeError
/*
* Table of name to function pointer of python.
@@ -391,6 +397,7 @@ static struct
{"PyErr_Occurred", (PYTHON_PROC*)&dll_PyErr_Occurred},
{"PyErr_SetNone", (PYTHON_PROC*)&dll_PyErr_SetNone},
{"PyErr_SetString", (PYTHON_PROC*)&dll_PyErr_SetString},
{"PyErr_SetObject", (PYTHON_PROC*)&dll_PyErr_SetObject},
{"PyEval_InitThreads", (PYTHON_PROC*)&dll_PyEval_InitThreads},
{"PyEval_RestoreThread", (PYTHON_PROC*)&dll_PyEval_RestoreThread},
{"PyEval_SaveThread", (PYTHON_PROC*)&dll_PyEval_SaveThread},
@@ -459,6 +466,7 @@ static struct
{"_PyObject_New", (PYTHON_PROC*)&dll__PyObject_New},
{"PyObject_Init", (PYTHON_PROC*)&dll__PyObject_Init},
{"PyObject_GetIter", (PYTHON_PROC*)&dll_PyObject_GetIter},
{"PyObject_IsTrue", (PYTHON_PROC*)&dll_PyObject_IsTrue},
# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
{"_PyObject_NextNotImplemented", (PYTHON_PROC*)&dll__PyObject_NextNotImplemented},
# endif
@@ -587,12 +595,14 @@ get_exceptions(void)
imp_PyExc_KeyboardInterrupt = PyDict_GetItemString(exdict, "KeyboardInterrupt");
imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError");
imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError");
imp_PyExc_RuntimeError = PyDict_GetItemString(exdict, "RuntimeError");
Py_XINCREF(imp_PyExc_AttributeError);
Py_XINCREF(imp_PyExc_IndexError);
Py_XINCREF(imp_PyExc_KeyError);
Py_XINCREF(imp_PyExc_KeyboardInterrupt);
Py_XINCREF(imp_PyExc_TypeError);
Py_XINCREF(imp_PyExc_ValueError);
Py_XINCREF(imp_PyExc_RuntimeError);
Py_XDECREF(exmod);
}
#endif /* DYNAMIC_PYTHON */
@@ -619,9 +629,14 @@ static int initialised = 0;
#define DESTRUCTOR_FINISH(self) Py_DECREF(self);
#define WIN_PYTHON_REF(win) win->w_python_ref
#define BUF_PYTHON_REF(buf) buf->b_python_ref
#define TAB_PYTHON_REF(tab) tab->tp_python_ref
static PyObject *OutputGetattr(PyObject *, char *);
static PyObject *BufferGetattr(PyObject *, char *);
static PyObject *WindowGetattr(PyObject *, char *);
static PyObject *TabPageGetattr(PyObject *, char *);
static PyObject *RangeGetattr(PyObject *, char *);
static PyObject *DictionaryGetattr(PyObject *, char*);
static PyObject *ListGetattr(PyObject *, char *);
@@ -784,7 +799,10 @@ Python_Init(void)
* so the following does both: unlock GIL and save thread state in TLS
* without deleting thread state
*/
PyEval_SaveThread();
#ifndef PY_CAN_RECURSE
saved_python_thread =
#endif
PyEval_SaveThread();
initialised = 1;
}
@@ -1016,9 +1034,6 @@ static int ConvertFromPyObject(PyObject *, typval_T *);
#define BufferType_Check(obj) ((obj)->ob_type == &BufferType)
static PyInt BufferLength(PyObject *);
static PyObject *BufferItem(PyObject *, PyInt);
static PyObject *BufferSlice(PyObject *, PyInt, PyInt);
static PyInt BufferAssItem(PyObject *, PyInt, PyObject *);
static PyInt BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *);
@@ -1053,42 +1068,6 @@ static PySequenceMethods BufferAsSeq = {
/* Buffer object - Implementation
*/
static PyObject *
BufferNew(buf_T *buf)
{
/* We need to handle deletion of buffers underneath us.
* If we add a "b_python_ref" field to the buf_T structure,
* then we can get at it in buf_freeall() in vim. We then
* need to create only ONE Python object per buffer - if
* we try to create a second, just INCREF the existing one
* and return it. The (single) Python object referring to
* the buffer is stored in "b_python_ref".
* Question: what to do on a buf_freeall(). We'll probably
* have to either delete the Python object (DECREF it to
* zero - a bad idea, as it leaves dangling refs!) or
* set the buf_T * value to an invalid value (-1?), which
* means we need checks in all access functions... Bah.
*/
BufferObject *self;
if (buf->b_python_ref != NULL)
{
self = buf->b_python_ref;
Py_INCREF(self);
}
else
{
self = PyObject_NEW(BufferObject, &BufferType);
if (self == NULL)
return NULL;
self->buf = buf;
buf->b_python_ref = self;
}
return (PyObject *)(self);
}
static PyObject *
BufferGetattr(PyObject *self, char *name)
{
@@ -1106,44 +1085,16 @@ BufferGetattr(PyObject *self, char *name)
/******************/
static PyInt
BufferLength(PyObject *self)
{
/* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */
if (CheckBuffer((BufferObject *)(self)))
return -1; /* ??? */
return (((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
static PyObject *
BufferItem(PyObject *self, PyInt n)
{
return RBItem((BufferObject *)(self), n, 1,
(int)((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
static PyObject *
BufferSlice(PyObject *self, PyInt lo, PyInt hi)
{
return RBSlice((BufferObject *)(self), lo, hi, 1,
(int)((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
static PyInt
BufferAssItem(PyObject *self, PyInt n, PyObject *val)
{
return RBAsItem((BufferObject *)(self), n, val, 1,
(PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
NULL);
return RBAsItem((BufferObject *)(self), n, val, 1, -1, NULL);
}
static PyInt
BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
{
return RBAsSlice((BufferObject *)(self), lo, hi, val, 1,
(PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
NULL);
return RBAsSlice((BufferObject *)(self), lo, hi, val, 1, -1, NULL);
}
static PySequenceMethods RangeAsSeq = {
@@ -1195,61 +1146,27 @@ RangeAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
&((RangeObject *)(self))->end);
}
/* Buffer list object - Definitions
*/
static PySequenceMethods BufListAsSeq = {
(PyInquiry) BufListLength, /* sq_length, len(x) */
(binaryfunc) 0, /* sq_concat, x+y */
(PyIntArgFunc) 0, /* sq_repeat, x*n */
(PyIntArgFunc) BufListItem, /* sq_item, x[i] */
(PyIntIntArgFunc) 0, /* sq_slice, x[i:j] */
(PyIntObjArgProc) 0, /* sq_ass_item, x[i]=v */
(PyIntIntObjArgProc) 0, /* sq_ass_slice, x[i:j]=v */
(objobjproc) 0,
#if PY_MAJOR_VERSION >= 2
(binaryfunc) 0,
0,
#endif
};
/* Window object - Implementation
/* TabPage object - Implementation
*/
static PyObject *
WindowNew(win_T *win)
TabPageGetattr(PyObject *self, char *name)
{
/* We need to handle deletion of windows underneath us.
* If we add a "w_python_ref" field to the win_T structure,
* then we can get at it in win_free() in vim. We then
* need to create only ONE Python object per window - if
* we try to create a second, just INCREF the existing one
* and return it. The (single) Python object referring to
* the window is stored in "w_python_ref".
* On a win_free() we set the Python object's win_T* field
* to an invalid value. We trap all uses of a window
* object, and reject them if the win_T* field is invalid.
*/
PyObject *r;
WindowObject *self;
if (CheckTabPage((TabPageObject *)(self)))
return NULL;
if (win->w_python_ref)
{
self = win->w_python_ref;
Py_INCREF(self);
}
r = TabPageAttr((TabPageObject *)(self), name);
if (r || PyErr_Occurred())
return r;
else
{
self = PyObject_NEW(WindowObject, &WindowType);
if (self == NULL)
return NULL;
self->win = win;
win->w_python_ref = self;
}
return (PyObject *)(self);
return Py_FindMethod(TabPageMethods, self, name);
}
/* Window object - Implementation
*/
static PyObject *
WindowGetattr(PyObject *self, char *name)
{
@@ -1265,6 +1182,24 @@ WindowGetattr(PyObject *self, char *name)
return Py_FindMethod(WindowMethods, self, name);
}
/* Tab page list object - Definitions
*/
static PySequenceMethods TabListAsSeq = {
(PyInquiry) TabListLength, /* sq_length, len(x) */
(binaryfunc) 0, /* sq_concat, x+y */
(PyIntArgFunc) 0, /* sq_repeat, x*n */
(PyIntArgFunc) TabListItem, /* sq_item, x[i] */
(PyIntIntArgFunc) 0, /* sq_slice, x[i:j] */
(PyIntObjArgProc) 0, /* sq_ass_item, x[i]=v */
(PyIntIntObjArgProc) 0, /* sq_ass_slice, x[i:j]=v */
(objobjproc) 0,
#if PY_MAJOR_VERSION >= 2
(binaryfunc) 0,
0,
#endif
};
/* Window list object - Definitions
*/
@@ -1289,11 +1224,11 @@ static PySequenceMethods WinListAsSeq = {
void
python_buffer_free(buf_T *buf)
{
if (buf->b_python_ref != NULL)
if (BUF_PYTHON_REF(buf) != NULL)
{
BufferObject *bp = buf->b_python_ref;
BufferObject *bp = BUF_PYTHON_REF(buf);
bp->buf = INVALID_BUFFER_VALUE;
buf->b_python_ref = NULL;
BUF_PYTHON_REF(buf) = NULL;
}
}
@@ -1301,23 +1236,35 @@ python_buffer_free(buf_T *buf)
void
python_window_free(win_T *win)
{
if (win->w_python_ref != NULL)
if (WIN_PYTHON_REF(win) != NULL)
{
WindowObject *wp = win->w_python_ref;
WindowObject *wp = WIN_PYTHON_REF(win);
wp->win = INVALID_WINDOW_VALUE;
win->w_python_ref = NULL;
WIN_PYTHON_REF(win) = NULL;
}
}
void
python_tabpage_free(tabpage_T *tab)
{
if (TAB_PYTHON_REF(tab) != NULL)
{
TabPageObject *tp = TAB_PYTHON_REF(tab);
tp->tab = INVALID_TABPAGE_VALUE;
TAB_PYTHON_REF(tab) = NULL;
}
}
#endif
static BufListObject TheBufferList =
static BufMapObject TheBufferMap =
{
PyObject_HEAD_INIT(&BufListType)
PyObject_HEAD_INIT(&BufMapType)
};
static WinListObject TheWindowList =
{
PyObject_HEAD_INIT(&WinListType)
NULL
};
static CurrentObject TheCurrent =
@@ -1325,6 +1272,11 @@ static CurrentObject TheCurrent =
PyObject_HEAD_INIT(&CurrentType)
};
static TabListObject TheTabPageList =
{
PyObject_HEAD_INIT(&TabListType)
};
static int
PythonMod_Init(void)
{
@@ -1335,11 +1287,14 @@ PythonMod_Init(void)
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
/* Fixups... */
PyType_Ready(&IterType);
PyType_Ready(&BufferType);
PyType_Ready(&RangeType);
PyType_Ready(&WindowType);
PyType_Ready(&BufListType);
PyType_Ready(&TabPageType);
PyType_Ready(&BufMapType);
PyType_Ready(&WinListType);
PyType_Ready(&TabListType);
PyType_Ready(&CurrentType);
PyType_Ready(&OptionsType);
@@ -1352,9 +1307,10 @@ PythonMod_Init(void)
VimError = Py_BuildValue("s", "vim.error");
PyDict_SetItemString(dict, "error", VimError);
PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferList);
PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferMap);
PyDict_SetItemString(dict, "current", (PyObject *)(void *)&TheCurrent);
PyDict_SetItemString(dict, "windows", (PyObject *)(void *)&TheWindowList);
PyDict_SetItemString(dict, "tabpages", (PyObject *)(void *)&TheTabPageList);
tmp = DictionaryNew(&globvardict);
PyDict_SetItemString(dict, "vars", tmp);
Py_DECREF(tmp);

View File

@@ -128,6 +128,7 @@ static void init_structs(void);
# define PyErr_Occurred py3_PyErr_Occurred
# define PyErr_SetNone py3_PyErr_SetNone
# define PyErr_SetString py3_PyErr_SetString
# define PyErr_SetObject py3_PyErr_SetObject
# define PyEval_InitThreads py3_PyEval_InitThreads
# define PyEval_RestoreThread py3_PyEval_RestoreThread
# define PyEval_SaveThread py3_PyEval_SaveThread
@@ -156,6 +157,7 @@ static void init_structs(void);
# define PyMapping_Items py3_PyMapping_Items
# define PyIter_Next py3_PyIter_Next
# define PyObject_GetIter py3_PyObject_GetIter
# define PyObject_IsTrue py3_PyObject_IsTrue
# define PyModule_GetDict py3_PyModule_GetDict
#undef PyRun_SimpleString
# define PyRun_SimpleString py3_PyRun_SimpleString
@@ -249,6 +251,7 @@ static int (*py3_PySlice_GetIndicesEx)(PyObject *r, Py_ssize_t length,
static PyObject* (*py3_PyErr_NoMemory)(void);
static void (*py3_Py_Finalize)(void);
static void (*py3_PyErr_SetString)(PyObject *, const char *);
static void (*py3_PyErr_SetObject)(PyObject *, PyObject *);
static int (*py3_PyRun_SimpleString)(char *);
static PyObject* (*py3_PyRun_String)(char *, int, PyObject *, PyObject *);
static PyObject* (*py3_PyList_GetItem)(PyObject *, Py_ssize_t);
@@ -264,6 +267,7 @@ static PyObject* (*py3_PyLong_FromLong)(long);
static PyObject* (*py3_PyDict_New)(void);
static PyObject* (*py3_PyIter_Next)(PyObject *);
static PyObject* (*py3_PyObject_GetIter)(PyObject *);
static int (*py3_PyObject_IsTrue)(PyObject *);
static PyObject* (*py3_Py_BuildValue)(char *, ...);
static int (*py3_PyType_Ready)(PyTypeObject *type);
static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item);
@@ -332,6 +336,7 @@ static PyObject *p3imp_PyExc_KeyError;
static PyObject *p3imp_PyExc_KeyboardInterrupt;
static PyObject *p3imp_PyExc_TypeError;
static PyObject *p3imp_PyExc_ValueError;
static PyObject *p3imp_PyExc_RuntimeError;
# define PyExc_AttributeError p3imp_PyExc_AttributeError
# define PyExc_IndexError p3imp_PyExc_IndexError
@@ -339,6 +344,7 @@ static PyObject *p3imp_PyExc_ValueError;
# define PyExc_KeyboardInterrupt p3imp_PyExc_KeyboardInterrupt
# define PyExc_TypeError p3imp_PyExc_TypeError
# define PyExc_ValueError p3imp_PyExc_ValueError
# define PyExc_RuntimeError p3imp_PyExc_RuntimeError
/*
* Table of name to function pointer of python.
@@ -377,6 +383,7 @@ static struct
{"PyErr_NoMemory", (PYTHON_PROC*)&py3_PyErr_NoMemory},
{"Py_Finalize", (PYTHON_PROC*)&py3_Py_Finalize},
{"PyErr_SetString", (PYTHON_PROC*)&py3_PyErr_SetString},
{"PyErr_SetObject", (PYTHON_PROC*)&py3_PyErr_SetObject},
{"PyRun_SimpleString", (PYTHON_PROC*)&py3_PyRun_SimpleString},
{"PyRun_String", (PYTHON_PROC*)&py3_PyRun_String},
{"PyList_GetItem", (PYTHON_PROC*)&py3_PyList_GetItem},
@@ -392,6 +399,7 @@ static struct
{"PyMapping_Items", (PYTHON_PROC*)&py3_PyMapping_Items},
{"PyIter_Next", (PYTHON_PROC*)&py3_PyIter_Next},
{"PyObject_GetIter", (PYTHON_PROC*)&py3_PyObject_GetIter},
{"PyObject_IsTrue", (PYTHON_PROC*)&py3_PyObject_IsTrue},
{"PyLong_FromLong", (PYTHON_PROC*)&py3_PyLong_FromLong},
{"PyDict_New", (PYTHON_PROC*)&py3_PyDict_New},
{"PyType_Ready", (PYTHON_PROC*)&py3_PyType_Ready},
@@ -574,12 +582,14 @@ get_py3_exceptions()
p3imp_PyExc_KeyboardInterrupt = PyDict_GetItemString(exdict, "KeyboardInterrupt");
p3imp_PyExc_TypeError = PyDict_GetItemString(exdict, "TypeError");
p3imp_PyExc_ValueError = PyDict_GetItemString(exdict, "ValueError");
p3imp_PyExc_RuntimeError = PyDict_GetItemString(exdict, "RuntimeError");
Py_XINCREF(p3imp_PyExc_AttributeError);
Py_XINCREF(p3imp_PyExc_IndexError);
Py_XINCREF(p3imp_PyExc_KeyError);
Py_XINCREF(p3imp_PyExc_KeyboardInterrupt);
Py_XINCREF(p3imp_PyExc_TypeError);
Py_XINCREF(p3imp_PyExc_ValueError);
Py_XINCREF(p3imp_PyExc_RuntimeError);
Py_XDECREF(exmod);
}
#endif /* DYNAMIC_PYTHON3 */
@@ -621,6 +631,10 @@ static int py3initialised = 0;
#define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self);
#define WIN_PYTHON_REF(win) win->w_python3_ref
#define BUF_PYTHON_REF(buf) buf->b_python3_ref
#define TAB_PYTHON_REF(tab) tab->tp_python3_ref
static void
call_PyObject_Free(void *p)
{
@@ -646,6 +660,7 @@ call_PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
static PyObject *OutputGetattro(PyObject *, PyObject *);
static int OutputSetattro(PyObject *, PyObject *, PyObject *);
static PyObject *BufferGetattro(PyObject *, PyObject *);
static PyObject *TabPageGetattro(PyObject *, PyObject *);
static PyObject *WindowGetattro(PyObject *, PyObject *);
static int WindowSetattro(PyObject *, PyObject *, PyObject *);
static PyObject *RangeGetattro(PyObject *, PyObject *);
@@ -1067,45 +1082,9 @@ static PyMappingMethods BufferAsMapping = {
};
/* Buffer object - Definitions
/* Buffer object
*/
static PyObject *
BufferNew(buf_T *buf)
{
/* We need to handle deletion of buffers underneath us.
* If we add a "b_python3_ref" field to the buf_T structure,
* then we can get at it in buf_freeall() in vim. We then
* need to create only ONE Python object per buffer - if
* we try to create a second, just INCREF the existing one
* and return it. The (single) Python object referring to
* the buffer is stored in "b_python3_ref".
* Question: what to do on a buf_freeall(). We'll probably
* have to either delete the Python object (DECREF it to
* zero - a bad idea, as it leaves dangling refs!) or
* set the buf_T * value to an invalid value (-1?), which
* means we need checks in all access functions... Bah.
*/
BufferObject *self;
if (buf->b_python3_ref != NULL)
{
self = buf->b_python3_ref;
Py_INCREF(self);
}
else
{
self = PyObject_NEW(BufferObject, &BufferType);
buf->b_python3_ref = self;
if (self == NULL)
return NULL;
self->buf = buf;
}
return (PyObject *)(self);
}
static PyObject *
BufferGetattro(PyObject *self, PyObject*nameobj)
{
@@ -1132,29 +1111,6 @@ BufferDir(PyObject *self UNUSED, PyObject *args UNUSED)
/******************/
static Py_ssize_t
BufferLength(PyObject *self)
{
if (CheckBuffer((BufferObject *)(self)))
return -1;
return (Py_ssize_t)(((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
static PyObject *
BufferItem(PyObject *self, Py_ssize_t n)
{
return RBItem((BufferObject *)(self), n, 1,
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
static PyObject *
BufferSlice(PyObject *self, Py_ssize_t lo, Py_ssize_t hi)
{
return RBSlice((BufferObject *)(self), lo, hi, 1,
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
static PyObject *
BufferSubscript(PyObject *self, PyObject* idx)
{
@@ -1166,8 +1122,11 @@ BufferSubscript(PyObject *self, PyObject* idx)
{
Py_ssize_t start, stop, step, slicelen;
if (CheckBuffer((BufferObject *) self))
return NULL;
if (PySlice_GetIndicesEx((PyObject *)idx,
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
&start, &stop,
&step, &slicelen) < 0)
{
@@ -1177,7 +1136,7 @@ BufferSubscript(PyObject *self, PyObject* idx)
}
else
{
PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
PyErr_SetString(PyExc_TypeError, _("index must be int or slice"));
return NULL;
}
}
@@ -1195,8 +1154,11 @@ BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
{
Py_ssize_t start, stop, step, slicelen;
if (CheckBuffer((BufferObject *) self))
return -1;
if (PySlice_GetIndicesEx((PyObject *)idx,
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count+1,
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
&start, &stop,
&step, &slicelen) < 0)
{
@@ -1208,7 +1170,7 @@ BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
}
else
{
PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
PyErr_SetString(PyExc_TypeError, _("index must be int or slice"));
return -1;
}
}
@@ -1290,7 +1252,7 @@ RangeSubscript(PyObject *self, PyObject* idx)
}
else
{
PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
PyErr_SetString(PyExc_TypeError, _("index must be int or slice"));
return NULL;
}
}
@@ -1317,64 +1279,34 @@ RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val)
}
else
{
PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
PyErr_SetString(PyExc_TypeError, _("index must be int or slice"));
return -1;
}
}
/* Buffer list object - Definitions
*/
static PySequenceMethods BufListAsSeq = {
(lenfunc) BufListLength, /* sq_length, len(x) */
(binaryfunc) 0, /* sq_concat, x+y */
(ssizeargfunc) 0, /* sq_repeat, x*n */
(ssizeargfunc) BufListItem, /* sq_item, x[i] */
0, /* was_sq_slice, x[i:j] */
(ssizeobjargproc) 0, /* sq_as_item, x[i]=v */
0, /* sq_ass_slice, x[i:j]=v */
0, /* sq_contains */
0, /* sq_inplace_concat */
0, /* sq_inplace_repeat */
};
/* Window object - Implementation
/* TabPage object - Implementation
*/
static PyObject *
WindowNew(win_T *win)
TabPageGetattro(PyObject *self, PyObject *nameobj)
{
/* We need to handle deletion of windows underneath us.
* If we add a "w_python3_ref" field to the win_T structure,
* then we can get at it in win_free() in vim. We then
* need to create only ONE Python object per window - if
* we try to create a second, just INCREF the existing one
* and return it. The (single) Python object referring to
* the window is stored in "w_python3_ref".
* On a win_free() we set the Python object's win_T* field
* to an invalid value. We trap all uses of a window
* object, and reject them if the win_T* field is invalid.
*/
PyObject *r;
WindowObject *self;
GET_ATTR_STRING(name, nameobj);
if (win->w_python3_ref)
{
self = win->w_python3_ref;
Py_INCREF(self);
}
if (CheckTabPage((TabPageObject *)(self)))
return NULL;
r = TabPageAttr((TabPageObject *)(self), name);
if (r || PyErr_Occurred())
return r;
else
{
self = PyObject_NEW(WindowObject, &WindowType);
if (self == NULL)
return NULL;
self->win = win;
win->w_python3_ref = self;
}
return (PyObject *)(self);
return PyObject_GenericGetAttr(self, nameobj);
}
/* Window object - Implementation
*/
static PyObject *
WindowGetattro(PyObject *self, PyObject *nameobj)
{
@@ -1400,6 +1332,22 @@ WindowSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
return WindowSetattr(self, name, val);
}
/* Tab page list object - Definitions
*/
static PySequenceMethods TabListAsSeq = {
(lenfunc) TabListLength, /* sq_length, len(x) */
(binaryfunc) 0, /* sq_concat, x+y */
(ssizeargfunc) 0, /* sq_repeat, x*n */
(ssizeargfunc) TabListItem, /* sq_item, x[i] */
0, /* sq_slice, x[i:j] */
(ssizeobjargproc)0, /* sq_as_item, x[i]=v */
0, /* sq_ass_slice, x[i:j]=v */
0, /* sq_contains */
0, /* sq_inplace_concat */
0, /* sq_inplace_repeat */
};
/* Window list object - Definitions
*/
@@ -1506,7 +1454,7 @@ ListSubscript(PyObject *self, PyObject* idxObject)
}
else
{
PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
PyErr_SetString(PyExc_TypeError, _("index must be int or slice"));
return NULL;
}
}
@@ -1530,7 +1478,7 @@ ListAsSubscript(PyObject *self, PyObject *idxObject, PyObject *obj)
}
else
{
PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
PyErr_SetString(PyExc_TypeError, _("index must be int or slice"));
return -1;
}
}
@@ -1575,11 +1523,11 @@ FunctionGetattro(PyObject *self, PyObject *nameobj)
void
python3_buffer_free(buf_T *buf)
{
if (buf->b_python3_ref != NULL)
if (BUF_PYTHON_REF(buf) != NULL)
{
BufferObject *bp = buf->b_python3_ref;
BufferObject *bp = BUF_PYTHON_REF(buf);
bp->buf = INVALID_BUFFER_VALUE;
buf->b_python3_ref = NULL;
BUF_PYTHON_REF(buf) = NULL;
}
}
@@ -1587,23 +1535,35 @@ python3_buffer_free(buf_T *buf)
void
python3_window_free(win_T *win)
{
if (win->w_python3_ref != NULL)
if (WIN_PYTHON_REF(win) != NULL)
{
WindowObject *wp = win->w_python3_ref;
WindowObject *wp = WIN_PYTHON_REF(win);
wp->win = INVALID_WINDOW_VALUE;
win->w_python3_ref = NULL;
WIN_PYTHON_REF(win) = NULL;
}
}
void
python3_tabpage_free(tabpage_T *tab)
{
if (TAB_PYTHON_REF(tab) != NULL)
{
TabPageObject *tp = TAB_PYTHON_REF(tab);
tp->tab = INVALID_TABPAGE_VALUE;
TAB_PYTHON_REF(tab) = NULL;
}
}
#endif
static BufListObject TheBufferList =
static BufMapObject TheBufferMap =
{
PyObject_HEAD_INIT(&BufListType)
PyObject_HEAD_INIT(&BufMapType)
};
static WinListObject TheWindowList =
{
PyObject_HEAD_INIT(&WinListType)
NULL
};
static CurrentObject TheCurrent =
@@ -1611,6 +1571,11 @@ static CurrentObject TheCurrent =
PyObject_HEAD_INIT(&CurrentType)
};
static TabListObject TheTabPageList =
{
PyObject_HEAD_INIT(&TabListType)
};
static PyObject *
Py3Init_vim(void)
{
@@ -1619,11 +1584,14 @@ Py3Init_vim(void)
/* The special value is removed from sys.path in Python3_Init(). */
static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};
PyType_Ready(&IterType);
PyType_Ready(&BufferType);
PyType_Ready(&RangeType);
PyType_Ready(&WindowType);
PyType_Ready(&BufListType);
PyType_Ready(&TabPageType);
PyType_Ready(&BufMapType);
PyType_Ready(&WinListType);
PyType_Ready(&TabListType);
PyType_Ready(&CurrentType);
PyType_Ready(&DictionaryType);
PyType_Ready(&ListType);
@@ -1641,12 +1609,14 @@ Py3Init_vim(void)
Py_INCREF(VimError);
PyModule_AddObject(mod, "error", VimError);
Py_INCREF((PyObject *)(void *)&TheBufferList);
PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferList);
Py_INCREF((PyObject *)(void *)&TheBufferMap);
PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferMap);
Py_INCREF((PyObject *)(void *)&TheCurrent);
PyModule_AddObject(mod, "current", (PyObject *)(void *)&TheCurrent);
Py_INCREF((PyObject *)(void *)&TheWindowList);
PyModule_AddObject(mod, "windows", (PyObject *)(void *)&TheWindowList);
Py_INCREF((PyObject *)(void *)&TheTabPageList);
PyModule_AddObject(mod, "tabpages", (PyObject *)(void *)&TheTabPageList);
PyModule_AddObject(mod, "vars", DictionaryNew(&globvardict));
PyModule_AddObject(mod, "vvars", DictionaryNew(&vimvardict));

View File

@@ -144,6 +144,7 @@
#endif
static int ruby_initialized = 0;
static void *ruby_stack_start;
static VALUE objtbl;
static VALUE mVIM;
@@ -157,102 +158,112 @@ static void error_print(int);
static void ruby_io_init(void);
static void ruby_vim_init(void);
#if defined(DYNAMIC_RUBY) || defined(PROTO)
#ifdef PROTO
# define HINSTANCE int /* for generating prototypes */
#if defined(__ia64) && !defined(ruby_init_stack)
# define ruby_init_stack(addr) ruby_init_stack((addr), rb_ia64_bsp())
#endif
#if defined(DYNAMIC_RUBY) || defined(PROTO)
# ifdef PROTO
# define HINSTANCE int /* for generating prototypes */
# endif
/*
* Wrapper defines
*/
#define rb_assoc_new dll_rb_assoc_new
#define rb_cObject (*dll_rb_cObject)
#define rb_check_type dll_rb_check_type
#define rb_class_path dll_rb_class_path
#define rb_data_object_alloc dll_rb_data_object_alloc
#define rb_define_class_under dll_rb_define_class_under
#define rb_define_const dll_rb_define_const
#define rb_define_global_function dll_rb_define_global_function
#define rb_define_method dll_rb_define_method
#define rb_define_module dll_rb_define_module
#define rb_define_module_function dll_rb_define_module_function
#define rb_define_singleton_method dll_rb_define_singleton_method
#define rb_define_virtual_variable dll_rb_define_virtual_variable
#define rb_stdout (*dll_rb_stdout)
#define rb_eArgError (*dll_rb_eArgError)
#define rb_eIndexError (*dll_rb_eIndexError)
#define rb_eRuntimeError (*dll_rb_eRuntimeError)
#define rb_eStandardError (*dll_rb_eStandardError)
#define rb_eval_string_protect dll_rb_eval_string_protect
#define rb_global_variable dll_rb_global_variable
#define rb_hash_aset dll_rb_hash_aset
#define rb_hash_new dll_rb_hash_new
#define rb_inspect dll_rb_inspect
#define rb_int2inum dll_rb_int2inum
#if SIZEOF_INT < SIZEOF_LONG /* 64 bits only */
#define rb_fix2int dll_rb_fix2int
#define rb_num2int dll_rb_num2int
#define rb_num2uint dll_rb_num2uint
#endif
#define rb_lastline_get dll_rb_lastline_get
#define rb_lastline_set dll_rb_lastline_set
#define rb_load_protect dll_rb_load_protect
#ifndef RUBY19_OR_LATER
#define rb_num2long dll_rb_num2long
#endif
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 19
#define rb_num2ulong dll_rb_num2ulong
#endif
#define rb_obj_alloc dll_rb_obj_alloc
#define rb_obj_as_string dll_rb_obj_as_string
#define rb_obj_id dll_rb_obj_id
#define rb_raise dll_rb_raise
#define rb_str_cat dll_rb_str_cat
#define rb_str_concat dll_rb_str_concat
#define rb_str_new dll_rb_str_new
#ifdef rb_str_new2
# define rb_assoc_new dll_rb_assoc_new
# define rb_cObject (*dll_rb_cObject)
# define rb_check_type dll_rb_check_type
# define rb_class_path dll_rb_class_path
# define rb_data_object_alloc dll_rb_data_object_alloc
# define rb_define_class_under dll_rb_define_class_under
# define rb_define_const dll_rb_define_const
# define rb_define_global_function dll_rb_define_global_function
# define rb_define_method dll_rb_define_method
# define rb_define_module dll_rb_define_module
# define rb_define_module_function dll_rb_define_module_function
# define rb_define_singleton_method dll_rb_define_singleton_method
# define rb_define_virtual_variable dll_rb_define_virtual_variable
# define rb_stdout (*dll_rb_stdout)
# define rb_eArgError (*dll_rb_eArgError)
# define rb_eIndexError (*dll_rb_eIndexError)
# define rb_eRuntimeError (*dll_rb_eRuntimeError)
# define rb_eStandardError (*dll_rb_eStandardError)
# define rb_eval_string_protect dll_rb_eval_string_protect
# define rb_global_variable dll_rb_global_variable
# define rb_hash_aset dll_rb_hash_aset
# define rb_hash_new dll_rb_hash_new
# define rb_inspect dll_rb_inspect
# define rb_int2inum dll_rb_int2inum
# if SIZEOF_INT < SIZEOF_LONG /* 64 bits only */
# define rb_fix2int dll_rb_fix2int
# define rb_num2int dll_rb_num2int
# define rb_num2uint dll_rb_num2uint
# endif
# define rb_lastline_get dll_rb_lastline_get
# define rb_lastline_set dll_rb_lastline_set
# define rb_load_protect dll_rb_load_protect
# ifndef RUBY19_OR_LATER
# define rb_num2long dll_rb_num2long
# endif
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 19
# define rb_num2ulong dll_rb_num2ulong
# endif
# define rb_obj_alloc dll_rb_obj_alloc
# define rb_obj_as_string dll_rb_obj_as_string
# define rb_obj_id dll_rb_obj_id
# define rb_raise dll_rb_raise
# define rb_str_cat dll_rb_str_cat
# define rb_str_concat dll_rb_str_concat
# define rb_str_new dll_rb_str_new
# ifdef rb_str_new2
/* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */
# define need_rb_str_new_cstr 1
# define need_rb_str_new_cstr 1
/* Ruby's headers #define rb_str_new_cstr to make use of GCC's
* __builtin_constant_p extension. */
# undef rb_str_new_cstr
# define rb_str_new_cstr dll_rb_str_new_cstr
#else
# define rb_str_new2 dll_rb_str_new2
#endif
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# define rb_string_value dll_rb_string_value
# define rb_string_value_ptr dll_rb_string_value_ptr
# define rb_float_new dll_rb_float_new
# define rb_ary_new dll_rb_ary_new
# define rb_ary_push dll_rb_ary_push
#else
# define rb_str2cstr dll_rb_str2cstr
#endif
#ifdef RUBY19_OR_LATER
# define rb_errinfo dll_rb_errinfo
#else
# define ruby_errinfo (*dll_ruby_errinfo)
#endif
#define ruby_init dll_ruby_init
#define ruby_init_loadpath dll_ruby_init_loadpath
#ifdef WIN3264
# define NtInitialize dll_NtInitialize
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# define rb_w32_snprintf dll_rb_w32_snprintf
# undef rb_str_new_cstr
# define rb_str_new_cstr dll_rb_str_new_cstr
# else
# define rb_str_new2 dll_rb_str_new2
# endif
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# define rb_string_value dll_rb_string_value
# define rb_string_value_ptr dll_rb_string_value_ptr
# define rb_float_new dll_rb_float_new
# define rb_ary_new dll_rb_ary_new
# define rb_ary_push dll_rb_ary_push
# ifdef __ia64
# define rb_ia64_bsp dll_rb_ia64_bsp
# undef ruby_init_stack
# define ruby_init_stack(addr) dll_ruby_init_stack((addr), rb_ia64_bsp())
# else
# define ruby_init_stack dll_ruby_init_stack
# endif
# else
# define rb_str2cstr dll_rb_str2cstr
# endif
# ifdef RUBY19_OR_LATER
# define rb_errinfo dll_rb_errinfo
# else
# define ruby_errinfo (*dll_ruby_errinfo)
# endif
# define ruby_init dll_ruby_init
# define ruby_init_loadpath dll_ruby_init_loadpath
# ifdef WIN3264
# define NtInitialize dll_NtInitialize
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# define rb_w32_snprintf dll_rb_w32_snprintf
# endif
# endif
#endif
#ifdef RUBY19_OR_LATER
# define ruby_script dll_ruby_script
# define rb_enc_find_index dll_rb_enc_find_index
# define rb_enc_find dll_rb_enc_find
# define rb_enc_str_new dll_rb_enc_str_new
# define rb_sprintf dll_rb_sprintf
# define rb_require dll_rb_require
# define ruby_init_stack dll_ruby_init_stack
# define ruby_process_options dll_ruby_process_options
#endif
# ifdef RUBY19_OR_LATER
# define ruby_script dll_ruby_script
# define rb_enc_find_index dll_rb_enc_find_index
# define rb_enc_find dll_rb_enc_find
# define rb_enc_str_new dll_rb_enc_str_new
# define rb_sprintf dll_rb_sprintf
# define rb_require dll_rb_require
# define ruby_process_options dll_ruby_process_options
# endif
/*
* Pointers for dynamic link
@@ -260,9 +271,9 @@ static void ruby_vim_init(void);
static VALUE (*dll_rb_assoc_new) (VALUE, VALUE);
VALUE *dll_rb_cFalseClass;
VALUE *dll_rb_cFixnum;
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
VALUE *dll_rb_cFloat;
#endif
# endif
VALUE *dll_rb_cNilClass;
static VALUE *dll_rb_cObject;
VALUE *dll_rb_cSymbol;
@@ -289,11 +300,11 @@ static VALUE (*dll_rb_hash_aset) (VALUE, VALUE, VALUE);
static VALUE (*dll_rb_hash_new) (void);
static VALUE (*dll_rb_inspect) (VALUE);
static VALUE (*dll_rb_int2inum) (long);
#if SIZEOF_INT < SIZEOF_LONG /* 64 bits only */
# if SIZEOF_INT < SIZEOF_LONG /* 64 bits only */
static long (*dll_rb_fix2int) (VALUE);
static long (*dll_rb_num2int) (VALUE);
static unsigned long (*dll_rb_num2uint) (VALUE);
#endif
# endif
static VALUE (*dll_rb_lastline_get) (void);
static void (*dll_rb_lastline_set) (VALUE);
static void (*dll_rb_load_protect) (VALUE, int, int*);
@@ -303,55 +314,60 @@ static VALUE (*dll_rb_obj_alloc) (VALUE);
static VALUE (*dll_rb_obj_as_string) (VALUE);
static VALUE (*dll_rb_obj_id) (VALUE);
static void (*dll_rb_raise) (VALUE, const char*, ...);
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
static VALUE (*dll_rb_string_value) (volatile VALUE*);
#else
# else
static char *(*dll_rb_str2cstr) (VALUE,int*);
#endif
# endif
static VALUE (*dll_rb_str_cat) (VALUE, const char*, long);
static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
static VALUE (*dll_rb_str_new) (const char*, long);
#ifdef need_rb_str_new_cstr
# ifdef need_rb_str_new_cstr
/* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */
static VALUE (*dll_rb_str_new_cstr) (const char*);
#else
# else
static VALUE (*dll_rb_str_new2) (const char*);
#endif
#ifdef RUBY19_OR_LATER
# endif
# ifdef RUBY19_OR_LATER
static VALUE (*dll_rb_errinfo) (void);
#else
# else
static VALUE *dll_ruby_errinfo;
#endif
# endif
static void (*dll_ruby_init) (void);
static void (*dll_ruby_init_loadpath) (void);
#ifdef WIN3264
# ifdef WIN3264
static void (*dll_NtInitialize) (int*, char***);
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
# endif
# endif
#endif
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
static char * (*dll_rb_string_value_ptr) (volatile VALUE*);
static VALUE (*dll_rb_float_new) (double);
static VALUE (*dll_rb_ary_new) (void);
static VALUE (*dll_rb_ary_push) (VALUE, VALUE);
#endif
#ifdef RUBY19_OR_LATER
# ifdef __ia64
static void * (*dll_rb_ia64_bsp) (void);
static void (*dll_ruby_init_stack)(VALUE*, void*);
# else
static void (*dll_ruby_init_stack)(VALUE*);
# endif
# endif
# ifdef RUBY19_OR_LATER
static VALUE (*dll_rb_int2big)(SIGNED_VALUE);
#endif
# endif
#ifdef RUBY19_OR_LATER
# ifdef RUBY19_OR_LATER
static void (*dll_ruby_script) (const char*);
static int (*dll_rb_enc_find_index) (const char*);
static rb_encoding* (*dll_rb_enc_find) (const char*);
static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
static VALUE (*dll_rb_sprintf) (const char*, ...);
static VALUE (*dll_rb_require) (const char*);
static void (*ruby_init_stack)(VALUE*);
static void* (*ruby_process_options)(int, char**);
#endif
# endif
#if defined(RUBY19_OR_LATER) && !defined(PROTO)
# if defined(RUBY19_OR_LATER) && !defined(PROTO)
SIGNED_VALUE rb_num2long_stub(VALUE x)
{
return dll_rb_num2long(x);
@@ -360,7 +376,7 @@ VALUE rb_int2big_stub(SIGNED_VALUE x)
{
return dll_rb_int2big(x);
}
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20 \
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20 \
&& SIZEOF_INT < SIZEOF_LONG
long rb_fix2int_stub(VALUE x)
{
@@ -370,8 +386,8 @@ long rb_num2int_stub(VALUE x)
{
return dll_rb_num2int(x);
}
#endif
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
# endif
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
VALUE
rb_float_new_in_heap(double d)
{
@@ -381,8 +397,8 @@ VALUE rb_num2ulong(VALUE x)
{
return (long)RSHIFT((SIGNED_VALUE)(x),1);
}
#endif
#endif
# endif
# endif
static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */
@@ -398,9 +414,9 @@ static struct
{"rb_assoc_new", (RUBY_PROC*)&dll_rb_assoc_new},
{"rb_cFalseClass", (RUBY_PROC*)&dll_rb_cFalseClass},
{"rb_cFixnum", (RUBY_PROC*)&dll_rb_cFixnum},
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
{"rb_cFloat", (RUBY_PROC*)&dll_rb_cFloat},
#endif
# endif
{"rb_cNilClass", (RUBY_PROC*)&dll_rb_cNilClass},
{"rb_cObject", (RUBY_PROC*)&dll_rb_cObject},
{"rb_cSymbol", (RUBY_PROC*)&dll_rb_cSymbol},
@@ -427,11 +443,11 @@ static struct
{"rb_hash_new", (RUBY_PROC*)&dll_rb_hash_new},
{"rb_inspect", (RUBY_PROC*)&dll_rb_inspect},
{"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum},
#if SIZEOF_INT < SIZEOF_LONG /* 64 bits only */
# if SIZEOF_INT < SIZEOF_LONG /* 64 bits only */
{"rb_fix2int", (RUBY_PROC*)&dll_rb_fix2int},
{"rb_num2int", (RUBY_PROC*)&dll_rb_num2int},
{"rb_num2uint", (RUBY_PROC*)&dll_rb_num2uint},
#endif
# endif
{"rb_lastline_get", (RUBY_PROC*)&dll_rb_lastline_get},
{"rb_lastline_set", (RUBY_PROC*)&dll_rb_lastline_set},
{"rb_load_protect", (RUBY_PROC*)&dll_rb_load_protect},
@@ -441,49 +457,53 @@ static struct
{"rb_obj_as_string", (RUBY_PROC*)&dll_rb_obj_as_string},
{"rb_obj_id", (RUBY_PROC*)&dll_rb_obj_id},
{"rb_raise", (RUBY_PROC*)&dll_rb_raise},
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
{"rb_string_value", (RUBY_PROC*)&dll_rb_string_value},
#else
# else
{"rb_str2cstr", (RUBY_PROC*)&dll_rb_str2cstr},
#endif
# endif
{"rb_str_cat", (RUBY_PROC*)&dll_rb_str_cat},
{"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat},
{"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
#ifdef need_rb_str_new_cstr
# ifdef need_rb_str_new_cstr
{"rb_str_new_cstr", (RUBY_PROC*)&dll_rb_str_new_cstr},
#else
# else
{"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
#endif
#ifdef RUBY19_OR_LATER
# endif
# ifdef RUBY19_OR_LATER
{"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
#else
# else
{"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
#endif
# endif
{"ruby_init", (RUBY_PROC*)&dll_ruby_init},
{"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath},
#ifdef WIN3264
# ifdef WIN3264
{
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER < 19
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER < 19
"NtInitialize",
# else
# else
"ruby_sysinit",
# endif
# endif
(RUBY_PROC*)&dll_NtInitialize},
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
{"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf},
# endif
# endif
#endif
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
{"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr},
# if DYNAMIC_RUBY_VER <= 19
# ifdef __ia64
{"rb_ia64_bsp", (RUBY_PROC*)&dll_rb_ia64_bsp},
# endif
{"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
# if DYNAMIC_RUBY_VER <= 19
{"rb_float_new", (RUBY_PROC*)&dll_rb_float_new},
# else
# else
{"rb_float_new_in_heap", (RUBY_PROC*)&dll_rb_float_new},
# endif
# endif
{"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new},
{"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push},
#endif
#ifdef RUBY19_OR_LATER
# endif
# ifdef RUBY19_OR_LATER
{"rb_int2big", (RUBY_PROC*)&dll_rb_int2big},
{"ruby_script", (RUBY_PROC*)&dll_ruby_script},
{"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
@@ -491,9 +511,8 @@ static struct
{"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
{"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
{"rb_require", (RUBY_PROC*)&dll_rb_require},
{"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
{"ruby_process_options", (RUBY_PROC*)&dll_ruby_process_options},
#endif
# endif
{"", NULL},
};
@@ -716,8 +735,8 @@ static int ensure_ruby_initialized(void)
NtInitialize(&argc, &argv);
#endif
{
#ifdef RUBY19_OR_LATER
RUBY_INIT_STACK;
#if defined(RUBY_VERSION) && RUBY_VERSION >= 18
ruby_init_stack(ruby_stack_start);
#endif
ruby_init();
}
@@ -1389,3 +1408,9 @@ static void ruby_vim_init(void)
rb_define_virtual_variable("$curbuf", buffer_s_current, 0);
rb_define_virtual_variable("$curwin", window_s_current, 0);
}
void vim_ruby_init(void *stack_start)
{
/* should get machine stack start address early in main function */
ruby_stack_start = stack_start;
}

View File

@@ -192,6 +192,13 @@ main
params.window_count = -1;
#endif
#ifdef FEAT_RUBY
{
int ruby_stack_start;
vim_ruby_init((void *)&ruby_stack_start);
}
#endif
#ifdef FEAT_TCL
vim_tcl_init(params.argv[0]);
#endif

View File

@@ -8847,7 +8847,7 @@ get_option_value_strict(name, numval, stringval, opt_type, from)
void *from;
{
int opt_idx;
char_u *varp;
char_u *varp = NULL;
struct vimoption *p;
int r = 0;

View File

@@ -127,4 +127,6 @@ int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bu
char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
int switch_win __ARGS((win_T **, tabpage_T **, win_T *, tabpage_T *));
void restore_win __ARGS((win_T *, tabpage_T *));
void list_add_watch __ARGS((list_T *l, listwatch_T *lw));
void list_rem_watch __ARGS((list_T *l, listwatch_T *lwrem));
/* vim: set ft=c : */

View File

@@ -6,6 +6,7 @@ void ex_python __ARGS((exarg_T *eap));
void ex_pyfile __ARGS((exarg_T *eap));
void python_buffer_free __ARGS((buf_T *buf));
void python_window_free __ARGS((win_T *win));
void python_tabpage_free __ARGS((tabpage_T *tab));
void do_pyeval __ARGS((char_u *str, typval_T *rettv));
void set_ref_in_python __ARGS((int copyID));
/* vim: set ft=c : */

View File

@@ -6,6 +6,7 @@ void ex_py3 __ARGS((exarg_T *eap));
void ex_py3file __ARGS((exarg_T *eap));
void python3_buffer_free __ARGS((buf_T *buf));
void python3_window_free __ARGS((win_T *win));
void python3_tabpage_free __ARGS((tabpage_T *tab));
void do_py3eval __ARGS((char_u *str, typval_T *rettv));
void set_ref_in_python3 __ARGS((int copyID));
/* vim: set ft=c : */

View File

@@ -6,4 +6,5 @@ void ex_rubydo __ARGS((exarg_T *eap));
void ex_rubyfile __ARGS((exarg_T *eap));
void ruby_buffer_free __ARGS((buf_T *buf));
void ruby_window_free __ARGS((win_T *win));
void vim_ruby_init __ARGS((void *stack_start));
/* vim: set ft=c : */

View File

@@ -74,4 +74,6 @@ int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
int match_delete __ARGS((win_T *wp, int id, int perr));
void clear_matches __ARGS((win_T *wp));
matchitem_T *get_match __ARGS((win_T *wp, int id));
int get_win_number __ARGS((win_T *wp, win_T *first_win));
int get_tab_number __ARGS((tabpage_T *tp));
/* vim: set ft=c : */

View File

@@ -2085,7 +2085,7 @@ qf_age(eap)
if (qi->qf_curlist == 0)
{
EMSG(_("E380: At bottom of quickfix stack"));
return;
break;
}
--qi->qf_curlist;
}
@@ -2094,13 +2094,12 @@ qf_age(eap)
if (qi->qf_curlist >= qi->qf_listcount - 1)
{
EMSG(_("E381: At top of quickfix stack"));
return;
break;
}
++qi->qf_curlist;
}
}
qf_msg(qi);
}
static void

View File

@@ -1759,6 +1759,14 @@ struct tabpage_S
dictitem_T tp_winvar; /* variable for "t:" Dictionary */
dict_T *tp_vars; /* internal variables, local to tab page */
#endif
#ifdef FEAT_PYTHON
void *tp_python_ref; /* The Python value for this tab page */
#endif
#ifdef FEAT_PYTHON3
void *tp_python3_ref; /* The Python value for this tab page */
#endif
};
/*

View File

@@ -3253,9 +3253,19 @@ stoptermcap()
if (!gui.in_use && !gui.starting)
# endif
{
/* May need to check for T_CRV response. */
/* May need to discard T_CRV or T_U7 response. */
if (crv_status == CRV_SENT || u7_status == U7_SENT)
(void)vpeekc_nomap();
{
# ifdef UNIX
/* Give the terminal a chance to respond. */
mch_delay(100L, FALSE);
# endif
# ifdef TCIFLUSH
/* Discard data received but not read. */
if (exiting)
tcflush(fileno(stdin), TCIFLUSH);
# endif
}
/* Check for termcodes first, otherwise an external program may
* get them. */
check_for_codes_from_term();
@@ -4116,9 +4126,11 @@ check_termcode(max_offset, buf, bufsize, buflen)
* The final byte is 'R'. now it is only used for checking for
* ambiguous-width character state.
*/
p = tp[0] == CSI ? tp + 1 : tp + 2;
if ((*T_CRV != NUL || *T_U7 != NUL)
&& ((tp[0] == ESC && tp[1] == '[' && len >= 3)
|| (tp[0] == CSI && len >= 2)))
|| (tp[0] == CSI && len >= 2))
&& (VIM_ISDIGIT(*p) || *p == '>' || *p == '?'))
{
j = 0;
extra = 0;
@@ -4126,7 +4138,7 @@ check_termcode(max_offset, buf, bufsize, buflen)
&& !(tp[i] >= '{' && tp[i] <= '~')
&& !ASCII_ISALPHA(tp[i]); ++i)
if (tp[i] == ';' && ++j == 1)
extra = atoi((char *)tp + i + 1);
extra = i + 1;
if (i == len)
return -1; /* not enough characters */
@@ -4140,6 +4152,8 @@ check_termcode(max_offset, buf, bufsize, buflen)
# ifdef FEAT_AUTOCMD
did_cursorhold = TRUE;
# endif
if (extra > 0)
extra = atoi((char *)tp + extra);
if (extra == 2)
aw = "single";
else if (extra == 3)
@@ -4168,6 +4182,8 @@ check_termcode(max_offset, buf, bufsize, buflen)
/* rxvt sends its version number: "20703" is 2.7.3.
* Ignore it for when the user has set 'term' to xterm,
* even though it's an rxvt. */
if (extra > 0)
extra = atoi((char *)tp + extra);
if (extra > 20000)
extra = 0;

View File

@@ -183,38 +183,21 @@ STARTTEST
: $put ='[0.0, 0.0]'
:endif
:let messages=[]
:py <<EOF
py <<EOF
d=vim.bindeval('{}')
m=vim.bindeval('messages')
try:
d['abc']
except Exception as e:
m.extend([e.__class__.__name__])
def em(expr, g=globals(), l=locals()):
try:
exec(expr, g, l)
except:
m.extend([sys.exc_type.__name__])
try:
d['abc']="\0"
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['abc']=vim
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['']=1
except Exception as e:
m.extend([e.__class__.__name__])
try:
d['a\0b']=1
except Exception as e:
m.extend([e.__class__.__name__])
try:
d[b'a\0b']=1
except Exception as e:
m.extend([e.__class__.__name__])
em('d["abc"]')
em('d["abc"]="\\0"')
em('d["abc"]=vim')
em('d[""]=1')
em('d["a\\0b"]=1')
em('d[u"a\\0b"]=1')
EOF
:$put =messages
:unlet messages
@@ -394,14 +377,14 @@ py << EOF
def e(s, g=globals(), l=locals()):
try:
exec(s, g, l)
except Exception as e:
vim.command('throw ' + repr(e.__class__.__name__))
except:
vim.command('throw ' + repr(sys.exc_type.__name__))
def ev(s, g=globals(), l=locals()):
try:
return eval(s, g, l)
except Exception as e:
vim.command('throw ' + repr(e.__class__.__name__))
except:
vim.command('throw ' + repr(sys.exc_type.__name__))
return 0
EOF
:function E(s)
@@ -475,9 +458,109 @@ EOF
: endtry
: endfor
: call RecVars(oname)
endtry
:endfor
:only
:for buf in g:bufs[1:]
: execute 'bwipeout!' buf
:endfor
:"
:" Test buffer object
:vnew
:put ='First line'
:put ='Second line'
:put ='Third line'
:1 delete _
:py b=vim.current.buffer
:wincmd w
:mark a
py << EOF
cb = vim.current.buffer
# Tests BufferAppend and BufferItem
cb.append(b[0])
# Tests BufferSlice and BufferAssSlice
cb.append('abc') # Will be overwritten
cb[-1:] = b[:-2]
# Test BufferLength and BufferAssSlice
cb.append('def') # Will not be overwritten
cb[len(cb):] = b[:]
# Test BufferAssItem and BufferMark
cb.append('ghi') # Will be overwritten
cb[-1] = repr((len(cb) - cb.mark('a')[0], cb.mark('a')[1]))
# Test BufferRepr
cb.append(repr(cb) + repr(b))
# Modify foreign buffer
b.append('foo')
b[0]='bar'
b[0:0]=['baz']
vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
# Test CheckBuffer
vim.command('bwipeout! ' + str(b.number))
for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
try:
exec(expr)
except vim.error:
pass
else:
# Usually a SEGV here
# Should not happen in any case
cb.append('No exception for ' + expr)
EOF
:"
:" Test vim.buffers object
:set hidden
:edit a
:buffer #
:edit b
:buffer #
:edit c
:buffer #
py << EOF
# Check GCing iterator that was not fully exhausted
i = iter(vim.buffers)
cb.append('i:' + str(next(i)))
# and also check creating more then one iterator at a time
i2 = iter(vim.buffers)
cb.append('i2:' + str(next(i2)))
cb.append('i:' + str(next(i)))
# The following should trigger GC and not cause any problems
del i
del i2
i3 = iter(vim.buffers)
cb.append('i3:' + str(next(i3)))
del i3
prevnum = 0
for b in vim.buffers:
# Check buffer order
if prevnum >= b.number:
cb.append('!!! Buffer numbers not in strictly ascending order')
# Check indexing: vim.buffers[number].number == number
cb.append(str(b.number) + ':' + repr(vim.buffers[b.number]) + '=' + repr(b))
prevnum = b.number
cb.append(str(len(vim.buffers)))
bnums = list(map(lambda b: b.number, vim.buffers))[1:]
# Test wiping out buffer with existing iterator
i4 = iter(vim.buffers)
cb.append('i4:' + str(next(i4)))
vim.command('bwipeout! ' + str(bnums.pop(0)))
try:
next(i4)
except vim.error:
pass
else:
cb.append('!!!! No vim.error')
i4 = iter(vim.buffers)
vim.command('bwipeout! ' + str(bnums.pop(-1)))
vim.command('bwipeout! ' + str(bnums.pop(-1)))
cb.append('i4:' + str(next(i4)))
try:
next(i4)
except StopIteration:
cb.append('StopIteration')
EOF
:endfun
:"
:call Test()

View File

@@ -82,7 +82,6 @@ def
bar
>>> paste
p/gopts1: False
inv: 2! ValueError
p/wopts1! KeyError
inv: 2! KeyError
wopts1! KeyError
@@ -103,7 +102,7 @@ bar
B: 1:1 2:1 3:1 4:1
>>> previewheight
p/gopts1: 12
inv: 'a'! ValueError
inv: 'a'! TypeError
p/wopts1! KeyError
inv: 'a'! KeyError
wopts1! KeyError
@@ -124,7 +123,7 @@ bar
B: 1:5 2:5 3:5 4:5
>>> operatorfunc
p/gopts1: ''
inv: 2! ValueError
inv: 2! TypeError
p/wopts1! KeyError
inv: 2! KeyError
wopts1! KeyError
@@ -199,9 +198,9 @@ bar
B: 1:'+2' 2:'+3' 3:'+1' 4:''
>>> statusline
p/gopts1: ''
inv: 0! ValueError
inv: 0! TypeError
p/wopts1: None
inv: 0! ValueError
inv: 0! TypeError
p/bopts1! KeyError
inv: 0! KeyError
bopts1! KeyError
@@ -224,15 +223,14 @@ bar
wopts2! KeyError
wopts3! KeyError
p/bopts1: False
inv: 2! ValueError
G: 0
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
del wopts3! KeyError
del bopts3! ValueError
G: 0
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
>>> iminsert
p/gopts1! KeyError
inv: 3! KeyError
@@ -244,13 +242,13 @@ bar
wopts3! KeyError
p/bopts1: 2
G: 1
W: 1:2 2:1 3:0 4:2
B: 1:2 2:1 3:0 4:2
W: 1:0 2:2 3:2 4:1
B: 1:0 2:2 3:2 4:1
del wopts3! KeyError
del bopts3! ValueError
G: 1
W: 1:2 2:1 3:0 4:2
B: 1:2 2:1 3:0 4:2
W: 1:0 2:2 3:2 4:1
B: 1:0 2:2 3:2 4:1
>>> omnifunc
p/gopts1! KeyError
inv: 1! KeyError
@@ -261,15 +259,15 @@ bar
wopts2! KeyError
wopts3! KeyError
p/bopts1: ''
inv: 1! ValueError
inv: 1! TypeError
G: ''
W: 1:'B' 2:'C' 3:'A' 4:''
B: 1:'B' 2:'C' 3:'A' 4:''
W: 1:'A' 2:'B' 3:'' 4:'C'
B: 1:'A' 2:'B' 3:'' 4:'C'
del wopts3! KeyError
del bopts3! ValueError
G: ''
W: 1:'B' 2:'C' 3:'A' 4:''
B: 1:'B' 2:'C' 3:'A' 4:''
W: 1:'A' 2:'B' 3:'' 4:'C'
B: 1:'A' 2:'B' 3:'' 4:'C'
>>> preserveindent
p/gopts1! KeyError
inv: 2! KeyError
@@ -280,29 +278,53 @@ bar
wopts2! KeyError
wopts3! KeyError
p/bopts1: False
inv: 2! ValueError
G: 0
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
del wopts3! KeyError
del bopts3! ValueError
G: 0
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
>>> path
p/gopts1: '.,/usr/include,,'
inv: 0! ValueError
inv: 0! TypeError
p/wopts1! KeyError
inv: 0! KeyError
wopts1! KeyError
wopts2! KeyError
wopts3! KeyError
p/bopts1: None
inv: 0! ValueError
inv: 0! TypeError
G: '.,,'
W: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
B: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
W: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
B: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
del wopts3! KeyError
G: '.,,'
W: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
B: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
W: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
B: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
First line
First line
def
First line
Second line
Third line
(7, 2)
<buffer test86.in><buffer >
baz
bar
Second line
Third line
foo
i:<buffer test86.in>
i2:<buffer test86.in>
i:<buffer a>
i3:<buffer test86.in>
1:<buffer test86.in>=<buffer test86.in>
6:<buffer a>=<buffer a>
7:<buffer b>=<buffer b>
8:<buffer c>=<buffer c>
4
i4:<buffer test86.in>
i4:<buffer test86.in>
StopIteration

View File

@@ -444,9 +444,109 @@ EOF
: endtry
: endfor
: call RecVars(oname)
endtry
:endfor
:only
:for buf in g:bufs[1:]
: execute 'bwipeout!' buf
:endfor
:"
:" Test buffer object
:vnew
:put ='First line'
:put ='Second line'
:put ='Third line'
:1 delete _
:py3 b=vim.current.buffer
:wincmd w
:mark a
py3 << EOF
cb = vim.current.buffer
# Tests BufferAppend and BufferItem
cb.append(b[0])
# Tests BufferSlice and BufferAssSlice
cb.append('abc') # Will be overwritten
cb[-1:] = b[:-2]
# Test BufferLength and BufferAssSlice
cb.append('def') # Will not be overwritten
cb[len(cb):] = b[:]
# Test BufferAssItem and BufferMark
cb.append('ghi') # Will be overwritten
cb[-1] = repr((len(cb) - cb.mark('a')[0], cb.mark('a')[1]))
# Test BufferRepr
cb.append(repr(cb) + repr(b))
# Modify foreign buffer
b.append('foo')
b[0]='bar'
b[0:0]=['baz']
vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
# Test CheckBuffer
vim.command('bwipeout! ' + str(b.number))
for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
try:
exec(expr)
except vim.error:
pass
else:
# Usually a SEGV here
# Should not happen in any case
cb.append('No exception for ' + expr)
EOF
:"
:" Test vim.buffers object
:set hidden
:edit a
:buffer #
:edit b
:buffer #
:edit c
:buffer #
py3 << EOF
# Check GCing iterator that was not fully exhausted
i = iter(vim.buffers)
cb.append('i:' + str(next(i)))
# and also check creating more then one iterator at a time
i2 = iter(vim.buffers)
cb.append('i2:' + str(next(i2)))
cb.append('i:' + str(next(i)))
# The following should trigger GC and not cause any problems
del i
del i2
i3 = iter(vim.buffers)
cb.append('i3:' + str(next(i3)))
del i3
prevnum = 0
for b in vim.buffers:
# Check buffer order
if prevnum >= b.number:
cb.append('!!! Buffer numbers not in strictly ascending order')
# Check indexing: vim.buffers[number].number == number
cb.append(str(b.number) + ':' + repr(vim.buffers[b.number]) + '=' + repr(b))
prevnum = b.number
cb.append(str(len(vim.buffers)))
bnums = list(map(lambda b: b.number, vim.buffers))[1:]
# Test wiping out buffer with existing iterator
i4 = iter(vim.buffers)
cb.append('i4:' + str(next(i4)))
vim.command('bwipeout! ' + str(bnums.pop(0)))
try:
next(i4)
except vim.error:
pass
else:
cb.append('!!!! No vim.error')
i4 = iter(vim.buffers)
vim.command('bwipeout! ' + str(bnums.pop(-1)))
vim.command('bwipeout! ' + str(bnums.pop(-1)))
cb.append('i4:' + str(next(i4)))
try:
next(i4)
except StopIteration:
cb.append('StopIteration')
EOF
:endfun
:"
:call Test()
@@ -455,6 +555,7 @@ endtry
:call garbagecollect(1)
:"
:/^start:/,$wq! test.out
:call getchar()
ENDTEST
start:

View File

@@ -71,7 +71,6 @@ def
bar
>>> paste
p/gopts1: False
inv: 2! ValueError
p/wopts1! KeyError
inv: 2! KeyError
wopts1! KeyError
@@ -92,7 +91,7 @@ bar
B: 1:1 2:1 3:1 4:1
>>> previewheight
p/gopts1: 12
inv: 'a'! ValueError
inv: 'a'! TypeError
p/wopts1! KeyError
inv: 'a'! KeyError
wopts1! KeyError
@@ -113,7 +112,7 @@ bar
B: 1:5 2:5 3:5 4:5
>>> operatorfunc
p/gopts1: b''
inv: 2! ValueError
inv: 2! TypeError
p/wopts1! KeyError
inv: 2! KeyError
wopts1! KeyError
@@ -188,9 +187,9 @@ bar
B: 1:'+2' 2:'+3' 3:'+1' 4:''
>>> statusline
p/gopts1: b''
inv: 0! ValueError
inv: 0! TypeError
p/wopts1: None
inv: 0! ValueError
inv: 0! TypeError
p/bopts1! KeyError
inv: 0! KeyError
bopts1! KeyError
@@ -213,15 +212,14 @@ bar
wopts2! KeyError
wopts3! KeyError
p/bopts1: False
inv: 2! ValueError
G: 0
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
del wopts3! KeyError
del bopts3! ValueError
G: 0
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
>>> iminsert
p/gopts1! KeyError
inv: 3! KeyError
@@ -233,13 +231,13 @@ bar
wopts3! KeyError
p/bopts1: 2
G: 1
W: 1:2 2:1 3:0 4:2
B: 1:2 2:1 3:0 4:2
W: 1:0 2:2 3:2 4:1
B: 1:0 2:2 3:2 4:1
del wopts3! KeyError
del bopts3! ValueError
G: 1
W: 1:2 2:1 3:0 4:2
B: 1:2 2:1 3:0 4:2
W: 1:0 2:2 3:2 4:1
B: 1:0 2:2 3:2 4:1
>>> omnifunc
p/gopts1! KeyError
inv: 1! KeyError
@@ -250,15 +248,15 @@ bar
wopts2! KeyError
wopts3! KeyError
p/bopts1: b''
inv: 1! ValueError
inv: 1! TypeError
G: ''
W: 1:'B' 2:'C' 3:'A' 4:''
B: 1:'B' 2:'C' 3:'A' 4:''
W: 1:'A' 2:'B' 3:'' 4:'C'
B: 1:'A' 2:'B' 3:'' 4:'C'
del wopts3! KeyError
del bopts3! ValueError
G: ''
W: 1:'B' 2:'C' 3:'A' 4:''
B: 1:'B' 2:'C' 3:'A' 4:''
W: 1:'A' 2:'B' 3:'' 4:'C'
B: 1:'A' 2:'B' 3:'' 4:'C'
>>> preserveindent
p/gopts1! KeyError
inv: 2! KeyError
@@ -269,29 +267,53 @@ bar
wopts2! KeyError
wopts3! KeyError
p/bopts1: False
inv: 2! ValueError
G: 0
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
del wopts3! KeyError
del bopts3! ValueError
G: 0
W: 1:1 2:1 3:0 4:0
B: 1:1 2:1 3:0 4:0
W: 1:0 2:1 3:0 4:1
B: 1:0 2:1 3:0 4:1
>>> path
p/gopts1: b'.,/usr/include,,'
inv: 0! ValueError
inv: 0! TypeError
p/wopts1! KeyError
inv: 0! KeyError
wopts1! KeyError
wopts2! KeyError
wopts3! KeyError
p/bopts1: None
inv: 0! ValueError
inv: 0! TypeError
G: '.,,'
W: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
B: 1:',,' 2:'.' 3:'.,,' 4:'.,,'
W: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
B: 1:'.,,' 2:',,' 3:'.,,' 4:'.'
del wopts3! KeyError
G: '.,,'
W: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
B: 1:',,' 2:'.,,' 3:'.,,' 4:'.,,'
W: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
B: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,'
First line
First line
def
First line
Second line
Third line
(7, 2)
<buffer test87.in><buffer >
baz
bar
Second line
Third line
foo
i:<buffer test87.in>
i2:<buffer test87.in>
i:<buffer a>
i3:<buffer test87.in>
1:<buffer test87.in>=<buffer test87.in>
6:<buffer a>=<buffer a>
7:<buffer b>=<buffer b>
8:<buffer c>=<buffer c>
4
i4:<buffer test87.in>
i4:<buffer test87.in>
StopIteration

View File

@@ -728,6 +728,48 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
951,
/**/
950,
/**/
949,
/**/
948,
/**/
947,
/**/
946,
/**/
945,
/**/
944,
/**/
943,
/**/
942,
/**/
941,
/**/
940,
/**/
939,
/**/
938,
/**/
937,
/**/
936,
/**/
935,
/**/
934,
/**/
933,
/**/
932,
/**/
931,
/**/
930,
/**/

View File

@@ -3510,6 +3510,15 @@ free_tabpage(tp)
hash_init(&tp->tp_vars->dv_hashtab);
unref_var_dict(tp->tp_vars);
#endif
#ifdef FEAT_PYTHON
python_tabpage_free(tp);
#endif
#ifdef FEAT_PYTHON3
python3_tabpage_free(tp);
#endif
vim_free(tp);
}
@@ -6731,3 +6740,35 @@ get_match(wp, id)
return cur;
}
#endif
#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
int
get_win_number(win_T *wp, win_T *first_win)
{
int i = 1;
win_T *w;
for (w = first_win; w != NULL && w != wp; w = W_NEXT(w))
++i;
if (w == NULL)
return 0;
else
return i;
}
int
get_tab_number(tabpage_T *tp)
{
int i = 1;
tabpage_T *t;
for (t = first_tabpage; t != NULL && t != tp; t = t->tp_next)
++i;
if (t == NULL)
return 0;
else
return i;
}
#endif