|
Karsten Hopp |
ffc55f |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
ffc55f |
Subject: Patch 7.3.941
|
|
Karsten Hopp |
ffc55f |
Fcc: outbox
|
|
Karsten Hopp |
ffc55f |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
ffc55f |
Mime-Version: 1.0
|
|
Karsten Hopp |
ffc55f |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
ffc55f |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
ffc55f |
------------
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
Patch 7.3.941
|
|
Karsten Hopp |
ffc55f |
Problem: Stuff in if_py_both.h is ordered badly.
|
|
Karsten Hopp |
ffc55f |
Solution: Reorder by type. (ZyX)
|
|
Karsten Hopp |
ffc55f |
Files: src/if_py_both.h, src/if_python.c
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
*** ../vim-7.3.940/src/if_py_both.h 2013-05-12 19:30:27.000000000 +0200
|
|
Karsten Hopp |
ffc55f |
--- src/if_py_both.h 2013-05-12 19:36:38.000000000 +0200
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 7,13 ****
|
|
Karsten Hopp |
ffc55f |
* See README.txt for an overview of the Vim source code.
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
/*
|
|
Karsten Hopp |
ffc55f |
! * Python extensions by Paul Moore, David Leonard, Roland Puntaier.
|
|
Karsten Hopp |
ffc55f |
*
|
|
Karsten Hopp |
ffc55f |
* Common code for if_python.c and if_python3.c.
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
--- 7,14 ----
|
|
Karsten Hopp |
ffc55f |
* See README.txt for an overview of the Vim source code.
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
/*
|
|
Karsten Hopp |
ffc55f |
! * Python extensions by Paul Moore, David Leonard, Roland Puntaier, Nikolay
|
|
Karsten Hopp |
ffc55f |
! * Pavlov.
|
|
Karsten Hopp |
ffc55f |
*
|
|
Karsten Hopp |
ffc55f |
* Common code for if_python.c and if_python3.c.
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 22,27 ****
|
|
Karsten Hopp |
ffc55f |
--- 23,39 ----
|
|
Karsten Hopp |
ffc55f |
# define ENC_OPT "latin1"
|
|
Karsten Hopp |
ffc55f |
#endif
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
|
|
Karsten Hopp |
ffc55f |
+ #define INVALID_WINDOW_VALUE ((win_T *)(-1))
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static int ConvertFromPyObject(PyObject *, typval_T *);
|
|
Karsten Hopp |
ffc55f |
+ static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static PyInt RangeStart;
|
|
Karsten Hopp |
ffc55f |
+ static PyInt RangeEnd;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
/*
|
|
Karsten Hopp |
ffc55f |
* obtain a lock on the Vim data structures
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 38,53 ****
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! /* Output object definition
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static PyObject *OutputWrite(PyObject *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
- static PyObject *OutputWritelines(PyObject *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
- static PyObject *OutputFlush(PyObject *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
/* Function to write a line, points to either msg() or emsg(). */
|
|
Karsten Hopp |
ffc55f |
typedef void (*writefn)(char_u *);
|
|
Karsten Hopp |
ffc55f |
! static void writer(writefn fn, char_u *str, PyInt n);
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
typedef struct
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 50,62 ----
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! /* Output buffer management
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
/* Function to write a line, points to either msg() or emsg(). */
|
|
Karsten Hopp |
ffc55f |
typedef void (*writefn)(char_u *);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyTypeObject OutputType;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
typedef struct
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 56,76 ****
|
|
Karsten Hopp |
ffc55f |
long error;
|
|
Karsten Hopp |
ffc55f |
} OutputObject;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static struct PyMethodDef OutputMethods[] = {
|
|
Karsten Hopp |
ffc55f |
- /* name, function, calling, documentation */
|
|
Karsten Hopp |
ffc55f |
- {"write", OutputWrite, 1, ""},
|
|
Karsten Hopp |
ffc55f |
- {"writelines", OutputWritelines, 1, ""},
|
|
Karsten Hopp |
ffc55f |
- {"flush", OutputFlush, 1, ""},
|
|
Karsten Hopp |
ffc55f |
- { NULL, NULL, 0, NULL}
|
|
Karsten Hopp |
ffc55f |
- };
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- /*************/
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- /* Output buffer management
|
|
Karsten Hopp |
ffc55f |
- */
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static int
|
|
Karsten Hopp |
ffc55f |
OutputSetattr(PyObject *self, char *name, PyObject *val)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 65,70 ----
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 96,101 ****
|
|
Karsten Hopp |
ffc55f |
--- 90,145 ----
|
|
Karsten Hopp |
ffc55f |
return -1;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ /* Buffer IO, we write one whole line at a time. */
|
|
Karsten Hopp |
ffc55f |
+ static garray_T io_ga = {0, 0, 1, 80, NULL};
|
|
Karsten Hopp |
ffc55f |
+ static writefn old_fn = NULL;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static void
|
|
Karsten Hopp |
ffc55f |
+ PythonIO_Flush(void)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ if (old_fn != NULL && io_ga.ga_len > 0)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ ((char_u *)io_ga.ga_data)[io_ga.ga_len] = NUL;
|
|
Karsten Hopp |
ffc55f |
+ old_fn((char_u *)io_ga.ga_data);
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ io_ga.ga_len = 0;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static void
|
|
Karsten Hopp |
ffc55f |
+ writer(writefn fn, char_u *str, PyInt n)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ char_u *ptr;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ /* Flush when switching output function. */
|
|
Karsten Hopp |
ffc55f |
+ if (fn != old_fn)
|
|
Karsten Hopp |
ffc55f |
+ PythonIO_Flush();
|
|
Karsten Hopp |
ffc55f |
+ old_fn = fn;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ /* Write each NL separated line. Text after the last NL is kept for
|
|
Karsten Hopp |
ffc55f |
+ * writing later. */
|
|
Karsten Hopp |
ffc55f |
+ while (n > 0 && (ptr = memchr(str, '\n', n)) != NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyInt len = ptr - str;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (ga_grow(&io_ga, (int)(len + 1)) == FAIL)
|
|
Karsten Hopp |
ffc55f |
+ break;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)len);
|
|
Karsten Hopp |
ffc55f |
+ ((char *)io_ga.ga_data)[io_ga.ga_len + len] = NUL;
|
|
Karsten Hopp |
ffc55f |
+ fn((char_u *)io_ga.ga_data);
|
|
Karsten Hopp |
ffc55f |
+ str = ptr + 1;
|
|
Karsten Hopp |
ffc55f |
+ n -= len + 1;
|
|
Karsten Hopp |
ffc55f |
+ io_ga.ga_len = 0;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ /* Put the remaining text into io_ga for later printing. */
|
|
Karsten Hopp |
ffc55f |
+ if (n > 0 && ga_grow(&io_ga, (int)(n + 1)) == OK)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)n);
|
|
Karsten Hopp |
ffc55f |
+ io_ga.ga_len += (int)n;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
OutputWrite(PyObject *self, PyObject *args)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 172,231 ****
|
|
Karsten Hopp |
ffc55f |
return Py_None;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- /* Buffer IO, we write one whole line at a time. */
|
|
Karsten Hopp |
ffc55f |
- static garray_T io_ga = {0, 0, 1, 80, NULL};
|
|
Karsten Hopp |
ffc55f |
- static writefn old_fn = NULL;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- static void
|
|
Karsten Hopp |
ffc55f |
- PythonIO_Flush(void)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- if (old_fn != NULL && io_ga.ga_len > 0)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- ((char_u *)io_ga.ga_data)[io_ga.ga_len] = NUL;
|
|
Karsten Hopp |
ffc55f |
- old_fn((char_u *)io_ga.ga_data);
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
- io_ga.ga_len = 0;
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- static void
|
|
Karsten Hopp |
ffc55f |
- writer(writefn fn, char_u *str, PyInt n)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- char_u *ptr;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- /* Flush when switching output function. */
|
|
Karsten Hopp |
ffc55f |
- if (fn != old_fn)
|
|
Karsten Hopp |
ffc55f |
- PythonIO_Flush();
|
|
Karsten Hopp |
ffc55f |
- old_fn = fn;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- /* Write each NL separated line. Text after the last NL is kept for
|
|
Karsten Hopp |
ffc55f |
- * writing later. */
|
|
Karsten Hopp |
ffc55f |
- while (n > 0 && (ptr = memchr(str, '\n', n)) != NULL)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- PyInt len = ptr - str;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- if (ga_grow(&io_ga, (int)(len + 1)) == FAIL)
|
|
Karsten Hopp |
ffc55f |
- break;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)len);
|
|
Karsten Hopp |
ffc55f |
- ((char *)io_ga.ga_data)[io_ga.ga_len + len] = NUL;
|
|
Karsten Hopp |
ffc55f |
- fn((char_u *)io_ga.ga_data);
|
|
Karsten Hopp |
ffc55f |
- str = ptr + 1;
|
|
Karsten Hopp |
ffc55f |
- n -= len + 1;
|
|
Karsten Hopp |
ffc55f |
- io_ga.ga_len = 0;
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- /* Put the remaining text into io_ga for later printing. */
|
|
Karsten Hopp |
ffc55f |
- if (n > 0 && ga_grow(&io_ga, (int)(n + 1)) == OK)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- mch_memmove(((char *)io_ga.ga_data) + io_ga.ga_len, str, (size_t)n);
|
|
Karsten Hopp |
ffc55f |
- io_ga.ga_len += (int)n;
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
/***************/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static PyTypeObject OutputType;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static OutputObject Output =
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 216,230 ----
|
|
Karsten Hopp |
ffc55f |
return Py_None;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
/***************/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static struct PyMethodDef OutputMethods[] = {
|
|
Karsten Hopp |
ffc55f |
! /* name, function, calling, documentation */
|
|
Karsten Hopp |
ffc55f |
! {"write", OutputWrite, 1, ""},
|
|
Karsten Hopp |
ffc55f |
! {"writelines", OutputWritelines, 1, ""},
|
|
Karsten Hopp |
ffc55f |
! {"flush", OutputFlush, 1, ""},
|
|
Karsten Hopp |
ffc55f |
! { NULL, NULL, 0, NULL}
|
|
Karsten Hopp |
ffc55f |
! };
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static OutputObject Output =
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 281,286 ****
|
|
Karsten Hopp |
ffc55f |
--- 280,286 ----
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
/* Vim module - Implementation
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
VimCommand(PyObject *self UNUSED, PyObject *args)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 530,555 ****
|
|
Karsten Hopp |
ffc55f |
{ NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
};
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- typedef struct
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- PyObject_HEAD
|
|
Karsten Hopp |
ffc55f |
- buf_T *buf;
|
|
Karsten Hopp |
ffc55f |
- } BufferObject;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
/*
|
|
Karsten Hopp |
ffc55f |
* Buffer list object - Implementation
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
typedef struct
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
PyObject_HEAD
|
|
Karsten Hopp |
ffc55f |
} BufListObject;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static PyTypeObject BufListType;
|
|
Karsten Hopp |
ffc55f |
- static PySequenceMethods WinListAsSeq;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static PyInt
|
|
Karsten Hopp |
ffc55f |
BufListLength(PyObject *self UNUSED)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 530,547 ----
|
|
Karsten Hopp |
ffc55f |
{ NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
};
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
/*
|
|
Karsten Hopp |
ffc55f |
* Buffer list object - Implementation
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ static PyTypeObject BufListType;
|
|
Karsten Hopp |
ffc55f |
+ static PySequenceMethods BufListAsSeq;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
typedef struct
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
PyObject_HEAD
|
|
Karsten Hopp |
ffc55f |
} BufListObject;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyInt
|
|
Karsten Hopp |
ffc55f |
BufListLength(PyObject *self UNUSED)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 580,599 ****
|
|
Karsten Hopp |
ffc55f |
return NULL;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- typedef struct
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- PyObject_HEAD
|
|
Karsten Hopp |
ffc55f |
- win_T *win;
|
|
Karsten Hopp |
ffc55f |
- } WindowObject;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- static struct PyMethodDef WindowMethods[] = {
|
|
Karsten Hopp |
ffc55f |
- /* name, function, calling, documentation */
|
|
Karsten Hopp |
ffc55f |
- { NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
- };
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- static int ConvertFromPyObject(PyObject *, typval_T *);
|
|
Karsten Hopp |
ffc55f |
- static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
typedef struct pylinkedlist_S {
|
|
Karsten Hopp |
ffc55f |
struct pylinkedlist_S *pll_next;
|
|
Karsten Hopp |
ffc55f |
struct pylinkedlist_S *pll_prev;
|
|
Karsten Hopp |
ffc55f |
--- 572,577 ----
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 655,670 ****
|
|
Karsten Hopp |
ffc55f |
pylinkedlist_T ref;
|
|
Karsten Hopp |
ffc55f |
} DictionaryObject;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static PyInt DictionaryAssItem(PyObject *, PyObject *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
- static PyInt DictionaryLength(PyObject *);
|
|
Karsten Hopp |
ffc55f |
- static PyObject *DictionaryItem(PyObject *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- static PyMappingMethods DictionaryAsMapping = {
|
|
Karsten Hopp |
ffc55f |
- (lenfunc) DictionaryLength,
|
|
Karsten Hopp |
ffc55f |
- (binaryfunc) DictionaryItem,
|
|
Karsten Hopp |
ffc55f |
- (objobjargproc) DictionaryAssItem,
|
|
Karsten Hopp |
ffc55f |
- };
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
DictionaryNew(dict_T *dict)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 633,638 ----
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 693,895 ****
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static int
|
|
Karsten Hopp |
ffc55f |
! pydict_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! dict_T *d;
|
|
Karsten Hopp |
ffc55f |
! char_u *key;
|
|
Karsten Hopp |
ffc55f |
! dictitem_T *di;
|
|
Karsten Hopp |
ffc55f |
! PyObject *keyObject;
|
|
Karsten Hopp |
ffc55f |
! PyObject *valObject;
|
|
Karsten Hopp |
ffc55f |
! Py_ssize_t iter = 0;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! d = dict_alloc();
|
|
Karsten Hopp |
ffc55f |
! if (d == NULL)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
return -1;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! tv->v_type = VAR_DICT;
|
|
Karsten Hopp |
ffc55f |
! tv->vval.v_dict = d;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! while (PyDict_Next(obj, &iter, &keyObject, &valObject))
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! DICTKEY_DECL
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (keyObject == NULL)
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! if (valObject == NULL)
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! DICTKEY_GET_NOTEMPTY(-1)
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! di = dictitem_alloc(key);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! DICTKEY_UNREF
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (di == NULL)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! di->di_tv.v_lock = 0;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! vim_free(di);
|
|
Karsten Hopp |
ffc55f |
return -1;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
! if (dict_add(d, di) == FAIL)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! vim_free(di);
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetVim(_("failed to add key to dictionary"));
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
- return 0;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static int
|
|
Karsten Hopp |
ffc55f |
! pymap_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
- dict_T *d;
|
|
Karsten Hopp |
ffc55f |
char_u *key;
|
|
Karsten Hopp |
ffc55f |
dictitem_T *di;
|
|
Karsten Hopp |
ffc55f |
! PyObject *list;
|
|
Karsten Hopp |
ffc55f |
! PyObject *litem;
|
|
Karsten Hopp |
ffc55f |
! PyObject *keyObject;
|
|
Karsten Hopp |
ffc55f |
! PyObject *valObject;
|
|
Karsten Hopp |
ffc55f |
! Py_ssize_t lsize;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! d = dict_alloc();
|
|
Karsten Hopp |
ffc55f |
! if (d == NULL)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! tv->v_type = VAR_DICT;
|
|
Karsten Hopp |
ffc55f |
! tv->vval.v_dict = d;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! list = PyMapping_Items(obj);
|
|
Karsten Hopp |
ffc55f |
! if (list == NULL)
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! lsize = PyList_Size(list);
|
|
Karsten Hopp |
ffc55f |
! while (lsize--)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! DICTKEY_DECL
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! litem = PyList_GetItem(list, lsize);
|
|
Karsten Hopp |
ffc55f |
! if (litem == NULL)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! keyObject = PyTuple_GetItem(litem, 0);
|
|
Karsten Hopp |
ffc55f |
! if (keyObject == NULL)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! DICTKEY_GET_NOTEMPTY(-1)
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! valObject = PyTuple_GetItem(litem, 1);
|
|
Karsten Hopp |
ffc55f |
! if (valObject == NULL)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! di = dictitem_alloc(key);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! DICTKEY_UNREF
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (di == NULL)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
! PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! di->di_tv.v_lock = 0;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! vim_free(di);
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! if (dict_add(d, di) == FAIL)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! vim_free(di);
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetVim(_("failed to add key to dictionary"));
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
! return 0;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static int
|
|
Karsten Hopp |
ffc55f |
! DictionarySetattr(PyObject *self, char *name, PyObject *val)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! DictionaryObject *this = (DictionaryObject *)(self);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (val == NULL)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (strcmp(name, "locked") == 0)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! if (this->dict->dv_lock == VAR_FIXED)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary"));
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! else
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! if (!PyBool_Check(val))
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed"));
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (val == Py_True)
|
|
Karsten Hopp |
ffc55f |
! this->dict->dv_lock = VAR_LOCKED;
|
|
Karsten Hopp |
ffc55f |
! else
|
|
Karsten Hopp |
ffc55f |
! this->dict->dv_lock = 0;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! return 0;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! else
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyInt
|
|
Karsten Hopp |
ffc55f |
! DictionaryLength(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used)));
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! DictionaryItem(PyObject *self, PyObject *keyObject)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! char_u *key;
|
|
Karsten Hopp |
ffc55f |
! dictitem_T *di;
|
|
Karsten Hopp |
ffc55f |
! DICTKEY_DECL
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
DICTKEY_GET_NOTEMPTY(NULL)
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
--- 661,717 ----
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static int
|
|
Karsten Hopp |
ffc55f |
! DictionarySetattr(PyObject *self, char *name, PyObject *val)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! DictionaryObject *this = (DictionaryObject *)(self);
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! if (val == NULL)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
|
|
Karsten Hopp |
ffc55f |
return -1;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! if (strcmp(name, "locked") == 0)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! if (this->dict->dv_lock == VAR_FIXED)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary"));
|
|
Karsten Hopp |
ffc55f |
return -1;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
! else
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! if (!PyBool_Check(val))
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed"));
|
|
Karsten Hopp |
ffc55f |
! return -1;
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (val == Py_True)
|
|
Karsten Hopp |
ffc55f |
! this->dict->dv_lock = VAR_LOCKED;
|
|
Karsten Hopp |
ffc55f |
! else
|
|
Karsten Hopp |
ffc55f |
! this->dict->dv_lock = 0;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
+ return 0;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ else
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static PyInt
|
|
Karsten Hopp |
ffc55f |
! DictionaryLength(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used)));
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! DictionaryItem(PyObject *self, PyObject *keyObject)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
char_u *key;
|
|
Karsten Hopp |
ffc55f |
dictitem_T *di;
|
|
Karsten Hopp |
ffc55f |
! DICTKEY_DECL
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
DICTKEY_GET_NOTEMPTY(NULL)
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 993,998 ****
|
|
Karsten Hopp |
ffc55f |
--- 815,826 ----
|
|
Karsten Hopp |
ffc55f |
return r;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ static PyMappingMethods DictionaryAsMapping = {
|
|
Karsten Hopp |
ffc55f |
+ (lenfunc) DictionaryLength,
|
|
Karsten Hopp |
ffc55f |
+ (binaryfunc) DictionaryItem,
|
|
Karsten Hopp |
ffc55f |
+ (objobjargproc) DictionaryAssItem,
|
|
Karsten Hopp |
ffc55f |
+ };
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
static struct PyMethodDef DictionaryMethods[] = {
|
|
Karsten Hopp |
ffc55f |
{"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""},
|
|
Karsten Hopp |
ffc55f |
{ NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 1065,1136 ****
|
|
Karsten Hopp |
ffc55f |
return 0;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static int
|
|
Karsten Hopp |
ffc55f |
- pyseq_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- list_T *l;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- l = list_alloc();
|
|
Karsten Hopp |
ffc55f |
- if (l == NULL)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
- return -1;
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- tv->v_type = VAR_LIST;
|
|
Karsten Hopp |
ffc55f |
- tv->vval.v_list = l;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- if (list_py_concat(l, obj, lookupDict) == -1)
|
|
Karsten Hopp |
ffc55f |
- return -1;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- return 0;
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- static int
|
|
Karsten Hopp |
ffc55f |
- pyiter_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- PyObject *iterator = PyObject_GetIter(obj);
|
|
Karsten Hopp |
ffc55f |
- PyObject *item;
|
|
Karsten Hopp |
ffc55f |
- list_T *l;
|
|
Karsten Hopp |
ffc55f |
- listitem_T *li;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- l = list_alloc();
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- if (l == NULL)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
- return -1;
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- tv->vval.v_list = l;
|
|
Karsten Hopp |
ffc55f |
- tv->v_type = VAR_LIST;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- if (iterator == NULL)
|
|
Karsten Hopp |
ffc55f |
- return -1;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- while ((item = PyIter_Next(obj)))
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- li = listitem_alloc();
|
|
Karsten Hopp |
ffc55f |
- if (li == NULL)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
- return -1;
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
- li->li_tv.v_lock = 0;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- if (_ConvertFromPyObject(item, &li->li_tv, lookupDict) == -1)
|
|
Karsten Hopp |
ffc55f |
- return -1;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- list_append(l, li);
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- Py_DECREF(item);
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- Py_DECREF(iterator);
|
|
Karsten Hopp |
ffc55f |
- return 0;
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static PyInt
|
|
Karsten Hopp |
ffc55f |
ListLength(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 893,898 ----
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 1768,1774 ****
|
|
Karsten Hopp |
ffc55f |
(objobjargproc) OptionsAssItem,
|
|
Karsten Hopp |
ffc55f |
};
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! #define INVALID_WINDOW_VALUE ((win_T *)(-1))
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static int
|
|
Karsten Hopp |
ffc55f |
CheckWindow(WindowObject *this)
|
|
Karsten Hopp |
ffc55f |
--- 1530,1547 ----
|
|
Karsten Hopp |
ffc55f |
(objobjargproc) OptionsAssItem,
|
|
Karsten Hopp |
ffc55f |
};
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! /* Window object
|
|
Karsten Hopp |
ffc55f |
! */
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! typedef struct
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyObject_HEAD
|
|
Karsten Hopp |
ffc55f |
! win_T *win;
|
|
Karsten Hopp |
ffc55f |
! } WindowObject;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static int WindowSetattr(PyObject *, char *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
! static PyObject *WindowRepr(PyObject *);
|
|
Karsten Hopp |
ffc55f |
! static PyTypeObject WindowType;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static int
|
|
Karsten Hopp |
ffc55f |
CheckWindow(WindowObject *this)
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 1782,1794 ****
|
|
Karsten Hopp |
ffc55f |
return 0;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- /* Window object
|
|
Karsten Hopp |
ffc55f |
- */
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- static int WindowSetattr(PyObject *, char *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
- static PyObject *WindowRepr(PyObject *);
|
|
Karsten Hopp |
ffc55f |
- static PyTypeObject WindowType;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
WindowNew(win_T *win)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 1555,1560 ----
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 1803,1809 ****
|
|
Karsten Hopp |
ffc55f |
* to an invalid value. We trap all uses of a window
|
|
Karsten Hopp |
ffc55f |
* object, and reject them if the win_T* field is invalid.
|
|
Karsten Hopp |
ffc55f |
*
|
|
Karsten Hopp |
ffc55f |
! * Python2 and Python3 get different fields and different objects:
|
|
Karsten Hopp |
ffc55f |
* w_python_ref and w_python3_ref fields respectively.
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
--- 1569,1575 ----
|
|
Karsten Hopp |
ffc55f |
* to an invalid value. We trap all uses of a window
|
|
Karsten Hopp |
ffc55f |
* object, and reject them if the win_T* field is invalid.
|
|
Karsten Hopp |
ffc55f |
*
|
|
Karsten Hopp |
ffc55f |
! * Python2 and Python3 get different fields and different objects:
|
|
Karsten Hopp |
ffc55f |
* w_python_ref and w_python3_ref fields respectively.
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 1826,1831 ****
|
|
Karsten Hopp |
ffc55f |
--- 1592,1608 ----
|
|
Karsten Hopp |
ffc55f |
return (PyObject *)(self);
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ static void
|
|
Karsten Hopp |
ffc55f |
+ WindowDestructor(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ WindowObject *this = (WindowObject *)(self);
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (this->win && this->win != INVALID_WINDOW_VALUE)
|
|
Karsten Hopp |
ffc55f |
+ WIN_PYTHON_REF(this->win) = NULL;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ DESTRUCTOR_FINISH(self);
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
WindowAttr(WindowObject *this, char *name)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 1863,1879 ****
|
|
Karsten Hopp |
ffc55f |
return NULL;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static void
|
|
Karsten Hopp |
ffc55f |
- WindowDestructor(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
- {
|
|
Karsten Hopp |
ffc55f |
- WindowObject *this = (WindowObject *)(self);
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- if (this->win && this->win != INVALID_WINDOW_VALUE)
|
|
Karsten Hopp |
ffc55f |
- WIN_PYTHON_REF(this->win) = NULL;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
- DESTRUCTOR_FINISH(self);
|
|
Karsten Hopp |
ffc55f |
- }
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static int
|
|
Karsten Hopp |
ffc55f |
WindowSetattr(PyObject *self, char *name, PyObject *val)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 1640,1645 ----
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 1994,2011 ****
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
/*
|
|
Karsten Hopp |
ffc55f |
! * Window list object - Implementation
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
typedef struct
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
PyObject_HEAD
|
|
Karsten Hopp |
ffc55f |
} WinListObject;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static PyTypeObject WinListType;
|
|
Karsten Hopp |
ffc55f |
- static PySequenceMethods BufListAsSeq;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static PyInt
|
|
Karsten Hopp |
ffc55f |
WinListLength(PyObject *self UNUSED)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 1760,1782 ----
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ static struct PyMethodDef WindowMethods[] = {
|
|
Karsten Hopp |
ffc55f |
+ /* name, function, calling, documentation */
|
|
Karsten Hopp |
ffc55f |
+ { NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
+ };
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
/*
|
|
Karsten Hopp |
ffc55f |
! * Window list object
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ static PyTypeObject WinListType;
|
|
Karsten Hopp |
ffc55f |
+ static PySequenceMethods WinListAsSeq;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
typedef struct
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
PyObject_HEAD
|
|
Karsten Hopp |
ffc55f |
} WinListObject;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyInt
|
|
Karsten Hopp |
ffc55f |
WinListLength(PyObject *self UNUSED)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 2596,2602 ****
|
|
Karsten Hopp |
ffc55f |
* -------------------------------------------
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static int
|
|
Karsten Hopp |
ffc55f |
CheckBuffer(BufferObject *this)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
if (this->buf == INVALID_BUFFER_VALUE)
|
|
Karsten Hopp |
ffc55f |
--- 2367,2379 ----
|
|
Karsten Hopp |
ffc55f |
* -------------------------------------------
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! typedef struct
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! PyObject_HEAD
|
|
Karsten Hopp |
ffc55f |
! buf_T *buf;
|
|
Karsten Hopp |
ffc55f |
! } BufferObject;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static int
|
|
Karsten Hopp |
ffc55f |
CheckBuffer(BufferObject *this)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
if (this->buf == INVALID_BUFFER_VALUE)
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 2737,2746 ****
|
|
Karsten Hopp |
ffc55f |
return Py_None;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! /* Range object - Definitions
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyTypeObject RangeType;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
typedef struct
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 2514,2525 ----
|
|
Karsten Hopp |
ffc55f |
return Py_None;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! /* Range object
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyTypeObject RangeType;
|
|
Karsten Hopp |
ffc55f |
+ static PySequenceMethods RangeAsSeq;
|
|
Karsten Hopp |
ffc55f |
+ static PyMappingMethods RangeAsMapping;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
typedef struct
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 2750,2759 ****
|
|
Karsten Hopp |
ffc55f |
PyInt end;
|
|
Karsten Hopp |
ffc55f |
} RangeObject;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static void RangeDestructor(PyObject *);
|
|
Karsten Hopp |
ffc55f |
- static PySequenceMethods RangeAsSeq;
|
|
Karsten Hopp |
ffc55f |
- static PyMappingMethods RangeAsMapping;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
RangeNew(buf_T *buf, PyInt start, PyInt end)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 2529,2534 ----
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 2785,2806 ****
|
|
Karsten Hopp |
ffc55f |
DESTRUCTOR_FINISH(self);
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static PyTypeObject BufferType;
|
|
Karsten Hopp |
ffc55f |
! static PyObject *BufferRepr(PyObject *);
|
|
Karsten Hopp |
ffc55f |
! static PySequenceMethods BufferAsSeq;
|
|
Karsten Hopp |
ffc55f |
! static PyMappingMethods BufferAsMapping;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static void
|
|
Karsten Hopp |
ffc55f |
! BufferDestructor(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! BufferObject *this = (BufferObject *)(self);
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! if (this->buf && this->buf != INVALID_BUFFER_VALUE)
|
|
Karsten Hopp |
ffc55f |
! BUF_PYTHON_REF(this->buf) = NULL;
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! DESTRUCTOR_FINISH(self);
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
BufferNew(buf_T *buf)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 2560,2642 ----
|
|
Karsten Hopp |
ffc55f |
DESTRUCTOR_FINISH(self);
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static PyInt
|
|
Karsten Hopp |
ffc55f |
! RangeLength(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */
|
|
Karsten Hopp |
ffc55f |
! if (CheckBuffer(((RangeObject *)(self))->buf))
|
|
Karsten Hopp |
ffc55f |
! return -1; /* ??? */
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! return (((RangeObject *)(self))->end - ((RangeObject *)(self))->start + 1);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! RangeItem(PyObject *self, PyInt n)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! return RBItem(((RangeObject *)(self))->buf, n,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->start,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->end);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! RangeSlice(PyObject *self, PyInt lo, PyInt hi)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! return RBSlice(((RangeObject *)(self))->buf, lo, hi,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->start,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->end);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! RangeAppend(PyObject *self, PyObject *args)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! return RBAppend(((RangeObject *)(self))->buf, args,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->start,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->end,
|
|
Karsten Hopp |
ffc55f |
! &((RangeObject *)(self))->end);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! RangeRepr(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! static char repr[100];
|
|
Karsten Hopp |
ffc55f |
! RangeObject *this = (RangeObject *)(self);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (this->buf->buf == INVALID_BUFFER_VALUE)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! vim_snprintf(repr, 100, "<range object (for deleted buffer) at %p>",
|
|
Karsten Hopp |
ffc55f |
! (self));
|
|
Karsten Hopp |
ffc55f |
! return PyString_FromString(repr);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! else
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! char *name = (char *)this->buf->buf->b_fname;
|
|
Karsten Hopp |
ffc55f |
! int len;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (name == NULL)
|
|
Karsten Hopp |
ffc55f |
! name = "";
|
|
Karsten Hopp |
ffc55f |
! len = (int)strlen(name);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (len > 45)
|
|
Karsten Hopp |
ffc55f |
! name = name + (45 - len);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! vim_snprintf(repr, 100, "<range %s%s (%d:%d)>",
|
|
Karsten Hopp |
ffc55f |
! len > 45 ? "..." : "", name,
|
|
Karsten Hopp |
ffc55f |
! this->start, this->end);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! return PyString_FromString(repr);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ static struct PyMethodDef RangeMethods[] = {
|
|
Karsten Hopp |
ffc55f |
+ /* name, function, calling, documentation */
|
|
Karsten Hopp |
ffc55f |
+ {"append", RangeAppend, 1, "Append data to the Vim range" },
|
|
Karsten Hopp |
ffc55f |
+ { NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
+ };
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static PyTypeObject BufferType;
|
|
Karsten Hopp |
ffc55f |
+ static PySequenceMethods BufferAsSeq;
|
|
Karsten Hopp |
ffc55f |
+ static PyMappingMethods BufferAsMapping;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
BufferNew(buf_T *buf)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 2817,2823 ****
|
|
Karsten Hopp |
ffc55f |
* set the buf_T * value to an invalid value (-1?), which
|
|
Karsten Hopp |
ffc55f |
* means we need checks in all access functions... Bah.
|
|
Karsten Hopp |
ffc55f |
*
|
|
Karsten Hopp |
ffc55f |
! * Python2 and Python3 get different fields and different objects:
|
|
Karsten Hopp |
ffc55f |
* b_python_ref and b_python3_ref fields respectively.
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
--- 2653,2659 ----
|
|
Karsten Hopp |
ffc55f |
* set the buf_T * value to an invalid value (-1?), which
|
|
Karsten Hopp |
ffc55f |
* means we need checks in all access functions... Bah.
|
|
Karsten Hopp |
ffc55f |
*
|
|
Karsten Hopp |
ffc55f |
! * Python2 and Python3 get different fields and different objects:
|
|
Karsten Hopp |
ffc55f |
* b_python_ref and b_python3_ref fields respectively.
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 2840,2861 ****
|
|
Karsten Hopp |
ffc55f |
return (PyObject *)(self);
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! BufferAttr(BufferObject *this, char *name)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! if (strcmp(name, "name") == 0)
|
|
Karsten Hopp |
ffc55f |
! return Py_BuildValue("s", this->buf->b_ffname);
|
|
Karsten Hopp |
ffc55f |
! else if (strcmp(name, "number") == 0)
|
|
Karsten Hopp |
ffc55f |
! return Py_BuildValue(Py_ssize_t_fmt, this->buf->b_fnum);
|
|
Karsten Hopp |
ffc55f |
! else if (strcmp(name, "vars") == 0)
|
|
Karsten Hopp |
ffc55f |
! return DictionaryNew(this->buf->b_vars);
|
|
Karsten Hopp |
ffc55f |
! else if (strcmp(name, "options") == 0)
|
|
Karsten Hopp |
ffc55f |
! return OptionsNew(SREQ_BUF, this->buf, (checkfun) CheckBuffer,
|
|
Karsten Hopp |
ffc55f |
! (PyObject *) this);
|
|
Karsten Hopp |
ffc55f |
! else if (strcmp(name,"__members__") == 0)
|
|
Karsten Hopp |
ffc55f |
! return Py_BuildValue("[ssss]", "name", "number", "vars", "options");
|
|
Karsten Hopp |
ffc55f |
! else
|
|
Karsten Hopp |
ffc55f |
! return NULL;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyInt
|
|
Karsten Hopp |
ffc55f |
--- 2676,2690 ----
|
|
Karsten Hopp |
ffc55f |
return (PyObject *)(self);
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static void
|
|
Karsten Hopp |
ffc55f |
! BufferDestructor(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
! BufferObject *this = (BufferObject *)(self);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (this->buf && this->buf != INVALID_BUFFER_VALUE)
|
|
Karsten Hopp |
ffc55f |
! BUF_PYTHON_REF(this->buf) = NULL;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! DESTRUCTOR_FINISH(self);
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyInt
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 2883,2888 ****
|
|
Karsten Hopp |
ffc55f |
--- 2712,2735 ----
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
+ BufferAttr(BufferObject *this, char *name)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ if (strcmp(name, "name") == 0)
|
|
Karsten Hopp |
ffc55f |
+ return Py_BuildValue("s", this->buf->b_ffname);
|
|
Karsten Hopp |
ffc55f |
+ else if (strcmp(name, "number") == 0)
|
|
Karsten Hopp |
ffc55f |
+ return Py_BuildValue(Py_ssize_t_fmt, this->buf->b_fnum);
|
|
Karsten Hopp |
ffc55f |
+ else if (strcmp(name, "vars") == 0)
|
|
Karsten Hopp |
ffc55f |
+ return DictionaryNew(this->buf->b_vars);
|
|
Karsten Hopp |
ffc55f |
+ else if (strcmp(name, "options") == 0)
|
|
Karsten Hopp |
ffc55f |
+ return OptionsNew(SREQ_BUF, this->buf, (checkfun) CheckBuffer,
|
|
Karsten Hopp |
ffc55f |
+ (PyObject *) this);
|
|
Karsten Hopp |
ffc55f |
+ else if (strcmp(name,"__members__") == 0)
|
|
Karsten Hopp |
ffc55f |
+ return Py_BuildValue("[ssss]", "name", "number", "vars", "options");
|
|
Karsten Hopp |
ffc55f |
+ else
|
|
Karsten Hopp |
ffc55f |
+ return NULL;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static PyObject *
|
|
Karsten Hopp |
ffc55f |
BufferAppend(PyObject *self, PyObject *args)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
return RBAppend((BufferObject *)(self), args, 1,
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 2985,3073 ****
|
|
Karsten Hopp |
ffc55f |
{ NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
};
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! RangeAppend(PyObject *self, PyObject *args)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! return RBAppend(((RangeObject *)(self))->buf, args,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->start,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->end,
|
|
Karsten Hopp |
ffc55f |
! &((RangeObject *)(self))->end);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyInt
|
|
Karsten Hopp |
ffc55f |
! RangeLength(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */
|
|
Karsten Hopp |
ffc55f |
! if (CheckBuffer(((RangeObject *)(self))->buf))
|
|
Karsten Hopp |
ffc55f |
! return -1; /* ??? */
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! return (((RangeObject *)(self))->end - ((RangeObject *)(self))->start + 1);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! RangeItem(PyObject *self, PyInt n)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! return RBItem(((RangeObject *)(self))->buf, n,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->start,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->end);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! RangeRepr(PyObject *self)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! static char repr[100];
|
|
Karsten Hopp |
ffc55f |
! RangeObject *this = (RangeObject *)(self);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (this->buf->buf == INVALID_BUFFER_VALUE)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! vim_snprintf(repr, 100, "<range object (for deleted buffer) at %p>",
|
|
Karsten Hopp |
ffc55f |
! (self));
|
|
Karsten Hopp |
ffc55f |
! return PyString_FromString(repr);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! else
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! char *name = (char *)this->buf->buf->b_fname;
|
|
Karsten Hopp |
ffc55f |
! int len;
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (name == NULL)
|
|
Karsten Hopp |
ffc55f |
! name = "";
|
|
Karsten Hopp |
ffc55f |
! len = (int)strlen(name);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! if (len > 45)
|
|
Karsten Hopp |
ffc55f |
! name = name + (45 - len);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! vim_snprintf(repr, 100, "<range %s%s (%d:%d)>",
|
|
Karsten Hopp |
ffc55f |
! len > 45 ? "..." : "", name,
|
|
Karsten Hopp |
ffc55f |
! this->start, this->end);
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! return PyString_FromString(repr);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static PyObject *
|
|
Karsten Hopp |
ffc55f |
! RangeSlice(PyObject *self, PyInt lo, PyInt hi)
|
|
Karsten Hopp |
ffc55f |
! {
|
|
Karsten Hopp |
ffc55f |
! return RBSlice(((RangeObject *)(self))->buf, lo, hi,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->start,
|
|
Karsten Hopp |
ffc55f |
! ((RangeObject *)(self))->end);
|
|
Karsten Hopp |
ffc55f |
! }
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! /*
|
|
Karsten Hopp |
ffc55f |
! * Line range object - Definitions
|
|
Karsten Hopp |
ffc55f |
! */
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! static struct PyMethodDef RangeMethods[] = {
|
|
Karsten Hopp |
ffc55f |
! /* name, function, calling, documentation */
|
|
Karsten Hopp |
ffc55f |
! {"append", RangeAppend, 1, "Append data to the Vim range" },
|
|
Karsten Hopp |
ffc55f |
! { NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
! };
|
|
Karsten Hopp |
ffc55f |
!
|
|
Karsten Hopp |
ffc55f |
! /* Current items object - Implementation
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static PyInt RangeStart;
|
|
Karsten Hopp |
ffc55f |
- static PyInt RangeEnd;
|
|
Karsten Hopp |
ffc55f |
-
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
CurrentGetattr(PyObject *self UNUSED, char *name)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
--- 2832,2840 ----
|
|
Karsten Hopp |
ffc55f |
{ NULL, NULL, 0, NULL }
|
|
Karsten Hopp |
ffc55f |
};
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
! /* Current items object
|
|
Karsten Hopp |
ffc55f |
*/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static PyObject *
|
|
Karsten Hopp |
ffc55f |
CurrentGetattr(PyObject *self UNUSED, char *name)
|
|
Karsten Hopp |
ffc55f |
{
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 3147,3152 ****
|
|
Karsten Hopp |
ffc55f |
--- 2914,3131 ----
|
|
Karsten Hopp |
ffc55f |
return 0;
|
|
Karsten Hopp |
ffc55f |
}
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
+ static int
|
|
Karsten Hopp |
ffc55f |
+ pydict_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ dict_T *d;
|
|
Karsten Hopp |
ffc55f |
+ char_u *key;
|
|
Karsten Hopp |
ffc55f |
+ dictitem_T *di;
|
|
Karsten Hopp |
ffc55f |
+ PyObject *keyObject;
|
|
Karsten Hopp |
ffc55f |
+ PyObject *valObject;
|
|
Karsten Hopp |
ffc55f |
+ Py_ssize_t iter = 0;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ d = dict_alloc();
|
|
Karsten Hopp |
ffc55f |
+ if (d == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ tv->v_type = VAR_DICT;
|
|
Karsten Hopp |
ffc55f |
+ tv->vval.v_dict = d;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ while (PyDict_Next(obj, &iter, &keyObject, &valObject))
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ DICTKEY_DECL
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (keyObject == NULL)
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ if (valObject == NULL)
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ DICTKEY_GET_NOTEMPTY(-1)
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ di = dictitem_alloc(key);
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ DICTKEY_UNREF
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (di == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ di->di_tv.v_lock = 0;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ vim_free(di);
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ if (dict_add(d, di) == FAIL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ vim_free(di);
|
|
Karsten Hopp |
ffc55f |
+ PyErr_SetVim(_("failed to add key to dictionary"));
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ return 0;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static int
|
|
Karsten Hopp |
ffc55f |
+ pymap_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ dict_T *d;
|
|
Karsten Hopp |
ffc55f |
+ char_u *key;
|
|
Karsten Hopp |
ffc55f |
+ dictitem_T *di;
|
|
Karsten Hopp |
ffc55f |
+ PyObject *list;
|
|
Karsten Hopp |
ffc55f |
+ PyObject *litem;
|
|
Karsten Hopp |
ffc55f |
+ PyObject *keyObject;
|
|
Karsten Hopp |
ffc55f |
+ PyObject *valObject;
|
|
Karsten Hopp |
ffc55f |
+ Py_ssize_t lsize;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ d = dict_alloc();
|
|
Karsten Hopp |
ffc55f |
+ if (d == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ tv->v_type = VAR_DICT;
|
|
Karsten Hopp |
ffc55f |
+ tv->vval.v_dict = d;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ list = PyMapping_Items(obj);
|
|
Karsten Hopp |
ffc55f |
+ if (list == NULL)
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ lsize = PyList_Size(list);
|
|
Karsten Hopp |
ffc55f |
+ while (lsize--)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ DICTKEY_DECL
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ litem = PyList_GetItem(list, lsize);
|
|
Karsten Hopp |
ffc55f |
+ if (litem == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ keyObject = PyTuple_GetItem(litem, 0);
|
|
Karsten Hopp |
ffc55f |
+ if (keyObject == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ DICTKEY_GET_NOTEMPTY(-1)
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ valObject = PyTuple_GetItem(litem, 1);
|
|
Karsten Hopp |
ffc55f |
+ if (valObject == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ di = dictitem_alloc(key);
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ DICTKEY_UNREF
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (di == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ di->di_tv.v_lock = 0;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (_ConvertFromPyObject(valObject, &di->di_tv, lookupDict) == -1)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ vim_free(di);
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ if (dict_add(d, di) == FAIL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ vim_free(di);
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
+ PyErr_SetVim(_("failed to add key to dictionary"));
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(litem);
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(list);
|
|
Karsten Hopp |
ffc55f |
+ return 0;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static int
|
|
Karsten Hopp |
ffc55f |
+ pyseq_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ list_T *l;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ l = list_alloc();
|
|
Karsten Hopp |
ffc55f |
+ if (l == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ tv->v_type = VAR_LIST;
|
|
Karsten Hopp |
ffc55f |
+ tv->vval.v_list = l;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (list_py_concat(l, obj, lookupDict) == -1)
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ return 0;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ static int
|
|
Karsten Hopp |
ffc55f |
+ pyiter_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyObject *iterator = PyObject_GetIter(obj);
|
|
Karsten Hopp |
ffc55f |
+ PyObject *item;
|
|
Karsten Hopp |
ffc55f |
+ list_T *l;
|
|
Karsten Hopp |
ffc55f |
+ listitem_T *li;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ l = list_alloc();
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (l == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ tv->vval.v_list = l;
|
|
Karsten Hopp |
ffc55f |
+ tv->v_type = VAR_LIST;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (iterator == NULL)
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ while ((item = PyIter_Next(obj)))
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ li = listitem_alloc();
|
|
Karsten Hopp |
ffc55f |
+ if (li == NULL)
|
|
Karsten Hopp |
ffc55f |
+ {
|
|
Karsten Hopp |
ffc55f |
+ PyErr_NoMemory();
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+ li->li_tv.v_lock = 0;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ if (_ConvertFromPyObject(item, &li->li_tv, lookupDict) == -1)
|
|
Karsten Hopp |
ffc55f |
+ return -1;
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ list_append(l, li);
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(item);
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
+ Py_DECREF(iterator);
|
|
Karsten Hopp |
ffc55f |
+ return 0;
|
|
Karsten Hopp |
ffc55f |
+ }
|
|
Karsten Hopp |
ffc55f |
+
|
|
Karsten Hopp |
ffc55f |
typedef int (*pytotvfunc)(PyObject *, typval_T *, PyObject *);
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
static int
|
|
Karsten Hopp |
ffc55f |
*** ../vim-7.3.940/src/if_python.c 2013-05-12 18:44:44.000000000 +0200
|
|
Karsten Hopp |
ffc55f |
--- src/if_python.c 2013-05-12 19:34:35.000000000 +0200
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 1019,1027 ****
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
#define BufferType_Check(obj) ((obj)->ob_type == &BufferType)
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
- static PyInt BufferLength(PyObject *);
|
|
Karsten Hopp |
ffc55f |
- static PyObject *BufferItem(PyObject *, PyInt);
|
|
Karsten Hopp |
ffc55f |
- static PyObject *BufferSlice(PyObject *, PyInt, PyInt);
|
|
Karsten Hopp |
ffc55f |
static PyInt BufferAssItem(PyObject *, PyInt, PyObject *);
|
|
Karsten Hopp |
ffc55f |
static PyInt BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *);
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
--- 1019,1024 ----
|
|
Karsten Hopp |
ffc55f |
*** ../vim-7.3.940/src/version.c 2013-05-12 19:30:27.000000000 +0200
|
|
Karsten Hopp |
ffc55f |
--- src/version.c 2013-05-12 19:37:08.000000000 +0200
|
|
Karsten Hopp |
ffc55f |
***************
|
|
Karsten Hopp |
ffc55f |
*** 730,731 ****
|
|
Karsten Hopp |
ffc55f |
--- 730,733 ----
|
|
Karsten Hopp |
ffc55f |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
ffc55f |
+ /**/
|
|
Karsten Hopp |
ffc55f |
+ 941,
|
|
Karsten Hopp |
ffc55f |
/**/
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
--
|
|
Karsten Hopp |
ffc55f |
ARTHUR: Well, I AM king...
|
|
Karsten Hopp |
ffc55f |
DENNIS: Oh king, eh, very nice. An' how'd you get that, eh? By exploitin'
|
|
Karsten Hopp |
ffc55f |
the workers -- by 'angin' on to outdated imperialist dogma which
|
|
Karsten Hopp |
ffc55f |
perpetuates the economic an' social differences in our society! If
|
|
Karsten Hopp |
ffc55f |
there's ever going to be any progress--
|
|
Karsten Hopp |
ffc55f |
The Quest for the Holy Grail (Monty Python)
|
|
Karsten Hopp |
ffc55f |
|
|
Karsten Hopp |
ffc55f |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
ffc55f |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
ffc55f |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
ffc55f |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|